@povio/ui 3.3.0 → 3.4.0-rc.1

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 +1 -2
  2. package/dist/components/inputs/Checkbox/Checkbox.js +93 -100
  3. package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +1 -2
  4. package/dist/components/inputs/Checkbox/CheckboxGroup.js +109 -113
  5. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +1 -2
  6. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +14 -21
  7. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +1 -2
  8. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +14 -22
  9. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +1 -2
  10. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +14 -21
  11. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -2
  12. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +275 -294
  13. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +1 -2
  14. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +1 -10
  15. package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
  16. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +43 -46
  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 +36 -38
  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 +35 -36
  35. package/dist/components/inputs/Inputs/Inputs.d.ts +2 -2
  36. package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -2
  37. package/dist/components/inputs/RadioGroup/RadioGroup.js +107 -111
  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 +0 -1
  48. package/dist/components/inputs/Selection/shared/SelectBase.js +34 -37
  49. package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
  50. package/dist/components/inputs/Selection/shared/select.context.js +4 -8
  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 +1 -2
  57. package/dist/components/inputs/Toggle/Toggle.js +59 -63
  58. package/dist/components/inputs/shared/form.binding.d.ts +27 -0
  59. package/dist/components/inputs/shared/form.binding.js +57 -0
  60. package/dist/components/inputs/shared/form.types.d.ts +9 -8
  61. package/dist/components/inputs/shared/form.types.js +8 -0
  62. package/dist/components/segment/Segment.d.ts +1 -1
  63. package/dist/components/segment/Segment.js +17 -17
  64. package/dist/components/segment/segment.types.d.ts +1 -1
  65. package/dist/config/uiConfig.context.d.ts +5 -5
  66. package/dist/config/uiConfig.context.js +3 -12
  67. package/dist/helpers/dynamicColumns.d.ts +1 -1
  68. package/dist/helpers/dynamicInputs.d.ts +7 -7
  69. package/dist/hooks/useAutosave.d.ts +4 -4
  70. package/dist/hooks/useAutosave.js +64 -49
  71. package/dist/hooks/useForm.d.ts +39 -15
  72. package/dist/hooks/useForm.js +96 -43
  73. package/dist/hooks/useFormAutosave.d.ts +8 -9
  74. package/dist/hooks/useFormAutosave.js +23 -9
  75. package/dist/index.d.ts +2 -2
  76. package/dist/index.js +3 -3
  77. package/package.json +2 -3
  78. package/dist/hooks/useAutosave.spec.d.ts +0 -1
@@ -1,5 +1,6 @@
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";
3
4
  import { FormField } from "../../FormField/FormField.js";
4
5
  import { Calendar } from "../shared/Calendar.js";
5
6
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
@@ -12,19 +13,17 @@ import { getStaticCalendarDateTimeSegments, getStaticDateTimeFocusTarget } from
12
13
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
13
14
  import { InputFrame } from "../../Skeleton/InputFrame.js";
14
15
  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 { 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";
22
21
  import { Time, createCalendar, getLocalTimeZone, toCalendarDate, toCalendarDateTime, today } from "@internationalized/date";
23
22
  import { useCalendarState, useDatePickerState } from "react-stately";
24
23
  //#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
25
24
  var DateTimePickerBase = (props) => {
26
25
  const ui = UIConfig.useConfig();
27
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, isTimeOptional, placeholder, inputClassName, shouldShrinkInput, hideLabel: hideLabelProp, variant: variantProp, as: asProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconButtonComponent: todayIconButtonComponentProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, shouldUpdateDateOnMonthYearChange: shouldUpdateDateOnMonthYearChangeProp, timeZone: timeZoneProp, autoFixYear: autoFixYearProp, fireBlurOnChange: fireBlurOnChangeProp, format, setDateValueOnDateSelection: setDateValueOnDateSelectionProp, ...rest } = props;
26
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, isTimeOptional, placeholder, inputClassName, shouldShrinkInput, hideLabel: hideLabelProp, variant: variantProp, as: asProp, size: sizeProp, isClearable: isClearableProp, todayIcon: todayIconProp, todayIconButtonSize: todayIconButtonSizeProp, todayIconButtonComponent: todayIconButtonComponentProp, todayIconPlacement: todayIconPlacementProp, shouldForceLeadingZeros: shouldForceLeadingZerosProp, disableManualEntry: disableManualEntryProp, shouldUpdateDateOnMonthYearChange: shouldUpdateDateOnMonthYearChangeProp, timeZone: timeZoneProp, autoFixYear: autoFixYearProp, format, setDateValueOnDateSelection: setDateValueOnDateSelectionProp, ...rest } = props;
28
27
  const hideLabel = hideLabelProp ?? ui.input.hideLabel;
29
28
  const variant = variantProp ?? ui.input.variant;
30
29
  const as = asProp ?? ui.input.as;
