haze-ui 1.12.1 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.md +99 -31
  2. package/dist/components/Checkbox/Checkbox.js +13 -20
  3. package/dist/components/Checkbox/CheckboxCore.js +23 -0
  4. package/dist/components/ColorPicker/ColorPicker.js +13 -42
  5. package/dist/components/ColorPicker/ColorPickerCore.js +38 -0
  6. package/dist/components/Combobox/Combobox.js +45 -34
  7. package/dist/components/Command/Command.js +72 -37
  8. package/dist/components/ContextMenu/ContextMenu.js +19 -17
  9. package/dist/components/ContextMenu/ContextMenuContent.js +24 -12
  10. package/dist/components/ContextMenu/ContextMenuItem.js +2 -0
  11. package/dist/components/DateRangePicker/DateRangePicker.js +17 -35
  12. package/dist/components/DateRangePicker/DateRangePickerCore.js +33 -0
  13. package/dist/components/Datepicker/Calendar.js +58 -44
  14. package/dist/components/Datepicker/Datepicker.js +15 -39
  15. package/dist/components/Datepicker/DatepickerCore.js +50 -0
  16. package/dist/components/DropdownMenu/DropdownMenu.js +20 -20
  17. package/dist/components/DropdownMenu/DropdownMenuContent.js +38 -45
  18. package/dist/components/DropdownMenu/DropdownMenuTrigger.js +9 -7
  19. package/dist/components/InlineEdit/InlineEdit.js +1 -0
  20. package/dist/components/Input/Input.js +11 -22
  21. package/dist/components/Input/InputCore.js +26 -0
  22. package/dist/components/Menu/Menu.js +38 -26
  23. package/dist/components/Menu/MenuItem.js +1 -0
  24. package/dist/components/ModelPicker/ModelPicker.js +1 -0
  25. package/dist/components/NumberInput/NumberInput.js +16 -53
  26. package/dist/components/NumberInput/NumberInputCore.js +56 -0
  27. package/dist/components/OTPInput/OTPInput.js +11 -45
  28. package/dist/components/OTPInput/OTPInputCore.js +44 -0
  29. package/dist/components/PasswordInput/PasswordInput.js +14 -29
  30. package/dist/components/PasswordInput/PasswordInputCore.js +31 -0
  31. package/dist/components/Popover/Popover.js +32 -75
  32. package/dist/components/Progress/Progress.js +2 -0
  33. package/dist/components/Radio/RadioGroup.js +12 -21
  34. package/dist/components/Radio/RadioGroupCore.js +24 -0
  35. package/dist/components/Rating/Rating.js +14 -46
  36. package/dist/components/Rating/RatingCore.js +48 -0
  37. package/dist/components/Segmented/Segmented.js +12 -37
  38. package/dist/components/Segmented/SegmentedCore.js +39 -0
  39. package/dist/components/Select/Select.js +12 -23
  40. package/dist/components/Select/SelectCore.js +27 -0
  41. package/dist/components/Slider/Slider.js +10 -15
  42. package/dist/components/Slider/SliderCore.js +19 -0
  43. package/dist/components/Switch/Switch.js +11 -38
  44. package/dist/components/Switch/SwitchCore.js +42 -0
  45. package/dist/components/TagInput/TagInput.js +18 -72
  46. package/dist/components/TagInput/TagInputCore.js +68 -0
  47. package/dist/components/Textarea/Textarea.js +11 -22
  48. package/dist/components/Textarea/TextareaCore.js +26 -0
  49. package/dist/components/TimePicker/TimePicker.js +10 -15
  50. package/dist/components/TimePicker/TimePickerCore.js +18 -0
  51. package/dist/components/Tooltip/Tooltip.js +50 -24
  52. package/dist/components/Tree/TreeItem.js +44 -41
  53. package/dist/components/Upload/Upload.js +1 -0
  54. package/dist/css/checkbox.css +1 -1
  55. package/dist/css/color-picker.css +1 -1
  56. package/dist/css/combobox.css +2 -1
  57. package/dist/css/command.css +1 -1
  58. package/dist/css/context-menu.css +1 -0
  59. package/dist/css/date-range-picker.css +1 -1
  60. package/dist/css/datepicker.css +3 -2
  61. package/dist/css/dropdown-menu.css +2 -1
  62. package/dist/css/input.css +1 -1
  63. package/dist/css/menu.css +2 -1
  64. package/dist/css/number-input.css +1 -1
  65. package/dist/css/otp-input.css +1 -1
  66. package/dist/css/password-input.css +1 -1
  67. package/dist/css/popover.css +2 -1
  68. package/dist/css/radio.css +1 -1
  69. package/dist/css/rating.css +1 -1
  70. package/dist/css/segmented.css +1 -1
  71. package/dist/css/select.css +1 -1
  72. package/dist/css/slider.css +1 -1
  73. package/dist/css/switch.css +1 -1
  74. package/dist/css/tag-input.css +1 -1
  75. package/dist/css/textarea.css +1 -1
  76. package/dist/css/time-picker.css +1 -1
  77. package/dist/css/tooltip.css +2 -1
  78. package/dist/form/FormItem.js +41 -33
  79. package/dist/haze-ui.css +31 -24
  80. package/dist/index.js +138 -122
  81. package/dist/types/components/Checkbox/CheckboxCore.d.ts +12 -0
  82. package/dist/types/components/Checkbox/index.d.ts +2 -0
  83. package/dist/types/components/ColorPicker/ColorPickerCore.d.ts +8 -0
  84. package/dist/types/components/ColorPicker/index.d.ts +2 -0
  85. package/dist/types/components/ContextMenu/ContextMenuContent.d.ts +1 -1
  86. package/dist/types/components/ContextMenu/ContextMenuContext.d.ts +5 -1
  87. package/dist/types/components/DateRangePicker/DateRangePickerCore.d.ts +11 -0
  88. package/dist/types/components/DateRangePicker/index.d.ts +2 -0
  89. package/dist/types/components/Datepicker/DatepickerCore.d.ts +12 -0
  90. package/dist/types/components/Datepicker/index.d.ts +2 -0
  91. package/dist/types/components/DropdownMenu/DropdownMenuContent.d.ts +1 -1
  92. package/dist/types/components/DropdownMenu/DropdownMenuContext.d.ts +3 -0
  93. package/dist/types/components/DropdownMenu/DropdownMenuTrigger.d.ts +1 -1
  94. package/dist/types/components/Input/InputCore.d.ts +13 -0
  95. package/dist/types/components/Input/index.d.ts +2 -0
  96. package/dist/types/components/NumberInput/NumberInputCore.d.ts +15 -0
  97. package/dist/types/components/NumberInput/index.d.ts +2 -0
  98. package/dist/types/components/OTPInput/OTPInputCore.d.ts +8 -0
  99. package/dist/types/components/OTPInput/index.d.ts +2 -0
  100. package/dist/types/components/PasswordInput/PasswordInputCore.d.ts +9 -0
  101. package/dist/types/components/PasswordInput/index.d.ts +2 -0
  102. package/dist/types/components/Radio/RadioContext.d.ts +1 -2
  103. package/dist/types/components/Radio/RadioGroupCore.d.ts +10 -0
  104. package/dist/types/components/Radio/index.d.ts +2 -0
  105. package/dist/types/components/Rating/RatingCore.d.ts +9 -0
  106. package/dist/types/components/Rating/index.d.ts +2 -0
  107. package/dist/types/components/Segmented/Segmented.d.ts +1 -6
  108. package/dist/types/components/Segmented/SegmentedCore.d.ts +15 -0
  109. package/dist/types/components/Segmented/index.d.ts +2 -0
  110. package/dist/types/components/Select/SelectCore.d.ts +13 -0
  111. package/dist/types/components/Select/index.d.ts +2 -0
  112. package/dist/types/components/Slider/SliderCore.d.ts +11 -0
  113. package/dist/types/components/Slider/index.d.ts +2 -0
  114. package/dist/types/components/Switch/Switch.d.ts +1 -1
  115. package/dist/types/components/Switch/SwitchCore.d.ts +12 -0
  116. package/dist/types/components/Switch/index.d.ts +2 -0
  117. package/dist/types/components/TagInput/TagInputCore.d.ts +20 -0
  118. package/dist/types/components/TagInput/index.d.ts +2 -0
  119. package/dist/types/components/Textarea/TextareaCore.d.ts +12 -0
  120. package/dist/types/components/Textarea/index.d.ts +2 -0
  121. package/dist/types/components/TimePicker/TimePickerCore.d.ts +9 -0
  122. package/dist/types/components/TimePicker/index.d.ts +2 -0
  123. package/dist/types/components/Tooltip/Tooltip.d.ts +5 -1
  124. package/dist/types/form/FormItem.d.ts +86 -19
  125. package/dist/types/form/index.d.ts +2 -3
  126. package/dist/types/index.d.ts +36 -36
  127. package/dist/types/utils/floating.d.ts +99 -0
  128. package/dist/types/utils/menuKeyboard.d.ts +43 -0
  129. package/dist/utils/floating.js +181 -0
  130. package/dist/utils/menuKeyboard.js +88 -0
  131. package/package.json +45 -19
  132. package/dist/components/DropdownMenu/useMenuKeyboard.js +0 -52
  133. package/dist/form/useFormControl.js +0 -54
  134. package/dist/types/components/DropdownMenu/useMenuKeyboard.d.ts +0 -19
  135. package/dist/types/form/useFormControl.d.ts +0 -35
  136. package/dist/types/hooks/index.d.ts +0 -1
  137. package/dist/types/utils/index.d.ts +0 -1
