@wix/site-ui 1.347.0 → 1.348.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 (226) hide show
  1. package/dist/{6706.js → 1093.js} +3 -3
  2. package/dist/{8724.js → 1219.js} +2 -2
  3. package/dist/{7373.js → 1288.js} +8 -2
  4. package/dist/{5299.js → 1381.js} +98 -127
  5. package/dist/{3056.js → 1607.js} +32 -34
  6. package/dist/1629.js +2 -0
  7. package/dist/1669.js +75 -0
  8. package/dist/1718.js +26 -0
  9. package/dist/{1477.js → 201.js} +17 -26
  10. package/dist/2221.js +9 -0
  11. package/dist/{2445.js → 226.js} +12 -48
  12. package/dist/2387.js +7 -0
  13. package/dist/2580.js +6 -0
  14. package/dist/{1500.js → 2859.js} +10 -34
  15. package/dist/3014.js +178 -0
  16. package/dist/{6247.js → 3054.js} +3 -3
  17. package/dist/{7642.js → 3093.js} +1 -1
  18. package/dist/3189.js +5 -0
  19. package/dist/{7564.js → 331.js} +2 -2
  20. package/dist/3357.js +7 -0
  21. package/dist/{487.js → 3398.js} +38 -39
  22. package/dist/3502.js +224 -0
  23. package/dist/3695.js +50 -0
  24. package/dist/3829.js +1 -1
  25. package/dist/{6588.js → 3859.js} +115 -92
  26. package/dist/{3670.js → 3910.js} +28 -21
  27. package/dist/392.js +7 -0
  28. package/dist/{4549.js → 4155.js} +11 -3
  29. package/dist/4226.js +7 -0
  30. package/dist/{6329.js → 4229.js} +1 -1
  31. package/dist/4293.js +3 -0
  32. package/dist/4346.js +853 -2
  33. package/dist/{285.js → 4472.js} +3 -3
  34. package/dist/4605.js +207 -0
  35. package/dist/{7366.js → 488.js} +60 -7
  36. package/dist/{8750.js → 497.js} +190 -375
  37. package/dist/4989.js +35 -0
  38. package/dist/{6270.js → 510.js} +157 -196
  39. package/dist/5258.js +26 -0
  40. package/dist/{5036.js → 5275.js} +0 -3
  41. package/dist/{8171.js → 5298.js} +90 -102
  42. package/dist/5473.js +11 -0
  43. package/dist/{4745.js → 5490.js} +3 -1
  44. package/dist/{6089.js → 5561.js} +869 -786
  45. package/dist/{8996.js → 5595.js} +4 -3
  46. package/dist/5890.js +25 -0
  47. package/dist/{6046.js → 5969.js} +1 -1
  48. package/dist/5984.js +38 -0
  49. package/dist/{8527.js → 6006.js} +3 -3
  50. package/dist/6040.js +97 -0
  51. package/dist/{8758.js → 6137.js} +10 -8
  52. package/dist/{4281.js → 6140.js} +18 -10
  53. package/dist/{8960.js → 6191.js} +2 -2
  54. package/dist/6240.js +121 -0
  55. package/dist/{4490.js → 6373.js} +7 -5
  56. package/dist/{904.js → 6487.js} +19 -17
  57. package/dist/{9635.js → 6498.js} +1 -1
  58. package/dist/6499.js +4 -7
  59. package/dist/6508.js +7 -0
  60. package/dist/{8225.js → 6540.js} +1 -0
  61. package/dist/6551.js +46 -0
  62. package/dist/{9369.js → 6620.js} +35 -34
  63. package/dist/{4143.js → 6838.js} +19 -10
  64. package/dist/6902.js +48 -0
  65. package/dist/6904.js +51 -0
  66. package/dist/70.js +24 -0
  67. package/dist/7024.js +39 -0
  68. package/dist/{6882.js → 721.js} +737 -362
  69. package/dist/{951.js → 7270.js} +4 -4
  70. package/dist/{3485.js → 7323.js} +143 -111
  71. package/dist/{7541.js → 7488.js} +2 -2
  72. package/dist/{4863.js → 7542.js} +7 -6
  73. package/dist/7551.js +28 -0
  74. package/dist/{7021.js → 7640.js} +1 -1
  75. package/dist/{353.js → 7692.js} +3 -7
  76. package/dist/{4707.js → 7930.js} +2 -2
  77. package/dist/{8052.js → 8.js} +80 -64
  78. package/dist/{6914.js → 8129.js} +3 -15
  79. package/dist/{3319.js → 8358.js} +62 -63
  80. package/dist/{5864.js → 8407.js} +13 -13
  81. package/dist/8488.js +15 -0
  82. package/dist/{4768.js → 8495.js} +1 -1
  83. package/dist/8734.js +171 -0
  84. package/dist/{1763.js → 9018.js} +205 -331
  85. package/dist/9053.js +29 -0
  86. package/dist/9067.js +41 -0
  87. package/dist/{2861.js → 9120.js} +2 -2
  88. package/dist/{42.js → 9197.js} +2 -2
  89. package/dist/{9189.js → 9248.js} +36 -17
  90. package/dist/{2801.js → 9252.js} +4 -9
  91. package/dist/9295.js +7 -0
  92. package/dist/9303.js +8 -0
  93. package/dist/{167.js → 9374.js} +1 -1
  94. package/dist/{9352.js → 9540.js} +17 -47
  95. package/dist/9576.js +51 -0
  96. package/dist/{8272.js → 9591.js} +36 -46
  97. package/dist/{6107.js → 9770.js} +2 -2
  98. package/dist/{5085.js → 9880.js} +6 -3
  99. package/dist/Accordion/index.d.ts +207 -41
  100. package/dist/Accordion/index.js +75 -177
  101. package/dist/AlertDialog/index.d.ts +440 -140
  102. package/dist/AlertDialog/index.js +3 -13
  103. package/dist/Autocomplete/index.d.ts +722 -150
  104. package/dist/Autocomplete/index.js +16 -29
  105. package/dist/Avatar/index.d.ts +38 -3
  106. package/dist/Avatar/index.js +82 -28
  107. package/dist/Breadcrumbs/index.d.ts +63 -91
  108. package/dist/Breadcrumbs/index.js +1 -1
  109. package/dist/Button/index.d.ts +11 -0
  110. package/dist/Button/index.js +2 -2
  111. package/dist/Checkbox/index.d.ts +206 -36
  112. package/dist/Checkbox/index.js +293 -8
  113. package/dist/CheckboxField/index.css +1 -1
  114. package/dist/CheckboxField/index.d.ts +40 -36
  115. package/dist/CheckboxGroup/index.d.ts +50 -36
  116. package/dist/CheckboxGroup/index.js +87 -58
  117. package/dist/CheckboxGroupField/index.css +1 -1
  118. package/dist/Collapsible/index.d.ts +128 -36
  119. package/dist/Collapsible/index.js +21 -25
  120. package/dist/Combobox/index.d.ts +801 -158
  121. package/dist/Combobox/index.js +70 -114
  122. package/dist/ContextMenu/index.d.ts +1162 -195
  123. package/dist/ContextMenu/index.js +46 -36
  124. package/dist/Dialog/index.d.ts +425 -133
  125. package/dist/Dialog/index.js +8 -4
  126. package/dist/Drawer/index.d.ts +589 -144
  127. package/dist/Drawer/index.js +482 -562
  128. package/dist/Field/index.css +1 -1
  129. package/dist/Field/index.d.ts +341 -42
  130. package/dist/Field/index.js +123 -273
  131. package/dist/Fieldset/index.d.ts +11 -0
  132. package/dist/Fieldset/index.js +10 -17
  133. package/dist/Form/index.d.ts +43 -39
  134. package/dist/Form/index.js +58 -50
  135. package/dist/Input/index.css +1 -1
  136. package/dist/Input/index.d.ts +94 -42
  137. package/dist/Input/index.js +1 -1
  138. package/dist/Menu/index.d.ts +1140 -175
  139. package/dist/Menu/index.js +51 -67
  140. package/dist/Menubar/index.d.ts +651 -173
  141. package/dist/Menubar/index.js +12 -16
  142. package/dist/Meter/index.js +21 -18
  143. package/dist/NavigationMenu/index.d.ts +370 -86
  144. package/dist/NavigationMenu/index.js +144 -178
  145. package/dist/NumberField/index.css +1 -1
  146. package/dist/NumberField/index.d.ts +507 -47
  147. package/dist/NumberField/index.js +434 -718
  148. package/dist/Popover/index.d.ts +561 -142
  149. package/dist/Popover/index.js +181 -252
  150. package/dist/PreviewCard/index.d.ts +507 -143
  151. package/dist/PreviewCard/index.js +97 -151
  152. package/dist/Progress/index.d.ts +117 -3
  153. package/dist/Progress/index.js +37 -36
  154. package/dist/Radio/index.d.ts +177 -7
  155. package/dist/Radio/index.js +54 -70
  156. package/dist/RadioField/index.css +1 -1
  157. package/dist/RadioField/index.d.ts +23 -7
  158. package/dist/RadioGroup/index.d.ts +51 -37
  159. package/dist/RadioGroup/index.js +60 -51
  160. package/dist/RadioGroupField/index.css +1 -1
  161. package/dist/RadioGroupField/index.d.ts +40 -37
  162. package/dist/ScrollArea/index.d.ts +295 -1
  163. package/dist/ScrollArea/index.js +256 -324
  164. package/dist/Select/index.d.ts +516 -123
  165. package/dist/Select/index.js +513 -635
  166. package/dist/SelectField/index.css +1 -1
  167. package/dist/SelectField/index.d.ts +109 -134
  168. package/dist/SelectField/index.js +5 -1
  169. package/dist/Separator/index.d.ts +12 -0
  170. package/dist/Separator/index.js +1 -1
  171. package/dist/Slider/index.d.ts +383 -64
  172. package/dist/Slider/index.js +298 -374
  173. package/dist/Switch/index.d.ts +184 -37
  174. package/dist/Switch/index.js +44 -58
  175. package/dist/Tabs/index.d.ts +220 -35
  176. package/dist/Tabs/index.js +199 -193
  177. package/dist/Toast/index.d.ts +280 -64
  178. package/dist/Toast/index.js +299 -374
  179. package/dist/Toggle/index.d.ts +55 -35
  180. package/dist/Toggle/index.js +19 -13
  181. package/dist/ToggleGroup/index.d.ts +62 -35
  182. package/dist/ToggleGroup/index.js +13 -31
  183. package/dist/Toolbar/index.d.ts +117 -2
  184. package/dist/Toolbar/index.js +31 -43
  185. package/dist/Tooltip/index.d.ts +507 -150
  186. package/dist/Tooltip/index.js +163 -213
  187. package/dist/index.d.ts +12912 -5382
  188. package/package.json +3 -3
  189. package/dist/2205.js +0 -26
  190. package/dist/2274.js +0 -34
  191. package/dist/2287.js +0 -17
  192. package/dist/3020.js +0 -7
  193. package/dist/3021.js +0 -72
  194. package/dist/3140.js +0 -4
  195. package/dist/3248.js +0 -307
  196. package/dist/4026.js +0 -12
  197. package/dist/4922.js +0 -15
  198. package/dist/5659.js +0 -4
  199. package/dist/5992.js +0 -447
  200. package/dist/6330.js +0 -30
  201. package/dist/6535.js +0 -72
  202. package/dist/6917.js +0 -55
  203. package/dist/7725.js +0 -10
  204. package/dist/7871.js +0 -38
  205. package/dist/8106.js +0 -239
  206. package/dist/8685.js +0 -102
  207. package/dist/8935.js +0 -8
  208. package/dist/8971.js +0 -40
  209. package/dist/8979.js +0 -10
  210. package/dist/9048.js +0 -52
  211. package/dist/9087.js +0 -256
  212. package/dist/9255.js +0 -136
  213. /package/dist/{1457.js → 1068.js} +0 -0
  214. /package/dist/{6003.js → 1234.js} +0 -0
  215. /package/dist/{4723.js → 1282.js} +0 -0
  216. /package/dist/{6825.js → 1876.js} +0 -0
  217. /package/dist/{5778.js → 1885.js} +0 -0
  218. /package/dist/{2445.js.LICENSE.txt → 226.js.LICENSE.txt} +0 -0
  219. /package/dist/{1279.js → 3278.js} +0 -0
  220. /package/dist/{3296.js → 5568.js} +0 -0
  221. /package/dist/{8685.css → 6240.css} +0 -0
  222. /package/dist/{9829.js → 6488.js} +0 -0
  223. /package/dist/{9863.js → 6534.js} +0 -0
  224. /package/dist/{4495.js → 7718.js} +0 -0
  225. /package/dist/{3395.js → 8866.js} +0 -0
  226. /package/dist/{2418.js → 9837.js} +0 -0