@@ -38,7 +37,6 @@ var DateTimePickerBase = (props) => {
38
37
  const disableManualEntry = disableManualEntryProp ?? ui.dateInput.disableManualEntry;
39
38
  const shouldUpdateDateOnMonthYearChange = shouldUpdateDateOnMonthYearChangeProp ?? ui.dateInput.shouldUpdateDateOnMonthYearChange;
40
39
  const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
41
- const fireBlurOnChange = fireBlurOnChangeProp ?? ui.dateInput.fireBlurOnChange;
42
40
  const setDateValueOnDateSelection = setDateValueOnDateSelectionProp ?? ui.dateInput.setDateValueOnDateSelection;
43
41
  const timeZone = timeZoneProp ?? ui.dateInput.timeZone;
44
42
  let effectiveTimeZone = getLocalTimeZone();
@@ -69,7 +67,6 @@ var DateTimePickerBase = (props) => {
69
67
  const handleBlur = (val) => {
70
68
  onBlur?.({ target: { value: val } });
71
69
  };
72
- const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
73
70
  const normalizedValue = value ?? null;
74
71
  const dialogState = useDatePickerState({
75
72
  ...rest,
@@ -90,7 +87,6 @@ var DateTimePickerBase = (props) => {
90
87
  onChange?.(val_0);
91
88
  dialogState.setValue(val_0);
92
89
  calendarState.setFocusedDate(val_0 || today(effectiveTimeZone));
93
- if (fireBlurOnChange) debouncedBlur(val_0);
94
90
  },
95
91
  shouldCloseOnSelect: false,
96
92
  granularity: "minute",
@@ -129,7 +125,6 @@ var DateTimePickerBase = (props) => {
129
125
  const newValue = dialogState.value;
130
126
  state.setValue(newValue);
131
127
  state.toggle();
132
- if (fireBlurOnChange) handleBlur(newValue);
133
128
  };
134
129
  const onMonthYearChange = (selectedDate) => {
135
130
  if (!shouldUpdateDateOnMonthYearChange) return;
@@ -154,7 +149,6 @@ var DateTimePickerBase = (props) => {
154
149
  const onInputClear = () => {
155
150
  onChange?.(null);
156
151
  dialogState.setValue(null);
157
- if (fireBlurOnChange) handleBlur(null);
158
152
  };
159
153
  const syncDialogFromControlledValue = () => {
160
154
  dialogState.setValue(state.value);
@@ -224,7 +218,6 @@ var DateTimePickerBase = (props) => {
224
218
  timeZone: effectiveTimeZone,
225
219
  isTimeOptional,
226
220
  format,
227
- fireBlurOnChange,
228
221
  onClear: onInputClear
229
222
  }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
230
223
  footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
@@ -356,20 +349,20 @@ var DateTimePickerInner = ({ fullIso: _fullIso = true, renderStaticInput, isForm
356
349
  });
357
350
  };
358
351
  var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
359
- if ("formControl" in props && props.formControl) {
360
- const { formControl, ref, ...innerProps } = props;
361
- const controlWithOptions = formControl.control;
362
- return /* @__PURE__ */ jsx(Controller, {
363
- control: formControl.control,
364
- name: formControl.name,
365
- render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerInner, {
352
+ if ("field" in props && props.field) {
353
+ const { field, ref, ...innerProps } = props;
354
+ const controlWithOptions = field.form;
355
+ return /* @__PURE__ */ jsx(FieldController, {
356
+ control: field.form,
357
+ name: field.name,
358
+ render: ({ field: field_0, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerInner, {
366
359
  ...innerProps,
367
- ref: mergeRefs(ref, field.ref),
368
- value: field.value ?? null,
369
- onChange: field.onChange,
370
- onBlur: field.onBlur,
360
+ ref: mergeRefs(ref, field_0.ref),
361
+ value: field_0.value ?? null,
362
+ onChange: field_0.onChange,
363
+ onBlur: field_0.onBlur,
371
364
  isDirty,
372
- isDisabled: field.disabled || props.isDisabled,
365
+ isDisabled: field_0.disabled || props.isDisabled,
373
366
  isFormControlDisabled: !!controlWithOptions._options?.disabled,
374
367
  error: props.error ?? error?.message,
375
368
  fullIso,
@@ -1,6 +1,6 @@
1
1
  import { Ref, FocusEvent } from 'react';
2
2
  import { AriaTimeFieldProps, TimeValue } from 'react-aria';
3
- import { FieldValues } from 'react-hook-form';
3
+ import { FieldValues } from '../../shared/form.binding';
4
4
  import { FormFieldProps } from '../../FormField/FormField';
5
5
  import { ControlProps } from '../../shared/form.types';
6
6
  import { InputVariantProps } from '../../shared/input.cva';
@@ -14,7 +14,6 @@ interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Ar
14
14
  placeholder?: string;
15
15
  inputClassName?: string;
16
16
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
17
- fireBlurOnChange?: boolean;
18
17
  shouldForceLeadingZeros?: boolean;
19
18
  }
20
19
  export interface TimePickerProps extends Omit<TimePickerBaseProps, "value" | "onChange"> {