@povio/ui 0.0.7 → 0.0.8
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/index.js +62585 -0
- package/package.json +5 -57
- package/povio-ui-0.0.8.tgz +0 -0
- package/{dist → src}/components/Menu/MenuDesktop.d.ts +1 -1
- package/{dist → src}/components/Menu/MenuItem.d.ts +1 -1
- package/{dist → src}/components/Menu/MenuMobile.d.ts +1 -1
- package/{dist → src}/components/Menu/MenuPopover.d.ts +1 -1
- package/{dist → src}/components/buttons/Button/Button.d.ts +1 -1
- package/{dist → src}/components/buttons/Button/button.cva.d.ts +1 -1
- package/{dist → src}/components/buttons/IconButton/IconButton.d.ts +1 -1
- package/{dist → src}/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -1
- package/{dist → src}/components/buttons/PillButton/PillButton.d.ts +2 -2
- package/{dist → src}/components/buttons/PillButton/pillButton.cva.d.ts +1 -1
- package/{dist → src}/components/buttons/SplitButton/SplitButton.d.ts +2 -2
- package/{dist → src}/components/buttons/TextButton/TextButton.d.ts +3 -3
- package/{dist → src}/components/buttons/ToggleButton/ToggleButton.d.ts +3 -3
- package/{dist → src}/components/buttons/shared/ButtonContent.d.ts +3 -3
- package/{dist → src}/components/inputs/Checkbox/Checkbox.d.ts +3 -3
- package/{dist → src}/components/inputs/Checkbox/CheckboxCheckmark.d.ts +1 -1
- package/{dist → src}/components/inputs/Checkbox/checkbox.cva.d.ts +1 -1
- package/{dist → src}/components/inputs/DateTime/DatePicker/DatePicker.d.ts +3 -3
- package/{dist → src}/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +3 -3
- package/{dist → src}/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +3 -3
- package/{dist → src}/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -3
- package/{dist → src}/components/inputs/DateTime/shared/CalendarHeader.d.ts +1 -1
- package/{dist → src}/components/inputs/DateTime/shared/DatePickerInput.d.ts +2 -2
- package/{dist → src}/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -2
- package/{dist → src}/components/inputs/File/fileUpload.types.d.ts +3 -3
- package/{dist → src}/components/inputs/File/inputUpload.types.d.ts +2 -2
- package/{dist → src}/components/inputs/File/shared/FileCard.d.ts +1 -1
- package/{dist → src}/components/inputs/File/shared/FileCardList.d.ts +1 -1
- package/{dist → src}/components/inputs/File/shared/FileUploadContent.d.ts +1 -1
- package/{dist → src}/components/inputs/File/shared/FileUploadContentEmpty.d.ts +1 -1
- package/{dist → src}/components/inputs/File/shared/FileUploadContentError.d.ts +1 -1
- package/{dist → src}/components/inputs/File/shared/FileUploadContentFilled.d.ts +1 -1
- package/{dist → src}/components/inputs/File/shared/FileUploadContentLoading.d.ts +1 -1
- package/{dist → src}/components/inputs/File/shared/InputUploadContent.d.ts +1 -1
- package/{dist → src}/components/inputs/FormField/FormField.d.ts +3 -3
- package/src/components/inputs/FormField/FormFieldLabel.d.ts +12 -0
- package/{dist → src}/components/inputs/Input/NumberInput/NumberInput.d.ts +4 -4
- package/{dist → src}/components/inputs/Input/PasswordInput/PasswordInput.d.ts +2 -2
- package/{dist → src}/components/inputs/Input/TextArea/TextArea.d.ts +3 -3
- package/{dist → src}/components/inputs/Input/TextInput/TextInput.d.ts +5 -4
- package/{dist → src}/components/inputs/Input/shared/InputContent.d.ts +3 -3
- package/{dist → src}/components/inputs/Inputs/Form.d.ts +2 -2
- package/{dist → src}/components/inputs/Inputs/InputItem.d.ts +16 -16
- package/{dist → src}/components/inputs/RadioGroup/RadioGroup.d.ts +3 -3
- package/{dist → src}/components/inputs/RadioGroup/radio.cva.d.ts +1 -1
- package/{dist → src}/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +3 -3
- package/{dist → src}/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -3
- package/{dist → src}/components/inputs/Selection/Select/Select.d.ts +3 -3
- package/{dist → src}/components/inputs/Selection/shared/SelectBase.d.ts +5 -4
- package/{dist → src}/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/{dist → src}/components/inputs/Selection/shared/SelectInput.d.ts +6 -6
- package/src/components/inputs/Selection/shared/SelectInputTags.d.ts +11 -0
- package/src/components/inputs/Selection/shared/SelectListBox.d.ts +9 -0
- package/{dist → src}/components/inputs/Selection/shared/SelectListBoxItem.d.ts +2 -2
- package/{dist → src}/components/inputs/Selection/shared/SelectListBoxItemSelectAll.d.ts +1 -1
- package/{dist → src}/components/inputs/Selection/shared/SelectListBoxLoadingItem.d.ts +1 -1
- package/{dist → src}/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/{dist → src}/components/inputs/Selection/shared/select.context.d.ts +2 -2
- package/{dist → src}/components/inputs/Selection/shared/select.types.d.ts +9 -1
- package/{dist → src}/components/inputs/Selection/shared/useSelectItems.d.ts +2 -2
- package/{dist → src}/components/inputs/Slider/Slider.d.ts +2 -2
- package/{dist → src}/components/inputs/TextEditor/TextEditor.d.ts +2 -2
- package/{dist → src}/components/inputs/TextEditor/Toolbar/HyperlinkAction.d.ts +1 -1
- package/{dist → src}/components/inputs/TextEditor/Toolbar/TextAlignSelect.d.ts +1 -1
- package/{dist → src}/components/inputs/TextEditor/Toolbar/TextColorSelect.d.ts +1 -1
- package/{dist → src}/components/inputs/TextEditor/Toolbar/TextHighlightSelect.d.ts +1 -1
- package/{dist → src}/components/inputs/TextEditor/Toolbar/TextListActions.d.ts +1 -1
- package/{dist → src}/components/inputs/TextEditor/Toolbar/TextMarksActions.d.ts +1 -1
- package/{dist → src}/components/inputs/TextEditor/Toolbar/TextStyleSelect.d.ts +1 -1
- package/{dist → src}/components/inputs/Toggle/Toggle.d.ts +3 -3
- package/{dist → src}/components/inputs/Toggle/toggle.cva.d.ts +1 -1
- package/{dist → src}/components/inputs/shared/CheckContent.d.ts +1 -1
- package/src/components/inputs/shared/InputClear.d.ts +8 -0
- package/{dist → src}/components/inputs/shared/label.cva.d.ts +1 -1
- package/{dist → src}/components/overlays/ActionModal/ActionModal.d.ts +2 -2
- package/{dist → src}/components/overlays/Modal/Modal.d.ts +1 -1
- package/{dist → src}/components/overlays/Tooltip/Tooltip.d.ts +4 -2
- package/src/components/overlays/Tooltip/tooltip.cva.d.ts +21 -0
- package/{dist → src}/components/segment/segment.types.d.ts +1 -1
- package/{dist → src}/components/shared/pagination/PaginationList.d.ts +1 -1
- package/{dist → src}/components/status/Alert/Alert.d.ts +1 -1
- package/{dist → src}/components/status/Loader/Loader.d.ts +1 -1
- package/{dist → src}/components/status/Toast/Toast.d.ts +1 -1
- package/{dist → src}/components/status/Toast/toast.cva.d.ts +1 -1
- package/{dist → src}/components/table/table.cva.d.ts +7 -3
- package/{dist → src}/components/text/Link/Link.d.ts +1 -1
- package/{dist → src}/components/text/Tag/Tag.d.ts +1 -1
- package/{dist → src}/components/text/Typography/Typography.d.ts +1 -1
- package/{dist → src}/config/confirmation.context.d.ts +1 -1
- package/{dist → src}/config/uiConfig.context.d.ts +10 -8
- package/{dist → src}/config/uiStyle.context.d.ts +15 -14
- package/{dist → src}/helpers/dynamicInputs.d.ts +4 -2
- package/{dist → src}/hooks/useFormAutosave.d.ts +2 -2
- package/{dist → src}/index.d.ts +12 -6
- package/{dist → src}/types/react-query.d.ts +1 -1
- package/src/utils/vendor/acl/AclGuard.d.ts +8 -0
- package/src/utils/vendor/acl/Can.d.ts +9 -0
- package/src/utils/vendor/acl/ability.context.d.ts +15 -0
- package/src/utils/vendor/acl/appAbility.types.d.ts +3 -0
- package/src/utils/vendor/auth/AuthGuard.d.ts +6 -0
- package/src/utils/vendor/auth/auth.context.d.ts +21 -0
- package/src/utils/vendor/auth/withPrivateAuthGuard.d.ts +6 -0
- package/{dist/utils/rest/rest-client.d.ts → src/utils/vendor/rest-client.types.d.ts} +8 -14
- package/{dist → src}/utils/zod.utils.d.ts +2 -1
- package/vite.config.d.ts +2 -0
- package/dist/assets/icons/AlignCenter.js +0 -21
- package/dist/assets/icons/AlignLeft.js +0 -21
- package/dist/assets/icons/AlignLeftRight.js +0 -21
- package/dist/assets/icons/AlignRight.js +0 -21
- package/dist/assets/icons/ArrowDropDown.js +0 -21
- package/dist/assets/icons/ArrowDropUp.js +0 -21
- package/dist/assets/icons/ArrowLeft.js +0 -21
- package/dist/assets/icons/ArrowRight.js +0 -21
- package/dist/assets/icons/Bold.js +0 -21
- package/dist/assets/icons/BulletedList.js +0 -21
- package/dist/assets/icons/Calendar.js +0 -23
- package/dist/assets/icons/Check.js +0 -23
- package/dist/assets/icons/CheckCircle.js +0 -21
- package/dist/assets/icons/CheckboxCheckmark.js +0 -24
- package/dist/assets/icons/CheckboxIndeterminate.js +0 -24
- package/dist/assets/icons/ChevronDown.js +0 -23
- package/dist/assets/icons/ChevronLeft.js +0 -23
- package/dist/assets/icons/ChevronRight.js +0 -23
- package/dist/assets/icons/ChevronUp.js +0 -23
- package/dist/assets/icons/ChevronsLeft.js +0 -34
- package/dist/assets/icons/ChevronsRight.js +0 -34
- package/dist/assets/icons/Clock.js +0 -21
- package/dist/assets/icons/Close.js +0 -21
- package/dist/assets/icons/DateTime.js +0 -25
- package/dist/assets/icons/Drag.js +0 -21
- package/dist/assets/icons/File.js +0 -23
- package/dist/assets/icons/Highlight.js +0 -21
- package/dist/assets/icons/HighlightOn.js +0 -30
- package/dist/assets/icons/Info.js +0 -34
- package/dist/assets/icons/Italic.js +0 -21
- package/dist/assets/icons/Link.js +0 -21
- package/dist/assets/icons/Menu.js +0 -23
- package/dist/assets/icons/NumberedList.js +0 -21
- package/dist/assets/icons/PointerHorizontal.js +0 -21
- package/dist/assets/icons/PointerVertical.js +0 -21
- package/dist/assets/icons/Send.js +0 -23
- package/dist/assets/icons/Strikethrough.js +0 -21
- package/dist/assets/icons/TextColor.js +0 -30
- package/dist/assets/icons/Today.js +0 -21
- package/dist/assets/icons/Underlined.js +0 -23
- package/dist/assets/icons/Upload.js +0 -30
- package/dist/assets/icons/View.js +0 -18
- package/dist/assets/icons/ViewOff.js +0 -18
- package/dist/assets/icons/Warningfilled.js +0 -23
- package/dist/assets/locales/en/translation.json.js +0 -14
- package/dist/assets/locales/sl/translation.json.js +0 -14
- package/dist/components/Menu/Menu.js +0 -14
- package/dist/components/Menu/MenuDesktop.js +0 -68
- package/dist/components/Menu/MenuItem.js +0 -33
- package/dist/components/Menu/MenuMobile.js +0 -78
- package/dist/components/Menu/MenuPopover.js +0 -38
- package/dist/components/buttons/Button/Button.js +0 -68
- package/dist/components/buttons/Button/button.cva.js +0 -672
- package/dist/components/buttons/IconButton/IconButton.js +0 -17
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +0 -18
- package/dist/components/buttons/PillButton/PillButton.js +0 -44
- package/dist/components/buttons/PillButton/pillButton.cva.js +0 -86
- package/dist/components/buttons/SplitButton/SplitButton.js +0 -62
- package/dist/components/buttons/TextButton/TextButton.js +0 -18
- package/dist/components/buttons/ToggleButton/ToggleButton.js +0 -21
- package/dist/components/buttons/shared/ButtonContent.js +0 -53
- package/dist/components/buttons/shared/buttonContent.cva.js +0 -16
- package/dist/components/inputs/Checkbox/Checkbox.js +0 -81
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +0 -49
- package/dist/components/inputs/Checkbox/checkbox.cva.js +0 -47
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +0 -234
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +0 -668
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +0 -248
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +0 -224
- package/dist/components/inputs/DateTime/shared/Calendar.js +0 -85
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +0 -160
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +0 -67
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +0 -89
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +0 -203
- package/dist/components/inputs/DateTime/shared/DateField.js +0 -62
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +0 -163
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +0 -54
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +0 -76
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +0 -41
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +0 -82
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +0 -131
- package/dist/components/inputs/DateTime/shared/TimeField.js +0 -26
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +0 -186
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +0 -107
- package/dist/components/inputs/DateTime/shared/YearPicker.js +0 -89
- package/dist/components/inputs/File/FileUpload.js +0 -254
- package/dist/components/inputs/File/FileUploadContainer.js +0 -17
- package/dist/components/inputs/File/InputUpload.js +0 -176
- package/dist/components/inputs/File/shared/FileCard.js +0 -67
- package/dist/components/inputs/File/shared/FileCardList.js +0 -20
- package/dist/components/inputs/File/shared/FileProgressBar.js +0 -32
- package/dist/components/inputs/File/shared/FileUploadContent.js +0 -92
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +0 -92
- package/dist/components/inputs/File/shared/FileUploadContentError.js +0 -167
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +0 -176
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +0 -128
- package/dist/components/inputs/File/shared/InputUploadContent.js +0 -68
- package/dist/components/inputs/File/shared/InputUploadFilled.js +0 -31
- package/dist/components/inputs/File/shared/fileUpload.cva.js +0 -57
- package/dist/components/inputs/File/shared/inputUploadButton.cva.js +0 -48
- package/dist/components/inputs/FormField/FormField.js +0 -54
- package/dist/components/inputs/FormField/FormFieldError.js +0 -16
- package/dist/components/inputs/FormField/FormFieldHeader.js +0 -57
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +0 -20
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +0 -11
- package/dist/components/inputs/FormField/FormFieldLabel.js +0 -31
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +0 -157
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +0 -26
- package/dist/components/inputs/Input/TextArea/TextArea.js +0 -149
- package/dist/components/inputs/Input/TextInput/TextInput.js +0 -147
- package/dist/components/inputs/Input/shared/InputContent.js +0 -106
- package/dist/components/inputs/Inputs/Form.js +0 -68
- package/dist/components/inputs/Inputs/InputItem.js +0 -63
- package/dist/components/inputs/Inputs/Inputs.js +0 -32
- package/dist/components/inputs/RadioGroup/RadioGroup.js +0 -113
- package/dist/components/inputs/RadioGroup/radio.cva.js +0 -47
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +0 -39
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +0 -25
- package/dist/components/inputs/Selection/Select/Select.js +0 -32
- package/dist/components/inputs/Selection/shared/SelectBase.js +0 -24
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +0 -211
- package/dist/components/inputs/Selection/shared/SelectInput.js +0 -237
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +0 -9
- package/dist/components/inputs/Selection/shared/SelectListBox.js +0 -97
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +0 -78
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +0 -45
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +0 -47
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +0 -42
- package/dist/components/inputs/Selection/shared/SelectMobile.js +0 -161
- package/dist/components/inputs/Selection/shared/select.context.js +0 -243
- package/dist/components/inputs/Selection/shared/useSelectItems.js +0 -94
- package/dist/components/inputs/Slider/Slider.js +0 -137
- package/dist/components/inputs/TextEditor/TextEditor.js +0 -223
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +0 -34
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +0 -80
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +0 -92
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +0 -56
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +0 -33
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +0 -31
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +0 -37
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +0 -51
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +0 -73
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +0 -61
- package/dist/components/inputs/TextEditor/textEditor.types.js +0 -40
- package/dist/components/inputs/Toggle/Toggle.js +0 -65
- package/dist/components/inputs/Toggle/toggle.cva.js +0 -44
- package/dist/components/inputs/shared/CheckContent.js +0 -22
- package/dist/components/inputs/shared/InputClear.d.ts +0 -6
- package/dist/components/inputs/shared/InputClear.js +0 -26
- package/dist/components/inputs/shared/input.cva.js +0 -167
- package/dist/components/inputs/shared/label.cva.js +0 -133
- package/dist/components/outline.clsx.js +0 -11
- package/dist/components/overlays/ActionModal/ActionModal.js +0 -80
- package/dist/components/overlays/BottomSheet/BottomSheet.js +0 -256
- package/dist/components/overlays/Drawer/Drawer.js +0 -84
- package/dist/components/overlays/Modal/Modal.js +0 -53
- package/dist/components/overlays/Modal/modal.cva.js +0 -53
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +0 -71
- package/dist/components/overlays/Tooltip/Tooltip.js +0 -44
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +0 -27
- package/dist/components/segment/Segment.js +0 -113
- package/dist/components/segment/SegmentItem.js +0 -41
- package/dist/components/shared/pagination/Pagination.js +0 -75
- package/dist/components/shared/pagination/PaginationList.js +0 -145
- package/dist/components/shared/pagination/minWidth.cva.js +0 -15
- package/dist/components/status/Alert/Alert.js +0 -41
- package/dist/components/status/Alert/alert.cva.js +0 -64
- package/dist/components/status/Loader/Loader.js +0 -37
- package/dist/components/status/Loader/loader.cva.js +0 -27
- package/dist/components/status/Toast/Toast.js +0 -64
- package/dist/components/status/Toast/toast.cva.js +0 -150
- package/dist/components/status/Toast/useToast.js +0 -83
- package/dist/components/status/shared/status.cva.js +0 -62
- package/dist/components/table/CellText.js +0 -18
- package/dist/components/table/ColumnConfig.js +0 -124
- package/dist/components/table/HeaderText.js +0 -15
- package/dist/components/table/InfiniteTable.js +0 -40
- package/dist/components/table/PaginatedTable.js +0 -33
- package/dist/components/table/Table.js +0 -352
- package/dist/components/table/table.cva.js +0 -37
- package/dist/components/text/Link/Link.js +0 -18
- package/dist/components/text/Link/link.cva.js +0 -18
- package/dist/components/text/Tag/Tag.js +0 -49
- package/dist/components/text/Tag/tag.cva.js +0 -59
- package/dist/components/text/Typography/Typography.js +0 -22
- package/dist/components/text/Typography/typography.cva.js +0 -100
- package/dist/config/confirmation.context.js +0 -107
- package/dist/config/i18n.js +0 -15
- package/dist/config/router.context.js +0 -43
- package/dist/config/uiConfig.context.js +0 -62
- package/dist/config/uiStyle.context.js +0 -16
- package/dist/helpers/dynamicColumns.js +0 -359
- package/dist/helpers/dynamicInputs.js +0 -214
- package/dist/hooks/useAutosave.js +0 -80
- package/dist/hooks/useBreakpoint.js +0 -20
- package/dist/hooks/useDebounceCallback.js +0 -29
- package/dist/hooks/useDeepCompare.js +0 -25
- package/dist/hooks/useFilters.js +0 -120
- package/dist/hooks/useForm.js +0 -22
- package/dist/hooks/useFormAutosave.js +0 -67
- package/dist/hooks/useIntersectionObserver.js +0 -27
- package/dist/hooks/useLocalStorage.js +0 -63
- package/dist/hooks/useLongPressRepeat.js +0 -33
- package/dist/hooks/usePagination.js +0 -35
- package/dist/hooks/useScrollableListBox.js +0 -30
- package/dist/hooks/useSingletonMutation.d.ts +0 -4
- package/dist/hooks/useSingletonMutation.js +0 -27
- package/dist/hooks/useSorting.js +0 -30
- package/dist/hooks/useStateAndRef.js +0 -17
- package/dist/hooks/useTableColumnConfig.js +0 -59
- package/dist/hooks/useTableNav.js +0 -409
- package/dist/hooks/useTranslationMemo.js +0 -14
- package/dist/index.js +0 -280
- package/dist/utils/array.utils.js +0 -12
- package/dist/utils/compoundMapper.js +0 -14
- package/dist/utils/date-time.utils.js +0 -77
- package/dist/utils/date.utils.js +0 -12
- package/dist/utils/dom.utils.js +0 -13
- package/dist/utils/file.utils.js +0 -63
- package/dist/utils/isEqual.js +0 -94
- package/dist/utils/logger.js +0 -19
- package/dist/utils/object.utils.js +0 -53
- package/dist/utils/queries.utils.js +0 -9
- package/dist/utils/rest/interceptors/logging.interceptor.d.ts +0 -2
- package/dist/utils/rest/interceptors/logging.interceptor.js +0 -17
- package/dist/utils/rest/interceptors/response.interceptor.d.ts +0 -2
- package/dist/utils/rest/interceptors/response.interceptor.js +0 -25
- package/dist/utils/rest/interceptors/rest-interceptor.js +0 -21
- package/dist/utils/rest/rest-client.js +0 -62
- package/dist/utils/rest/rest.utils.js +0 -51
- package/dist/utils/routing.utils.js +0 -15
- package/dist/utils/string.utils.js +0 -12
- package/dist/utils/vendor/error-handling.js +0 -119
- package/dist/utils/zod.utils.js +0 -25
- /package/{dist → src}/assets/icons/AlignCenter.d.ts +0 -0
- /package/{dist → src}/assets/icons/AlignLeft.d.ts +0 -0
- /package/{dist → src}/assets/icons/AlignLeftRight.d.ts +0 -0
- /package/{dist → src}/assets/icons/AlignRight.d.ts +0 -0
- /package/{dist → src}/assets/icons/ArrowDropDown.d.ts +0 -0
- /package/{dist → src}/assets/icons/ArrowDropUp.d.ts +0 -0
- /package/{dist → src}/assets/icons/ArrowLeft.d.ts +0 -0
- /package/{dist → src}/assets/icons/ArrowRight.d.ts +0 -0
- /package/{dist → src}/assets/icons/Bold.d.ts +0 -0
- /package/{dist → src}/assets/icons/BulletedList.d.ts +0 -0
- /package/{dist → src}/assets/icons/Calendar.d.ts +0 -0
- /package/{dist → src}/assets/icons/Check.d.ts +0 -0
- /package/{dist → src}/assets/icons/CheckCircle.d.ts +0 -0
- /package/{dist → src}/assets/icons/CheckboxCheckmark.d.ts +0 -0
- /package/{dist → src}/assets/icons/CheckboxIndeterminate.d.ts +0 -0
- /package/{dist → src}/assets/icons/ChevronDown.d.ts +0 -0
- /package/{dist → src}/assets/icons/ChevronLeft.d.ts +0 -0
- /package/{dist → src}/assets/icons/ChevronRight.d.ts +0 -0
- /package/{dist → src}/assets/icons/ChevronUp.d.ts +0 -0
- /package/{dist → src}/assets/icons/ChevronsLeft.d.ts +0 -0
- /package/{dist → src}/assets/icons/ChevronsRight.d.ts +0 -0
- /package/{dist → src}/assets/icons/Clock.d.ts +0 -0
- /package/{dist → src}/assets/icons/Close.d.ts +0 -0
- /package/{dist → src}/assets/icons/DateTime.d.ts +0 -0
- /package/{dist → src}/assets/icons/Drag.d.ts +0 -0
- /package/{dist → src}/assets/icons/File.d.ts +0 -0
- /package/{dist → src}/assets/icons/Highlight.d.ts +0 -0
- /package/{dist → src}/assets/icons/HighlightOn.d.ts +0 -0
- /package/{dist → src}/assets/icons/Info.d.ts +0 -0
- /package/{dist → src}/assets/icons/Italic.d.ts +0 -0
- /package/{dist → src}/assets/icons/Link.d.ts +0 -0
- /package/{dist → src}/assets/icons/Menu.d.ts +0 -0
- /package/{dist → src}/assets/icons/NumberedList.d.ts +0 -0
- /package/{dist → src}/assets/icons/PointerHorizontal.d.ts +0 -0
- /package/{dist → src}/assets/icons/PointerVertical.d.ts +0 -0
- /package/{dist → src}/assets/icons/Send.d.ts +0 -0
- /package/{dist → src}/assets/icons/Strikethrough.d.ts +0 -0
- /package/{dist → src}/assets/icons/TextColor.d.ts +0 -0
- /package/{dist → src}/assets/icons/Today.d.ts +0 -0
- /package/{dist → src}/assets/icons/Underlined.d.ts +0 -0
- /package/{dist → src}/assets/icons/Upload.d.ts +0 -0
- /package/{dist → src}/assets/icons/View.d.ts +0 -0
- /package/{dist → src}/assets/icons/ViewOff.d.ts +0 -0
- /package/{dist/assets/icons/Warningfilled.d.ts → src/assets/icons/WarningFilled.d.ts} +0 -0
- /package/{dist → src}/components/Menu/Menu.d.ts +0 -0
- /package/{dist → src}/components/buttons/shared/buttonContent.cva.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/Calendar.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/CalendarCell.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/CalendarGrid.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/CalendarSelectHeader.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/DateField.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/DateSegmentItem.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/DateTimeDialog.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/DateTimeDialogFooter.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/MonthPicker.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/RangeCalendar.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/TimeField.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/TimePickerForm.d.ts +0 -0
- /package/{dist → src}/components/inputs/DateTime/shared/YearPicker.d.ts +0 -0
- /package/{dist → src}/components/inputs/File/FileUpload.d.ts +0 -0
- /package/{dist → src}/components/inputs/File/FileUploadContainer.d.ts +0 -0
- /package/{dist → src}/components/inputs/File/InputUpload.d.ts +0 -0
- /package/{dist → src}/components/inputs/File/index.d.ts +0 -0
- /package/{dist → src}/components/inputs/File/shared/FileProgressBar.d.ts +0 -0
- /package/{dist → src}/components/inputs/File/shared/InputUploadFilled.d.ts +0 -0
- /package/{dist → src}/components/inputs/File/shared/fileUpload.cva.d.ts +0 -0
- /package/{dist → src}/components/inputs/File/shared/inputUploadButton.cva.d.ts +0 -0
- /package/{dist → src}/components/inputs/FormField/FormFieldError.d.ts +0 -0
- /package/{dist → src}/components/inputs/FormField/FormFieldHeader.d.ts +0 -0
- /package/{dist → src}/components/inputs/FormField/FormFieldHeaderClose.d.ts +0 -0
- /package/{dist → src}/components/inputs/Inputs/Inputs.d.ts +0 -0
- /package/{dist → src}/components/inputs/Selection/shared/SelectListBoxSelectionBar.d.ts +0 -0
- /package/{dist → src}/components/inputs/TextEditor/Toolbar/ColorPicker.d.ts +0 -0
- /package/{dist → src}/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.d.ts +0 -0
- /package/{dist → src}/components/inputs/TextEditor/Toolbar/TextEditorToolbar.d.ts +0 -0
- /package/{dist → src}/components/inputs/TextEditor/textEditor.types.d.ts +0 -0
- /package/{dist → src}/components/inputs/shared/form.types.d.ts +0 -0
- /package/{dist → src}/components/inputs/shared/input.cva.d.ts +0 -0
- /package/{dist → src}/components/outline.clsx.d.ts +0 -0
- /package/{dist → src}/components/overlays/BottomSheet/BottomSheet.d.ts +0 -0
- /package/{dist → src}/components/overlays/Drawer/Drawer.d.ts +0 -0
- /package/{dist → src}/components/overlays/Modal/modal.cva.d.ts +0 -0
- /package/{dist → src}/components/overlays/ResponsivePopover/ResponsivePopover.d.ts +0 -0
- /package/{dist → src}/components/overlays/Tooltip/TooltipEllipsis.d.ts +0 -0
- /package/{dist → src}/components/segment/Segment.d.ts +0 -0
- /package/{dist → src}/components/segment/SegmentItem.d.ts +0 -0
- /package/{dist → src}/components/shared/pagination/Pagination.d.ts +0 -0
- /package/{dist → src}/components/shared/pagination/minWidth.cva.d.ts +0 -0
- /package/{dist → src}/components/status/Alert/alert.cva.d.ts +0 -0
- /package/{dist → src}/components/status/Loader/loader.cva.d.ts +0 -0
- /package/{dist → src}/components/status/Toast/useToast.d.ts +0 -0
- /package/{dist → src}/components/status/shared/status.cva.d.ts +0 -0
- /package/{dist → src}/components/table/CellText.d.ts +0 -0
- /package/{dist → src}/components/table/ColumnConfig.d.ts +0 -0
- /package/{dist → src}/components/table/HeaderText.d.ts +0 -0
- /package/{dist → src}/components/table/InfiniteTable.d.ts +0 -0
- /package/{dist → src}/components/table/PaginatedTable.d.ts +0 -0
- /package/{dist → src}/components/table/Table.d.ts +0 -0
- /package/{dist → src}/components/text/Link/link.cva.d.ts +0 -0
- /package/{dist → src}/components/text/Tag/tag.cva.d.ts +0 -0
- /package/{dist → src}/components/text/Typography/typography.cva.d.ts +0 -0
- /package/{dist → src}/config/i18n.d.ts +0 -0
- /package/{dist → src}/config/router.context.d.ts +0 -0
- /package/{dist → src}/helpers/dynamicColumns.d.ts +0 -0
- /package/{dist → src}/hooks/useAutosave.d.ts +0 -0
- /package/{dist → src}/hooks/useBreakpoint.d.ts +0 -0
- /package/{dist → src}/hooks/useDebounceCallback.d.ts +0 -0
- /package/{dist → src}/hooks/useDeepCompare.d.ts +0 -0
- /package/{dist → src}/hooks/useFilters.d.ts +0 -0
- /package/{dist → src}/hooks/useForm.d.ts +0 -0
- /package/{dist → src}/hooks/useIntersectionObserver.d.ts +0 -0
- /package/{dist → src}/hooks/useLocalStorage.d.ts +0 -0
- /package/{dist → src}/hooks/useLongPressRepeat.d.ts +0 -0
- /package/{dist → src}/hooks/usePagination.d.ts +0 -0
- /package/{dist → src}/hooks/useScrollableListBox.d.ts +0 -0
- /package/{dist → src}/hooks/useSorting.d.ts +0 -0
- /package/{dist → src}/hooks/useStateAndRef.d.ts +0 -0
- /package/{dist → src}/hooks/useTableColumnConfig.d.ts +0 -0
- /package/{dist → src}/hooks/useTableNav.d.ts +0 -0
- /package/{dist → src}/hooks/useTranslationMemo.d.ts +0 -0
- /package/{dist → src}/types/common.d.ts +0 -0
- /package/{dist → src}/utils/array.utils.d.ts +0 -0
- /package/{dist → src}/utils/array.utils.spec.d.ts +0 -0
- /package/{dist → src}/utils/compoundMapper.d.ts +0 -0
- /package/{dist → src}/utils/compoundMapper.spec.d.ts +0 -0
- /package/{dist → src}/utils/date-time.utils.d.ts +0 -0
- /package/{dist → src}/utils/date-time.utils.spec.d.ts +0 -0
- /package/{dist → src}/utils/date.utils.d.ts +0 -0
- /package/{dist → src}/utils/date.utils.spec.d.ts +0 -0
- /package/{dist → src}/utils/dom.utils.d.ts +0 -0
- /package/{dist → src}/utils/file.utils.d.ts +0 -0
- /package/{dist → src}/utils/isEqual.d.ts +0 -0
- /package/{dist → src}/utils/logger.d.ts +0 -0
- /package/{dist → src}/utils/object.utils.d.ts +0 -0
- /package/{dist → src}/utils/queries.utils.d.ts +0 -0
- /package/{dist/utils/rest → src/utils}/rest.utils.d.ts +0 -0
- /package/{dist → src}/utils/routing.utils.d.ts +0 -0
- /package/{dist → src}/utils/string.utils.d.ts +0 -0
- /package/{dist → src}/utils/vendor/error-handling.d.ts +0 -0
- /package/{dist/utils/rest/interceptors → src/utils/vendor}/rest-interceptor.d.ts +0 -0
- /package/{dist/styles → styles}/editor.css +0 -0
- /package/{dist/styles → styles}/index.css +0 -0
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import i18next from "i18next";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { StringUtils } from "../utils/string.utils.js";
|
|
4
|
-
import { ZodUtils } from "../utils/zod.utils.js";
|
|
5
|
-
const defaultComponentTypes = {
|
|
6
|
-
datetime: "datePicker",
|
|
7
|
-
dateRange: "dateRangePicker",
|
|
8
|
-
textEditor: "textEditor",
|
|
9
|
-
boolean: "toggle",
|
|
10
|
-
number: "numberInput",
|
|
11
|
-
enum: "select",
|
|
12
|
-
string: "textInput",
|
|
13
|
-
email: "textInput",
|
|
14
|
-
object: "unknown",
|
|
15
|
-
array: "select",
|
|
16
|
-
unknown: "unknown"
|
|
17
|
-
};
|
|
18
|
-
const ZOD_TYPE_COMPONENT_TYPE = [
|
|
19
|
-
[z.ZodBoolean, defaultComponentTypes.boolean],
|
|
20
|
-
[z.ZodNumber, defaultComponentTypes.number],
|
|
21
|
-
[z.ZodEnum, defaultComponentTypes.enum],
|
|
22
|
-
[z.ZodISODateTime, defaultComponentTypes.datetime],
|
|
23
|
-
[z.ZodString, defaultComponentTypes.string],
|
|
24
|
-
[z.ZodEmail, defaultComponentTypes.email],
|
|
25
|
-
[z.ZodObject, defaultComponentTypes.object],
|
|
26
|
-
[z.ZodArray, defaultComponentTypes.array]
|
|
27
|
-
];
|
|
28
|
-
const DEFAULT_NAMESPACE = "dynamicInputs";
|
|
29
|
-
const sortInputDefs = (inputDefs, orderKeys) => {
|
|
30
|
-
if (!orderKeys) {
|
|
31
|
-
return inputDefs;
|
|
32
|
-
}
|
|
33
|
-
return inputDefs.sort((a, b) => {
|
|
34
|
-
const orderMap = new Map(orderKeys.map((key, index) => [key, index]));
|
|
35
|
-
const orderA = orderMap.get(a.name);
|
|
36
|
-
const orderB = orderMap.get(b.name);
|
|
37
|
-
if (orderA !== void 0 && orderB !== void 0) {
|
|
38
|
-
return orderA - orderB;
|
|
39
|
-
}
|
|
40
|
-
if (orderA !== void 0 && orderB === void 0) {
|
|
41
|
-
return -1;
|
|
42
|
-
}
|
|
43
|
-
if (orderA === void 0 && orderB !== void 0) {
|
|
44
|
-
return 1;
|
|
45
|
-
}
|
|
46
|
-
return 0;
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
const excludeEntries = (entries) => {
|
|
50
|
-
return entries.filter(([, value]) => value !== false && value !== void 0);
|
|
51
|
-
};
|
|
52
|
-
const inputConfigToObjectDefinition = (value) => {
|
|
53
|
-
if (typeof value === "object") {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
if (typeof value === "function") {
|
|
57
|
-
return { render: value };
|
|
58
|
-
}
|
|
59
|
-
return {};
|
|
60
|
-
};
|
|
61
|
-
const convertInputsConfigToObjectDefinitions = (entries) => {
|
|
62
|
-
return entries.map(([key, value]) => {
|
|
63
|
-
const k = key;
|
|
64
|
-
return [k, inputConfigToObjectDefinition(value)];
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
const getDefaultInputComponentType = (schemaType) => {
|
|
68
|
-
if (ZodUtils.isDateRange(schemaType)) {
|
|
69
|
-
return defaultComponentTypes.dateRange;
|
|
70
|
-
}
|
|
71
|
-
if (ZodUtils.isTextEditor(schemaType)) {
|
|
72
|
-
return defaultComponentTypes.textEditor;
|
|
73
|
-
}
|
|
74
|
-
const unwrappedType = ZodUtils.unwrapZodType(schemaType);
|
|
75
|
-
const componentType = ZOD_TYPE_COMPONENT_TYPE.find(([zodType]) => unwrappedType instanceof zodType)?.[1];
|
|
76
|
-
if (componentType) {
|
|
77
|
-
return componentType;
|
|
78
|
-
}
|
|
79
|
-
return defaultComponentTypes.unknown;
|
|
80
|
-
};
|
|
81
|
-
const getDefaultSelectionItems = (keyType) => {
|
|
82
|
-
const unwrappedType = ZodUtils.unwrapZodType(keyType instanceof z.ZodArray ? keyType.element : keyType);
|
|
83
|
-
if (unwrappedType instanceof z.ZodEnum) {
|
|
84
|
-
return Object.values(unwrappedType.options).filter((value) => typeof value === "string").map((value) => ({ id: value, label: StringUtils.capitalize(value) }));
|
|
85
|
-
}
|
|
86
|
-
return [];
|
|
87
|
-
};
|
|
88
|
-
const getDefaultSelectionMode = (keyType) => {
|
|
89
|
-
return keyType instanceof z.ZodArray ? "multiple" : "single";
|
|
90
|
-
};
|
|
91
|
-
const getDefaultProps = (componentType, keyType) => {
|
|
92
|
-
const props = {};
|
|
93
|
-
const unwrappedType = ZodUtils.unwrapZodType(keyType);
|
|
94
|
-
if (["select", "autocomplete", "segment"].includes(componentType)) {
|
|
95
|
-
props.items = getDefaultSelectionItems(unwrappedType);
|
|
96
|
-
}
|
|
97
|
-
if (["select", "autocomplete", "queryAutocomplete", "segment"].includes(componentType)) {
|
|
98
|
-
props.selectionMode = getDefaultSelectionMode(unwrappedType);
|
|
99
|
-
}
|
|
100
|
-
return props;
|
|
101
|
-
};
|
|
102
|
-
const getLabelAndPlaceholder = (value, options, schemaKey) => {
|
|
103
|
-
const namespace = options.namespace ?? DEFAULT_NAMESPACE;
|
|
104
|
-
const stringKey = String(schemaKey);
|
|
105
|
-
let { label, placeholder } = value;
|
|
106
|
-
if (!label) {
|
|
107
|
-
const key = `${namespace}.${stringKey}.label`;
|
|
108
|
-
const translation = i18next.exists(key) ? i18next.t(key) : null;
|
|
109
|
-
label = typeof translation === "string" ? translation : StringUtils.capitalize(stringKey);
|
|
110
|
-
}
|
|
111
|
-
if (!placeholder) {
|
|
112
|
-
const key = `${namespace}.${stringKey}.placeholder`;
|
|
113
|
-
const translation = i18next.exists(key) ? i18next.t(key) : null;
|
|
114
|
-
placeholder = typeof translation === "string" ? translation : void 0;
|
|
115
|
-
}
|
|
116
|
-
return { label, placeholder };
|
|
117
|
-
};
|
|
118
|
-
const overridePresetLabelsAndPlaceholders = (presetInputDefs, options) => {
|
|
119
|
-
const namespace = options.namespace ?? DEFAULT_NAMESPACE;
|
|
120
|
-
return presetInputDefs.map((inputDef) => {
|
|
121
|
-
const labelName = String(inputDef.name);
|
|
122
|
-
const labelKey = `${namespace}.${labelName}.label`;
|
|
123
|
-
const placeholderKey = `${namespace}.${labelName}.placeholder`;
|
|
124
|
-
const labelTranslation = i18next.exists(labelKey) ? i18next.t(labelKey) : null;
|
|
125
|
-
const placeholderTranslation = i18next.exists(placeholderKey) ? i18next.t(placeholderKey) : null;
|
|
126
|
-
return {
|
|
127
|
-
...inputDef,
|
|
128
|
-
label: typeof labelTranslation === "string" ? labelTranslation : inputDef.label,
|
|
129
|
-
placeholder: typeof placeholderTranslation === "string" ? placeholderTranslation : inputDef.placeholder
|
|
130
|
-
};
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
const removeOverriddenPresetInputs = (presetInputs, options) => {
|
|
134
|
-
if (presetInputs.length === 0) {
|
|
135
|
-
return presetInputs;
|
|
136
|
-
}
|
|
137
|
-
const usedKeys = Object.entries(options.inputs ?? {}).map(([key]) => String(key));
|
|
138
|
-
return presetInputs.filter((input) => !usedKeys.includes(String(input.name)));
|
|
139
|
-
};
|
|
140
|
-
const validateParams = (schema, presetInputs, options) => {
|
|
141
|
-
const { inputs, order, includeAll } = options;
|
|
142
|
-
if (!order) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const inputKeys = Object.keys(inputs ?? {});
|
|
146
|
-
const presetKeys = presetInputs.map((input) => input.name).filter((name) => name !== void 0);
|
|
147
|
-
const schemaKeys = includeAll ? Object.keys(schema.shape) : [];
|
|
148
|
-
const allInputKeys = /* @__PURE__ */ new Set([...inputKeys, ...presetKeys, ...schemaKeys]);
|
|
149
|
-
const unnecessaryOrderKeys = order.filter((key) => !allInputKeys.has(key));
|
|
150
|
-
if (unnecessaryOrderKeys.length > 0) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
`Found unnecessary keys in "order": [${unnecessaryOrderKeys.join(", ")}]. These keys are not found in any of the input definitions.
|
|
153
|
-
All defined input keys are: [${Array.from(allInputKeys).join(", ")}].
|
|
154
|
-
In the case of a preset input definition, the key is the name attribute.`
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const populateInputDef = (schema, schemaKey, value, options) => {
|
|
159
|
-
const name = String(schemaKey);
|
|
160
|
-
const { label, placeholder } = getLabelAndPlaceholder(value, options, schemaKey);
|
|
161
|
-
const inputWrapper = value.inputWrapper ?? options.globalInputWrapper;
|
|
162
|
-
if ("render" in value) {
|
|
163
|
-
return {
|
|
164
|
-
name,
|
|
165
|
-
render: value.render
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
const schemaKeyType = schema.shape[schemaKey];
|
|
169
|
-
const componentType = "type" in value ? value.type : getDefaultInputComponentType(schemaKeyType);
|
|
170
|
-
const defaultProps = componentType ? getDefaultProps(componentType, schemaKeyType) : {};
|
|
171
|
-
const props = { ...defaultProps, ...options.globalProps, ...value.props };
|
|
172
|
-
return {
|
|
173
|
-
type: componentType === "unknown" ? null : componentType,
|
|
174
|
-
name,
|
|
175
|
-
label,
|
|
176
|
-
placeholder,
|
|
177
|
-
inputWrapper,
|
|
178
|
-
props
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
const addMissingSchemaFields = (schema, existingInputDefs, options) => {
|
|
182
|
-
const schemaFields = Object.keys(schema.shape);
|
|
183
|
-
const definedFields = new Set(existingInputDefs.map((def) => def.name));
|
|
184
|
-
const missingFields = schemaFields.filter((field) => !definedFields.has(field));
|
|
185
|
-
const additionalInputDefs = missingFields.map((field) => {
|
|
186
|
-
return populateInputDef(schema, field, {}, options);
|
|
187
|
-
});
|
|
188
|
-
return [...existingInputDefs, ...additionalInputDefs];
|
|
189
|
-
};
|
|
190
|
-
const dynamicInputs = ({
|
|
191
|
-
schema,
|
|
192
|
-
preset = [],
|
|
193
|
-
options
|
|
194
|
-
}) => {
|
|
195
|
-
validateParams(schema, preset, options);
|
|
196
|
-
let entries = Object.entries(options.inputs ?? {});
|
|
197
|
-
entries = excludeEntries(entries);
|
|
198
|
-
const dynamicInputDefs = convertInputsConfigToObjectDefinitions(entries);
|
|
199
|
-
const inputDefs = dynamicInputDefs.map(([key, value]) => {
|
|
200
|
-
return populateInputDef(schema, key, value, options);
|
|
201
|
-
});
|
|
202
|
-
let presetInputDefs = removeOverriddenPresetInputs(preset, options);
|
|
203
|
-
if (options.overridePresetLocales) {
|
|
204
|
-
presetInputDefs = overridePresetLabelsAndPlaceholders(presetInputDefs, options);
|
|
205
|
-
}
|
|
206
|
-
const mergedInputDefs = [...presetInputDefs, ...inputDefs];
|
|
207
|
-
const allInputDefs = options.includeAll ? addMissingSchemaFields(schema, mergedInputDefs, options) : mergedInputDefs;
|
|
208
|
-
return sortInputDefs(allInputDefs, options.order);
|
|
209
|
-
};
|
|
210
|
-
export {
|
|
211
|
-
dynamicInputs,
|
|
212
|
-
getDefaultInputComponentType,
|
|
213
|
-
getDefaultSelectionMode
|
|
214
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect } from "react";
|
|
2
|
-
import { useFormState, useWatch } from "react-hook-form";
|
|
3
|
-
import { isEqual } from "../utils/isEqual.js";
|
|
4
|
-
import { ObjectUtils } from "../utils/object.utils.js";
|
|
5
|
-
function isNilOrEqual(left, right) {
|
|
6
|
-
if (ObjectUtils.isNil(left) && ObjectUtils.isNil(right)) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
return isEqual(left, right);
|
|
10
|
-
}
|
|
11
|
-
function diffLeftOnly(left, right, shallowKeys) {
|
|
12
|
-
if (!ObjectUtils.isObject(left) || ObjectUtils.isDate(left) || ObjectUtils.isRegExp(left)) {
|
|
13
|
-
return !isNilOrEqual(left, right) ? left : void 0;
|
|
14
|
-
}
|
|
15
|
-
if (Array.isArray(left)) {
|
|
16
|
-
return !isNilOrEqual(left, right) ? left : void 0;
|
|
17
|
-
}
|
|
18
|
-
const result = Object.entries(left).reduce((acc, [key, value]) => {
|
|
19
|
-
const shallowSubtree = shallowKeys?.[key];
|
|
20
|
-
if (shallowSubtree === true) {
|
|
21
|
-
if (!isNilOrEqual(value, right?.[key])) {
|
|
22
|
-
acc[key] = value;
|
|
23
|
-
}
|
|
24
|
-
return acc;
|
|
25
|
-
}
|
|
26
|
-
const diff = diffLeftOnly(value, right?.[key], shallowSubtree);
|
|
27
|
-
if (diff !== void 0 && (!ObjectUtils.isObject(diff) || !ObjectUtils.isEmpty(diff))) {
|
|
28
|
-
acc[key] = diff;
|
|
29
|
-
}
|
|
30
|
-
return acc;
|
|
31
|
-
}, {});
|
|
32
|
-
return ObjectUtils.isEmpty(result) ? void 0 : result;
|
|
33
|
-
}
|
|
34
|
-
function useAutosave({
|
|
35
|
-
form,
|
|
36
|
-
delay = 500,
|
|
37
|
-
enabled = true,
|
|
38
|
-
onSave,
|
|
39
|
-
onSaveSuccess
|
|
40
|
-
}) {
|
|
41
|
-
const timeoutRef = useRef(void 0);
|
|
42
|
-
const { control, reset, handleSubmit } = form;
|
|
43
|
-
const { dirtyFields, defaultValues } = useFormState({ control });
|
|
44
|
-
const formData = useWatch({ control });
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (!enabled || Object.keys(dirtyFields).length === 0) {
|
|
47
|
-
return void 0;
|
|
48
|
-
}
|
|
49
|
-
if (timeoutRef.current) {
|
|
50
|
-
clearTimeout(timeoutRef.current);
|
|
51
|
-
}
|
|
52
|
-
timeoutRef.current = setTimeout(() => {
|
|
53
|
-
handleSubmit(async (data) => {
|
|
54
|
-
const dirtyData = Object.entries(dirtyFields).filter(([, value]) => value).reduce((acc, [key]) => ({ ...acc, [key]: data[key] }), {});
|
|
55
|
-
const changedData = diffLeftOnly(dirtyData, defaultValues, dirtyFields) ?? {};
|
|
56
|
-
if (Object.keys(changedData).length === 0) {
|
|
57
|
-
return void 0;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
reset(void 0, { keepValues: true });
|
|
61
|
-
await onSave(changedData);
|
|
62
|
-
onSaveSuccess?.();
|
|
63
|
-
} catch {
|
|
64
|
-
reset(defaultValues);
|
|
65
|
-
return void 0;
|
|
66
|
-
}
|
|
67
|
-
return void 0;
|
|
68
|
-
})();
|
|
69
|
-
return void 0;
|
|
70
|
-
}, delay);
|
|
71
|
-
return () => {
|
|
72
|
-
if (timeoutRef.current) {
|
|
73
|
-
clearTimeout(timeoutRef.current);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}, [defaultValues, dirtyFields, formData, delay, onSave, handleSubmit, enabled, reset]);
|
|
77
|
-
}
|
|
78
|
-
export {
|
|
79
|
-
useAutosave
|
|
80
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import { useMediaQuery } from "react-responsive";
|
|
3
|
-
function getBreakpoints() {
|
|
4
|
-
const cs = getComputedStyle(document.documentElement);
|
|
5
|
-
const entries = ["sm", "md", "lg", "xl", "2xl"].map((k) => [k, cs.getPropertyValue(`--breakpoint-${k}`).trim()]).filter(([, v]) => !!v);
|
|
6
|
-
return Object.fromEntries(entries);
|
|
7
|
-
}
|
|
8
|
-
function useBreakpoint(breakpointKey) {
|
|
9
|
-
const breakpoints = useMemo(() => getBreakpoints(), []);
|
|
10
|
-
if (!breakpoints) {
|
|
11
|
-
throw new Error("Tailwind config is missing theme.screens");
|
|
12
|
-
}
|
|
13
|
-
const bool = useMediaQuery({
|
|
14
|
-
query: `(min-width: ${breakpoints[breakpointKey]})`
|
|
15
|
-
});
|
|
16
|
-
return bool;
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
useBreakpoint
|
|
20
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useRef, useState, useCallback, useEffect } from "react";
|
|
2
|
-
function useDebounceCallback(callback, { delay = 500 } = {}) {
|
|
3
|
-
const timeoutRef = useRef(null);
|
|
4
|
-
const [isDebouncing, setIsDebouncing] = useState(false);
|
|
5
|
-
const debouncedCallback = useCallback(
|
|
6
|
-
(...args) => {
|
|
7
|
-
if (timeoutRef.current) {
|
|
8
|
-
clearTimeout(timeoutRef.current);
|
|
9
|
-
}
|
|
10
|
-
setIsDebouncing(true);
|
|
11
|
-
timeoutRef.current = setTimeout(() => {
|
|
12
|
-
setIsDebouncing(false);
|
|
13
|
-
callback?.(...args);
|
|
14
|
-
}, delay);
|
|
15
|
-
},
|
|
16
|
-
[callback, delay]
|
|
17
|
-
);
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
return () => {
|
|
20
|
-
if (timeoutRef.current) {
|
|
21
|
-
clearTimeout(timeoutRef.current);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}, []);
|
|
25
|
-
return { callback: debouncedCallback, isDebouncing };
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
useDebounceCallback
|
|
29
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
2
|
-
import { isEqual } from "../utils/isEqual.js";
|
|
3
|
-
const useDeepCompareEffect = (callback, dependencies) => {
|
|
4
|
-
return useEffect(callback, useDeepCompareDeps(dependencies));
|
|
5
|
-
};
|
|
6
|
-
const useDeepCompareLayoutEffect = (callback, dependencies) => {
|
|
7
|
-
return useLayoutEffect(callback, useDeepCompareDeps(dependencies));
|
|
8
|
-
};
|
|
9
|
-
const useDeepCompareMemo = (factory, dependencies) => {
|
|
10
|
-
return useMemo(factory, useDeepCompareDeps(dependencies));
|
|
11
|
-
};
|
|
12
|
-
const useDeepCompareDeps = (value) => {
|
|
13
|
-
const ref = useRef(void 0);
|
|
14
|
-
const signalRef = useRef(0);
|
|
15
|
-
if (!isEqual(value, ref.current)) {
|
|
16
|
-
ref.current = value;
|
|
17
|
-
signalRef.current += 1;
|
|
18
|
-
}
|
|
19
|
-
return [signalRef.current];
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
useDeepCompareEffect,
|
|
23
|
-
useDeepCompareLayoutEffect,
|
|
24
|
-
useDeepCompareMemo
|
|
25
|
-
};
|
package/dist/hooks/useFilters.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import { UIRouter } from "../config/router.context.js";
|
|
3
|
-
const serializeFiltersToQuery = (filterData, prefix) => {
|
|
4
|
-
const query = {};
|
|
5
|
-
for (const [key, value] of Object.entries(filterData)) {
|
|
6
|
-
if (value === null || value === void 0) {
|
|
7
|
-
continue;
|
|
8
|
-
}
|
|
9
|
-
const filterKey = `filter[${prefix && `${prefix}-`}${key}]`;
|
|
10
|
-
if (Array.isArray(value) || typeof value === "object") {
|
|
11
|
-
query[filterKey] = JSON.stringify(value);
|
|
12
|
-
} else if (typeof value === "boolean") {
|
|
13
|
-
query[filterKey] = value ? "true" : "false";
|
|
14
|
-
} else {
|
|
15
|
-
query[filterKey] = value;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return query;
|
|
19
|
-
};
|
|
20
|
-
const parseFilterFromQuery = (query) => {
|
|
21
|
-
const filter = {};
|
|
22
|
-
for (const [key, value] of Object.entries(query)) {
|
|
23
|
-
const match = /^filter\[(.+?)\]$/.exec(key);
|
|
24
|
-
if (!match) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const filterKey = match[1];
|
|
28
|
-
const isArray = value.startsWith("[") && value.endsWith("]");
|
|
29
|
-
const isObject = value.startsWith("{") && value.endsWith("}");
|
|
30
|
-
const isNumber = !Number.isNaN(Number(value)) && value !== "";
|
|
31
|
-
const isBoolean = ["true", "false"].includes(value);
|
|
32
|
-
if (isArray || isObject || isNumber) {
|
|
33
|
-
filter[filterKey] = JSON.parse(value);
|
|
34
|
-
} else if (isBoolean) {
|
|
35
|
-
filter[filterKey] = value === "true";
|
|
36
|
-
} else {
|
|
37
|
-
filter[filterKey] = value;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return filter;
|
|
41
|
-
};
|
|
42
|
-
const useFilters = (defaultFilterValues, prefix = "") => {
|
|
43
|
-
const { query, pathname, replace } = UIRouter.useUIRouter();
|
|
44
|
-
const queryFilters = parseFilterFromQuery(query);
|
|
45
|
-
const [filterData, setFilterData] = useState(queryFilters);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
const setUrlToDefaultFilters = () => {
|
|
48
|
-
const flatFilterQuery = serializeFiltersToQuery(defaultFilterValues, prefix);
|
|
49
|
-
replace({
|
|
50
|
-
pathname,
|
|
51
|
-
query: {
|
|
52
|
-
...query,
|
|
53
|
-
...flatFilterQuery
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const currentFilters = parseFilterFromQuery(query);
|
|
58
|
-
const hasFiltersSet = Object.keys(currentFilters).length > 0;
|
|
59
|
-
if (defaultFilterValues && !hasFiltersSet) {
|
|
60
|
-
setUrlToDefaultFilters();
|
|
61
|
-
}
|
|
62
|
-
}, [defaultFilterValues, prefix]);
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const newQueryFilters = parseFilterFromQuery(query);
|
|
65
|
-
setFilterData(newQueryFilters);
|
|
66
|
-
}, [query]);
|
|
67
|
-
const setFilterValue = (data) => {
|
|
68
|
-
let newFilters = { ...filterData };
|
|
69
|
-
const isReset = Object.keys(data).length === 0;
|
|
70
|
-
const isResetToDefault = data === defaultFilterValues;
|
|
71
|
-
if (isResetToDefault) {
|
|
72
|
-
newFilters = {
|
|
73
|
-
...defaultFilterValues
|
|
74
|
-
};
|
|
75
|
-
} else if (isReset) {
|
|
76
|
-
newFilters = {};
|
|
77
|
-
} else {
|
|
78
|
-
Object.entries(data).forEach(([key, value]) => {
|
|
79
|
-
if (value === void 0) {
|
|
80
|
-
delete newFilters[key];
|
|
81
|
-
} else {
|
|
82
|
-
newFilters[key] = value;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
const prefixPart = prefix ? `${prefix}-` : "";
|
|
87
|
-
const cleanedQuery = Object.keys(query).reduce(
|
|
88
|
-
(acc, k) => {
|
|
89
|
-
if (!k.startsWith(`filter[${prefixPart}`)) {
|
|
90
|
-
acc[k] = query[k];
|
|
91
|
-
}
|
|
92
|
-
return acc;
|
|
93
|
-
},
|
|
94
|
-
{}
|
|
95
|
-
);
|
|
96
|
-
const flatFilterQuery = serializeFiltersToQuery(newFilters, prefix);
|
|
97
|
-
replace({
|
|
98
|
-
pathname,
|
|
99
|
-
query: {
|
|
100
|
-
...cleanedQuery,
|
|
101
|
-
...flatFilterQuery
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
setFilterData(newFilters);
|
|
105
|
-
};
|
|
106
|
-
const getFilterValue = (keys) => {
|
|
107
|
-
const result = {};
|
|
108
|
-
keys.forEach((key) => {
|
|
109
|
-
result[key] = filterData[key];
|
|
110
|
-
});
|
|
111
|
-
return result;
|
|
112
|
-
};
|
|
113
|
-
const clearAllFilters = () => {
|
|
114
|
-
setFilterValue(defaultFilterValues ?? {});
|
|
115
|
-
};
|
|
116
|
-
return { filterData, setFilterValue, getFilterValue, clearAllFilters };
|
|
117
|
-
};
|
|
118
|
-
export {
|
|
119
|
-
useFilters
|
|
120
|
-
};
|
package/dist/hooks/useForm.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useForm as useForm$1 } from "react-hook-form";
|
|
4
|
-
function useForm({
|
|
5
|
-
resolver,
|
|
6
|
-
zodSchema,
|
|
7
|
-
defaultValues,
|
|
8
|
-
...props
|
|
9
|
-
}) {
|
|
10
|
-
const formResolver = useMemo(
|
|
11
|
-
() => resolver ?? (zodSchema ? zodResolver(zodSchema) : void 0),
|
|
12
|
-
[resolver, zodSchema]
|
|
13
|
-
);
|
|
14
|
-
return useForm$1({
|
|
15
|
-
...props,
|
|
16
|
-
resolver: formResolver,
|
|
17
|
-
defaultValues
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
useForm
|
|
22
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect } from "react";
|
|
2
|
-
import { useAutosave } from "./useAutosave.js";
|
|
3
|
-
import { useForm } from "./useForm.js";
|
|
4
|
-
import { ObjectUtils } from "../utils/object.utils.js";
|
|
5
|
-
const getResetTimeoutErrorMessage = (resetTimeout) => `Form Reset Timeout (${resetTimeout}ms) - Action Required
|
|
6
|
-
Problem: Form values weren't reset after submission.
|
|
7
|
-
|
|
8
|
-
Likely causes:
|
|
9
|
-
• Missing variables in reset dependency array
|
|
10
|
-
• Reset dependencies not updating after form save
|
|
11
|
-
• Async operations blocking timely reset
|
|
12
|
-
|
|
13
|
-
Solutions:
|
|
14
|
-
1. Ensure reset dependencies include all relevant state variables
|
|
15
|
-
2. Confirm your submission handler updates state properly (check query invalidation)
|
|
16
|
-
3. For slower operations, consider increasing the timeout threshold`;
|
|
17
|
-
function useFormAutosave({
|
|
18
|
-
autosaveDelay,
|
|
19
|
-
enableAutosave,
|
|
20
|
-
onAutosave,
|
|
21
|
-
getResetValues,
|
|
22
|
-
resetDeps,
|
|
23
|
-
resetTimeout = 5e3,
|
|
24
|
-
...props
|
|
25
|
-
}) {
|
|
26
|
-
const form = useForm({ ...props, defaultValues: getResetValues() });
|
|
27
|
-
const shouldResetFormValuesRef = useRef(false);
|
|
28
|
-
const resetFormValuesTimeoutRef = useRef(void 0);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const resetValues = getResetValues();
|
|
31
|
-
if (resetValues === void 0) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const resetFormValues = async () => {
|
|
35
|
-
const keepStateOptions = shouldResetFormValuesRef.current ? { keepDirtyValues: true } : void 0;
|
|
36
|
-
shouldResetFormValuesRef.current = false;
|
|
37
|
-
let values = resetValues;
|
|
38
|
-
if (ObjectUtils.isFunction(resetValues)) {
|
|
39
|
-
values = await resetValues();
|
|
40
|
-
}
|
|
41
|
-
form.reset(values, keepStateOptions);
|
|
42
|
-
};
|
|
43
|
-
resetFormValues();
|
|
44
|
-
}, [...resetDeps]);
|
|
45
|
-
const onSaveSuccess = () => {
|
|
46
|
-
shouldResetFormValuesRef.current = true;
|
|
47
|
-
if (resetFormValuesTimeoutRef.current) {
|
|
48
|
-
clearTimeout(resetFormValuesTimeoutRef.current);
|
|
49
|
-
}
|
|
50
|
-
resetFormValuesTimeoutRef.current = setTimeout(() => {
|
|
51
|
-
if (shouldResetFormValuesRef.current) {
|
|
52
|
-
throw new Error(getResetTimeoutErrorMessage(resetTimeout));
|
|
53
|
-
}
|
|
54
|
-
}, resetTimeout);
|
|
55
|
-
};
|
|
56
|
-
useAutosave({
|
|
57
|
-
form,
|
|
58
|
-
delay: autosaveDelay,
|
|
59
|
-
enabled: enableAutosave,
|
|
60
|
-
onSave: onAutosave,
|
|
61
|
-
onSaveSuccess
|
|
62
|
-
});
|
|
63
|
-
return form;
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
useFormAutosave
|
|
67
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
const useIntersectionObserver = ({
|
|
3
|
-
onIntersection,
|
|
4
|
-
root,
|
|
5
|
-
rootMargin,
|
|
6
|
-
threshold
|
|
7
|
-
}) => {
|
|
8
|
-
const [ref, setRef] = useState(null);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const observer = new IntersectionObserver(
|
|
11
|
-
(entries) => {
|
|
12
|
-
if (entries.some((entry) => entry.isIntersecting)) {
|
|
13
|
-
onIntersection?.();
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
{ root, rootMargin, threshold }
|
|
17
|
-
);
|
|
18
|
-
if (ref) {
|
|
19
|
-
observer.observe(ref);
|
|
20
|
-
}
|
|
21
|
-
return () => observer.disconnect();
|
|
22
|
-
}, [ref, root, rootMargin, threshold, onIntersection]);
|
|
23
|
-
return { setRef };
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
useIntersectionObserver
|
|
27
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback } from "react";
|
|
2
|
-
const useLocalStorage = ({ key, schema }) => {
|
|
3
|
-
const [value, setValue] = useState(null);
|
|
4
|
-
const [isInitialLoading, setIsInitialLoading] = useState(true);
|
|
5
|
-
const [error, setError] = useState(null);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (!localStorage) {
|
|
8
|
-
setValue(null);
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
try {
|
|
12
|
-
const lsValue = localStorage.getItem(key);
|
|
13
|
-
if (!lsValue) {
|
|
14
|
-
setValue(null);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
let jsonOrString;
|
|
18
|
-
try {
|
|
19
|
-
jsonOrString = JSON.parse(lsValue);
|
|
20
|
-
} catch {
|
|
21
|
-
jsonOrString = lsValue;
|
|
22
|
-
}
|
|
23
|
-
const parsedValue = schema.safeParse(jsonOrString);
|
|
24
|
-
if (parsedValue.success) {
|
|
25
|
-
setValue(parsedValue.data);
|
|
26
|
-
} else {
|
|
27
|
-
setError(parsedValue.error);
|
|
28
|
-
setValue(null);
|
|
29
|
-
}
|
|
30
|
-
} finally {
|
|
31
|
-
setIsInitialLoading(false);
|
|
32
|
-
}
|
|
33
|
-
}, [key, schema]);
|
|
34
|
-
const set = useCallback(
|
|
35
|
-
(newValue) => {
|
|
36
|
-
if (!localStorage) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const parsedValue = schema.safeParse(newValue);
|
|
40
|
-
if (!parsedValue.success) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (typeof parsedValue.data === "string") {
|
|
44
|
-
localStorage.setItem(key, parsedValue.data);
|
|
45
|
-
} else {
|
|
46
|
-
localStorage.setItem(key, JSON.stringify(parsedValue.data));
|
|
47
|
-
}
|
|
48
|
-
setValue(parsedValue.data);
|
|
49
|
-
},
|
|
50
|
-
[key, schema]
|
|
51
|
-
);
|
|
52
|
-
const remove = useCallback(() => {
|
|
53
|
-
if (!localStorage) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
localStorage.removeItem(key);
|
|
57
|
-
setValue(null);
|
|
58
|
-
}, [key]);
|
|
59
|
-
return { value, set, remove, error, isInitialLoading };
|
|
60
|
-
};
|
|
61
|
-
export {
|
|
62
|
-
useLocalStorage
|
|
63
|
-
};
|