@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 { FormField } from "../../FormField/FormField.js";
5
4
  import { Calendar } from "../shared/Calendar.js";
6
5
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
@@ -13,17 +12,19 @@ import { getStaticCalendarDateTimeSegments, 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 { 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 { Time, createCalendar, getLocalTimeZone, toCalendarDate, toCalendarDateTime, today } from "@internationalized/date";
22
23
  import { useCalendarState, useDatePickerState } from "react-stately";
23
24
  //#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
24
25
  var DateTimePickerBase = (props) => {
25
26
  const ui = UIConfig.useConfig();
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;
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;
27
28
  const hideLabel = hideLabelProp ?? ui.input.hideLabel;
28
29
  const variant = variantProp ?? ui.input.variant;
29
30
  const as = asProp ?? ui.input.as;
@@ -37,6 +38,7 @@ var DateTimePickerBase = (props) => {
37
38
  const disableManualEntry = disableManualEntryProp ?? ui.dateInput.disableManualEntry;
38
39
  const shouldUpdateDateOnMonthYearChange = shouldUpdateDateOnMonthYearChangeProp ?? ui.dateInput.shouldUpdateDateOnMonthYearChange;
39
40
  const autoFixYear = autoFixYearProp ?? ui.dateInput.autoFixYear;
41
+ const fireBlurOnChange = fireBlurOnChangeProp ?? ui.dateInput.fireBlurOnChange;
40
42
  const setDateValueOnDateSelection = setDateValueOnDateSelectionProp ?? ui.dateInput.setDateValueOnDateSelection;
41
43
  const timeZone = timeZoneProp ?? ui.dateInput.timeZone;
42
44
  let effectiveTimeZone = getLocalTimeZone();
@@ -67,6 +69,7 @@ var DateTimePickerBase = (props) => {
67
69
  const handleBlur = (val) => {
68
70
  onBlur?.({ target: { value: val } });
69
71
  };
72
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
70
73
  const normalizedValue = value ?? null;
71
74
  const dialogState = useDatePickerState({
72
75
  ...rest,
@@ -87,6 +90,7 @@ var DateTimePickerBase = (props) => {
87
90
  onChange?.(val_0);
88
91
  dialogState.setValue(val_0);
89
92
  calendarState.setFocusedDate(val_0 || today(effectiveTimeZone));
93
+ if (fireBlurOnChange) debouncedBlur(val_0);
90
94
  },
91
95
  shouldCloseOnSelect: false,
92
96
  granularity: "minute",
@@ -125,6 +129,7 @@ var DateTimePickerBase = (props) => {
125
129
  const newValue = dialogState.value;
126
130
  state.setValue(newValue);
127
131
  state.toggle();
132
+ if (fireBlurOnChange) handleBlur(newValue);
128
133
  };
129
134
  const onMonthYearChange = (selectedDate) => {
130
135
  if (!shouldUpdateDateOnMonthYearChange) return;
@@ -149,6 +154,7 @@ var DateTimePickerBase = (props) => {
149
154
  const onInputClear = () => {
150
155
  onChange?.(null);
151
156
  dialogState.setValue(null);
157
+ if (fireBlurOnChange) handleBlur(null);
152
158
  };
153
159
  const syncDialogFromControlledValue = () => {
154
160
  dialogState.setValue(state.value);
@@ -218,6 +224,7 @@ var DateTimePickerBase = (props) => {
218
224
  timeZone: effectiveTimeZone,
219
225
  isTimeOptional,
220
226
  format,
227
+ fireBlurOnChange,
221
228
  onClear: onInputClear
222
229
  }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
223
230
  footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
@@ -349,20 +356,20 @@ var DateTimePickerInner = ({ fullIso: _fullIso = true, renderStaticInput, isForm
349
356
  });
350
357
  };
351
358
  var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
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, {
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, {
359
366
  ...innerProps,
360
- ref: mergeRefs(ref, field_0.ref),
361
- value: field_0.value ?? null,
362
- onChange: field_0.onChange,
363
- onBlur: field_0.onBlur,
367
+ ref: mergeRefs(ref, field.ref),
368
+ value: field.value ?? null,
369
+ onChange: field.onChange,
370
+ onBlur: field.onBlur,
364
371
  isDirty,
365
- isDisabled: field_0.disabled || props.isDisabled,
372
+ isDisabled: field.disabled || props.isDisabled,
366
373
  isFormControlDisabled: !!controlWithOptions._options?.disabled,
367
374
  error: props.error ?? error?.message,
368
375
  fullIso,
@@ -1,6 +1,6 @@
1
1
  import { Ref, FocusEvent } from 'react';
2
2
  import { AriaTimeFieldProps, TimeValue } from 'react-aria';
3
- import { FieldValues } from '../../shared/form.binding';
3
+ import { FieldValues } from 'react-hook-form';
4
4
  import { FormFieldProps } from '../../FormField/FormField';
5
5
  import { ControlProps } from '../../shared/form.types';
6
6
  import { InputVariantProps } from '../../shared/input.cva';
@@ -14,6 +14,7 @@ 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;
17
18
  shouldForceLeadingZeros?: boolean;
18
19
  }
19
20
  export interface TimePickerProps extends Omit<TimePickerBaseProps, "value" | "onChange"> {