@wix/site-ui 1.29.0 → 1.31.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 (177) hide show
  1. package/dist/1268.js +99 -0
  2. package/dist/1279.js +7 -0
  3. package/dist/1457.js +10 -0
  4. package/dist/1477.js +106 -0
  5. package/dist/1500.js +111 -0
  6. package/dist/167.js +6 -0
  7. package/dist/2274.js +34 -0
  8. package/dist/2287.js +17 -0
  9. package/dist/2418.js +31 -0
  10. package/dist/2801.js +20 -0
  11. package/dist/285.js +86 -0
  12. package/dist/2861.js +6 -0
  13. package/dist/3020.js +7 -0
  14. package/dist/3021.js +72 -0
  15. package/dist/3056.js +229 -0
  16. package/dist/3140.js +4 -0
  17. package/dist/3248.js +307 -0
  18. package/dist/3296.js +4 -0
  19. package/dist/3319.js +400 -0
  20. package/dist/3395.js +4 -0
  21. package/dist/3485.js +854 -0
  22. package/dist/353.js +14 -0
  23. package/dist/3670.js +418 -0
  24. package/dist/3829.js +113 -0
  25. package/dist/4026.js +12 -0
  26. package/dist/4143.js +46 -0
  27. package/dist/42.js +32 -0
  28. package/dist/4281.js +30 -0
  29. package/dist/4346.js +2 -0
  30. package/dist/4388.js +418 -0
  31. package/dist/4490.js +32 -0
  32. package/dist/4495.js +9 -0
  33. package/dist/4549.js +24 -0
  34. package/dist/4586.js +41 -0
  35. package/dist/4586.js.LICENSE.txt +19 -0
  36. package/dist/4707.js +19 -0
  37. package/dist/4723.js +7 -0
  38. package/dist/4745.js +7 -0
  39. package/dist/4768.js +35 -0
  40. package/dist/4922.js +15 -0
  41. package/dist/5036.js +17 -0
  42. package/dist/5085.js +20 -0
  43. package/dist/5299.js +597 -0
  44. package/dist/5659.js +4 -0
  45. package/dist/5778.js +10 -0
  46. package/dist/5864.js +86 -0
  47. package/dist/5992.js +913 -0
  48. package/dist/5992.js.LICENSE.txt +19 -0
  49. package/dist/6003.js +10 -0
  50. package/dist/6046.js +29 -0
  51. package/dist/6089.js +2355 -0
  52. package/dist/6107.js +10 -0
  53. package/dist/6247.js +20 -0
  54. package/dist/6270.js +487 -0
  55. package/dist/6329.js +32 -0
  56. package/dist/6330.js +30 -0
  57. package/dist/6499.js +7 -0
  58. package/dist/6535.js +71 -0
  59. package/dist/6588.js +382 -0
  60. package/dist/6706.js +16 -0
  61. package/dist/6825.js +7 -0
  62. package/dist/6882.js +1562 -0
  63. package/dist/6914.js +30 -0
  64. package/dist/7021.js +13 -0
  65. package/dist/7366.js +83 -0
  66. package/dist/7373.js +25 -0
  67. package/dist/7541.js +25 -0
  68. package/dist/7564.js +10 -0
  69. package/dist/7642.js +20 -0
  70. package/dist/7725.js +10 -0
  71. package/dist/7871.js +38 -0
  72. package/dist/8052.js +352 -0
  73. package/dist/8106.js +238 -0
  74. package/dist/8171.js +346 -0
  75. package/dist/8225.js +21 -0
  76. package/dist/8272.js +333 -0
  77. package/dist/8527.js +58 -0
  78. package/dist/8724.js +10 -0
  79. package/dist/8750.js +1920 -0
  80. package/dist/8758.js +43 -0
  81. package/dist/880.js +149 -0
  82. package/dist/8935.js +8 -0
  83. package/dist/8960.js +22 -0
  84. package/dist/8971.js +40 -0
  85. package/dist/8979.js +10 -0
  86. package/dist/8996.js +71 -0
  87. package/dist/904.js +121 -0
  88. package/dist/9048.js +52 -0
  89. package/dist/9087.js +256 -0
  90. package/dist/9189.js +158 -0
  91. package/dist/9255.js +136 -0
  92. package/dist/9352.js +148 -0
  93. package/dist/951.js +22 -0
  94. package/dist/9635.js +22 -0
  95. package/dist/9829.js +4 -0
  96. package/dist/9863.js +8 -0
  97. package/dist/Accordion/index.d.ts +569 -12
  98. package/dist/Accordion/index.js +423 -8
  99. package/dist/AlertDialog/index.d.ts +1417 -18
  100. package/dist/AlertDialog/index.js +34 -14
  101. package/dist/Autocomplete/index.d.ts +1861 -38
  102. package/dist/Autocomplete/index.js +98 -24
  103. package/dist/Avatar/index.d.ts +129 -7
  104. package/dist/Avatar/index.js +149 -6
  105. package/dist/Badge/index.css +44 -0
  106. package/dist/Badge/index.d.ts +22 -0
  107. package/dist/Badge/index.js +23 -0
  108. package/dist/Breadcrumbs/index.d.ts +960 -7
  109. package/dist/Breadcrumbs/index.js +5 -5
  110. package/dist/Button/index.d.ts +88 -6
  111. package/dist/Button/index.js +27 -3
  112. package/dist/Checkbox/index.d.ts +425 -5
  113. package/dist/Checkbox/index.js +45 -5
  114. package/dist/CheckboxGroup/index.d.ts +318 -3
  115. package/dist/CheckboxGroup/index.js +166 -3
  116. package/dist/Collapsible/index.d.ts +377 -7
  117. package/dist/Collapsible/index.js +160 -6
  118. package/dist/Combobox/index.d.ts +1984 -48
  119. package/dist/Combobox/index.js +352 -29
  120. package/dist/ContextMenu/index.d.ts +2340 -36
  121. package/dist/ContextMenu/index.js +197 -22
  122. package/dist/Dialog/index.d.ts +1355 -18
  123. package/dist/Dialog/index.js +16 -14
  124. package/dist/Drawer/index.d.ts +1653 -18
  125. package/dist/Drawer/index.js +2797 -20
  126. package/dist/Field/index.d.ts +655 -15
  127. package/dist/Field/index.js +677 -10
  128. package/dist/Fieldset/index.d.ts +94 -5
  129. package/dist/Fieldset/index.js +68 -5
  130. package/dist/Form/index.d.ts +331 -2
  131. package/dist/Form/index.js +106 -3
  132. package/dist/Input/index.d.ts +692 -3
  133. package/dist/Input/index.js +10 -3
  134. package/dist/Menu/index.d.ts +2301 -36
  135. package/dist/Menu/index.js +365 -26
  136. package/dist/Menubar/index.d.ts +2301 -3
  137. package/dist/Menubar/index.js +105 -3
  138. package/dist/Meter/index.d.ts +175 -11
  139. package/dist/Meter/index.js +129 -9
  140. package/dist/NavigationMenu/index.d.ts +978 -28
  141. package/dist/NavigationMenu/index.js +1034 -17
  142. package/dist/NumberField/index.d.ts +612 -15
  143. package/dist/NumberField/index.js +1409 -11
  144. package/dist/Popover/index.d.ts +1655 -20
  145. package/dist/Popover/index.js +792 -17
  146. package/dist/PreviewCard/index.d.ts +1523 -14
  147. package/dist/PreviewCard/index.js +679 -14
  148. package/dist/Progress/index.d.ts +183 -11
  149. package/dist/Progress/index.js +181 -9
  150. package/dist/Radio/index.d.ts +185 -6
  151. package/dist/Radio/index.js +253 -6
  152. package/dist/RadioGroup/index.d.ts +341 -2
  153. package/dist/RadioGroup/index.js +154 -3
  154. package/dist/ScrollArea/index.d.ts +265 -13
  155. package/dist/ScrollArea/index.js +892 -10
  156. package/dist/Select/index.d.ts +1493 -38
  157. package/dist/Select/index.js +1824 -23
  158. package/dist/Separator/index.d.ts +80 -6
  159. package/dist/Separator/index.js +3 -3
  160. package/dist/Slider/index.d.ts +678 -16
  161. package/dist/Slider/index.js +1199 -11
  162. package/dist/Switch/index.d.ts +393 -5
  163. package/dist/Switch/index.js +208 -6
  164. package/dist/Tabs/index.d.ts +523 -12
  165. package/dist/Tabs/index.js +685 -9
  166. package/dist/Toggle/index.d.ts +305 -2
  167. package/dist/Toggle/index.js +76 -3
  168. package/dist/ToggleGroup/index.d.ts +316 -2
  169. package/dist/ToggleGroup/index.js +102 -3
  170. package/dist/Toolbar/index.d.ts +282 -13
  171. package/dist/Toolbar/index.js +230 -9
  172. package/dist/Tooltip/index.d.ts +1572 -14
  173. package/dist/Tooltip/index.js +965 -14
  174. package/dist/index.d.ts +12758 -646
  175. package/dist/index.js +1 -0
  176. package/dist/rslib-runtime.js +18 -0
  177. package/package.json +3 -3
