@geotab/zenith 1.26.4 → 1.26.5-beta.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/README.md +6 -0
- package/dist/absolute/absolute.js +2 -2
- package/dist/chip/chip.d.ts +35 -0
- package/dist/chip/chip.js +105 -0
- package/dist/chip/chipStatusProvider.d.ts +9 -0
- package/dist/chip/chipStatusProvider.js +13 -0
- package/dist/chip/utils/getChipStateClassName.d.ts +2 -0
- package/dist/chip/utils/getChipStateClassName.js +32 -0
- package/dist/chip/utils/useChip.d.ts +10 -0
- package/dist/chip/utils/useChip.js +24 -0
- package/dist/commonHelpers/hooks/useDebouncedMemo.d.ts +2 -0
- package/dist/commonHelpers/hooks/useDebouncedMemo.js +26 -0
- package/dist/commonStyles/shadows/shadows.less +4 -0
- package/dist/dateRange/dateRange.d.ts +2 -1
- package/dist/dateRange/dateRange.js +6 -2
- package/dist/dropdown/dropdown.d.ts +18 -3
- package/dist/dropdown/dropdown.js +63 -31
- package/dist/dropdown/dropdownHelper.d.ts +1 -1
- package/dist/dropdown/dropdownHelper.js +7 -3
- package/dist/dropdown/dropdownList.d.ts +1 -0
- package/dist/dropdown/dropdownList.js +2 -2
- package/dist/dropdown/dropdownPopup.d.ts +1 -0
- package/dist/dropdown/dropdownPopup.js +2 -2
- package/dist/dropdown/stateReducer/stateAction.d.ts +9 -1
- package/dist/dropdown/stateReducer/stateActionType.d.ts +1 -0
- package/dist/dropdown/stateReducer/stateActionType.js +1 -0
- package/dist/dropdown/stateReducer/stateReducer.js +35 -0
- package/dist/dropdown/useDropdownState.d.ts +7 -0
- package/dist/dropdown/useDropdownState.js +10 -0
- package/dist/filters/components/filtersChip.d.ts +9 -0
- package/dist/filters/components/filtersChip.js +28 -0
- package/dist/filters/components/filtersContainer.d.ts +12 -0
- package/dist/filters/components/filtersContainer.js +77 -0
- package/dist/filters/components/filtersCustom.d.ts +13 -0
- package/dist/filters/components/filtersCustom.js +15 -0
- package/dist/filters/components/filtersDateRange.d.ts +33 -0
- package/dist/filters/components/filtersDateRange.js +27 -0
- package/dist/filters/components/filtersDropdown.d.ts +32 -0
- package/dist/filters/components/filtersDropdown.js +42 -0
- package/dist/filters/components/filtersGroups.d.ts +14 -0
- package/dist/filters/components/filtersGroups.js +28 -0
- package/dist/filters/components/filtersItem.d.ts +25 -0
- package/dist/filters/components/filtersItem.js +23 -0
- package/dist/filters/components/filtersModal.d.ts +17 -0
- package/dist/filters/components/filtersModal.js +107 -0
- package/dist/filters/components/filtersModalItem.d.ts +9 -0
- package/dist/filters/components/filtersModalItem.js +74 -0
- package/dist/filters/components/filtersRange.d.ts +11 -0
- package/dist/filters/components/filtersRange.js +27 -0
- package/dist/filters/components/filtersSaveModal.d.ts +7 -0
- package/dist/filters/components/filtersSaveModal.js +53 -0
- package/dist/filters/components/filtersSavedChipComponent.d.ts +2 -0
- package/dist/filters/components/filtersSavedChipComponent.js +66 -0
- package/dist/filters/components/filtersSavedItemsProvider.d.ts +19 -0
- package/dist/filters/components/filtersSavedItemsProvider.js +13 -0
- package/dist/filters/components/filtersSearch.d.ts +16 -0
- package/dist/filters/components/filtersSearch.js +64 -0
- package/dist/filters/components/filtersSearchItemData.d.ts +16 -0
- package/dist/filters/components/filtersSearchItemData.js +42 -0
- package/dist/filters/components/filtersSearchList.d.ts +30 -0
- package/dist/filters/components/filtersSearchList.js +75 -0
- package/dist/filters/components/filtersSelect.d.ts +30 -0
- package/dist/filters/components/filtersSelect.js +51 -0
- package/dist/filters/components/filtersSelectListItem.d.ts +15 -0
- package/dist/filters/components/filtersSelectListItem.js +14 -0
- package/dist/filters/filters.d.ts +99 -0
- package/dist/filters/filters.js +246 -0
- package/dist/filters/filtersHelper.d.ts +40 -0
- package/dist/filters/filtersHelper.js +226 -0
- package/dist/filters/filtersHooks.d.ts +19 -0
- package/dist/filters/filtersHooks.js +25 -0
- package/dist/filtersBar/components/filtersBarDropdownWithCheckbox/filtersBarDropdownWithCheckbox.d.ts +5 -3
- package/dist/groupsFilter/groupsFilter.d.ts +10 -1
- package/dist/groupsFilter/groupsFilter.js +40 -11
- package/dist/header/components/collapsedItemsControl/collapsedItemsControl.js +7 -4
- package/dist/header/headerMenu.d.ts +1 -0
- package/dist/header/headerMenu.js +11 -4
- package/dist/index.css +3452 -2648
- package/dist/index.d.ts +18 -3
- package/dist/index.js +55 -15
- package/dist/layout/layout.js +5 -0
- package/dist/list/list.d.ts +1 -1
- package/dist/list/list.js +3 -2
- package/dist/modal/modal.d.ts +11 -1
- package/dist/modal/modal.js +8 -5
- package/dist/nav/nav.d.ts +1 -0
- package/dist/nav/nav.js +21 -7
- package/dist/nav/navHeader/navHeader.js +1 -1
- package/dist/nav/navItem/navItem.d.ts +4 -2
- package/dist/nav/navItem/navItem.js +25 -10
- package/dist/nav/navMobileBar/navMobileBar.d.ts +11 -0
- package/dist/nav/navMobileBar/navMobileBar.js +33 -0
- package/dist/nav/navSection/navSection.js +52 -1
- package/dist/nav/storyHelpers/storyDecorator.js +2 -1
- package/dist/nav/utils/navUtils.d.ts +6 -1
- package/dist/nav/utils/navUtils.js +48 -1
- package/dist/pageHeader/pageHeader.d.ts +16 -0
- package/dist/pageHeader/pageHeader.js +21 -0
- package/dist/pageHeader/pageHeaderActions.d.ts +10 -0
- package/dist/pageHeader/pageHeaderActions.js +35 -0
- package/dist/pageHeader/pageHeaderButton.d.ts +16 -0
- package/dist/pageHeader/pageHeaderButton.js +26 -0
- package/dist/pageHeader/pageHeaderFilters.d.ts +13 -0
- package/dist/pageHeader/pageHeaderFilters.js +7 -0
- package/dist/pageHeader/pageHeaderHelpers.d.ts +4 -0
- package/dist/pageHeader/pageHeaderHelpers.js +62 -0
- package/dist/pageHeader/pageHeaderMenu.d.ts +9 -0
- package/dist/pageHeader/pageHeaderMenu.js +9 -0
- package/dist/pillBox/components/pillBoxItem.js +1 -1
- package/dist/pillBox/pillBox.d.ts +1 -0
- package/dist/pillBox/pillBox.js +2 -2
- package/dist/range/range.d.ts +2 -1
- package/dist/range/range.js +11 -2
- package/dist/tabs/tabs.d.ts +1 -2
- package/dist/utils/localization/translations/en-json.d.ts +18 -0
- package/dist/utils/localization/translations/en-json.js +19 -1
- package/package.json +4 -4
|
@@ -6,7 +6,7 @@ export declare const getGroupsTreeItem: (stateObj: IDropdownState, itemId: strin
|
|
|
6
6
|
export declare const getListDataWithDisabled: (listData: IDropdownItem[], isIgnoreDisabled: boolean) => IDropdownItem[];
|
|
7
7
|
export declare const isAllChildrenSelected: (stateObj: IDropdownState, currentId?: string) => boolean;
|
|
8
8
|
export declare const isEveryItemSelected: (listData: IDropdownItem[], selectedItems: string[]) => boolean;
|
|
9
|
-
export declare const getDataForChange: (listData: IDropdownItem[], selectedItems: string[], isDeselect: boolean) =>
|
|
9
|
+
export declare const getDataForChange: (listData: IDropdownItem[], selectedItems: string[], isDeselect: boolean) => string[];
|
|
10
10
|
export declare const isAllItemsHasOneParent: (listData: IDropdownItem[], childrenArr: string[]) => boolean;
|
|
11
11
|
export declare function prepareComboOptionsForList(actionListData: Set<string>, translate: (s: string) => string, options: IDropdownItem[], getSelectedFn: () => string[], getSelectedChildFn: (optionId: any) => string[], isFlatList: boolean, getTitle?: (itemId: string) => string, isAllSelected?: boolean): ICheckboxListWithActionOption[];
|
|
12
12
|
export declare const createOptions: (stateObj: IDropdownState, translate: (s: string) => string, listItem: IDropdownItem[], isAllSelected?: boolean) => ICheckboxListWithActionOption[];
|
|
@@ -29,10 +29,14 @@ const isEveryItemSelected = (listData, selectedItems) => {
|
|
|
29
29
|
exports.isEveryItemSelected = isEveryItemSelected;
|
|
30
30
|
const getDataForChange = (listData, selectedItems, isDeselect) => {
|
|
31
31
|
const selectedItemsSet = new Set(selectedItems);
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const result = [];
|
|
33
|
+
for (const item of listData) {
|
|
34
|
+
const isSelected = selectedItemsSet.has(item.id);
|
|
35
|
+
if ((isDeselect && isSelected) || (!isDeselect && !isSelected)) {
|
|
36
|
+
result.push(item.id);
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
|
-
return
|
|
39
|
+
return result;
|
|
36
40
|
};
|
|
37
41
|
exports.getDataForChange = getDataForChange;
|
|
38
42
|
const isAllItemsHasOneParent = (listData, childrenArr) => {
|
|
@@ -39,6 +39,7 @@ export interface IDropdownList extends IZenComponentProps {
|
|
|
39
39
|
isChecked?: boolean;
|
|
40
40
|
}
|
|
41
41
|
interface IDropdownEmptyList extends Pick<IDropdownList, "translate" | "className" | "width" | "onClearClick" | "onApplyClick" | "onCancelClick" | "hasApplyButton" | "isApplyDisabled" | "isClearButtonDisabled" | "isWithFooter"> {
|
|
42
|
+
hasError: boolean;
|
|
42
43
|
}
|
|
43
44
|
export declare const EmptyList: React.FC<IDropdownEmptyList>;
|
|
44
45
|
export declare const DropdownList: React.FC<IDropdownList>;
|
|
@@ -38,10 +38,10 @@ const useDrive_1 = require("../utils/theme/useDrive");
|
|
|
38
38
|
const useDriveClassName_1 = require("../utils/theme/useDriveClassName");
|
|
39
39
|
const useLanguage_1 = require("../utils/localization/useLanguage");
|
|
40
40
|
const checkbox_1 = require("../checkbox/checkbox");
|
|
41
|
-
const EmptyList = ({ className, width, onClearClick, onApplyClick, onCancelClick, hasApplyButton, isApplyDisabled, isClearButtonDisabled, isWithFooter }) => {
|
|
41
|
+
const EmptyList = ({ className, width, onClearClick, onApplyClick, onCancelClick, hasApplyButton, isApplyDisabled, isClearButtonDisabled, isWithFooter, hasError }) => {
|
|
42
42
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
43
43
|
const styleWidth = width ? { style: { width: `${width}px` } } : {};
|
|
44
|
-
return (0, jsx_runtime_1.jsxs)("div", Object.assign({}, styleWidth, { className: (0, classNames_1.classNames)(["zen-dropdown-list__container", className || ""]), children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__container--empty", children: translate("No data") }), isWithFooter ? (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__footer", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onClearClick, disabled: isClearButtonDisabled, className: "zen-dropdown-list__clear-button", type: buttonType_1.ButtonType.Tertiary, title: translate("Clear"), children: translate("Clear") }), hasApplyButton && (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__button-group", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onCancelClick, className: "zen-dropdown-list__cancel-button", title: translate("Cancel"), children: translate("Cancel") }), (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onApplyClick, type: buttonType_1.ButtonType.Primary, disabled: isApplyDisabled, className: "zen-dropdown-list__apply-button", title: translate("Apply"), children: translate("Apply") })] })] }) : null] }));
|
|
44
|
+
return (0, jsx_runtime_1.jsxs)("div", Object.assign({}, styleWidth, { className: (0, classNames_1.classNames)(["zen-dropdown-list__container", className || ""]), children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__container--empty", children: translate(hasError ? "Error Loading Items" : "No data") }), isWithFooter ? (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__footer", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onClearClick, disabled: isClearButtonDisabled, className: "zen-dropdown-list__clear-button", type: buttonType_1.ButtonType.Tertiary, title: translate("Clear"), children: translate("Clear") }), hasApplyButton && (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__button-group", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onCancelClick, className: "zen-dropdown-list__cancel-button", title: translate("Cancel"), children: translate("Cancel") }), (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onApplyClick, type: buttonType_1.ButtonType.Primary, disabled: isApplyDisabled, className: "zen-dropdown-list__apply-button", title: translate("Apply"), children: translate("Apply") })] })] }) : null] }));
|
|
45
45
|
};
|
|
46
46
|
exports.EmptyList = EmptyList;
|
|
47
47
|
const DropdownList = ({ onBackButtonClick, onSelectAllClick, onClearClick, onApplyClick, onCancelClick, onChange, onSelect, onSingleSelect, listData, isAllSelected, backButtonName, width, minWidth, isSelectAllButtonDisable, hasSelectAllButton, filterName, isMultiselect, hasApplyButton, isApplyDisabled, isClearButtonDisabled, activeValue, forceSelection, isWithFooter, isMobile, handleCheckboxChange, checkboxLabel, isChecked }) => {
|
|
@@ -28,5 +28,6 @@ export interface IDropdownPopup extends IZenComponentProps {
|
|
|
28
28
|
handleCheckboxChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
29
29
|
checkboxLabel?: string;
|
|
30
30
|
isChecked?: boolean;
|
|
31
|
+
isSearchInPopup?: boolean;
|
|
31
32
|
}
|
|
32
33
|
export declare const DropdownPopup: React.FC<IDropdownPopup>;
|
|
@@ -13,7 +13,7 @@ const useLanguage_1 = require("../utils/localization/useLanguage");
|
|
|
13
13
|
const footerButtons_1 = require("../footerButtons/footerButtons");
|
|
14
14
|
const checkbox_1 = require("../checkbox/checkbox");
|
|
15
15
|
const useScrollWithAndroidKeyboard_1 = require("../utils/useScrollWithAndroidKeyboard");
|
|
16
|
-
const DropdownPopup = ({ alignment, triggerRef, classNamePopup, isMobile, inputValue, dialogAriaLabel, disabled, filterName, handleApplyClick, handleClearClick, handleTriggerClick, onInputChange, hasApplyButton, inputId, isClearButtonDisabled, isWithFooter, placeholder, searchField, isApplyButtonDisabled, isOpenCombo, inputRef, contentRef, children, onReadyForFocus, handleCheckboxChange, checkboxLabel, isChecked }) => {
|
|
16
|
+
const DropdownPopup = ({ alignment, triggerRef, classNamePopup, isMobile, inputValue, dialogAriaLabel, disabled, filterName, handleApplyClick, handleClearClick, handleTriggerClick, onInputChange, hasApplyButton, inputId, isClearButtonDisabled, isWithFooter, placeholder, searchField, isSearchInPopup, isApplyButtonDisabled, isOpenCombo, inputRef, contentRef, children, onReadyForFocus, handleCheckboxChange, checkboxLabel, isChecked }) => {
|
|
17
17
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
18
18
|
const triggerId = (0, react_1.useId)();
|
|
19
19
|
const { handleFocus, handleBlur, wrapperClass } = (0, useScrollWithAndroidKeyboard_1.useScrollWithAndroidKeyboard)();
|
|
@@ -29,7 +29,7 @@ const DropdownPopup = ({ alignment, triggerRef, classNamePopup, isMobile, inputV
|
|
|
29
29
|
return (0, jsx_runtime_1.jsxs)(footerButtons_1.FooterButtons, { children: [hasApplyButton ? (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: handleApplyClick, type: buttonType_1.ButtonType.Primary, disabled: isApplyButtonDisabled, className: "zen-ellipsis", title: translate("Apply"), children: translate("Apply") }) : null, (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: handleClearClick, disabled: isClearButtonDisabled, className: "zen-ellipsis", type: buttonType_1.ButtonType.Tertiary, title: translate("Clear"), children: translate("Clear") })] });
|
|
30
30
|
}, [handleApplyClick, handleClearClick, hasApplyButton, isApplyButtonDisabled, isClearButtonDisabled, isWithFooter, translate]);
|
|
31
31
|
const memoizedMobileView = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsxs)(mobileSheet_1.MobileSheet, { className: (0, classNames_1.classNames)(["zen-dropdown--mobile", classNamePopup || ""]), wrapperClassName: wrapperClass, label: "label", triggerRef: triggerRef, isOpen: isOpenCombo, onHidePanel: memoizedHandleHide, onCloseClick: memoizedHandleHide, useTrapFocusWithTrigger: true, onReadyForFocus: onReadyForFocus, children: [(0, jsx_runtime_1.jsx)(mobileSheet_1.MobileSheet.Title, { className: "zen-dropdown-mobile-sheet__title", children: filterName || placeholder || "" }), (0, jsx_runtime_1.jsx)(mobileSheet_1.MobileSheet.Content, { children: memoizedMobileContent }), (0, jsx_runtime_1.jsx)(mobileSheet_1.MobileSheet.Footer, { children: memoizedMobileFooter })] }), [classNamePopup, wrapperClass, triggerRef, isOpenCombo, memoizedHandleHide, onReadyForFocus, filterName, placeholder, memoizedMobileContent, memoizedMobileFooter]);
|
|
32
|
-
const memoizedDesktopView = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(controlledPopup_1.ControlledPopup, { isOpen: isOpenCombo, className: (0, classNames_1.classNames)(["zen-dropdown-popup zen-shadow-dropdown-default", classNamePopup || ""]), onOpenChange: handleTriggerClick, useTrapFocusWithTrigger: "withTrigger", alignment: alignment, shouldHoldScroll: true, triggerRef: triggerRef, ariaLabel: dialogAriaLabel || placeholder || translate("Filter by group"), recalculateOnScroll: true, children: (0, jsx_runtime_1.
|
|
32
|
+
const memoizedDesktopView = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(controlledPopup_1.ControlledPopup, { isOpen: isOpenCombo, className: (0, classNames_1.classNames)(["zen-dropdown-popup zen-shadow-dropdown-default", classNamePopup || ""]), onOpenChange: handleTriggerClick, useTrapFocusWithTrigger: "withTrigger", alignment: alignment, shouldHoldScroll: true, triggerRef: triggerRef, ariaLabel: dialogAriaLabel || placeholder || translate("Filter by group"), recalculateOnScroll: true, children: (0, jsx_runtime_1.jsxs)("div", { ref: contentRef, children: [searchField && isSearchInPopup ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-popup__search-container", children: (0, jsx_runtime_1.jsx)(searchInput_1.SearchInput, { className: "zen-dropdown-chip__search", onChange: onInputChange, value: inputValue || "", ref: inputRef, id: inputId || triggerId, disabled: disabled, placeholder: placeholder || translate("Filter by group") }) }) : null, children] }) }), [alignment, children, classNamePopup, contentRef, dialogAriaLabel, disabled, handleTriggerClick, inputId, inputRef, inputValue, isOpenCombo, isSearchInPopup, onInputChange, placeholder, searchField, translate, triggerId, triggerRef]);
|
|
33
33
|
return isMobile ? memoizedMobileView : memoizedDesktopView;
|
|
34
34
|
};
|
|
35
35
|
exports.DropdownPopup = DropdownPopup;
|
|
@@ -4,6 +4,10 @@ interface IPayloadSelectionAction {
|
|
|
4
4
|
value: boolean;
|
|
5
5
|
itemId: string;
|
|
6
6
|
}
|
|
7
|
+
interface IPayloadBulkSelectionAction {
|
|
8
|
+
value: boolean;
|
|
9
|
+
itemsIds: string[];
|
|
10
|
+
}
|
|
7
11
|
interface IPayloadShowAction {
|
|
8
12
|
show: "showWaiting" | "showEmptyList" | "showList";
|
|
9
13
|
value: boolean;
|
|
@@ -69,6 +73,10 @@ interface IChangeSelectionAction {
|
|
|
69
73
|
type: StateActionType.ChangeSelection;
|
|
70
74
|
payload: IPayloadSelectionAction;
|
|
71
75
|
}
|
|
76
|
+
interface IChangeBulkSelectionAction {
|
|
77
|
+
type: StateActionType.ChangeBulkSelection;
|
|
78
|
+
payload: IPayloadBulkSelectionAction;
|
|
79
|
+
}
|
|
72
80
|
interface IChangeSingleSelectionAction {
|
|
73
81
|
type: StateActionType.ChangeSingleSelection;
|
|
74
82
|
payload: IPayloadSingleSelectionAction;
|
|
@@ -129,5 +137,5 @@ interface IUpdateNamelessItemsAction {
|
|
|
129
137
|
type: StateActionType.UpdateNamelessItems;
|
|
130
138
|
payload: undefined;
|
|
131
139
|
}
|
|
132
|
-
export type TStateAction = ICreateMapAction | ISetStateAction | ISetGlobalStateAction | ISetListDataAction | ISetIsOpenComboAction | IShowAction | IShowWaitingAction | IShowEmptyListAction | IShowListAction | ISetInputValueAction | INothingToShowAction | ISetCurrentIdAction | IChangeSelectionAction | IChangeSingleSelectionAction | ISelectAllChildrenAction | IDeselectAllChildrenAction | IResetSelection | IResetStateToGlobal | ISetDataProblemAction | ISetDefaultValueAction | IUpdateSelectedItemsAction | ISetPendingStateAction | IUpdateNamelessItemsAction | IToggleValueForAllSelectedAction | IDeselectItemsFromAllSelectedAction | ISetDefaultAllSelectedAction | ISetIsCheckedAction | ISetIsCheckedAction | ISetDefaultIsCheckedAction;
|
|
140
|
+
export type TStateAction = ICreateMapAction | ISetStateAction | ISetGlobalStateAction | ISetListDataAction | ISetIsOpenComboAction | IShowAction | IShowWaitingAction | IShowEmptyListAction | IShowListAction | ISetInputValueAction | INothingToShowAction | ISetCurrentIdAction | IChangeSelectionAction | IChangeBulkSelectionAction | IChangeSingleSelectionAction | ISelectAllChildrenAction | IDeselectAllChildrenAction | IResetSelection | IResetStateToGlobal | ISetDataProblemAction | ISetDefaultValueAction | IUpdateSelectedItemsAction | ISetPendingStateAction | IUpdateNamelessItemsAction | IToggleValueForAllSelectedAction | IDeselectItemsFromAllSelectedAction | ISetDefaultAllSelectedAction | ISetIsCheckedAction | ISetIsCheckedAction | ISetDefaultIsCheckedAction;
|
|
133
141
|
export {};
|
|
@@ -5,6 +5,7 @@ export declare enum StateActionType {
|
|
|
5
5
|
SetGlobalState = "SET_GLOBAL_STATE",
|
|
6
6
|
SetListData = "SET_LIST_DATA",
|
|
7
7
|
ChangeSelection = "CHANGE_SELECTION",
|
|
8
|
+
ChangeBulkSelection = "CHANGE_BULK_SELECTION",
|
|
8
9
|
ChangeSingleSelection = "CHANGE_SINGLE_SELECTION",
|
|
9
10
|
DeselectAllChildren = "DESELECT_ALL_CHILDREN",
|
|
10
11
|
SelectAllChildren = "SELECT_ALL_CHILDREN",
|
|
@@ -9,6 +9,7 @@ var StateActionType;
|
|
|
9
9
|
StateActionType["SetGlobalState"] = "SET_GLOBAL_STATE";
|
|
10
10
|
StateActionType["SetListData"] = "SET_LIST_DATA";
|
|
11
11
|
StateActionType["ChangeSelection"] = "CHANGE_SELECTION";
|
|
12
|
+
StateActionType["ChangeBulkSelection"] = "CHANGE_BULK_SELECTION";
|
|
12
13
|
StateActionType["ChangeSingleSelection"] = "CHANGE_SINGLE_SELECTION";
|
|
13
14
|
StateActionType["DeselectAllChildren"] = "DESELECT_ALL_CHILDREN";
|
|
14
15
|
StateActionType["SelectAllChildren"] = "SELECT_ALL_CHILDREN";
|
|
@@ -229,6 +229,41 @@ function stateReducer(state, action) {
|
|
|
229
229
|
});
|
|
230
230
|
return Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds) });
|
|
231
231
|
}
|
|
232
|
+
case stateActionType_1.StateActionType.ChangeBulkSelection: {
|
|
233
|
+
const { itemsIds, value } = payload;
|
|
234
|
+
const currentSelectedIds = new Set(state.selectedIds);
|
|
235
|
+
const parentsToProcess = new Set();
|
|
236
|
+
const childrenToProcess = new Set();
|
|
237
|
+
itemsIds.forEach(itemId => {
|
|
238
|
+
var _a, _b, _c, _d;
|
|
239
|
+
if (value) {
|
|
240
|
+
currentSelectedIds.add(itemId);
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
242
|
+
let parent = (_b = (_a = state.groupsMap[itemId]) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id;
|
|
243
|
+
while (parent && parent !== "root") {
|
|
244
|
+
parentsToProcess.add(parent);
|
|
245
|
+
parent = (_c = state.groupsMap[parent].parent) === null || _c === void 0 ? void 0 : _c.id;
|
|
246
|
+
}
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
248
|
+
const currentChild = (0, stateReducerHelper_1.getChildList)((_d = state.groupsMap[itemId]) === null || _d === void 0 ? void 0 : _d.children);
|
|
249
|
+
currentChild.forEach(childId => childrenToProcess.add(childId.id));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
currentSelectedIds.delete(itemId);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
childrenToProcess.forEach(childId => currentSelectedIds.delete(childId));
|
|
256
|
+
parentsToProcess.forEach(parentId => currentSelectedIds.delete(parentId));
|
|
257
|
+
currentSelectedIds.forEach(id => {
|
|
258
|
+
if (!state.groupsMapSelected.has(id)) {
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
260
|
+
const item = state.groupsMap[id] || state.listData.find(el => el.id === id);
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
262
|
+
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds) });
|
|
266
|
+
}
|
|
232
267
|
case stateActionType_1.StateActionType.SelectAllChildren: {
|
|
233
268
|
const currentEl = state.groupsMap[payload];
|
|
234
269
|
const newSelected = new Set(state.selectedIds);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const useDropdownState: (withCheckbox?: boolean) => {
|
|
3
|
+
checked?: boolean | undefined;
|
|
4
|
+
setChecked?: import("react").Dispatch<import("react").SetStateAction<boolean>> | undefined;
|
|
5
|
+
search: string;
|
|
6
|
+
setSearch: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDropdownState = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useDropdownState = (withCheckbox) => {
|
|
6
|
+
const [search, setSearch] = (0, react_1.useState)("");
|
|
7
|
+
const [checked, setChecked] = (0, react_1.useState)(false);
|
|
8
|
+
return Object.assign({ search, setSearch }, (withCheckbox ? { checked, setChecked } : {}));
|
|
9
|
+
};
|
|
10
|
+
exports.useDropdownState = useDropdownState;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IFiltersItem } from "./filtersItem";
|
|
3
|
+
import { IChip } from "../../chip/chip";
|
|
4
|
+
export interface IFiltersChipProps extends Pick<IChip, "disabled" | "icon" | "status" | "readonly"> {
|
|
5
|
+
}
|
|
6
|
+
export interface IFiltersChip extends Omit<IFiltersItem<boolean>, "defaultState">, IFiltersChipProps {
|
|
7
|
+
}
|
|
8
|
+
export declare const FiltersChipDisplayName = "FiltersChip";
|
|
9
|
+
export declare const FiltersChip: React.FC<IFiltersChip>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.FiltersChip = exports.FiltersChipDisplayName = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const classNames_1 = require("../../commonHelpers/classNames/classNames");
|
|
18
|
+
const chip_1 = require("../../chip/chip");
|
|
19
|
+
const chipStatusProvider_1 = require("../../chip/chipStatusProvider");
|
|
20
|
+
exports.FiltersChipDisplayName = "FiltersChip";
|
|
21
|
+
const FiltersChip = (_a) => {
|
|
22
|
+
var { className, name, state, onChange: onChangeState, id } = _a, componentProps = __rest(_a, ["className", "name", "state", "onChange", "id"]);
|
|
23
|
+
const chipStatus = (0, chipStatusProvider_1.useChipStatus)();
|
|
24
|
+
const component = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(chip_1.Chip, Object.assign({ id: id }, componentProps, { className: (0, classNames_1.classNames)(["zen-filters-chip", className || ""]), active: state, status: state ? chipStatus || undefined : undefined, onChange: () => onChangeState(!state), children: name })), [id, componentProps, className, state, chipStatus, name, onChangeState]);
|
|
25
|
+
return component;
|
|
26
|
+
};
|
|
27
|
+
exports.FiltersChip = FiltersChip;
|
|
28
|
+
exports.FiltersChip.displayName = exports.FiltersChipDisplayName;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { IZenComponentProps } from "../../commonHelpers/zenComponent";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export interface IFiltersContainer extends IZenComponentProps {
|
|
5
|
+
isPinned?: boolean;
|
|
6
|
+
onPinChange?: (isPinned: boolean) => void;
|
|
7
|
+
filtersClickHandler: () => void;
|
|
8
|
+
hasSavedFilters: boolean;
|
|
9
|
+
filtersForCalculation: ReactElement[];
|
|
10
|
+
onSaveFilters?: (filterName: string, filterState?: Record<string, unknown>) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const FiltersContainer: React.FC<IFiltersContainer>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FiltersContainer = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const classNames_1 = require("../../commonHelpers/classNames/classNames");
|
|
10
|
+
const chip_1 = require("../../chip/chip");
|
|
11
|
+
const react_2 = __importDefault(require("react"));
|
|
12
|
+
const iconFilter_1 = require("../../icons/iconFilter");
|
|
13
|
+
const iconPin2_1 = require("../../icons/iconPin2");
|
|
14
|
+
const filtersHelper_1 = require("../filtersHelper");
|
|
15
|
+
const filtersSavedChipComponent_1 = require("./filtersSavedChipComponent");
|
|
16
|
+
const iconClose_1 = require("../../icons/iconClose");
|
|
17
|
+
const chipStatusProvider_1 = require("../../chip/chipStatusProvider");
|
|
18
|
+
const useLanguage_1 = require("../../utils/localization/useLanguage");
|
|
19
|
+
const FiltersContainer = ({ className, isPinned = false, onPinChange, filtersClickHandler, hasSavedFilters, filtersForCalculation, children }) => {
|
|
20
|
+
const chipStatus = (0, chipStatusProvider_1.useChipStatus)();
|
|
21
|
+
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
22
|
+
const numberOfChangedFilters = (0, react_1.useMemo)(() => {
|
|
23
|
+
const suppressedFilters = new Set();
|
|
24
|
+
filtersForCalculation.forEach(filter => {
|
|
25
|
+
const inhibited = (filter.props).inhibit;
|
|
26
|
+
if (inhibited) {
|
|
27
|
+
inhibited.forEach((id) => suppressedFilters.add(id));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const filteredState = (0, filtersHelper_1.getFiltersState)(filtersForCalculation.filter(f => !suppressedFilters.has(f.props.id)));
|
|
31
|
+
return (0, filtersHelper_1.getNumberOfChangedFilters)(filteredState);
|
|
32
|
+
}, [filtersForCalculation]);
|
|
33
|
+
const filtersChipRef = (0, react_1.useRef)(null);
|
|
34
|
+
const handlePinChange = (0, react_1.useCallback)((newIsPinned) => {
|
|
35
|
+
onPinChange && onPinChange(newIsPinned);
|
|
36
|
+
}, [onPinChange]);
|
|
37
|
+
const pinComponent = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(chip_1.Chip, { active: isPinned, status: isPinned ? "accent" : undefined, onChange: handlePinChange, icon: iconPin2_1.IconPin2, children: isPinned ? "" : "+" }), [isPinned, handlePinChange]);
|
|
38
|
+
const filtersChipComponent = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(chip_1.Chip, { quantity: numberOfChangedFilters, isOpen: false, status: numberOfChangedFilters > 0 ? chipStatus || "active" : undefined, onClick: filtersClickHandler, icon: iconFilter_1.IconFilter, title: translate("All Filters"), triggerRef: filtersChipRef, children: "+" }), [numberOfChangedFilters, chipStatus, filtersClickHandler, translate]);
|
|
39
|
+
const childrenSignature = (0, react_1.useMemo)(() => {
|
|
40
|
+
const childrenArray = react_2.default.Children.toArray(children).filter(Boolean);
|
|
41
|
+
return childrenArray
|
|
42
|
+
.map(child => {
|
|
43
|
+
if (!react_2.default.isValidElement(child)) {
|
|
44
|
+
return "invalid";
|
|
45
|
+
}
|
|
46
|
+
const childId = child.props.id || "no-id";
|
|
47
|
+
const state = child.props.state;
|
|
48
|
+
const defaultState = child.props.defaultState;
|
|
49
|
+
const childPropsQuery = JSON.stringify(child.props.fetchState || {});
|
|
50
|
+
const stateHash = (0, filtersHelper_1.createStateHash)(state);
|
|
51
|
+
const defaultStateHash = (0, filtersHelper_1.createStateHash)(defaultState);
|
|
52
|
+
const propsHash = (0, filtersHelper_1.createPropsHash)(child.props);
|
|
53
|
+
return `${childId}|${stateHash}|${defaultStateHash}|${propsHash}|${childPropsQuery}`;
|
|
54
|
+
})
|
|
55
|
+
.join("||");
|
|
56
|
+
}, [children]);
|
|
57
|
+
const memoizedChildren = (0, react_1.useMemo)(() => (0, filtersHelper_1.stabilizeChildrenWithId)(children).filter(Boolean),
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
[childrenSignature]);
|
|
60
|
+
const handleRemovalClick = (0, react_1.useCallback)(() => {
|
|
61
|
+
const defaultState = (0, filtersHelper_1.createStateObject)(filtersForCalculation, "defaultState");
|
|
62
|
+
filtersForCalculation.forEach((child) => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
65
|
+
if (child) {
|
|
66
|
+
const childDefaultState = defaultState[child.props.id];
|
|
67
|
+
(_b = (_a = child.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, childDefaultState);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
onPinChange === null || onPinChange === void 0 ? void 0 : onPinChange(false);
|
|
71
|
+
}, [filtersForCalculation, onPinChange]);
|
|
72
|
+
const chipRemovalComponent = (0, react_1.useMemo)(() => numberOfChangedFilters ?
|
|
73
|
+
(0, jsx_runtime_1.jsx)(chip_1.Chip, { title: translate("Clear"), className: "zen-filters-container__removal-chip", active: false, status: isPinned ? "accent" : undefined, onChange: handleRemovalClick, icon: iconClose_1.IconClose })
|
|
74
|
+
: null, [isPinned, handleRemovalClick, translate, numberOfChangedFilters]);
|
|
75
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-filters-container", className || ""]), children: [memoizedChildren, onPinChange ? pinComponent : null, hasSavedFilters ? (0, jsx_runtime_1.jsx)(filtersSavedChipComponent_1.FiltersSavedChipComponent, {}) : null, filtersChipComponent, chipRemovalComponent] });
|
|
76
|
+
};
|
|
77
|
+
exports.FiltersContainer = FiltersContainer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IFiltersItem } from "./filtersItem";
|
|
3
|
+
import { IIcon } from "../../icons/icon";
|
|
4
|
+
export interface IFiltersCustom<T> extends IFiltersItem<T> {
|
|
5
|
+
chipIcon?: React.FC<IIcon>;
|
|
6
|
+
chipName?: string;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const FiltersCustomDisplayName = "FiltersCustom";
|
|
10
|
+
export declare const FiltersCustom: {
|
|
11
|
+
<T = unknown>({ state, defaultState, name, chipIcon, chipName, id }: IFiltersCustom<T>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiltersCustom = exports.FiltersCustomDisplayName = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const iconFilter_1 = require("../../icons/iconFilter");
|
|
7
|
+
const chip_1 = require("../../chip/chip");
|
|
8
|
+
exports.FiltersCustomDisplayName = "FiltersCustom";
|
|
9
|
+
const FiltersCustom = ({ state, defaultState, name, chipIcon, chipName, id }) => {
|
|
10
|
+
const triggerRef = (0, react_1.useRef)(null);
|
|
11
|
+
const chipComponent = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(chip_1.Chip, { status: state === defaultState ? undefined : "active", isOpen: false, disabled: false, onClick: () => { }, onClose: state === defaultState ? undefined : () => { }, triggerRef: triggerRef, icon: chipIcon || iconFilter_1.IconFilter, id: id, children: chipName || name }), [state, defaultState, chipIcon, id, chipName, name]);
|
|
12
|
+
return chipComponent;
|
|
13
|
+
};
|
|
14
|
+
exports.FiltersCustom = FiltersCustom;
|
|
15
|
+
exports.FiltersCustom.displayName = exports.FiltersCustomDisplayName;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IFiltersItem } from "./filtersItem";
|
|
3
|
+
import { IDateRangeValue, IDateRangeValueOptionalLabel } from "../../dateRange/dateRangeUtils";
|
|
4
|
+
import { IDateRange } from "../../dateRange/dateRange";
|
|
5
|
+
export interface IFiltersDateRangeProps extends Pick<IDateRange, "options" | "dropDownTitle" | "timeSelect" | "disableFutureDates" | "disablePastDates" | "lockEndDate" | "lockStartDate" | "classNamePopup" | "disableDatesBefore" | "disableDatesAfter" | "chipIcon"> {
|
|
6
|
+
allowUnsetValue?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface IFiltersDateRangeState extends IDateRangeValueOptionalLabel {
|
|
9
|
+
}
|
|
10
|
+
export interface IFiltersDateRangeCompleteState extends IDateRangeValue {
|
|
11
|
+
}
|
|
12
|
+
export interface IFiltersDateRangeDefaultState extends IDateRangeValue {
|
|
13
|
+
}
|
|
14
|
+
export type TFiltersDateRangeState = IFiltersDateRangeState | undefined;
|
|
15
|
+
export type TFiltersDateRangeCompleteState = IFiltersDateRangeCompleteState | undefined;
|
|
16
|
+
type TDateRangeStateType<P> = P extends {
|
|
17
|
+
allowUnsetValue: true;
|
|
18
|
+
} ? TFiltersDateRangeState : IFiltersDateRangeState;
|
|
19
|
+
export type TFiltersDateRangeStateOptional = TFiltersDateRangeState;
|
|
20
|
+
export type TFiltersDateRangeStateRequired = IFiltersDateRangeState;
|
|
21
|
+
type InferDateRangeOnChangeType<P> = (state: TDateRangeStateType<P>) => void;
|
|
22
|
+
export type IFiltersDateRangeItem<P extends IFiltersDateRangeProps = IFiltersDateRangeProps> = Omit<IFiltersItem<TDateRangeStateType<P>>, "onChange"> & P & {
|
|
23
|
+
state: TDateRangeStateType<P>;
|
|
24
|
+
onChange: InferDateRangeOnChangeType<P>;
|
|
25
|
+
defaultState: TDateRangeStateType<P>;
|
|
26
|
+
};
|
|
27
|
+
export type IFiltersDateRange = IFiltersDateRangeItem;
|
|
28
|
+
export declare const FiltersDateRangeDisplayName = "FiltersDateRange";
|
|
29
|
+
export declare const FiltersDateRange: {
|
|
30
|
+
<P extends IFiltersDateRangeProps = IFiltersDateRangeProps>({ className, state, defaultState, name, onChange: onChangeState, id, allowUnsetValue, chipIcon, ...dateRangeProps }: IFiltersDateRangeItem<P>): JSX.Element;
|
|
31
|
+
displayName: string;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.FiltersDateRange = exports.FiltersDateRangeDisplayName = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const classNames_1 = require("../../commonHelpers/classNames/classNames");
|
|
18
|
+
const dateRange_1 = require("../../dateRange/dateRange");
|
|
19
|
+
const iconCalendar_1 = require("../../icons/iconCalendar");
|
|
20
|
+
exports.FiltersDateRangeDisplayName = "FiltersDateRange";
|
|
21
|
+
const FiltersDateRange = (_a) => {
|
|
22
|
+
var { className, state, defaultState, name, onChange: onChangeState, id, allowUnsetValue, chipIcon } = _a, dateRangeProps = __rest(_a, ["className", "state", "defaultState", "name", "onChange", "id", "allowUnsetValue", "chipIcon"]);
|
|
23
|
+
const component = (0, react_1.useMemo)(() => allowUnsetValue ? (0, jsx_runtime_1.jsx)(dateRange_1.DateRange, Object.assign({}, dateRangeProps, { value: state, onChange: onChangeState, defaultValue: defaultState, allowUnsetValue: true, className: (0, classNames_1.classNames)(["zen-filters-date-range", className || ""]), chip: true, chipId: id, chipName: name, chipIcon: chipIcon || iconCalendar_1.IconCalendar })) : (0, jsx_runtime_1.jsx)(dateRange_1.DateRange, Object.assign({}, dateRangeProps, { value: state, onChange: onChangeState, defaultValue: defaultState, allowUnsetValue: false, className: (0, classNames_1.classNames)(["zen-filters-date-range", className || ""]), chip: true, chipId: id, chipName: name, chipIcon: chipIcon || iconCalendar_1.IconCalendar })), [dateRangeProps, id, state, defaultState, className, name, onChangeState, allowUnsetValue, chipIcon]);
|
|
24
|
+
return component;
|
|
25
|
+
};
|
|
26
|
+
exports.FiltersDateRange = FiltersDateRange;
|
|
27
|
+
exports.FiltersDateRange.displayName = exports.FiltersDateRangeDisplayName;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IDropdown, IDropdownFullSelection, IDropdownFullSelectionWithCheckbox, IDropdownWithCheckbox, IFetchDropdownState } from "../../dropdown/dropdown";
|
|
3
|
+
import { IFiltersItem } from "./filtersItem";
|
|
4
|
+
export interface IFiltersDropdownProps extends Omit<IDropdown | IDropdownFullSelection | IDropdownWithCheckbox | IDropdownFullSelectionWithCheckbox, "value" | "onChange" | "defaultValue" | "className" | "getData" | "dataItems" | "isLoading" | "errorHandler"> {
|
|
5
|
+
}
|
|
6
|
+
export type TFiltersDropdownState = string[];
|
|
7
|
+
export interface IFiltersDropdownFullSelectionState {
|
|
8
|
+
selected: string[];
|
|
9
|
+
isAllSelected: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface IFiltersDropdownWithCheckboxState {
|
|
12
|
+
selected: string[];
|
|
13
|
+
isChecked: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface IFiltersDropdownFullSelectionWithCheckboxState {
|
|
16
|
+
selected: string[];
|
|
17
|
+
isAllSelected: boolean;
|
|
18
|
+
isChecked: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type TFiltersDropdownComplexState = IFiltersDropdownFullSelectionState | IFiltersDropdownWithCheckboxState | IFiltersDropdownFullSelectionWithCheckboxState;
|
|
21
|
+
export type TFiltersDropdownAllStates = TFiltersDropdownState | TFiltersDropdownComplexState;
|
|
22
|
+
export type TInferOnChangeType<T> = T extends string[] ? (state: string[]) => void : T extends IFiltersDropdownWithCheckboxState ? (state: IFiltersDropdownWithCheckboxState) => void : T extends IFiltersDropdownFullSelectionState ? (state: IFiltersDropdownFullSelectionState) => void : T extends IFiltersDropdownFullSelectionWithCheckboxState ? (state: IFiltersDropdownFullSelectionWithCheckboxState) => void : (state: T) => void;
|
|
23
|
+
export interface IFiltersDropdown<T extends TFiltersDropdownAllStates = TFiltersDropdownState> extends Omit<IFiltersItem<T>, "onChange" | "defaultState">, IFiltersDropdownProps {
|
|
24
|
+
onChange: TInferOnChangeType<T>;
|
|
25
|
+
fetchState: IFetchDropdownState;
|
|
26
|
+
defaultState?: T;
|
|
27
|
+
}
|
|
28
|
+
export declare const FiltersDropdownDisplayName = "FiltersDropdown";
|
|
29
|
+
export declare function FiltersDropdown<T extends TFiltersDropdownAllStates = TFiltersDropdownState>({ className, state, name, defaultState, onChange: onChangeState, id, chipIcon, classNamePopup, fetchState, ...restDropdownProps }: IFiltersDropdown<T>): JSX.Element;
|
|
30
|
+
export declare namespace FiltersDropdown {
|
|
31
|
+
var displayName: string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.FiltersDropdown = exports.FiltersDropdownDisplayName = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const classNames_1 = require("../../commonHelpers/classNames/classNames");
|
|
18
|
+
const dropdown_1 = require("../../dropdown/dropdown");
|
|
19
|
+
const iconFilter_1 = require("../../icons/iconFilter");
|
|
20
|
+
const filtersHelper_1 = require("../filtersHelper");
|
|
21
|
+
exports.FiltersDropdownDisplayName = "FiltersDropdown";
|
|
22
|
+
function FiltersDropdown(_a) {
|
|
23
|
+
var { className, state, name, defaultState, onChange: onChangeState, id, chipIcon, classNamePopup, fetchState } = _a, restDropdownProps = __rest(_a, ["className", "state", "name", "defaultState", "onChange", "id", "chipIcon", "classNamePopup", "fetchState"]);
|
|
24
|
+
const prepareValue = (value) => {
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
return value.map((item) => item.id);
|
|
27
|
+
}
|
|
28
|
+
return Object.assign(Object.assign({}, value), { selected: value.selected.map((item) => item.id) });
|
|
29
|
+
};
|
|
30
|
+
const dropdownStateType = (0, filtersHelper_1.getDropdownStateType)(state);
|
|
31
|
+
const memoizedDefaultState = (0, react_1.useMemo)(() => defaultState ? defaultState : (0, filtersHelper_1.prepareDefaultDropdownState)(dropdownStateType), [dropdownStateType, defaultState]);
|
|
32
|
+
const component = (0, react_1.useMemo)(() => {
|
|
33
|
+
const dropdownPropsForComponent = Object.assign(Object.assign({}, restDropdownProps), { value: state, onChange: (newValue) => {
|
|
34
|
+
const preparedValue = prepareValue(newValue);
|
|
35
|
+
onChangeState(preparedValue);
|
|
36
|
+
}, multiselect: dropdownStateType === "fullSelection" || dropdownStateType === "fullSelectionWithCheckbox" ? true : restDropdownProps.multiselect, selectAllButton: dropdownStateType === "fullSelection" || dropdownStateType === "fullSelectionWithCheckbox" ? true : restDropdownProps.selectAllButton, fetchState: fetchState, isLoading: undefined, errorHandler: (() => { }), placeholder: restDropdownProps.placeholder || name, defaultValue: memoizedDefaultState, className: (0, classNames_1.classNames)(["zen-filters-dropdown", className || ""]), classNamePopup: (0, classNames_1.classNames)(["zen-filters-dropdown-popup", classNamePopup || ""]), chip: true, chipId: id, chipName: name, chipIcon: chipIcon || iconFilter_1.IconFilter });
|
|
37
|
+
return (0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, Object.assign({}, dropdownPropsForComponent));
|
|
38
|
+
}, [restDropdownProps, state, dropdownStateType, memoizedDefaultState, fetchState, className, classNamePopup, id, name, chipIcon, onChangeState]);
|
|
39
|
+
return component;
|
|
40
|
+
}
|
|
41
|
+
exports.FiltersDropdown = FiltersDropdown;
|
|
42
|
+
FiltersDropdown.displayName = exports.FiltersDropdownDisplayName;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IFiltersItem } from "./filtersItem";
|
|
3
|
+
import { IGroupsFilterTotalState } from "../../groupsFilter/groupsFilterInterfaces";
|
|
4
|
+
import { IGroupsFilter } from "../../groupsFilter/groupsFilter";
|
|
5
|
+
export interface IFiltersGroupsProps extends Pick<IGroupsFilter, "dataLoader" | "errorHandler" | "listLimit" | "chipIcon"> {
|
|
6
|
+
}
|
|
7
|
+
export interface IFiltersGroupsItem extends Omit<IFiltersItem<IGroupsFilterTotalState>, "defaultState"> {
|
|
8
|
+
state: IGroupsFilterTotalState;
|
|
9
|
+
onChange: (state: IGroupsFilterTotalState) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface IFiltersGroups extends IFiltersGroupsItem, IFiltersGroupsProps {
|
|
12
|
+
}
|
|
13
|
+
export declare const FiltersGroupsDisplayName = "FiltersGroups";
|
|
14
|
+
export declare const FiltersGroups: React.FC<IFiltersGroups>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.FiltersGroups = exports.FiltersGroupsDisplayName = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const classNames_1 = require("../../commonHelpers/classNames/classNames");
|
|
18
|
+
const groupsFilter_1 = require("../../groupsFilter/groupsFilter");
|
|
19
|
+
const iconFolders_1 = require("../../icons/iconFolders");
|
|
20
|
+
exports.FiltersGroupsDisplayName = "FiltersGroups";
|
|
21
|
+
const FiltersGroups = (_a) => {
|
|
22
|
+
var { className, state, name, onChange: onChangeState, id, chipIcon } = _a, otherGroupsFilterProps = __rest(_a, ["className", "state", "name", "onChange", "id", "chipIcon"]);
|
|
23
|
+
// defaultState here getDefaultFilterState()
|
|
24
|
+
const component = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(groupsFilter_1.GroupsFilter, Object.assign({}, otherGroupsFilterProps, { initialFilterState: state, onChange: onChangeState, className: (0, classNames_1.classNames)(["zen-filters-groups", className || ""]), chip: true, chipId: id, chipName: name, chipIcon: chipIcon || iconFolders_1.IconFolders })), [otherGroupsFilterProps, state, onChangeState, className, id, name, chipIcon]);
|
|
25
|
+
return component;
|
|
26
|
+
};
|
|
27
|
+
exports.FiltersGroups = FiltersGroups;
|
|
28
|
+
exports.FiltersGroups.displayName = exports.FiltersGroupsDisplayName;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IGroupsFilterTotalState } from "../../groupsFilter/groupsFilterInterfaces";
|
|
3
|
+
import { FiltersChip, IFiltersChip } from "./filtersChip";
|
|
4
|
+
import { FiltersDateRange, IFiltersDateRangeItem, TFiltersDateRangeState } from "./filtersDateRange";
|
|
5
|
+
import { FiltersDropdown, IFiltersDropdown, TFiltersDropdownAllStates } from "./filtersDropdown";
|
|
6
|
+
import { FiltersGroups, IFiltersGroups } from "./filtersGroups";
|
|
7
|
+
import { FiltersRange, IFiltersRange, IFiltersRangeState } from "./filtersRange";
|
|
8
|
+
export interface IFiltersItem<State = unknown> {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
state: State;
|
|
12
|
+
onChange: (state: State) => void;
|
|
13
|
+
defaultState: State;
|
|
14
|
+
visible?: ((selection: string[], allFiltersState?: Record<string, TFiltersComponentsItemState>) => boolean) | boolean;
|
|
15
|
+
inhibit?: string[];
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
export type TFiltersComponents = typeof FiltersChip | typeof FiltersDateRange | typeof FiltersDropdown | typeof FiltersGroups | typeof FiltersRange;
|
|
19
|
+
export type TFiltersComponentsProps = IFiltersChip | IFiltersDateRangeItem | IFiltersDropdown | IFiltersGroups | IFiltersRange;
|
|
20
|
+
export type TFiltersComponentsItemState = boolean | TFiltersDateRangeState | TFiltersDropdownAllStates | IGroupsFilterTotalState | IFiltersRangeState;
|
|
21
|
+
export declare const allowedFiltersComponents: ({
|
|
22
|
+
<P extends import("./filtersDateRange").IFiltersDateRangeProps = import("./filtersDateRange").IFiltersDateRangeProps>({ className, state, defaultState, name, onChange: onChangeState, id, allowUnsetValue, chipIcon, ...dateRangeProps }: IFiltersDateRangeItem<P>): JSX.Element;
|
|
23
|
+
displayName: string;
|
|
24
|
+
} | React.FC<IFiltersGroups> | React.FC<IFiltersRange> | React.FC<IFiltersChip> | typeof FiltersDropdown)[];
|
|
25
|
+
export declare const getAllowedFilters: <T extends React.ReactNode>(items: T[]) => React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAllowedFilters = exports.allowedFiltersComponents = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const filtersChip_1 = require("./filtersChip");
|
|
9
|
+
const filtersDateRange_1 = require("./filtersDateRange");
|
|
10
|
+
const filtersDropdown_1 = require("./filtersDropdown");
|
|
11
|
+
const filtersGroups_1 = require("./filtersGroups");
|
|
12
|
+
const filtersRange_1 = require("./filtersRange");
|
|
13
|
+
exports.allowedFiltersComponents = [filtersChip_1.FiltersChip, filtersDateRange_1.FiltersDateRange, filtersDropdown_1.FiltersDropdown, filtersGroups_1.FiltersGroups, filtersRange_1.FiltersRange];
|
|
14
|
+
const getAllowedFilters = (items) => items.reduce((acc, item) => {
|
|
15
|
+
if (!item || !react_1.default.isValidElement(item)) {
|
|
16
|
+
return acc;
|
|
17
|
+
}
|
|
18
|
+
if (exports.allowedFiltersComponents.includes(item.type)) {
|
|
19
|
+
acc.push(item);
|
|
20
|
+
}
|
|
21
|
+
return acc;
|
|
22
|
+
}, []);
|
|
23
|
+
exports.getAllowedFilters = getAllowedFilters;
|