@povio/ui 3.4.0-rc.1 → 3.4.0-rc.11

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 (78) hide show
  1. package/dist/components/inputs/Checkbox/Checkbox.d.ts +2 -1
  2. package/dist/components/inputs/Checkbox/Checkbox.js +100 -93
  3. package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +2 -1
  4. package/dist/components/inputs/Checkbox/CheckboxGroup.js +113 -109
  5. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +2 -1
  6. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +21 -14
  7. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
  8. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +22 -14
  9. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
  10. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +21 -14
  11. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
  12. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +294 -275
  13. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +2 -1
  14. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +10 -1
  15. package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
  16. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +46 -43
  17. package/dist/components/inputs/File/FileUpload.d.ts +1 -1
  18. package/dist/components/inputs/File/FileUpload.js +17 -17
  19. package/dist/components/inputs/File/InputUpload.d.ts +1 -1
  20. package/dist/components/inputs/File/InputUpload.js +17 -17
  21. package/dist/components/inputs/File/fileUpload.types.d.ts +1 -1
  22. package/dist/components/inputs/File/inputUpload.types.d.ts +1 -1
  23. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -1
  24. package/dist/components/inputs/Input/NumberInput/NumberInput.js +19 -19
  25. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +1 -1
  26. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +18 -18
  27. package/dist/components/inputs/Input/PasswordInput/PasswordInput.d.ts +1 -1
  28. package/dist/components/inputs/Input/TextArea/TextArea.d.ts +1 -1
  29. package/dist/components/inputs/Input/TextArea/TextArea.js +18 -18
  30. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +2 -2
  31. package/dist/components/inputs/Input/TextInput/TextInput.js +38 -36
  32. package/dist/components/inputs/Inputs/Form.d.ts +4 -4
  33. package/dist/components/inputs/Inputs/InputItem.d.ts +22 -22
  34. package/dist/components/inputs/Inputs/InputItem.js +36 -35
  35. package/dist/components/inputs/Inputs/Inputs.d.ts +2 -2
  36. package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
  37. package/dist/components/inputs/RadioGroup/RadioGroup.js +111 -107
  38. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -1
  39. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +13 -13
  40. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  41. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +19 -19
  42. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -1
  43. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -1
  44. package/dist/components/inputs/Selection/Select/QuerySelect.js +19 -19
  45. package/dist/components/inputs/Selection/Select/Select.d.ts +1 -1
  46. package/dist/components/inputs/Selection/Select/Select.js +19 -19
  47. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -0
  48. package/dist/components/inputs/Selection/shared/SelectBase.js +37 -34
  49. package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
  50. package/dist/components/inputs/Selection/shared/select.context.js +8 -4
  51. package/dist/components/inputs/Selection/shared/select.types.d.ts +1 -1
  52. package/dist/components/inputs/Slider/Slider.d.ts +1 -1
  53. package/dist/components/inputs/Slider/Slider.js +18 -18
  54. package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -1
  55. package/dist/components/inputs/TextEditor/TextEditor.js +18 -18
  56. package/dist/components/inputs/Toggle/Toggle.d.ts +2 -1
  57. package/dist/components/inputs/Toggle/Toggle.js +63 -59
  58. package/dist/components/inputs/shared/form.types.d.ts +8 -9
  59. package/dist/components/segment/Segment.d.ts +1 -1
  60. package/dist/components/segment/Segment.js +17 -17
  61. package/dist/components/segment/segment.types.d.ts +1 -1
  62. package/dist/config/uiConfig.context.d.ts +5 -5
  63. package/dist/config/uiConfig.context.js +12 -3
  64. package/dist/helpers/dynamicColumns.d.ts +1 -1
  65. package/dist/helpers/dynamicInputs.d.ts +7 -7
  66. package/dist/hooks/useAutosave.d.ts +4 -4
  67. package/dist/hooks/useAutosave.js +49 -64
  68. package/dist/hooks/useAutosave.spec.d.ts +1 -0
  69. package/dist/hooks/useForm.d.ts +15 -39
  70. package/dist/hooks/useForm.js +43 -96
  71. package/dist/hooks/useFormAutosave.d.ts +9 -8
  72. package/dist/hooks/useFormAutosave.js +9 -23
  73. package/dist/index.d.ts +2 -2
  74. package/dist/index.js +3 -3
  75. package/package.json +3 -2
  76. package/dist/components/inputs/shared/form.binding.d.ts +0 -27
  77. package/dist/components/inputs/shared/form.binding.js +0 -57
  78. package/dist/components/inputs/shared/form.types.js +0 -8
@@ -1,6 +1,5 @@
1
1
  import { UIOverrides } from "../../../config/uiOverrides.context.js";
2
2
  import { UIConfig } from "../../../config/uiConfig.context.js";
3
- import { FieldController } from "../shared/form.binding.js";
4
3
  import { checkboxContentRowDefinition, checkboxContentWrapperDefinition, checkboxGroupLabelDefinition } from "./checkbox.cva.js";