@@ -0,0 +1,11 @@
1
+ import type { ComponentPropsWithoutRef } from 'react';
2
+ type SliderCoreProps = {
3
+ value: number;
4
+ onChange: (value: number) => void;
5
+ /** Native change event passthrough — invoked with the DOM event after
6
+ * `onChange`, so a spread can never override the controlled callback. */
7
+ onNativeChange?: ComponentPropsWithoutRef<'input'>['onChange'];
8
+ className?: string;
9
+ } & Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'value' | 'onChange'>;
10
+ export default function SliderCore({ value, onChange, onNativeChange, className, ...rest }: SliderCoreProps): import("react").JSX.Element;
11
+ export type { SliderCoreProps };
@@ -1,2 +1,4 @@
1
1
  export { default as Slider } from './Slider';
2
2
  export type { SliderProps } from './Slider';
3
+ export { default as SliderCore } from './SliderCore';
4
+ export type { SliderCoreProps } from './SliderCore';
@@ -3,6 +3,6 @@ import type { Control } from 'react-use-control';
3
3
  type SwitchProps = {
4
4
  checked?: Control<boolean> | boolean;
5
5
  size?: 'sm' | 'md' | 'lg';
6
- } & Omit<ComponentPropsWithoutRef<'button'>, 'type' | 'checked'>;
6
+ } & Omit<ComponentPropsWithoutRef<'button'>, 'type' | 'checked' | 'onChange'>;
7
7
  export default function Switch({ checked: checkedControl, size, className, onClick, ...rest }: SwitchProps): import("react").JSX.Element;
