@povio/ui 2.3.0-rc.9 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icons/AlignCenter.js +11 -26
- package/dist/assets/icons/AlignLeft.js +11 -26
- package/dist/assets/icons/AlignLeftRight.js +11 -26
- package/dist/assets/icons/AlignRight.js +11 -26
- package/dist/assets/icons/ArrowDropDown.js +11 -26
- package/dist/assets/icons/ArrowDropUp.js +11 -26
- package/dist/assets/icons/ArrowLeft.js +11 -26
- package/dist/assets/icons/ArrowRight.js +11 -26
- package/dist/assets/icons/Bold.js +11 -26
- package/dist/assets/icons/BulletedList.js +11 -26
- package/dist/assets/icons/Calendar.js +13 -28
- package/dist/assets/icons/Check.js +13 -28
- package/dist/assets/icons/CheckCircle.js +11 -26
- package/dist/assets/icons/CheckboxCheckmark.js +14 -29
- package/dist/assets/icons/CheckboxIndeterminate.js +14 -29
- package/dist/assets/icons/ChevronDown.js +13 -28
- package/dist/assets/icons/ChevronLeft.js +13 -28
- package/dist/assets/icons/ChevronRight.js +13 -28
- package/dist/assets/icons/ChevronUp.js +13 -28
- package/dist/assets/icons/ChevronsLeft.js +13 -28
- package/dist/assets/icons/ChevronsRight.js +13 -28
- package/dist/assets/icons/Clock.js +11 -26
- package/dist/assets/icons/Close.js +11 -26
- package/dist/assets/icons/DateTime.js +14 -35
- package/dist/assets/icons/DragIndicator.js +11 -26
- package/dist/assets/icons/File.js +13 -28
- package/dist/assets/icons/Highlight.js +11 -26
- package/dist/assets/icons/HighlightOn.js +15 -49
- package/dist/assets/icons/Home.js +11 -26
- package/dist/assets/icons/Info.js +16 -37
- package/dist/assets/icons/Italic.js +11 -26
- package/dist/assets/icons/Link.js +11 -26
- package/dist/assets/icons/Menu.js +11 -26
- package/dist/assets/icons/NumberedList.js +11 -26
- package/dist/assets/icons/PointerHorizontal.js +11 -26
- package/dist/assets/icons/PointerVertical.js +11 -26
- package/dist/assets/icons/Search.js +11 -26
- package/dist/assets/icons/Send.js +13 -28
- package/dist/assets/icons/Strikethrough.js +11 -26
- package/dist/assets/icons/TextColor.js +14 -48
- package/dist/assets/icons/Today.js +11 -26
- package/dist/assets/icons/Underlined.js +13 -28
- package/dist/assets/icons/Upload.js +14 -35
- package/dist/assets/icons/Visibility.js +11 -26
- package/dist/assets/icons/VisibilityOff.js +11 -26
- package/dist/assets/icons/WarningFilled.js +13 -28
- package/dist/components/Breadcrumbs/Breadcrumbs.js +56 -207
- package/dist/components/Menu/Menu.js +2 -18
- package/dist/components/Menu/MenuDesktop.js +7 -41
- package/dist/components/Menu/MenuItem.js +9 -32
- package/dist/components/Menu/MenuMobile.js +38 -97
- package/dist/components/Menu/MenuPopover.js +29 -105
- package/dist/components/buttons/IconButton/IconButton.js +8 -40
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -2
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +9 -34
- package/dist/components/buttons/PillButton/PillButton.js +17 -55
- package/dist/components/buttons/SplitButton/SplitButton.js +18 -103
- package/dist/components/buttons/TextButton/TextButton.js +8 -30
- package/dist/components/buttons/ToggleButton/ToggleButton.js +8 -28
- package/dist/components/buttons/shared/ButtonContent.js +22 -80
- package/dist/components/inputs/Checkbox/Checkbox.js +35 -172
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +10 -24
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +0 -3
- package/dist/components/inputs/Checkbox/checkbox.cva.js +1 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +5 -10
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +20 -121
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +5 -10
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +111 -215
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +5 -11
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +19 -123
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -5
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +104 -448
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +2 -5
- package/dist/components/inputs/DateTime/shared/Calendar.js +119 -330
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +102 -283
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +33 -142
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +93 -249
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +137 -318
- package/dist/components/inputs/DateTime/shared/DateField.js +112 -296
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +3 -6
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +136 -355
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +0 -14
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +11 -97
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +27 -81
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +10 -59
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +58 -103
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +82 -193
- package/dist/components/inputs/DateTime/shared/TimeField.js +8 -27
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +110 -279
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +65 -207
- package/dist/components/inputs/DateTime/shared/YearPicker.js +68 -119
- package/dist/components/inputs/File/FileUpload.js +44 -87
- package/dist/components/inputs/File/FileUploadContainer.js +7 -15
- package/dist/components/inputs/File/InputUpload.js +79 -317
- package/dist/components/inputs/File/shared/FileCard.js +41 -104
- package/dist/components/inputs/File/shared/FileCardList.js +12 -47
- package/dist/components/inputs/File/shared/FileUploadContent.js +44 -175
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +46 -149
- package/dist/components/inputs/File/shared/FileUploadContentError.js +93 -234
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +97 -230
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +55 -199
- package/dist/components/inputs/File/shared/InputUploadContent.js +34 -148
- package/dist/components/inputs/File/shared/InputUploadFilled.js +8 -49
- package/dist/components/inputs/File/shared/ProgressBar.js +9 -48
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormField.js +37 -119
- package/dist/components/inputs/FormField/FormFieldError.js +5 -25
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +22 -81
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +7 -31
- package/dist/components/inputs/FormField/FormFieldHelper.js +6 -26
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldLabel.js +9 -40
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +2 -5
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +88 -334
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +9 -48
- package/dist/components/inputs/Input/TextArea/TextArea.js +90 -305
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +1 -3
- package/dist/components/inputs/Input/TextInput/TextInput.js +79 -319
- package/dist/components/inputs/Input/shared/InputContent.js +59 -192
- package/dist/components/inputs/Inputs/Form.js +11 -40
- package/dist/components/inputs/Inputs/InputItem.d.ts +21 -16
- package/dist/components/inputs/Inputs/InputItem.js +14 -71
- package/dist/components/inputs/Inputs/Inputs.js +11 -37
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.js +60 -352
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +0 -17
- package/dist/components/inputs/RadioGroup/radio.cva.js +1 -42
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +2 -6
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +7 -109
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +18 -3
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +8 -34
- package/dist/components/inputs/Selection/Select/Select.d.ts +3 -7
- package/dist/components/inputs/Selection/Select/Select.js +5 -132
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -8
- package/dist/components/inputs/Selection/shared/SelectBase.js +18 -69
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +138 -393
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +116 -338
- package/dist/components/inputs/Selection/shared/SelectInputTags.js +25 -99
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +52 -164
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +35 -85
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +16 -69
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +21 -70
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +9 -58
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +3 -9
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -3
- package/dist/components/inputs/Selection/shared/select.context.js +34 -57
- package/dist/components/inputs/Selection/shared/select.types.d.ts +2 -3
- package/dist/components/inputs/Selection/shared/useSelectItems.js +49 -109
- package/dist/components/inputs/Slider/Slider.js +74 -250
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +0 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +98 -447
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +11 -37
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +30 -102
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +45 -194
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +28 -88
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +14 -48
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +19 -66
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +15 -49
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +32 -92
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +54 -126
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +38 -141
- package/dist/components/inputs/Toggle/Toggle.js +37 -189
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +0 -3
- package/dist/components/inputs/Toggle/toggle.cva.js +1 -2
- package/dist/components/inputs/shared/CheckContent.d.ts +1 -2
- package/dist/components/inputs/shared/CheckContent.js +11 -21
- package/dist/components/inputs/shared/InputClear.d.ts +1 -2
- package/dist/components/inputs/shared/InputClear.js +13 -79
- package/dist/components/inputs/shared/TooltipWrapper.js +11 -50
- package/dist/components/inputs/shared/input.cva.d.ts +0 -10
- package/dist/components/inputs/shared/input.cva.js +4 -32
- package/dist/components/navigation/Accordion/Accordion.js +22 -69
- package/dist/components/navigation/Accordion/AccordionItem.js +41 -86
- package/dist/components/navigation/Stepper/Stepper.js +22 -67
- package/dist/components/navigation/Stepper/StepperItem.js +31 -104
- package/dist/components/navigation/Stepper/StepperSeparator.js +5 -23
- package/dist/components/overlays/ActionModal/ActionModal.js +35 -169
- package/dist/components/overlays/BottomSheet/BottomSheet.js +49 -98
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +8 -48
- package/dist/components/overlays/Drawer/Drawer.js +20 -62
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +27 -83
- package/dist/components/overlays/Tooltip/Tooltip.js +28 -137
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +12 -37
- package/dist/components/segment/Segment.js +57 -218
- package/dist/components/segment/SegmentItem.js +10 -67
- package/dist/components/shared/pagination/Pagination.js +22 -108
- package/dist/components/shared/pagination/PaginationList.js +64 -167
- package/dist/components/status/Alert/Alert.js +30 -97
- package/dist/components/status/Loader/Loader.js +22 -77
- package/dist/components/status/Toast/Toast.js +13 -21
- package/dist/components/status/Toast/useToast.js +57 -62
- package/dist/components/table/ColumnConfig.js +54 -158
- package/dist/components/table/InfiniteTable.js +16 -67
- package/dist/components/table/PaginatedTable.js +18 -84
- package/dist/components/table/Table.js +27 -28
- package/dist/components/text/Link/Link.js +7 -19
- package/dist/components/text/Typography/Typography.js +8 -23
- package/dist/config/confirmation.context.js +1 -1
- package/dist/config/link.context.js +9 -23
- package/dist/config/router.context.js +16 -42
- package/dist/config/theme.context.js +45 -98
- package/dist/config/uiConfig.context.d.ts +6 -16
- package/dist/config/uiConfig.context.js +13 -56
- package/dist/config/uiStyle.context.d.ts +4 -27
- package/dist/config/uiStyle.context.js +5 -15
- package/dist/helpers/dynamicInputs.d.ts +5 -5
- package/dist/helpers/dynamicInputs.js +0 -3
- package/dist/hooks/useBreakpoint.js +3 -16
- package/dist/hooks/useDebounceCallback.js +17 -51
- package/dist/hooks/useFilters.js +64 -125
- package/dist/hooks/useForm.js +8 -42
- package/dist/hooks/useFormAutosave.js +30 -101
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +24 -91
- package/dist/hooks/useLocalStorage.js +10 -43
- package/dist/hooks/useLongPressRepeat.js +20 -55
- package/dist/hooks/usePagination.js +19 -49
- package/dist/hooks/useScrollableListBox.js +16 -37
- package/dist/hooks/useSorting.js +28 -69
- package/dist/hooks/useStateAndRef.js +7 -21
- package/dist/hooks/useTableColumnConfig.js +31 -124
- package/dist/hooks/useTranslationMemo.js +5 -25
- package/dist/index.d.ts +0 -7
- package/dist/index.js +3 -5
- package/dist/tw-ui-plugin.js +0 -2
- package/dist/utils/date-time.utils.d.ts +10 -31
- package/dist/utils/date-time.utils.js +22 -123
- package/dist/utils/dom.utils.js +1 -1
- package/package.json +1 -1
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +0 -4
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +0 -7
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +0 -13
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +0 -6
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +0 -21
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +0 -2
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +0 -1
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +0 -31
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +0 -80
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.spec.d.ts +0 -1
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +0 -6
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +0 -11
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +0 -45
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +0 -571
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +0 -35
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +0 -479
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +0 -4
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +0 -5
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +0 -1
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +0 -7
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +0 -36
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +0 -14
- package/dist/components/inputs/Selection/Select/QuerySelect.js +0 -122
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.d.ts +0 -9
- package/dist/components/inputs/Selection/shared/StaticSelectTrailingContent.js +0 -47
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +0 -6
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +0 -13
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +0 -3
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +0 -5
- package/dist/components/inputs/Selection/shared/selectInput.cva.d.ts +0 -5
- package/dist/components/inputs/Selection/shared/selectInput.cva.js +0 -5
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +0 -23
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +0 -37
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +0 -1
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +0 -79
- package/dist/components/inputs/Skeleton/InputFrame.js +0 -526
- package/dist/components/inputs/shared/StaticInput.d.ts +0 -38
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +0 -4
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +0 -5
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +0 -14
- package/dist/components/inputs/shared/useStaticInputHandoff.js +0 -100
- package/dist/hooks/useQueryAutocomplete.d.ts +0 -14
- package/dist/hooks/useQueryAutocomplete.js +0 -57
- package/dist/utils/query.utils.d.ts +0 -4
- package/dist/utils/query.utils.js +0 -8
|
@@ -1,22 +1,18 @@
|
|
|
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 { c } from "react/compiler-runtime";
|
|
7
3
|
import { jsx } from "react/jsx-runtime";
|
|
8
4
|
import { createContext, use } from "react";
|
|
9
5
|
//#region src/config/uiConfig.context.tsx
|
|
10
6
|
var UIConfig;
|
|
11
7
|
(function(_UIConfig) {
|
|
12
8
|
const DEFAULT_CONFIG = {
|
|
13
|
-
renderStaticInput: true,
|
|
14
9
|
input: {
|
|
15
10
|
variant: "outlined",
|
|
16
11
|
as: "default",
|
|
17
12
|
size: "default",
|
|
18
13
|
isClearable: false,
|
|
19
|
-
hideLabel: false
|
|
14
|
+
hideLabel: false,
|
|
15
|
+
alwaysShowClear: false
|
|
20
16
|
},
|
|
21
17
|
button: {
|
|
22
18
|
variant: "contained",
|
|
@@ -36,11 +32,8 @@ var UIConfig;
|
|
|
36
32
|
isSearchable: false,
|
|
37
33
|
selectedTagsType: "list",
|
|
38
34
|
collapseAfter: 3,
|
|
39
|
-
hideSearchIcon: false
|
|
40
|
-
fireBlurOnChange: false
|
|
35
|
+
hideSearchIcon: false
|
|
41
36
|
},
|
|
42
|
-
queryAutocomplete: { isInitialQueryDisabled: false },
|
|
43
|
-
querySelect: { isInitialQueryDisabled: false },
|
|
44
37
|
toggle: { variant: "default" },
|
|
45
38
|
slider: {
|
|
46
39
|
minValue: 0,
|
|
@@ -48,17 +41,11 @@ var UIConfig;
|
|
|
48
41
|
},
|
|
49
42
|
dateInput: {
|
|
50
43
|
todayIcon: false,
|
|
51
|
-
todayIconButtonSize: "none",
|
|
52
|
-
todayIconPlacement: "content",
|
|
53
44
|
shouldForceLeadingZeros: false,
|
|
54
45
|
disableManualEntry: false,
|
|
55
|
-
|
|
56
|
-
calendarIcon: /* @__PURE__ */ jsx(CalendarIcon, { className: "size-5" }),
|
|
57
|
-
dateTimeIcon: /* @__PURE__ */ jsx(DateTimeIcon, { className: "size-5" }),
|
|
58
|
-
timeIcon: /* @__PURE__ */ jsx(ClockIcon, { className: "size-6 text-interactive-text-secondary-idle" }),
|
|
59
|
-
setDateValueOnDateSelection: false,
|
|
46
|
+
shouldUpdateDateOnMonthYearChange: false,
|
|
60
47
|
granularity: "day",
|
|
61
|
-
|
|
48
|
+
autoFixYear: false
|
|
62
49
|
},
|
|
63
50
|
actionModal: {
|
|
64
51
|
titleTypography: {
|
|
@@ -91,42 +78,15 @@ var UIConfig;
|
|
|
91
78
|
toast: { variant: "outlined" }
|
|
92
79
|
};
|
|
93
80
|
const Context = createContext(DEFAULT_CONFIG);
|
|
94
|
-
_UIConfig.Provider = (
|
|
95
|
-
const $ = c(9);
|
|
96
|
-
const { config: t1, children } = t0;
|
|
97
|
-
let t2;
|
|
98
|
-
if ($[0] !== t1) {
|
|
99
|
-
t2 = t1 === void 0 ? {} : t1;
|
|
100
|
-
$[0] = t1;
|
|
101
|
-
$[1] = t2;
|
|
102
|
-
} else t2 = $[1];
|
|
103
|
-
const config = t2;
|
|
81
|
+
_UIConfig.Provider = ({ config = {}, children }) => {
|
|
104
82
|
const parentConfig = use(Context) || DEFAULT_CONFIG;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
$[4] = t3;
|
|
113
|
-
$[5] = t4;
|
|
114
|
-
} else {
|
|
115
|
-
t3 = $[4];
|
|
116
|
-
t4 = $[5];
|
|
117
|
-
}
|
|
118
|
-
const value = useDeepCompareMemo(t3, t4);
|
|
119
|
-
let t5;
|
|
120
|
-
if ($[6] !== children || $[7] !== value) {
|
|
121
|
-
t5 = /* @__PURE__ */ jsx(Context.Provider, {
|
|
122
|
-
value,
|
|
123
|
-
children
|
|
124
|
-
});
|
|
125
|
-
$[6] = children;
|
|
126
|
-
$[7] = value;
|
|
127
|
-
$[8] = t5;
|
|
128
|
-
} else t5 = $[8];
|
|
129
|
-
return t5;
|
|
83
|
+
const value = useDeepCompareMemo(() => {
|
|
84
|
+
return ObjectUtils.deepConditionalMerge(parentConfig, config, (val) => val !== null && val !== void 0);
|
|
85
|
+
}, [config, parentConfig]);
|
|
86
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
87
|
+
value,
|
|
88
|
+
children
|
|
89
|
+
});
|
|
130
90
|
};
|
|
131
91
|
_UIConfig.useConfig = () => {
|
|
132
92
|
const context = use(Context);
|
|
@@ -134,8 +94,5 @@ var UIConfig;
|
|
|
134
94
|
return context;
|
|
135
95
|
};
|
|
136
96
|
})(UIConfig || (UIConfig = {}));
|
|
137
|
-
function _temp(val) {
|
|
138
|
-
return val !== null && val !== void 0;
|
|
139
|
-
}
|
|
140
97
|
//#endregion
|
|
141
98
|
export { UIConfig };
|
|
@@ -4,17 +4,11 @@ import { BreadcrumbChevronVariantProps, BreadcrumbIconVariantProps, BreadcrumbIt
|
|
|
4
4
|
import { ButtonVariantProps } from '../components/buttons/Button/button.cva';
|
|
5
5
|
import { PillButtonVariants } from '../components/buttons/PillButton/pillButton.cva';
|
|
6
6
|
import { CheckboxIconVariantProps, CheckboxVariantProps } from '../components/inputs/Checkbox/checkbox.cva';
|
|
7
|
-
import { DatePickerInputContentRowProps } from '../components/inputs/DateTime/shared/datePickerInput.cva';
|
|
8
7
|
import { FormFieldErrorVariantProps } from '../components/inputs/FormField/formFieldError.cva';
|
|
9
|
-
import { FormFieldHeaderVariantProps } from '../components/inputs/FormField/formFieldHeader.cva';
|
|
10
8
|
import { FormFieldHelperVariantProps } from '../components/inputs/FormField/formFieldHelper.cva';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { SelectPopoverCva } from '../components/inputs/Selection/shared/selectDesktop.cva';
|
|
14
|
-
import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
|
|
15
|
-
import { InputBaseProps, InputClearClassProps, InputContentWrapperProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
9
|
+
import { RadioVariantProps } from '../components/inputs/RadioGroup/radio.cva';
|
|
10
|
+
import { InputBaseProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
16
11
|
import { LabelBaseProps } from '../components/inputs/shared/label.cva';
|
|
17
|
-
import { TooltipWrapperTriggerVariantProps } from '../components/inputs/shared/tooltipWrapper.cva';
|
|
18
12
|
import { ToggleVariantProps } from '../components/inputs/Toggle/toggle.cva';
|
|
19
13
|
import { MenuCvaVariantProps, MenuItemVariantProps, MenuPopoverVariantProps, MenuPopoverWrapperVariantProps } from '../components/Menu/menu.cva';
|
|
20
14
|
import { AccordionChevronVariantProps, AccordionHeadingSubtitleVariantProps, AccordionHeadingTitleVariantProps, AccordionHeadingVariantProps, AccordionIconVariantProps, AccordionItemVariantProps, AccordionPanelContentVariantProps, AccordionPanelVariantProps, AccordionTriggerVariantProps, AccordionVariantProps } from '../components/navigation/Accordion/accordion.cva';
|
|
@@ -30,12 +24,13 @@ import { LinkVariantProps } from '../components/text/Link/link.cva';
|
|
|
30
24
|
import { TagVariantProps } from '../components/text/Tag/tag.cva';
|
|
31
25
|
import { TypographyVariantProps } from '../components/text/Typography/typography.cva';
|
|
32
26
|
import { CompoundMapper, ConfigSchema } from '../utils/compoundMapper';
|
|
27
|
+
import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
|
|
33
28
|
export declare namespace UIStyle {
|
|
34
29
|
export type Cva<T> = (props: (T & ClassProp) | ClassProp) => string;
|
|
35
30
|
type OptionKey = {
|
|
36
31
|
[K in keyof Options]: Options[K] extends object ? `${K & string}.${keyof Options[K] & string}` : never;
|
|
37
32
|
}[keyof Options];
|
|
38
|
-
|
|
33
|
+
interface Options {
|
|
39
34
|
button: {
|
|
40
35
|
cva?: Cva<ButtonVariantProps>;
|
|
41
36
|
sizeCva?: Cva<ButtonVariantProps>;
|
|
@@ -51,14 +46,10 @@ export declare namespace UIStyle {
|
|
|
51
46
|
cva?: Cva<CheckboxVariantProps>;
|
|
52
47
|
iconCva?: Cva<CheckboxIconVariantProps>;
|
|
53
48
|
typography?: CompoundMapper<TypographyVariantProps, CheckboxVariantProps>;
|
|
54
|
-
contentClassName?: CompoundMapper<string, CheckboxVariantProps>;
|
|
55
49
|
};
|
|
56
50
|
radio: {
|
|
57
51
|
cva?: Cva<RadioVariantProps>;
|
|
58
|
-
contentWrapperCva?: Cva<RadioContentWrapperVariantProps>;
|
|
59
|
-
contentRowCva?: Cva<RadioContentRowVariantProps>;
|
|
60
52
|
typography?: CompoundMapper<TypographyVariantProps, RadioVariantProps>;
|
|
61
|
-
contentClassName?: CompoundMapper<string, RadioVariantProps>;
|
|
62
53
|
};
|
|
63
54
|
status: {
|
|
64
55
|
iconCva?: Cva<ToastVariantProps>;
|
|
@@ -73,20 +64,9 @@ export declare namespace UIStyle {
|
|
|
73
64
|
};
|
|
74
65
|
input: {
|
|
75
66
|
baseCva?: Cva<InputBaseProps>;
|
|
76
|
-
clearClassCva?: Cva<InputClearClassProps>;
|
|
77
|
-
contentWrapperCva?: Cva<InputContentWrapperProps>;
|
|
78
67
|
sizeCva?: Cva<InputSizeProps>;
|
|
79
68
|
sideCva?: Cva<InputSideProps>;
|
|
80
69
|
};
|
|
81
|
-
textArea: {
|
|
82
|
-
wrapperCva?: Cva<TextAreaWrapperVariantProps>;
|
|
83
|
-
};
|
|
84
|
-
tooltipWrapper: {
|
|
85
|
-
triggerCva?: Cva<TooltipWrapperTriggerVariantProps>;
|
|
86
|
-
};
|
|
87
|
-
datePickerInput: {
|
|
88
|
-
contentRowCva?: Cva<DatePickerInputContentRowProps>;
|
|
89
|
-
};
|
|
90
70
|
label: {
|
|
91
71
|
cva?: Cva<LabelBaseProps>;
|
|
92
72
|
typography?: CompoundMapper<TypographyVariantProps, LabelBaseProps>;
|
|
@@ -94,7 +74,6 @@ export declare namespace UIStyle {
|
|
|
94
74
|
toggle: {
|
|
95
75
|
cva?: Cva<ToggleVariantProps>;
|
|
96
76
|
typography?: CompoundMapper<TypographyVariantProps, ToggleVariantProps>;
|
|
97
|
-
contentClassName?: CompoundMapper<string, ToggleVariantProps>;
|
|
98
77
|
};
|
|
99
78
|
typography: {
|
|
100
79
|
cva?: Cva<TypographyVariantProps>;
|
|
@@ -166,13 +145,11 @@ export declare namespace UIStyle {
|
|
|
166
145
|
cva?: Cva<PopoverVariantProps>;
|
|
167
146
|
};
|
|
168
147
|
formField: {
|
|
169
|
-
headerCva?: Cva<FormFieldHeaderVariantProps>;
|
|
170
148
|
errorLabelCva?: Cva<FormFieldErrorVariantProps>;
|
|
171
149
|
helperLabelCva?: Cva<FormFieldHelperVariantProps>;
|
|
172
150
|
};
|
|
173
151
|
select: {
|
|
174
152
|
listBoxItemCva?: Cva<SelectListBoxItemCva>;
|
|
175
|
-
popoverCva?: Cva<SelectPopoverCva>;
|
|
176
153
|
};
|
|
177
154
|
}
|
|
178
155
|
interface ProviderProps {
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import { c } from "react/compiler-runtime";
|
|
2
1
|
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import { createContext, use } from "react";
|
|
4
3
|
//#region src/config/uiStyle.context.tsx
|
|
5
4
|
var UIStyle;
|
|
6
5
|
(function(_UIStyle) {
|
|
7
6
|
const Context = createContext(null);
|
|
8
|
-
_UIStyle.Provider = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
t1 = /* @__PURE__ */ jsx(Context.Provider, {
|
|
14
|
-
value: config,
|
|
15
|
-
children
|
|
16
|
-
});
|
|
17
|
-
$[0] = children;
|
|
18
|
-
$[1] = config;
|
|
19
|
-
$[2] = t1;
|
|
20
|
-
} else t1 = $[2];
|
|
21
|
-
return t1;
|
|
7
|
+
_UIStyle.Provider = ({ children, config }) => {
|
|
8
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
9
|
+
value: config,
|
|
10
|
+
children
|
|
11
|
+
});
|
|
22
12
|
};
|
|
23
13
|
const useConfig = () => {
|
|
24
14
|
return use(Context);
|
|
@@ -21,14 +21,14 @@ export type AllowedComponentType<TZodType extends z.ZodType> = ZodUtils.ZodTypeS
|
|
|
21
21
|
datetime: "datePicker" | "dateTimePicker" | "timePicker";
|
|
22
22
|
dateRange: "dateRangePicker";
|
|
23
23
|
boolean: "toggle" | "checkbox";
|
|
24
|
-
number: "numberInput" | "slider" | "select" | "
|
|
25
|
-
enum: "select" | "
|
|
26
|
-
string: "textInput" | "passwordInput" | "textArea" | "
|
|
24
|
+
number: "numberInput" | "slider" | "select" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
25
|
+
enum: "select" | "autocomplete" | "segment";
|
|
26
|
+
string: "textInput" | "passwordInput" | "textArea" | "select" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
27
27
|
email: "textInput";
|
|
28
|
-
array: "select" | "
|
|
28
|
+
array: "select" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
29
29
|
object: InputComponentType;
|
|
30
30
|
unknown: InputComponentType;
|
|
31
|
-
uuid: "select" | "
|
|
31
|
+
uuid: "select" | "autocomplete" | "queryAutocomplete" | "segment";
|
|
32
32
|
}>;
|
|
33
33
|
interface DynamicInputDefBase<TProps> {
|
|
34
34
|
label?: string;
|
|
@@ -81,7 +81,6 @@ var getDefaultProps = (componentType, keyType) => {
|
|
|
81
81
|
].includes(componentType)) props.items = getDefaultSelectionItems(unwrappedType);
|
|
82
82
|
if ([
|
|
83
83
|
"select",
|
|
84
|
-
"querySelect",
|
|
85
84
|
"autocomplete",
|
|
86
85
|
"queryAutocomplete",
|
|
87
86
|
"segment"
|
|
@@ -147,8 +146,6 @@ var populateInputDef = (schema, schemaKey, value, options) => {
|
|
|
147
146
|
const inputWrapper = value.inputWrapper ?? options.globalInputWrapper;
|
|
148
147
|
if ("render" in value) return {
|
|
149
148
|
name,
|
|
150
|
-
label,
|
|
151
|
-
placeholder,
|
|
152
149
|
render: value.render
|
|
153
150
|
};
|
|
154
151
|
const schemaKeyType = schema.shape[schemaKey];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
2
|
import { useMediaQuery } from "react-responsive";
|
|
3
3
|
//#region src/hooks/useBreakpoint.ts
|
|
4
4
|
var breakpoints = null;
|
|
@@ -22,22 +22,9 @@ function getBreakpoints() {
|
|
|
22
22
|
return breakpoints;
|
|
23
23
|
}
|
|
24
24
|
function useBreakpoint(breakpointKey) {
|
|
25
|
-
const
|
|
26
|
-
let t0;
|
|
27
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
|
-
t0 = getBreakpoints();
|
|
29
|
-
$[0] = t0;
|
|
30
|
-
} else t0 = $[0];
|
|
31
|
-
const breakpoints = t0;
|
|
25
|
+
const breakpoints = useMemo(() => getBreakpoints(), []);
|
|
32
26
|
if (!breakpoints) throw new Error("Tailwind config is missing theme.screens");
|
|
33
|
-
|
|
34
|
-
let t2;
|
|
35
|
-
if ($[1] !== t1) {
|
|
36
|
-
t2 = { query: t1 };
|
|
37
|
-
$[1] = t1;
|
|
38
|
-
$[2] = t2;
|
|
39
|
-
} else t2 = $[2];
|
|
40
|
-
return useMediaQuery(t2);
|
|
27
|
+
return useMediaQuery({ query: `(min-width: ${breakpoints[breakpointKey]})` });
|
|
41
28
|
}
|
|
42
29
|
//#endregion
|
|
43
30
|
export { useBreakpoint };
|
|
@@ -1,59 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
2
|
//#region src/hooks/useDebounceCallback.ts
|
|
4
|
-
function useDebounceCallback(callback,
|
|
5
|
-
const $ = c(10);
|
|
6
|
-
let t1;
|
|
7
|
-
if ($[0] !== t0) {
|
|
8
|
-
t1 = t0 === void 0 ? {} : t0;
|
|
9
|
-
$[0] = t0;
|
|
10
|
-
$[1] = t1;
|
|
11
|
-
} else t1 = $[1];
|
|
12
|
-
const { delay: t2 } = t1;
|
|
13
|
-
const delay = t2 === void 0 ? 500 : t2;
|
|
3
|
+
function useDebounceCallback(callback, { delay = 500 } = {}) {
|
|
14
4
|
const timeoutRef = useRef(null);
|
|
15
5
|
const [isDebouncing, setIsDebouncing] = useState(false);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
const debouncedCallback = useCallback((...args) => {
|
|
7
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
8
|
+
setIsDebouncing(true);
|
|
9
|
+
timeoutRef.current = setTimeout(() => {
|
|
10
|
+
setIsDebouncing(false);
|
|
11
|
+
callback?.(...args);
|
|
12
|
+
}, delay);
|
|
13
|
+
}, [callback, delay]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
return () => {
|
|
20
16
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
21
|
-
setIsDebouncing(true);
|
|
22
|
-
timeoutRef.current = setTimeout(() => {
|
|
23
|
-
setIsDebouncing(false);
|
|
24
|
-
callback?.(...args);
|
|
25
|
-
}, delay);
|
|
26
17
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let t4;
|
|
33
|
-
let t5;
|
|
34
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
35
|
-
t4 = () => () => {
|
|
36
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
37
|
-
};
|
|
38
|
-
t5 = [];
|
|
39
|
-
$[5] = t4;
|
|
40
|
-
$[6] = t5;
|
|
41
|
-
} else {
|
|
42
|
-
t4 = $[5];
|
|
43
|
-
t5 = $[6];
|
|
44
|
-
}
|
|
45
|
-
useEffect(t4, t5);
|
|
46
|
-
let t6;
|
|
47
|
-
if ($[7] !== debouncedCallback || $[8] !== isDebouncing) {
|
|
48
|
-
t6 = {
|
|
49
|
-
callback: debouncedCallback,
|
|
50
|
-
isDebouncing
|
|
51
|
-
};
|
|
52
|
-
$[7] = debouncedCallback;
|
|
53
|
-
$[8] = isDebouncing;
|
|
54
|
-
$[9] = t6;
|
|
55
|
-
} else t6 = $[9];
|
|
56
|
-
return t6;
|
|
18
|
+
}, []);
|
|
19
|
+
return {
|
|
20
|
+
callback: debouncedCallback,
|
|
21
|
+
isDebouncing
|
|
22
|
+
};
|
|
57
23
|
}
|
|
58
24
|
//#endregion
|
|
59
25
|
export { useDebounceCallback };
|
package/dist/hooks/useFilters.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { UIRouter } from "../config/router.context.js";
|
|
2
2
|
import { RoutingUtils } from "../utils/routing.utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
4
|
import { z } from "zod";
|
|
6
5
|
//#region src/hooks/useFilters.ts
|
|
7
6
|
function getFieldType(schema, fieldKey) {
|
|
@@ -51,138 +50,78 @@ var parseFilterFromQuery = (searchParams, schema) => {
|
|
|
51
50
|
}
|
|
52
51
|
return filter;
|
|
53
52
|
};
|
|
54
|
-
var useFilters = (defaultFilterValues,
|
|
55
|
-
const $ = c(33);
|
|
56
|
-
const prefix = t0 === void 0 ? "" : t0;
|
|
53
|
+
var useFilters = (defaultFilterValues, prefix = "", schema) => {
|
|
57
54
|
const { searchParams, replace } = UIRouter.useUIRouter();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
$[1] = searchParams;
|
|
63
|
-
$[2] = t1;
|
|
64
|
-
} else t1 = $[2];
|
|
65
|
-
const [filterData, setFilterData] = useState(t1);
|
|
66
|
-
let t2;
|
|
67
|
-
if ($[3] !== defaultFilterValues || $[4] !== prefix || $[5] !== replace || $[6] !== schema || $[7] !== searchParams) {
|
|
68
|
-
t2 = () => {
|
|
69
|
-
const setUrlToDefaultFilters = () => {
|
|
70
|
-
const flatFilterQuery = serializeFiltersToQuery(defaultFilterValues, prefix);
|
|
71
|
-
replace(".", {
|
|
72
|
-
...RoutingUtils.toRouterSearch(searchParams),
|
|
73
|
-
...flatFilterQuery
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
const currentFilters = parseFilterFromQuery(searchParams, schema);
|
|
77
|
-
const hasFiltersSet = Object.keys(currentFilters).length > 0;
|
|
78
|
-
if (defaultFilterValues && !hasFiltersSet) setUrlToDefaultFilters();
|
|
79
|
-
};
|
|
80
|
-
$[3] = defaultFilterValues;
|
|
81
|
-
$[4] = prefix;
|
|
82
|
-
$[5] = replace;
|
|
83
|
-
$[6] = schema;
|
|
84
|
-
$[7] = searchParams;
|
|
85
|
-
$[8] = t2;
|
|
86
|
-
} else t2 = $[8];
|
|
87
|
-
let t3;
|
|
88
|
-
if ($[9] !== defaultFilterValues || $[10] !== prefix || $[11] !== schema) {
|
|
89
|
-
t3 = [
|
|
90
|
-
defaultFilterValues,
|
|
91
|
-
prefix,
|
|
92
|
-
schema
|
|
93
|
-
];
|
|
94
|
-
$[9] = defaultFilterValues;
|
|
95
|
-
$[10] = prefix;
|
|
96
|
-
$[11] = schema;
|
|
97
|
-
$[12] = t3;
|
|
98
|
-
} else t3 = $[12];
|
|
99
|
-
useEffect(t2, t3);
|
|
100
|
-
let t4;
|
|
101
|
-
let t5;
|
|
102
|
-
if ($[13] !== schema || $[14] !== searchParams) {
|
|
103
|
-
t4 = () => {
|
|
104
|
-
setFilterData(parseFilterFromQuery(searchParams, schema));
|
|
105
|
-
};
|
|
106
|
-
t5 = [searchParams, schema];
|
|
107
|
-
$[13] = schema;
|
|
108
|
-
$[14] = searchParams;
|
|
109
|
-
$[15] = t4;
|
|
110
|
-
$[16] = t5;
|
|
111
|
-
} else {
|
|
112
|
-
t4 = $[15];
|
|
113
|
-
t5 = $[16];
|
|
114
|
-
}
|
|
115
|
-
useEffect(t4, t5);
|
|
116
|
-
let t6;
|
|
117
|
-
if ($[17] !== defaultFilterValues || $[18] !== filterData || $[19] !== prefix || $[20] !== replace || $[21] !== searchParams) {
|
|
118
|
-
t6 = (data) => {
|
|
119
|
-
let newFilters = { ...filterData };
|
|
120
|
-
const isReset = Object.keys(data).length === 0;
|
|
121
|
-
if (data === defaultFilterValues) newFilters = { ...defaultFilterValues };
|
|
122
|
-
else if (isReset) newFilters = {};
|
|
123
|
-
else Object.entries(data).forEach((t7) => {
|
|
124
|
-
const [key, value] = t7;
|
|
125
|
-
if (value === void 0) delete newFilters[key];
|
|
126
|
-
else newFilters[key] = value;
|
|
127
|
-
});
|
|
128
|
-
const prefixPart = prefix ? `${prefix}-` : "";
|
|
129
|
-
const cleanedQuery = RoutingUtils.toRouterSearch(searchParams);
|
|
130
|
-
Object.keys(cleanedQuery).forEach((key_0) => {
|
|
131
|
-
if (key_0.startsWith(`filter[${prefixPart}`)) delete cleanedQuery[key_0];
|
|
132
|
-
});
|
|
133
|
-
const flatFilterQuery_0 = serializeFiltersToQuery(newFilters, prefix);
|
|
55
|
+
const [filterData, setFilterData] = useState(() => parseFilterFromQuery(searchParams, schema));
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const setUrlToDefaultFilters = () => {
|
|
58
|
+
const flatFilterQuery = serializeFiltersToQuery(defaultFilterValues, prefix);
|
|
134
59
|
replace(".", {
|
|
135
|
-
...
|
|
136
|
-
...
|
|
137
|
-
});
|
|
138
|
-
setFilterData(newFilters);
|
|
139
|
-
};
|
|
140
|
-
$[17] = defaultFilterValues;
|
|
141
|
-
$[18] = filterData;
|
|
142
|
-
$[19] = prefix;
|
|
143
|
-
$[20] = replace;
|
|
144
|
-
$[21] = searchParams;
|
|
145
|
-
$[22] = t6;
|
|
146
|
-
} else t6 = $[22];
|
|
147
|
-
const setFilterValue = t6;
|
|
148
|
-
let t7;
|
|
149
|
-
if ($[23] !== filterData) {
|
|
150
|
-
t7 = (keys) => {
|
|
151
|
-
const result = {};
|
|
152
|
-
keys.forEach((key_1) => {
|
|
153
|
-
result[key_1] = filterData[key_1];
|
|
60
|
+
...RoutingUtils.toRouterSearch(searchParams),
|
|
61
|
+
...flatFilterQuery
|
|
154
62
|
});
|
|
155
|
-
return result;
|
|
156
|
-
};
|
|
157
|
-
$[23] = filterData;
|
|
158
|
-
$[24] = t7;
|
|
159
|
-
} else t7 = $[24];
|
|
160
|
-
const getFilterValue = t7;
|
|
161
|
-
let t8;
|
|
162
|
-
if ($[25] !== defaultFilterValues || $[26] !== setFilterValue) {
|
|
163
|
-
t8 = () => {
|
|
164
|
-
setFilterValue(defaultFilterValues ?? {});
|
|
165
63
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
64
|
+
const currentFilters = parseFilterFromQuery(searchParams, schema);
|
|
65
|
+
const hasFiltersSet = Object.keys(currentFilters).length > 0;
|
|
66
|
+
if (defaultFilterValues && !hasFiltersSet) setUrlToDefaultFilters();
|
|
67
|
+
}, [
|
|
68
|
+
defaultFilterValues,
|
|
69
|
+
prefix,
|
|
70
|
+
schema
|
|
71
|
+
]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setFilterData(parseFilterFromQuery(searchParams, schema));
|
|
74
|
+
}, [searchParams, schema]);
|
|
75
|
+
const setFilterValue = useCallback((data) => {
|
|
76
|
+
let newFilters = { ...filterData };
|
|
77
|
+
const isReset = Object.keys(data).length === 0;
|
|
78
|
+
if (data === defaultFilterValues) newFilters = { ...defaultFilterValues };
|
|
79
|
+
else if (isReset) newFilters = {};
|
|
80
|
+
else Object.entries(data).forEach(([key, value]) => {
|
|
81
|
+
if (value === void 0) delete newFilters[key];
|
|
82
|
+
else newFilters[key] = value;
|
|
83
|
+
});
|
|
84
|
+
const prefixPart = prefix ? `${prefix}-` : "";
|
|
85
|
+
const cleanedQuery = RoutingUtils.toRouterSearch(searchParams);
|
|
86
|
+
Object.keys(cleanedQuery).forEach((key) => {
|
|
87
|
+
if (key.startsWith(`filter[${prefixPart}`)) delete cleanedQuery[key];
|
|
88
|
+
});
|
|
89
|
+
const flatFilterQuery = serializeFiltersToQuery(newFilters, prefix);
|
|
90
|
+
replace(".", {
|
|
91
|
+
...cleanedQuery,
|
|
92
|
+
...flatFilterQuery
|
|
93
|
+
});
|
|
94
|
+
setFilterData(newFilters);
|
|
95
|
+
}, [
|
|
96
|
+
filterData,
|
|
97
|
+
prefix,
|
|
98
|
+
replace,
|
|
99
|
+
defaultFilterValues,
|
|
100
|
+
searchParams
|
|
101
|
+
]);
|
|
102
|
+
const getFilterValue = useCallback((keys) => {
|
|
103
|
+
const result = {};
|
|
104
|
+
keys.forEach((key) => {
|
|
105
|
+
result[key] = filterData[key];
|
|
106
|
+
});
|
|
107
|
+
return result;
|
|
108
|
+
}, [filterData]);
|
|
109
|
+
const clearAllFilters = useCallback(() => {
|
|
110
|
+
setFilterValue(defaultFilterValues ?? {});
|
|
111
|
+
}, [defaultFilterValues, setFilterValue]);
|
|
112
|
+
return useMemo(() => {
|
|
113
|
+
return {
|
|
174
114
|
filterData,
|
|
175
115
|
setFilterValue,
|
|
176
116
|
getFilterValue,
|
|
177
117
|
clearAllFilters
|
|
178
118
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return t9;
|
|
119
|
+
}, [
|
|
120
|
+
filterData,
|
|
121
|
+
setFilterValue,
|
|
122
|
+
getFilterValue,
|
|
123
|
+
clearAllFilters
|
|
124
|
+
]);
|
|
186
125
|
};
|
|
187
126
|
//#endregion
|
|
188
127
|
export { useFilters };
|
package/dist/hooks/useForm.js
CHANGED
|
@@ -1,48 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
2
|
import { useForm } from "react-hook-form";
|
|
3
3
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
4
|
//#region src/hooks/useForm.ts
|
|
5
|
-
function useForm$1(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
({resolver, zodSchema, defaultValues, ...props} = t0);
|
|
13
|
-
$[0] = t0;
|
|
14
|
-
$[1] = defaultValues;
|
|
15
|
-
$[2] = props;
|
|
16
|
-
$[3] = resolver;
|
|
17
|
-
$[4] = zodSchema;
|
|
18
|
-
} else {
|
|
19
|
-
defaultValues = $[1];
|
|
20
|
-
props = $[2];
|
|
21
|
-
resolver = $[3];
|
|
22
|
-
zodSchema = $[4];
|
|
23
|
-
}
|
|
24
|
-
let t1;
|
|
25
|
-
if ($[5] !== resolver || $[6] !== zodSchema) {
|
|
26
|
-
t1 = resolver ?? (zodSchema ? zodResolver(zodSchema) : void 0);
|
|
27
|
-
$[5] = resolver;
|
|
28
|
-
$[6] = zodSchema;
|
|
29
|
-
$[7] = t1;
|
|
30
|
-
} else t1 = $[7];
|
|
31
|
-
const formResolver = t1;
|
|
32
|
-
const t2 = defaultValues;
|
|
33
|
-
let t3;
|
|
34
|
-
if ($[8] !== formResolver || $[9] !== props || $[10] !== t2) {
|
|
35
|
-
t3 = {
|
|
36
|
-
...props,
|
|
37
|
-
resolver: formResolver,
|
|
38
|
-
defaultValues: t2
|
|
39
|
-
};
|
|
40
|
-
$[8] = formResolver;
|
|
41
|
-
$[9] = props;
|
|
42
|
-
$[10] = t2;
|
|
43
|
-
$[11] = t3;
|
|
44
|
-
} else t3 = $[11];
|
|
45
|
-
return useForm(t3);
|
|
5
|
+
function useForm$1({ resolver, zodSchema, defaultValues, ...props }) {
|
|
6
|
+
const formResolver = useMemo(() => resolver ?? (zodSchema ? zodResolver(zodSchema) : void 0), [resolver, zodSchema]);
|
|
7
|
+
return useForm({
|
|
8
|
+
...props,
|
|
9
|
+
resolver: formResolver,
|
|
10
|
+
defaultValues
|
|
11
|
+
});
|
|
46
12
|
}
|
|
47
13
|
//#endregion
|
|
48
14
|
export { useForm$1 as useForm };
|