@@ -1,17 +1,106 @@
1
- import { FieldsetLegendProps } from '@base-ui/react/fieldset';
2
- import { FieldsetRootProps } from '@base-ui/react/fieldset';
1
+ import { FieldsetLegendProps as FieldsetLegendProps_2 } from '@base-ui/react/fieldset';
2
+ import { FieldsetRootProps as FieldsetRootProps_2 } from '@base-ui/react/fieldset';
3
3
  import * as React_2 from 'react';
4
4
 
5
+ /**
6
+ * Props shared by all Base UI components.
7
+ * Contains `className` (string or callback taking the component's state as an argument) and `render` (function to customize rendering).
8
+ */
9
+ declare type BaseUIComponentProps<ElementType extends React_2.ElementType, State, RenderFunctionProps = HTMLProps> = Omit<WithBaseUIEvent<React_2.ComponentPropsWithRef<ElementType>>, 'className' | 'color' | 'defaultValue' | 'defaultChecked' | 'style'> & {
10
+ /**
11
+ * CSS class applied to the element, or a function that
12
+ * returns a class based on the component's state.
13
+ */
14
+ className?: string | ((state: State) => string | undefined) | undefined;
15
+ /**
16
+ * Allows you to replace the component's HTML element
17
+ * with a different tag, or compose it with another component.
18
+ *
19
+ * Accepts a `ReactElement` or a function that returns the element to render.
20
+ */
21
+ render?: React_2.ReactElement | ComponentRenderFn<RenderFunctionProps, State> | undefined;
22
+ /**
23
+ * Style applied to the element, or a function that
24
+ * returns a style object based on the component's state.
25
+ */
26
+ style?: React_2.CSSProperties | ((state: State) => React_2.CSSProperties | undefined) | undefined;
27
+ };
28
+
29
+ declare type BaseUIEvent<E extends React_2.SyntheticEvent<Element, Event>> = E & {
30
+ preventBaseUIHandler: () => void;
31
+ readonly baseUIHandlerPrevented?: boolean | undefined;
32
+ };
33
+
34
+ /**
35
+ * Shape of the render prop: a function that takes props to be spread on the element and component's state and returns a React element.
36
+ *
37
+ * @template Props Props to be spread on the rendered element.
38
+ * @template State Component's internal state.
39
+ */
40
+ declare type ComponentRenderFn<Props, State> = (props: Props, state: State) => React_2.ReactElement<unknown>;
41
+
5
42
  export declare const Fieldset: {
6
- Root: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<FieldsetRootProps, "ref"> & React_2.RefAttributes<HTMLElement>, "ref">, "className"> & {
43
+ Root: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<FieldsetRootProps_2, "ref"> & React_2.RefAttributes<HTMLElement>, "ref">, "className"> & {
7
44
  className?: string | undefined;
8
45
  } & React_2.RefAttributes<HTMLElement>>;
9
- Legend: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<FieldsetLegendProps, "ref"> & React_2.RefAttributes<HTMLDivElement>, "ref">, "className"> & {
46
+ Legend: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<FieldsetLegendProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>, "ref">, "className"> & {
10
47
  className?: string | undefined;
11
48
  } & React_2.RefAttributes<HTMLDivElement>>;
12
49
  };
13
50
 
51
+ /**
52
+ * An accessible label that is automatically associated with the fieldset.
53
+ * Renders a `<div>` element.
54
+ *
55
+ * Documentation: [Base UI Fieldset](https://base-ui.com/react/components/fieldset)
56
+ */
57
+ export declare const FieldsetLegend: React_2.ForwardRefExoticComponent<Omit<FieldsetLegendProps, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
58
+
59
+ export declare namespace FieldsetLegend {
60
+ export type State = FieldsetLegendState;
61
+ export type Props = FieldsetLegendProps;
62
+ }
63
+
64
+ export declare interface FieldsetLegendProps extends BaseUIComponentProps<'div', FieldsetLegendState> {}
65
+
66
+ export declare interface FieldsetLegendState {
67
+ /**
68
+ * Whether the component should ignore user interaction.
69
+ */
70
+ disabled: boolean;
71
+ }
72
+
73
+ /**
74
+ * Groups a shared legend with related controls.
75
+ * Renders a `<fieldset>` element.
76
+ *
77
+ * Documentation: [Base UI Fieldset](https://base-ui.com/react/components/fieldset)
78
+ */
79
+ export declare const FieldsetRoot: React_2.ForwardRefExoticComponent<Omit<FieldsetRootProps, "ref"> & React_2.RefAttributes<HTMLElement>>;
80
+
81
+ export declare namespace FieldsetRoot {
82
+ export type State = FieldsetRootState;
83
+ export type Props = FieldsetRootProps;
84
+ }
85
+
86
+ export declare interface FieldsetRootProps extends BaseUIComponentProps<'fieldset', FieldsetRootState> {}
87
+
88
+ export declare interface FieldsetRootState {
89
+ /**
90
+ * Whether the component should ignore user interaction.
91
+ */
92
+ disabled: boolean;
93
+ }
94
+
95
+ declare type HTMLProps<T = any> = React_2.HTMLAttributes<T> & {
96
+ ref?: React_2.Ref<T> | undefined;
97
+ };
98
+
99
+ /**
100
+ * Adds a `preventBaseUIHandler` method to all event handlers.
101
+ */
102
+ declare type WithBaseUIEvent<T> = { [K in keyof T]: WithPreventBaseUIHandler<T[K]> };
14
103
 
15
- export * from "@base-ui/react/fieldset";
104
+ declare type WithPreventBaseUIHandler<T> = T extends ((event: infer E) => any) ? E extends React_2.SyntheticEvent<Element, Event> ? (event: BaseUIEvent<E>) => ReturnType<T> : T : T extends undefined ? undefined : T;
16
105
 
17
106
  export { }
@@ -1,22 +1,85 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Fieldset } from "@base-ui/react/fieldset";
3
2
  import clsx from "clsx";
3
+ import { useRenderElement } from "../8272.js";
4
+ import { FieldsetRootContext, useFieldsetRootContext } from "../353.js";
5
+ import { useBaseUiId } from "../6046.js";
6
+ import { useIsoLayoutEffect } from "../6499.js";
4
7
  import * as __rspack_external_react from "react";
8
+ const FieldsetRoot_FieldsetRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
9
+ const { render, className, style, disabled = false, ...elementProps } = componentProps;
10
+ const [legendId, setLegendId] = __rspack_external_react.useState(void 0);
11
+ const state = {
12
+ disabled
13
+ };
14
+ const element = useRenderElement('fieldset', componentProps, {
15
+ ref: forwardedRef,
16
+ state,
17
+ props: [
18
+ {
19
+ 'aria-labelledby': legendId
20
+ },
21
+ elementProps
22
+ ]
23
+ });
24
+ const contextValue = __rspack_external_react.useMemo(()=>({
25
+ legendId,
26
+ setLegendId,
27
+ disabled
28
+ }), [
29
+ legendId,
30
+ setLegendId,
31
+ disabled
32
+ ]);
33
+ return /*#__PURE__*/ jsx(FieldsetRootContext.Provider, {
34
+ value: contextValue,
35
+ children: element
36
+ });
37
+ });
38
+ if ("production" !== process.env.NODE_ENV) FieldsetRoot_FieldsetRoot.displayName = "FieldsetRoot";
39
+ const FieldsetLegend_FieldsetLegend = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
40
+ const { render, className, style, id: idProp, ...elementProps } = componentProps;
41
+ const { disabled, setLegendId } = useFieldsetRootContext();
42
+ const id = useBaseUiId(idProp);
43
+ useIsoLayoutEffect(()=>{
44
+ setLegendId(id);
45
+ return ()=>{
46
+ setLegendId(void 0);
47
+ };
48
+ }, [
49
+ setLegendId,
50
+ id
51
+ ]);
52
+ const state = {
53
+ disabled: disabled ?? false
54
+ };
55
+ const element = useRenderElement('div', componentProps, {
56
+ state,
57
+ ref: forwardedRef,
58
+ props: [
59
+ {
60
+ id
61
+ },
62
+ elementProps
63
+ ]
64
+ });
65
+ return element;
66
+ });
67
+ if ("production" !== process.env.NODE_ENV) FieldsetLegend_FieldsetLegend.displayName = "FieldsetLegend";
5
68
  const Fieldset_module = {
6
69
  root: "root-v8M2Sx"
7
70
  };
