@wix/site-ui 1.30.0 → 1.32.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 (173) 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/Breadcrumbs/index.d.ts +960 -7
  106. package/dist/Breadcrumbs/index.js +5 -5
  107. package/dist/Button/index.d.ts +88 -6
  108. package/dist/Button/index.js +27 -3
  109. package/dist/Checkbox/index.d.ts +425 -5
  110. package/dist/Checkbox/index.js +45 -5
  111. package/dist/CheckboxGroup/index.d.ts +318 -3
  112. package/dist/CheckboxGroup/index.js +166 -3
  113. package/dist/Collapsible/index.d.ts +377 -7
  114. package/dist/Collapsible/index.js +160 -6
  115. package/dist/Combobox/index.d.ts +1984 -48
  116. package/dist/Combobox/index.js +352 -29
  117. package/dist/ContextMenu/index.d.ts +2340 -36
  118. package/dist/ContextMenu/index.js +197 -22
  119. package/dist/Dialog/index.d.ts +1355 -18
  120. package/dist/Dialog/index.js +16 -14
  121. package/dist/Drawer/index.d.ts +1653 -18
  122. package/dist/Drawer/index.js +2797 -20
  123. package/dist/Field/index.d.ts +655 -15
  124. package/dist/Field/index.js +677 -10
  125. package/dist/Fieldset/index.d.ts +94 -5
  126. package/dist/Fieldset/index.js +68 -5
  127. package/dist/Form/index.d.ts +331 -2
  128. package/dist/Form/index.js +106 -3
  129. package/dist/Input/index.d.ts +692 -3
  130. package/dist/Input/index.js +10 -3
  131. package/dist/Menu/index.d.ts +2301 -36
  132. package/dist/Menu/index.js +365 -26
  133. package/dist/Menubar/index.d.ts +2301 -3
  134. package/dist/Menubar/index.js +105 -3
  135. package/dist/Meter/index.d.ts +175 -11
  136. package/dist/Meter/index.js +129 -9
  137. package/dist/NavigationMenu/index.d.ts +978 -28
  138. package/dist/NavigationMenu/index.js +1034 -17
  139. package/dist/NumberField/index.d.ts +612 -15
  140. package/dist/NumberField/index.js +1409 -11
  141. package/dist/Popover/index.d.ts +1655 -20
  142. package/dist/Popover/index.js +792 -17
  143. package/dist/PreviewCard/index.d.ts +1523 -14
  144. package/dist/PreviewCard/index.js +679 -14
  145. package/dist/Progress/index.d.ts +183 -11
  146. package/dist/Progress/index.js +181 -9
  147. package/dist/Radio/index.d.ts +185 -6
  148. package/dist/Radio/index.js +253 -6
  149. package/dist/RadioGroup/index.d.ts +341 -2
  150. package/dist/RadioGroup/index.js +154 -3
  151. package/dist/ScrollArea/index.d.ts +265 -13
  152. package/dist/ScrollArea/index.js +892 -10
  153. package/dist/Select/index.d.ts +1493 -38
  154. package/dist/Select/index.js +1824 -23
  155. package/dist/Separator/index.d.ts +80 -6
  156. package/dist/Separator/index.js +3 -3
  157. package/dist/Slider/index.d.ts +678 -16
  158. package/dist/Slider/index.js +1199 -11
  159. package/dist/Switch/index.d.ts +393 -5
  160. package/dist/Switch/index.js +208 -6
  161. package/dist/Tabs/index.d.ts +523 -12
  162. package/dist/Tabs/index.js +685 -9
  163. package/dist/Toggle/index.d.ts +305 -2
  164. package/dist/Toggle/index.js +76 -3
  165. package/dist/ToggleGroup/index.d.ts +316 -2
  166. package/dist/ToggleGroup/index.js +102 -3
  167. package/dist/Toolbar/index.d.ts +282 -13
  168. package/dist/Toolbar/index.js +230 -9
  169. package/dist/Tooltip/index.d.ts +1572 -14
  170. package/dist/Tooltip/index.js +965 -14
  171. package/dist/index.d.ts +12749 -652
  172. package/dist/rslib-runtime.js +18 -0
  173. package/package.json +3 -3
@@ -1,7 +1,674 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Field } from "@base-ui/react/field";
3
2
  import clsx from "clsx";