@@ -1,53 +1,62 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { InfoCircle } from "@wix/wix-ui-icons-common";
3
3
  import clsx from "clsx";
4
- import { useBaseUiId } from "../6046.js";
5
- import { useRefWithInit, EMPTY_OBJECT, mergeProps, useRenderElement } from "../8272.js";
6
- import { LabelableContext, FieldRootContext, useFieldRootContext, useLabelableContext, fieldValidityMapping, DEFAULT_VALIDITY_STATE } from "../1477.js";
7
- import { useStableCallback } from "../7541.js";
8
- import { useFormContext } from "../5085.js";
9
- import { useTimeout } from "../42.js";
10
- import { useIsoLayoutEffect, SafeReact } from "../6499.js";
11
- import { useFieldsetRootContext } from "../353.js";
12
- import { useLabel } from "../4143.js";
13
- import { error } from "../4026.js";
14
- import { transitionStatusMapping, useOpenChangeComplete } from "../9369.js";
15
- import { useTransitionStatus } from "../4863.js";
16
- import { useCheckboxGroupContext } from "../8979.js";
17
- import { FieldItemContext } from "../1457.js";
18
- import { Input_module, FieldControl_FieldControl } from "../8685.js";
4
+ import { useBaseUiId } from "../5969.js";
5
+ import { useRefWithInit, useRenderElement } from "../9591.js";
6
+ import { LabelableContext, FieldRootContext, useFieldRootContext, useLabelableContext, fieldValidityMapping, DEFAULT_VALIDITY_STATE } from "../201.js";
7
+ import { useStableCallback } from "../7488.js";
8
+ import { useFormContext } from "../9880.js";
9
+ import { useFieldValidation, getCombinedFieldValidityData } from "../4605.js";
10
+ import { useIsoLayoutEffect, SafeReact } from "../3357.js";
11
+ import { useFieldsetRootContext } from "../7692.js";
12
+ import { FieldItemContext, useFieldItemContext } from "../1068.js";
13
+ import { useLabel } from "../6838.js";
14
+ import { error as error_error } from "../4293.js";
15
+ import { transitionStatusMapping } from "../8488.js";
16
+ import { useTransitionStatus } from "../7542.js";
17
+ import { useOpenChangeComplete } from "../6620.js";
18
+ import { Input_module, FieldControl_FieldControl } from "../6240.js";
19
19
  import * as __rspack_external_react from "react";
