diff --git a/packages/@luke-ui/react/src/combobox-field/index.tsx b/packages/@luke-ui/react/src/combobox-field/index.tsx index 533da0ae..e749e5ce 100644 --- a/packages/@luke-ui/react/src/combobox-field/index.tsx +++ b/packages/@luke-ui/react/src/combobox-field/index.tsx @@ -1,9 +1,8 @@ -import type { CSSProperties, JSX, ReactNode } from 'react'; +import type { CSSProperties, JSX } from 'react'; import type { ComboBoxProps as RacComboBoxProps } from 'react-aria-components/ComboBox'; import { composeField } from '../field/compose-field.js'; -import type { FieldErrorProps } from '../field/primitive/error.js'; +import type { FieldSlotProps } from '../field/compose-field.js'; import { Field } from '../field/primitive/index.js'; -import type { FieldNecessityIndicator } from '../field/primitive/label.js'; import { Icon } from '../icon/index.js'; import { LoadingSpinner } from '../loading-spinner/index.js'; import type { DistributiveOmit } from '../types/distributive-omit.js'; @@ -38,19 +37,11 @@ interface ComboboxFieldRedeclaredRACProps { export interface ComboboxFieldProps extends DistributiveOmit, 'children' | keyof ComboboxFieldRedeclaredRACProps>, - ComboboxFieldRedeclaredRACProps { + ComboboxFieldRedeclaredRACProps, + FieldSlotProps { /** Item content for the listbox (render prop or static children). */ children: ComboboxListBoxProps['children']; - /** Helper text shown below the control. */ - description?: ReactNode; - - /** Error content passed to `FieldError`. */ - errorMessage?: FieldErrorProps['children']; - - /** Label content shown above the control. */ - label?: ReactNode; - /** Props forwarded to the inner listbox. */ listBoxProps?: DistributiveOmit, 'children' | 'items' | 'loadMoreItem'>; @@ -63,9 +54,6 @@ export interface ComboboxFieldProps /** Width applied to the popover menu. */ menuWidth?: CSSProperties['width']; - /** Label necessity style. @default 'icon' */ - necessityIndicator?: FieldNecessityIndicator; - /** Called when the listbox reaches its load-more sentinel. */ onLoadMore?: ComboboxLoadMoreItemProps['onLoadMore']; diff --git a/packages/@luke-ui/react/src/field/compose-field.ts b/packages/@luke-ui/react/src/field/compose-field.ts index 678dbbff..53c171dc 100644 --- a/packages/@luke-ui/react/src/field/compose-field.ts +++ b/packages/@luke-ui/react/src/field/compose-field.ts @@ -9,7 +9,7 @@ export interface FieldSlotProps { errorMessage?: FieldErrorProps['children']; /** Label content shown above the control. */ label?: ReactNode; - /** Label necessity style. */ + /** Label necessity style. @default 'icon' */ necessityIndicator?: FieldNecessityIndicator; } diff --git a/packages/@luke-ui/react/src/field/primitive/index.tsx b/packages/@luke-ui/react/src/field/primitive/index.tsx index 86fb4c8e..e8dbcb94 100644 --- a/packages/@luke-ui/react/src/field/primitive/index.tsx +++ b/packages/@luke-ui/react/src/field/primitive/index.tsx @@ -1,4 +1,5 @@ import type { ComponentProps, JSX, ReactNode } from 'react'; +import type { FieldSlotProps } from '../compose-field.js'; import type { FieldDescriptionProps } from './description.js'; import { FieldDescription } from './description.js'; import type { FieldErrorProps } from './error.js'; @@ -17,16 +18,8 @@ type PrimitiveFieldProps = ComponentProps; * * @tier primitive */ -export interface FieldProps extends Omit { +export interface FieldProps extends Omit, FieldSlotProps { children: ReactNode; - /** Optional helper text shown below the input. */ - description?: ReactNode; - /** Error content passed to `FieldError`. */ - errorMessage?: FieldErrorProps['children']; - /** Label content shown above the input. */ - label?: ReactNode; - /** Label necessity style. Defaults to `'icon'`. */ - necessityIndicator?: FieldNecessityIndicator; } /** Composes label, control slot, description, and error text. */ diff --git a/packages/@luke-ui/react/src/text-field/index.tsx b/packages/@luke-ui/react/src/text-field/index.tsx index ecbc7b94..c80e44b8 100644 --- a/packages/@luke-ui/react/src/text-field/index.tsx +++ b/packages/@luke-ui/react/src/text-field/index.tsx @@ -5,9 +5,8 @@ import type { } from 'react-aria-components/TextField'; import { TextField as RacTextField } from 'react-aria-components/TextField'; import { composeField } from '../field/compose-field.js'; -import type { FieldErrorProps } from '../field/primitive/error.js'; +import type { FieldSlotProps } from '../field/compose-field.js'; import { Field } from '../field/primitive/index.js'; -import type { FieldNecessityIndicator } from '../field/primitive/label.js'; import type { TextInputSize } from './primitive/index.js'; import { TextInput } from './primitive/index.js'; @@ -34,21 +33,14 @@ interface TextFieldRedeclaredRACProps { export interface TextFieldProps extends Omit, - TextFieldRedeclaredRACProps { + TextFieldRedeclaredRACProps, + FieldSlotProps { /** Element shown after the input value. */ adornmentEnd?: ReactNode; /** Element shown before the input value. */ adornmentStart?: ReactNode; - /** Helper text shown below the control. */ - description?: ReactNode; - /** Error content passed to `FieldError`. */ - errorMessage?: FieldErrorProps['children']; /** Class name forwarded to the inner input element. */ inputClassName?: RacInputProps['className']; - /** Label content shown above the input. */ - label?: ReactNode; - /** Label necessity style. */ - necessityIndicator?: FieldNecessityIndicator; /** Placeholder text for the input. */ placeholder?: string; /** Control size. Defaults to `'medium'`. */