8
8
  export type { SwitchProps };
@@ -0,0 +1,12 @@
1
+ import type { ComponentPropsWithoutRef } from 'react';
2
+ type SwitchCoreProps = {
3
+ checked: boolean;
4
+ onChange: (checked: boolean) => void;
5
+ /** Native click event passthrough — invoked with the DOM event after
6
+ * `onChange`, so a spread can never override the controlled callback. */
7
+ onNativeClick?: ComponentPropsWithoutRef<'button'>['onClick'];
8
+ size?: 'sm' | 'md' | 'lg';
9
+ className?: string;
10
+ } & Omit<ComponentPropsWithoutRef<'button'>, 'type' | 'checked' | 'onChange'>;
11
+ export default function SwitchCore({ checked, onChange, onNativeClick, size, className, ...rest }: SwitchCoreProps): import("react").JSX.Element;
12
+ export type { SwitchCoreProps };
@@ -1,2 +1,4 @@
1
1
  export { default as Switch } from './Switch';
2
2
  export type { SwitchProps } from './Switch';
3
+ export { default as SwitchCore } from './SwitchCore';
4
+ export type { SwitchCoreProps } from './SwitchCore';
@@ -0,0 +1,20 @@
1
+ type TagInputCoreProps = {
2
+ value: string[];
3
+ onChange: (value: string[]) => void;
4
+ placeholder?: string;
5
+ maxTags?: number;
6
+ disabled?: boolean;
7
+ className?: string;
8
+ /**
9
+ * 字段 id(FormItem 桥生成):必须挂到内部可聚焦的 input 上而非根
10
+ * div,<label htmlFor> 与错误 span 的 aria 链路才能接到焦点元素——
11
+ * 根 div 不聚焦,挂那里等于断链。
12
+ */
13
+ id?: string;
14
+ /** 由 FormItem 桥传入,随字段错误态变化,透传给内部 input。 */
15
+ 'aria-invalid'?: boolean;
16
+ /** 指向 FormItem 渲染的错误 span(id={errorId}),透传给内部 input。 */
17
+ 'aria-describedby'?: string;
18
+ };
19
+ export default function TagInputCore({ value: tags, onChange, placeholder, maxTags, disabled, className, id, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedby, }: TagInputCoreProps): import("react").JSX.Element;
20
+ export type { TagInputCoreProps };
@@ -1,2 +1,4 @@
1
1
  export { default as TagInput } from './TagInput';
2
2
  export type { TagInputProps } from './TagInput';
3
+ export { default as TagInputCore } from './TagInputCore';
4
+ export type { TagInputCoreProps } from './TagInputCore';
@@ -0,0 +1,12 @@
1
+ import type { ComponentPropsWithoutRef } from 'react';
2
+ type TextareaCoreProps = {
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ /** Native change event passthrough — invoked with the DOM event after
6
+ * `onChange`, so a spread can never override the controlled callback. */
7
+ onNativeChange?: ComponentPropsWithoutRef<'textarea'>['onChange'];
8
+ size?: 'sm' | 'md' | 'lg';
9
+ className?: string;
10
+ } & Omit<ComponentPropsWithoutRef<'textarea'>, 'value' | 'onChange' | 'size'>;
11
+ export default function TextareaCore({ value, onChange, onNativeChange, size, className, ...rest }: TextareaCoreProps): import("react").JSX.Element;
12
+ export type { TextareaCoreProps };
@@ -1,2 +1,4 @@
1
1
  export { default as Textarea } from './Textarea';
2
2
  export type { TextareaProps } from './Textarea';
3
+ export { default as TextareaCore } from './TextareaCore';
4
+ export type { TextareaCoreProps } from './TextareaCore';
@@ -0,0 +1,9 @@
1
+ import type { ComponentPropsWithoutRef } from 'react';
2
+ type TimePickerCoreProps = {
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ placeholder?: string;
6
+ className?: string;
7
+ } & Omit<ComponentPropsWithoutRef<'input'>, 'value' | 'onChange' | 'type' | 'placeholder'>;
8
+ export default function TimePickerCore({ value, onChange, placeholder, className, ...rest }: TimePickerCoreProps): import("react").JSX.Element;
9
+ export type { TimePickerCoreProps };
@@ -1,2 +1,4 @@
1
1
  export { default as TimePicker } from './TimePicker';
2
2
  export type { TimePickerProps } from './TimePicker';
3
+ export { default as TimePickerCore } from './TimePickerCore';
4
+ export type { TimePickerCoreProps } from './TimePickerCore';
@@ -1,9 +1,13 @@
1
1
  import type { ReactNode } from 'react';