20
20
  const LabelableProvider_LabelableProvider = function(props) {
21
21
  const defaultId = useBaseUiId();
22
- const initialControlId = void 0 === props.controlId ? defaultId : props.controlId;
23
- const [controlId, setControlIdState] = __rspack_external_react.useState(initialControlId);
24
- const [labelId, setLabelId] = __rspack_external_react.useState(props.labelId);
22
+ const [controlIdState, setControlIdState] = __rspack_external_react.useState(defaultId);
23
+ const [labelId, setLabelId] = __rspack_external_react.useState();
25
24
  const [messageIds, setMessageIds] = __rspack_external_react.useState([]);
25
+ const controlId = void 0 === controlIdState ? defaultId : controlIdState;
26
26
  const registrationsRef = useRefWithInit(()=>new Map());
27
27
  const { messageIds: parentMessageIds } = useLabelableContext();
28
28
  const registerControlId = useStableCallback((source, nextId)=>{
29
29
  const registrations = registrationsRef.current;
30
- if (void 0 === nextId) return void registrations.delete(source);
31
- registrations.set(source, nextId);
30
+ if (void 0 === nextId) registrations.delete(source);
31
+ else registrations.set(source, nextId);
32
32
  setControlIdState((prev)=>{
33
- if (0 === registrations.size) return;
33
+ if (0 === registrations.size) return prev;
34
34
  let nextControlId;
35
35
  for (const id of registrations.values()){
36
- if (void 0 !== prev && id === prev) return prev;
36
+ if (id === prev) return prev;
37
37
  if (void 0 === nextControlId) nextControlId = id;
38
38
  }
39
39
  return nextControlId;
40
40
  });
41
41
  });
42
- const getDescriptionProps = __rspack_external_react.useCallback((externalProps)=>mergeProps({
43
- 'aria-describedby': parentMessageIds.concat(messageIds).join(' ') || void 0
44
- }, externalProps), [
42
+ const resetControlId = useStableCallback(()=>{
43
+ if (0 === registrationsRef.current.size) setControlIdState(defaultId);
44
+ });
45
+ const getDescriptionProps = __rspack_external_react.useCallback((externalProps)=>{
46
+ const ids = externalProps['aria-describedby'] ? externalProps['aria-describedby'].split(' ') : [];
47
+ ids.push(...parentMessageIds, ...messageIds);
48
+ return {
49
+ ...externalProps,
50
+ 'aria-describedby': Array.from(new Set(ids)).join(' ') || void 0
51
+ };
52
+ }, [
45
53
  parentMessageIds,
46
54
  messageIds
47
55
  ]);
48
56
  const contextValue = __rspack_external_react.useMemo(()=>({
49
57
  controlId,
50
58
  registerControlId,
59
+ resetControlId,
51
60
  labelId,
52
61
  setLabelId,
53
62
  messageIds,
@@ -56,6 +65,7 @@ const LabelableProvider_LabelableProvider = function(props) {
56
65
  }), [
57
66
  controlId,
58
67
  registerControlId,
68
+ resetControlId,
59
69
  labelId,
60
70
  setLabelId,
61
71
  messageIds,
@@ -68,203 +78,34 @@ const LabelableProvider_LabelableProvider = function(props) {
68
78
  });
69
79
  };
70
80
  if ("production" !== process.env.NODE_ENV) LabelableProvider_LabelableProvider.displayName = "LabelableProvider";
71
- function getCombinedFieldValidityData(validityData, invalid) {
72
- return {
73
- ...validityData,
74
- state: {
75
- ...validityData.state,
76
- valid: !invalid && validityData.state.valid
77
- }
78
- };
79
- }
80
- const validityKeys = Object.keys(DEFAULT_VALIDITY_STATE);
81
- function isOnlyValueMissing(state) {
82
- if (!state || state.valid || !state.valueMissing) return false;
83
- let onlyValueMissing = false;
84
- for (const key of validityKeys)if ('valid' !== key) {
85
- if ('valueMissing' === key) onlyValueMissing = state[key];
86
- if (state[key]) onlyValueMissing = false;
87
- }
88
- return onlyValueMissing;
89
- }
90
- function useFieldValidation(params) {
91
- const { formRef, clearErrors } = useFormContext();
92
- const { setValidityData, validate, validityData, validationDebounceTime, invalid, markedDirtyRef, state, name, shouldValidateOnChange, getRegisteredFieldId } = params;
93
- const { controlId, getDescriptionProps } = useLabelableContext();
94
- const timeout = useTimeout();
95
- const inputRef = __rspack_external_react.useRef(null);
96
- const commit = useStableCallback(async (value, revalidate = false)=>{
97
- const element = inputRef.current;
98
- if (!element) return;
99
- function updateRegisteredFieldValidity(nextValidityData, externalInvalid = invalid) {
100
- const fieldId = getRegisteredFieldId() ?? controlId;
101
- if (null == fieldId) return;
102
- const currentFieldData = formRef.current.fields.get(fieldId);
103
- if (!currentFieldData) return;
104
- const validityDataWithFormErrors = getCombinedFieldValidityData(nextValidityData, externalInvalid);
105
- formRef.current.fields.set(fieldId, {
106
- ...currentFieldData,
107
- validityData: validityDataWithFormErrors
108
- });
109
- }
110
- if (revalidate) {
111
- if (false !== state.valid) return;
112
- const currentNativeValidity = element.validity;
113
- if (!currentNativeValidity.valueMissing) {
114
- const nextValidityData = {
115
- value,
116
- state: {
117
- ...DEFAULT_VALIDITY_STATE,
118
- valid: true
119
- },
120
- error: '',
121
- errors: [],
122
- initialValue: validityData.initialValue
123
- };
124
- element.setCustomValidity('');
125
- updateRegisteredFieldValidity(nextValidityData, false);
126
- setValidityData(nextValidityData);
127
- return;
128
- }
129
- const currentNativeValidityObject = validityKeys.reduce((acc, key)=>{
130
- acc[key] = currentNativeValidity[key];
131
- return acc;
132
- }, {});
133
- if (!currentNativeValidityObject.valid && !isOnlyValueMissing(currentNativeValidityObject)) return;
134
- }
135
- function getState(el) {
136
- const computedState = validityKeys.reduce((acc, key)=>{
137
- acc[key] = el.validity[key];
138
- return acc;
139
- }, {});
140
- let hasOnlyValueMissingError = false;
141
- for (const key of validityKeys)if ('valid' !== key) {
142
- if ('valueMissing' === key && computedState[key]) hasOnlyValueMissingError = true;
143
- else if (computedState[key]) return computedState;
144
- }
145
- if (hasOnlyValueMissingError && !markedDirtyRef.current) {
146
- computedState.valid = true;
147
- computedState.valueMissing = false;
148
- }
149
- return computedState;
150
- }
151
- timeout.clear();
152
- let result = null;
153
- let validationErrors = [];
154
- const nextState = getState(element);
155
- let defaultValidationMessage;
156
- const validateOnChange = shouldValidateOnChange();
157
- if (element.validationMessage && !validateOnChange) {
158
- defaultValidationMessage = element.validationMessage;
159
- validationErrors = [
160
- element.validationMessage
161
- ];
162
- } else {
163
- const formValues = Array.from(formRef.current.fields.values()).reduce((acc, field)=>{
164
- if (field.name) acc[field.name] = field.getValue();
165
- return acc;
166
- }, {});
167
- const resultOrPromise = validate(value, formValues);
168
- result = 'object' == typeof resultOrPromise && null !== resultOrPromise && 'then' in resultOrPromise ? await resultOrPromise : resultOrPromise;
169
- if (null !== result) {
170
- nextState.valid = false;
171
- nextState.customError = true;
172
- if (Array.isArray(result)) {
173
- validationErrors = result;
174
- element.setCustomValidity(result.join('\n'));
175
- } else if (result) {
176
- validationErrors = [
177
- result
178
- ];
179
- element.setCustomValidity(result);
180
- }
181
- } else if (validateOnChange) {
182
- element.setCustomValidity('');
183
- nextState.customError = false;
184
- if (element.validationMessage) {
185
- defaultValidationMessage = element.validationMessage;
186
- validationErrors = [
187
- element.validationMessage
188
- ];
189
- } else if (element.validity.valid && !nextState.valid) nextState.valid = true;
190
- }
191
- }
192
- const nextValidityData = {
193
- value,
194
- state: nextState,
195
- error: defaultValidationMessage ?? (Array.isArray(result) ? result[0] : result ?? ''),
196
- errors: validationErrors,
197
- initialValue: validityData.initialValue
198
- };
199
- updateRegisteredFieldValidity(nextValidityData);
200
- setValidityData(nextValidityData);
201
- });
202
- const getValidationProps = __rspack_external_react.useCallback((externalProps = {})=>mergeProps(getDescriptionProps, false === state.valid ? {
203
- 'aria-invalid': true
204
- } : EMPTY_OBJECT, externalProps), [
205
- getDescriptionProps,
206
- state.valid
207
- ]);
208
- const getInputValidationProps = __rspack_external_react.useCallback((externalProps = {})=>mergeProps({
209
- onChange (event) {
210
- if (event.nativeEvent.defaultPrevented) return;
211
- clearErrors(name);
212
- if (!shouldValidateOnChange()) return void commit(event.currentTarget.value, true);
213
- const element = event.currentTarget;
214
- if ('' === element.value) return void commit(element.value);
215
- timeout.clear();
216
- if (validationDebounceTime) timeout.start(validationDebounceTime, ()=>{
217
- commit(element.value);
218
- });
219
- else commit(element.value);
220
- }
221
- }, getValidationProps(externalProps)), [
222
- getValidationProps,
223
- clearErrors,
224
- name,
225
- timeout,
226
- commit,
227
- validationDebounceTime,
228
- shouldValidateOnChange
229
- ]);
230
- return __rspack_external_react.useMemo(()=>({
231
- getValidationProps,
232
- getInputValidationProps,
233
- inputRef,
234
- commit
235
- }), [
236
- getValidationProps,
237
- getInputValidationProps,
238
- commit
239
- ]);
240
- }
241
81
  function useFieldControlRegistration(params) {
242
- const { commit, invalid, markedDirtyRef, name, setRegisteredFieldId, setValidityData, validityData } = params;
82
+ const { change, commit, invalid, markedDirtyRef, name, setRegisteredFieldName, registeredFieldIdRef, setValidityData, validityData } = params;
243
83
  const { formRef } = useFormContext();
244
84
  const activeFieldControlSourceRef = __rspack_external_react.useRef(null);
245
85
  const registrationRef = __rspack_external_react.useRef(null);
246
- const fallbackControlRef = __rspack_external_react.useRef(null);
86
+ const initialValueCapturedRef = __rspack_external_react.useRef(false);
247
87
  const getValueForForm = useStableCallback(()=>{
248
88
  const registration = registrationRef.current;
249
89
  if (!registration) return;
250
90
  if (registration.getValue) return registration.getValue();
251
91
  return registration.value;
252
92
  });
93
+ function getRegistrationValue(registration) {
94
+ return void 0 === registration.value ? getValueForForm() : registration.value;
95
+ }
253
96
  const validate = useStableCallback(()=>{
254
97
  const registration = registrationRef.current;
255
- if (!registration) return;
256
- let nextValue = registration.value;
257
- if (void 0 === nextValue) nextValue = getValueForForm();
258
98
  markedDirtyRef.current = true;
259
- commit(nextValue);
99
+ if (!registration) return void commit(validityData.value);
100
+ commit(getRegistrationValue(registration));
260
101
  });
261
102
  function refreshRegistration() {
262
103
  const registration = registrationRef.current;
263
104
  if (!registration || !registration.id) return;
264
105
  formRef.current.fields.set(registration.id, {
265
106
  getValue: getValueForForm,
266
- name,
267
- controlRef: registration.controlRef ?? fallbackControlRef,
107
+ name: name ?? registration.name,
108
+ controlRef: registration.controlRef,
268
109
  validityData: getCombinedFieldValidityData(validityData, invalid),
269
110
  validate
270
111
  });
@@ -272,23 +113,23 @@ function useFieldControlRegistration(params) {
272
113
  function deleteRegistration(id = registrationRef.current?.id) {
273
114
  if (id) formRef.current.fields.delete(id);
274
115
  }
275
- function syncInitialValue() {
276
- const registration = registrationRef.current;
277
- if (!registration) return;
278
- let initialValue = registration.value;
279
- if (void 0 === initialValue) initialValue = getValueForForm();
280
- if (null === validityData.initialValue && null !== initialValue) setValidityData((prev)=>({
116
+ function captureInitialValue(registration) {
117
+ if (initialValueCapturedRef.current) return;
118
+ initialValueCapturedRef.current = true;
119
+ const initialValue = getRegistrationValue(registration);
120
+ setValidityData((prev)=>prev.initialValue === initialValue ? prev : {
281
121
  ...prev,
282
122
  initialValue
283
- }));
123
+ });
284
124
  }
285
125
  useIsoLayoutEffect(()=>{
286
126
  const registration = registrationRef.current;
287
127
  if (!registration || !registration.id) return;
128
+ setRegisteredFieldName(name ? void 0 : registration.name);
288
129
  formRef.current.fields.set(registration.id, {
289
130
  getValue: getValueForForm,
290
- name,
291
- controlRef: registration.controlRef ?? fallbackControlRef,
131
+ name: name ?? registration.name,
132
+ controlRef: registration.controlRef,
292
133
  validityData: getCombinedFieldValidityData(validityData, invalid),
293
134
  validate
294
135
  });
@@ -297,6 +138,7 @@ function useFieldControlRegistration(params) {
297
138
  getValueForForm,
298
139
  invalid,
299
140
  name,
141
+ setRegisteredFieldName,
300
142
  validate,
301
143
  validityData
302
144
  ]);
@@ -309,43 +151,56 @@ function useFieldControlRegistration(params) {
309
151
  }, [
310
152
  formRef
311
153
  ]);
312
- return useStableCallback((source, registration)=>{
154
+ const register = useStableCallback((source, registration)=>{
313
155
  if (!registration) {
314
156
  if (activeFieldControlSourceRef.current === source) {
315
157
  activeFieldControlSourceRef.current = null;
158
+ change(void 0, true);
316
159
  deleteRegistration();
317
160
  registrationRef.current = null;
318
- setRegisteredFieldId(void 0);
161
+ setRegisteredFieldName(void 0);
162
+ registeredFieldIdRef.current = void 0;
319
163
  }
320
164
  return;
321
165
  }
322
166
  const previousId = registrationRef.current?.id;
167
+ const previousSource = activeFieldControlSourceRef.current;
168
+ if (previousSource && previousSource !== source) change(void 0, true);
323
169
  activeFieldControlSourceRef.current = source;
324
170
  registrationRef.current = registration;
325
- setRegisteredFieldId(registration.id);
171
+ if (!name) setRegisteredFieldName(registration.name);
172
+ registeredFieldIdRef.current = registration.id;
326
173
  if (previousId && previousId !== registration.id) deleteRegistration(previousId);
327
- syncInitialValue();
174
+ captureInitialValue(registration);
328
175
  refreshRegistration();
329
176
  });
177
+ return [
178
+ validate,
179
+ register
180
+ ];
330
181
  }
331
182
  const FieldRoot_FieldRootInner = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
332
- const { errors, validationMode: formValidationMode, submitAttemptedRef } = useFormContext();
183
+ const { errors, validationMode: formValidationMode, submitCountRef } = useFormContext();
333
184
  const { render, className, validate: validateProp, validationDebounceTime = 0, validationMode = formValidationMode, name, disabled: disabledProp = false, invalid: invalidProp, dirty: dirtyProp, touched: touchedProp, actionsRef, style, ...elementProps } = componentProps;
334
- const { disabled: disabledFieldset } = useFieldsetRootContext();
185
+ const disabledFieldset = useFieldsetRootContext(true)?.disabled;
335
186
  const validate = useStableCallback(validateProp || (()=>null));
336
187
  const disabled = disabledFieldset || disabledProp;
337
188
  const [touchedState, setTouchedUnwrapped] = __rspack_external_react.useState(false);
338
189
  const [dirtyState, setDirtyUnwrapped] = __rspack_external_react.useState(false);
339
190
  const [filled, setFilled] = __rspack_external_react.useState(false);
340
191
  const [focused, setFocused] = __rspack_external_react.useState(false);
192
+ const focusOwnerRef = __rspack_external_react.useRef(void 0);
341
193
  const dirty = dirtyProp ?? dirtyState;
342
194
  const touched = touchedProp ?? touchedState;
343
- const markedDirtyRef = __rspack_external_react.useRef(false);
195
+ const markedDirtyRef = __rspack_external_react.useRef(dirty);
344
196
  const registeredFieldIdRef = __rspack_external_react.useRef(void 0);
345
- const getRegisteredFieldId = __rspack_external_react.useCallback(()=>registeredFieldIdRef.current, []);
346
- const setRegisteredFieldId = __rspack_external_react.useCallback((id)=>{
347
- registeredFieldIdRef.current = id;
348
- }, []);
197
+ const [registeredFieldName, setRegisteredFieldName] = __rspack_external_react.useState();
198
+ const effectiveName = name ?? registeredFieldName;
199
+ useIsoLayoutEffect(()=>{
200
+ if (void 0 !== dirtyProp) markedDirtyRef.current = dirtyProp;
201
+ }, [
202
+ dirtyProp
203
+ ]);
349
204
  const setDirty = useStableCallback((value)=>{
350
205
  if (void 0 !== dirtyProp) return;
351
206
  if (value) markedDirtyRef.current = true;
@@ -355,8 +210,9 @@ const FieldRoot_FieldRootInner = /*#__PURE__*/ __rspack_external_react.forwardRe
355
210
  if (void 0 !== touchedProp) return;
356
211
  setTouchedUnwrapped(value);
357
212
  });
358
- const shouldValidateOnChange = useStableCallback(()=>'onChange' === validationMode || 'onSubmit' === validationMode && submitAttemptedRef.current);
359
- const hasFormError = !!name && Object.hasOwn(errors, name) && void 0 !== errors[name];
213
+ const shouldValidateOnChange = useStableCallback(()=>'onChange' === validationMode || 'onSubmit' === validationMode && submitCountRef.current > 0);
214
+ const formError = effectiveName && Object.hasOwn(errors, effectiveName) ? errors[effectiveName] : null;
215
+ const hasFormError = !!(Array.isArray(formError) ? formError.length : formError);
360
216
  const invalid = true === invalidProp || hasFormError;
361
217
  const [validityData, setValidityData] = __rspack_external_react.useState({
362
218
  state: DEFAULT_VALIDITY_STATE,
@@ -365,7 +221,7 @@ const FieldRoot_FieldRootInner = /*#__PURE__*/ __rspack_external_react.forwardRe
365
221
  value: null,
366
222
  initialValue: null
367
223
  });
368
- const valid = !invalid && validityData.state.valid;
224
+ const valid = !invalid && (disabled ? null : validityData.state.valid);
369
225
  const state = __rspack_external_react.useMemo(()=>({
370
226
  disabled,
371
227
  touched,
@@ -389,70 +245,52 @@ const FieldRoot_FieldRootInner = /*#__PURE__*/ __rspack_external_react.forwardRe
389
245
  invalid,
390
246
  markedDirtyRef,
391
247
  state,
392
- name,
393
248
  shouldValidateOnChange,
394
- getRegisteredFieldId
249
+ validationMode,
250
+ registeredFieldIdRef
395
251
  });
396
- const validityValue = validityData.value;
397
- const handleImperativeValidate = __rspack_external_react.useCallback(()=>{
398
- markedDirtyRef.current = true;
399
- validation.commit(validityValue);
400
- }, [
401
- validation,
402
- validityValue
403
- ]);
404
- const registerFieldControl = useFieldControlRegistration({
252
+ const [validateFieldControl, registerFieldControl] = useFieldControlRegistration({
253
+ change: validation.change,
405
254
  commit: validation.commit,
406
255
  invalid,
407
256
  markedDirtyRef,
408
257
  name,
409
- setRegisteredFieldId,
258
+ setRegisteredFieldName,
259
+ registeredFieldIdRef,
410
260
  setValidityData,
411
261
  validityData
412
262
  });
413
263
  __rspack_external_react.useImperativeHandle(actionsRef, ()=>({
414
- validate: handleImperativeValidate
264
+ validate: validateFieldControl
415
265
  }), [
416
- handleImperativeValidate
266
+ validateFieldControl
417
267
  ]);
418
268
  const contextValue = __rspack_external_react.useMemo(()=>({
419
269
  invalid,
420
- name,
270
+ name: effectiveName,
421
271
  validityData,
422
272
  setValidityData,
423
273
  disabled,
424
- touched,
425
274
  setTouched,
426
- dirty,
427
275
  setDirty,
428
- filled,
429
276
  setFilled,
430
- focused,
431
277
  setFocused,
432
- validate,
278
+ focusOwnerRef,
433
279
  validationMode,
434
- validationDebounceTime,
435
280
  shouldValidateOnChange,
436
281
  state,
437
- markedDirtyRef,
438
282
  registerFieldControl,
439
283
  validation
440
284
  }), [
441
285
  invalid,
442
- name,
286
+ effectiveName,
443
287
  validityData,
444
288
  disabled,
445
- touched,
446
289
  setTouched,
447
- dirty,
448
290
  setDirty,
449
- filled,
450
291
  setFilled,
451
- focused,
452
292
  setFocused,
453
- validate,
454
293
  validationMode,
455
- validationDebounceTime,
456
294
  shouldValidateOnChange,
457
295
  state,
458
296
  registerFieldControl,
@@ -482,7 +320,12 @@ if ("production" !== process.env.NODE_ENV) FieldRoot_FieldRoot.displayName = "Fi
482
320
  const FieldLabel_FieldLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
483
321
  const { render, className, style, id: idProp, nativeLabel = true, ...elementProps } = componentProps;
484
322
  const fieldRootContext = useFieldRootContext(false);
323
+ const fieldItemContext = useFieldItemContext();
485
324
  const { labelId } = useLabelableContext();
325
+ const state = {
326
+ ...fieldRootContext.state,
327
+ disabled: fieldRootContext.disabled || fieldItemContext.disabled
328
+ };
486
329
  const labelRef = __rspack_external_react.useRef(null);
487
330
  const labelProps = useLabel({
488
331
  id: labelId ?? idProp,
@@ -495,12 +338,12 @@ const FieldLabel_FieldLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(f
495
338
  if (!isLabelTag) {
496
339
  const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';
497
340
  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`.";
498
- error(`${message}${ownerStackMessage}`);
341
+ error_error(`${message}${ownerStackMessage}`);
499
342
  }
500
343
  } else if (isLabelTag) {
501
344
  const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';
502
345
  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`.";
503
- error(`${message}${ownerStackMessage}`);
346
+ error_error(`${message}${ownerStackMessage}`);
504
347
  }
505
348
  }, [
506
349
  nativeLabel
@@ -510,7 +353,7 @@ const FieldLabel_FieldLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(f
510
353
  forwardedRef,
511
354
  labelRef
512
355
  ],
513
- state: fieldRootContext.state,
356
+ state,
514
357
  props: [
515
358
  labelProps,
516
359
  elementProps
@@ -530,10 +373,11 @@ const FieldError_FieldError = /*#__PURE__*/ __rspack_external_react.forwardRef(f
530
373
  const { validityData, state: fieldState, name } = useFieldRootContext(false);
531
374
  const { setMessageIds } = useLabelableContext();
532
375
  const { errors } = useFormContext();
533
- const formError = name ? errors[name] : null;
376
+ const formError = name && Object.hasOwn(errors, name) ? errors[name] : null;
377
+ const hasFormError = !!(Array.isArray(formError) ? formError.length : formError);
534
378
  const hasSpecificMatch = 'string' == typeof match;
535
379
  let rendered = false;
536
- rendered = true === match ? true : hasSpecificMatch ? Boolean(validityData.state[match]) : Boolean(formError) || false === validityData.state.valid;
380
+ rendered = true === match ? true : fieldState.disabled ? false : hasSpecificMatch ? Boolean(validityData.state[match]) : hasFormError || false === validityData.state.valid;
537
381
  const { mounted, transitionStatus, setMounted } = useTransitionStatus(rendered);
538
382
  useIsoLayoutEffect(()=>{
539
383
  if (!rendered || !id) return;
@@ -549,15 +393,16 @@ const FieldError_FieldError = /*#__PURE__*/ __rspack_external_react.forwardRef(f
549
393
  const errorRef = __rspack_external_react.useRef(null);
550
394
  const [lastRenderedMessage, setLastRenderedMessage] = __rspack_external_react.useState(null);
551
395
  const [lastRenderedMessageKey, setLastRenderedMessageKey] = __rspack_external_react.useState(null);
552
- const clientErrorMessage = validityData.errors.length > 1 ? /*#__PURE__*/ jsx("ul", {
553
- children: validityData.errors.map((message)=>/*#__PURE__*/ jsx("li", {
396
+ let error = validityData.error;
397
+ if (!hasSpecificMatch && hasFormError) error = formError;
398
+ else if (validityData.errors.length > 1) error = validityData.errors;
399
+ let errorMessage = error;
400
+ if (Array.isArray(error)) errorMessage = error.length > 1 ? /*#__PURE__*/ jsx("ul", {
401
+ children: error.map((message)=>/*#__PURE__*/ jsx("li", {
554
402
  children: message
555
403
  }, message))
556
- }) : validityData.error;
557
- const errorMessage = hasSpecificMatch ? clientErrorMessage : formError || clientErrorMessage;
558
- let errorKey = validityData.error;
559
- if (null != formError) errorKey = Array.isArray(formError) ? JSON.stringify(formError) : formError;
560
- else if (validityData.errors.length > 1) errorKey = JSON.stringify(validityData.errors);
404
+ }) : error[0];
405
+ const errorKey = Array.isArray(error) ? JSON.stringify(error) : error;
561
406
  if (rendered && errorKey !== lastRenderedMessageKey) {
562
407
  setLastRenderedMessageKey(errorKey);
563
408
  setLastRenderedMessage(errorMessage);
@@ -597,7 +442,12 @@ const FieldDescription_FieldDescription = /*#__PURE__*/ __rspack_external_react.
597
442
  const { render, id: idProp, className, style, ...elementProps } = componentProps;
598
443
  const id = useBaseUiId(idProp);
599
444
  const fieldRootContext = useFieldRootContext(false);
445
+ const fieldItemContext = useFieldItemContext();
600
446
  const { setMessageIds } = useLabelableContext();
447
+ const state = {
448
+ ...fieldRootContext.state,
449
+ disabled: fieldRootContext.disabled || fieldItemContext.disabled
450
+ };
601
451
  useIsoLayoutEffect(()=>{
602
452
  if (!id) return;
603
453
  setMessageIds((v)=>v.concat(id));
@@ -610,7 +460,7 @@ const FieldDescription_FieldDescription = /*#__PURE__*/ __rspack_external_react.
610
460
  ]);
611
461
  const element = useRenderElement('p', componentProps, {
612
462
  ref: forwardedRef,
613
- state: fieldRootContext.state,
463
+ state,
614
464
  props: [
615
465
  {
616
466
  id
@@ -624,11 +474,12 @@ const FieldDescription_FieldDescription = /*#__PURE__*/ __rspack_external_react.
624
474
  if ("production" !== process.env.NODE_ENV) FieldDescription_FieldDescription.displayName = "FieldDescription";
625
475
  const FieldItem_FieldItem = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
626
476
  const { render, className, style, disabled: disabledProp = false, ...elementProps } = componentProps;
627
- const { state, disabled: rootDisabled } = useFieldRootContext(false);
477
+ const { state: fieldState, disabled: rootDisabled } = useFieldRootContext(false);
628
478
  const disabled = rootDisabled || disabledProp;
629
- const checkboxGroupContext = useCheckboxGroupContext();
630
- const hasParentCheckbox = checkboxGroupContext?.allValues !== void 0;
631
- const controlId = hasParentCheckbox ? checkboxGroupContext?.parent.id : void 0;
479
+ const state = {
480
+ ...fieldState,
481
+ disabled
482
+ };
632
483
  const fieldItemContext = __rspack_external_react.useMemo(()=>({
633
484
  disabled
634
485
  }), [
@@ -641,7 +492,6 @@ const FieldItem_FieldItem = /*#__PURE__*/ __rspack_external_react.forwardRef(fun
641
492
  stateAttributesMapping: fieldValidityMapping
642
493
  });
643
494
  return /*#__PURE__*/ jsx(LabelableProvider_LabelableProvider, {
644
- controlId: controlId,
645
495
  children: /*#__PURE__*/ jsx(FieldItemContext.Provider, {
646
496
  value: fieldItemContext,
647
497
  children: element
@@ -39,6 +39,11 @@ declare type BaseUIEvent<E extends React_2.SyntheticEvent<Element, Event>> = E &
39
39
  */
40
40
  declare type ComponentRenderFn<Props, State> = (props: Props, state: State) => React_2.ReactElement<unknown>;
41
41
 
42
+ /**
43
+ * Present when the fieldset is disabled.
44
+ */
45
+ declare const disabled = "data-disabled";
46
+
42
47
  export declare const Fieldset: {
43
48
  Root: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<FieldsetRootProps_2, "ref"> & React_2.RefAttributes<HTMLElement>, "ref">, "className"> & {
44
49
  className?: string;
@@ -61,6 +66,12 @@ export declare namespace FieldsetLegend {
61
66
  export type Props = FieldsetLegendProps;
62
67
  }
63
68
 
69
+ export declare namespace FieldsetLegendDataAttributes {
70
+ export {
71
+ disabled
72
+ }
73
+ }
74
+
64
75
  export declare interface FieldsetLegendProps extends BaseUIComponentProps<'div', FieldsetLegendState> {}
65
76
 
66
77
  export declare interface FieldsetLegendState {