8
- const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Fieldset.Root, {
71
+ const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(FieldsetRoot_FieldsetRoot, {
9
72
  ref: ref,
10
73
  className: clsx(Fieldset_module.root, className),
11
74
  ...props
12
75
  }));
13
- const Legend = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Fieldset.Legend, {
76
+ const Legend = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(FieldsetLegend_FieldsetLegend, {
14
77
  ref: ref,
15
78
  className: clsx(Fieldset_module.legend, className),
16
79
  ...props
17
80
  }));
18
- const Fieldset_Fieldset = {
81
+ const Fieldset = {
19
82
  Root: Root,
20
83
  Legend: Legend
21
84
  };
22
- export { Fieldset_Fieldset as Fieldset };
85
+ export { Fieldset };
@@ -1,13 +1,342 @@
1
- import { Form as Form_2 } from '@base-ui/react/form';
2
1
  import * as React_2 from 'react';
3
2
 
3
+ /**
4
+ * Props shared by all Base UI components.
5
+ * Contains `className` (string or callback taking the component's state as an argument) and `render` (function to customize rendering).
6
+ */
7
+ declare type BaseUIComponentProps<ElementType extends React_2.ElementType, State, RenderFunctionProps = HTMLProps> = Omit<WithBaseUIEvent<React_2.ComponentPropsWithRef<ElementType>>, 'className' | 'color' | 'defaultValue' | 'defaultChecked' | 'style'> & {
8
+ /**
9
+ * CSS class applied to the element, or a function that
10
+ * returns a class based on the component's state.
11
+ */
12
+ className?: string | ((state: State) => string | undefined) | undefined;
13
+ /**
14
+ * Allows you to replace the component's HTML element
15
+ * with a different tag, or compose it with another component.
16
+ *
17
+ * Accepts a `ReactElement` or a function that returns the element to render.
18
+ */
19
+ render?: React_2.ReactElement | ComponentRenderFn<RenderFunctionProps, State> | undefined;
20
+ /**
21
+ * Style applied to the element, or a function that
22
+ * returns a style object based on the component's state.
23
+ */
24
+ style?: React_2.CSSProperties | ((state: State) => React_2.CSSProperties | undefined) | undefined;
25
+ };
26
+
27
+ declare type BaseUIEvent<E extends React_2.SyntheticEvent<Element, Event>> = E & {
28
+ preventBaseUIHandler: () => void;
29
+ readonly baseUIHandlerPrevented?: boolean | undefined;
30
+ };
31
+
32
+ /**
33
+ * Details of custom generic events emitted by Base UI components.
34
+ */
35
+ declare type BaseUIGenericEventDetail<Reason extends string, CustomProperties extends object> = {
36
+ /**
37
+ * The reason for the event.
38
+ */
39
+ reason: Reason;
40
+ /**
41
+ * The native event associated with the custom event.
42
+ */
43
+ event: ReasonToEvent<Reason>;
44
+ } & CustomProperties;
45
+
46
+ declare type BaseUIGenericEventDetails<Reason extends string, CustomProperties extends object = {}> = Reason extends string ? BaseUIGenericEventDetail<Reason, CustomProperties> & {} : never;
47
+
48
+ declare const cancelOpen: "cancel-open";
49
+
50
+ declare const chipRemovePress: "chip-remove-press";
51
+
52
+ declare const clearPress: "clear-press";
53
+
54
+ declare const closePress: "close-press";
55
+
56
+ declare const closeWatcher: "close-watcher";
57
+
58
+ /**
59
+ * Shape of the render prop: a function that takes props to be spread on the element and component's state and returns a React element.
60
+ *
61
+ * @template Props Props to be spread on the rendered element.
62
+ * @template State Component's internal state.
63
+ */
64
+ declare type ComponentRenderFn<Props, State> = (props: Props, state: State) => React_2.ReactElement<unknown>;
65
+
66
+ declare const decrementPress: "decrement-press";
67
+
68
+ declare const disabled: "disabled";
69
+
70
+ declare const drag: "drag";
71
+
72
+ declare type Errors = Record<string, string | string[]>;
73
+
74
+ declare const escapeKey: "escape-key";
75
+
76
+ declare interface FieldValidityData {
77
+ state: {
78
+ badInput: boolean;
79
+ customError: boolean;
80
+ patternMismatch: boolean;
81
+ rangeOverflow: boolean;
82
+ rangeUnderflow: boolean;
83
+ stepMismatch: boolean;
84
+ tooLong: boolean;
85
+ tooShort: boolean;
86
+ typeMismatch: boolean;
87
+ valueMissing: boolean;
88
+ valid: boolean | null;
89
+ };
90
+ error: string;
91
+ errors: string[];
92
+ value: unknown;
93
+ initialValue: unknown;
94
+ }
95
+
96
+ declare const focusOut: "focus-out";
97
+
4
98
  export declare const Form: React_2.ForwardRefExoticComponent<Omit<Omit<Form_2.Props<Record<string, any>> & {
5
99
  ref?: React_2.Ref<HTMLFormElement> | undefined;
6
100
  }, "ref">, "className"> & {
7
101
  className?: string | undefined;
8
102
  } & React_2.RefAttributes<HTMLFormElement>>;
9
103
 
104
+ /**
105
+ * A native form element with consolidated error handling.
106
+ * Renders a `<form>` element.
107
+ *
108
+ * Documentation: [Base UI Form](https://base-ui.com/react/components/form)
109
+ */
110
+ declare const Form_2: {
111
+ <FormValues extends Record<string, any> = Record<string, any>>(props: Form_2.Props<FormValues> & {
112
+ ref?: React_2.Ref<HTMLFormElement> | undefined;
113
+ }): React_2.JSX.Element;
114
+ };
115
+
116
+ declare namespace Form_2 {
117
+ type Props<FormValues extends Record<string, any> = Record<string, any>> = FormProps<FormValues>;
118
+ type State = FormState;
119
+ type Actions = FormActions;
120
+ type ValidationMode = FormValidationMode;
121
+ type SubmitEventReason = FormSubmitEventReason;
122
+ type SubmitEventDetails = FormSubmitEventDetails;
123
+ type Values<FormValues extends Record<string, any> = Record<string, any>> = FormValues;
124
+ }
125
+
126
+ export declare interface FormActions {
127
+ validate: (fieldName?: string | undefined) => void;
128
+ }
129
+
130
+ declare interface FormContext {
131
+ errors: Errors;
132
+ clearErrors: (name: string | undefined) => void;
133
+ formRef: React_2.RefObject<{
134
+ fields: Map<string, {
135
+ name: string | undefined;
136
+ /**
137
+ * After this returns, the field registry entry reflects the latest synchronous
138
+ * validity verdict. Async validators do not block submit.
139
+ */
140
+ validate: () => void;
141
+ validityData: FieldValidityData;
142
+ controlRef: React_2.RefObject<HTMLElement | null>;
143
+ getValue: () => unknown;
144
+ }>;
145
+ }>;
146
+ validationMode: Form_2.ValidationMode;
147
+ submitAttemptedRef: React_2.RefObject<boolean>;
148
+ }
149
+
150
+ declare const FormContext: React_2.Context<FormContext>;
151
+
152
+ export declare interface FormProps<FormValues extends Record<string, any> = Record<string, any>> extends BaseUIComponentProps<'form', FormState> {
153
+ /**
154
+ * Determines when the form should be validated.
155
+ * The `validationMode` prop on `<Field.Root>` takes precedence over this.
156
+ *
157
+ * - `onSubmit` (default): validates the field when the form is submitted, afterwards fields will re-validate on change.
158
+ * - `onBlur`: validates a field when it loses focus.
159
+ * - `onChange`: validates the field on every change to its value.
160
+ *
161
+ * @default 'onSubmit'
162
+ */
163
+ validationMode?: FormValidationMode | undefined;
164
+ /**
165
+ * Validation errors returned externally, typically after submission by a server or a form action.
166
+ * This should be an object where keys correspond to the `name` attribute on `<Field.Root>`,
167
+ * and values correspond to error(s) related to that field.
168
+ */
169
+ errors?: FormContext['errors'] | undefined;
170
+ /**
171
+ * Event handler called when the form is submitted.
172
+ * `preventDefault()` is called on the native submit event when used.
173
+ */
174
+ onFormSubmit?: ((formValues: FormValues, eventDetails: Form_2.SubmitEventDetails) => void) | undefined;
175
+ /**
176
+ * A ref to imperative actions.
177
+ * - `validate`: Validates all fields when called. Optionally pass a field name to validate a single field.
178
+ * @example
179
+ * ```tsx
180
+ * // validate all fields
181
+ * actionsRef.current.validate();
182
+ *
183
+ * // validate one field
184
+ * actionsRef.current.validate('email');
185
+ * ```
186
+ */
187
+ actionsRef?: React_2.RefObject<Form_2.Actions | null> | undefined;
188
+ }
189
+
190
+ export declare interface FormState {}
191
+
192
+ export declare type FormSubmitEventDetails = BaseUIGenericEventDetails<Form_2.SubmitEventReason>;
193
+
194
+ export declare type FormSubmitEventReason = typeof REASONS.none;
195
+
196
+ export declare type FormValidationMode = 'onSubmit' | 'onBlur' | 'onChange';
197
+
198
+ declare type HTMLProps<T = any> = React_2.HTMLAttributes<T> & {
199
+ ref?: React_2.Ref<T> | undefined;
200
+ };
201
+
202
+ declare const imperativeAction: "imperative-action";
203
+
204
+ declare const incrementPress: "increment-press";
205
+
206
+ declare const initial: "initial";
207
+
208
+ declare const inputBlur: "input-blur";
209
+
210
+ declare const inputChange: "input-change";
211
+
212
+ declare const inputClear: "input-clear";
213
+
214
+ declare const inputPaste: "input-paste";
215
+
216
+ declare const inputPress: "input-press";
217
+
218
+ declare const itemPress: "item-press";
219
+
220
+ declare const keyboard: "keyboard";
221
+
222
+ declare const linkPress: "link-press";
223
+
224
+ declare const listNavigation: "list-navigation";
225
+
226
+ declare const missing: "missing";
227
+
228
+ declare const none: "none";
229
+
230
+ declare const outsidePress: "outside-press";
231
+
232
+ declare const pointer: "pointer";
233
+
234
+ declare namespace REASONS {
235
+ export {
236
+ none,
237
+ triggerPress,
238
+ triggerHover,
239
+ triggerFocus,
240
+ outsidePress,
241
+ itemPress,
242
+ closePress,
243
+ linkPress,
244
+ clearPress,
245
+ chipRemovePress,
246
+ trackPress,
247
+ incrementPress,
248
+ decrementPress,
249
+ inputChange,
250
+ inputClear,
251
+ inputBlur,
252
+ inputPaste,
253
+ inputPress,
254
+ focusOut,
255
+ escapeKey,
256
+ closeWatcher,
257
+ listNavigation,
258
+ keyboard,
259
+ pointer,
260
+ drag,
261
+ wheel,
262
+ scrub,
263
+ cancelOpen,
264
+ siblingOpen,
265
+ disabled,
266
+ missing,
267
+ initial,
268
+ imperativeAction,
269
+ swipe,
270
+ windowResize
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Maps a change `reason` string to the corresponding native event type.
276
+ */
277
+ declare type ReasonToEvent<Reason extends string> = Reason extends keyof ReasonToEventMap ? ReasonToEventMap[Reason] : Event;
278
+
279
+ declare interface ReasonToEventMap {
280
+ [REASONS.none]: Event;
281
+ [REASONS.triggerPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
282
+ [REASONS.triggerHover]: MouseEvent;
283
+ [REASONS.triggerFocus]: FocusEvent;
284
+ [REASONS.outsidePress]: MouseEvent | PointerEvent | TouchEvent;
285
+ [REASONS.itemPress]: MouseEvent | KeyboardEvent | PointerEvent;
286
+ [REASONS.closePress]: MouseEvent | KeyboardEvent | PointerEvent;
287
+ [REASONS.linkPress]: MouseEvent | PointerEvent;
288
+ [REASONS.clearPress]: PointerEvent | MouseEvent | KeyboardEvent;
289
+ [REASONS.chipRemovePress]: PointerEvent | MouseEvent | KeyboardEvent;
290
+ [REASONS.trackPress]: PointerEvent | MouseEvent | TouchEvent;
291
+ [REASONS.incrementPress]: PointerEvent | MouseEvent | TouchEvent;
292
+ [REASONS.decrementPress]: PointerEvent | MouseEvent | TouchEvent;
293
+ [REASONS.inputChange]: InputEvent | Event;
294
+ [REASONS.inputClear]: InputEvent | FocusEvent | Event;
295
+ [REASONS.inputBlur]: FocusEvent;
296
+ [REASONS.inputPaste]: ClipboardEvent;
297
+ [REASONS.inputPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
298
+ [REASONS.focusOut]: FocusEvent | KeyboardEvent;
299
+ [REASONS.escapeKey]: KeyboardEvent;
300
+ [REASONS.closeWatcher]: Event;
301
+ [REASONS.listNavigation]: KeyboardEvent;
302
+ [REASONS.keyboard]: KeyboardEvent;
303
+ [REASONS.pointer]: PointerEvent;
304
+ [REASONS.drag]: PointerEvent | TouchEvent;
305
+ [REASONS.swipe]: PointerEvent | TouchEvent;
306
+ [REASONS.wheel]: WheelEvent;
307
+ [REASONS.scrub]: PointerEvent;
308
+ [REASONS.cancelOpen]: MouseEvent;
309
+ [REASONS.siblingOpen]: Event;
310
+ [REASONS.disabled]: Event;
311
+ [REASONS.missing]: Event;
312
+ [REASONS.initial]: Event;
313
+ [REASONS.imperativeAction]: Event;
314
+ [REASONS.windowResize]: UIEvent;
315
+ }
316
+
317
+ declare const scrub: "scrub";
318
+
319
+ declare const siblingOpen: "sibling-open";
320
+
321
+ declare const swipe: "swipe";
322
+
323
+ declare const trackPress: "track-press";
324
+
325
+ declare const triggerFocus: "trigger-focus";
326
+
327
+ declare const triggerHover: "trigger-hover";
328
+
329
+ declare const triggerPress: "trigger-press";
330
+
331
+ declare const wheel: "wheel";
332
+
333
+ declare const windowResize: "window-resize";
334
+
335
+ /**
336
+ * Adds a `preventBaseUIHandler` method to all event handlers.
337
+ */
338
+ declare type WithBaseUIEvent<T> = { [K in keyof T]: WithPreventBaseUIHandler<T[K]> };
10
339
 
11
- export * from "@base-ui/react/form";
340
+ declare type WithPreventBaseUIHandler<T> = T extends ((event: infer E) => any) ? E extends React_2.SyntheticEvent<Element, Event> ? (event: BaseUIEvent<E>) => ReturnType<T> : T : T extends undefined ? undefined : T;
12
341
 
13
342
  export { }
@@ -1,11 +1,114 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Form } from "@base-ui/react/form";
3
2
  import clsx from "clsx";
3
+ import { useStableCallback } from "../7541.js";
4
+ import { useValueChanged } from "../2801.js";
5
+ import { useRenderElement, EMPTY_OBJECT } from "../8272.js";
6
+ import { createGenericEventDetails } from "../4768.js";
7
+ import { FormContext } from "../5085.js";
4
8
  import * as __rspack_external_react from "react";
9
+ const Form_Form = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
10
+ const { render, className, validationMode = 'onSubmit', errors: externalErrors, onSubmit, onFormSubmit, actionsRef, style, ...elementProps } = componentProps;
11
+ const formRef = __rspack_external_react.useRef({
12
+ fields: new Map()
13
+ });
14
+ const submittedRef = __rspack_external_react.useRef(false);
15
+ const submitAttemptedRef = __rspack_external_react.useRef(false);
16
+ const focusControl = useStableCallback((control)=>{
17
+ if (!control) return;
18
+ control.focus();
19
+ if ('INPUT' === control.tagName) control.select();
20
+ });
21
+ const [errors, setErrors] = __rspack_external_react.useState(externalErrors);
22
+ useValueChanged(externalErrors, ()=>{
23
+ setErrors(externalErrors);
24
+ });
25
+ __rspack_external_react.useEffect(()=>{
26
+ if (!submittedRef.current) return;
27
+ submittedRef.current = false;
28
+ const invalidFields = Array.from(formRef.current.fields.values()).filter((field)=>false === field.validityData.state.valid);
29
+ if (invalidFields.length) focusControl(invalidFields[0].controlRef.current);
30
+ }, [
31
+ errors,
32
+ focusControl
33
+ ]);
34
+ const handleImperativeValidate = __rspack_external_react.useCallback((fieldName)=>{
35
+ const values = Array.from(formRef.current.fields.values());
36
+ if (fieldName) {
37
+ const namedField = values.find((field)=>field.name === fieldName);
38
+ if (namedField) namedField.validate();
39
+ } else values.forEach((field)=>{
40
+ field.validate();
41
+ });
42
+ }, []);
43
+ __rspack_external_react.useImperativeHandle(actionsRef, ()=>({
44
+ validate: handleImperativeValidate
45
+ }), [
46
+ handleImperativeValidate
47
+ ]);
48
+ const element = useRenderElement('form', componentProps, {
49
+ ref: forwardedRef,
50
+ props: [
51
+ {
52
+ noValidate: true,
53
+ onSubmit (event) {
54
+ submitAttemptedRef.current = true;
55
+ let values = Array.from(formRef.current.fields.values());
56
+ values.forEach((field)=>{
57
+ field.validate();
58
+ });
59
+ values = Array.from(formRef.current.fields.values());
60
+ const invalidFields = values.filter((field)=>!field.validityData.state.valid);
61
+ if (invalidFields.length) {
62
+ event.preventDefault();
63
+ focusControl(invalidFields[0].controlRef.current);
64
+ } else {
65
+ submittedRef.current = true;
66
+ onSubmit?.(event);
67
+ if (onFormSubmit) {
68
+ event.preventDefault();
69
+ const formValues = values.reduce((acc, field)=>{
70
+ if (field.name) acc[field.name] = field.getValue();
71
+ return acc;
72
+ }, {});
73
+ onFormSubmit(formValues, createGenericEventDetails("none", event.nativeEvent));
74
+ }
75
+ }
76
+ }
77
+ },
78
+ elementProps
79
+ ]
80
+ });
81
+ const clearErrors = useStableCallback((name)=>{
82
+ if (name && errors && EMPTY_OBJECT.hasOwnProperty.call(errors, name)) {
83
+ const nextErrors = {
84
+ ...errors
85
+ };
86
+ delete nextErrors[name];
87
+ setErrors(nextErrors);
88
+ }
89
+ });
90
+ const contextValue = __rspack_external_react.useMemo(()=>({
91
+ formRef,
92
+ validationMode,
93
+ errors: errors ?? EMPTY_OBJECT,
94
+ clearErrors,
95
+ submitAttemptedRef
96
+ }), [
97
+ formRef,
98
+ validationMode,
99
+ errors,
100
+ clearErrors
101
+ ]);
102
+ return /*#__PURE__*/ jsx(FormContext.Provider, {
103
+ value: contextValue,
104
+ children: element
105
+ });
106
+ });
107
+ if ("production" !== process.env.NODE_ENV) Form_Form.displayName = "Form";
5
108
  const Form_module = {};
6
- const Form_Form = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Form, {
109
+ const Form_Form_Form = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Form_Form, {
7
110
  ref: ref,
8
111
  className: clsx(Form_module.root, className),
9
112
  ...props
10
113
  }));
11
- export { Form_Form as Form };
114
+ export { Form_Form_Form as Form };