2
+ import type { Control } from 'react-use-control';
2
3
  type TooltipProps = {
3
4
  content: ReactNode;
4
5
  position?: 'top' | 'bottom' | 'left' | 'right';
6
+ /** Milliseconds of hover/focus before the tooltip appears. */
7
+ delay?: number;
8
+ open?: Control<boolean> | boolean;
5
9
  className?: string;
6
10
  children: ReactNode;
7
11
  };
8
- export default function Tooltip({ content, position, className, children, }: TooltipProps): import("react").JSX.Element;
12
+ export default function Tooltip({ content, position, delay, open: openControl, className, children, }: TooltipProps): import("react").JSX.Element;
9
13
  export type { TooltipProps };
@@ -1,20 +1,24 @@
1
- import type { ReactNode } from 'react';
2
- import type { FieldError, FieldPath, FieldRules, Name, ValidationMode } from 'react-f0rm';
3
- import type { Control } from 'react-use-control';
4
- import type { FormInstance, PathValueOf } from './useFormControl';
1
+ import type { ComponentType, ReactNode } from 'react';
2
+ import type { FieldError, FieldPath, FieldRules, Name, ValidationMode, FormInstance, PathValueOf } from 'react-f0rm';
5
3
  /**
6
4
  * Field-level validator, structurally compatible with react-f0rm's
7
5
  * `Validator`: return an error (string, FieldError, or an array mixing
8
6
  * both) or `undefined` when valid; return a Promise for async validation.
9
7
  * `meta.signal` aborts as soon as the round is superseded.
8
+ *
9
+ * Generic like react-f0rm's own `useField` `validate`: with `form` (a
10
+ * `FormInstance<TValues>`) and `name` (a `FieldPath<TValues>`) in scope,
11
+ * the value argument is `PathValueOf<TValues, P>` — the field's actual
12
+ * type — instead of `any`. The bare defaults keep untyped call sites
13
+ * exactly as permissive as before.
10
14
  */