5
4
  import { CheckboxBase } from "./Checkbox.js";
6
5
  import { FormFieldLabel } from "../FormField/FormFieldLabel.js";
@@ -12,20 +11,22 @@ import { clsx } from "clsx";
12
11
  import { CheckboxGroup } from "react-aria-components";
13
12
  import { useLabel } from "react-aria";
14
13
  import { mergeRefs } from "@react-aria/utils";
14
+ import { Controller } from "react-hook-form";
15
15
  //#region src/components/inputs/Checkbox/CheckboxGroup.tsx
16
16
  var CheckboxGroupBase = (props) => {
17
- const $ = c(99);
17
+ const $ = c(101);
18
18
  const ui = UIConfig.useConfig();
19
19
  const checkboxContentWrapperCva = UIOverrides.useCva("checkbox.contentWrapperCva", checkboxContentWrapperDefinition);
20
20
  const checkboxContentRowCva = UIOverrides.useCva("checkbox.contentRowCva", checkboxContentRowDefinition);
21
21
  const checkboxGroupLabelCva = UIOverrides.useCva("checkbox.groupLabelCva", checkboxGroupLabelDefinition);
22
22
  const inputBaseCva = UIOverrides.useCva("input.baseCva", inputBaseDefinition);
23
23
  const inputSizeCva = UIOverrides.useCva("input.sizeCva", inputSizeDefinition);
24
- const { ref, label, tooltipText, helperText, isDirty, isRequired, rightContent, isDisabled, headerClassName, errorClassName, labelClassName, inputClassName, isHeaderHidden, error, className, options, allValue, value, defaultValue, onChange, onBlur, as: asProp, size: sizeProp, variant: variantProp, hideLabel: hideLabelProp, ...rest } = props;
24
+ const { ref, label, tooltipText, helperText, isDirty, isRequired, rightContent, isDisabled, headerClassName, errorClassName, labelClassName, inputClassName, isHeaderHidden, error, className, options, allValue, value, defaultValue, onChange, onBlur, fireBlurOnChange: fireBlurOnChangeProp, as: asProp, size: sizeProp, variant: variantProp, hideLabel: hideLabelProp, ...rest } = props;
25
25
  const as = asProp ?? ui.input.as;
26
26
  const size = sizeProp ?? ui.input.size;
27
27
  const variant = variantProp ?? ui.checkbox.variant;
28
28
  const hideLabel = hideLabelProp ?? ui.input.hideLabel;
29
+ const fireBlurOnChange = fireBlurOnChangeProp ?? ui.checkbox.fireBlurOnChange;
29
30
  let optionValues;
30
31
  let resolvedValue;
31
32
  let t0;
@@ -121,16 +122,19 @@ var CheckboxGroupBase = (props) => {
121
122
  } else t5 = $[31];
122
123
  const headerProps = t5;
123
124
  let t6;
124
- if ($[32] !== allValue || $[33] !== onChange || $[34] !== optionValues) {
125
+ if ($[32] !== allValue || $[33] !== fireBlurOnChange || $[34] !== onBlur || $[35] !== onChange || $[36] !== optionValues) {
125
126
  t6 = (nextValue) => {
126
127
  const hasAllOptions = allValue !== void 0 && optionValues.length > 0 && optionValues.every((optionValue) => nextValue.includes(optionValue));
127
128
  onChange?.(hasAllOptions ? allValue : nextValue);
129
+ if (fireBlurOnChange) onBlur?.({});
128
130
  };
129
131
  $[32] = allValue;
130
- $[33] = onChange;
131
- $[34] = optionValues;
132
- $[35] = t6;
133
- } else t6 = $[35];
132
+ $[33] = fireBlurOnChange;
133
+ $[34] = onBlur;
134
+ $[35] = onChange;
135
+ $[36] = optionValues;
136
+ $[37] = t6;
137
+ } else t6 = $[37];
134
138
  const handleChange = t6;
135
139
  const T0 = CheckboxGroup;
136
140
  const t7 = !!error;
@@ -140,26 +144,26 @@ var CheckboxGroupBase = (props) => {
140
144
  const T1 = FormField;
141
145
  const t11 = as === "inline" && "h-full";
142
146
  let t12;
143
- if ($[36] !== className || $[37] !== t11) {
147
+ if ($[38] !== className || $[39] !== t11) {
144
148
  t12 = clsx("w-full", t11, className);
145
- $[36] = className;
146
- $[37] = t11;
147
- $[38] = t12;
148
- } else t12 = $[38];
149
+ $[38] = className;
150
+ $[39] = t11;
151
+ $[40] = t12;
152
+ } else t12 = $[40];
149
153
  const t13 = as === "inline" ? -1 : void 0;
150
154
  let t14;
151
- if ($[39] !== as || $[40] !== inputBaseCva || $[41] !== inputClassName || $[42] !== shouldRenderInputFrame || $[43] !== ui) {
155
+ if ($[41] !== as || $[42] !== inputBaseCva || $[43] !== inputClassName || $[44] !== shouldRenderInputFrame || $[45] !== ui) {
152
156
  t14 = clsx("group/checkbox-group-content relative", shouldRenderInputFrame && inputBaseCva({
153
157
  variant: ui.input.variant,
154
158
  as
155
159
  }), inputClassName);
156
- $[39] = as;
157
- $[40] = inputBaseCva;
158
- $[41] = inputClassName;
159
- $[42] = shouldRenderInputFrame;
160
- $[43] = ui;
161
- $[44] = t14;
162
- } else t14 = $[44];
160
+ $[41] = as;
161
+ $[42] = inputBaseCva;
162
+ $[43] = inputClassName;
163
+ $[44] = shouldRenderInputFrame;
164
+ $[45] = ui;
165
+ $[46] = t14;
166
+ } else t14 = $[46];
163
167
  const t15 = "";
164
168
  const t16 = isDisabled || void 0;
165
169
  const t17 = isDisabled || void 0;
@@ -179,20 +183,20 @@ var CheckboxGroupBase = (props) => {
179
183
  const t22 = isDirty || void 0;
180
184
  const t23 = isRequired || void 0;
181
185
  let t24;
182
- if ($[45] !== as || $[46] !== checkboxGroupLabelCva || $[47] !== headerClassName || $[48] !== headerProps || $[49] !== size) {
186
+ if ($[47] !== as || $[48] !== checkboxGroupLabelCva || $[49] !== headerClassName || $[50] !== headerProps || $[51] !== size) {
183
187
  t24 = as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
184
188
  ...headerProps,
185
189
  as: as === "floating" ? "filter" : as,
186
190
  size,
187
191
  className: clsx(headerClassName, checkboxGroupLabelCva({ as }))
188
192
  });
189
- $[45] = as;
190
- $[46] = checkboxGroupLabelCva;
191
- $[47] = headerClassName;
192
- $[48] = headerProps;
193
- $[49] = size;
194
- $[50] = t24;
195
- } else t24 = $[50];
193
+ $[47] = as;
194
+ $[48] = checkboxGroupLabelCva;
195
+ $[49] = headerClassName;
196
+ $[50] = headerProps;
197
+ $[51] = size;
198
+ $[52] = t24;
199
+ } else t24 = $[52];
196
200
  const t25 = checkboxContentRowCva({
197
201
  variant,
198
202
  as,
@@ -200,9 +204,9 @@ var CheckboxGroupBase = (props) => {
200
204
  ...rest
201
205
  });
202
206
  let t26;
203
- if ($[51] !== hideLabel || $[52] !== labelClassName || $[53] !== options || $[54] !== variant) {
207
+ if ($[53] !== hideLabel || $[54] !== labelClassName || $[55] !== options || $[56] !== variant) {
204
208
  let t27;
205
- if ($[56] !== hideLabel || $[57] !== labelClassName || $[58] !== variant) {
209
+ if ($[58] !== hideLabel || $[59] !== labelClassName || $[60] !== variant) {
206
210
  t27 = (option_0) => /* @__PURE__ */ jsx(CheckboxBase, {
207
211
  value: option_0.value,
208
212
  variant,
@@ -211,45 +215,45 @@ var CheckboxGroupBase = (props) => {
211
215
  labelClassName,
212
216
  children: option_0.label
213
217
  }, option_0.value);
214
- $[56] = hideLabel;
215
- $[57] = labelClassName;
216
- $[58] = variant;
217
- $[59] = t27;
218
- } else t27 = $[59];
218
+ $[58] = hideLabel;
219
+ $[59] = labelClassName;
220
+ $[60] = variant;
221
+ $[61] = t27;
222
+ } else t27 = $[61];
219
223
  t26 = options.map(t27);
220
- $[51] = hideLabel;
221
- $[52] = labelClassName;
222
- $[53] = options;
223
- $[54] = variant;
224
- $[55] = t26;
225
- } else t26 = $[55];
224
+ $[53] = hideLabel;
225
+ $[54] = labelClassName;
226
+ $[55] = options;
227
+ $[56] = variant;
228
+ $[57] = t26;
229
+ } else t26 = $[57];
226
230
  let t27;
227
- if ($[60] !== t25 || $[61] !== t26) {
231
+ if ($[62] !== t25 || $[63] !== t26) {
228
232
  t27 = /* @__PURE__ */ jsx("div", {
229
233
  className: t25,
230
234
  children: t26
231
235
  });
232
- $[60] = t25;
233
- $[61] = t26;
234
- $[62] = t27;
235
- } else t27 = $[62];
236
+ $[62] = t25;
237
+ $[63] = t26;
238
+ $[64] = t27;
239
+ } else t27 = $[64];
236
240
  let t28;
237
- if ($[63] !== t21 || $[64] !== t22 || $[65] !== t23 || $[66] !== t24 || $[67] !== t27) {
241
+ if ($[65] !== t21 || $[66] !== t22 || $[67] !== t23 || $[68] !== t24 || $[69] !== t27) {
238
242
  t28 = /* @__PURE__ */ jsxs("div", {
239
243
  className: t21,
240
244
  "data-is-dirty": t22,
241
245
  "data-is-required": t23,
242
246
  children: [t24, t27]
243
247
  });
244
- $[63] = t21;
245
- $[64] = t22;
246
- $[65] = t23;
247
- $[66] = t24;
248
- $[67] = t27;
249
- $[68] = t28;
250
- } else t28 = $[68];
248
+ $[65] = t21;
249
+ $[66] = t22;
250
+ $[67] = t23;
251
+ $[68] = t24;
252
+ $[69] = t27;
253
+ $[70] = t28;
254
+ } else t28 = $[70];
251
255
  let t29;
252
- if ($[69] !== t14 || $[70] !== t16 || $[71] !== t17 || $[72] !== t18 || $[73] !== t19 || $[74] !== t28) {
256
+ if ($[71] !== t14 || $[72] !== t16 || $[73] !== t17 || $[74] !== t18 || $[75] !== t19 || $[76] !== t28) {
253
257
  t29 = /* @__PURE__ */ jsx("div", {
254
258
  className: t14,
255
259
  "data-rac": t15,
@@ -260,16 +264,16 @@ var CheckboxGroupBase = (props) => {
260
264
  "data-checkbox-group-content": t20,
261
265
  children: t28
262
266
  });
263
- $[69] = t14;
264
- $[70] = t16;
265
- $[71] = t17;
266
- $[72] = t18;
267
- $[73] = t19;
268
- $[74] = t28;
269
- $[75] = t29;
270
- } else t29 = $[75];
267
+ $[71] = t14;
268
+ $[72] = t16;
269
+ $[73] = t17;
270
+ $[74] = t18;
271
+ $[75] = t19;
272
+ $[76] = t28;
273
+ $[77] = t29;
274
+ } else t29 = $[77];
271
275
  let t30;
272
- if ($[76] !== T1 || $[77] !== as || $[78] !== formFieldProps || $[79] !== labelProps || $[80] !== t12 || $[81] !== t13 || $[82] !== t29) {
276
+ if ($[78] !== T1 || $[79] !== as || $[80] !== formFieldProps || $[81] !== labelProps || $[82] !== t12 || $[83] !== t13 || $[84] !== t29) {
273
277
  t30 = /* @__PURE__ */ jsx(T1, {
274
278
  ...formFieldProps,
275
279
  as,
@@ -278,17 +282,17 @@ var CheckboxGroupBase = (props) => {
278
282
  tabIndex: t13,
279
283
  children: t29
280
284
  });
281
- $[76] = T1;
282
- $[77] = as;
283
- $[78] = formFieldProps;
284
- $[79] = labelProps;
285
- $[80] = t12;
286
- $[81] = t13;
287
- $[82] = t29;
288
- $[83] = t30;
289
- } else t30 = $[83];
285
+ $[78] = T1;
286
+ $[79] = as;
287
+ $[80] = formFieldProps;
288
+ $[81] = labelProps;
289
+ $[82] = t12;
290
+ $[83] = t13;
291
+ $[84] = t29;
292
+ $[85] = t30;
293
+ } else t30 = $[85];
290
294
  let t31;
291
- if ($[84] !== T0 || $[85] !== fieldProps || $[86] !== handleChange || $[87] !== isDisabled || $[88] !== isRequired || $[89] !== onBlur || $[90] !== ref || $[91] !== resolvedDefaultValue || $[92] !== resolvedValue || $[93] !== rest || $[94] !== t30 || $[95] !== t7 || $[96] !== t8 || $[97] !== t9) {
295
+ if ($[86] !== T0 || $[87] !== fieldProps || $[88] !== handleChange || $[89] !== isDisabled || $[90] !== isRequired || $[91] !== onBlur || $[92] !== ref || $[93] !== resolvedDefaultValue || $[94] !== resolvedValue || $[95] !== rest || $[96] !== t30 || $[97] !== t7 || $[98] !== t8 || $[99] !== t9) {
292
296
  t31 = /* @__PURE__ */ jsx(T0, {
293
297
  ...rest,
294
298
  ...fieldProps,
@@ -305,55 +309,55 @@ var CheckboxGroupBase = (props) => {
305
309
  className: t10,
306
310
  children: t30
307
311
  });
308
- $[84] = T0;
309
- $[85] = fieldProps;
310
- $[86] = handleChange;
311
- $[87] = isDisabled;
312
- $[88] = isRequired;
313
- $[89] = onBlur;
314
- $[90] = ref;
315
- $[91] = resolvedDefaultValue;
316
- $[92] = resolvedValue;
317
- $[93] = rest;
318
- $[94] = t30;
319
- $[95] = t7;
320
- $[96] = t8;
321
- $[97] = t9;
322
- $[98] = t31;
323
- } else t31 = $[98];
312
+ $[86] = T0;
313
+ $[87] = fieldProps;
314
+ $[88] = handleChange;
315
+ $[89] = isDisabled;
316
+ $[90] = isRequired;
317
+ $[91] = onBlur;
318
+ $[92] = ref;
319
+ $[93] = resolvedDefaultValue;
320
+ $[94] = resolvedValue;
321
+ $[95] = rest;
322
+ $[96] = t30;
323
+ $[97] = t7;
324
+ $[98] = t8;
325
+ $[99] = t9;
326
+ $[100] = t31;
327
+ } else t31 = $[100];
324
328
  return t31;
325
329
  };
326
330
  var CheckboxGroup$1 = (props) => {
327
331
  const $ = c(15);
328
- if ("field" in props && props.field) {
329
- let field;
332
+ if ("formControl" in props && props.formControl) {
333
+ let formControl;
330
334
  let innerProps;
331
335
  let ref;
332
336
  if ($[0] !== props) {
333
- ({field, ref, ...innerProps} = props);
337
+ ({formControl, ref, ...innerProps} = props);
334
338
  $[0] = props;
335
- $[1] = field;
339
+ $[1] = formControl;
336
340
  $[2] = innerProps;
337
341
  $[3] = ref;
338
342
  } else {
339
- field = $[1];
343
+ formControl = $[1];
340
344
  innerProps = $[2];
341
345
  ref = $[3];
342
346
  }
343
347
  let t0;
344
348
  if ($[4] !== innerProps || $[5] !== props.error || $[6] !== props.isDisabled || $[7] !== ref) {
345
349
  t0 = (t1) => {
346
- const { field: field_0, fieldState: t2 } = t1;
350
+ const { field, fieldState: t2 } = t1;
347
351
  const { error, isDirty } = t2;
348
352
  return /* @__PURE__ */ jsx(CheckboxGroupBase, {
349
353
  ...innerProps,
350
- ref: mergeRefs(ref, field_0.ref),
351
- value: field_0.value,
352
- onChange: field_0.onChange,
353
- onBlur: field_0.onBlur,
354
- name: field_0.name,
354
+ ref: mergeRefs(ref, field.ref),
355
+ value: field.value,
356
+ onChange: field.onChange,
357
+ onBlur: field.onBlur,
358
+ name: field.name,
355
359
  isDirty,
356
- isDisabled: field_0.disabled || props.isDisabled,
360
+ isDisabled: field.disabled || props.isDisabled,
357
361
  error: props.error ?? error?.message
358
362
  });
359
363
  };
@@ -364,14 +368,14 @@ var CheckboxGroup$1 = (props) => {
364
368
  $[8] = t0;
365
369
  } else t0 = $[8];
366
370
  let t1;
367
- if ($[9] !== field.form || $[10] !== field.name || $[11] !== t0) {
368
- t1 = /* @__PURE__ */ jsx(FieldController, {
369
- control: field.form,
370
- name: field.name,
371
+ if ($[9] !== formControl.control || $[10] !== formControl.name || $[11] !== t0) {
372
+ t1 = /* @__PURE__ */ jsx(Controller, {
373
+ control: formControl.control,
374
+ name: formControl.name,
371
375
  render: t0
372
376
  });
373
- $[9] = field.form;
374
- $[10] = field.name;
377
+ $[9] = formControl.control;
378
+ $[10] = formControl.name;
375
379
  $[11] = t0;
376
380
  $[12] = t1;
377
381
  } else t1 = $[12];
@@ -1,6 +1,6 @@
1
1
  import { CalendarDate, DateValue } from '@internationalized/date';
2
2
  import { FocusEvent, Ref } from 'react';
3
- import { FieldValues } from '../../shared/form.binding';
3
+ import { FieldValues } from 'react-hook-form';
4
4
  import { DatePickerStateOptions } from 'react-stately';
5
5
  import { DatePickerInputHandle } from '../shared/DatePickerInput';
6
6
  import { DatePickerTodayIcon, DatePickerTodayIconButtonComponent, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
@@ -26,6 +26,7 @@ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Da
26
26
  shouldUpdateDateOnMonthYearChange?: boolean;
27
27
  granularity?: DatePickerGranularity;
28
28
  format?: string;
29
+ fireBlurOnChange?: boolean;
29
30
  }
30
31
  export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
31
32
  value?: string | null;
@@ -1,6 +1,5 @@
1
1
  import { UIOverrides } from "../../../../config/uiOverrides.context.js";
2
2
  import { UIConfig } from "../../../../config/uiConfig.context.js";
3
- import { FieldController } from "../../shared/form.binding.js";
4
3
  import { FormField } from "../../FormField/FormField.js";
5
4
  import { Calendar } from "../shared/Calendar.js";
6
5
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
@@ -13,18 +12,20 @@ import { getStaticCalendarDateSegments, getStaticDateTimeFocusTarget } from "../
13
12
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
14
13
  import { InputFrame } from "../../Skeleton/InputFrame.js";
15
14
  import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
15
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
16
16
  import { jsx, jsxs } from "react/jsx-runtime";
17
17
  import { clsx } from "clsx";
18
18
  import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
19
19
  import { useDatePicker, useLocale } from "react-aria";
20
20
  import { mergeRefs } from "@react-aria/utils";
21
+ import { Controller } from "react-hook-form";
21
22
  import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
22
23
  import { DateTime } from "luxon";
23
24
  import { useCalendarState, useDatePickerState } from "react-stately";
24
25
  //#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
25
26
  var DatePickerBase = (props) => {
26
27
  const ui = UIConfig.useConfig();
27
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as: asProp, hideLabel: hideLabelProp, variant: variantProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconButtonComponent: todayIconButtonComponentProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, shouldUpdateDateOnMonthYearChange: shouldUpdateDateOnMonthYearChangeProp, granularity: granularityProp, autoFixYear: autoFixYearProp, format, ...rest } = props;
28
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as: asProp, hideLabel: hideLabelProp, variant: variantProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconButtonComponent: todayIconButtonComponentProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, shouldUpdateDateOnMonthYearChange: shouldUpdateDateOnMonthYearChangeProp, granularity: granularityProp, autoFixYear: autoFixYearProp, fireBlurOnChange: fireBlurOnChangeProp, format, ...rest } = props;
28
29
  const as = asProp ?? ui.input.as;
29
30
  const hideLabel = hideLabelProp ?? ui.input.hideLabel;
30
31
  const variant = variantProp ?? ui.input.variant;
@@ -39,6 +40,7 @@ var DatePickerBase = (props) => {
39
40
  const shouldUpdateDateOnMonthYearChange = shouldUpdateDateOnMonthYearChangeProp ?? ui.dateInput.shouldUpdateDateOnMonthYearChange;
40
41
  const granularity = granularityProp ?? ui.dateInput.granularity;
41
42
  const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
43
+ const fireBlurOnChange = fireBlurOnChangeProp ?? ui.dateInput.fireBlurOnChange;
42
44
  const timeZone = ui.dateInput.timeZone;
43
45
  let effectiveTimeZone = getLocalTimeZone();
44
46
  if (timeZone !== "clientLocal") effectiveTimeZone = timeZone;
@@ -76,6 +78,7 @@ var DatePickerBase = (props) => {
76
78
  const handleBlur = (val) => {
77
79
  onBlur?.({ target: { value: val } });
78
80
  };
81
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
79
82
  const normalizedValue = value ?? null;
80
83
  const dialogState = useDatePickerState({
81
84
  ...rest,
@@ -96,6 +99,7 @@ var DatePickerBase = (props) => {
96
99
  }
97
100
  onChange?.(normalizedValue_0);
98
101
  dialogState.setValue(normalizedValue_0);
102
+ if (fireBlurOnChange) debouncedBlur(normalizedValue_0);
99
103
  if (normalizedValue_0) {
100
104
  calendarState.setFocusedDate(normalizedValue_0);
101
105
  return;
@@ -135,6 +139,7 @@ var DatePickerBase = (props) => {
135
139
  const newValue = dialogState.value ? normalizeByGranularity(dialogState.value) : dialogState.value;
136
140
  state.setValue(newValue);
137
141
  state.toggle();
142
+ if (fireBlurOnChange) handleBlur(newValue);
138
143
  };
139
144
  const onMonthYearChange = (selectedDate) => {
140
145
  if (!(shouldUpdateDateOnMonthYearChange || granularity !== "day")) return;
@@ -156,6 +161,7 @@ var DatePickerBase = (props) => {
156
161
  const onInputClear = () => {
157
162
  onChange?.(null);
158
163
  dialogState.setValue(null);
164
+ if (fireBlurOnChange) handleBlur(null);
159
165
  };
160
166
  const syncDialogFromControlledValue = () => {
161
167
  dialogState.setValue(state.value);
@@ -238,6 +244,7 @@ var DatePickerBase = (props) => {
238
244
  dateGranularity: granularity,
239
245
  format,
240
246
  timeZone: effectiveTimeZone,
247
+ fireBlurOnChange,
241
248
  onClear: onInputClear
242
249
  }), (!disableDropdown || disableManualEntry) && state.isOpen && /* @__PURE__ */ jsx(DateTimeDialog, {
243
250
  footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
@@ -384,20 +391,20 @@ var DatePickerInner = ({ fullIso = true, granularity = "day", minValue, maxValue
384
391
  });
385
392
  };
386
393
  var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, renderStaticInput, ...props }) => {
387
- if ("field" in props && props.field) {
388
- const { field, ref, ...innerProps } = props;
389
- const controlWithOptions = field.form;
390
- return /* @__PURE__ */ jsx(FieldController, {
391
- control: field.form,
392
- name: field.name,
393
- render: ({ field: field_0, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerInner, {
394
+ if ("formControl" in props && props.formControl) {
395
+ const { formControl, ref, ...innerProps } = props;
396
+ const controlWithOptions = formControl.control;
397
+ return /* @__PURE__ */ jsx(Controller, {
398
+ control: formControl.control,
399
+ name: formControl.name,
400
+ render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DatePickerInner, {
394
401
  ...innerProps,
395
- ref: mergeRefs(ref, field_0.ref),
396
- value: field_0.value ?? null,
397
- onChange: field_0.onChange,
398
- onBlur: field_0.onBlur,
402
+ ref: mergeRefs(ref, field.ref),
403
+ value: field.value ?? null,
404
+ onChange: field.onChange,
405
+ onBlur: field.onBlur,
399
406
  isDirty,
400
- isDisabled: field_0.disabled || props.isDisabled,
407
+ isDisabled: field.disabled || props.isDisabled,
401
408
  isFormControlDisabled: !!controlWithOptions._options?.disabled,
402
409
  error: props.error ?? error?.message,
403
410
  fullIso,
@@ -1,7 +1,7 @@
1
1
  import { CalendarDate } from '@internationalized/date';
2
2
  import { FocusEvent, Ref } from 'react';
3
3
  import { DateValue } from 'react-aria';
4
- import { FieldValues } from '../../shared/form.binding';
4
+ import { FieldValues } from 'react-hook-form';
5
5
  import { DateRangePickerStateOptions } from 'react-stately';
6
6
  import { DatePickerInputHandle } from '../shared/DatePickerInput';
7
7
  import { DatePickerTodayIcon, DatePickerTodayIconButtonComponent, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
@@ -24,6 +24,7 @@ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Om
24
24
  placeholder?: string;
25
25
  inputClassName?: string;
26
26
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
27
+ fireBlurOnChange?: boolean;
27
28
  allowPartialRange?: boolean;
28
29
  }
29
30
  export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
@@ -2,7 +2,6 @@ import { UIOverrides } from "../../../../config/uiOverrides.context.js";
2
2
  import { Typography } from "../../../text/Typography/Typography.js";
3
3
  import { UIConfig } from "../../../../config/uiConfig.context.js";
4
4
  import "../../../../config/i18n.js";
5
- import { FieldController } from "../../shared/form.binding.js";
6
5
  import { FormField } from "../../FormField/FormField.js";
7
6
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
8
7
  import { datePickerInputContentRowDefinition } from "../shared/datePickerInput.cva.js";
@@ -14,6 +13,7 @@ import { getStaticDateRangeSegments, getStaticDateTimeFocusTarget } from "../sha
14
13
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
15
14
  import { InputFrame } from "../../Skeleton/InputFrame.js";
16
15
  import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
16
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
17
17
  import { RangeCalendar } from "../shared/RangeCalendar.js";
18
18
  import { jsx, jsxs } from "react/jsx-runtime";
19
19
  import { clsx } from "clsx";
@@ -22,6 +22,7 @@ import { Button } from "react-aria-components";
22
22
  import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
23
23
  import { mergeRefs } from "@react-aria/utils";
24
24
  import { useTranslation } from "react-i18next";
25
+ import { Controller } from "react-hook-form";
25
26
  import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
26
27
  import { DateTime } from "luxon";
27
28
  import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
@@ -29,7 +30,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
29
30
  var DateRangePickerBase = (props) => {
30
31
  const ui = UIConfig.useConfig();
31
32
  const { t } = useTranslation();
32
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel: hideLabelProp, variant: variantProp, as: asProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconButtonComponent: todayIconButtonComponentProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, autoFixYear: autoFixYearProp, allowPartialRange: allowPartialRangeProp, minValue, maxValue, ...rest } = props;
33
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel: hideLabelProp, variant: variantProp, as: asProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconButtonComponent: todayIconButtonComponentProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, autoFixYear: autoFixYearProp, fireBlurOnChange: fireBlurOnChangeProp, allowPartialRange: allowPartialRangeProp, minValue, maxValue, ...rest } = props;
33
34
  const hideLabel = hideLabelProp ?? ui.input.hideLabel;
34
35
  const variant = variantProp ?? ui.input.variant;
35
36
  const as = asProp ?? ui.input.as;
@@ -42,6 +43,7 @@ var DateRangePickerBase = (props) => {
42
43
  const shouldForceLeadingZeros = shouldForceLeadingZerosProp ?? ui.dateInput.shouldForceLeadingZeros;
43
44
  const disableManualEntry = disableManualEntryProp ?? ui.dateInput.disableManualEntry;
44
45
  const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
46
+ const fireBlurOnChange = fireBlurOnChangeProp ?? ui.dateInput.fireBlurOnChange;
45
47
  const allowPartialRange = allowPartialRangeProp ?? ui.dateInput.allowPartialRange;
46
48
  const timeZone = ui.dateInput.timeZone;
47
49
  let effectiveTimeZone = getLocalTimeZone();
@@ -75,6 +77,7 @@ var DateRangePickerBase = (props) => {
75
77
  onChange?.(newValue);
76
78
  if (isInvalidRange) return;
77
79
  handleCalendarStatesChange(newValue);
80
+ if (fireBlurOnChange) debouncedBlur(newValue);
78
81
  },
79
82
  shouldCloseOnSelect: false
80
83
  });
@@ -102,6 +105,7 @@ var DateRangePickerBase = (props) => {
102
105
  if (partialRange.start && partialRange.end) return;
103
106
  const newValue_0 = partialRange.start || partialRange.end ? partialRange : null;
104
107
  onChange?.(newValue_0);
108
+ if (fireBlurOnChange) debouncedBlur(newValue_0);
105
109
  };
106
110
  const { locale } = useLocale$1();
107
111
  useImperativeHandle(ref, () => ({
@@ -113,6 +117,7 @@ var DateRangePickerBase = (props) => {
113
117
  const handleBlur = (newValue_1) => {
114
118
  onBlur?.({ target: { value: newValue_1 } });
115
119
  };
120
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
116
121
  const formFieldProps = {
117
122
  error: error || validationRangeError,
118
123
  label,
@@ -424,6 +429,7 @@ var DateRangePickerBase = (props) => {
424
429
  }
425
430
  }
426
431
  state.toggle();
432
+ if (fireBlurOnChange) handleBlur(valueToApply);
427
433
  };
428
434
  const onTodayPress = () => {
429
435
  const todayDate = today(effectiveTimeZone);
@@ -451,6 +457,7 @@ var DateRangePickerBase = (props) => {
451
457
  isSelecting: false
452
458
  });
453
459
  setHoverDate(null);
460
+ if (fireBlurOnChange) handleBlur(null);
454
461
  };
455
462
  const syncSelectionFromControlledValue = () => {
456
463
  const currentValue = state.value;
@@ -661,6 +668,7 @@ var DateRangePickerBase = (props) => {
661
668
  className: inputClassName,
662
669
  onOpenDropdown,
663
670
  timeZone: effectiveTimeZone,
671
+ fireBlurOnChange,
664
672
  onClear: onInputClear
665
673
  }), /* @__PURE__ */ jsx(DateTimeDialog, {
666
674
  hideSidebar,
@@ -847,20 +855,20 @@ var DateRangePickerInner = ({ fullIso = true, minValue, maxValue, renderStaticIn
847
855
  });
848
856
  };
849
857
  var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...props }) => {
850
- if ("field" in props && props.field) {
851
- const { field, ref, ...innerProps } = props;
852
- const controlWithOptions = field.form;
853
- return /* @__PURE__ */ jsx(FieldController, {
854
- control: field.form,
855
- name: field.name,
856
- render: ({ field: field_0, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerInner, {
858
+ if ("formControl" in props && props.formControl) {
859
+ const { formControl, ref, ...innerProps } = props;
860
+ const controlWithOptions = formControl.control;
861
+ return /* @__PURE__ */ jsx(Controller, {
862
+ control: formControl.control,
863
+ name: formControl.name,
864
+ render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateRangePickerInner, {
857
865
  ...innerProps,
858
- ref: mergeRefs(ref, field_0.ref),
859
- value: field_0.value ?? null,
860
- onChange: field_0.onChange,
861
- onBlur: field_0.onBlur,
866
+ ref: mergeRefs(ref, field.ref),
867
+ value: field.value ?? null,
868
+ onChange: field.onChange,
869
+ onBlur: field.onBlur,
862
870
  isDirty,
863
- isDisabled: field_0.disabled || props.isDisabled,
871
+ isDisabled: field.disabled || props.isDisabled,
864
872
  isFormControlDisabled: !!controlWithOptions._options?.disabled,
865
873
  error: props.error ?? error?.message,
866
874
  fullIso,
@@ -1,6 +1,6 @@
1
1
  import { FocusEvent, Ref } from 'react';
2
2
  import { DateValue } from 'react-aria';
3
- import { FieldValues } from '../../shared/form.binding';
3
+ import { FieldValues } from 'react-hook-form';
4
4
  import { DatePickerStateOptions } from 'react-stately';
5
5
  import { DatePickerInputHandle } from '../shared/DatePickerInput';
6
6
  import { DatePickerTodayIcon, DatePickerTodayIconButtonComponent, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
@@ -27,6 +27,7 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
27
27
  timeZone?: string;
28
28
  format?: string;
29
29
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
30
+ fireBlurOnChange?: boolean;
30
31
  }
31
32
  export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
32
33
  value?: string | null;