From 07fca0875d34165a98713c616b9ce8d28832cde0 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Tue, 15 Mar 2022 18:51:39 +0900 Subject: [PATCH 01/15] BaseControl: Change file extensions to typescript --- packages/components/src/base-control/{index.js => index.tsx} | 0 .../components/src/base-control/stories/{index.js => index.tsx} | 0 .../styles/{base-control-styles.js => base-control-styles.ts} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename packages/components/src/base-control/{index.js => index.tsx} (100%) rename packages/components/src/base-control/stories/{index.js => index.tsx} (100%) rename packages/components/src/base-control/styles/{base-control-styles.js => base-control-styles.ts} (100%) diff --git a/packages/components/src/base-control/index.js b/packages/components/src/base-control/index.tsx similarity index 100% rename from packages/components/src/base-control/index.js rename to packages/components/src/base-control/index.tsx diff --git a/packages/components/src/base-control/stories/index.js b/packages/components/src/base-control/stories/index.tsx similarity index 100% rename from packages/components/src/base-control/stories/index.js rename to packages/components/src/base-control/stories/index.tsx diff --git a/packages/components/src/base-control/styles/base-control-styles.js b/packages/components/src/base-control/styles/base-control-styles.ts similarity index 100% rename from packages/components/src/base-control/styles/base-control-styles.js rename to packages/components/src/base-control/styles/base-control-styles.ts From caf979dc0c1d75290f71749978d873980b75d269 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Tue, 15 Mar 2022 23:30:32 +0900 Subject: [PATCH 02/15] Convert types --- .../components/src/base-control/index.tsx | 71 ++++++++++--------- packages/components/src/base-control/types.ts | 51 +++++++++++++ 2 files changed, 90 insertions(+), 32 deletions(-) create mode 100644 packages/components/src/base-control/types.ts diff --git a/packages/components/src/base-control/index.tsx b/packages/components/src/base-control/index.tsx index a8c19457d13644..4d6721fdea23bf 100644 --- a/packages/components/src/base-control/index.tsx +++ b/packages/components/src/base-control/index.tsx @@ -2,11 +2,13 @@ * External dependencies */ import classnames from 'classnames'; +import type { FunctionComponent } from 'react'; /** * Internal dependencies */ import { VisuallyHidden } from '../visually-hidden'; +import type { BaseControlProps, BaseControlVisualLabelProps } from './types'; import { Wrapper, StyledField, @@ -16,35 +18,29 @@ import { } from './styles/base-control-styles'; /** - * @typedef Props - * @property {boolean} [__nextHasNoMarginBottom] Start opting into the new margin-free styles that will become the default in a future version. - * @property {string} [id] The id of the element to which labels and help text are being generated. - * That element should be passed as a child. - * @property {import('react').ReactNode} help If this property is added, a help text will be - * generated using help property as the content. - * @property {import('react').ReactNode} [label] If this property is added, a label will be generated - * using label property as the content. - * @property {boolean} [hideLabelFromVision] If true, the label will only be visible to screen readers. - * @property {string} [className] The class that will be added with "components-base-control" to the - * classes of the wrapper div. If no className is passed only - * components-base-control is used. - * @property {import('react').ReactNode} [children] The content to be displayed within - * the BaseControl. + * `BaseControl` is a component used to generate labels and help text for components handling user inputs. + * + * @example + * // Render a `BaseControl` for a textarea input + * import { BaseControl } from '@wordpress/components'; + * + * const MyBaseControl = () => ( + * + *