An open source design system that's fully customizable and agent ready
TypeScript
feat(inputs)!: FR10 prop targets for TextInput, TextArea, NumberInput, FileInput (#7336)
Cindy Zhang936b1f73a039
diff --git a/.changeset/field-input-styling-text.md b/.changeset/field-input-styling-text.mdnew file mode 100644index 0000000000..c6d986bf85--- /dev/null+++ b/.changeset/field-input-styling-text.md@@ -0,0 +1,12 @@+---+'@astryxdesign/core': minor+'@astryxdesign/cli': minor+---++[breaking] TextInput, TextArea, NumberInput, and FileInput no longer accept root `xstyle`, `className`, or `style`. Style the field with `containerXstyle`/`containerClassName`/`containerStyle` (the Field box; no effect inside InputGroup or a `horizontal-labels` FormLayout) and the visual control box with `controlXstyle`/`controlClassName`/`controlStyle`. Base props such as `ref`, `id`, `data-*`, `aria-*`, and DOM handlers reach the native control, and a caller `id` is now honored there. CLI templates use the new props.++Migration: rename root `xstyle`/`className`/`style` on these components to `controlXstyle`/`controlClassName`/`controlStyle`, which style the same element as before. `astryx upgrade` rewrites JSX usage; styling passed through a wrapper's own props or a spread is not rewritten and now fails type-checking at that callsite, so rename it there. Untyped callers get a development warning and the value is ignored. Not rewritten by the codemod: a caller `id` used to be replaced by a generated one and now reaches the native control (the label stays associated), so remove an `id` you passed but relied on being ignored. Other base props already reached the native control and are unchanged.++From #5656 by @harjothkhara.++@cixzhangdiff --git a/apps/docsite/src/app/playground/PlaygroundClient.tsx b/apps/docsite/src/app/playground/PlaygroundClient.tsxindex bec49a1118..bd6ced3b53 100644--- a/apps/docsite/src/app/playground/PlaygroundClient.tsx+++ b/apps/docsite/src/app/playground/PlaygroundClient.tsx@@ -1176,7 +1176,7 @@ export function PlaygroundClient() {isDisabledvalue={shareUrl}onChange={() => {}}- xstyle={s.shareInput}+ controlXstyle={s.shareInput}/><Buttonlabel={copied ? 'Copied' : 'Copy URL'}@@ -1208,7 +1208,7 @@ export function PlaygroundClient() {onChange={v =>setThemeName(v.replace(/[\s-]/g, ''))}- xstyle={s.shareInput}+ controlXstyle={s.shareInput}/><Buttonlabel="Download theme"diff --git a/apps/docsite/src/app/playground/propertyEditor/PropertyEditor.tsx b/apps/docsite/src/app/playground/propertyEditor/PropertyEditor.tsxindex 18ed0391af..bb91b22698 100644--- a/apps/docsite/src/app/playground/propertyEditor/PropertyEditor.tsx+++ b/apps/docsite/src/app/playground/propertyEditor/PropertyEditor.tsx@@ -98,7 +98,7 @@ function LiveNumberControl({onInput={liveNumber.handleInput}onBlur={liveNumber.handleBlur}onKeyDown={liveNumber.handleKeyDown}- xstyle={s.inputControl}+ controlXstyle={s.inputControl}/>);}@@ -218,7 +218,7 @@ function PropRow({prop, instance, code, onCodeChange}: PropRowProps) {placeholder="value"value={value}onChange={next => commit('string', next)}- xstyle={s.inputControl}+ controlXstyle={s.inputControl}/>);} else {diff --git a/apps/docsite/src/app/playground/themeEditor/ColorSwatch.tsx b/apps/docsite/src/app/playground/themeEditor/ColorSwatch.tsxindex 99ec76a996..9b6f335505 100644--- a/apps/docsite/src/app/playground/themeEditor/ColorSwatch.tsx+++ b/apps/docsite/src/app/playground/themeEditor/ColorSwatch.tsx@@ -128,7 +128,7 @@ export function ColorSwatch({onChange(tokenName, newValue);}}}- xstyle={s.input}+ controlXstyle={s.input}/>}/>diff --git a/apps/docsite/src/app/playground/themeEditor/RawTokensPanel.tsx b/apps/docsite/src/app/playground/themeEditor/RawTokensPanel.tsxindex e71f661bfb..fe498206c8 100644--- a/apps/docsite/src/app/playground/themeEditor/RawTokensPanel.tsx+++ b/apps/docsite/src/app/playground/themeEditor/RawTokensPanel.tsx@@ -136,7 +136,7 @@ function SpacingEditor({tokenName, value, onChange}: EditorProps) {value={value}onChange={val => onChange(tokenName, val)}size="sm"- xstyle={s.inputSm}+ controlXstyle={s.inputSm}/>}/>@@ -157,7 +157,7 @@ function RadiusEditor({tokenName, value, onChange}: EditorProps) {value={value}onChange={val => onChange(tokenName, val)}size="sm"- xstyle={s.inputSm}+ controlXstyle={s.inputSm}/>}/>@@ -192,7 +192,7 @@ function TypographyEditor({tokenName, value, onChange}: EditorProps) {value={value}onChange={val => onChange(tokenName, val)}size="sm"- xstyle={s.inputLg}+ controlXstyle={s.inputLg}/>}/>@@ -210,7 +210,7 @@ function GenericEditor({tokenName, value, onChange}: EditorProps) {value={value}onChange={val => onChange(tokenName, val)}size="sm"- xstyle={s.inputLg}+ controlXstyle={s.inputLg}/>}/>diff --git a/apps/sandbox/src/app/(sandbox)/pages/textarea-counter/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/textarea-counter/page.tsxindex 410bfbd258..41b4bae154 100644--- a/apps/sandbox/src/app/(sandbox)/pages/textarea-counter/page.tsx+++ b/apps/sandbox/src/app/(sandbox)/pages/textarea-counter/page.tsx@@ -259,7 +259,7 @@ function InsideBottomRight({value, onChange, max, status}: VariantProps) {rows={3}width="100%"placeholder="Write a description..."- xstyle={styles.overlayTextareaPad}+ controlXstyle={styles.overlayTextareaPad}/><div {...stylex.props(styles.overlayCounter)}><Counter length={value.length} max={max} />diff --git a/packages/cli/assets/templates/pages/canvas-editor/page.tsx b/packages/cli/assets/templates/pages/canvas-editor/page.tsxindex 1d093f9ac8..aac9b86def 100644--- a/packages/cli/assets/templates/pages/canvas-editor/page.tsx+++ b/packages/cli/assets/templates/pages/canvas-editor/page.tsx@@ -1153,7 +1153,7 @@ function FilterRow({value={value}onChange={onChange}isWheelEnabled={false}- xstyle={styles.filterValue}+ controlXstyle={styles.filterValue}/></InspectorRow>);diff --git a/packages/cli/assets/templates/pages/form-wizard-vertical/page.tsx b/packages/cli/assets/templates/pages/form-wizard-vertical/page.tsxindex f14aa1b2f6..1bfcb6f5ad 100644--- a/packages/cli/assets/templates/pages/form-wizard-vertical/page.tsx+++ b/packages/cli/assets/templates/pages/form-wizard-vertical/page.tsx@@ -871,7 +871,7 @@ export default function FormWizardVerticalPage() {ref={fieldRefs.cover}label="Cover image"isLabelHidden- style={hasCover ? dropzoneFill : undefined}+ controlStyle={hasCover ? dropzoneFill : undefined}mode="dropzone"accept="image/png,image/jpeg"maxSize={5 * 1024 * 1024}diff --git a/packages/cli/assets/templates/pages/payment-form/page.tsx b/packages/cli/assets/templates/pages/payment-form/page.tsxindex df45510d97..f302aadeb5 100644--- a/packages/cli/assets/templates/pages/payment-form/page.tsx+++ b/packages/cli/assets/templates/pages/payment-form/page.tsx@@ -714,7 +714,7 @@ export default function PaymentFormPage() {placeholder="Enter promo code"value={promo}onChange={setPromo}- style={fullWidth}+ controlStyle={fullWidth}/></StackItem><Buttondiff --git a/packages/cli/assets/templates/pages/theme-showcase/page.tsx b/packages/cli/assets/templates/pages/theme-showcase/page.tsxindex 63ada9ee82..cf24e8a1b6 100644--- a/packages/cli/assets/templates/pages/theme-showcase/page.tsx+++ b/packages/cli/assets/templates/pages/theme-showcase/page.tsx@@ -500,7 +500,7 @@ function StorePreview({max={99}size="sm"width={72}- style={styles.quantityInput}+ controlStyle={styles.quantityInput}/><Buttonlabel="Add to cart"@@ -1143,7 +1143,7 @@ function InventoryCard({value=""onChange={() => {}}startIcon={<Search size={16} />}- style={styles.searchInput}+ controlStyle={styles.searchInput}/><OverflowListgap={2}diff --git a/packages/core/src/Field/fieldInputFamily.render-testing.tsx b/packages/core/src/Field/fieldInputFamily.render-testing.tsxnew file mode 100644index 0000000000..4a3e6c1703--- /dev/null+++ b/packages/core/src/Field/fieldInputFamily.render-testing.tsx@@ -0,0 +1,154 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file fieldInputFamily.render-testing.tsx+ * @input Uses Testing Library, Vitest, InputGroup, FormLayout+ * @output Exports describeFieldInputParts, the shared FR10 render suite+ * @position Test helper for family:input-fields FR10. Each Field-composed+ * component's test file calls it with a render function and a locator for+ * its primary semantic control.+ */++import {describe, it, expect, vi, afterEach} from 'vitest';+import {render, fireEvent} from '@testing-library/react';+import {createRef, type ReactElement} from 'react';+import {FormLayout} from '../FormLayout';+import {InputGroup} from '../InputGroup';++export interface FieldInputPartsOptions {+ /** Render the member with extra props merged into its required props. */+ renderMember: (props: Record<string, unknown>) => ReactElement;+ /** Locate the primary semantic control after rendering. */+ getControl: () => HTMLElement;+ /** Whether the member is InputGroup-compatible. */+ inGroup?: boolean;+ /**+ * Whether the member honors a caller `id` on its control. Defaults to true;+ * set false only for a member whose control id is component-owned.+ */+ forwardsId?: boolean;+}++/**+ * Shared FR10 render suite: base props reach the primary semantic control,+ * root styling is dropped with a warning, `container*` reaches the Field box+ * only where one renders, and `control*` reaches the visual control box.+ */+export function describeFieldInputParts(+ name: string,+ {+ renderMember,+ getControl,+ inGroup = false,+ forwardsId = true,+ }: FieldInputPartsOptions,+): void {+ describe(`${name} FR10 prop targets`, () => {+ afterEach(() => {+ vi.restoreAllMocks();+ });++ it('forwards base props, ref, and handlers to the primary semantic control', () => {+ const ref = createRef<HTMLElement>();+ const onFocus = vi.fn();+ render(+ renderMember({+ ref,+ ...(forwardsId ? {id: 'caller-id'} : {}),+ 'data-testid': 'member',+ 'data-track': 'field',+ 'aria-details': 'details-id',+ onFocus,+ }),+ );+ const control = getControl();+ expect(control).toHaveAttribute('data-testid', 'member');+ expect(control).toHaveAttribute('data-track', 'field');+ expect(control).toHaveAttribute('aria-details', 'details-id');+ if (forwardsId) {+ expect(control).toHaveAttribute('id', 'caller-id');+ }+ expect(ref.current).toBe(control);+ fireEvent.focus(control);+ expect(onFocus).toHaveBeenCalled();+ });++ it('styles the Field box with container* and the control box with control*', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const {container} = render(+ renderMember({+ containerClassName: 'fr10-container',+ containerStyle: {marginTop: '7px'},+ controlClassName: 'fr10-control',+ controlStyle: {marginBottom: '9px'},+ }),+ );+ const control = getControl();+ const fieldBox = container.querySelector('.fr10-container');+ const controlBox = container.querySelector('.fr10-control');+ expect(fieldBox).not.toBeNull();+ expect(controlBox).not.toBeNull();+ expect((fieldBox as HTMLElement).style.marginTop).toBe('7px');+ expect((controlBox as HTMLElement).style.marginBottom).toBe('9px');+ // The Field box holds the label and the control box; the control box+ // holds (or is) the control but is never the native input itself.+ expect(fieldBox).toContainElement(controlBox as HTMLElement);+ expect(fieldBox).not.toBe(controlBox);+ expect(controlBox).not.toBe(+ control.tagName === 'INPUT' || control.tagName === 'TEXTAREA'+ ? control+ : null,+ );+ expect(warn).not.toHaveBeenCalled();+ });++ it('drops untyped root styling and warns in development', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const {container} = render(+ renderMember({className: 'fr10-root', style: {outlineColor: 'red'}}),+ );+ expect(container.querySelector('.fr10-root')).toBeNull();+ expect(getControl().style.outlineColor).toBe('');+ expect(+ warn.mock.calls.some(call => String(call[0]).startsWith(`${name}:`)),+ ).toBe(true);+ });++ it('ignores container* and warns in a horizontal-labels FormLayout', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const {container} = render(+ <FormLayout direction="horizontal-labels">+ {renderMember({containerClassName: 'fr10-container'})}+ </FormLayout>,+ );+ expect(container.querySelector('.fr10-container')).toBeNull();+ expect(+ warn.mock.calls.some(call =>+ String(call[0]).includes('no Field box renders'),+ ),+ ).toBe(true);+ });++ if (inGroup) {+ it('ignores container* and warns inside InputGroup, keeping control*', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const {container} = render(+ // eslint-disable-next-line @astryx/no-hardcoded-i18n-string -- test fixture label+ <InputGroup label="Group">+ {renderMember({+ containerClassName: 'fr10-container',+ controlClassName: 'fr10-control',+ })}+ </InputGroup>,+ );+ expect(container.querySelector('.fr10-container')).toBeNull();+ expect(container.querySelector('.fr10-control')).not.toBeNull();+ expect(+ warn.mock.calls.some(call =>+ String(call[0]).includes('no Field box renders'),+ ),+ ).toBe(true);+ });+ }+ });+}diff --git a/packages/core/src/Field/fieldInputFamily.test.tsx b/packages/core/src/Field/fieldInputFamily.test.tsxnew file mode 100644index 0000000000..f001a15daf--- /dev/null+++ b/packages/core/src/Field/fieldInputFamily.test.tsx@@ -0,0 +1,177 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, it, expect, vi, afterEach} from 'vitest';+import {readdirSync, readFileSync, statSync} from 'node:fs';+import {join} from 'node:path';+import {renderHook} from '@testing-library/react';+import type {ReactNode} from 'react';+import {useFieldInputStyling, type FieldInputBaseProps} from './fieldParts';+import {expectFieldInputProps} from './fieldInputFamily.testing';+import {FormLayoutContext} from '../FormLayout/FormLayoutContext';+import {InputGroupContext} from '../InputGroup/InputGroupContext';++const SRC = join(__dirname, '..');++// Directories that render <Field> without being a Field-composed input.+const NOT_FIELD_INPUTS = new Set(['Field', 'InputGroup', 'FormLayout']);++// Field-composed inputs not yet converted to FR10. Each batch removes its own+// group; keep the comment lines between groups so removals merge cleanly.+const PENDING_FR10 = new Set([+ // text batch+ // date/time batch+ 'DateInput',+ 'DateRangeInput',+ 'DateTimeInput',+ 'TimeInput',+ // selector batch+ 'Selector',+ 'MultiSelector',+ 'ComplexSelector',+ // field-root batch+ 'Typeahead',+ 'Tokenizer',+ 'CheckboxList',+ 'RadioList',+ 'Slider',+]);++function fieldComposedComponents(): string[] {+ return readdirSync(SRC)+ .filter(name => statSync(join(SRC, name)).isDirectory())+ .filter(name => !NOT_FIELD_INPUTS.has(name))+ .filter(dir =>+ readdirSync(join(SRC, dir)).some(+ file =>+ file.endsWith('.tsx') &&+ !/\.(test|stories)\.tsx$/.test(file) &&+ /<Field[\s>]/.test(readFileSync(join(SRC, dir, file), 'utf8')),+ ),+ )+ .sort();+}++function hasFamilyTypeCheck(dir: string): boolean {+ return readdirSync(join(SRC, dir)).some(+ file =>+ /\.test\.tsx?$/.test(file) &&+ readFileSync(join(SRC, dir, file), 'utf8').includes(+ 'expectFieldInputProps<',+ ),+ );+}++describe('family:input-fields FR10 coverage', () => {+ it('every Field-composed component type-checks its props, or is pending', () => {+ const unchecked = fieldComposedComponents().filter(+ dir => !PENDING_FR10.has(dir) && !hasFamilyTypeCheck(dir),+ );+ expect(unchecked).toEqual([]);+ });++ it('no pending component already carries the check', () => {+ const stale = [...PENDING_FR10].filter(hasFamilyTypeCheck);+ expect(stale).toEqual([]);+ });++ it('rejects root styling at the type level', () => {+ expectFieldInputProps<FieldInputBaseProps>();+ // @ts-expect-error -- BaseProps accepts root xstyle/className/style+ expectFieldInputProps<{xstyle?: unknown} & FieldInputBaseProps>();+ });+});++describe('useFieldInputStyling', () => {+ afterEach(() => {+ vi.restoreAllMocks();+ });++ const GROUP_CONTEXT = {isInGroup: true as const, labelID: 'group-label'};+ const HORIZONTAL_LABELS_CONTEXT = {direction: 'horizontal-labels' as const};++ function wrapper(kind: 'plain' | 'group' | 'horizontal-labels') {+ return function Wrapper({children}: {children: ReactNode}) {+ if (kind === 'group') {+ return (+ <InputGroupContext value={GROUP_CONTEXT}>+ {children}+ </InputGroupContext>+ );+ }+ if (kind === 'horizontal-labels') {+ return (+ <FormLayoutContext value={HORIZONTAL_LABELS_CONTEXT}>+ {children}+ </FormLayoutContext>+ );+ }+ return <>{children}</>;+ };+ }++ it('forwards container styling to Field when a Field box renders', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const {result} = renderHook(+ () =>+ useFieldInputStyling(+ 'TextInput',+ {'data-testid': 'x'},+ {+ containerClassName: 'outer',+ containerStyle: {margin: 4},+ },+ ),+ {wrapper: wrapper('plain')},+ );+ expect(result.current.hasFieldBox).toBe(true);+ expect(result.current.container).toEqual({+ xstyle: undefined,+ className: 'outer',+ style: {margin: 4},+ });+ expect(result.current.rest).toEqual({'data-testid': 'x'});+ expect(warn).not.toHaveBeenCalled();+ });++ it.each(['group', 'horizontal-labels'] as const)(+ 'drops container styling and warns when no Field box renders (%s)',+ kind => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const {result} = renderHook(+ () =>+ useFieldInputStyling('TextInput', {}, {containerClassName: 'outer'}),+ {wrapper: wrapper(kind)},+ );+ expect(result.current.hasFieldBox).toBe(false);+ expect(result.current.container).toEqual({});+ expect(warn).toHaveBeenCalledOnce();+ expect(String(warn.mock.calls[0][0])).toContain('no Field box renders');+ },+ );++ it('does not warn when no container styling is passed outside a Field box', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ renderHook(() => useFieldInputStyling('TextInput', {}, {}), {+ wrapper: wrapper('group'),+ });+ expect(warn).not.toHaveBeenCalled();+ });++ it('strips untyped root styling and warns once', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});+ const untyped = {+ className: 'legacy',+ style: {color: 'red'},+ 'aria-label': 'Name',+ };+ const {result, rerender} = renderHook(+ () => useFieldInputStyling('TextInput', untyped, {}),+ {wrapper: wrapper('plain')},+ );+ rerender();+ expect(result.current.rest).toEqual({'aria-label': 'Name'});+ expect(warn).toHaveBeenCalledOnce();+ expect(String(warn.mock.calls[0][0])).toContain('TextInput:');+ expect(String(warn.mock.calls[0][0])).toContain('controlXstyle');+ });+});diff --git a/packages/core/src/Field/fieldInputFamily.testing.ts b/packages/core/src/Field/fieldInputFamily.testing.tsnew file mode 100644index 0000000000..604c3207bd--- /dev/null+++ b/packages/core/src/Field/fieldInputFamily.testing.ts@@ -0,0 +1,46 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file fieldInputFamily.testing.ts+ * @input Uses the FR10 forbidden root styling prop names+ * @output Exports expectFieldInputProps, a compile-time check for member tests+ * @position Test helper for family:input-fields FR10; each Field-composed+ * component's test calls it, and fieldInputFamily.test.ts verifies the call+ * exists for every component that renders Field+ */++import type {+ FieldInputForbiddenStyleProp,+ FieldPartStyleProps,+} from './fieldParts';++type AcceptsRootStyling<P> = [+ Extract<keyof P, FieldInputForbiddenStyleProp>,+] extends [never]+ ? false+ : true;++type MissingParts<P> = Exclude<keyof FieldPartStyleProps, keyof P>;++/**+ * Compile-time FR10 check: fails type-checking when `P` accepts root+ * `xstyle`/`className`/`style`, or lacks any `container*`/`control*` prop.+ * A no-op at runtime.+ *+ * @example+ * ```+ * it('has no root styling props (FR10)', () => {+ * expectFieldInputProps<TextInputProps>();+ * });+ * ```+ */+export function expectFieldInputProps<P>(+ ..._check: AcceptsRootStyling<P> extends true+ ? [error: 'accepts root xstyle, className, or style']+ : [MissingParts<P>] extends [never]+ ? []+ : [+ error: 'missing container* or control* part props',+ missing: MissingParts<P>,+ ]+): void {}diff --git a/packages/core/src/Field/fieldParts.ts b/packages/core/src/Field/fieldParts.tsnew file mode 100644index 0000000000..6c19763ec7--- /dev/null+++ b/packages/core/src/Field/fieldParts.ts@@ -0,0 +1,174 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++'use client';++/**+ * @file fieldParts.ts+ * @input Uses BaseProps, FormLayoutContext, InputGroupContext, useDevWarning+ * @output Exports FieldInputBaseProps, the container and control part style+ * props, and useFieldInputStyling+ * @position Shared styling contract for every Field-composed input+ * (family:input-fields FR10): base props reach the primary semantic control,+ * there is no root `xstyle`/`className`/`style`, `container*` styles the Field+ * box where one renders, and `control*` styles the visual control box.+ *+ * SYNC: When modified, update:+ * - /packages/core/src/Field/fieldInputFamily.test.tsx (family registry and type checks)+ * - /packages/core/src/Field/index.ts (type exports)+ */++import {type CSSProperties, use} from 'react';+import type {StyleXStyles} from '@stylexjs/stylex';+import type {BaseProps} from '../BaseProps';+import {FormLayoutContext} from '../FormLayout/FormLayoutContext';+import {useInputGroup} from '../InputGroup/InputGroupContext';+import {useDevWarning} from '../hooks/useDevWarning';++/** Root styling props a Field-composed input does not accept. */+export type FieldInputForbiddenStyleProp = 'xstyle' | 'className' | 'style';++/** Styling for the Field box (label, control, and status together). */+// A prop mixin for Field-composed inputs, not a component props type.+// eslint-disable-next-line @astryx/require-base-props, @astryx/require-ref-prop+export interface FieldContainerStyleProps {+ /**+ * StyleX styles for the field container (the Field box around the label,+ * control, and status). Has no effect where no Field box renders: inside+ * InputGroup (style the InputGroup instead) and in a `horizontal-labels`+ * FormLayout.+ */+ containerXstyle?: StyleXStyles;+ /** Class name for the field container. Same targeting as `containerXstyle`. */+ containerClassName?: string;+ /** Inline styles for the field container. Same targeting as `containerXstyle`. */+ containerStyle?: CSSProperties;+}++/** Styling for the visual control box (border, background, icons, end controls). */+// A prop mixin for Field-composed inputs, not a component props type.+// eslint-disable-next-line @astryx/require-base-props, @astryx/require-ref-prop+export interface FieldControlStyleProps {+ /**+ * StyleX styles for the visual control box: the element that paints the+ * field border and background and holds its icons and end controls. Never+ * the native input.+ */+ controlXstyle?: StyleXStyles;+ /** Class name for the visual control box. */+ controlClassName?: string;+ /** Inline styles for the visual control box. */+ controlStyle?: CSSProperties;+}++export interface FieldPartStyleProps+ extends FieldContainerStyleProps, FieldControlStyleProps {}++/**+ * BaseProps for a Field-composed input. Root `xstyle`, `className`, and `style`+ * are omitted, so passing one is a type error; style the field through+ * `container*` and the control box through `control*`.+ */+export type FieldInputBaseProps<T extends HTMLElement = HTMLElement> = Omit<+ BaseProps<T>,+ FieldInputForbiddenStyleProp+> &+ FieldPartStyleProps;++/** Styling props to pass to Field's own `xstyle`/`className`/`style`. */+export interface FieldContainerTarget {+ xstyle?: StyleXStyles;+ className?: string;+ style?: CSSProperties;+}++export interface FieldInputStyling<R> {+ /** The caller's remaining props, with any untyped root styling removed. */+ rest: R;+ /**+ * Whether a Field box renders: false inside InputGroup and in a+ * `horizontal-labels` FormLayout, where Field lays out its children in the+ * form's columns without a box of its own.+ */+ hasFieldBox: boolean;+ /** Spread onto `<Field>`; empty where no Field box renders. */+ container: FieldContainerTarget;+}++const ROOT_STYLING_MESSAGE =+ '`xstyle`, `className`, and `style` are not supported on Field-composed inputs and were ignored. ' ++ 'Style the field with `containerXstyle`/`containerClassName`/`containerStyle` and the control box with ' ++ '`controlXstyle`/`controlClassName`/`controlStyle`. `astryx upgrade` rewrites existing usage.';++const CONTAINER_WITHOUT_FIELD_MESSAGE =+ '`containerXstyle`/`containerClassName`/`containerStyle` have no effect here because no Field box renders ' ++ '(inside InputGroup or a `horizontal-labels` FormLayout). Inside InputGroup, style the InputGroup.';++/**+ * Resolve FR10 styling for a Field-composed input.+ *+ * Strips root `xstyle`/`className`/`style` that an untyped caller passed (they+ * would otherwise spread onto the native control) and warns once in+ * development. Returns the `container*` props to forward to Field only when a+ * Field box renders, and warns once when they are passed where none does.+ * `control*` props are the caller's to apply to the control box directly.+ *+ * @example+ * ```+ * const {rest, container} = useFieldInputStyling('TextInput', restProps, {+ * containerXstyle, containerClassName, containerStyle,+ * });+ * ```+ */+export function useFieldInputStyling<R extends object>(+ component: string,+ restProps: R,+ containerProps: FieldContainerStyleProps,+): FieldInputStyling<R> {+ const inputGroup = useInputGroup();+ const {direction} = use(FormLayoutContext);+ const hasFieldBox = inputGroup == null && direction !== 'horizontal-labels';++ const untyped = restProps as R & {+ xstyle?: unknown;+ className?: unknown;+ style?: unknown;+ };+ const hasRootStyling =+ untyped.xstyle != null ||+ untyped.className != null ||+ untyped.style != null;+ let rest = restProps;+ if (hasRootStyling) {+ const {+ xstyle: _xstyle,+ className: _className,+ style: _style,+ ...remaining+ } = untyped;+ rest = remaining as R;+ }+ useDevWarning(component, ROOT_STYLING_MESSAGE, hasRootStyling);++ const {containerXstyle, containerClassName, containerStyle} = containerProps;+ const hasContainerStyling =+ containerXstyle != null ||+ containerClassName != null ||+ containerStyle != null;+ useDevWarning(+ component,+ CONTAINER_WITHOUT_FIELD_MESSAGE,+ hasContainerStyling && !hasFieldBox,+ );++ return {+ rest,+ hasFieldBox,+ container: hasFieldBox+ ? {+ xstyle: containerXstyle,+ className: containerClassName,+ style: containerStyle,+ }+ : {},+ };+}diff --git a/packages/core/src/Field/index.ts b/packages/core/src/Field/index.tsindex bd070af402..96957b3695 100644--- a/packages/core/src/Field/index.ts+++ b/packages/core/src/Field/index.ts@@ -12,11 +12,7 @@*/export {Field} from './Field';-export type {- FieldProps,- FieldStatusInput,- FieldStatusType,-} from './Field';+export type {FieldProps, FieldStatusInput, FieldStatusType} from './Field';export {FieldLabel} from './FieldLabel';export type {FieldLabelProps} from './FieldLabel';export {FieldStatus} from '../FieldStatus';@@ -28,6 +24,12 @@ export type {// Shared input typesexport type {InputStatus, InputStatusType, InputSize} from './types';+export type {+ FieldInputBaseProps,+ FieldContainerStyleProps,+ FieldControlStyleProps,+ FieldPartStyleProps,+} from './fieldParts';// Shared input stylesexport {diff --git a/packages/core/src/FileInput/FileInput.doc.mjs b/packages/core/src/FileInput/FileInput.doc.mjsindex 01f72dff2d..18ddb6db22 100644--- a/packages/core/src/FileInput/FileInput.doc.mjs+++ b/packages/core/src/FileInput/FileInput.doc.mjs@@ -138,6 +138,38 @@ export const docs = {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: 'containerXstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for the field container (label, control, and status together). No effect inside InputGroup (style the InputGroup instead) or in a `horizontal-labels` FormLayout. Root `xstyle`, `className`, and `style` are not accepted.',+ },+ {+ name: 'containerClassName',+ type: 'string',+ description: 'Class name for the field container. Same targeting as `containerXstyle`.',+ },+ {+ name: 'containerStyle',+ type: 'CSSProperties',+ description: 'Inline styles for the field container. Same targeting as `containerXstyle`.',+ },+ {+ name: 'controlXstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for the visual control box: the element that paints the border and background and holds icons and end controls. Never the native input.',+ },+ {+ name: 'controlClassName',+ type: 'string',+ description: 'Class name for the visual control box.',+ },+ {+ name: 'controlStyle',+ type: 'CSSProperties',+ description: 'Inline styles for the visual control box.',+ },],theming: {targets: [@@ -267,6 +299,38 @@ export const docsZh = {'状态消息相对于输入框的放置方式。attached 直接叠加在输入框下方(带边框处理);detached 作为独立元素浮于下方并留有间距;tooltip 隐藏消息框,并在状态图标上以提示气泡形式显示。',default: "'attached'",},+ {+ name: 'containerXstyle',+ type: 'StyleXStyles',+ description:+ '字段容器(标签、控件和状态整体)的 StyleX 样式。在 InputGroup 内(请改为设置 InputGroup 的样式)或 `horizontal-labels` FormLayout 中无效。不接受根级 `xstyle`、`className` 和 `style`。',+ },+ {+ name: 'containerClassName',+ type: 'string',+ description: '字段容器的类名,作用目标同 `containerXstyle`。',+ },+ {+ name: 'containerStyle',+ type: 'CSSProperties',+ description: '字段容器的内联样式,作用目标同 `containerXstyle`。',+ },+ {+ name: 'controlXstyle',+ type: 'StyleXStyles',+ description:+ '可视控件框的 StyleX 样式:绘制边框和背景并包含图标与尾部控件的元素,而非原生输入元素。',+ },+ {+ name: 'controlClassName',+ type: 'string',+ description: '可视控件框的类名。',+ },+ {+ name: 'controlStyle',+ type: 'CSSProperties',+ description: '可视控件框的内联样式。',+ },],theming: {targets: [@@ -319,6 +383,12 @@ export const docsDense = {],},propDescriptions: {+ containerXstyle: 'StyleX styles for the field container; no effect in InputGroup or horizontal-labels FormLayout. No root xstyle/className/style.',+ containerClassName: 'Class name for the field container.',+ containerStyle: 'Inline styles for the field container.',+ controlXstyle: 'StyleX styles for the visual control box (border, background, icons); not the native input.',+ controlClassName: 'Class name for the visual control box.',+ controlStyle: 'Inline styles for the visual control box.',label: 'Accessible label for the file input.',value: 'Currently selected file(s). Controlled.',onChange: 'Fired when files are selected or removed.',diff --git a/packages/core/src/FileInput/FileInput.fr10.test.tsx b/packages/core/src/FileInput/FileInput.fr10.test.tsxnew file mode 100644index 0000000000..a6e7b87f45--- /dev/null+++ b/packages/core/src/FileInput/FileInput.fr10.test.tsx@@ -0,0 +1,20 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, it} from 'vitest';+import {expectFieldInputProps} from '../Field/fieldInputFamily.testing';+import {describeFieldInputParts} from '../Field/fieldInputFamily.render-testing';+import {FileInput, type FileInputProps} from './FileInput';++describe('FileInput props type (family:input-fields FR10)', () => {+ it('accepts container* and control* and no root styling', () => {+ expectFieldInputProps<FileInputProps>();+ });+});++describeFieldInputParts('FileInput', {+ renderMember: props => (+ <FileInput label="Resume" value={null} onChange={() => {}} {...props} />+ ),+ getControl: () => document.querySelector<HTMLElement>('input[type="file"]')!,+ inGroup: false,+});diff --git a/packages/core/src/FileInput/FileInput.tsx b/packages/core/src/FileInput/FileInput.tsxindex 58b33ff910..e2cf3392ca 100644--- a/packages/core/src/FileInput/FileInput.tsx+++ b/packages/core/src/FileInput/FileInput.tsx@@ -57,6 +57,10 @@ export type {} from '../Field';import {mergeProps} from '../utils';import type {BaseProps} from '../BaseProps';+import {+ type FieldInputBaseProps,+ useFieldInputStyling,+} from '../Field/fieldParts';import type {SizeValue} from '../utils/types';import {themeProps} from '../utils/themeProps';import {useTranslator} from '../i18n';@@ -291,7 +295,7 @@ const statusBorderStyles = stylex.create({});export interface FileInputProps extends Omit<- BaseProps,+ FieldInputBaseProps,'onChange' | 'defaultValue' | 'value'> {ref?: React.Ref<HTMLInputElement>;@@ -409,7 +413,7 @@ export interface FileInputProps extends Omit</*** Width of the field. Numbers are treated as pixels, strings are used as-is* (e.g. `'100%'`). Sizes the whole field (label, control, and status) so they- * stay aligned, unlike setting width via `xstyle`/`className`/`style`.+ * stay aligned, unlike setting width via `controlXstyle`/`controlClassName`/`controlStyle`.*/width?: SizeValue;/**@@ -448,14 +452,24 @@ export function FileInput({isOptional = false,labelTooltip,width,- xstyle,- className,- style,+ containerXstyle,+ containerClassName,+ containerStyle,+ controlXstyle,+ controlClassName,+ controlStyle,ref,- ...rest+ id: idProp,+ ...restProps}: FileInputProps) {+ const {rest, container} = useFieldInputStyling('FileInput', restProps, {+ containerXstyle,+ containerClassName,+ containerStyle,+ });const t = useTranslator();- const id = useId();+ const generatedID = useId();+ const id = idProp ?? generatedID;const descriptionID = useId();const statusMessageID = useId();const requiredID = useId();@@ -785,6 +799,7 @@ export function FileInput({return (<Field+ {...container}label={label}isLabelHidden={isLabelHidden}description={description}@@ -827,10 +842,10 @@ export function FileInput({isDropzone && isDisabled && styles.dropzoneDisabled,!isDropzone && isDisabled && styles.compactDisabled,status && statusBorderStyles[status.type],- xstyle,+ controlXstyle,),- className,- style,+ controlClassName,+ controlStyle,)}>{/* Visually hidden real button carrying the accessible role, name, andARIA. Kept as a sibling of the clear/status controls inside adiff --git a/packages/core/src/NumberInput/NumberInput.doc.mjs b/packages/core/src/NumberInput/NumberInput.doc.mjsindex f4915c8dcd..544d59628f 100644--- a/packages/core/src/NumberInput/NumberInput.doc.mjs+++ b/packages/core/src/NumberInput/NumberInput.doc.mjs@@ -217,6 +217,38 @@ export const docs = {type: '() => void',description: 'Callback fired when the user presses the Enter key.',},+ {+ name: 'containerXstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for the field container (label, control, and status together). No effect inside InputGroup (style the InputGroup instead) or in a `horizontal-labels` FormLayout. Root `xstyle`, `className`, and `style` are not accepted.',+ },+ {+ name: 'containerClassName',+ type: 'string',+ description: 'Class name for the field container. Same targeting as `containerXstyle`.',+ },+ {+ name: 'containerStyle',+ type: 'CSSProperties',+ description: 'Inline styles for the field container. Same targeting as `containerXstyle`.',+ },+ {+ name: 'controlXstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for the visual control box: the element that paints the border and background and holds icons and end controls. Never the native input.',+ },+ {+ name: 'controlClassName',+ type: 'string',+ description: 'Class name for the visual control box.',+ },+ {+ name: 'controlStyle',+ type: 'CSSProperties',+ description: 'Inline styles for the visual control box.',+ },],theming: {targets: [@@ -492,6 +524,38 @@ export const docsZh = {type: '() => void',description: '用户按下 Enter 键时触发的回调。',},+ {+ name: 'containerXstyle',+ type: 'StyleXStyles',+ description:+ '字段容器(标签、控件和状态整体)的 StyleX 样式。在 InputGroup 内(请改为设置 InputGroup 的样式)或 `horizontal-labels` FormLayout 中无效。不接受根级 `xstyle`、`className` 和 `style`。',+ },+ {+ name: 'containerClassName',+ type: 'string',+ description: '字段容器的类名,作用目标同 `containerXstyle`。',+ },+ {+ name: 'containerStyle',+ type: 'CSSProperties',+ description: '字段容器的内联样式,作用目标同 `containerXstyle`。',+ },+ {+ name: 'controlXstyle',+ type: 'StyleXStyles',+ description:+ '可视控件框的 StyleX 样式:绘制边框和背景并包含图标与尾部控件的元素,而非原生输入元素。',+ },+ {+ name: 'controlClassName',+ type: 'string',+ description: '可视控件框的类名。',+ },+ {+ name: 'controlStyle',+ type: 'CSSProperties',+ description: '可视控件框的内联样式。',+ },],theming: {targets: [@@ -656,6 +720,12 @@ export const docsDense = {],},propDescriptions: {+ containerXstyle: 'StyleX styles for the field container; no effect in InputGroup or horizontal-labels FormLayout. No root xstyle/className/style.',+ containerClassName: 'Class name for the field container.',+ containerStyle: 'Inline styles for the field container.',+ controlXstyle: 'StyleX styles for the visual control box (border, background, icons); not the native input.',+ controlClassName: 'Class name for the visual control box.',+ controlStyle: 'Inline styles for the visual control box.',label: 'Label text (always rendered for accessibility).',value: 'Current input value.',onChange:diff --git a/packages/core/src/NumberInput/NumberInput.fr10.test.tsx b/packages/core/src/NumberInput/NumberInput.fr10.test.tsxnew file mode 100644index 0000000000..aee04e2203--- /dev/null+++ b/packages/core/src/NumberInput/NumberInput.fr10.test.tsx@@ -0,0 +1,21 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, it} from 'vitest';+import {screen} from '@testing-library/react';+import {expectFieldInputProps} from '../Field/fieldInputFamily.testing';+import {describeFieldInputParts} from '../Field/fieldInputFamily.render-testing';+import {NumberInput, type NumberInputProps} from './NumberInput';++describe('NumberInput props type (family:input-fields FR10)', () => {+ it('accepts container* and control* and no root styling', () => {+ expectFieldInputProps<NumberInputProps>();+ });+});++describeFieldInputParts('NumberInput', {+ renderMember: props => (+ <NumberInput label="Quantity" value={1} onChange={() => {}} {...props} />+ ),+ getControl: () => screen.getByRole('spinbutton'),+ inGroup: true,+});diff --git a/packages/core/src/NumberInput/NumberInput.tsx b/packages/core/src/NumberInput/NumberInput.tsxindex 3d0a2074b3..ebb1f13deb 100644--- a/packages/core/src/NumberInput/NumberInput.tsx+++ b/packages/core/src/NumberInput/NumberInput.tsx@@ -213,6 +213,10 @@ export type {} from '../Field';import {isImeKeyEvent, mergeProps, mergeRefs} from '../utils';import type {BaseProps} from '../BaseProps';+import {+ type FieldInputBaseProps,+ useFieldInputStyling,+} from '../Field/fieldParts';import type {SizeValue} from '../utils/types';import {themeProps} from '../utils/themeProps';import {useTranslator, useLocale} from '../i18n';@@ -220,7 +224,7 @@ import {formatEditableNumber} from './numberParser';import {parseNumberInput, resolveNumberInputCommit} from './numberInputCommit';interface NumberInputPropsBase extends Omit<- BaseProps,+ FieldInputBaseProps,'onChange' | 'defaultValue'> {/** Ref forwarded to the root element */@@ -329,7 +333,7 @@ interface NumberInputPropsBase extends Omit</*** Width of the field. Numbers are treated as pixels, strings are used as-is* (e.g. `'100%'`). Sizes the whole field (label, control, and status) so they- * stay aligned, unlike setting width via `xstyle`/`className`/`style`.+ * stay aligned, unlike setting width via `controlXstyle`/`controlClassName`/`controlStyle`.*/width?: SizeValue;/**@@ -561,18 +565,28 @@ export function NumberInput({onEnter,onKeyDown,width,- xstyle,- className,- style,+ containerXstyle,+ containerClassName,+ containerStyle,+ controlXstyle,+ controlClassName,+ controlStyle,ref,- ...rest+ id: idProp,+ ...restProps}: NumberInputProps) {+ const {rest, container} = useFieldInputStyling('NumberInput', restProps, {+ containerXstyle,+ containerClassName,+ containerStyle,+ });const pressable = usePressFeedback();const t = useTranslator();const locale = useLocale();const isEffectivelyRequired = useResolvedRequired({isRequired, isOptional});const size = useSize(sizeProp, 'md');- const id = useId();+ const generatedID = useId();+ const id = idProp ?? generatedID;const inputLabelID = useId();const descriptionID = useId();const statusMessageID = useId();@@ -891,10 +905,10 @@ export function NumberInput({status && !isDisabled && inputStatusHoverShadowStyles[status.type],status && inputStatusFocusWithinStyles[status.type],inputGroup && groupStyles.inGroup,- xstyle,+ controlXstyle,),- className,- style,+ controlClassName,+ controlStyle,)}>{startIcon && renderIconSlot(startIcon, {size: 'sm', color: 'secondary'})}{inputGroup && <VisuallyHidden id={inputLabelID}>{label}</VisuallyHidden>}@@ -1031,6 +1045,7 @@ export function NumberInput({return (<Field+ {...container}label={label}isLabelHidden={isLabelHidden}description={description}diff --git a/packages/core/src/TextArea/TextArea.doc.mjs b/packages/core/src/TextArea/TextArea.doc.mjsindex c7c40d17a8..b0f75ad90e 100644--- a/packages/core/src/TextArea/TextArea.doc.mjs+++ b/packages/core/src/TextArea/TextArea.doc.mjs@@ -267,6 +267,38 @@ export const docs = {description:'StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value, not an inline style object like style={{}}.',},+ {+ name: 'containerXstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for the field container (label, control, and status together). No effect inside InputGroup (style the InputGroup instead) or in a `horizontal-labels` FormLayout. Root `xstyle`, `className`, and `style` are not accepted.',+ },+ {+ name: 'containerClassName',+ type: 'string',+ description: 'Class name for the field container. Same targeting as `containerXstyle`.',+ },+ {+ name: 'containerStyle',+ type: 'CSSProperties',+ description: 'Inline styles for the field container. Same targeting as `containerXstyle`.',+ },+ {+ name: 'controlXstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for the visual control box: the element that paints the border and background and holds icons and end controls. Never the native input.',+ },+ {+ name: 'controlClassName',+ type: 'string',+ description: 'Class name for the visual control box.',+ },+ {+ name: 'controlStyle',+ type: 'CSSProperties',+ description: 'Inline styles for the visual control box.',+ },],theming: {targets: [@@ -515,6 +547,38 @@ export const docsZh = {description:'StyleX 样式,用于布局自定义(边距、定位、尺寸)。必须是 stylex.create() 的值,而非内联样式对象。',},+ {+ name: 'containerXstyle',+ type: 'StyleXStyles',+ description:+ '字段容器(标签、控件和状态整体)的 StyleX 样式。在 InputGroup 内(请改为设置 InputGroup 的样式)或 `horizontal-labels` FormLayout 中无效。不接受根级 `xstyle`、`className` 和 `style`。',+ },+ {+ name: 'containerClassName',+ type: 'string',+ description: '字段容器的类名,作用目标同 `containerXstyle`。',+ },+ {+ name: 'containerStyle',+ type: 'CSSProperties',+ description: '字段容器的内联样式,作用目标同 `containerXstyle`。',+ },+ {+ name: 'controlXstyle',+ type: 'StyleXStyles',+ description:+ '可视控件框的 StyleX 样式:绘制边框和背景并包含图标与尾部控件的元素,而非原生输入元素。',+ },+ {+ name: 'controlClassName',+ type: 'string',+ description: '可视控件框的类名。',+ },+ {+ name: 'controlStyle',+ type: 'CSSProperties',+ description: '可视控件框的内联样式。',+ },],theming: {targets: [@@ -639,6 +703,12 @@ export const docsDense = {],},propDescriptions: {+ containerXstyle: 'StyleX styles for the field container; no effect in InputGroup or horizontal-labels FormLayout. No root xstyle/className/style.',+ containerClassName: 'Class name for the field container.',+ containerStyle: 'Inline styles for the field container.',+ controlXstyle: 'StyleX styles for the visual control box (border, background, icons); not the native input.',+ controlClassName: 'Class name for the visual control box.',+ controlStyle: 'Inline styles for the visual control box.',ref: 'ref forwarded to underlying <textarea>.',label: 'Label text for textarea; always rendered for a11y.',value: 'Current textarea value.',diff --git a/packages/core/src/TextArea/TextArea.fr10.test.tsx b/packages/core/src/TextArea/TextArea.fr10.test.tsxnew file mode 100644index 0000000000..5425c42e98--- /dev/null+++ b/packages/core/src/TextArea/TextArea.fr10.test.tsx@@ -0,0 +1,21 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, it} from 'vitest';+import {screen} from '@testing-library/react';+import {expectFieldInputProps} from '../Field/fieldInputFamily.testing';+import {describeFieldInputParts} from '../Field/fieldInputFamily.render-testing';+import {TextArea, type TextAreaProps} from './TextArea';++describe('TextArea props type (family:input-fields FR10)', () => {+ it('accepts container* and control* and no root styling', () => {+ expectFieldInputProps<TextAreaProps>();+ });+});++describeFieldInputParts('TextArea', {+ renderMember: props => (+ <TextArea label="Notes" value="" onChange={() => {}} {...props} />+ ),+ getControl: () => screen.getByRole('textbox'),+ inGroup: false,+});diff --git a/packages/core/src/TextArea/TextArea.tsx b/packages/core/src/TextArea/TextArea.tsxindex 8de2179c22..a86774822a 100644--- a/packages/core/src/TextArea/TextArea.tsx+++ b/packages/core/src/TextArea/TextArea.tsx@@ -48,6 +48,10 @@ import {Spinner} from '../Spinner';import {useTooltip} from '../Tooltip';import {mergeProps} from '../utils';import type {BaseProps} from '../BaseProps';+import {+ type FieldInputBaseProps,+ useFieldInputStyling,+} from '../Field/fieldParts';import type {SizeValue} from '../utils/types';import {useInputContainer} from '../hooks/useInputContainer';import {useInputStatusIcon} from '../hooks/useInputStatusIcon';@@ -195,7 +199,7 @@ export interface TextAreaStatus {}export interface TextAreaProps extends Omit<- BaseProps,+ FieldInputBaseProps,'onChange' | 'defaultValue'> {/** Ref forwarded to the root element */@@ -299,7 +303,7 @@ export interface TextAreaProps extends Omit</*** Width of the field. Numbers are treated as pixels, strings are used as-is* (e.g. `'100%'`). Sizes the whole field (label, control, and status) so they- * stay aligned, unlike setting width via `xstyle`/`className`/`style`.+ * stay aligned, unlike setting width via `controlXstyle`/`controlClassName`/`controlStyle`.*/width?: SizeValue;/**@@ -400,17 +404,27 @@ export function TextArea({onFocus,onBlur,width,- xstyle,- className,- style,+ containerXstyle,+ containerClassName,+ containerStyle,+ controlXstyle,+ controlClassName,+ controlStyle,ref,- ...rest+ id: idProp,+ ...restProps}: TextAreaProps) {+ const {rest, container} = useFieldInputStyling('TextArea', restProps, {+ containerXstyle,+ containerClassName,+ containerStyle,+ });const size = useSize(sizeProp, 'md');const t = useTranslator();const isEffectivelyRequired = useResolvedRequired({isRequired, isOptional});const announce = useAnnounce();- const id = useId();+ const generatedID = useId();+ const id = idProp ?? generatedID;const descriptionID = useId();const statusMessageID = useId();const counterID = useId();@@ -537,6 +551,7 @@ export function TextArea({return (<Field+ {...container}label={label}isLabelHidden={isLabelHidden}description={description}@@ -581,10 +596,10 @@ export function TextArea({status && inputStatusBorderStyles[status.type],status && !isDisabled && inputStatusHoverShadowStyles[status.type],status && inputStatusFocusWithinStyles[status.type],- xstyle,+ controlXstyle,),- className,- style,+ controlClassName,+ controlStyle,)}>{startIcon && (<span {...stylex.props(styles.startIcon)}>diff --git a/packages/core/src/TextInput/TextInput.doc.mjs b/packages/core/src/TextInput/TextInput.doc.mjsindex 5b828c6c2d..9a83ea0ced 100644--- a/packages/core/src/TextInput/TextInput.doc.mjs+++ b/packages/core/src/TextInput/TextInput.doc.mjs@@ -170,6 +170,38 @@ export const docs = {description:'The native autocomplete attribute, forwarded to the input unchanged. Does not affect the controlled value.',},+ {+ name: 'containerXstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for the field container (label, control, and status together). No effect inside InputGroup (style the InputGroup instead) or in a `horizontal-labels` FormLayout. Root `xstyle`, `className`, and `style` are not accepted.',+ },+ {+ name: 'containerClassName',+ type: 'string',+ description: 'Class name for the field container. Same targeting as `containerXstyle`.',+ },+ {+ name: 'containerStyle',+ type: 'CSSProperties',+ description: 'Inline styles for the field container. Same targeting as `containerXstyle`.',+ },+ {+ name: 'controlXstyle',+ type: 'StyleXStyles',+ description:+ 'StyleX styles for the visual control box: the element that paints the border and background and holds icons and end controls. Never the native input.',+ },+ {+ name: 'controlClassName',+ type: 'string',+ description: 'Class name for the visual control box.',+ },+ {+ name: 'controlStyle',+ type: 'CSSProperties',+ description: 'Inline styles for the visual control box.',+ },],theming: {targets: [@@ -349,6 +381,38 @@ export const docsZh = {description:'原生 autocomplete 属性,原样转发给输入框。不影响受控的值。',},+ {+ name: 'containerXstyle',+ type: 'StyleXStyles',+ description:+ '字段容器(标签、控件和状态整体)的 StyleX 样式。在 InputGroup 内(请改为设置 InputGroup 的样式)或 `horizontal-labels` FormLayout 中无效。不接受根级 `xstyle`、`className` 和 `style`。',+ },+ {+ name: 'containerClassName',+ type: 'string',+ description: '字段容器的类名,作用目标同 `containerXstyle`。',+ },+ {+ name: 'containerStyle',+ type: 'CSSProperties',+ description: '字段容器的内联样式,作用目标同 `containerXstyle`。',+ },+ {+ name: 'controlXstyle',+ type: 'StyleXStyles',+ description:+ '可视控件框的 StyleX 样式:绘制边框和背景并包含图标与尾部控件的元素,而非原生输入元素。',+ },+ {+ name: 'controlClassName',+ type: 'string',+ description: '可视控件框的类名。',+ },+ {+ name: 'controlStyle',+ type: 'CSSProperties',+ description: '可视控件框的内联样式。',+ },],theming: {targets: [@@ -407,6 +471,12 @@ export const docsDense = {],},propDescriptions: {+ containerXstyle: 'StyleX styles for the field container; no effect in InputGroup or horizontal-labels FormLayout. No root xstyle/className/style.',+ containerClassName: 'Class name for the field container.',+ containerStyle: 'Inline styles for the field container.',+ controlXstyle: 'StyleX styles for the visual control box (border, background, icons); not the native input.',+ controlClassName: 'Class name for the visual control box.',+ controlStyle: 'Inline styles for the visual control box.',type: 'HTML input type.',label: 'Label text for input; always rendered for a11y.',value: 'Current input value.',diff --git a/packages/core/src/TextInput/TextInput.fr10.test.tsx b/packages/core/src/TextInput/TextInput.fr10.test.tsxnew file mode 100644index 0000000000..6d8c62bdb5--- /dev/null+++ b/packages/core/src/TextInput/TextInput.fr10.test.tsx@@ -0,0 +1,21 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, it} from 'vitest';+import {screen} from '@testing-library/react';+import {expectFieldInputProps} from '../Field/fieldInputFamily.testing';+import {describeFieldInputParts} from '../Field/fieldInputFamily.render-testing';+import {TextInput, type TextInputProps} from './TextInput';++describe('TextInput props type (family:input-fields FR10)', () => {+ it('accepts container* and control* and no root styling', () => {+ expectFieldInputProps<TextInputProps>();+ });+});++describeFieldInputParts('TextInput', {+ renderMember: props => (+ <TextInput label="Name" value="" onChange={() => {}} {...props} />+ ),+ getControl: () => screen.getByRole('textbox'),+ inGroup: true,+});diff --git a/packages/core/src/TextInput/TextInput.tsx b/packages/core/src/TextInput/TextInput.tsxindex c1c6c8c357..2e3c220bff 100644--- a/packages/core/src/TextInput/TextInput.tsx+++ b/packages/core/src/TextInput/TextInput.tsx@@ -109,6 +109,10 @@ import {useInputStatusIcon} from '../hooks/useInputStatusIcon';import {useResolvedRequired} from '../hooks/useResolvedRequired';import {useInputGroup} from '../InputGroup/InputGroupContext';import type {BaseProps} from '../BaseProps';+import {+ type FieldInputBaseProps,+ useFieldInputStyling,+} from '../Field/fieldParts';import type {SizeValue} from '../utils/types';import {themeProps} from '../utils/themeProps';import {useTranslator} from '../i18n';@@ -117,7 +121,7 @@ import {useMergedRefs} from '../hooks/useMergedRefs';export type TextInputType = 'text' | 'password' | 'email';export interface TextInputProps extends Omit<- BaseProps,+ FieldInputBaseProps,'onChange' | 'defaultValue'> {/** Ref forwarded to the root element */@@ -233,7 +237,7 @@ export interface TextInputProps extends Omit</*** Width of the field. Numbers are treated as pixels, strings are used as-is* (e.g. `'100%'`). Sizes the whole field (label, control, and status) so they- * stay aligned, unlike setting width via `xstyle`/`className`/`style`.+ * stay aligned, unlike setting width via `controlXstyle`/`controlClassName`/`controlStyle`.*/width?: SizeValue;/**@@ -308,17 +312,27 @@ export function TextInput({onEnter,onKeyDown,width,- xstyle,- className,- style,+ containerXstyle,+ containerClassName,+ containerStyle,+ controlXstyle,+ controlClassName,+ controlStyle,ref,- ...rest+ id: idProp,+ ...restProps}: TextInputProps) {+ const {rest, container} = useFieldInputStyling('TextInput', restProps, {+ containerXstyle,+ containerClassName,+ containerStyle,+ });const t = useTranslator();const isEffectivelyRequired = useResolvedRequired({isRequired, isOptional});const size = useSize(sizeProp, 'md');- const id = useId();+ const generatedID = useId();+ const id = idProp ?? generatedID;const inputLabelID = useId();const descriptionID = useId();const statusMessageID = useId();@@ -436,10 +450,10 @@ export function TextInput({status && !isDisabled && inputStatusHoverShadowStyles[status.type],status && inputStatusFocusWithinStyles[status.type],inputGroup && groupStyles.inGroup,- xstyle,+ controlXstyle,),- className,- style,+ controlClassName,+ controlStyle,)}>{startIcon && renderIconSlot(startIcon, {size: 'sm', color: 'secondary'})}{inputGroup && <VisuallyHidden id={inputLabelID}>{label}</VisuallyHidden>}@@ -505,6 +519,7 @@ export function TextInput({return (<Field+ {...container}label={label}isLabelHidden={isLabelHidden}description={description}diff --git a/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx b/packages/lab/src/MobileTokenizer/MobileTokenizer.tsxindex 48285f5705..e55d1d0cf6 100644--- a/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx+++ b/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx@@ -417,7 +417,7 @@ export function MobileTokenizer<T extends SearchableItem>({setQuery(next);onChangeQuery?.(next);}}- xstyle={styles.filterInput}+ controlXstyle={styles.filterInput}/></div><divdiff --git a/packages/lab/src/TransferList/TransferList.tsx b/packages/lab/src/TransferList/TransferList.tsxindex 802d8ee441..c80090da65 100644--- a/packages/lab/src/TransferList/TransferList.tsx+++ b/packages/lab/src/TransferList/TransferList.tsx@@ -1216,7 +1216,7 @@ export function TransferList<T extends string = string>({startIcon={<Icon icon="search" size="sm" color="secondary" />}hasClearwidth="100%"- xstyle={styles.search}+ controlXstyle={styles.search}onChange={handleSearch}/></div>