@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.
- package/dist/components/inputs/Checkbox/Checkbox.d.ts +1 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +93 -100
- package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +1 -2
- package/dist/components/inputs/Checkbox/CheckboxGroup.js +109 -113
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +14 -21
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +14 -22
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +14 -21
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +275 -294
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +1 -10
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +43 -46
- package/dist/components/inputs/File/FileUpload.d.ts +1 -1
- package/dist/components/inputs/File/FileUpload.js +17 -17
- package/dist/components/inputs/File/InputUpload.d.ts +1 -1
- package/dist/components/inputs/File/InputUpload.js +17 -17
- package/dist/components/inputs/File/fileUpload.types.d.ts +1 -1
- package/dist/components/inputs/File/inputUpload.types.d.ts +1 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +19 -19
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +18 -18
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/inputs/Input/TextArea/TextArea.d.ts +1 -1
- package/dist/components/inputs/Input/TextArea/TextArea.js +18 -18
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +2 -2
- package/dist/components/inputs/Input/TextInput/TextInput.js +36 -38
- package/dist/components/inputs/Inputs/Form.d.ts +4 -4
- package/dist/components/inputs/Inputs/InputItem.d.ts +22 -22
- package/dist/components/inputs/Inputs/InputItem.js +35 -36
- package/dist/components/inputs/Inputs/Inputs.d.ts +2 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.js +107 -111
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +13 -13
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +19 -19
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/QuerySelect.js +19 -19
- package/dist/components/inputs/Selection/Select/Select.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/Select.js +19 -19
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +0 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +34 -37
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/select.context.js +4 -8
- package/dist/components/inputs/Selection/shared/select.types.d.ts +1 -1
- package/dist/components/inputs/Slider/Slider.d.ts +1 -1
- package/dist/components/inputs/Slider/Slider.js +18 -18
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +18 -18
- package/dist/components/inputs/Toggle/Toggle.d.ts +1 -2
- package/dist/components/inputs/Toggle/Toggle.js +59 -63
- package/dist/components/inputs/shared/form.binding.d.ts +27 -0
- package/dist/components/inputs/shared/form.binding.js +57 -0
- package/dist/components/inputs/shared/form.types.d.ts +9 -8
- package/dist/components/inputs/shared/form.types.js +8 -0
- package/dist/components/segment/Segment.d.ts +1 -1
- package/dist/components/segment/Segment.js +17 -17
- package/dist/components/segment/segment.types.d.ts +1 -1
- package/dist/config/uiConfig.context.d.ts +5 -5
- package/dist/config/uiConfig.context.js +3 -12
- package/dist/helpers/dynamicColumns.d.ts +1 -1
- package/dist/helpers/dynamicInputs.d.ts +7 -7
- package/dist/hooks/useAutosave.d.ts +4 -4
- package/dist/hooks/useAutosave.js +64 -49
- package/dist/hooks/useForm.d.ts +39 -15
- package/dist/hooks/useForm.js +96 -43
- package/dist/hooks/useFormAutosave.d.ts +8 -9
- package/dist/hooks/useFormAutosave.js +23 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/package.json +2 -3
- 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,
|
|
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 ("
|
|
360
|
-
const {
|
|
361
|
-
const controlWithOptions =
|
|
362
|
-
return /* @__PURE__ */ jsx(
|
|
363
|
-
control:
|
|
364
|
-
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,
|
|
368
|
-
value:
|
|
369
|
-
onChange:
|
|
370
|
-
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:
|
|
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 '
|
|
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"> {
|