@geotab/zenith 3.0.1 → 3.1.0-beta.0
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 +17 -0
- package/dist/advancedGroupsFilter/advancedGroupsFilter.d.ts +1 -0
- package/dist/advancedGroupsFilter/advancedGroupsFilter.js +2 -2
- package/dist/advancedGroupsFilter/advancedGroupsFilterFormSection.js +3 -1
- package/dist/chip/chip.js +5 -5
- package/dist/commonStyles/zIndex.less +5 -0
- package/dist/dateInput/dateInput.d.ts +2 -1
- package/dist/dateInput/dateInput.js +11 -2
- package/dist/dateRange/dateRange.js +9 -8
- package/dist/dropdown/dropdown.d.ts +2 -0
- package/dist/dropdown/dropdown.js +6 -5
- package/dist/dropdown/dropdownHelper.d.ts +4 -4
- package/dist/dropdown/dropdownHelper.js +2 -1
- 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/dropdownSearchableTrigger.js +1 -1
- package/dist/dropdown/stateReducer/stateReducer.d.ts +6 -2
- package/dist/dropdown/stateReducer/stateReducer.js +28 -42
- package/dist/dropdown/stateReducer/stateReducerHelper.d.ts +2 -0
- package/dist/dropdown/stateReducer/stateReducerHelper.js +12 -1
- package/dist/dropdown/useDropdownState.d.ts +1 -1
- package/dist/dropdown/useDropdownState.js +5 -2
- package/dist/filters/components/filtersContainer.d.ts +1 -0
- package/dist/filters/components/filtersContainer.js +10 -11
- package/dist/filters/components/filtersDateInput.d.ts +10 -0
- package/dist/filters/components/filtersDateInput.js +27 -0
- package/dist/filters/components/filtersDropdown.d.ts +5 -4
- package/dist/filters/components/filtersDropdown.js +3 -3
- package/dist/filters/components/filtersEmptySelectedList.d.ts +2 -0
- package/dist/filters/components/filtersEmptySelectedList.js +11 -0
- package/dist/filters/components/filtersItem.d.ts +5 -4
- package/dist/filters/components/filtersItem.js +2 -1
- package/dist/filters/components/filtersSaveModal.d.ts +3 -1
- package/dist/filters/components/filtersSaveModal.js +2 -2
- package/dist/filters/components/filtersSavedChipComponent.js +68 -6
- package/dist/filters/components/filtersSearch.d.ts +4 -4
- package/dist/filters/components/filtersSearch.js +20 -9
- package/dist/filters/components/filtersSearchItemData.js +18 -1
- package/dist/filters/components/filtersSearchList.d.ts +5 -1
- package/dist/filters/components/filtersSearchList.js +155 -27
- package/dist/filters/components/filtersSelect.d.ts +1 -0
- package/dist/filters/components/filtersSelect.js +35 -7
- package/dist/filters/components/filtersSelectListItem.d.ts +21 -15
- package/dist/filters/components/filtersSelectListItem.js +13 -3
- package/dist/filters/components/filtersSidePanel.d.ts +15 -0
- package/dist/filters/components/filtersSidePanel.js +212 -0
- package/dist/filters/components/filtersSidePanelChip.d.ts +9 -0
- package/dist/filters/components/filtersSidePanelChip.js +13 -0
- package/dist/filters/components/filtersSidePanelDropdown.d.ts +6 -0
- package/dist/filters/components/filtersSidePanelDropdown.js +85 -0
- package/dist/filters/components/filtersSidePanelItem.d.ts +16 -0
- package/dist/filters/components/filtersSidePanelItem.js +67 -0
- package/dist/filters/components/filtersSidePanelRange.d.ts +6 -0
- package/dist/filters/components/filtersSidePanelRange.js +28 -0
- package/dist/filters/filters.d.ts +5 -0
- package/dist/filters/filters.js +101 -38
- package/dist/filters/filtersHelper.d.ts +4 -2
- package/dist/filters/filtersHelper.js +40 -1
- package/dist/filters/filtersHooks.d.ts +12 -2
- package/dist/filters/filtersHooks.js +21 -3
- package/dist/formStepper/formStepper.d.ts +1 -1
- package/dist/formStepper/formStepper.js +5 -2
- package/dist/groupsFilter/groupsFilter.js +72 -37
- package/dist/groupsFilter/groupsFilterMenu.d.ts +1 -0
- package/dist/groupsFilter/groupsFilterMenu.js +2 -2
- package/dist/groupsFilter/groupsFilterTrigger.js +1 -1
- package/dist/images/imageLooking.d.ts +4 -0
- package/dist/images/imageLooking.js +16 -0
- package/dist/index.css +407 -83
- package/dist/index.d.ts +7 -4
- package/dist/index.js +26 -15
- package/dist/list/list.d.ts +3 -1
- package/dist/list/list.js +2 -2
- package/dist/mobileSheet/mobileSheet.d.ts +2 -0
- package/dist/mobileSheet/mobileSheet.js +4 -4
- package/dist/modal/modal.d.ts +1 -0
- package/dist/modal/modal.js +2 -2
- package/dist/radioGroup/radioGroup.d.ts +1 -0
- package/dist/radioGroup/radioGroup.js +3 -2
- package/dist/range/range.js +29 -10
- package/dist/searchInputRaw/searchInputRaw.js +1 -1
- package/dist/sidePanel/sidePanel.d.ts +1 -0
- package/dist/sidePanel/sidePanel.js +3 -3
- package/dist/tabs/tabItem/tabItem.d.ts +1 -0
- package/dist/tabs/tabItem/tabItem.js +2 -2
- package/dist/tabs/tabs.d.ts +1 -0
- package/dist/tabs/tabs.js +1 -1
- package/dist/utils/keyboardHelpers.d.ts +2 -0
- package/dist/utils/keyboardHelpers.js +49 -0
- package/dist/utils/localization/translations/cs-json.d.ts +1 -0
- package/dist/utils/localization/translations/cs-json.js +2 -1
- package/dist/utils/localization/translations/de-json.d.ts +1 -0
- package/dist/utils/localization/translations/de-json.js +2 -1
- package/dist/utils/localization/translations/en-json.d.ts +7 -0
- package/dist/utils/localization/translations/en-json.js +8 -1
- package/dist/utils/localization/translations/es-json.d.ts +1 -0
- package/dist/utils/localization/translations/es-json.js +2 -1
- package/dist/utils/localization/translations/fr-FR-json.d.ts +1 -0
- package/dist/utils/localization/translations/fr-FR-json.js +2 -1
- package/dist/utils/localization/translations/fr-json.d.ts +1 -0
- package/dist/utils/localization/translations/fr-json.js +2 -1
- package/dist/utils/localization/translations/id-json.d.ts +1 -0
- package/dist/utils/localization/translations/id-json.js +2 -1
- package/dist/utils/localization/translations/it-json.d.ts +1 -0
- package/dist/utils/localization/translations/it-json.js +2 -1
- package/dist/utils/localization/translations/ja-json.d.ts +1 -0
- package/dist/utils/localization/translations/ja-json.js +2 -1
- package/dist/utils/localization/translations/ko-KR-json.d.ts +1 -0
- package/dist/utils/localization/translations/ko-KR-json.js +2 -1
- package/dist/utils/localization/translations/ms-json.d.ts +1 -0
- package/dist/utils/localization/translations/ms-json.js +2 -1
- package/dist/utils/localization/translations/nl-json.d.ts +1 -0
- package/dist/utils/localization/translations/nl-json.js +2 -1
- package/dist/utils/localization/translations/pl-json.d.ts +1 -0
- package/dist/utils/localization/translations/pl-json.js +2 -1
- package/dist/utils/localization/translations/pt-BR-json.d.ts +1 -0
- package/dist/utils/localization/translations/pt-BR-json.js +2 -1
- package/dist/utils/localization/translations/sv-json.d.ts +1 -0
- package/dist/utils/localization/translations/sv-json.js +2 -1
- package/dist/utils/localization/translations/th-json.d.ts +1 -0
- package/dist/utils/localization/translations/th-json.js +2 -1
- package/dist/utils/localization/translations/tr-json.d.ts +1 -0
- package/dist/utils/localization/translations/tr-json.js +2 -1
- package/dist/utils/localization/translations/zh-Hans-json.d.ts +1 -0
- package/dist/utils/localization/translations/zh-Hans-json.js +2 -1
- package/dist/utils/localization/translations/zh-TW-json.d.ts +1 -0
- package/dist/utils/localization/translations/zh-TW-json.js +2 -1
- package/esm/advancedGroupsFilter/advancedGroupsFilter.d.ts +1 -0
- package/esm/advancedGroupsFilter/advancedGroupsFilter.js +2 -2
- package/esm/advancedGroupsFilter/advancedGroupsFilterFormSection.js +3 -1
- package/esm/chip/chip.js +5 -5
- package/esm/dateInput/dateInput.d.ts +2 -1
- package/esm/dateInput/dateInput.js +11 -2
- package/esm/dateRange/dateRange.js +9 -8
- package/esm/dropdown/dropdown.d.ts +2 -0
- package/esm/dropdown/dropdown.js +5 -4
- package/esm/dropdown/dropdownHelper.d.ts +4 -4
- package/esm/dropdown/dropdownHelper.js +2 -1
- package/esm/dropdown/dropdownList.js +2 -2
- package/esm/dropdown/dropdownPopup.d.ts +1 -0
- package/esm/dropdown/dropdownPopup.js +2 -2
- package/esm/dropdown/dropdownSearchableTrigger.js +1 -1
- package/esm/dropdown/stateReducer/stateReducer.d.ts +6 -2
- package/esm/dropdown/stateReducer/stateReducer.js +29 -43
- package/esm/dropdown/stateReducer/stateReducerHelper.d.ts +2 -0
- package/esm/dropdown/stateReducer/stateReducerHelper.js +10 -0
- package/esm/dropdown/useDropdownState.d.ts +1 -1
- package/esm/dropdown/useDropdownState.js +5 -2
- package/esm/filters/components/filtersContainer.d.ts +1 -0
- package/esm/filters/components/filtersContainer.js +12 -13
- package/esm/filters/components/filtersDateInput.d.ts +10 -0
- package/esm/filters/components/filtersDateInput.js +23 -0
- package/esm/filters/components/filtersDropdown.d.ts +5 -4
- package/esm/filters/components/filtersDropdown.js +3 -3
- package/esm/filters/components/filtersEmptySelectedList.d.ts +2 -0
- package/esm/filters/components/filtersEmptySelectedList.js +7 -0
- package/esm/filters/components/filtersItem.d.ts +5 -4
- package/esm/filters/components/filtersItem.js +2 -1
- package/esm/filters/components/filtersSaveModal.d.ts +3 -1
- package/esm/filters/components/filtersSaveModal.js +2 -2
- package/esm/filters/components/filtersSavedChipComponent.js +68 -6
- package/esm/filters/components/filtersSearch.d.ts +4 -4
- package/esm/filters/components/filtersSearch.js +20 -9
- package/esm/filters/components/filtersSearchItemData.js +18 -1
- package/esm/filters/components/filtersSearchList.d.ts +5 -1
- package/esm/filters/components/filtersSearchList.js +156 -28
- package/esm/filters/components/filtersSelect.d.ts +1 -0
- package/esm/filters/components/filtersSelect.js +36 -8
- package/esm/filters/components/filtersSelectListItem.d.ts +21 -15
- package/esm/filters/components/filtersSelectListItem.js +13 -3
- package/esm/filters/components/filtersSidePanel.d.ts +15 -0
- package/esm/filters/components/filtersSidePanel.js +208 -0
- package/esm/filters/components/filtersSidePanelChip.d.ts +9 -0
- package/esm/filters/components/filtersSidePanelChip.js +9 -0
- package/esm/filters/components/filtersSidePanelDropdown.d.ts +6 -0
- package/esm/filters/components/filtersSidePanelDropdown.js +81 -0
- package/esm/filters/components/filtersSidePanelItem.d.ts +16 -0
- package/esm/filters/components/filtersSidePanelItem.js +63 -0
- package/esm/filters/components/filtersSidePanelRange.d.ts +6 -0
- package/esm/filters/components/filtersSidePanelRange.js +24 -0
- package/esm/filters/filters.d.ts +5 -0
- package/esm/filters/filters.js +101 -38
- package/esm/filters/filtersHelper.d.ts +4 -2
- package/esm/filters/filtersHelper.js +37 -0
- package/esm/filters/filtersHooks.d.ts +12 -2
- package/esm/filters/filtersHooks.js +19 -2
- package/esm/formStepper/formStepper.d.ts +1 -1
- package/esm/formStepper/formStepper.js +5 -2
- package/esm/groupsFilter/groupsFilter.js +72 -37
- package/esm/groupsFilter/groupsFilterMenu.d.ts +1 -0
- package/esm/groupsFilter/groupsFilterMenu.js +2 -2
- package/esm/groupsFilter/groupsFilterTrigger.js +1 -1
- package/esm/images/imageLooking.d.ts +4 -0
- package/esm/images/imageLooking.js +12 -0
- package/esm/index.d.ts +7 -4
- package/esm/index.js +6 -3
- package/esm/list/list.d.ts +3 -1
- package/esm/list/list.js +2 -2
- package/esm/mobileSheet/mobileSheet.d.ts +2 -0
- package/esm/mobileSheet/mobileSheet.js +4 -4
- package/esm/modal/modal.d.ts +1 -0
- package/esm/modal/modal.js +2 -2
- package/esm/radioGroup/radioGroup.d.ts +1 -0
- package/esm/radioGroup/radioGroup.js +3 -2
- package/esm/range/range.js +29 -10
- package/esm/searchInputRaw/searchInputRaw.js +1 -1
- package/esm/sidePanel/sidePanel.d.ts +1 -0
- package/esm/sidePanel/sidePanel.js +3 -3
- package/esm/tabs/tabItem/tabItem.d.ts +1 -0
- package/esm/tabs/tabItem/tabItem.js +2 -2
- package/esm/tabs/tabs.d.ts +1 -0
- package/esm/tabs/tabs.js +1 -1
- package/esm/utils/keyboardHelpers.d.ts +2 -0
- package/esm/utils/keyboardHelpers.js +44 -0
- package/esm/utils/localization/translations/cs-json.d.ts +1 -0
- package/esm/utils/localization/translations/cs-json.js +2 -1
- package/esm/utils/localization/translations/de-json.d.ts +1 -0
- package/esm/utils/localization/translations/de-json.js +2 -1
- package/esm/utils/localization/translations/en-json.d.ts +7 -0
- package/esm/utils/localization/translations/en-json.js +8 -1
- package/esm/utils/localization/translations/es-json.d.ts +1 -0
- package/esm/utils/localization/translations/es-json.js +2 -1
- package/esm/utils/localization/translations/fr-FR-json.d.ts +1 -0
- package/esm/utils/localization/translations/fr-FR-json.js +2 -1
- package/esm/utils/localization/translations/fr-json.d.ts +1 -0
- package/esm/utils/localization/translations/fr-json.js +2 -1
- package/esm/utils/localization/translations/id-json.d.ts +1 -0
- package/esm/utils/localization/translations/id-json.js +2 -1
- package/esm/utils/localization/translations/it-json.d.ts +1 -0
- package/esm/utils/localization/translations/it-json.js +2 -1
- package/esm/utils/localization/translations/ja-json.d.ts +1 -0
- package/esm/utils/localization/translations/ja-json.js +2 -1
- package/esm/utils/localization/translations/ko-KR-json.d.ts +1 -0
- package/esm/utils/localization/translations/ko-KR-json.js +2 -1
- package/esm/utils/localization/translations/ms-json.d.ts +1 -0
- package/esm/utils/localization/translations/ms-json.js +2 -1
- package/esm/utils/localization/translations/nl-json.d.ts +1 -0
- package/esm/utils/localization/translations/nl-json.js +2 -1
- package/esm/utils/localization/translations/pl-json.d.ts +1 -0
- package/esm/utils/localization/translations/pl-json.js +2 -1
- package/esm/utils/localization/translations/pt-BR-json.d.ts +1 -0
- package/esm/utils/localization/translations/pt-BR-json.js +2 -1
- package/esm/utils/localization/translations/sv-json.d.ts +1 -0
- package/esm/utils/localization/translations/sv-json.js +2 -1
- package/esm/utils/localization/translations/th-json.d.ts +1 -0
- package/esm/utils/localization/translations/th-json.js +2 -1
- package/esm/utils/localization/translations/tr-json.d.ts +1 -0
- package/esm/utils/localization/translations/tr-json.js +2 -1
- package/esm/utils/localization/translations/zh-Hans-json.d.ts +1 -0
- package/esm/utils/localization/translations/zh-Hans-json.js +2 -1
- package/esm/utils/localization/translations/zh-TW-json.d.ts +1 -0
- package/esm/utils/localization/translations/zh-TW-json.js +2 -1
- package/package.json +1 -1
- package/dist/filters/components/filtersModal.d.ts +0 -17
- package/dist/filters/components/filtersModal.js +0 -107
- package/dist/filters/components/filtersModalItem.d.ts +0 -9
- package/dist/filters/components/filtersModalItem.js +0 -74
- package/esm/filters/components/filtersModal.d.ts +0 -17
- package/esm/filters/components/filtersModal.js +0 -103
- package/esm/filters/components/filtersModalItem.d.ts +0 -9
- package/esm/filters/components/filtersModalItem.js +0 -70
|
@@ -5,7 +5,7 @@ const stateActionType_1 = require("./stateActionType");
|
|
|
5
5
|
const stateReducerHelper_1 = require("./stateReducerHelper");
|
|
6
6
|
const groupsFilterHelper_1 = require("../../groupsFilter/groupsFilterHelper");
|
|
7
7
|
const groupsHelper_1 = require("../../groupsFilter/groupsHelper");
|
|
8
|
-
const getInitialState = (isFullSelectionMode, comboItems, selection, defaultValue, isAllSelected, defaultValueIsAllSelected, isChecked, defaultValueIsChecked) => {
|
|
8
|
+
const getInitialState = (isFullSelectionMode, comboItems, selection, listLimit, defaultValue, isAllSelected, defaultValueIsAllSelected, isChecked, defaultValueIsChecked) => {
|
|
9
9
|
const updatedGroupsMapSelected = new Map();
|
|
10
10
|
const updatedGroupsMap = comboItems.length ? (0, groupsFilterHelper_1.createGroupsMap)(comboItems, groupsHelper_1.ENTIRE_ORGANIZATION_GROUP_ID) : {};
|
|
11
11
|
const namelessIds = new Set();
|
|
@@ -46,13 +46,15 @@ const getInitialState = (isFullSelectionMode, comboItems, selection, defaultValu
|
|
|
46
46
|
defaultValueIsAllSelected: isFullSelectionMode ? defaultValueIsAllSelected || false : undefined,
|
|
47
47
|
isChecked: isChecked,
|
|
48
48
|
defaultValueIsChecked: isChecked !== undefined ? defaultValueIsChecked || false : undefined,
|
|
49
|
-
globalIsChecked: isChecked
|
|
49
|
+
globalIsChecked: isChecked,
|
|
50
|
+
listLimit,
|
|
51
|
+
resultsExceedListLimit: false
|
|
50
52
|
};
|
|
51
53
|
};
|
|
52
54
|
exports.getInitialState = getInitialState;
|
|
53
55
|
// eslint-disable-next-line complexity
|
|
54
56
|
function stateReducer(state, action) {
|
|
55
|
-
var _a, _b, _c, _d;
|
|
57
|
+
var _a, _b, _c, _d, _e, _f;
|
|
56
58
|
const { type, payload } = action;
|
|
57
59
|
switch (type) {
|
|
58
60
|
case stateActionType_1.StateActionType.CreateMap: {
|
|
@@ -73,7 +75,9 @@ function stateReducer(state, action) {
|
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
77
|
const isCurrentListNested = Object.keys(updatedGroupsMap).length > 0 && (updatedGroupsMap[groupsHelper_1.ENTIRE_ORGANIZATION_GROUP_ID].children || []).some(el => el.children && el.children.length);
|
|
76
|
-
|
|
78
|
+
state.groupsMap = updatedGroupsMap;
|
|
79
|
+
const additionalStateUpdates = (0, stateReducerHelper_1.updateAllSelectedStateValueBasedOnTotalSelected)(state, state.selectedIds.length - newNamelessIds.size);
|
|
80
|
+
return Object.assign(Object.assign(Object.assign({}, state), { namelessIds: newNamelessIds, isNestedList: state.isNestedList ? state.isNestedList : isCurrentListNested, resultsExceedListLimit: Object.keys(updatedGroupsMap).length - 1 >= state.listLimit }), additionalStateUpdates);
|
|
77
81
|
}
|
|
78
82
|
case stateActionType_1.StateActionType.SetListData: {
|
|
79
83
|
state.selectedIds.forEach(id => {
|
|
@@ -116,11 +120,8 @@ function stateReducer(state, action) {
|
|
|
116
120
|
const newNamelessIds = new Set(state.namelessIds);
|
|
117
121
|
payload.selected.forEach(id => {
|
|
118
122
|
if (!state.groupsMapSelected.has(id)) {
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
120
123
|
const item = state.groupsMap[id];
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
122
124
|
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
124
125
|
!item && newNamelessIds.add(id);
|
|
125
126
|
}
|
|
126
127
|
});
|
|
@@ -133,13 +134,9 @@ function stateReducer(state, action) {
|
|
|
133
134
|
const newNamelessIds = new Set(state.namelessIds);
|
|
134
135
|
state.selectedIds.forEach(id => {
|
|
135
136
|
if (!state.groupsMapSelected.has(id)) {
|
|
136
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
137
137
|
const item = state.groupsMap[id];
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
139
138
|
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
141
139
|
!item && newNamelessIds.add(id);
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
143
140
|
item && newNamelessIds.delete(id);
|
|
144
141
|
}
|
|
145
142
|
else {
|
|
@@ -167,11 +164,8 @@ function stateReducer(state, action) {
|
|
|
167
164
|
const newNamelessIds = new Set(state.namelessIds);
|
|
168
165
|
payload.forEach(id => {
|
|
169
166
|
if (!state.groupsMapSelected.has(id)) {
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
171
167
|
const item = state.groupsMap[id] || state.listData.find(el => el.id === id);
|
|
172
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
173
168
|
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
175
169
|
!item && newNamelessIds.add(id);
|
|
176
170
|
}
|
|
177
171
|
});
|
|
@@ -183,9 +177,7 @@ function stateReducer(state, action) {
|
|
|
183
177
|
case stateActionType_1.StateActionType.ChangeSingleSelection: {
|
|
184
178
|
const newSelectedId = payload.value ? payload.value : state.defaultValue[0];
|
|
185
179
|
if (newSelectedId && !state.groupsMapSelected.has(newSelectedId)) {
|
|
186
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
187
180
|
const item = state.groupsMap[newSelectedId] || state.listData.find(el => el.id === newSelectedId);
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
189
181
|
item && state.groupsMapSelected.set(newSelectedId, Object.assign(Object.assign({ id: newSelectedId }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
190
182
|
}
|
|
191
183
|
return Object.assign(Object.assign({}, state), { selectedIds: payload.value ? [payload.value] : (payload.reset ? [...state.defaultValue] : []) });
|
|
@@ -205,7 +197,7 @@ function stateReducer(state, action) {
|
|
|
205
197
|
let parent = (_b = (_a = state.groupsMap[payload.itemId]) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id;
|
|
206
198
|
while (parent && parent !== "root") {
|
|
207
199
|
parentForDeselect.push(parent);
|
|
208
|
-
parent = (_c = state.groupsMap[parent]
|
|
200
|
+
parent = (_d = (_c = state.groupsMap[parent]) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.id;
|
|
209
201
|
}
|
|
210
202
|
parentForDeselect.forEach(parentId => {
|
|
211
203
|
currentSelectedIds.delete(parentId);
|
|
@@ -213,7 +205,7 @@ function stateReducer(state, action) {
|
|
|
213
205
|
// deselect children
|
|
214
206
|
const childrenForDeselect = [];
|
|
215
207
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
216
|
-
const currentChild = (0, stateReducerHelper_1.getChildList)((
|
|
208
|
+
const currentChild = (0, stateReducerHelper_1.getChildList)((_e = state.groupsMap[payload.itemId]) === null || _e === void 0 ? void 0 : _e.children);
|
|
217
209
|
currentChild.forEach(el => {
|
|
218
210
|
childrenForDeselect.push(el.id);
|
|
219
211
|
});
|
|
@@ -221,13 +213,12 @@ function stateReducer(state, action) {
|
|
|
221
213
|
}
|
|
222
214
|
currentSelectedIds.forEach(id => {
|
|
223
215
|
if (!state.groupsMapSelected.has(id)) {
|
|
224
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
225
216
|
const item = state.groupsMap[id] || state.listData.find(el => el.id === id);
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
227
217
|
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
228
218
|
}
|
|
229
219
|
});
|
|
230
|
-
|
|
220
|
+
const additionalStateUpdates = (0, stateReducerHelper_1.updateAllSelectedStateValueBasedOnTotalSelected)(state, currentSelectedIds.size);
|
|
221
|
+
return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds) }), additionalStateUpdates);
|
|
231
222
|
}
|
|
232
223
|
case stateActionType_1.StateActionType.ChangeBulkSelection: {
|
|
233
224
|
const { itemsIds, value } = payload;
|
|
@@ -235,17 +226,17 @@ function stateReducer(state, action) {
|
|
|
235
226
|
const parentsToProcess = new Set();
|
|
236
227
|
const childrenToProcess = new Set();
|
|
237
228
|
itemsIds.forEach(itemId => {
|
|
238
|
-
var _a, _b, _c, _d;
|
|
229
|
+
var _a, _b, _c, _d, _e;
|
|
239
230
|
if (value) {
|
|
240
231
|
currentSelectedIds.add(itemId);
|
|
241
232
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
242
233
|
let parent = (_b = (_a = state.groupsMap[itemId]) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id;
|
|
243
234
|
while (parent && parent !== "root") {
|
|
244
235
|
parentsToProcess.add(parent);
|
|
245
|
-
parent = (_c = state.groupsMap[parent]
|
|
236
|
+
parent = (_d = (_c = state.groupsMap[parent]) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.id;
|
|
246
237
|
}
|
|
247
238
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
248
|
-
const currentChild = (0, stateReducerHelper_1.getChildList)((
|
|
239
|
+
const currentChild = (0, stateReducerHelper_1.getChildList)((_e = state.groupsMap[itemId]) === null || _e === void 0 ? void 0 : _e.children);
|
|
249
240
|
currentChild.forEach(childId => childrenToProcess.add(childId.id));
|
|
250
241
|
}
|
|
251
242
|
else {
|
|
@@ -256,36 +247,35 @@ function stateReducer(state, action) {
|
|
|
256
247
|
parentsToProcess.forEach(parentId => currentSelectedIds.delete(parentId));
|
|
257
248
|
currentSelectedIds.forEach(id => {
|
|
258
249
|
if (!state.groupsMapSelected.has(id)) {
|
|
259
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
260
250
|
const item = state.groupsMap[id] || state.listData.find(el => el.id === id);
|
|
261
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
262
251
|
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
263
252
|
}
|
|
264
253
|
});
|
|
265
|
-
|
|
254
|
+
const additionalStateUpdates = (0, stateReducerHelper_1.updateAllSelectedStateValueBasedOnTotalSelected)(state, currentSelectedIds.size);
|
|
255
|
+
return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds) }), additionalStateUpdates);
|
|
266
256
|
}
|
|
267
257
|
case stateActionType_1.StateActionType.SelectAllChildren: {
|
|
268
258
|
const currentEl = state.groupsMap[payload];
|
|
269
259
|
const newSelected = new Set(state.selectedIds);
|
|
270
260
|
const isDisableStateProhibited = state.isNestedList;
|
|
271
|
-
(currentEl.children || []).forEach(el => {
|
|
272
|
-
var _a, _b;
|
|
261
|
+
((currentEl === null || currentEl === void 0 ? void 0 : currentEl.children) || []).forEach(el => {
|
|
262
|
+
var _a, _b, _c, _d, _e;
|
|
273
263
|
if (!newSelected.has(el.id)) {
|
|
274
264
|
// select when isDisableStateProhibited, or when disabled elements are allowed to be displayed, and this element is not disabled
|
|
275
265
|
(isDisableStateProhibited || !el.disabled) && newSelected.add(el.id);
|
|
276
266
|
// deselect parent
|
|
277
267
|
const parentForDeselect = [];
|
|
278
|
-
let parent = (_a = state.groupsMap[el.id]
|
|
268
|
+
let parent = (_b = (_a = state.groupsMap[el.id]) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id;
|
|
279
269
|
while (parent && parent !== "root") {
|
|
280
270
|
parentForDeselect.push(parent);
|
|
281
|
-
parent = (
|
|
271
|
+
parent = (_d = (_c = state.groupsMap[parent]) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.id;
|
|
282
272
|
}
|
|
283
273
|
parentForDeselect.forEach(parentId => {
|
|
284
274
|
newSelected.delete(parentId);
|
|
285
275
|
});
|
|
286
276
|
//deselect children
|
|
287
277
|
const childrenForDeselect = [];
|
|
288
|
-
const currentChild = (0, stateReducerHelper_1.getChildList)(state.groupsMap[el.id].children);
|
|
278
|
+
const currentChild = (0, stateReducerHelper_1.getChildList)((_e = state.groupsMap[el.id]) === null || _e === void 0 ? void 0 : _e.children);
|
|
289
279
|
currentChild.forEach(elt => {
|
|
290
280
|
childrenForDeselect.push(elt.id);
|
|
291
281
|
});
|
|
@@ -294,9 +284,7 @@ function stateReducer(state, action) {
|
|
|
294
284
|
});
|
|
295
285
|
newSelected.forEach(id => {
|
|
296
286
|
if (!state.groupsMapSelected.has(id)) {
|
|
297
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
298
287
|
const item = state.groupsMap[id] || state.listData.find(el => el.id === id);
|
|
299
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
300
288
|
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
301
289
|
}
|
|
302
290
|
});
|
|
@@ -307,7 +295,7 @@ function stateReducer(state, action) {
|
|
|
307
295
|
// action not submitted for disabled item, other items, even if disabled, not change their state
|
|
308
296
|
const deselectedItems = payload ? new Set([payload]) : new Set(state.listData.filter(elem => !elem.disabled).map(el => el.id));
|
|
309
297
|
const newSelected = new Set();
|
|
310
|
-
(currentEl.children || []).forEach(el => {
|
|
298
|
+
((currentEl === null || currentEl === void 0 ? void 0 : currentEl.children) || []).forEach(el => {
|
|
311
299
|
if (!newSelected.has(el.id) && !deselectedItems.has(el.id)) {
|
|
312
300
|
newSelected.add(el.id);
|
|
313
301
|
}
|
|
@@ -319,9 +307,7 @@ function stateReducer(state, action) {
|
|
|
319
307
|
});
|
|
320
308
|
newSelected.forEach(id => {
|
|
321
309
|
if (!state.groupsMapSelected.has(id)) {
|
|
322
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
323
310
|
const item = state.groupsMap[id] || state.listData.find(el => el.id === id);
|
|
324
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
325
311
|
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
326
312
|
}
|
|
327
313
|
});
|
|
@@ -330,24 +316,24 @@ function stateReducer(state, action) {
|
|
|
330
316
|
case stateActionType_1.StateActionType.ToggleValueForAllSelected: {
|
|
331
317
|
const currentEl = state.groupsMap[groupsHelper_1.ENTIRE_ORGANIZATION_GROUP_ID];
|
|
332
318
|
const newSelected = new Set();
|
|
333
|
-
state.isAllSelected && (currentEl.children || []).forEach(el => {
|
|
319
|
+
state.isAllSelected && ((currentEl === null || currentEl === void 0 ? void 0 : currentEl.children) || []).forEach(el => {
|
|
334
320
|
if (!newSelected.has(el.id) && el.disabled) {
|
|
335
321
|
newSelected.add(el.id);
|
|
336
322
|
}
|
|
337
323
|
});
|
|
338
324
|
newSelected.forEach(id => {
|
|
339
325
|
if (!state.groupsMapSelected.has(id)) {
|
|
340
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
341
326
|
const item = state.groupsMap[id] || state.listData.find(el => el.id === id);
|
|
342
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
343
327
|
item && state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
344
328
|
}
|
|
345
329
|
});
|
|
346
|
-
|
|
330
|
+
const updatedIsAllSelectedValue = state.isFullSelectionMode ? !state.isAllSelected : undefined;
|
|
331
|
+
const additionalStateUpdates = (0, stateReducerHelper_1.updateAllSelectedStateValueBasedOnTotalSelected)(state, newSelected.size);
|
|
332
|
+
return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: state.isAllSelected ? Array.from(newSelected) : [], isAllSelected: updatedIsAllSelectedValue }), additionalStateUpdates);
|
|
347
333
|
}
|
|
348
334
|
case stateActionType_1.StateActionType.DeselectAllChildren: {
|
|
349
335
|
const childrenForDeselect = [];
|
|
350
|
-
const currentChild = (0, stateReducerHelper_1.getChildList)(state.groupsMap[payload].children);
|
|
336
|
+
const currentChild = (0, stateReducerHelper_1.getChildList)((_f = state.groupsMap[payload]) === null || _f === void 0 ? void 0 : _f.children);
|
|
351
337
|
const isDisableStateProhibited = state.isNestedList;
|
|
352
338
|
currentChild.forEach(el => {
|
|
353
339
|
// deselect when isDisableStateProhibited, or when disabled elements are allowed to be displayed, and this element is not disabled
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { IDropdownItem } from "../dropdown";
|
|
2
|
+
import { IDropdownState } from "./stateReducer";
|
|
2
3
|
export declare function getChildList(childArr: IDropdownItem[] | undefined): IDropdownItem[];
|
|
4
|
+
export declare const updateAllSelectedStateValueBasedOnTotalSelected: (state: IDropdownState, totalSelected: number) => Partial<Pick<IDropdownState, "isAllSelected">>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChildList = void 0;
|
|
3
|
+
exports.updateAllSelectedStateValueBasedOnTotalSelected = exports.getChildList = void 0;
|
|
4
4
|
function getChildList(childArr) {
|
|
5
5
|
const list = [];
|
|
6
6
|
if (!childArr) {
|
|
@@ -16,3 +16,14 @@ function getChildList(childArr) {
|
|
|
16
16
|
return list;
|
|
17
17
|
}
|
|
18
18
|
exports.getChildList = getChildList;
|
|
19
|
+
const updateAllSelectedStateValueBasedOnTotalSelected = (state, totalSelected) => {
|
|
20
|
+
const additionalStateUpdates = {};
|
|
21
|
+
const groupsMapLength = Object.keys(state.groupsMap).length - 1;
|
|
22
|
+
if (!state.resultsExceedListLimit && !state.isAllSelected && state.isFullSelectionMode && groupsMapLength > 0) {
|
|
23
|
+
if (totalSelected >= groupsMapLength) {
|
|
24
|
+
additionalStateUpdates.isAllSelected = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return additionalStateUpdates;
|
|
28
|
+
};
|
|
29
|
+
exports.updateAllSelectedStateValueBasedOnTotalSelected = updateAllSelectedStateValueBasedOnTotalSelected;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const useDropdownState: (withCheckbox?: boolean) => {
|
|
2
|
+
export declare const useDropdownState: (withCheckbox?: boolean, debounceTimeout?: number) => {
|
|
3
3
|
checked?: boolean | undefined;
|
|
4
4
|
setChecked?: import("react").Dispatch<import("react").SetStateAction<boolean>> | undefined;
|
|
5
5
|
search: string;
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDropdownState = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const useDebouncedMemo_1 = require("../commonHelpers/hooks/useDebouncedMemo");
|
|
6
|
+
const useDropdownState = (withCheckbox, debounceTimeout = 300) => {
|
|
6
7
|
const [search, setSearch] = (0, react_1.useState)("");
|
|
7
8
|
const [checked, setChecked] = (0, react_1.useState)(false);
|
|
8
|
-
|
|
9
|
+
const debouncedSearch = (0, useDebouncedMemo_1.useDebouncedMemo)(() => search, [search], debounceTimeout);
|
|
10
|
+
const debouncedChecked = (0, useDebouncedMemo_1.useDebouncedMemo)(() => checked, [checked], debounceTimeout);
|
|
11
|
+
return Object.assign({ search: debouncedSearch, setSearch }, (withCheckbox ? { checked: debouncedChecked, setChecked } : {}));
|
|
9
12
|
};
|
|
10
13
|
exports.useDropdownState = useDropdownState;
|
|
@@ -8,5 +8,6 @@ export interface IFiltersContainer extends IZenComponentProps {
|
|
|
8
8
|
hasSavedFilters: boolean;
|
|
9
9
|
filtersForCalculation: ReactElement[];
|
|
10
10
|
onSaveFilters?: (filterName: string, filterState?: Record<string, unknown>) => void;
|
|
11
|
+
filtersChipRef: React.RefObject<HTMLElement>;
|
|
11
12
|
}
|
|
12
13
|
export declare const FiltersContainer: React.FC<IFiltersContainer>;
|
|
@@ -10,15 +10,16 @@ const classNames_1 = require("../../commonHelpers/classNames/classNames");
|
|
|
10
10
|
const chip_1 = require("../../chip/chip");
|
|
11
11
|
const react_2 = __importDefault(require("react"));
|
|
12
12
|
const iconFilter_1 = require("../../icons/iconFilter");
|
|
13
|
-
const iconPin2_1 = require("../../icons/iconPin2");
|
|
14
13
|
const filtersHelper_1 = require("../filtersHelper");
|
|
15
14
|
const filtersSavedChipComponent_1 = require("./filtersSavedChipComponent");
|
|
16
15
|
const iconClose_1 = require("../../icons/iconClose");
|
|
17
16
|
const chipStatusProvider_1 = require("../../chip/chipStatusProvider");
|
|
18
17
|
const useLanguage_1 = require("../../utils/localization/useLanguage");
|
|
19
|
-
const
|
|
18
|
+
const useMobile_1 = require("../../commonHelpers/hooks/useMobile");
|
|
19
|
+
const FiltersContainer = ({ className, isPinned = false, onPinChange, filtersClickHandler, hasSavedFilters, filtersForCalculation, children, filtersChipRef }) => {
|
|
20
20
|
const chipStatus = (0, chipStatusProvider_1.useChipStatus)();
|
|
21
21
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
22
|
+
const isMobile = (0, useMobile_1.useMobile)();
|
|
22
23
|
const numberOfChangedFilters = (0, react_1.useMemo)(() => {
|
|
23
24
|
const suppressedFilters = new Set();
|
|
24
25
|
filtersForCalculation.forEach(filter => {
|
|
@@ -31,12 +32,7 @@ const FiltersContainer = ({ className, isPinned = false, onPinChange, filtersCli
|
|
|
31
32
|
const filteredState = (0, filtersHelper_1.getFiltersState)(filtersForCalculation.filter(f => !suppressedFilters.has(f.props.id)));
|
|
32
33
|
return (0, filtersHelper_1.getNumberOfChangedFilters)(filteredState);
|
|
33
34
|
}, [filtersForCalculation]);
|
|
34
|
-
const
|
|
35
|
-
const handlePinChange = (0, react_1.useCallback)((newIsPinned) => {
|
|
36
|
-
onPinChange && onPinChange(newIsPinned);
|
|
37
|
-
}, [onPinChange]);
|
|
38
|
-
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]);
|
|
39
|
-
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]);
|
|
35
|
+
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, filtersChipRef]);
|
|
40
36
|
const childrenSignature = (0, react_1.useMemo)(() => {
|
|
41
37
|
const childrenArray = react_2.default.Children.toArray(children).filter(Boolean);
|
|
42
38
|
return childrenArray
|
|
@@ -48,10 +44,11 @@ const FiltersContainer = ({ className, isPinned = false, onPinChange, filtersCli
|
|
|
48
44
|
const state = child.props.state;
|
|
49
45
|
const defaultState = child.props.defaultState;
|
|
50
46
|
const childPropsQuery = JSON.stringify(child.props.fetchState || {});
|
|
47
|
+
const childPropsDataItems = JSON.stringify(child.props.dataItems || "no-data-items");
|
|
51
48
|
const stateHash = (0, filtersHelper_1.createStateHash)(state);
|
|
52
49
|
const defaultStateHash = (0, filtersHelper_1.createStateHash)(defaultState);
|
|
53
50
|
const propsHash = (0, filtersHelper_1.createPropsHash)(child.props);
|
|
54
|
-
return `${childId}|${stateHash}|${defaultStateHash}|${propsHash}|${childPropsQuery}`;
|
|
51
|
+
return `${childId}|${stateHash}|${defaultStateHash}|${propsHash}|${childPropsQuery}|${childPropsDataItems}`;
|
|
55
52
|
})
|
|
56
53
|
.join("||");
|
|
57
54
|
}, [children]);
|
|
@@ -72,10 +69,12 @@ const FiltersContainer = ({ className, isPinned = false, onPinChange, filtersCli
|
|
|
72
69
|
}
|
|
73
70
|
});
|
|
74
71
|
onPinChange === null || onPinChange === void 0 ? void 0 : onPinChange(false);
|
|
75
|
-
|
|
72
|
+
filtersChipRef.current.focus();
|
|
73
|
+
}, [filtersChipRef, filtersForCalculation, onPinChange]);
|
|
76
74
|
const chipRemovalComponent = (0, react_1.useMemo)(() => numberOfChangedFilters ?
|
|
77
75
|
(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 })
|
|
78
76
|
: null, [isPinned, handleRemovalClick, translate, numberOfChangedFilters]);
|
|
79
|
-
|
|
77
|
+
const memoizedFiltersElements = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [memoizedChildren, hasSavedFilters ? (0, jsx_runtime_1.jsx)(filtersSavedChipComponent_1.FiltersSavedChipComponent, {}) : null, filtersChipComponent, chipRemovalComponent] }), [chipRemovalComponent, filtersChipComponent, hasSavedFilters, memoizedChildren]);
|
|
78
|
+
return (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-filters-container", isMobile ? "zen-filters-container--mobile" : "", className || ""]), children: isMobile ? (0, jsx_runtime_1.jsx)("div", { className: "zen-filters-container__mobile-scroll-wrapper", children: memoizedFiltersElements }) : memoizedFiltersElements });
|
|
80
79
|
};
|
|
81
80
|
exports.FiltersContainer = FiltersContainer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IFiltersItem } from "./filtersItem";
|
|
3
|
+
import { IDateInput } from "../../dateInput/dateInput";
|
|
4
|
+
export interface IFiltersDateInputProps extends Pick<IDateInput, "classNamePopup" | "disabled" | "dropDownTitle" | "timeSelect" | "disableFutureDates" | "disablePastDates" | "disableDatesBefore" | "disableDatesAfter" | "requireSelection" | "chipIcon"> {
|
|
5
|
+
}
|
|
6
|
+
export type TFiltersDateInputState = string | undefined;
|
|
7
|
+
export interface IFiltersDateInput extends IFiltersItem<TFiltersDateInputState>, IFiltersDateInputProps {
|
|
8
|
+
}
|
|
9
|
+
export declare const FiltersDateInputDisplayName = "FiltersDateInput";
|
|
10
|
+
export declare const FiltersDateInput: React.FC<IFiltersDateInput>;
|
|
@@ -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.FiltersDateInput = exports.FiltersDateInputDisplayName = 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 dateInput_1 = require("../../dateInput/dateInput");
|
|
19
|
+
const iconCalendar_1 = require("../../icons/iconCalendar");
|
|
20
|
+
exports.FiltersDateInputDisplayName = "FiltersDateInput";
|
|
21
|
+
const FiltersDateInput = (_a) => {
|
|
22
|
+
var { className, state, defaultState, name, onChange: onChangeState, id, chipIcon } = _a, otherRangeProps = __rest(_a, ["className", "state", "defaultState", "name", "onChange", "id", "chipIcon"]);
|
|
23
|
+
const component = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(dateInput_1.DateInput, Object.assign({}, otherRangeProps, { buttonLabel: name, value: state, onChange: onChangeState, defaultValue: defaultState, className: (0, classNames_1.classNames)(["zen-filters-date-input", className || ""]), chip: true, chipId: id, chipName: name, chipIcon: chipIcon || iconCalendar_1.IconCalendar })), [otherRangeProps, chipIcon, state, onChangeState, defaultState, className, id, name]);
|
|
24
|
+
return component;
|
|
25
|
+
};
|
|
26
|
+
exports.FiltersDateInput = FiltersDateInput;
|
|
27
|
+
exports.FiltersDateInput.displayName = exports.FiltersDateInputDisplayName;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IDropdown, IDropdownFullSelection, IDropdownFullSelectionWithCheckbox, IDropdownWithCheckbox, IFetchDropdownState } from "../../dropdown/dropdown";
|
|
2
|
+
import { IDropdown, IDropdownFullSelection, IDropdownFullSelectionWithCheckbox, IDropdownWithCheckbox, IFetchDropdownState, IDropdownItem } from "../../dropdown/dropdown";
|
|
3
3
|
import { IFiltersItem } from "./filtersItem";
|
|
4
|
-
export interface IFiltersDropdownProps extends Omit<IDropdown | IDropdownFullSelection | IDropdownWithCheckbox | IDropdownFullSelectionWithCheckbox, "value" | "onChange" | "defaultValue" | "className" | "getData" | "
|
|
4
|
+
export interface IFiltersDropdownProps extends Omit<IDropdown | IDropdownFullSelection | IDropdownWithCheckbox | IDropdownFullSelectionWithCheckbox, "value" | "onChange" | "defaultValue" | "className" | "getData" | "errorHandler"> {
|
|
5
5
|
}
|
|
6
6
|
export type TFiltersDropdownState = string[];
|
|
7
7
|
export interface IFiltersDropdownFullSelectionState {
|
|
@@ -22,11 +22,12 @@ export type TFiltersDropdownAllStates = TFiltersDropdownState | TFiltersDropdown
|
|
|
22
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
23
|
export interface IFiltersDropdown<T extends TFiltersDropdownAllStates = TFiltersDropdownState> extends Omit<IFiltersItem<T>, "onChange" | "defaultState">, IFiltersDropdownProps {
|
|
24
24
|
onChange: TInferOnChangeType<T>;
|
|
25
|
-
fetchState
|
|
25
|
+
fetchState?: IFetchDropdownState;
|
|
26
|
+
dataItems?: IDropdownItem[];
|
|
26
27
|
defaultState?: T;
|
|
27
28
|
}
|
|
28
29
|
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>): React.JSX.Element;
|
|
30
|
+
export declare function FiltersDropdown<T extends TFiltersDropdownAllStates = TFiltersDropdownState>({ className, state, name, defaultState, onChange: onChangeState, id, chipIcon, classNamePopup, fetchState, dataItems, isLoading, ...restDropdownProps }: IFiltersDropdown<T>): React.JSX.Element;
|
|
30
31
|
export declare namespace FiltersDropdown {
|
|
31
32
|
var displayName: string;
|
|
32
33
|
}
|
|
@@ -20,7 +20,7 @@ const iconFilter_1 = require("../../icons/iconFilter");
|
|
|
20
20
|
const filtersHelper_1 = require("../filtersHelper");
|
|
21
21
|
exports.FiltersDropdownDisplayName = "FiltersDropdown";
|
|
22
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"]);
|
|
23
|
+
var { className, state, name, defaultState, onChange: onChangeState, id, chipIcon, classNamePopup, fetchState, dataItems, isLoading } = _a, restDropdownProps = __rest(_a, ["className", "state", "name", "defaultState", "onChange", "id", "chipIcon", "classNamePopup", "fetchState", "dataItems", "isLoading"]);
|
|
24
24
|
const prepareValue = (value) => {
|
|
25
25
|
if (Array.isArray(value)) {
|
|
26
26
|
return value.map((item) => item.id);
|
|
@@ -33,9 +33,9 @@ function FiltersDropdown(_a) {
|
|
|
33
33
|
const dropdownPropsForComponent = Object.assign(Object.assign({}, restDropdownProps), { value: state, onChange: (newValue) => {
|
|
34
34
|
const preparedValue = prepareValue(newValue);
|
|
35
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 });
|
|
36
|
+
}, multiselect: dropdownStateType === "fullSelection" || dropdownStateType === "fullSelectionWithCheckbox" ? true : restDropdownProps.multiselect, selectAllButton: dropdownStateType === "fullSelection" || dropdownStateType === "fullSelectionWithCheckbox" ? true : restDropdownProps.selectAllButton, fetchState: fetchState, dataItems: dataItems, isLoading: dataItems !== undefined ? 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
37
|
return (0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, Object.assign({}, dropdownPropsForComponent));
|
|
38
|
-
}, [restDropdownProps, state, dropdownStateType,
|
|
38
|
+
}, [restDropdownProps, state, dropdownStateType, fetchState, dataItems, isLoading, name, memoizedDefaultState, className, classNamePopup, id, chipIcon, onChangeState]);
|
|
39
39
|
return component;
|
|
40
40
|
}
|
|
41
41
|
exports.FiltersDropdown = FiltersDropdown;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiltersEmptySelectedList = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const useLanguage_1 = require("../../utils/localization/useLanguage");
|
|
6
|
+
const imageLooking_1 = require("../../images/imageLooking");
|
|
7
|
+
const FiltersEmptySelectedList = () => {
|
|
8
|
+
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
9
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: "zen-filters-empty-selected-list", children: [(0, jsx_runtime_1.jsx)(imageLooking_1.ImageLooking, { className: "zen-filters-empty-selected-list__image", title: translate("No Filters Selected"), description: translate("Selected filters will appear here.") }), (0, jsx_runtime_1.jsxs)("div", { className: "zen-filters-empty-selected-list__text", children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-filters-empty-selected-list__header", children: translate("No Filters Selected") }), (0, jsx_runtime_1.jsx)("div", { className: "zen-filters-empty-selected-list__description", children: translate("Selected filters will appear here.") })] })] });
|
|
10
|
+
};
|
|
11
|
+
exports.FiltersEmptySelectedList = FiltersEmptySelectedList;
|
|
@@ -5,6 +5,7 @@ import { FiltersDateRange, IFiltersDateRangeItem, TFiltersDateRangeState } from
|
|
|
5
5
|
import { FiltersDropdown, IFiltersDropdown, TFiltersDropdownAllStates } from "./filtersDropdown";
|
|
6
6
|
import { FiltersGroups, IFiltersGroups } from "./filtersGroups";
|
|
7
7
|
import { FiltersRange, IFiltersRange, IFiltersRangeState } from "./filtersRange";
|
|
8
|
+
import { FiltersDateInput, IFiltersDateInput, TFiltersDateInputState } from "./filtersDateInput";
|
|
8
9
|
export interface IFiltersItem<State = unknown> {
|
|
9
10
|
id: string;
|
|
10
11
|
name: string;
|
|
@@ -15,11 +16,11 @@ export interface IFiltersItem<State = unknown> {
|
|
|
15
16
|
inhibit?: string[];
|
|
16
17
|
className?: string;
|
|
17
18
|
}
|
|
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;
|
|
19
|
+
export type TFiltersComponents = typeof FiltersChip | typeof FiltersDateRange | typeof FiltersDateInput | typeof FiltersDropdown | typeof FiltersGroups | typeof FiltersRange;
|
|
20
|
+
export type TFiltersComponentsProps = IFiltersChip | IFiltersDateRangeItem | IFiltersDropdown | IFiltersGroups | IFiltersRange | IFiltersDateInput;
|
|
21
|
+
export type TFiltersComponentsItemState = boolean | TFiltersDateRangeState | TFiltersDropdownAllStates | IGroupsFilterTotalState | IFiltersRangeState | TFiltersDateInputState;
|
|
21
22
|
export declare const allowedFiltersComponents: ({
|
|
22
23
|
<P extends import("./filtersDateRange").IFiltersDateRangeProps = import("./filtersDateRange").IFiltersDateRangeProps>({ className, state, defaultState, name, onChange: onChangeState, id, allowUnsetValue, chipIcon, ...dateRangeProps }: IFiltersDateRangeItem<P>): React.JSX.Element;
|
|
23
24
|
displayName: string;
|
|
24
|
-
} | React.FC<IFiltersGroups> | React.FC<IFiltersRange> | React.FC<IFiltersChip> | typeof FiltersDropdown)[];
|
|
25
|
+
} | React.FC<IFiltersGroups> | React.FC<IFiltersRange> | React.FC<IFiltersDateInput> | React.FC<IFiltersChip> | typeof FiltersDropdown)[];
|
|
25
26
|
export declare const getAllowedFilters: <T extends React.ReactNode>(items: T[]) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>[];
|
|
@@ -10,7 +10,8 @@ const filtersDateRange_1 = require("./filtersDateRange");
|
|
|
10
10
|
const filtersDropdown_1 = require("./filtersDropdown");
|
|
11
11
|
const filtersGroups_1 = require("./filtersGroups");
|
|
12
12
|
const filtersRange_1 = require("./filtersRange");
|
|
13
|
-
|
|
13
|
+
const filtersDateInput_1 = require("./filtersDateInput");
|
|
14
|
+
exports.allowedFiltersComponents = [filtersChip_1.FiltersChip, filtersDateRange_1.FiltersDateRange, filtersDropdown_1.FiltersDropdown, filtersGroups_1.FiltersGroups, filtersRange_1.FiltersRange, filtersDateInput_1.FiltersDateInput];
|
|
14
15
|
const getAllowedFilters = (items) => items.reduce((acc, item) => {
|
|
15
16
|
if (!item || !react_1.default.isValidElement(item)) {
|
|
16
17
|
return acc;
|
|
@@ -3,5 +3,7 @@ export interface IFiltersModal {
|
|
|
3
3
|
isOpen: boolean;
|
|
4
4
|
onClose: (isOpen: boolean) => void;
|
|
5
5
|
onSave: (filterName: string) => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
prioritize?: boolean;
|
|
6
8
|
}
|
|
7
|
-
export declare const FiltersSaveModal: ({ isOpen, onClose, onSave }: IFiltersModal) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const FiltersSaveModal: ({ isOpen, onClose, onSave, className, prioritize }: IFiltersModal) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,7 +9,7 @@ const textInput_1 = require("../../textInput/textInput");
|
|
|
9
9
|
const filtersSavedItemsProvider_1 = require("./filtersSavedItemsProvider");
|
|
10
10
|
const iconDisk_1 = require("../../icons/iconDisk");
|
|
11
11
|
const useDriveClassName_1 = require("../../utils/theme/useDriveClassName");
|
|
12
|
-
const FiltersSaveModal = ({ isOpen, onClose, onSave }) => {
|
|
12
|
+
const FiltersSaveModal = ({ isOpen, onClose, onSave, className, prioritize }) => {
|
|
13
13
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
14
14
|
const { items } = (0, filtersSavedItemsProvider_1.useFiltersSavedItems)();
|
|
15
15
|
const iconDriveClassName = (0, useDriveClassName_1.useDriveClassName)("icon");
|
|
@@ -48,6 +48,6 @@ const FiltersSaveModal = ({ isOpen, onClose, onSave }) => {
|
|
|
48
48
|
return "";
|
|
49
49
|
}, [filterName, isValidFilterName, items, translate]);
|
|
50
50
|
const saveIcon = (0, react_1.useCallback)(() => (0, jsx_runtime_1.jsx)(iconDisk_1.IconDisk, { description: translate("Save"), className: "svgIcon", size: iconDriveClassName ? "huge" : "large" }), [iconDriveClassName, translate]);
|
|
51
|
-
return (0, jsx_runtime_1.jsxs)(modal_1.Modal, { isOpen: isOpen, onClose: toggleSaveModal, title: translate("Save filters"), children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-filters-modal__content", children: (0, jsx_runtime_1.jsx)(textInput_1.TextInput, { value: filterName, ariaLabel: translate("Filter title"), placeholder: translate("Filter title"), onChange: handleSaveModalFieldChange, maxLength: 100, error: errorText }) }), (0, jsx_runtime_1.jsx)(modal_1.Modal.SecondaryButton, { onClick: handleCancelSaveModal, title: translate("Cancel"), children: translate("Cancel") }), (0, jsx_runtime_1.jsx)(modal_1.Modal.PrimaryButton, { onClick: handleApplySaveModal, icon: saveIcon, title: translate("Save"), children: translate("Save") })] });
|
|
51
|
+
return (0, jsx_runtime_1.jsxs)(modal_1.Modal, { focus: "content", modalContainerClassName: prioritize ? "zen-filters-prioritized-modal" : "", isOpen: isOpen, onClose: toggleSaveModal, title: translate("Save filters"), className: className || "", children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-filters-modal__content", children: (0, jsx_runtime_1.jsx)(textInput_1.TextInput, { value: filterName, ariaLabel: translate("Filter title"), placeholder: translate("Filter title"), onChange: handleSaveModalFieldChange, maxLength: 100, error: errorText }) }), (0, jsx_runtime_1.jsx)(modal_1.Modal.SecondaryButton, { onClick: handleCancelSaveModal, title: translate("Cancel"), children: translate("Cancel") }), (0, jsx_runtime_1.jsx)(modal_1.Modal.PrimaryButton, { onClick: handleApplySaveModal, icon: saveIcon, title: translate("Save"), children: translate("Save") })] });
|
|
52
52
|
};
|
|
53
53
|
exports.FiltersSaveModal = FiltersSaveModal;
|