@povio/ui 3.3.0 → 3.4.0-rc.2

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 (82) 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 +15 -21
  7. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +1 -2
  8. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +15 -22
  9. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +1 -2
  10. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +19 -24
  11. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -2
  12. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +276 -294
  13. package/dist/components/inputs/DateTime/shared/DateField.d.ts +2 -1
  14. package/dist/components/inputs/DateTime/shared/DateField.js +2 -2
  15. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +1 -2
  16. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +4 -12
  17. package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
  18. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +45 -48
  19. package/dist/components/inputs/File/FileUpload.d.ts +1 -1
  20. package/dist/components/inputs/File/FileUpload.js +17 -17
  21. package/dist/components/inputs/File/InputUpload.d.ts +1 -1
  22. package/dist/components/inputs/File/InputUpload.js +17 -17
  23. package/dist/components/inputs/File/fileUpload.types.d.ts +1 -1
  24. package/dist/components/inputs/File/inputUpload.types.d.ts +1 -1
  25. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -1
  26. package/dist/components/inputs/Input/NumberInput/NumberInput.js +19 -19
  27. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +1 -1
  28. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +18 -18
  29. package/dist/components/inputs/Input/PasswordInput/PasswordInput.d.ts +1 -1
  30. package/dist/components/inputs/Input/TextArea/TextArea.d.ts +1 -1
  31. package/dist/components/inputs/Input/TextArea/TextArea.js +18 -18
  32. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +2 -2
  33. package/dist/components/inputs/Input/TextInput/TextInput.js +36 -38
  34. package/dist/components/inputs/Inputs/Form.d.ts +4 -4
  35. package/dist/components/inputs/Inputs/InputItem.d.ts +22 -22
  36. package/dist/components/inputs/Inputs/InputItem.js +35 -36
  37. package/dist/components/inputs/Inputs/Inputs.d.ts +2 -2
  38. package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -2
  39. package/dist/components/inputs/RadioGroup/RadioGroup.js +107 -111
  40. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -1
  41. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +13 -13
  42. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  43. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +19 -19
  44. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -1
  45. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -1
  46. package/dist/components/inputs/Selection/Select/QuerySelect.js +19 -19
  47. package/dist/components/inputs/Selection/Select/Select.d.ts +1 -1
  48. package/dist/components/inputs/Selection/Select/Select.js +19 -19
  49. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +0 -1
  50. package/dist/components/inputs/Selection/shared/SelectBase.js +34 -37
  51. package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
  52. package/dist/components/inputs/Selection/shared/select.context.js +4 -8
  53. package/dist/components/inputs/Selection/shared/select.types.d.ts +1 -1
  54. package/dist/components/inputs/Skeleton/InputFrame.js +5 -2
  55. package/dist/components/inputs/Slider/Slider.d.ts +1 -1
  56. package/dist/components/inputs/Slider/Slider.js +18 -18
  57. package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -1
  58. package/dist/components/inputs/TextEditor/TextEditor.js +18 -18
  59. package/dist/components/inputs/Toggle/Toggle.d.ts +1 -2
  60. package/dist/components/inputs/Toggle/Toggle.js +59 -63
  61. package/dist/components/inputs/shared/InputClear.js +40 -25
  62. package/dist/components/inputs/shared/form.binding.d.ts +27 -0
  63. package/dist/components/inputs/shared/form.binding.js +57 -0
  64. package/dist/components/inputs/shared/form.types.d.ts +9 -8
  65. package/dist/components/inputs/shared/form.types.js +8 -0
  66. package/dist/components/segment/Segment.d.ts +1 -1
  67. package/dist/components/segment/Segment.js +17 -17
  68. package/dist/components/segment/segment.types.d.ts +1 -1
  69. package/dist/config/uiConfig.context.d.ts +5 -5
  70. package/dist/config/uiConfig.context.js +3 -12
  71. package/dist/helpers/dynamicColumns.d.ts +1 -1
  72. package/dist/helpers/dynamicInputs.d.ts +7 -7
  73. package/dist/hooks/useAutosave.d.ts +4 -4
  74. package/dist/hooks/useAutosave.js +64 -49
  75. package/dist/hooks/useForm.d.ts +39 -15
  76. package/dist/hooks/useForm.js +96 -43
  77. package/dist/hooks/useFormAutosave.d.ts +8 -9
  78. package/dist/hooks/useFormAutosave.js +23 -9
  79. package/dist/index.d.ts +2 -2
  80. package/dist/index.js +3 -3
  81. package/package.json +2 -3
  82. 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",
@@ -126,10 +122,10 @@ var DateTimePickerBase = (props) => {
126
122
  labelProps
127
123
  };
128
124
  const onApply = () => {
129
- const newValue = dialogState.value;
130
- state.setValue(newValue);
131
- state.toggle();
132
- if (fireBlurOnChange) handleBlur(newValue);
125
+ const newValue = dialogState.value ?? null;
126
+ onChange?.(newValue);
127
+ dialogState.setValue(newValue);
128
+ state.close();
133
129
  };
134
130
  const onMonthYearChange = (selectedDate) => {
135
131
  if (!shouldUpdateDateOnMonthYearChange) return;
@@ -154,7 +150,6 @@ var DateTimePickerBase = (props) => {
154
150
  const onInputClear = () => {
155
151
  onChange?.(null);
156
152
  dialogState.setValue(null);
157
- if (fireBlurOnChange) handleBlur(null);
158
153
  };
159
154
  const syncDialogFromControlledValue = () => {
160
155
  dialogState.setValue(state.value);
@@ -224,7 +219,6 @@ var DateTimePickerBase = (props) => {
224
219
  timeZone: effectiveTimeZone,
225
220
  isTimeOptional,
226
221
  format,
227
- fireBlurOnChange,
228
222
  onClear: onInputClear
229
223
  }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
230
224
  footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
@@ -314,6 +308,7 @@ var DateTimePickerInner = ({ fullIso: _fullIso = true, renderStaticInput, isForm
314
308
  });
315
309
  return /* @__PURE__ */ jsx(InputFrame, {
316
310
  ...props,
311
+ onClear: () => props.onChange?.(null),
317
312
  isDisabled,
318
313
  className: clsx("group relative inline-flex w-full flex-col text-left", props.className),
319
314
  inputClassName: clsx(props.shouldShrinkInput ? "min-w-0" : "min-w-input-width-min-width", props.inputClassName),
@@ -356,20 +351,20 @@ var DateTimePickerInner = ({ fullIso: _fullIso = true, renderStaticInput, isForm
356
351
  });
357
352
  };
358
353
  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, {
354
+ if ("field" in props && props.field) {
355
+ const { field, ref, ...innerProps } = props;
356
+ const controlWithOptions = field.form;
357
+ return /* @__PURE__ */ jsx(FieldController, {
358
+ control: field.form,
359
+ name: field.name,
360
+ render: ({ field: field_0, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerInner, {
366
361
  ...innerProps,
367
- ref: mergeRefs(ref, field.ref),
368
- value: field.value ?? null,
369
- onChange: field.onChange,
370
- onBlur: field.onBlur,
362
+ ref: mergeRefs(ref, field_0.ref),
363
+ value: field_0.value ?? null,
364
+ onChange: (value) => field_0.onChange(value ?? null),
365
+ onBlur: field_0.onBlur,
371
366
  isDirty,
372
- isDisabled: field.disabled || props.isDisabled,
367
+ isDisabled: field_0.disabled || props.isDisabled,
373
368
  isFormControlDisabled: !!controlWithOptions._options?.disabled,
374
369
  error: props.error ?? error?.message,
375
370
  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"> {