@povio/ui 3.3.0 → 3.4.0-rc.10
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/assets/locales/en/translation.json.d.ts +158 -0
- package/dist/assets/locales/sl/translation.json.d.ts +154 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +7 -7
- package/dist/components/Menu/MenuDesktop.js +1 -1
- package/dist/components/Menu/MenuItem.js +4 -4
- package/dist/components/Menu/MenuMobile.js +5 -5
- package/dist/components/Menu/MenuPopover.js +2 -2
- package/dist/components/buttons/Button/Button.js +1 -1
- package/dist/components/buttons/PillButton/PillButton.js +4 -4
- package/dist/components/buttons/PillButton/pillButton.cva.d.ts +1 -1
- package/dist/components/buttons/SplitButton/SplitButton.js +3 -3
- package/dist/components/buttons/shared/ButtonContent.js +2 -2
- package/dist/components/buttons/shared/buttonContent.cva.d.ts +1 -1
- package/dist/components/inputs/Checkbox/Checkbox.d.ts +1 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +95 -102
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +2 -3
- package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +1 -2
- package/dist/components/inputs/Checkbox/CheckboxGroup.js +111 -115
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +2 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +17 -22
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +17 -23
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +21 -25
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +225 -238
- package/dist/components/inputs/DateTime/shared/Calendar.js +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +7 -10
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +8 -12
- package/dist/components/inputs/DateTime/shared/DateField.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/DateField.js +4 -4
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +2 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +8 -16
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +3 -3
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +2 -2
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +1 -1
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +2 -2
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +2 -2
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +4 -5
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +10 -11
- package/dist/components/inputs/DateTime/shared/YearPicker.js +2 -2
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +46 -1
- package/dist/components/inputs/DateTime/shared/useFirefoxDateSegmentSelectionGuard.js +1 -1
- package/dist/components/inputs/File/FileUpload.d.ts +1 -1
- package/dist/components/inputs/File/FileUpload.js +20 -20
- package/dist/components/inputs/File/InputUpload.d.ts +1 -1
- package/dist/components/inputs/File/InputUpload.js +19 -19
- 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/File/shared/FileCard.js +1 -1
- package/dist/components/inputs/File/shared/FileCardList.js +1 -1
- package/dist/components/inputs/File/shared/FileUploadContent.js +1 -1
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +3 -3
- package/dist/components/inputs/File/shared/FileUploadContentError.js +5 -6
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +5 -6
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +4 -5
- package/dist/components/inputs/File/shared/InputUploadContent.js +4 -4
- package/dist/components/inputs/File/shared/InputUploadFilled.js +3 -3
- package/dist/components/inputs/FormField/FormFieldError.js +1 -1
- package/dist/components/inputs/FormField/FormFieldHeader.js +4 -4
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +3 -3
- package/dist/components/inputs/FormField/FormFieldHelper.js +1 -1
- package/dist/components/inputs/FormField/FormFieldLabel.js +2 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +109 -107
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +2 -1
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +265 -254
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +2 -1
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +25 -24
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +3 -4
- package/dist/components/inputs/Input/TextArea/TextArea.d.ts +2 -1
- package/dist/components/inputs/Input/TextArea/TextArea.js +118 -117
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +2 -2
- package/dist/components/inputs/Input/TextInput/TextInput.js +129 -129
- package/dist/components/inputs/Input/shared/InputContent.d.ts +2 -1
- package/dist/components/inputs/Input/shared/InputContent.js +50 -48
- package/dist/components/inputs/Inputs/Form.d.ts +4 -4
- package/dist/components/inputs/Inputs/Form.js +1 -1
- package/dist/components/inputs/Inputs/InputItem.d.ts +22 -22
- package/dist/components/inputs/Inputs/InputItem.js +36 -37
- 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 +109 -113
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +16 -16
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +20 -20
- 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 +20 -20
- package/dist/components/inputs/Selection/Select/Select.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/Select.js +23 -23
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +34 -37
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +58 -56
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +57 -56
- package/dist/components/inputs/Selection/shared/SelectListBox.js +1 -1
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +1 -1
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -4
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.js +3 -3
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/select.context.js +5 -9
- package/dist/components/inputs/Selection/shared/select.types.d.ts +1 -1
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +1 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +10 -7
- package/dist/components/inputs/Slider/Slider.d.ts +1 -1
- package/dist/components/inputs/Slider/Slider.js +20 -20
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +20 -20
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +2 -2
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +4 -4
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +4 -4
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +5 -8
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +3 -3
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +4 -5
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +4 -5
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +6 -9
- package/dist/components/inputs/Toggle/Toggle.d.ts +1 -2
- package/dist/components/inputs/Toggle/Toggle.js +61 -65
- package/dist/components/inputs/shared/CheckContent.js +1 -1
- package/dist/components/inputs/shared/InputClear.js +45 -28
- package/dist/components/inputs/shared/TooltipWrapper.d.ts +1 -1
- 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/inputs/shared/input.cva.js +1 -1
- package/dist/components/inputs/shared/useStaticInputHandoff.js +64 -38
- package/dist/components/navigation/Accordion/Accordion.js +1 -1
- package/dist/components/navigation/Accordion/AccordionItem.js +3 -3
- package/dist/components/navigation/Stepper/Stepper.js +2 -2
- package/dist/components/navigation/Stepper/StepperItem.js +4 -4
- package/dist/components/overlays/ActionModal/ActionModal.js +1 -1
- package/dist/components/overlays/BottomSheet/BottomSheet.js +3 -3
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +4 -4
- package/dist/components/overlays/Drawer/Drawer.js +2 -2
- package/dist/components/overlays/Modal/Modal.js +3 -3
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +1 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +15 -8
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +1 -1
- package/dist/components/segment/Segment.d.ts +1 -1
- package/dist/components/segment/Segment.js +21 -21
- package/dist/components/segment/SegmentItem.js +1 -1
- package/dist/components/segment/segment.types.d.ts +1 -1
- package/dist/components/shared/pagination/Pagination.js +1 -1
- package/dist/components/shared/pagination/PaginationList.js +6 -9
- package/dist/components/table/ColumnConfig.js +1 -1
- package/dist/components/table/InfiniteTable.js +1 -1
- package/dist/components/table/Table.js +6 -8
- package/dist/components/text/Link/Link.js +1 -1
- package/dist/components/text/Pill/Pill.js +3 -3
- package/dist/components/text/Tag/Tag.js +3 -3
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/link.context.js +1 -1
- package/dist/config/router.context.js +1 -1
- package/dist/config/theme.context.js +1 -1
- package/dist/config/uiConfig.context.d.ts +14 -5
- package/dist/config/uiConfig.context.js +9 -11
- package/dist/config/uiOverrides.context.js +2 -2
- 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/useFilters.js +1 -1
- 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/hooks/useIntersectionObserver.js +1 -1
- package/dist/hooks/useLocalStorage.js +1 -1
- package/dist/hooks/usePagination.js +1 -1
- package/dist/hooks/useScrollableListBox.js +1 -1
- package/dist/hooks/useSorting.js +1 -1
- package/dist/hooks/useStateAndRef.js +1 -1
- package/dist/hooks/useTableColumnConfig.js +1 -1
- package/dist/index.d.ts +1 -263
- package/dist/index.js +11 -71
- package/dist/rhf/Inputs.d.ts +60 -0
- package/dist/rhf/Inputs.js +148 -0
- package/dist/rhf/components.d.ts +80 -0
- package/dist/rhf/components.js +101 -0
- package/dist/rhf/dynamicInputs.d.ts +18 -0
- package/dist/rhf/dynamicInputs.js +5 -0
- package/dist/rhf/fieldAdapter.d.ts +7 -0
- package/dist/rhf/fieldAdapter.js +40 -0
- package/dist/rhf/form.types.d.ts +12 -0
- package/dist/rhf/useAutosave.d.ts +10 -0
- package/dist/rhf/useAutosave.js +71 -0
- package/dist/rhf/useForm.d.ts +18 -0
- package/dist/rhf/useForm.js +48 -0
- package/dist/rhf/useFormAutosave.d.ts +15 -0
- package/dist/rhf/useFormAutosave.js +59 -0
- package/dist/rhf.d.ts +225 -0
- package/dist/tanstack.d.ts +224 -0
- package/dist/tanstack.js +141 -0
- package/package.json +15 -3
- package/dist/assets/icons/Account.d.ts +0 -2
- package/dist/assets/icons/AlignCenter.d.ts +0 -2
- package/dist/assets/icons/AlignCenter.js +0 -30
- package/dist/assets/icons/AlignLeft.d.ts +0 -2
- package/dist/assets/icons/AlignLeft.js +0 -30
- package/dist/assets/icons/AlignLeftRight.d.ts +0 -2
- package/dist/assets/icons/AlignLeftRight.js +0 -30
- package/dist/assets/icons/AlignRight.d.ts +0 -2
- package/dist/assets/icons/AlignRight.js +0 -30
- package/dist/assets/icons/ArrowDropDown.d.ts +0 -2
- package/dist/assets/icons/ArrowDropDown.js +0 -30
- package/dist/assets/icons/ArrowDropUp.d.ts +0 -2
- package/dist/assets/icons/ArrowDropUp.js +0 -30
- package/dist/assets/icons/ArrowLeft.d.ts +0 -2
- package/dist/assets/icons/ArrowLeft.js +0 -30
- package/dist/assets/icons/ArrowRight.d.ts +0 -2
- package/dist/assets/icons/ArrowRight.js +0 -30
- package/dist/assets/icons/Board.d.ts +0 -2
- package/dist/assets/icons/Bold.d.ts +0 -2
- package/dist/assets/icons/Bold.js +0 -30
- package/dist/assets/icons/BulletedList.d.ts +0 -2
- package/dist/assets/icons/BulletedList.js +0 -30
- package/dist/assets/icons/Calendar.d.ts +0 -2
- package/dist/assets/icons/Calendar.js +0 -32
- package/dist/assets/icons/Check.d.ts +0 -2
- package/dist/assets/icons/Check.js +0 -32
- package/dist/assets/icons/CheckCircle.d.ts +0 -2
- package/dist/assets/icons/CheckCircle.js +0 -30
- package/dist/assets/icons/CheckboxCheckmark.d.ts +0 -2
- package/dist/assets/icons/CheckboxCheckmark.js +0 -33
- package/dist/assets/icons/CheckboxIndeterminate.d.ts +0 -2
- package/dist/assets/icons/CheckboxIndeterminate.js +0 -33
- package/dist/assets/icons/ChevronDown.d.ts +0 -2
- package/dist/assets/icons/ChevronDown.js +0 -32
- package/dist/assets/icons/ChevronLeft.d.ts +0 -2
- package/dist/assets/icons/ChevronLeft.js +0 -32
- package/dist/assets/icons/ChevronRight.d.ts +0 -2
- package/dist/assets/icons/ChevronRight.js +0 -32
- package/dist/assets/icons/ChevronUp.d.ts +0 -2
- package/dist/assets/icons/ChevronUp.js +0 -32
- package/dist/assets/icons/ChevronsLeft.d.ts +0 -2
- package/dist/assets/icons/ChevronsLeft.js +0 -32
- package/dist/assets/icons/ChevronsRight.d.ts +0 -2
- package/dist/assets/icons/ChevronsRight.js +0 -32
- package/dist/assets/icons/Clock.d.ts +0 -2
- package/dist/assets/icons/Clock.js +0 -30
- package/dist/assets/icons/Close.d.ts +0 -2
- package/dist/assets/icons/Close.js +0 -30
- package/dist/assets/icons/DateTime.d.ts +0 -2
- package/dist/assets/icons/DateTime.js +0 -39
- package/dist/assets/icons/DragIndicator.d.ts +0 -2
- package/dist/assets/icons/DragIndicator.js +0 -30
- package/dist/assets/icons/Edit.d.ts +0 -2
- package/dist/assets/icons/Emoji.d.ts +0 -2
- package/dist/assets/icons/File.d.ts +0 -2
- package/dist/assets/icons/File.js +0 -32
- package/dist/assets/icons/Grid.d.ts +0 -2
- package/dist/assets/icons/Highlight.d.ts +0 -2
- package/dist/assets/icons/Highlight.js +0 -30
- package/dist/assets/icons/HighlightOn.d.ts +0 -6
- package/dist/assets/icons/HighlightOn.js +0 -55
- package/dist/assets/icons/Home.d.ts +0 -2
- package/dist/assets/icons/Home.js +0 -30
- package/dist/assets/icons/Image.d.ts +0 -2
- package/dist/assets/icons/ImageError.d.ts +0 -2
- package/dist/assets/icons/Info.d.ts +0 -2
- package/dist/assets/icons/Info.js +0 -41
- package/dist/assets/icons/Italic.d.ts +0 -2
- package/dist/assets/icons/Italic.js +0 -30
- package/dist/assets/icons/Link.d.ts +0 -2
- package/dist/assets/icons/Link.js +0 -30
- package/dist/assets/icons/Loader.d.ts +0 -2
- package/dist/assets/icons/MapPin.d.ts +0 -2
- package/dist/assets/icons/Menu.d.ts +0 -2
- package/dist/assets/icons/Menu.js +0 -30
- package/dist/assets/icons/Minus.d.ts +0 -2
- package/dist/assets/icons/MoreHoriz.d.ts +0 -2
- package/dist/assets/icons/NumberedList.d.ts +0 -2
- package/dist/assets/icons/NumberedList.js +0 -30
- package/dist/assets/icons/Pause.d.ts +0 -2
- package/dist/assets/icons/Plus.d.ts +0 -2
- package/dist/assets/icons/PointerHorizontal.d.ts +0 -2
- package/dist/assets/icons/PointerHorizontal.js +0 -30
- package/dist/assets/icons/PointerVertical.d.ts +0 -2
- package/dist/assets/icons/PointerVertical.js +0 -30
- package/dist/assets/icons/Retry.d.ts +0 -2
- package/dist/assets/icons/Search.d.ts +0 -2
- package/dist/assets/icons/Search.js +0 -30
- package/dist/assets/icons/Send.d.ts +0 -2
- package/dist/assets/icons/Send.js +0 -32
- package/dist/assets/icons/Share.d.ts +0 -2
- package/dist/assets/icons/Slash.d.ts +0 -2
- package/dist/assets/icons/Strikethrough.d.ts +0 -2
- package/dist/assets/icons/Strikethrough.js +0 -30
- package/dist/assets/icons/TextColor.d.ts +0 -6
- package/dist/assets/icons/TextColor.js +0 -52
- package/dist/assets/icons/Today.d.ts +0 -2
- package/dist/assets/icons/Today.js +0 -30
- package/dist/assets/icons/Trash.d.ts +0 -2
- package/dist/assets/icons/Underlined.d.ts +0 -2
- package/dist/assets/icons/Underlined.js +0 -32
- package/dist/assets/icons/Upload.d.ts +0 -2
- package/dist/assets/icons/Upload.js +0 -39
- package/dist/assets/icons/User.d.ts +0 -2
- package/dist/assets/icons/Visibility.d.ts +0 -2
- package/dist/assets/icons/Visibility.js +0 -30
- package/dist/assets/icons/VisibilityOff.d.ts +0 -2
- package/dist/assets/icons/VisibilityOff.js +0 -30
- package/dist/assets/icons/WarningFilled.d.ts +0 -2
- package/dist/assets/icons/WarningFilled.js +0 -32
- package/dist/assets/icons/WarningOutlined.d.ts +0 -2
- /package/dist/{hooks/useAutosave.spec.d.ts → rhf/entrypoints.type-test.d.ts} +0 -0
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { CalendarIcon } from "../assets/icons/Calendar.js";
|
|
2
|
-
import { ClockIcon } from "../assets/icons/Clock.js";
|
|
3
|
-
import { DateTimeIcon } from "../assets/icons/DateTime.js";
|
|
4
1
|
import { ObjectUtils } from "../utils/object.utils.js";
|
|
5
2
|
import { useDeepCompareMemo } from "../hooks/useDeepCompare.js";
|
|
6
|
-
import {
|
|
3
|
+
import { Calendar, CalendarClock, Clock } from "lucide-react";
|
|
7
4
|
import { createContext, use } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
6
|
//#region src/config/uiConfig.context.tsx
|
|
9
7
|
var UIConfig;
|
|
10
8
|
(function(_UIConfig) {
|
|
@@ -41,8 +39,8 @@ var UIConfig;
|
|
|
41
39
|
selectedTagsType: "list",
|
|
42
40
|
collapseAfter: 3,
|
|
43
41
|
hideSearchIcon: false,
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
multiSelectAutoConfirm: false,
|
|
43
|
+
fireBlurOnChange: false
|
|
46
44
|
},
|
|
47
45
|
queryAutocomplete: {
|
|
48
46
|
isInitialQueryDisabled: false,
|
|
@@ -70,15 +68,15 @@ var UIConfig;
|
|
|
70
68
|
shouldForceLeadingZeros: false,
|
|
71
69
|
disableManualEntry: false,
|
|
72
70
|
autoFixYear: false,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
timeIcon: /* @__PURE__ */ jsx(ClockIcon, { className: "size-6 text-interactive-text-secondary-idle" }),
|
|
71
|
+
calendarIcon: /* @__PURE__ */ jsx(Calendar, { className: "size-4" }),
|
|
72
|
+
dateTimeIcon: /* @__PURE__ */ jsx(CalendarClock, { className: "size-4" }),
|
|
73
|
+
timeIcon: /* @__PURE__ */ jsx(Clock, { className: "size-4 text-interactive-text-secondary-idle" }),
|
|
77
74
|
setDateValueOnDateSelection: false,
|
|
78
75
|
timeZone: "clientLocal",
|
|
79
76
|
granularity: "day",
|
|
80
77
|
shouldUpdateDateOnMonthYearChange: false,
|
|
81
|
-
allowPartialRange: false
|
|
78
|
+
allowPartialRange: false,
|
|
79
|
+
fireBlurOnChange: false
|
|
82
80
|
},
|
|
83
81
|
actionModal: {
|
|
84
82
|
titleTypography: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StyleMergeUtils } from "../utils/style-merge.util.js";
|
|
2
|
-
import { c } from "react/compiler-runtime";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
2
|
import { clsx } from "clsx";
|
|
5
3
|
import { createContext, use } from "react";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
6
5
|
import { cva } from "class-variance-authority";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/config/uiOverrides.context.tsx
|
|
8
8
|
var UIOverrides;
|
|
9
9
|
(function(_UIOverrides) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CellContext, ColumnDef, ColumnMeta } from '@tanstack/react-table';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { FieldPath } from '
|
|
3
|
+
import { FieldPath } from '../components/inputs/shared/form.binding';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
type NestedTypeFromKey<T, K extends string> = K extends keyof T ? T[K] : K extends `${infer First}.${infer Rest}` ? First extends keyof T ? NestedTypeFromKey<T[First], Rest> : never : never;
|
|
6
6
|
type SchemaType<TSchema extends z.ZodObject<any>> = z.infer<TSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FormInstance } from '../components/inputs/shared/form.binding';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { InputComponentProps, InputComponentType, InputDef, InputDefBaseProps, InputWrapperType } from '../components/inputs/Inputs/InputItem';
|
|
5
5
|
import { ZodUtils } from '../utils/zod.utils';
|
|
@@ -47,17 +47,17 @@ type UnknownInputDef<TSchema extends z.ZodObject<any>, K extends keyof z.infer<T
|
|
|
47
47
|
} & DynamicInputDefBase<InputDefBaseProps<InputComponentProps<T>>>;
|
|
48
48
|
}[DefaultComponentType<TSchema["shape"][K]>];
|
|
49
49
|
type RenderInputDef<TSchema extends z.ZodObject<any>, K extends keyof z.infer<TSchema>> = {
|
|
50
|
-
render: (
|
|
51
|
-
|
|
50
|
+
render: (field: {
|
|
51
|
+
form: FormInstance<z.infer<TSchema>>;
|
|
52
52
|
name: K;
|
|
53
|
-
}, form:
|
|
53
|
+
}, form: FormInstance<z.infer<TSchema>>) => ReactElement;
|
|
54
54
|
} & DynamicInputDefBase<Record<string, never>>;
|
|
55
55
|
type DynamicInputDef<TSchema extends z.ZodObject<any>, K extends keyof z.infer<TSchema>> = ConfigInputDef<TSchema, K> | UnknownInputDef<TSchema, K> | RenderInputDef<TSchema, K>;
|
|
56
56
|
type InputsConfig<TSchema extends z.ZodObject<any>> = {
|
|
57
|
-
[K in keyof z.infer<TSchema>]?: DynamicInputDef<TSchema, K> | ((
|
|
58
|
-
|
|
57
|
+
[K in keyof z.infer<TSchema>]?: DynamicInputDef<TSchema, K> | ((field: {
|
|
58
|
+
form: FormInstance<z.infer<TSchema>>;
|
|
59
59
|
name: K;
|
|
60
|
-
}, form:
|
|
60
|
+
}, form: FormInstance<z.infer<TSchema>>) => ReactElement) | boolean;
|
|
61
61
|
};
|
|
62
62
|
type GlobalProps = {
|
|
63
63
|
[T in Exclude<InputComponentType, "unknown">]: InputDefBaseProps<InputComponentProps<T>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface UseAutosaveProps<TFieldValues extends
|
|
3
|
-
form:
|
|
1
|
+
import { UIForm } from './useForm';
|
|
2
|
+
export interface UseAutosaveProps<TFieldValues extends Record<string, unknown>, TTransformedValues = TFieldValues, TResponse = unknown> {
|
|
3
|
+
form: UIForm<TFieldValues>;
|
|
4
4
|
delay?: number;
|
|
5
5
|
enabled?: boolean;
|
|
6
6
|
trigger?: "change" | "blur";
|
|
7
7
|
onSave: (data: Partial<TTransformedValues>) => Promise<TResponse>;
|
|
8
8
|
onSaveSuccess?: () => void;
|
|
9
9
|
}
|
|
10
|
-
export declare function useAutosave<TFieldValues extends
|
|
10
|
+
export declare function useAutosave<TFieldValues extends Record<string, unknown>, TTransformedValues = TFieldValues, TResponse = unknown>({ form, delay, enabled, trigger, onSave, onSaveSuccess, }: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>): void;
|
|
@@ -1,70 +1,85 @@
|
|
|
1
1
|
import { ObjectUtils } from "../utils/object.utils.js";
|
|
2
2
|
import { isEqual } from "../utils/isEqual.js";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
-
import { useFormState, useWatch } from "react-hook-form";
|
|
5
4
|
//#region src/hooks/useAutosave.ts
|
|
6
|
-
function
|
|
7
|
-
if (ObjectUtils.
|
|
8
|
-
return isEqual(left, right);
|
|
9
|
-
}
|
|
10
|
-
function diffLeftOnly(left, right, shallowKeys) {
|
|
11
|
-
if (!ObjectUtils.isObject(left) || ObjectUtils.isDate(left) || ObjectUtils.isRegExp(left)) return !isNilOrEqual(left, right) ? left : void 0;
|
|
12
|
-
if (Array.isArray(left)) return !isNilOrEqual(left, right) ? left : void 0;
|
|
5
|
+
function diffLeftOnly(left, right) {
|
|
6
|
+
if (!ObjectUtils.isObject(left) || ObjectUtils.isDate(left) || ObjectUtils.isRegExp(left)) return isEqual(left, right) ? void 0 : left;
|
|
7
|
+
if (Array.isArray(left)) return isEqual(left, right) ? void 0 : left;
|
|
13
8
|
const result = Object.entries(left).reduce((acc, [key, value]) => {
|
|
14
|
-
const
|
|
15
|
-
if (shallowSubtree === true) {
|
|
16
|
-
if (!isNilOrEqual(value, right?.[key])) acc[key] = value;
|
|
17
|
-
return acc;
|
|
18
|
-
}
|
|
19
|
-
const diff = diffLeftOnly(value, right?.[key], shallowSubtree);
|
|
9
|
+
const diff = diffLeftOnly(value, right?.[key]);
|
|
20
10
|
if (diff !== void 0 && (!ObjectUtils.isObject(diff) || !ObjectUtils.isEmpty(diff))) acc[key] = diff;
|
|
21
11
|
return acc;
|
|
22
12
|
}, {});
|
|
23
13
|
return ObjectUtils.isEmpty(result) ? void 0 : result;
|
|
24
14
|
}
|
|
15
|
+
var snapshot = (value) => structuredClone(value);
|
|
16
|
+
function pickChangedValues(source, changes) {
|
|
17
|
+
if (!ObjectUtils.isObject(changes) || Array.isArray(changes)) return source;
|
|
18
|
+
return Object.entries(changes).reduce((result, [key, value]) => {
|
|
19
|
+
result[key] = pickChangedValues(source?.[key], value);
|
|
20
|
+
return result;
|
|
21
|
+
}, {});
|
|
22
|
+
}
|
|
25
23
|
function useAutosave({ form, delay = 500, enabled = true, trigger = "change", onSave, onSaveSuccess }) {
|
|
26
24
|
const timeoutRef = useRef(void 0);
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
25
|
+
const savedSnapshotRef = useRef(snapshot(form.state.values));
|
|
26
|
+
const saveQueueRef = useRef(Promise.resolve());
|
|
27
|
+
const latestSaveRef = useRef({
|
|
28
|
+
onSave,
|
|
29
|
+
onSaveSuccess
|
|
30
|
+
});
|
|
31
|
+
latestSaveRef.current = {
|
|
32
|
+
onSave,
|
|
33
|
+
onSaveSuccess
|
|
34
|
+
};
|
|
31
35
|
useEffect(() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
const clearPending = () => {
|
|
37
|
+
if (timeoutRef.current) {
|
|
38
|
+
clearTimeout(timeoutRef.current);
|
|
39
|
+
timeoutRef.current = void 0;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const queueSave = () => {
|
|
43
|
+
if (!enabled) return;
|
|
44
|
+
clearPending();
|
|
45
|
+
timeoutRef.current = setTimeout(() => {
|
|
46
|
+
saveQueueRef.current = saveQueueRef.current.then(async () => {
|
|
47
|
+
const valuesAtSaveTime = snapshot(form.state.values);
|
|
48
|
+
const changedValues = diffLeftOnly(valuesAtSaveTime, savedSnapshotRef.current);
|
|
49
|
+
if (!changedValues) return;
|
|
50
|
+
let transformedValues;
|
|
51
|
+
try {
|
|
52
|
+
transformedValues = form.parseValues(valuesAtSaveTime);
|
|
53
|
+
} catch {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const payload = pickChangedValues(transformedValues, changedValues);
|
|
57
|
+
if (ObjectUtils.isEmpty(payload)) return;
|
|
58
|
+
try {
|
|
59
|
+
await latestSaveRef.current.onSave(payload);
|
|
60
|
+
savedSnapshotRef.current = valuesAtSaveTime;
|
|
61
|
+
for (const name of Object.keys(payload)) form.setFieldMeta(name, (meta) => ({
|
|
62
|
+
...meta,
|
|
63
|
+
isDirty: false
|
|
64
|
+
}));
|
|
65
|
+
latestSaveRef.current.onSaveSuccess?.();
|
|
66
|
+
} catch {}
|
|
67
|
+
});
|
|
68
|
+
}, delay);
|
|
69
|
+
};
|
|
70
|
+
const unsubscribeStore = trigger === "change" ? form.store.subscribe(() => {
|
|
71
|
+
if (!isEqual(form.state.values, savedSnapshotRef.current)) queueSave();
|
|
72
|
+
}) : void 0;
|
|
73
|
+
const unsubscribeBlur = trigger === "blur" ? form.subscribeBlur(queueSave) : void 0;
|
|
56
74
|
return () => {
|
|
57
|
-
|
|
75
|
+
clearPending();
|
|
76
|
+
unsubscribeStore?.unsubscribe();
|
|
77
|
+
unsubscribeBlur?.();
|
|
58
78
|
};
|
|
59
79
|
}, [
|
|
60
|
-
defaultValues,
|
|
61
|
-
dirtyFields,
|
|
62
|
-
trigger === "change" ? formData : touchedFields,
|
|
63
80
|
delay,
|
|
64
|
-
onSave,
|
|
65
|
-
handleSubmit,
|
|
66
81
|
enabled,
|
|
67
|
-
|
|
82
|
+
form,
|
|
68
83
|
trigger
|
|
69
84
|
]);
|
|
70
85
|
}
|
package/dist/hooks/useFilters.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UIRouter } from "../config/router.context.js";
|
|
2
2
|
import { RoutingUtils } from "../utils/routing.utils.js";
|
|
3
|
-
import { c } from "react/compiler-runtime";
|
|
4
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/hooks/useFilters.ts
|
|
7
7
|
function getFieldType(schema, fieldKey) {
|
package/dist/hooks/useForm.d.ts
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyFormApi, DeepKeys, DeepValue, ReactFormExtendedApi } from '@tanstack/react-form';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
type
|
|
4
|
-
|
|
3
|
+
type FormMode = "all" | "onBlur" | "onChange" | "onSubmit" | "onTouched";
|
|
4
|
+
type FieldValidators = {
|
|
5
|
+
onBlur?: ({ value }: {
|
|
6
|
+
value: unknown;
|
|
7
|
+
}) => string | undefined;
|
|
8
|
+
onChange?: ({ value }: {
|
|
9
|
+
value: unknown;
|
|
10
|
+
}) => string | undefined;
|
|
5
11
|
};
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
export type FormSubmitHandler<TValues> = (values: TValues) => void | Promise<void>;
|
|
13
|
+
export type FormSubmitErrorHandler<TValues> = (errors: unknown, values: TValues) => unknown;
|
|
14
|
+
type TanStackForm<TFieldValues> = ReactFormExtendedApi<TFieldValues, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, never>;
|
|
15
|
+
export type UIForm<TFieldValues extends Record<string, unknown> = Record<string, unknown>> = Omit<TanStackForm<TFieldValues>, "handleSubmit"> & {
|
|
16
|
+
readonly disabled: boolean;
|
|
17
|
+
getFieldValidators: (name: DeepKeys<TFieldValues>) => FieldValidators | undefined;
|
|
18
|
+
notifyBlur: (name: DeepKeys<TFieldValues>) => void;
|
|
19
|
+
parseValues: (values: TFieldValues) => unknown;
|
|
20
|
+
subscribeBlur: (listener: (name: DeepKeys<TFieldValues>) => void) => () => void;
|
|
21
|
+
handleSubmit: (onValid: FormSubmitHandler<any>, onInvalid?: FormSubmitErrorHandler<TFieldValues>) => (event?: {
|
|
22
|
+
preventDefault?: () => void;
|
|
23
|
+
stopPropagation?: () => void;
|
|
24
|
+
}) => Promise<void>;
|
|
16
25
|
};
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
type AsyncDefaultValues<TFieldValues> = (payload?: unknown) => Promise<TFieldValues>;
|
|
27
|
+
type NullableDefaults<T> = T extends Date | File | Blob ? T : T extends Array<infer TItem> ? Array<NullableDefaults<TItem>> : T extends object ? {
|
|
28
|
+
[K in keyof T]?: NullableDefaults<T[K]> | null;
|
|
29
|
+
} : T | null;
|
|
30
|
+
export interface UseFormProps<TFieldValues, TTransformedValues = TFieldValues> {
|
|
31
|
+
defaultValues?: NullableDefaults<TFieldValues> | AsyncDefaultValues<TFieldValues>;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
mode?: FormMode;
|
|
34
|
+
onSubmitAsync?: (props: {
|
|
35
|
+
value: TFieldValues;
|
|
36
|
+
}) => Promise<unknown>;
|
|
37
|
+
zodSchema?: z.ZodType<TTransformedValues, TFieldValues>;
|
|
38
|
+
}
|
|
39
|
+
export declare function useForm<TFieldValues extends Record<string, unknown> = Record<string, unknown>, _TContext = unknown, TTransformedValues = TFieldValues>({ defaultValues, disabled, mode, onSubmitAsync, zodSchema, }?: UseFormProps<TFieldValues, TTransformedValues>): UIForm<TFieldValues>;
|
|
40
|
+
export declare const useFormValue: <TFieldValues extends Record<string, unknown>, TSelected>(form: UIForm<TFieldValues>, selector: (values: TFieldValues) => TSelected) => TSelected;
|
|
41
|
+
export declare const useFormState: <TFieldValues extends Record<string, unknown>, TSelected>(form: UIForm<TFieldValues>, selector: (state: UIForm<TFieldValues>["state"]) => TSelected) => TSelected;
|
|
42
|
+
export type { AnyFormApi, DeepKeys, DeepValue };
|
package/dist/hooks/useForm.js
CHANGED
|
@@ -1,48 +1,101 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
1
2
|
import { c } from "react/compiler-runtime";
|
|
2
|
-
import { useForm } from "react-
|
|
3
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
3
|
+
import { useForm, useStore } from "@tanstack/react-form";
|
|
4
4
|
//#region src/hooks/useForm.ts
|
|
5
|
-
function useForm$1(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
5
|
+
function useForm$1({ defaultValues, disabled = false, mode = "onSubmit", onSubmitAsync, zodSchema } = {}) {
|
|
6
|
+
const submitHandlerRef = useRef(() => void 0);
|
|
7
|
+
const submitErrorHandlerRef = useRef(void 0);
|
|
8
|
+
const blurListenersRef = useRef(/* @__PURE__ */ new Set());
|
|
9
|
+
const fieldValidators = useMemo(() => {
|
|
10
|
+
return /* @__PURE__ */ new Map();
|
|
11
|
+
}, [mode, zodSchema]);
|
|
12
|
+
const formValidator = useMemo(() => {
|
|
13
|
+
if (!zodSchema) return;
|
|
14
|
+
return ({ value }) => {
|
|
15
|
+
const result = zodSchema.safeParse(value);
|
|
16
|
+
if (result.success) return;
|
|
17
|
+
return { fields: Object.fromEntries(result.error.issues.map((issue) => [pathToString(issue.path), issue.message])) };
|
|
18
|
+
};
|
|
19
|
+
}, [zodSchema]);
|
|
20
|
+
const form = useForm({
|
|
21
|
+
defaultValues: (typeof defaultValues === "function" ? {} : defaultValues) ?? {},
|
|
22
|
+
validators: formValidator || onSubmitAsync ? {
|
|
23
|
+
onSubmit: formValidator,
|
|
24
|
+
onSubmitAsync
|
|
25
|
+
} : void 0,
|
|
26
|
+
onSubmit: async ({ value: value_0 }) => {
|
|
27
|
+
const transformed = zodSchema ? zodSchema.parse(value_0) : value_0;
|
|
28
|
+
await submitHandlerRef.current(transformed);
|
|
29
|
+
},
|
|
30
|
+
onSubmitInvalid: ({ value: value_1, formApi }) => {
|
|
31
|
+
submitErrorHandlerRef.current?.(formApi.state.errors, value_1);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const originalHandleSubmit = useMemo(() => form.handleSubmit.bind(form), [form]);
|
|
35
|
+
const uiForm = form;
|
|
36
|
+
Object.defineProperties(uiForm, { disabled: {
|
|
37
|
+
configurable: true,
|
|
38
|
+
get: () => disabled
|
|
39
|
+
} });
|
|
40
|
+
uiForm.getFieldValidators = (name) => {
|
|
41
|
+
const cached = fieldValidators.get(name);
|
|
42
|
+
if (cached || fieldValidators.has(name)) return cached;
|
|
43
|
+
const schema = zodSchema ? getSchemaAtPath(zodSchema, name) : void 0;
|
|
44
|
+
if (!schema || mode === "onSubmit") {
|
|
45
|
+
fieldValidators.set(name, void 0);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const validate = ({ value: value_2 }) => {
|
|
49
|
+
const result_0 = schema.safeParse(value_2);
|
|
50
|
+
return result_0.success ? void 0 : result_0.error.issues[0]?.message;
|
|
39
51
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
const validators = mode === "onChange" || mode === "all" ? { onChange: validate } : { onBlur: validate };
|
|
53
|
+
fieldValidators.set(name, validators);
|
|
54
|
+
return validators;
|
|
55
|
+
};
|
|
56
|
+
uiForm.notifyBlur = (name_0) => {
|
|
57
|
+
for (const listener of blurListenersRef.current) listener(name_0);
|
|
58
|
+
};
|
|
59
|
+
uiForm.parseValues = (values) => zodSchema ? zodSchema.parse(values) : values;
|
|
60
|
+
uiForm.subscribeBlur = (listener_0) => {
|
|
61
|
+
blurListenersRef.current.add(listener_0);
|
|
62
|
+
return () => blurListenersRef.current.delete(listener_0);
|
|
63
|
+
};
|
|
64
|
+
uiForm.handleSubmit = (onValid, onInvalid) => async (event) => {
|
|
65
|
+
event?.preventDefault?.();
|
|
66
|
+
event?.stopPropagation?.();
|
|
67
|
+
submitHandlerRef.current = onValid;
|
|
68
|
+
submitErrorHandlerRef.current = onInvalid;
|
|
69
|
+
await originalHandleSubmit();
|
|
70
|
+
};
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (typeof defaultValues === "function") defaultValues().then((values_0) => form.reset(values_0));
|
|
73
|
+
}, [defaultValues, form]);
|
|
74
|
+
return uiForm;
|
|
46
75
|
}
|
|
76
|
+
var useFormValue = (form, selector) => {
|
|
77
|
+
const $ = c(2);
|
|
78
|
+
let t0;
|
|
79
|
+
if ($[0] !== selector) {
|
|
80
|
+
t0 = (state) => selector(state.values);
|
|
81
|
+
$[0] = selector;
|
|
82
|
+
$[1] = t0;
|
|
83
|
+
} else t0 = $[1];
|
|
84
|
+
return useStore(form.store, t0);
|
|
85
|
+
};
|
|
86
|
+
var useFormState = (form, selector) => {
|
|
87
|
+
return useStore(form.store, selector);
|
|
88
|
+
};
|
|
89
|
+
var getSchemaAtPath = (rootSchema, path) => {
|
|
90
|
+
let schema = rootSchema;
|
|
91
|
+
for (const segment of parsePath(path)) {
|
|
92
|
+
while (schema?.unwrap && !schema.shape && !schema.element && !schema.items) schema = schema.unwrap();
|
|
93
|
+
schema = typeof segment === "number" ? schema?.element ?? schema?.items?.[segment] : schema?.shape?.[segment];
|
|
94
|
+
if (!schema) return;
|
|
95
|
+
}
|
|
96
|
+
return schema;
|
|
97
|
+
};
|
|
98
|
+
var parsePath = (path) => path.replaceAll("[", ".").replaceAll("]", "").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
99
|
+
var pathToString = (path) => path.reduce((result, segment) => typeof segment === "number" ? `${result}[${segment}]` : result ? `${result}.${String(segment)}` : String(segment), "");
|
|
47
100
|
//#endregion
|
|
48
|
-
export { useForm$1 as useForm };
|
|
101
|
+
export { useForm$1 as useForm, useFormState, useFormValue };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
|
-
import { FieldValues } from 'react-hook-form';
|
|
3
2
|
import { UseAutosaveProps } from './useAutosave';
|
|
4
|
-
import { UseFormProps
|
|
5
|
-
export type UseFormAutosaveProps<TFieldValues extends
|
|
6
|
-
autosaveDelay?: UseAutosaveProps<TFieldValues,
|
|
7
|
-
enableAutosave?: UseAutosaveProps<TFieldValues,
|
|
8
|
-
autosaveOn?: UseAutosaveProps<TFieldValues,
|
|
3
|
+
import { UseFormProps } from './useForm';
|
|
4
|
+
export type UseFormAutosaveProps<TFieldValues extends Record<string, unknown> = Record<string, unknown>, _TContext = any, TTransformedValues = TFieldValues, TResponse = unknown> = Omit<UseFormProps<TFieldValues, TTransformedValues>, "defaultValues"> & {
|
|
5
|
+
autosaveDelay?: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>["delay"];
|
|
6
|
+
enableAutosave?: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>["enabled"];
|
|
7
|
+
autosaveOn?: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>["trigger"];
|
|
9
8
|
normalizeAutosaveData?: (data: Partial<TTransformedValues>) => Partial<TTransformedValues> | undefined;
|
|
10
|
-
onAutosave: UseAutosaveProps<TFieldValues,
|
|
11
|
-
getResetValues: () => UseFormProps<TFieldValues,
|
|
9
|
+
onAutosave: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>["onSave"];
|
|
10
|
+
getResetValues: () => UseFormProps<TFieldValues, TTransformedValues>["defaultValues"];
|
|
12
11
|
resetDeps: DependencyList;
|
|
13
12
|
resetTimeout?: number;
|
|
14
13
|
};
|
|
15
|
-
export declare function useFormAutosave<TFieldValues extends
|
|
14
|
+
export declare function useFormAutosave<TFieldValues extends Record<string, unknown> = Record<string, unknown>, TContext = any, TTransformedValues = TFieldValues, TResponse = any>({ autosaveDelay, enableAutosave, autosaveOn, normalizeAutosaveData, onAutosave, getResetValues, resetDeps, resetTimeout, ...props }: UseFormAutosaveProps<TFieldValues, TContext, TTransformedValues, TResponse>): import('./useForm').UIForm<TFieldValues>;
|
|
@@ -26,15 +26,19 @@ function useFormAutosave({ autosaveDelay, enableAutosave, autosaveOn = "change",
|
|
|
26
26
|
const resetValues = getResetValues();
|
|
27
27
|
if (resetValues === void 0) return;
|
|
28
28
|
const resetFormValues = async () => {
|
|
29
|
-
const
|
|
29
|
+
const keepCurrentValues = shouldResetFormValuesRef.current;
|
|
30
30
|
shouldResetFormValuesRef.current = false;
|
|
31
|
-
let values
|
|
31
|
+
let values;
|
|
32
32
|
if (ObjectUtils.isFunction(resetValues)) values = await resetValues();
|
|
33
|
-
|
|
33
|
+
else values = resetValues;
|
|
34
|
+
form.reset(keepCurrentValues ? {
|
|
35
|
+
...values,
|
|
36
|
+
...form.state.values
|
|
37
|
+
} : values);
|
|
34
38
|
};
|
|
35
39
|
resetFormValues();
|
|
36
40
|
}, [...resetDeps]);
|
|
37
|
-
const
|
|
41
|
+
const prepareForSaveReset = () => {
|
|
38
42
|
shouldResetFormValuesRef.current = true;
|
|
39
43
|
if (resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
40
44
|
resetFormValuesTimeoutRef.current = setTimeout(() => {
|
|
@@ -46,12 +50,22 @@ function useFormAutosave({ autosaveDelay, enableAutosave, autosaveOn = "change",
|
|
|
46
50
|
delay: autosaveDelay,
|
|
47
51
|
enabled: enableAutosave,
|
|
48
52
|
trigger: autosaveOn,
|
|
49
|
-
onSave: useCallback((data) => {
|
|
53
|
+
onSave: useCallback(async (data) => {
|
|
50
54
|
const normalizedData = normalizeAutosaveData ? normalizeAutosaveData(data) : data;
|
|
51
|
-
if (!normalizedData || ObjectUtils.isEmpty(normalizedData)) return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
if (!normalizedData || ObjectUtils.isEmpty(normalizedData)) return;
|
|
56
|
+
prepareForSaveReset();
|
|
57
|
+
try {
|
|
58
|
+
return await onAutosave(normalizedData);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
shouldResetFormValuesRef.current = false;
|
|
61
|
+
if (resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
normalizeAutosaveData,
|
|
66
|
+
onAutosave,
|
|
67
|
+
resetTimeout
|
|
68
|
+
])
|
|
55
69
|
});
|
|
56
70
|
return form;
|
|
57
71
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UIRouter } from "../config/router.context.js";
|
|
2
2
|
import { RoutingUtils } from "../utils/routing.utils.js";
|
|
3
|
-
import { c } from "react/compiler-runtime";
|
|
4
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
5
|
//#region src/hooks/usePagination.ts
|
|
6
6
|
var DEFAULT_STATE = {
|
|
7
7
|
pageIndex: 1,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useBreakpoint } from "./useBreakpoint.js";
|
|
2
|
-
import { c } from "react/compiler-runtime";
|
|
3
2
|
import { useEffect, useRef } from "react";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
4
|
//#region src/hooks/useScrollableListBox.ts
|
|
5
5
|
function useScrollableListBox() {
|
|
6
6
|
const $ = c(4);
|
package/dist/hooks/useSorting.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UIRouter } from "../config/router.context.js";
|
|
2
2
|
import { RoutingUtils } from "../utils/routing.utils.js";
|
|
3
|
-
import { c } from "react/compiler-runtime";
|
|
4
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
5
|
//#region src/hooks/useSorting.ts
|
|
6
6
|
function useSorting(defaultSorting, t0) {
|
|
7
7
|
const $ = c(16);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ObjectUtils } from "../utils/object.utils.js";
|
|
2
|
-
import { c } from "react/compiler-runtime";
|
|
3
2
|
import { useRef, useState } from "react";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
4
|
//#region src/hooks/useStateAndRef.ts
|
|
5
5
|
var useStateAndRef = (initialState) => {
|
|
6
6
|
const $ = c(3);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c } from "react/compiler-runtime";
|
|
2
1
|
import { useEffect, useState } from "react";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
3
|
//#region src/hooks/useTableColumnConfig.ts
|
|
4
4
|
function sortByKeyOrder(data, orderedKeys = []) {
|
|
5
5
|
return [...data].sort((a, b) => {
|