An open source design system that's fully customizable and agent ready
TypeScript
docs(core): document width prop across 17 input component docs (#4163) (#4313)
Ojas Mutrejaee63c6e8ab04
diff --git a/.changeset/input-family-width-prop-docs-tjsk.md b/.changeset/input-family-width-prop-docs-tjsk.mdnew file mode 100644index 0000000000..aa52a347bc--- /dev/null+++ b/.changeset/input-family-width-prop-docs-tjsk.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[docs] document `width` prop across 17 input component doc files (#4163)++@HelloOjasMutrejadiff --git a/packages/core/src/CheckboxInput/CheckboxInput.doc.mjs b/packages/core/src/CheckboxInput/CheckboxInput.doc.mjsindex 9a4780551c..f41ebf37c8 100644--- a/packages/core/src/CheckboxInput/CheckboxInput.doc.mjs+++ b/packages/core/src/CheckboxInput/CheckboxInput.doc.mjs@@ -121,6 +121,12 @@ export const docs = {description:'Status indicator. Displays a colored message box below the checkbox and sets aria-invalid for errors.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },],theming: {targets: [diff --git a/packages/core/src/CheckboxList/CheckboxList.doc.mjs b/packages/core/src/CheckboxList/CheckboxList.doc.mjsindex f5a7ddf4c9..19ff13869f 100644--- a/packages/core/src/CheckboxList/CheckboxList.doc.mjs+++ b/packages/core/src/CheckboxList/CheckboxList.doc.mjs@@ -88,6 +88,12 @@ export const docs = {type: "{type: 'warning' | 'error' | 'success', message?: string}",description: 'Status indicator ({ type, message }).',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/DateInput/DateInput.doc.mjs b/packages/core/src/DateInput/DateInput.doc.mjsindex 2bf3207939..0cf12c71e4 100644--- a/packages/core/src/DateInput/DateInput.doc.mjs+++ b/packages/core/src/DateInput/DateInput.doc.mjs@@ -149,6 +149,12 @@ export const docs = {"How the committed date value is displayed. Named values are reused from Timestamp's format vocabulary: 'date' shows 'Mar 21, 2026', 'date_long' shows 'March 21, 2026', 'date_weekday' shows 'Wed, Mar 21, 2026', 'system_date' shows '2026-03-21'. A function receives the ISO value and returns a custom string. Applies only to the committed value, never to text being typed.",default: "'date_long'",},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/DateRangeInput/DateRangeInput.doc.mjs b/packages/core/src/DateRangeInput/DateRangeInput.doc.mjsindex 4feb09fcff..9972e32c4f 100644--- a/packages/core/src/DateRangeInput/DateRangeInput.doc.mjs+++ b/packages/core/src/DateRangeInput/DateRangeInput.doc.mjs@@ -145,6 +145,12 @@ export const docs = {description: 'Number of months in the calendar.',default: '2',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/DateTimeInput/DateTimeInput.doc.mjs b/packages/core/src/DateTimeInput/DateTimeInput.doc.mjsindex 739601ae58..ba35315dff 100644--- a/packages/core/src/DateTimeInput/DateTimeInput.doc.mjs+++ b/packages/core/src/DateTimeInput/DateTimeInput.doc.mjs@@ -173,6 +173,12 @@ export const docs = {description: 'Number of months displayed simultaneously in the calendar.',default: '1',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/FileInput/FileInput.doc.mjs b/packages/core/src/FileInput/FileInput.doc.mjsindex 041c6d9abf..6bb46fbd9f 100644--- a/packages/core/src/FileInput/FileInput.doc.mjs+++ b/packages/core/src/FileInput/FileInput.doc.mjs@@ -132,6 +132,12 @@ export const docs = {description:'Tooltip text displayed in an info icon at the end of the label.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },],theming: {targets: [diff --git a/packages/core/src/MultiSelector/MultiSelector.doc.mjs b/packages/core/src/MultiSelector/MultiSelector.doc.mjsindex d51619e4af..2239c882e9 100644--- a/packages/core/src/MultiSelector/MultiSelector.doc.mjs+++ b/packages/core/src/MultiSelector/MultiSelector.doc.mjs@@ -173,6 +173,12 @@ export const docs = {description:'Custom render function for each selectable option in the dropdown. Not called for dividers, sections, or the select-all row.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/NumberInput/NumberInput.doc.mjs b/packages/core/src/NumberInput/NumberInput.doc.mjsindex bd04ade4b4..72dd7e5d52 100644--- a/packages/core/src/NumberInput/NumberInput.doc.mjs+++ b/packages/core/src/NumberInput/NumberInput.doc.mjs@@ -145,6 +145,12 @@ export const docs = {type: 'string',description: 'HTML autocomplete attribute.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'hasAutoFocus',type: 'boolean',diff --git a/packages/core/src/RadioList/RadioList.doc.mjs b/packages/core/src/RadioList/RadioList.doc.mjsindex c49f9160a7..dfbb4a7683 100644--- a/packages/core/src/RadioList/RadioList.doc.mjs+++ b/packages/core/src/RadioList/RadioList.doc.mjs@@ -114,6 +114,12 @@ export const docs = {type: 'string',description: 'Tooltip text for an info icon next to the label.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/Selector/Selector.doc.mjs b/packages/core/src/Selector/Selector.doc.mjsindex b1c37456f1..aea837c882 100644--- a/packages/core/src/Selector/Selector.doc.mjs+++ b/packages/core/src/Selector/Selector.doc.mjs@@ -143,6 +143,12 @@ export const docs = {description:'Custom render function for each selectable option in the dropdown. Use this instead of JSX children; dividers and sections are rendered by the selector.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/Slider/Slider.doc.mjs b/packages/core/src/Slider/Slider.doc.mjsindex 0aa701354e..7503443ed2 100644--- a/packages/core/src/Slider/Slider.doc.mjs+++ b/packages/core/src/Slider/Slider.doc.mjs@@ -141,6 +141,12 @@ export const docs = {type: 'string',description: 'Tooltip text for an info icon displayed next to the label.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/Switch/Switch.doc.mjs b/packages/core/src/Switch/Switch.doc.mjsindex ce5dd83c17..86fdde7998 100644--- a/packages/core/src/Switch/Switch.doc.mjs+++ b/packages/core/src/Switch/Switch.doc.mjs@@ -144,6 +144,12 @@ export const docs = {'Spacing behavior between label and switch. "hug" places them next to each other; "spread" pushes them to opposite ends of the container (full width). "default" is a deprecated alias for "hug".',default: "'hug'",},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },],theming: {targets: [diff --git a/packages/core/src/TextArea/TextArea.doc.mjs b/packages/core/src/TextArea/TextArea.doc.mjsindex af7bbc6637..1f53cc1490 100644--- a/packages/core/src/TextArea/TextArea.doc.mjs+++ b/packages/core/src/TextArea/TextArea.doc.mjs@@ -154,6 +154,12 @@ export const docs = {description:'HTML name attribute for the textarea element, useful for form submissions.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'onFocus',type: '(e: FocusEvent<HTMLTextAreaElement>) => void',diff --git a/packages/core/src/TextInput/TextInput.doc.mjs b/packages/core/src/TextInput/TextInput.doc.mjsindex 837cd2ff8f..c65c1ed566 100644--- a/packages/core/src/TextInput/TextInput.doc.mjs+++ b/packages/core/src/TextInput/TextInput.doc.mjs@@ -140,6 +140,12 @@ export const docs = {description:'The HTML name attribute for the input, useful for form submissions.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },],theming: {targets: [diff --git a/packages/core/src/TimeInput/TimeInput.doc.mjs b/packages/core/src/TimeInput/TimeInput.doc.mjsindex 7dcd087e06..65744c0851 100644--- a/packages/core/src/TimeInput/TimeInput.doc.mjs+++ b/packages/core/src/TimeInput/TimeInput.doc.mjs@@ -242,6 +242,12 @@ export const docs = {description:'Tooltip text rendered as an info icon at the end of the label row.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/Tokenizer/Tokenizer.doc.mjs b/packages/core/src/Tokenizer/Tokenizer.doc.mjsindex 71606ee3e3..6b3201f737 100644--- a/packages/core/src/Tokenizer/Tokenizer.doc.mjs+++ b/packages/core/src/Tokenizer/Tokenizer.doc.mjs@@ -192,7 +192,14 @@ export const docs = {{name: 'handleRef',type: 'React.Ref<TokenizerHandle>',- description: 'Imperative handle for focus() and blur() control.',+ description:+ 'Imperative handle exposing focusInput(), focusFirstToken(), focusLastToken(), clearInput(), and selectAll().',+ },+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',},{name: 'xstyle',diff --git a/packages/core/src/Typeahead/Typeahead.doc.mjs b/packages/core/src/Typeahead/Typeahead.doc.mjsindex 8b4ef430e0..ebe3e1f440 100644--- a/packages/core/src/Typeahead/Typeahead.doc.mjs+++ b/packages/core/src/Typeahead/Typeahead.doc.mjs@@ -165,6 +165,12 @@ export const docs = {type: '(isOpen: boolean) => void',description: 'Callback when the dropdown opens or closes.',},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ 'Width of the field (number = pixels, string used as-is, e.g. "100%"). Sizes the whole field (label, control, and status) so they stay aligned.',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/__tests__/inputWidthContract.test.tsx b/packages/core/src/__tests__/inputWidthContract.test.tsxnew file mode 100644index 0000000000..0b8312f360--- /dev/null+++ b/packages/core/src/__tests__/inputWidthContract.test.tsx@@ -0,0 +1,62 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, it, expect} from 'vitest';++import {docs as CheckboxInputDocs} from '../CheckboxInput/CheckboxInput.doc.mjs';+import {docs as CheckboxListDocs} from '../CheckboxList/CheckboxList.doc.mjs';+import {docs as DateInputDocs} from '../DateInput/DateInput.doc.mjs';+import {docs as DateRangeInputDocs} from '../DateRangeInput/DateRangeInput.doc.mjs';+import {docs as DateTimeInputDocs} from '../DateTimeInput/DateTimeInput.doc.mjs';+import {docs as FileInputDocs} from '../FileInput/FileInput.doc.mjs';+import {docs as MultiSelectorDocs} from '../MultiSelector/MultiSelector.doc.mjs';+import {docs as NumberInputDocs} from '../NumberInput/NumberInput.doc.mjs';+import {docs as RadioListDocs} from '../RadioList/RadioList.doc.mjs';+import {docs as SelectorDocs} from '../Selector/Selector.doc.mjs';+import {docs as SliderDocs} from '../Slider/Slider.doc.mjs';+import {docs as SwitchDocs} from '../Switch/Switch.doc.mjs';+import {docs as TextAreaDocs} from '../TextArea/TextArea.doc.mjs';+import {docs as TextInputDocs} from '../TextInput/TextInput.doc.mjs';+import {docs as TimeInputDocs} from '../TimeInput/TimeInput.doc.mjs';+import {docs as TokenizerDocs} from '../Tokenizer/Tokenizer.doc.mjs';+import {docs as TypeaheadDocs} from '../Typeahead/Typeahead.doc.mjs';++const inputDocsSuite = [+ {name: 'CheckboxInput', docs: CheckboxInputDocs},+ {name: 'CheckboxList', docs: CheckboxListDocs},+ {name: 'DateInput', docs: DateInputDocs},+ {name: 'DateRangeInput', docs: DateRangeInputDocs},+ {name: 'DateTimeInput', docs: DateTimeInputDocs},+ {name: 'FileInput', docs: FileInputDocs},+ {name: 'MultiSelector', docs: MultiSelectorDocs},+ {name: 'NumberInput', docs: NumberInputDocs},+ {name: 'RadioList', docs: RadioListDocs},+ {name: 'Selector', docs: SelectorDocs},+ {name: 'Slider', docs: SliderDocs},+ {name: 'Switch', docs: SwitchDocs},+ {name: 'TextArea', docs: TextAreaDocs},+ {name: 'TextInput', docs: TextInputDocs},+ {name: 'TimeInput', docs: TimeInputDocs},+ {name: 'Tokenizer', docs: TokenizerDocs},+ {name: 'Typeahead', docs: TypeaheadDocs},+];++describe('Input Family width Prop Contract (#4163)', () => {+ inputDocsSuite.forEach(({name, docs}) => {+ it(`documents the width prop for ${name}`, () => {+ const propsList = (docs.props || docs.components?.[0]?.props) as {+ name: string;+ type: string;+ }[];+ expect(+ propsList,+ `${name}.doc.mjs must expose a props array`,+ ).toBeDefined();+ const widthProp = propsList.find(p => p.name === 'width');+ expect(+ widthProp,+ `${name}.doc.mjs must document the width prop`,+ ).toBeDefined();+ expect(widthProp?.type).toBe('SizeValue');+ });+ });+});diff --git a/packages/core/src/doc-mjs.d.ts b/packages/core/src/doc-mjs.d.tsnew file mode 100644index 0000000000..9bea479944--- /dev/null+++ b/packages/core/src/doc-mjs.d.ts@@ -0,0 +1,19 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file Ambient module declaration for `*.doc.mjs` imports.+ *+ * Component contract tests (packages/core/src/__tests__/*Contract.test.tsx)+ * import `{Name}.doc.mjs` files directly to assert their documented props+ * stay in sync with the component's real API. Without this declaration,+ * TypeScript has no way to type a `.mjs` import and fails with+ * TS7016 ("Could not find a declaration file for module").+ */++declare module '*.doc.mjs' {+ import type {ComponentDoc, TranslationDoc} from './docs-types';++ export const docs: ComponentDoc;+ export const docsZh: ComponentDoc;+ export const docsDense: TranslationDoc;+}