3
+ import { useBaseUiId } from "../6046.js";
4
+ import { useRefWithInit, EMPTY_OBJECT, mergeProps, useRenderElement } from "../8272.js";
5
+ import { LabelableContext, FieldRootContext, useFieldRootContext, useLabelableContext, fieldValidityMapping, DEFAULT_VALIDITY_STATE } from "../1477.js";
6
+ import { useStableCallback } from "../7541.js";
7
+ import { useFormContext } from "../5085.js";
8
+ import { useTimeout } from "../42.js";
9
+ import { useIsoLayoutEffect, SafeReact } from "../6499.js";
10
+ import { useFieldsetRootContext } from "../353.js";
11
+ import { useLabel } from "../4143.js";
12
+ import { error } from "../4026.js";
13
+ import { transitionStatusMapping, useOpenChangeComplete, useTransitionStatus } from "../880.js";
14
+ import { useCheckboxGroupContext } from "../8979.js";
15
+ import { FieldItemContext } from "../1457.js";
16
+ import { FieldControl_FieldControl } from "../1268.js";
4
17
  import * as __rspack_external_react from "react";
18
+ const LabelableProvider_LabelableProvider = function(props) {
19
+ const defaultId = useBaseUiId();
20
+ const initialControlId = void 0 === props.controlId ? defaultId : props.controlId;
21
+ const [controlId, setControlIdState] = __rspack_external_react.useState(initialControlId);
22
+ const [labelId, setLabelId] = __rspack_external_react.useState(props.labelId);
23
+ const [messageIds, setMessageIds] = __rspack_external_react.useState([]);
24
+ const registrationsRef = useRefWithInit(()=>new Map());
25
+ const { messageIds: parentMessageIds } = useLabelableContext();
26
+ const registerControlId = useStableCallback((source, nextId)=>{
27
+ const registrations = registrationsRef.current;
28
+ if (void 0 === nextId) return void registrations.delete(source);
29
+ registrations.set(source, nextId);
30
+ setControlIdState((prev)=>{
31
+ if (0 === registrations.size) return;
32
+ let nextControlId;
33
+ for (const id of registrations.values()){
34
+ if (void 0 !== prev && id === prev) return prev;
35
+ if (void 0 === nextControlId) nextControlId = id;
36
+ }
37
+ return nextControlId;
38
+ });
39
+ });
40
+ const getDescriptionProps = __rspack_external_react.useCallback((externalProps)=>mergeProps({
41
+ 'aria-describedby': parentMessageIds.concat(messageIds).join(' ') || void 0
42
+ }, externalProps), [
43
+ parentMessageIds,
44
+ messageIds
45
+ ]);
46
+ const contextValue = __rspack_external_react.useMemo(()=>({
47
+ controlId,
48
+ registerControlId,
49
+ labelId,
50
+ setLabelId,
51
+ messageIds,
52
+ setMessageIds,
53
+ getDescriptionProps
54
+ }), [
55
+ controlId,
56
+ registerControlId,
57
+ labelId,
58
+ setLabelId,
59
+ messageIds,
60
+ setMessageIds,
61
+ getDescriptionProps
62
+ ]);
63
+ return /*#__PURE__*/ jsx(LabelableContext.Provider, {
64
+ value: contextValue,
65
+ children: props.children
66
+ });
67
+ };
68
+ if ("production" !== process.env.NODE_ENV) LabelableProvider_LabelableProvider.displayName = "LabelableProvider";
69
+ function getCombinedFieldValidityData(validityData, invalid) {
70
+ return {
71
+ ...validityData,
72
+ state: {
73
+ ...validityData.state,
74
+ valid: !invalid && validityData.state.valid
75
+ }
76
+ };
77
+ }
78
+ const validityKeys = Object.keys(DEFAULT_VALIDITY_STATE);
79
+ function isOnlyValueMissing(state) {
80
+ if (!state || state.valid || !state.valueMissing) return false;
81
+ let onlyValueMissing = false;
82
+ for (const key of validityKeys)if ('valid' !== key) {
83
+ if ('valueMissing' === key) onlyValueMissing = state[key];
84
+ if (state[key]) onlyValueMissing = false;
85
+ }
86
+ return onlyValueMissing;
87
+ }
88
+ function useFieldValidation(params) {
89
+ const { formRef, clearErrors } = useFormContext();
90
+ const { setValidityData, validate, validityData, validationDebounceTime, invalid, markedDirtyRef, state, name, shouldValidateOnChange, getRegisteredFieldId } = params;
91
+ const { controlId, getDescriptionProps } = useLabelableContext();
92
+ const timeout = useTimeout();
93
+ const inputRef = __rspack_external_react.useRef(null);
94
+ const commit = useStableCallback(async (value, revalidate = false)=>{
95
+ const element = inputRef.current;
96
+ if (!element) return;
97
+ function updateRegisteredFieldValidity(nextValidityData, externalInvalid = invalid) {
98
+ const fieldId = getRegisteredFieldId() ?? controlId;
99
+ if (null == fieldId) return;
100
+ const currentFieldData = formRef.current.fields.get(fieldId);
101
+ if (!currentFieldData) return;
102
+ const validityDataWithFormErrors = getCombinedFieldValidityData(nextValidityData, externalInvalid);
103
+ formRef.current.fields.set(fieldId, {
104
+ ...currentFieldData,
105
+ validityData: validityDataWithFormErrors
106
+ });
107
+ }
108
+ if (revalidate) {
109
+ if (false !== state.valid) return;
110
+ const currentNativeValidity = element.validity;
111
+ if (!currentNativeValidity.valueMissing) {
112
+ const nextValidityData = {
113
+ value,
114
+ state: {
115
+ ...DEFAULT_VALIDITY_STATE,
116
+ valid: true
117
+ },
118
+ error: '',
119
+ errors: [],
120
+ initialValue: validityData.initialValue
121
+ };
122
+ element.setCustomValidity('');
123
+ updateRegisteredFieldValidity(nextValidityData, false);
124
+ setValidityData(nextValidityData);
125
+ return;
126
+ }
127
+ const currentNativeValidityObject = validityKeys.reduce((acc, key)=>{
128
+ acc[key] = currentNativeValidity[key];
129
+ return acc;
130
+ }, {});
131
+ if (!currentNativeValidityObject.valid && !isOnlyValueMissing(currentNativeValidityObject)) return;
132
+ }
133
+ function getState(el) {
134
+ const computedState = validityKeys.reduce((acc, key)=>{
135
+ acc[key] = el.validity[key];
136
+ return acc;
137
+ }, {});
138
+ let hasOnlyValueMissingError = false;
139
+ for (const key of validityKeys)if ('valid' !== key) {
140
+ if ('valueMissing' === key && computedState[key]) hasOnlyValueMissingError = true;
141
+ else if (computedState[key]) return computedState;
142
+ }
143
+ if (hasOnlyValueMissingError && !markedDirtyRef.current) {
144
+ computedState.valid = true;
145
+ computedState.valueMissing = false;
146
+ }
147
+ return computedState;
148
+ }
149
+ timeout.clear();
150
+ let result = null;
151
+ let validationErrors = [];
152
+ const nextState = getState(element);
153
+ let defaultValidationMessage;
154
+ const validateOnChange = shouldValidateOnChange();
155
+ if (element.validationMessage && !validateOnChange) {
156
+ defaultValidationMessage = element.validationMessage;
157
+ validationErrors = [
158
+ element.validationMessage
159
+ ];
160
+ } else {
161
+ const formValues = Array.from(formRef.current.fields.values()).reduce((acc, field)=>{
162
+ if (field.name) acc[field.name] = field.getValue();
163
+ return acc;
164
+ }, {});
165
+ const resultOrPromise = validate(value, formValues);
166
+ result = 'object' == typeof resultOrPromise && null !== resultOrPromise && 'then' in resultOrPromise ? await resultOrPromise : resultOrPromise;
167
+ if (null !== result) {
168
+ nextState.valid = false;
169
+ nextState.customError = true;
170
+ if (Array.isArray(result)) {
171
+ validationErrors = result;
172
+ element.setCustomValidity(result.join('\n'));
173
+ } else if (result) {
174
+ validationErrors = [
175
+ result
176
+ ];
177
+ element.setCustomValidity(result);
178
+ }
179
+ } else if (validateOnChange) {
180
+ element.setCustomValidity('');
181
+ nextState.customError = false;
182
+ if (element.validationMessage) {
183
+ defaultValidationMessage = element.validationMessage;
184
+ validationErrors = [
185
+ element.validationMessage
186
+ ];
187
+ } else if (element.validity.valid && !nextState.valid) nextState.valid = true;
188
+ }
189
+ }
190
+ const nextValidityData = {
191
+ value,
192
+ state: nextState,
193
+ error: defaultValidationMessage ?? (Array.isArray(result) ? result[0] : result ?? ''),
194
+ errors: validationErrors,
195
+ initialValue: validityData.initialValue
196
+ };
197
+ updateRegisteredFieldValidity(nextValidityData);
198
+ setValidityData(nextValidityData);
199
+ });
200
+ const getValidationProps = __rspack_external_react.useCallback((externalProps = {})=>mergeProps(getDescriptionProps, false === state.valid ? {
201
+ 'aria-invalid': true
202
+ } : EMPTY_OBJECT, externalProps), [
203
+ getDescriptionProps,
204
+ state.valid
205
+ ]);
206
+ const getInputValidationProps = __rspack_external_react.useCallback((externalProps = {})=>mergeProps({
207
+ onChange (event) {
208
+ if (event.nativeEvent.defaultPrevented) return;
209
+ clearErrors(name);
210
+ if (!shouldValidateOnChange()) return void commit(event.currentTarget.value, true);
211
+ const element = event.currentTarget;
212
+ if ('' === element.value) return void commit(element.value);
213
+ timeout.clear();
214
+ if (validationDebounceTime) timeout.start(validationDebounceTime, ()=>{
215
+ commit(element.value);
216
+ });
217
+ else commit(element.value);
218
+ }
219
+ }, getValidationProps(externalProps)), [
220
+ getValidationProps,
221
+ clearErrors,
222
+ name,
223
+ timeout,
224
+ commit,
225
+ validationDebounceTime,
226
+ shouldValidateOnChange
227
+ ]);
228
+ return __rspack_external_react.useMemo(()=>({
229
+ getValidationProps,
230
+ getInputValidationProps,
231
+ inputRef,
232
+ commit
233
+ }), [
234
+ getValidationProps,
235
+ getInputValidationProps,
236
+ commit
237
+ ]);
238
+ }
239
+ function useFieldControlRegistration(params) {
240
+ const { commit, invalid, markedDirtyRef, name, setRegisteredFieldId, setValidityData, validityData } = params;
241
+ const { formRef } = useFormContext();
242
+ const activeFieldControlSourceRef = __rspack_external_react.useRef(null);
243
+ const registrationRef = __rspack_external_react.useRef(null);
244
+ const fallbackControlRef = __rspack_external_react.useRef(null);
245
+ const getValueForForm = useStableCallback(()=>{
246
+ const registration = registrationRef.current;
247
+ if (!registration) return;
248
+ if (registration.getValue) return registration.getValue();
249
+ return registration.value;
250
+ });
251
+ const validate = useStableCallback(()=>{
252
+ const registration = registrationRef.current;
253
+ if (!registration) return;
254
+ let nextValue = registration.value;
255
+ if (void 0 === nextValue) nextValue = getValueForForm();
256
+ markedDirtyRef.current = true;
257
+ commit(nextValue);
258
+ });
259
+ function refreshRegistration() {
260
+ const registration = registrationRef.current;
261
+ if (!registration || !registration.id) return;
262
+ formRef.current.fields.set(registration.id, {
263
+ getValue: getValueForForm,
264
+ name,
265
+ controlRef: registration.controlRef ?? fallbackControlRef,
266
+ validityData: getCombinedFieldValidityData(validityData, invalid),
267
+ validate
268
+ });
269
+ }
270
+ function deleteRegistration(id = registrationRef.current?.id) {
271
+ if (id) formRef.current.fields.delete(id);
272
+ }
273
+ function syncInitialValue() {
274
+ const registration = registrationRef.current;
275
+ if (!registration) return;
276
+ let initialValue = registration.value;
277
+ if (void 0 === initialValue) initialValue = getValueForForm();
278
+ if (null === validityData.initialValue && null !== initialValue) setValidityData((prev)=>({
279
+ ...prev,
280
+ initialValue
281
+ }));
282
+ }
283
+ useIsoLayoutEffect(()=>{
284
+ const registration = registrationRef.current;
285
+ if (!registration || !registration.id) return;
286
+ formRef.current.fields.set(registration.id, {
287
+ getValue: getValueForForm,
288
+ name,
289
+ controlRef: registration.controlRef ?? fallbackControlRef,
290
+ validityData: getCombinedFieldValidityData(validityData, invalid),
291
+ validate
292
+ });
293
+ }, [
294
+ formRef,
295
+ getValueForForm,
296
+ invalid,
297
+ name,
298
+ validate,
299
+ validityData
300
+ ]);
301
+ useIsoLayoutEffect(()=>{
302
+ const fields = formRef.current.fields;
303
+ return ()=>{
304
+ const id = registrationRef.current?.id;
305
+ if (id) fields.delete(id);
306
+ };
307
+ }, [
308
+ formRef
309
+ ]);
310
+ return useStableCallback((source, registration)=>{
311
+ if (!registration) {
312
+ if (activeFieldControlSourceRef.current === source) {
313
+ activeFieldControlSourceRef.current = null;
314
+ deleteRegistration();
315
+ registrationRef.current = null;
316
+ setRegisteredFieldId(void 0);
317
+ }
318
+ return;
319
+ }
320
+ const previousId = registrationRef.current?.id;
321
+ activeFieldControlSourceRef.current = source;
322
+ registrationRef.current = registration;
323
+ setRegisteredFieldId(registration.id);
324
+ if (previousId && previousId !== registration.id) deleteRegistration(previousId);
325
+ syncInitialValue();
326
+ refreshRegistration();
327
+ });
328
+ }
329
+ const FieldRoot_FieldRootInner = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
330
+ const { errors, validationMode: formValidationMode, submitAttemptedRef } = useFormContext();
331
+ const { render, className, validate: validateProp, validationDebounceTime = 0, validationMode = formValidationMode, name, disabled: disabledProp = false, invalid: invalidProp, dirty: dirtyProp, touched: touchedProp, actionsRef, style, ...elementProps } = componentProps;
332
+ const { disabled: disabledFieldset } = useFieldsetRootContext();
333
+ const validate = useStableCallback(validateProp || (()=>null));
334
+ const disabled = disabledFieldset || disabledProp;
335
+ const [touchedState, setTouchedUnwrapped] = __rspack_external_react.useState(false);
336
+ const [dirtyState, setDirtyUnwrapped] = __rspack_external_react.useState(false);
337
+ const [filled, setFilled] = __rspack_external_react.useState(false);
338
+ const [focused, setFocused] = __rspack_external_react.useState(false);
339
+ const dirty = dirtyProp ?? dirtyState;
340
+ const touched = touchedProp ?? touchedState;
341
+ const markedDirtyRef = __rspack_external_react.useRef(false);
342
+ const registeredFieldIdRef = __rspack_external_react.useRef(void 0);
343
+ const getRegisteredFieldId = __rspack_external_react.useCallback(()=>registeredFieldIdRef.current, []);
344
+ const setRegisteredFieldId = __rspack_external_react.useCallback((id)=>{
345
+ registeredFieldIdRef.current = id;
346
+ }, []);
347
+ const setDirty = useStableCallback((value)=>{
348
+ if (void 0 !== dirtyProp) return;
349
+ if (value) markedDirtyRef.current = true;
350
+ setDirtyUnwrapped(value);
351
+ });
352
+ const setTouched = useStableCallback((value)=>{
353
+ if (void 0 !== touchedProp) return;
354
+ setTouchedUnwrapped(value);
355
+ });
356
+ const shouldValidateOnChange = useStableCallback(()=>'onChange' === validationMode || 'onSubmit' === validationMode && submitAttemptedRef.current);
357
+ const hasFormError = !!name && Object.hasOwn(errors, name) && void 0 !== errors[name];
358
+ const invalid = true === invalidProp || hasFormError;
359
+ const [validityData, setValidityData] = __rspack_external_react.useState({
360
+ state: DEFAULT_VALIDITY_STATE,
361
+ error: '',
362
+ errors: [],
363
+ value: null,
364
+ initialValue: null
365
+ });
366
+ const valid = !invalid && validityData.state.valid;
367
+ const state = __rspack_external_react.useMemo(()=>({
368
+ disabled,
369
+ touched,
370
+ dirty,
371
+ valid,
372
+ filled,
373
+ focused
374
+ }), [
375
+ disabled,
376
+ touched,
377
+ dirty,
378
+ valid,
379
+ filled,
380
+ focused
381
+ ]);
382
+ const validation = useFieldValidation({
383
+ setValidityData,
384
+ validate,
385
+ validityData,
386
+ validationDebounceTime,
387
+ invalid,
388
+ markedDirtyRef,
389
+ state,
390
+ name,
391
+ shouldValidateOnChange,
392
+ getRegisteredFieldId
393
+ });
394
+ const validityValue = validityData.value;
395
+ const handleImperativeValidate = __rspack_external_react.useCallback(()=>{
396
+ markedDirtyRef.current = true;
397
+ validation.commit(validityValue);
398
+ }, [
399
+ validation,
400
+ validityValue
401
+ ]);
402
+ const registerFieldControl = useFieldControlRegistration({
403
+ commit: validation.commit,
404
+ invalid,
405
+ markedDirtyRef,
406
+ name,
407
+ setRegisteredFieldId,
408
+ setValidityData,
409
+ validityData
410
+ });
411
+ __rspack_external_react.useImperativeHandle(actionsRef, ()=>({
412
+ validate: handleImperativeValidate
413
+ }), [
414
+ handleImperativeValidate
415
+ ]);
416
+ const contextValue = __rspack_external_react.useMemo(()=>({
417
+ invalid,
418
+ name,
419
+ validityData,
420
+ setValidityData,
421
+ disabled,
422
+ touched,
423
+ setTouched,
424
+ dirty,
425
+ setDirty,
426
+ filled,
427
+ setFilled,
428
+ focused,
429
+ setFocused,
430
+ validate,
431
+ validationMode,
432
+ validationDebounceTime,
433
+ shouldValidateOnChange,
434
+ state,
435
+ markedDirtyRef,
436
+ registerFieldControl,
437
+ validation
438
+ }), [
439
+ invalid,
440
+ name,
441
+ validityData,
442
+ disabled,
443
+ touched,
444
+ setTouched,
445
+ dirty,
446
+ setDirty,
447
+ filled,
448
+ setFilled,
449
+ focused,
450
+ setFocused,
451
+ validate,
452
+ validationMode,
453
+ validationDebounceTime,
454
+ shouldValidateOnChange,
455
+ state,
456
+ registerFieldControl,
457
+ validation
458
+ ]);
459
+ const element = useRenderElement('div', componentProps, {
460
+ ref: forwardedRef,
461
+ state,
462
+ props: elementProps,
463
+ stateAttributesMapping: fieldValidityMapping
464
+ });
465
+ return /*#__PURE__*/ jsx(FieldRootContext.Provider, {
466
+ value: contextValue,
467
+ children: element
468
+ });
469
+ });
470
+ if ("production" !== process.env.NODE_ENV) FieldRoot_FieldRootInner.displayName = "FieldRootInner";
471
+ const FieldRoot_FieldRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
472
+ return /*#__PURE__*/ jsx(LabelableProvider_LabelableProvider, {
473
+ children: /*#__PURE__*/ jsx(FieldRoot_FieldRootInner, {
474
+ ...componentProps,
475
+ ref: forwardedRef
476
+ })
477
+ });
478
+ });
479
+ if ("production" !== process.env.NODE_ENV) FieldRoot_FieldRoot.displayName = "FieldRoot";
480
+ const FieldLabel_FieldLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
481
+ const { render, className, style, id: idProp, nativeLabel = true, ...elementProps } = componentProps;
482
+ const fieldRootContext = useFieldRootContext(false);
483
+ const { labelId } = useLabelableContext();
484
+ const labelRef = __rspack_external_react.useRef(null);
485
+ const labelProps = useLabel({
486
+ id: labelId ?? idProp,
487
+ native: nativeLabel
488
+ });
489
+ if ('production' !== process.env.NODE_ENV) __rspack_external_react.useEffect(()=>{
490
+ if (!labelRef.current) return;
491
+ const isLabelTag = 'LABEL' === labelRef.current.tagName;
492
+ if (nativeLabel) {
493
+ if (!isLabelTag) {
494
+ const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';
495
+ const message = "<Field.Label> expected a <label> element because the `nativeLabel` prop is true. Rendering a non-<label> disables native label association, so `htmlFor` will not work. Use a real <label> in the `render` prop, or set `nativeLabel` to `false`.";
496
+ error(`${message}${ownerStackMessage}`);
497
+ }
498
+ } else if (isLabelTag) {
499
+ const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';
500
+ const message = "<Field.Label> expected a non-<label> element because the `nativeLabel` prop is false. Rendering a <label> assumes native label behavior while Base UI treats it as non-native, which can cause unexpected pointer behavior. Use a non-<label> in the `render` prop, or set `nativeLabel` to `true`.";
501
+ error(`${message}${ownerStackMessage}`);
502
+ }
503
+ }, [
504
+ nativeLabel
505
+ ]);
506
+ const element = useRenderElement('label', componentProps, {
507
+ ref: [
508
+ forwardedRef,
509
+ labelRef
510
+ ],
511
+ state: fieldRootContext.state,
512
+ props: [
513
+ labelProps,
514
+ elementProps
515
+ ],
516
+ stateAttributesMapping: fieldValidityMapping
517
+ });
518
+ return element;
519
+ });
520
+ if ("production" !== process.env.NODE_ENV) FieldLabel_FieldLabel.displayName = "FieldLabel";
521
+ const stateAttributesMapping = {
522
+ ...fieldValidityMapping,
523
+ ...transitionStatusMapping
524
+ };
525
+ const FieldError_FieldError = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
526
+ const { render, id: idProp, className, match, style, ...elementProps } = componentProps;
527
+ const id = useBaseUiId(idProp);
528
+ const { validityData, state: fieldState, name } = useFieldRootContext(false);
529
+ const { setMessageIds } = useLabelableContext();
530
+ const { errors } = useFormContext();
531
+ const formError = name ? errors[name] : null;
532
+ const hasSpecificMatch = 'string' == typeof match;
533
+ let rendered = false;
534
+ rendered = true === match ? true : hasSpecificMatch ? Boolean(validityData.state[match]) : Boolean(formError) || false === validityData.state.valid;
535
+ const { mounted, transitionStatus, setMounted } = useTransitionStatus(rendered);
536
+ useIsoLayoutEffect(()=>{
537
+ if (!rendered || !id) return;
538
+ setMessageIds((v)=>v.concat(id));
539
+ return ()=>{
540
+ setMessageIds((v)=>v.filter((item)=>item !== id));
541
+ };
542
+ }, [
543
+ rendered,
544
+ id,
545
+ setMessageIds
546
+ ]);
547
+ const errorRef = __rspack_external_react.useRef(null);
548
+ const [lastRenderedMessage, setLastRenderedMessage] = __rspack_external_react.useState(null);
549
+ const [lastRenderedMessageKey, setLastRenderedMessageKey] = __rspack_external_react.useState(null);
550
+ const clientErrorMessage = validityData.errors.length > 1 ? /*#__PURE__*/ jsx("ul", {
551
+ children: validityData.errors.map((message)=>/*#__PURE__*/ jsx("li", {
552
+ children: message
553
+ }, message))
554
+ }) : validityData.error;
555
+ const errorMessage = hasSpecificMatch ? clientErrorMessage : formError || clientErrorMessage;
556
+ let errorKey = validityData.error;
557
+ if (null != formError) errorKey = Array.isArray(formError) ? JSON.stringify(formError) : formError;
558
+ else if (validityData.errors.length > 1) errorKey = JSON.stringify(validityData.errors);
559
+ if (rendered && errorKey !== lastRenderedMessageKey) {
560
+ setLastRenderedMessageKey(errorKey);
561
+ setLastRenderedMessage(errorMessage);
562
+ }
563
+ useOpenChangeComplete({
564
+ open: rendered,
565
+ ref: errorRef,
566
+ onComplete () {
567
+ if (!rendered) setMounted(false);
568
+ }
569
+ });
570
+ const state = {
571
+ ...fieldState,
572
+ transitionStatus
573
+ };
574
+ const element = useRenderElement('div', componentProps, {
575
+ ref: [
576
+ forwardedRef,
577
+ errorRef
578
+ ],
579
+ state,
580
+ props: [
581
+ {
582
+ id,
583
+ children: rendered ? errorMessage : lastRenderedMessage
584
+ },
585
+ elementProps
586
+ ],
587
+ stateAttributesMapping: stateAttributesMapping,
588
+ enabled: mounted
589
+ });
590
+ if (!mounted) return null;
591
+ return element;
592
+ });
593
+ if ("production" !== process.env.NODE_ENV) FieldError_FieldError.displayName = "FieldError";
594
+ const FieldDescription_FieldDescription = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
595
+ const { render, id: idProp, className, style, ...elementProps } = componentProps;
596
+ const id = useBaseUiId(idProp);
597
+ const fieldRootContext = useFieldRootContext(false);
598
+ const { setMessageIds } = useLabelableContext();
599
+ useIsoLayoutEffect(()=>{
600
+ if (!id) return;
601
+ setMessageIds((v)=>v.concat(id));
602
+ return ()=>{
603
+ setMessageIds((v)=>v.filter((item)=>item !== id));
604
+ };
605
+ }, [
606
+ id,
607
+ setMessageIds
608
+ ]);
609
+ const element = useRenderElement('p', componentProps, {
610
+ ref: forwardedRef,
611
+ state: fieldRootContext.state,
612
+ props: [
613
+ {
614
+ id
615
+ },
616
+ elementProps
617
+ ],
618
+ stateAttributesMapping: fieldValidityMapping
619
+ });
620
+ return element;
621
+ });
622
+ if ("production" !== process.env.NODE_ENV) FieldDescription_FieldDescription.displayName = "FieldDescription";
623
+ const FieldItem_FieldItem = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
624
+ const { render, className, style, disabled: disabledProp = false, ...elementProps } = componentProps;
625
+ const { state, disabled: rootDisabled } = useFieldRootContext(false);
626
+ const disabled = rootDisabled || disabledProp;
627
+ const checkboxGroupContext = useCheckboxGroupContext();
628
+ const hasParentCheckbox = checkboxGroupContext?.allValues !== void 0;
629
+ const controlId = hasParentCheckbox ? checkboxGroupContext?.parent.id : void 0;
630
+ const fieldItemContext = __rspack_external_react.useMemo(()=>({
631
+ disabled
632
+ }), [
633
+ disabled
634
+ ]);
635
+ const element = useRenderElement('div', componentProps, {
636
+ ref: forwardedRef,
637
+ state,
638
+ props: elementProps,
639
+ stateAttributesMapping: fieldValidityMapping
640
+ });
641
+ return /*#__PURE__*/ jsx(LabelableProvider_LabelableProvider, {
642
+ controlId: controlId,
643
+ children: /*#__PURE__*/ jsx(FieldItemContext.Provider, {
644
+ value: fieldItemContext,
645
+ children: element
646
+ })
647
+ });
648
+ });
649
+ if ("production" !== process.env.NODE_ENV) FieldItem_FieldItem.displayName = "FieldItem";
650
+ const FieldValidity_FieldValidity = function(props) {
651
+ const { children } = props;
652
+ const { validityData, invalid } = useFieldRootContext(false);
653
+ const combinedFieldValidityData = __rspack_external_react.useMemo(()=>getCombinedFieldValidityData(validityData, invalid), [
654
+ validityData,
655
+ invalid
656
+ ]);
657
+ const isInvalid = false === combinedFieldValidityData.state.valid;
658
+ const { transitionStatus } = useTransitionStatus(isInvalid);
659
+ const fieldValidityState = __rspack_external_react.useMemo(()=>({
660
+ ...combinedFieldValidityData,
661
+ validity: combinedFieldValidityData.state,
662
+ transitionStatus
663
+ }), [
664
+ combinedFieldValidityData,
665
+ transitionStatus
666
+ ]);
667
+ return /*#__PURE__*/ jsx(__rspack_external_react.Fragment, {
668
+ children: children(fieldValidityState)
669
+ });
670
+ };
671
+ if ("production" !== process.env.NODE_ENV) FieldValidity_FieldValidity.displayName = "FieldValidity";
5
672
  const Field_module = {
6
673
  root: "root-ECdHfF",
7
674
  label: "label-YSWZBs",
@@ -9,43 +676,43 @@ const Field_module = {
9
676
  description: "description-IVviYU",
10
677
  item: "item-kQeHOQ"
11
678
  };
12
- const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Field.Root, {
679
+ const Root = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(FieldRoot_FieldRoot, {
13
680
  ref: ref,
14
681
  className: clsx(Field_module.root, className),
15
682
  ...props
16
683
  }));
17
- const Label = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Field.Label, {
684
+ const Label = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(FieldLabel_FieldLabel, {
18
685
  ref: ref,
19
686
  className: clsx(Field_module.label, className),
20
687
  ...props
21
688
  }));
22
- const Error = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Field.Error, {
689
+ const Error = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(FieldError_FieldError, {
23
690
  ref: ref,
24
691
  className: clsx(Field_module.error, className),
25
692
  ...props
26
693
  }));
27
- const Description = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Field.Description, {
694
+ const Description = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(FieldDescription_FieldDescription, {
28
695
  ref: ref,
29
696
  className: clsx(Field_module.description, className),
30
697
  ...props
31
698
  }));
32
- const Control = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Field.Control, {
699
+ const Control = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(FieldControl_FieldControl, {
33
700
  ref: ref,
34
701
  className: clsx(Field_module.control, className),
35
702
  ...props
36
703
  }));
37
- const Item = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(Field.Item, {
704
+ const Item = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(FieldItem_FieldItem, {
38
705
  ref: ref,
39
706
  className: clsx(Field_module.item, className),
40
707
  ...props
41
708
  }));
42
- const Field_Field = {
709
+ const Field = {
43
710
  Root: Root,
44
711
  Label: Label,
45
712
  Error: Error,
46
713
  Description: Description,
47
714
  Control: Control,
48
715
  Item: Item,
49
- Validity: Field.Validity
716
+ Validity: FieldValidity_FieldValidity
50
717
  };
51
- export { Field_Field as Field };
718
+ export { Field };