11
- export type FieldValidator = (value: any, meta: {
15
+ export type FieldValidator<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name> = (value: PathValueOf<TValues, P>, meta: {
12
16
  form: FormInstance;
13
17
  signal: AbortSignal;
14
18
  }) => string | FieldError | (string | FieldError)[] | undefined | Promise<string | FieldError | (string | FieldError)[] | undefined>;
15
19
  /** Render binding handed to `FormItem`'s render-prop children. */
16
20
  export type FormItemBinding<TValues, P extends FieldPath<TValues> | Name> = {
17
- /** id for the field control element (`<Input id={id}>`) */
21
+ /** id for the field control element (`<InputCore id={id}>`) */
18
22
  id: string;
19
23
  /** id of the error message element; pass as `aria-describedby` */
20
24
  errorId: string;
@@ -23,19 +27,49 @@ export type FormItemBinding<TValues, P extends FieldPath<TValues> | Name> = {
23
27
  /** every error registered for the field, in insertion order */
24
28
  errors: FieldError[];
25
29
  /** react-f0rm blur hook for this field — pass to the control's `onBlur`
26
- * (`<Input onBlur={onBlur}/>`) so blur-scheduled validation modes
30
+ * (`<InputCore onBlur={onBlur}/>`) so blur-scheduled validation modes
27
31
  * (`mode='onBlur' | 'onTouched' | 'all'`) fire when the field loses focus. */
28
32
  onBlur: () => void;
29
- /** Control bound to the field value — pass to a control prop */
30
- control: Control<PathValueOf<TValues, P>>;
33
+ /** Field value subscribed per-field — pass to a controlled core
34
+ * (`<InputCore value={value} onChange={onChange} />`). */
35
+ value: PathValueOf<TValues, P>;
36
+ /** react-f0rm's own field-change writer — pass to the core's `onChange`.
37
+ * It routes through the same mode-gated, re-validating pipeline as
38
+ * react-f0rm's built-in Field/Checkbox/Select. */
39
+ onChange: (next: PathValueOf<TValues, P>) => void;
40
+ };
41
+ /**
42
+ * Declarative `as` binding for `FormItem` — the same props shape as
43
+ * react-f0rm `Field`'s `as` (deliberately *not* Radix's `asChild`): pass
44
+ * any component as the field control and `FormItem` wires the id, aria
45
+ * attributes, `onBlur` and `onChange` itself.
46
+ */
47
+ export type FormItemAsProps = {
48
+ /** Component rendered as the field control. When provided it takes
49
+ * precedence over the children render-prop. */
50
+ as?: ComponentType<any>;
51
+ /** Extra props spread onto the `as` component. They land before the
52
+ * value props, so `value`/`valueToProps` win conflicts — the same
53
+ * precedence react-f0rm's `Field` uses. */
54
+ asProps?: Record<string, any>;
55
+ /** Converts what the `as` component passes to its `onChange` into the
56
+ * field value. Defaults to identity — haze cores' `onChange` emits the
57
+ * next plain value; pass `(e) => e.target.value` when `as` is a raw
58
+ * DOM-element component. */
59
+ eventToValue?: (e: any) => any;
60
+ /** Derives the value props for the `as` component from the field value —
61
+ * e.g. `(checked) => ({checked})` for `CheckboxCore`. Defaults to
62
+ * passing `{value}`. */
63
+ valueToProps?: (value: any) => Record<string, any>;
31
64
  };
32
65
  export type FormItemProps<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name> = {
33
66
  form: FormInstance<TValues>;
34
67
  name: P;
35
68
  label?: ReactNode;
36
69
  /** Field-level validator, registered through react-f0rm's own
37
- * `useField` channel — validated per the form's `mode` and on submit. */
38
- validate?: FieldValidator;
70
+ * `useField` channel — validated per the form's `mode` and on submit.
71
+ * With a typed form the value argument is `PathValueOf<TValues, P>`. */
72
+ validate?: FieldValidator<TValues, P>;
39
73
  /** Per-field validation mode override (react-f0rm ≥0.6): when given,
40
74
  * this field validates on its own schedule — e.g. `'onBlur'` — instead
41
75
  * of the form's `mode`; other fields are unaffected. Omit to keep the
@@ -58,24 +92,57 @@ export type FormItemProps<TValues extends Record<string, any> = any, P extends F
58
92
  * `validate` — both sources' errors merge, rules errors ahead. Omit for
59
93
  * `validate`-only validation. */
60
94
  rules?: FieldRules;
95
+ /** Custom error renderer: when provided and the field has errors, the
96
+ * built-in error span renders `renderError(errors[0].message, errorId)`
97
+ * instead of the bare message. The span itself — id, `role='alert'`,
98
+ * styling — stays FormItem's, in both the `as` and children modes. */
99
+ renderError?: (error: string, id: string) => ReactNode;
61
100
  className?: string;
101
+ } & FormItemAsProps & ({
102
+ as: ComponentType<any>;
103
+ children?: never;
104
+ } | {
105
+ as?: undefined;
62
106
  children: (binding: FormItemBinding<TValues, P>) => ReactNode;
63
- };
107
+ });
64
108
  /**
65
- * Glue a single field of a react-f0rm form to a haze-ui control:
66
- * generates accessible ids, subscribes to the field's errors, and hands
67
- * both plus a `useFormControl` handle to the render-prop children.
109
+ * Glue a single field of a react-f0rm form to a haze-ui controlled core.
110
+ * The binding layer is react-f0rm's own headless `useField` hook — the
111
+ * same channel its built-in Field/Checkbox/Select use — so no adapter or
112
+ * state-bridge lives here. FormItem contributes only the view: label,
113
+ * error span and the id/aria convention.
68
114
  *
69
115
  * ```tsx
70
116
  * <FormItem form={form} name='email' label='Email'>
71
- * {({id, errorId, invalid, control}) => (
72
- * <Input id={id} value={control} aria-describedby={errorId} aria-invalid={invalid} />
117
+ * {({id, errorId, invalid, value, onChange}) => (
118
+ * <InputCore
119
+ * id={id}
120
+ * value={value}
121
+ * onChange={onChange}
122
+ * aria-describedby={errorId}
123
+ * aria-invalid={invalid}
124
+ * />
73
125
  * )}
74
126
  * </FormItem>
75
127
  * ```
76
128
  *
129
+ * Or declaratively, react-f0rm `Field`-style (`as` and children are
130
+ * mutually exclusive — pick one):
131
+ *
132
+ * ```tsx
133
+ * <FormItem form={form} name='email' label='Email' as={InputCore} />
134
+ * ```
135
+ *
136
+ * With `as`, the id/aria/onBlur/onChange wiring happens here: the control
137
+ * gets `id`, `aria-invalid`/`aria-describedby` while the field errors,
138
+ * and `onChange={(v) => onChange(toValue(v))}` where `toValue` defaults
139
+ * to identity (haze cores emit plain values — pass
140
+ * `eventToValue={(e) => e.target.value}` for a raw DOM element) and the
141
+ * value lands as `{value}` or, with `valueToProps`, whatever props the
142
+ * control wants (e.g. `{checked}` for CheckboxCore).
143
+ *
77
144
  * When the field has errors, the first error's message is rendered into a
78
- * `<span id={errorId} role='alert'>` next to the children; with no errors
145
+ * `<span id={errorId} role='alert'>` next to the control; with no errors
79
146
  * no extra element is rendered.
80
147
  */
81
- export default function FormItem<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name>({ form, name, label, validate, mode, validateDebounce, delayError, rules, className, children }: FormItemProps<TValues, P>): import("react").JSX.Element;
148
+ export default function FormItem<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name>({ form, name, label, validate, mode, validateDebounce, delayError, rules, className, renderError, as: As, asProps, eventToValue, valueToProps, children }: FormItemProps<TValues, P>): import("react").JSX.Element;
@@ -1,4 +1,3 @@
1
- export { useFormControl } from './useFormControl';
2
- export type { FormInstance, PathValueOf } from './useFormControl';
3
1
  export { default as FormItem } from './FormItem';
4
- export type { FieldValidator, FormItemBinding, FormItemProps } from './FormItem';
2
+ export type { FieldValidator, FormItemAsProps, FormItemBinding, FormItemProps } from './FormItem';
3
+ export type { FormInstance, PathValueOf } from 'react-f0rm';
@@ -5,14 +5,14 @@ export { TOKEN_REGISTRY, COMPONENT_TOKENS } from './tokens/registry';
5
5
  export type { TokenDef } from './tokens/registry';
6
6
  export { Button } from './components/Button';
7
7
  export type { ButtonProps } from './components/Button';
8
- export { Input } from './components/Input';
9
- export type { InputProps } from './components/Input';
10
- export { Select, Option } from './components/Select';
11
- export type { SelectProps, OptionProps } from './components/Select';
12
- export { Checkbox } from './components/Checkbox';
13
- export type { CheckboxProps } from './components/Checkbox';
14
- export { Switch } from './components/Switch';
15
- export type { SwitchProps } from './components/Switch';
8
+ export { Input, InputCore } from './components/Input';
9
+ export type { InputProps, InputCoreProps } from './components/Input';
10
+ export { Select, Option, SelectCore } from './components/Select';
11
+ export type { SelectProps, OptionProps, SelectCoreProps } from './components/Select';
12
+ export { Checkbox, CheckboxCore } from './components/Checkbox';
13
+ export type { CheckboxProps, CheckboxCoreProps } from './components/Checkbox';
14
+ export { Switch, SwitchCore } from './components/Switch';
15
+ export type { SwitchProps, SwitchCoreProps } from './components/Switch';
16
16
  export { Badge } from './components/Badge';
17
17
  export type { BadgeProps } from './components/Badge';
18
18
  export { Dialog } from './components/Dialog';
@@ -23,12 +23,12 @@ export { Popover } from './components/Popover';
23
23
  export type { PopoverProps } from './components/Popover';
24
24
  export { Card } from './components/Card';
25
25
  export type { CardProps } from './components/Card';
26
- export { Radio, RadioGroup } from './components/Radio';
27
- export type { RadioProps, RadioGroupProps } from './components/Radio';
28
- export { Textarea } from './components/Textarea';
29
- export type { TextareaProps } from './components/Textarea';
30
- export { Slider } from './components/Slider';
31
- export type { SliderProps } from './components/Slider';
26
+ export { Radio, RadioGroup, RadioGroupCore } from './components/Radio';
27
+ export type { RadioProps, RadioGroupProps, RadioGroupCoreProps } from './components/Radio';
28
+ export { Textarea, TextareaCore } from './components/Textarea';
29
+ export type { TextareaProps, TextareaCoreProps } from './components/Textarea';
30
+ export { Slider, SliderCore } from './components/Slider';
31
+ export type { SliderProps, SliderCoreProps } from './components/Slider';
32
32
  export { Tabs, TabList, Tab, TabPanel } from './components/Tabs';
33
33
  export type { TabsProps, TabListProps, TabProps, TabPanelProps, } from './components/Tabs';
34
34
  export { Accordion, AccordionItem } from './components/Accordion';
@@ -53,8 +53,8 @@ export { Disclosure } from './components/Disclosure';
53
53
  export type { DisclosureProps } from './components/Disclosure';
54
54
  export { Menu, MenuItem, MenuDivider } from './components/Menu';
55
55
  export type { MenuProps, MenuItemProps } from './components/Menu';
56
- export { NumberInput } from './components/NumberInput';
57
- export type { NumberInputProps } from './components/NumberInput';
56
+ export { NumberInput, NumberInputCore } from './components/NumberInput';
57
+ export type { NumberInputProps, NumberInputCoreProps } from './components/NumberInput';
58
58
  export { FileInput } from './components/FileInput';
59
59
  export type { FileInputProps } from './components/FileInput';
60
60
  export { Toast, ToastContainer, useToast } from './components/Toast';
@@ -67,8 +67,8 @@ export { Table, TableHead, TableBody, TableRow, TableCell, } from './components/
67
67
  export type { TableProps, TableHeadProps, TableBodyProps, TableRowProps, TableCellProps, } from './components/Table';
68
68
  export { Carousel, CarouselSlide } from './components/Carousel';
69
69
  export type { CarouselProps, CarouselSlideProps } from './components/Carousel';
70
- export { Datepicker } from './components/Datepicker';
71
- export type { DatepickerProps } from './components/Datepicker';
70
+ export { Datepicker, DatepickerCore } from './components/Datepicker';
71
+ export type { DatepickerProps, DatepickerCoreProps } from './components/Datepicker';
72
72
  export { Tree } from './components/Tree';
73
73
  export type { TreeProps, TreeNodeData } from './components/Tree';
74
74
  export { Divider } from './components/Divider';
@@ -97,32 +97,32 @@ export { Transfer } from './components/Transfer';
97
97
  export type { TransferProps, TransferItem } from './components/Transfer';
98
98
  export { Upload } from './components/Upload';
99
99
  export type { UploadProps } from './components/Upload';
100
- export { ColorPicker } from './components/ColorPicker';
101
- export type { ColorPickerProps } from './components/ColorPicker';
102
- export { Rating } from './components/Rating';
103
- export type { RatingProps } from './components/Rating';
100
+ export { ColorPicker, ColorPickerCore } from './components/ColorPicker';
101
+ export type { ColorPickerProps, ColorPickerCoreProps } from './components/ColorPicker';
102
+ export { Rating, RatingCore } from './components/Rating';
103
+ export type { RatingProps, RatingCoreProps } from './components/Rating';
104
104
  export { Timeline, TimelineItem } from './components/Timeline';
105
105
  export type { TimelineProps, TimelineItemProps } from './components/Timeline';
106
106
  export { Title, Text, Paragraph } from './components/Typography';
107
107
  export type { TitleProps, TextProps, ParagraphProps } from './components/Typography';
108
108
  export { Stat, StatGroup } from './components/Stat';
109
109
  export type { StatProps, StatGroupProps } from './components/Stat';
110
- export { Segmented } from './components/Segmented';
111
- export type { SegmentedProps } from './components/Segmented';
110
+ export { Segmented, SegmentedCore } from './components/Segmented';
111
+ export type { SegmentedProps, SegmentedCoreProps } from './components/Segmented';
112
112
  export { Chip } from './components/Chip';
113
113
  export type { ChipProps } from './components/Chip';
114
114
  export { ScrollArea } from './components/ScrollArea';
115
115
  export type { ScrollAreaProps } from './components/ScrollArea';
116
- export { TimePicker } from './components/TimePicker';
117
- export type { TimePickerProps } from './components/TimePicker';
118
- export { DateRangePicker } from './components/DateRangePicker';
119
- export type { DateRangePickerProps } from './components/DateRangePicker';
120
- export { OTPInput } from './components/OTPInput';
121
- export type { OTPInputProps } from './components/OTPInput';
122
- export { PasswordInput } from './components/PasswordInput';
123
- export type { PasswordInputProps } from './components/PasswordInput';
124
- export { TagInput } from './components/TagInput';
125
- export type { TagInputProps } from './components/TagInput';
116
+ export { TimePicker, TimePickerCore } from './components/TimePicker';
117
+ export type { TimePickerProps, TimePickerCoreProps } from './components/TimePicker';
118
+ export { DateRangePicker, DateRangePickerCore } from './components/DateRangePicker';
119
+ export type { DateRangePickerProps, DateRangePickerCoreProps } from './components/DateRangePicker';
120
+ export { OTPInput, OTPInputCore } from './components/OTPInput';
121
+ export type { OTPInputProps, OTPInputCoreProps } from './components/OTPInput';
122
+ export { PasswordInput, PasswordInputCore } from './components/PasswordInput';
123
+ export type { PasswordInputProps, PasswordInputCoreProps } from './components/PasswordInput';
124
+ export { TagInput, TagInputCore } from './components/TagInput';
125
+ export type { TagInputProps, TagInputCoreProps } from './components/TagInput';
126
126
  export { InlineEdit } from './components/InlineEdit';
127
127
  export type { InlineEditProps } from './components/InlineEdit';
128
128
  export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from './components/DropdownMenu';
@@ -181,6 +181,6 @@ export { DiffViewer } from './components/DiffViewer';
181
181
  export type { DiffViewerProps, DiffLine } from './components/DiffViewer';
182
182
  export { LogViewer } from './components/LogViewer';
183
183
  export type { LogViewerProps, LogEntry, LogLevel } from './components/LogViewer';
184
- export { FormItem, useFormControl } from './form';
185
- export type { FieldValidator, FormItemBinding, FormItemProps, FormInstance, PathValueOf, } from './form';
184
+ export { FormItem } from './form';
185
+ export type { FieldValidator, FormItemAsProps, FormItemBinding, FormItemProps, FormInstance, PathValueOf, } from './form';
186
186
  export { useControl } from 'react-use-control';
@@ -0,0 +1,99 @@
1
+ import type { ComponentProps, CSSProperties, Dispatch, ReactNode, RefObject, SetStateAction } from 'react';
2
+ /** Lazy feature detection so tests can flip between native and fallback. */
3
+ export declare function supportsNativePopover(): boolean;
4
+ /**
5
+ * Anchor positioning requires the popover API first: jsdom's
6
+ * `CSS.supports` returns true for arbitrary declarations, so it must never
7
+ * be trusted on its own.
8
+ */
9
+ export declare function supportsAnchorPositioning(): boolean;
10
+ declare const anchoredPlacements: {
11
+ readonly bottom: import("@linaria/core").LinariaClassName;
12
+ readonly 'bottom-span': import("@linaria/core").LinariaClassName;
13
+ readonly 'bottom-center': import("@linaria/core").LinariaClassName;
14
+ readonly 'bottom-end': import("@linaria/core").LinariaClassName;
15
+ readonly top: import("@linaria/core").LinariaClassName;
16
+ readonly left: import("@linaria/core").LinariaClassName;
17
+ readonly right: import("@linaria/core").LinariaClassName;
18
+ };
19
+ type AnchorablePlacement = keyof typeof anchoredPlacements;
20
+ /**
21
+ * Panel placement relative to the trigger. `point` leaves positioning
22
+ * entirely to the consumer (e.g. ContextMenu at the pointer coordinates).
23
+ */
24
+ export type FloatingPlacement = AnchorablePlacement | 'point';
25
+ type UseFloatingOptions = {
26
+ open: boolean;
27
+ setOpen: Dispatch<SetStateAction<boolean>>;
28
+ /** Element the panel is anchored to; also the outside-close boundary. */
29
+ triggerRef: RefObject<HTMLElement | null>;
30
+ /** The floating panel element. */
31
+ panelRef: RefObject<HTMLElement | null>;
32
+ };
33
+ export type FloatingBehavior = {
34
+ open: boolean;
35
+ native: boolean;
36
+ anchored: boolean;
37
+ /**
38
+ * Whether the panel element is actually shown right now (native path:
39
+ * mirrored from `toggle` events; fallback path: identical to `open`).
40
+ * Differs from `open` across the commit→effect gap: `open` flips when
41
+ * React commits, while the popover only becomes focusable/paintable
42
+ * after the effect calls showPopover(). Consumers that move focus into
43
+ * the panel on open must gate on `shown`, or the focus call lands on a
44
+ * display:none element and is silently dropped (Chromium).
45
+ */
46
+ shown: boolean;
47
+ /** Unique CSS anchor name for this instance (anchored path). */
48
+ anchorName: string;
49
+ /** Inline style for the trigger: declares `anchor-name`. */
50
+ triggerStyle: CSSProperties | undefined;
51
+ /** Spread on the trigger: records pointerdown for race attribution. */
52
+ onTriggerPointerDown: () => void;
53
+ /** Spread as the trigger's click handler: suppression-aware toggle. */
54
+ onTriggerClick: () => void;
55
+ /** Spread on the panel: popover attribute + anchor custom property. */
56
+ panelAttrs: {
57
+ popover: 'auto' | undefined;
58
+ style: CSSProperties | undefined;
59
+ };
60
+ /** Positioning-skeleton entries for the panel's x-class array. */
61
+ panelClasses: (string | false)[];
62
+ triggerRef: RefObject<HTMLElement | null>;
63
+ panelRef: RefObject<HTMLElement | null>;
64
+ };
65
+ export declare function useFloating({ open, setOpen, triggerRef, panelRef, }: UseFloatingOptions): FloatingBehavior;
66
+ /** x-class entries placing the panel relative to the trigger, per tier. */
67
+ export declare function floatingPlacementClasses(behavior: Pick<FloatingBehavior, 'native' | 'anchored'>, placement: FloatingPlacement): (string | false)[];
68
+ /**
69
+ * Tier 2 positioning: place the panel under/over/beside the trigger and
70
+ * re-place on scroll/resize while open. No-op on the anchored and
71
+ * fallback tiers.
72
+ */
73
+ export declare function useFloatingPosition({ behavior, placement, }: {
74
+ behavior: FloatingBehavior;
75
+ placement: FloatingPlacement;
76
+ }): void;
77
+ type FloatingPanelProps = {
78
+ /** Behavior record produced by `useFloating` at the floating root. */
79
+ behavior: FloatingBehavior;
80
+ /**
81
+ * Placement relative to the trigger. Omit (or pass 'point') when the
82
+ * consumer positions the panel itself, e.g. ContextMenu at the pointer.
83
+ */
84
+ placement?: FloatingPlacement;
85
+ /** Consumer visual skin: border, background, shadow, padding. */
86
+ visualClass?: string;
87
+ className?: string;
88
+ children?: ReactNode;
89
+ /** Merged with the anchor custom property the behavior may set. */
90
+ style?: CSSProperties;
91
+ } & Omit<ComponentProps<'div'>, 'className' | 'children' | 'style'>;
92
+ /**
93
+ * The panel element of a floating pair: applies the popover attribute,
94
+ * the anchor custom property and the tier/placement classes, and runs the
95
+ * tier-2 position effect. Everything else (id, role, handlers, ref) is
96
+ * passed through to the underlying div.
97
+ */
98
+ export declare function FloatingPanel({ behavior, placement, visualClass, className, style, children, ...rest }: FloatingPanelProps): import("react").JSX.Element;
99
+ export {};
@@ -0,0 +1,43 @@
1
+ import type { KeyboardEvent as ReactKeyboardEvent, RefObject } from 'react';
2
+ /** Enabled items inside a container, in DOM order. */
3
+ export declare function getEnabledMenuItems(container: HTMLElement | null, selector?: string): HTMLElement[];
4
+ type UseMenuKeyboardOptions = {
5
+ /** Element containing the item children (`[role=menuitem]` by default). */
6
+ menuRef: RefObject<HTMLElement | null>;
7
+ /**
8
+ * Called when the menu should close via keyboard; the caller returns
9
+ * focus to the trigger.
10
+ */
11
+ onClose: () => void;
12
+ /**
13
+ * Item selector for containers that are not a `role="menu"` — e.g. the
14
+ * `[role=option]` list of a Command palette.
15
+ */
16
+ selector?: string;
17
+ };
18
+ /**
19
+ * Keyboard behavior for a roving-tabindex item container (WAI-ARIA menu
20
+ * button / listbox pattern): ↑/↓ move focus (wrapping, skipping disabled
21
+ * items), Home/End jump to the ends, Escape closes (returning focus to
22
+ * the trigger), Tab closes, and printable characters run typeahead.
23
+ */
24
+ export declare function useMenuKeyboard({ menuRef, onClose, selector, }: UseMenuKeyboardOptions): (event: ReactKeyboardEvent) => void;
25
+ type UseRovingTabindexOptions = {
26
+ menuRef: RefObject<HTMLElement | null>;
27
+ /**
28
+ * While false the effect is inert — panels that stay mounted when
29
+ * closed (Menu, Combobox-style listboxes) manage the tab stops only
30
+ * while open.
31
+ */
32
+ active: boolean;
33
+ selector?: string;
34
+ };
35
+ /**
36
+ * Roving tabindex for a menu/listbox container: exactly one item is a tab
37
+ * stop at any time. On activation the current stop is kept (first item
38
+ * initially); a `focusin` listener moves the stop with focus, and a
39
+ * MutationObserver re-syncs when the item set changes (e.g. a filtered
40
+ * Command list).
41
+ */
42
+ export declare function useRovingTabindex({ menuRef, active, selector, }: UseRovingTabindexOptions): void;
43
+ export {};