@geotab/zenith 1.26.4 → 1.26.5-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 +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 +3453 -2649
- 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 +1 -1
|
@@ -0,0 +1,226 @@
|
|
|
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.getArrayOfElements = exports.useCombineData = exports.MAX_TOTAL_RESULTS = exports.serializeEntriesToId = exports.getTotalChangedNumber = exports.getNumberOfChangedFilters = exports.createStateObject = exports.getFiltersState = exports.getChildren = exports.prepareDefaultDropdownState = exports.getDropdownStateType = exports.stabilizeChildrenWithId = exports.createPropsHash = exports.createStateHash = void 0;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const filtersGroups_1 = require("./components/filtersGroups");
|
|
9
|
+
const react_2 = __importDefault(require("react"));
|
|
10
|
+
const isArraysEqualDeeply_1 = require("../utils/compareElementsUtils/isArraysEqualDeeply");
|
|
11
|
+
const isElementsEqual_1 = require("../utils/compareElementsUtils/isElementsEqual");
|
|
12
|
+
const groupsFilter_1 = require("../groupsFilter/groupsFilter");
|
|
13
|
+
const filtersChip_1 = require("./components/filtersChip");
|
|
14
|
+
const filtersDropdown_1 = require("./components/filtersDropdown");
|
|
15
|
+
const filtersSearchList_1 = require("./components/filtersSearchList");
|
|
16
|
+
const createStateHash = (state) => {
|
|
17
|
+
if (state === undefined) {
|
|
18
|
+
return "undefined";
|
|
19
|
+
}
|
|
20
|
+
if (state === null) {
|
|
21
|
+
return "null";
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const jsonString = JSON.stringify(state);
|
|
25
|
+
if (jsonString.length > 100) {
|
|
26
|
+
return `hash:${jsonString.length}:${jsonString.slice(0, 50)}`;
|
|
27
|
+
}
|
|
28
|
+
return jsonString;
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
return `[object ${typeof state}]`;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.createStateHash = createStateHash;
|
|
35
|
+
const createPropsHash = (props) => {
|
|
36
|
+
const relevantKeys = Object.keys(props)
|
|
37
|
+
.filter(key => key !== "children")
|
|
38
|
+
.sort();
|
|
39
|
+
return relevantKeys
|
|
40
|
+
.map(key => {
|
|
41
|
+
const value = props[key];
|
|
42
|
+
if (typeof value === "function") {
|
|
43
|
+
return `${key}:fn(${value.name || value.toString().slice(0, 30)})`;
|
|
44
|
+
}
|
|
45
|
+
if (key === "defaultState" || key === "onChange") {
|
|
46
|
+
try {
|
|
47
|
+
return `${key}:${JSON.stringify(value)}`;
|
|
48
|
+
}
|
|
49
|
+
catch (_a) {
|
|
50
|
+
return `${key}:${typeof value}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return `${key}:${typeof value}`;
|
|
54
|
+
})
|
|
55
|
+
.join(",");
|
|
56
|
+
};
|
|
57
|
+
exports.createPropsHash = createPropsHash;
|
|
58
|
+
const stabilizeChildrenWithId = (children) => {
|
|
59
|
+
const childrenArray = react_2.default.Children.toArray(children).filter(Boolean);
|
|
60
|
+
return childrenArray.map((child, index) => {
|
|
61
|
+
if (!react_2.default.isValidElement(child)) {
|
|
62
|
+
return child;
|
|
63
|
+
}
|
|
64
|
+
const childId = child.props.id;
|
|
65
|
+
if (!childId) {
|
|
66
|
+
console.error(`FiltersContainer: Child component at index ${index} is missing required 'id' prop. ` +
|
|
67
|
+
`Component will not be rendered. All filter components must have a unique 'id' for proper performance optimization.`, child);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return react_2.default.cloneElement(child, { key: childId });
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
exports.stabilizeChildrenWithId = stabilizeChildrenWithId;
|
|
74
|
+
const getDropdownStateType = (dropdownState) => {
|
|
75
|
+
if (Array.isArray(dropdownState)) {
|
|
76
|
+
return "base";
|
|
77
|
+
}
|
|
78
|
+
if (dropdownState.hasOwnProperty("isChecked") && dropdownState.hasOwnProperty("isAllSelected")) {
|
|
79
|
+
return "fullSelectionWithCheckbox";
|
|
80
|
+
}
|
|
81
|
+
if (dropdownState.hasOwnProperty("isAllSelected")) {
|
|
82
|
+
return "fullSelection";
|
|
83
|
+
}
|
|
84
|
+
return "withCheckbox";
|
|
85
|
+
};
|
|
86
|
+
exports.getDropdownStateType = getDropdownStateType;
|
|
87
|
+
const prepareDefaultDropdownState = (type) => {
|
|
88
|
+
if (type === "fullSelectionWithCheckbox") {
|
|
89
|
+
return { selected: [], isAllSelected: false, isChecked: false };
|
|
90
|
+
}
|
|
91
|
+
if (type === "withCheckbox") {
|
|
92
|
+
return { selected: [], isChecked: false };
|
|
93
|
+
}
|
|
94
|
+
if (type === "fullSelection") {
|
|
95
|
+
return { selected: [], isAllSelected: false };
|
|
96
|
+
}
|
|
97
|
+
return [];
|
|
98
|
+
};
|
|
99
|
+
exports.prepareDefaultDropdownState = prepareDefaultDropdownState;
|
|
100
|
+
const getChildren = (children) => (!children
|
|
101
|
+
? []
|
|
102
|
+
: (react_1.Children.count(children) === 1 ? [children] : children)).filter(c => !!c);
|
|
103
|
+
exports.getChildren = getChildren;
|
|
104
|
+
const getFiltersState = (children) => {
|
|
105
|
+
const state = {};
|
|
106
|
+
react_1.Children.forEach(children, (child) => {
|
|
107
|
+
state[child.props.id] = {};
|
|
108
|
+
state[child.props.id].state = child.props.state;
|
|
109
|
+
if (child.type === filtersGroups_1.FiltersGroups) {
|
|
110
|
+
state[child.props.id].defaultState = groupsFilter_1.groupsFilterTotalStateDefault;
|
|
111
|
+
}
|
|
112
|
+
else if (child.type === filtersChip_1.FiltersChip) {
|
|
113
|
+
state[child.props.id].defaultState = false;
|
|
114
|
+
}
|
|
115
|
+
else if (child.type === filtersDropdown_1.FiltersDropdown) {
|
|
116
|
+
state[child.props.id].defaultState = child.props.defaultState || (0, exports.prepareDefaultDropdownState)((0, exports.getDropdownStateType)(child.props.state));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
state[child.props.id].defaultState = child.props.defaultState;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return state;
|
|
123
|
+
};
|
|
124
|
+
exports.getFiltersState = getFiltersState;
|
|
125
|
+
const createStateObject = (children, field) => {
|
|
126
|
+
const state = {};
|
|
127
|
+
react_1.Children.forEach(children, (child) => {
|
|
128
|
+
state[child.props.id] = {};
|
|
129
|
+
if (child.type === filtersGroups_1.FiltersGroups && field === "defaultState") {
|
|
130
|
+
state[child.props.id] = groupsFilter_1.groupsFilterTotalStateDefault;
|
|
131
|
+
}
|
|
132
|
+
else if (child.type === filtersChip_1.FiltersChip && field === "defaultState") {
|
|
133
|
+
state[child.props.id] = false;
|
|
134
|
+
}
|
|
135
|
+
else if (child.type === filtersDropdown_1.FiltersDropdown && field === "defaultState") {
|
|
136
|
+
state[child.props.id] = child.props.defaultState || (0, exports.prepareDefaultDropdownState)((0, exports.getDropdownStateType)(child.props.state));
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
state[child.props.id] = child.props[field];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return state;
|
|
143
|
+
};
|
|
144
|
+
exports.createStateObject = createStateObject;
|
|
145
|
+
function getNumberOfChangedFilters(state) {
|
|
146
|
+
let changes = 0;
|
|
147
|
+
Object.keys(state).forEach(key => {
|
|
148
|
+
const defaultState = state[key].defaultState;
|
|
149
|
+
const currentState = state[key].state;
|
|
150
|
+
if (!state[key].hasOwnProperty("state") || !state[key].hasOwnProperty("defaultState")) {
|
|
151
|
+
changes++;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (Array.isArray(defaultState) && Array.isArray(currentState)) {
|
|
155
|
+
if (!(0, isArraysEqualDeeply_1.isArraysEqualDeeply)(defaultState, currentState)) {
|
|
156
|
+
changes++;
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (typeof defaultState === "object" && typeof currentState === "object") {
|
|
161
|
+
if (!(0, isElementsEqual_1.isElementsEqual)(defaultState, currentState)) {
|
|
162
|
+
changes++;
|
|
163
|
+
}
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (defaultState !== currentState) {
|
|
167
|
+
changes++;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
return changes;
|
|
171
|
+
}
|
|
172
|
+
exports.getNumberOfChangedFilters = getNumberOfChangedFilters;
|
|
173
|
+
const getTotalChangedNumber = (selectState, filters, isModalCondition) => {
|
|
174
|
+
const stateObject = (0, exports.createStateObject)(filters, "state");
|
|
175
|
+
const filteredFilters = filters.filter(el => typeof el.props.visible === "boolean" ? el.props.visible
|
|
176
|
+
: (el.props.visible === undefined ? true
|
|
177
|
+
: el.props.visible(Array.from(selectState), isModalCondition ? stateObject : undefined)));
|
|
178
|
+
const filteredChildrenState = (0, exports.getFiltersState)(filteredFilters);
|
|
179
|
+
const numberOfChangedFilters = getNumberOfChangedFilters(filteredChildrenState);
|
|
180
|
+
return numberOfChangedFilters;
|
|
181
|
+
};
|
|
182
|
+
exports.getTotalChangedNumber = getTotalChangedNumber;
|
|
183
|
+
const serializeEntriesToId = (entries) => {
|
|
184
|
+
const serializedEntries = entries.map(({ id, name, type }) => `${type || filtersSearchList_1.NO_TYPED_SEARCH_ITEM}:${id}:${name}`);
|
|
185
|
+
return serializedEntries.join("_");
|
|
186
|
+
};
|
|
187
|
+
exports.serializeEntriesToId = serializeEntriesToId;
|
|
188
|
+
exports.MAX_TOTAL_RESULTS = 500;
|
|
189
|
+
const useCombineData = (searchTypes) => {
|
|
190
|
+
var _a;
|
|
191
|
+
const combinedData = (0, react_1.useMemo)(() => {
|
|
192
|
+
const finalResults = [];
|
|
193
|
+
const totalRelevance = searchTypes.reduce((sum, item) => sum + (item.relevance !== undefined ? item.relevance : 1.0), 0);
|
|
194
|
+
if (totalRelevance === 0) {
|
|
195
|
+
return [];
|
|
196
|
+
}
|
|
197
|
+
searchTypes.forEach(item => {
|
|
198
|
+
const fetchedData = item.data.data;
|
|
199
|
+
const rawRelevance = item.relevance !== undefined ? item.relevance : 1.0;
|
|
200
|
+
if (fetchedData && Array.isArray(fetchedData)) {
|
|
201
|
+
const effectiveShare = rawRelevance / totalRelevance;
|
|
202
|
+
const limit = Math.round(exports.MAX_TOTAL_RESULTS * effectiveShare);
|
|
203
|
+
const takeCount = Math.min(limit, fetchedData.length);
|
|
204
|
+
const subset = fetchedData
|
|
205
|
+
.slice(0, takeCount)
|
|
206
|
+
.map((el) => (Object.assign(Object.assign({}, el), { type: item.id })));
|
|
207
|
+
finalResults.push(...subset);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return finalResults.slice(0, exports.MAX_TOTAL_RESULTS);
|
|
211
|
+
}, [searchTypes]);
|
|
212
|
+
const isLoading = searchTypes.some(item => item.data.isLoading);
|
|
213
|
+
return {
|
|
214
|
+
data: combinedData,
|
|
215
|
+
isLoading,
|
|
216
|
+
error: ((_a = searchTypes.find(item => item.data.error)) === null || _a === void 0 ? void 0 : _a.data.error) || null
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
exports.useCombineData = useCombineData;
|
|
220
|
+
function getArrayOfElements(elem) {
|
|
221
|
+
if (!elem) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
return Array.isArray(elem) ? elem : [elem];
|
|
225
|
+
}
|
|
226
|
+
exports.getArrayOfElements = getArrayOfElements;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IFiltersSearchType } from "./components/filtersSelect";
|
|
3
|
+
import { ISearchItem } from "./components/filtersSearchList";
|
|
4
|
+
export declare const useFiltersSearch: (keywordDebounceTime?: number) => {
|
|
5
|
+
keyword: string;
|
|
6
|
+
setKeyword: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
7
|
+
searchType: IFiltersSearchType;
|
|
8
|
+
setSearchType: import("react").Dispatch<import("react").SetStateAction<IFiltersSearchType>>;
|
|
9
|
+
isTypeEnabled: (type: string) => boolean;
|
|
10
|
+
debouncedKeyword: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const usePinnedFilters: () => {
|
|
13
|
+
isPinned: boolean;
|
|
14
|
+
onPinChange: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
15
|
+
};
|
|
16
|
+
export declare const useFiltersSelection: () => {
|
|
17
|
+
searchSelection: ISearchItem[];
|
|
18
|
+
setSearchSelection: import("react").Dispatch<import("react").SetStateAction<ISearchItem[]>>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFiltersSelection = exports.usePinnedFilters = exports.useFiltersSearch = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const filtersSelect_1 = require("./components/filtersSelect");
|
|
6
|
+
const useDebouncedMemo_1 = require("../commonHelpers/hooks/useDebouncedMemo");
|
|
7
|
+
const useFiltersSearch = (keywordDebounceTime = 300) => {
|
|
8
|
+
const [keyword, setKeyword] = (0, react_1.useState)("");
|
|
9
|
+
const [searchType, setSearchType] = (0, react_1.useState)((0, filtersSelect_1.getFiltersSearchTypeAllOption)());
|
|
10
|
+
const isTypeEnabled = (0, react_1.useCallback)((type) => Object.keys(searchType).includes(filtersSelect_1.ALL_SELECT_OPTION_ID) || Object.keys(searchType).includes(type), [searchType]);
|
|
11
|
+
const debouncedKeyword = (0, useDebouncedMemo_1.useDebouncedMemo)(() => keyword, [keyword], keywordDebounceTime);
|
|
12
|
+
return { keyword, setKeyword, searchType, setSearchType, isTypeEnabled, debouncedKeyword };
|
|
13
|
+
};
|
|
14
|
+
exports.useFiltersSearch = useFiltersSearch;
|
|
15
|
+
const usePinnedFilters = () => {
|
|
16
|
+
const [isPinned, setIsPinned] = (0, react_1.useState)(false);
|
|
17
|
+
const pinnedFilters = (0, react_1.useMemo)(() => ({ isPinned, onPinChange: setIsPinned }), [isPinned, setIsPinned]);
|
|
18
|
+
return pinnedFilters;
|
|
19
|
+
};
|
|
20
|
+
exports.usePinnedFilters = usePinnedFilters;
|
|
21
|
+
const useFiltersSelection = () => {
|
|
22
|
+
const [searchSelection, setSearchSelection] = (0, react_1.useState)([]);
|
|
23
|
+
return { searchSelection, setSearchSelection };
|
|
24
|
+
};
|
|
25
|
+
exports.useFiltersSelection = useFiltersSelection;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./filtersBarDropdownWithCheckbox.less";
|
|
3
3
|
import { IFiltersBarItem } from "../interfaces";
|
|
4
|
-
import { IDropdownWithCheckbox, IDropdownFullSelectionWithCheckbox } from "../../../dropdown/dropdown";
|
|
4
|
+
import { IDropdownWithCheckbox, IDropdownFullSelectionWithCheckbox, IDropdownItem } from "../../../dropdown/dropdown";
|
|
5
5
|
export interface IFiltersBarDropdownWithCheckboxState {
|
|
6
6
|
selected: string[];
|
|
7
7
|
isChecked: boolean;
|
|
@@ -11,9 +11,11 @@ export interface IFiltersBarDropdownWithCheckboxFullSelectionState {
|
|
|
11
11
|
isChecked: boolean;
|
|
12
12
|
isAllSelected: boolean;
|
|
13
13
|
}
|
|
14
|
-
export interface IFiltersBarDropdownWithCheckboxProps extends Omit<IDropdownWithCheckbox, "value" | "onChange" | "dataItems" | "getNamedItems" | "buttonType" | "alignment" | "error" | "className" | "children"> {
|
|
14
|
+
export interface IFiltersBarDropdownWithCheckboxProps extends Omit<IDropdownWithCheckbox, "value" | "onChange" | "dataItems" | "fetchState" | "getNamedItems" | "buttonType" | "alignment" | "error" | "className" | "children"> {
|
|
15
|
+
getData: (signal?: AbortSignal, searchValue?: string, checkboxValue?: boolean) => Promise<IDropdownItem[]>;
|
|
15
16
|
}
|
|
16
|
-
export interface IFiltersBarDropdownFullSelectionWithCheckboxProps extends Omit<IDropdownFullSelectionWithCheckbox, "value" | "onChange" | "getNamedItems" | "dataItems" | "buttonType" | "alignment" | "error" | "className" | "children"> {
|
|
17
|
+
export interface IFiltersBarDropdownFullSelectionWithCheckboxProps extends Omit<IDropdownFullSelectionWithCheckbox, "value" | "onChange" | "getNamedItems" | "dataItems" | "fetchState" | "buttonType" | "alignment" | "error" | "className" | "children"> {
|
|
18
|
+
getData: (signal?: AbortSignal, searchValue?: string, checkboxValue?: boolean) => Promise<IDropdownItem[]>;
|
|
17
19
|
}
|
|
18
20
|
export interface IFiltersBarDropdownWithCheckbox extends IFiltersBarItem<IFiltersBarDropdownWithCheckboxState, IFiltersBarDropdownWithCheckboxProps> {
|
|
19
21
|
className?: string;
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { IAdvancedEntitiesNavigatorDialog, IGroupItem, IGroupsFilterTotalState } from "./groupsFilterInterfaces";
|
|
3
3
|
import "./groupsFilter.less";
|
|
4
4
|
import { IZenComponentProps } from "../commonHelpers/zenComponent";
|
|
5
|
+
import { IChipsParent } from "../chip/chip";
|
|
5
6
|
interface IGroupsFilterOptions {
|
|
6
7
|
/**
|
|
7
8
|
* @deprecated
|
|
@@ -9,7 +10,11 @@ interface IGroupsFilterOptions {
|
|
|
9
10
|
*/
|
|
10
11
|
placeholder?: string;
|
|
11
12
|
}
|
|
12
|
-
export
|
|
13
|
+
export declare const groupsFilterTotalStateDefault: {
|
|
14
|
+
groups: import("./groupsFilterInterfaces").ILeafStateItem<import("..").IEntityWithId>;
|
|
15
|
+
sideWide: boolean;
|
|
16
|
+
};
|
|
17
|
+
export interface IGroupsFilter extends IZenComponentProps, IChipsParent {
|
|
13
18
|
initialFilterState?: IGroupsFilterTotalState;
|
|
14
19
|
dataLoader: () => Promise<IGroupItem[]>;
|
|
15
20
|
errorHandler: (e: Error) => void;
|
|
@@ -23,6 +28,10 @@ export interface IGroupsFilter extends IZenComponentProps {
|
|
|
23
28
|
fullSize?: boolean;
|
|
24
29
|
options?: IGroupsFilterOptions;
|
|
25
30
|
listLimit?: number;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated
|
|
33
|
+
* @param advancedDialog - will be removed in the next major release
|
|
34
|
+
*/
|
|
26
35
|
advancedDialog?: IAdvancedEntitiesNavigatorDialog;
|
|
27
36
|
}
|
|
28
37
|
export declare const GroupsFilter: React.FC<IGroupsFilter>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TRANSLATIONS = exports.GroupsFilter = void 0;
|
|
3
|
+
exports.TRANSLATIONS = exports.GroupsFilter = exports.groupsFilterTotalStateDefault = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const groupsFilterInterfaces_1 = require("./groupsFilterInterfaces");
|
|
@@ -26,8 +26,14 @@ const advancedGroupsFilter_1 = require("../advancedGroupsFilter/advancedGroupsFi
|
|
|
26
26
|
const useLanguage_1 = require("../utils/localization/useLanguage");
|
|
27
27
|
const groupsFilterAdvancedValue_1 = require("./groupsFilterAdvancedValue");
|
|
28
28
|
const skeletonList_1 = require("../skeletonList/skeletonList");
|
|
29
|
-
const
|
|
29
|
+
const chip_1 = require("../chip/chip");
|
|
30
|
+
const searchInput_1 = require("../searchInput/searchInput");
|
|
31
|
+
const chipStatusProvider_1 = require("../chip/chipStatusProvider");
|
|
32
|
+
exports.groupsFilterTotalStateDefault = { groups: (0, groupsHelper_1.getDefaultFilterState)(), sideWide: false };
|
|
33
|
+
// eslint-disable-next-line complexity
|
|
34
|
+
const GroupsFilter = ({ fullSize, className, dataLoader, errorHandler, isWithColor, onChange, initialFilterState, options = {}, listLimit = 500, chip, chipIcon, chipId, chipName }) => {
|
|
30
35
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
36
|
+
const chipStatus = (0, chipStatusProvider_1.useChipStatus)();
|
|
31
37
|
const [groupPlaceHolder, setGroupPlaceHolder] = (0, react_1.useState)(options.placeholder || translate("Groups"));
|
|
32
38
|
const [state, dispatchState] = (0, react_1.useReducer)(stateReducer_1.stateReducer, (0, stateReducer_1.getInitialState)(translate, initialFilterState));
|
|
33
39
|
const [uiState, dispatchUiState] = (0, react_1.useReducer)(uiStateReducer_1.uiStateReducer, uiStateReducer_1.uiInitialGroupsFilterState);
|
|
@@ -37,12 +43,14 @@ const GroupsFilter = ({ fullSize, className, dataLoader, errorHandler, isWithCol
|
|
|
37
43
|
const menuRef = (0, react_1.useRef)(null);
|
|
38
44
|
const prevInitialState = (0, react_1.useRef)(initialFilterState);
|
|
39
45
|
const prevSearchField = (0, react_1.useRef)("");
|
|
46
|
+
const groupsFilterId = (0, react_1.useId)();
|
|
40
47
|
const blocksMap = (0, react_1.useMemo)(() => [["builtInGroups", "userGroups"], ["advancedGroups", "builtInGroups", "userGroups"], ["builtInGroups", "userGroups"]], []);
|
|
41
48
|
const onOptionsToggle = () => { dispatchUiState({ type: uiStateActionType_1.UiStateActionType.ToggleOpen, payload: undefined }); };
|
|
42
49
|
const handleSetStep = (0, react_1.useCallback)((newStep) => {
|
|
50
|
+
var _a;
|
|
43
51
|
uiState.step !== groupsFilterInterfaces_1.FilterMenuStep.CurrentlySelected && dispatchUiState({ type: uiStateActionType_1.UiStateActionType.ClearUncheckedState, payload: undefined });
|
|
44
52
|
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetStep, payload: newStep });
|
|
45
|
-
if (inputRef.current.value && newStep !== groupsFilterInterfaces_1.FilterMenuStep.Initial) {
|
|
53
|
+
if (((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value) && newStep !== groupsFilterInterfaces_1.FilterMenuStep.Initial) {
|
|
46
54
|
inputRef.current.value = "";
|
|
47
55
|
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetSearchValue, payload: "" });
|
|
48
56
|
}
|
|
@@ -53,6 +61,11 @@ const GroupsFilter = ({ fullSize, className, dataLoader, errorHandler, isWithCol
|
|
|
53
61
|
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetIsOpen, payload: true });
|
|
54
62
|
uiState.step !== groupsFilterInterfaces_1.FilterMenuStep.Initial && handleSetStep(groupsFilterInterfaces_1.FilterMenuStep.Initial);
|
|
55
63
|
}, [handleSetStep, uiState.step]);
|
|
64
|
+
const onSearchChipChange = (0, react_1.useCallback)((newValue) => {
|
|
65
|
+
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetSearchValue, payload: newValue || "" });
|
|
66
|
+
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetIsOpen, payload: true });
|
|
67
|
+
uiState.step !== groupsFilterInterfaces_1.FilterMenuStep.Initial && handleSetStep(groupsFilterInterfaces_1.FilterMenuStep.Initial);
|
|
68
|
+
}, [handleSetStep, uiState.step]);
|
|
56
69
|
const handleCancel = () => {
|
|
57
70
|
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetIsOpen, payload: false });
|
|
58
71
|
dispatchState({ type: stateActionType_1.StateActionType.SetState, payload: state.frozenState });
|
|
@@ -63,7 +76,9 @@ const GroupsFilter = ({ fullSize, className, dataLoader, errorHandler, isWithCol
|
|
|
63
76
|
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetIsOpen, payload: false });
|
|
64
77
|
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetSearchValue, payload: "" });
|
|
65
78
|
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.ClearUncheckedState, payload: undefined });
|
|
66
|
-
inputRef.current
|
|
79
|
+
if (inputRef.current) {
|
|
80
|
+
inputRef.current.value = "";
|
|
81
|
+
}
|
|
67
82
|
handleSetStep(groupsFilterInterfaces_1.FilterMenuStep.Initial);
|
|
68
83
|
dispatchState({ type: stateActionType_1.StateActionType.FreezeState, payload: (0, stateReducerHelper_1.getCurrentState)(state) });
|
|
69
84
|
dispatchState({ type: stateActionType_1.StateActionType.FreezeSideWide, payload: state.sideWideState });
|
|
@@ -71,6 +86,18 @@ const GroupsFilter = ({ fullSize, className, dataLoader, errorHandler, isWithCol
|
|
|
71
86
|
const handleReset = () => {
|
|
72
87
|
dispatchState({ type: stateActionType_1.StateActionType.ResetSelection, payload: undefined });
|
|
73
88
|
};
|
|
89
|
+
const handleChipClose = () => {
|
|
90
|
+
dispatchState({ type: stateActionType_1.StateActionType.ResetSelection, payload: undefined });
|
|
91
|
+
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetIsOpen, payload: false });
|
|
92
|
+
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.SetSearchValue, payload: "" });
|
|
93
|
+
dispatchUiState({ type: uiStateActionType_1.UiStateActionType.ClearUncheckedState, payload: undefined });
|
|
94
|
+
if (inputRef.current) {
|
|
95
|
+
inputRef.current.value = "";
|
|
96
|
+
}
|
|
97
|
+
handleSetStep(groupsFilterInterfaces_1.FilterMenuStep.Initial);
|
|
98
|
+
dispatchState({ type: stateActionType_1.StateActionType.FreezeState, payload: stateReducer_1.defaultPreparedFilterState });
|
|
99
|
+
dispatchState({ type: stateActionType_1.StateActionType.FreezeSideWide, payload: false });
|
|
100
|
+
};
|
|
74
101
|
const handleCheckboxChange = (value) => {
|
|
75
102
|
if (value.partial) {
|
|
76
103
|
dispatchState({ type: stateActionType_1.StateActionType.DeselectAllChildren, payload: value.id });
|
|
@@ -211,25 +238,26 @@ const GroupsFilter = ({ fullSize, className, dataLoader, errorHandler, isWithCol
|
|
|
211
238
|
}
|
|
212
239
|
}, [initialFilterState, state.groupsMap]);
|
|
213
240
|
(0, react_1.useEffect)(() => {
|
|
214
|
-
var _a;
|
|
241
|
+
var _a, _b, _c;
|
|
215
242
|
if (!uiState.isOpen) {
|
|
216
243
|
return;
|
|
217
244
|
}
|
|
218
245
|
if (uiState.searchValue && uiState.step === groupsFilterInterfaces_1.FilterMenuStep.Initial || uiState.step === groupsFilterInterfaces_1.FilterMenuStep.Initial && uiState.searchValue === ""
|
|
219
246
|
&& prevSearchField.current !== uiState.searchValue) {
|
|
220
|
-
inputRef.current.focus();
|
|
247
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
221
248
|
prevSearchField.current = uiState.searchValue;
|
|
222
249
|
}
|
|
223
250
|
else {
|
|
224
|
-
const firstFocusable = (
|
|
251
|
+
const firstFocusable = (_b = menuRef.current) === null || _b === void 0 ? void 0 : _b.querySelector(focusableSelector_1.FOCUSABLE_SELECTOR);
|
|
225
252
|
prevSearchField.current = "";
|
|
226
|
-
if (firstFocusable && !inputRef.current.value) {
|
|
253
|
+
if (firstFocusable && !((_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.value)) {
|
|
227
254
|
firstFocusable.focus();
|
|
228
255
|
}
|
|
229
256
|
}
|
|
230
|
-
}, [uiState.searchValue, uiState.isOpen, uiState.step, handleSetStep]);
|
|
257
|
+
}, [uiState.searchValue, uiState.isOpen, uiState.step, handleSetStep, chip]);
|
|
231
258
|
(0, react_1.useEffect)(() => {
|
|
232
|
-
|
|
259
|
+
var _a;
|
|
260
|
+
uiState.isOpen && ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus());
|
|
233
261
|
}, [inputRef, uiState.isOpen]);
|
|
234
262
|
(0, react_1.useEffect)(() => {
|
|
235
263
|
if (!uiState.isOpen && uiState.step === groupsFilterInterfaces_1.FilterMenuStep.Initial && (0, groupsFilterHelper_1.isFilterHasSelection)(state.frozenState)) {
|
|
@@ -249,7 +277,8 @@ const GroupsFilter = ({ fullSize, className, dataLoader, errorHandler, isWithCol
|
|
|
249
277
|
(0, useEscape_1.useEscape)(triggerRef, handleEscape, uiState.isOpen);
|
|
250
278
|
const selectedCount = (0, stateReducerHelper_1.getFrozenCount)(state);
|
|
251
279
|
const isStateHasData = Object.keys(state.groupsMap).length > 0;
|
|
252
|
-
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(
|
|
280
|
+
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [chip ? (0, jsx_runtime_1.jsx)(chip_1.Chip, { status: selectedCount ? chipStatus || "active" : undefined, isOpen: uiState.isOpen, disabled: false, onClick: handleTriggerClick, onClose: selectedCount ? handleChipClose : undefined, triggerRef: triggerRef, icon: chipIcon, id: chipId, children: groupPlaceHolder !== translate("Groups") ? groupPlaceHolder : chipName })
|
|
281
|
+
: (0, jsx_runtime_1.jsx)(groupsFilterTrigger_1.GroupsFilterTrigger, { value: uiState.searchValue, onChange: onSearchChange, isOpenPopup: uiState.isOpen, count: selectedCount, withGlobeIcon: state.frozenSideWideState && selectedCount > 0, inputRef: inputRef, handleClick: handleTriggerClick, ref: triggerRef, fullSize: fullSize, placeholder: groupPlaceHolder }), (0, jsx_runtime_1.jsx)(controlledPopup_1.ControlledPopup, { isOpen: uiState.isOpen, className: (0, classNames_1.classNames)(["zen-groups-filter__popup", uiState.isOpenAdvancedFilter ? "zen-groups-filter__popup--inactive" : "", className ? className : ""]), onOpenChange: onOptionsToggle, useTrapFocusWithTrigger: uiState.isOpenAdvancedFilter ? "off" : "withTrigger", shouldHoldScroll: true, triggerRef: triggerRef, ariaLabel: translate("Organization groups filter"), recalculateOnScroll: true, children: (0, jsx_runtime_1.jsxs)("div", { className: "zen-groups-filter-menu", ref: menuRef, children: [chip && (0, jsx_runtime_1.jsx)("div", { className: "zen-groups-filter__input-container", children: (0, jsx_runtime_1.jsx)(searchInput_1.SearchInput, { className: "zen-groups-filter__chip-input", onChange: onSearchChipChange, value: uiState.searchValue, ref: inputRef, id: groupsFilterId, placeholder: translate("Filter by group") }) }), isStateHasData && !uiState.isLoadWithError && (0, jsx_runtime_1.jsxs)(groupsFilterMenu_1.GroupsFilterMenu, { onCancelClick: handleCancel, onApplyClick: handleApply, onResetClick: handleReset, isApplyDisabled: !(0, stateReducerHelper_1.isStateChanged)(state), children: [uiState.step === groupsFilterInterfaces_1.FilterMenuStep.Initial && (0, jsx_runtime_1.jsx)(groupsFilterInitialState_1.GroupsFilterInitialState, { siteWideState: state.sideWideState, onDialogButtonClick: handleAdvancedDialogOpen, count: (0, stateReducerHelper_1.getCurrentlySelectedCount)(state), onSiteWideChange: onSideWideChange, onCurrentlySelectedClick: handleCurrentlySelectedClick, searchResult: uiState.searchValue ? getSearchResult() : "", children: getGroupsBox() }), uiState.step === groupsFilterInterfaces_1.FilterMenuStep.Adjustment && (0, jsx_runtime_1.jsx)(groupsFilterAdjustmentState_1.GroupsFilterAdjustmentState, { onBackButtonClick: handleBackButtonClick, onHomeButtonClick: handleHomeButtonClick, onSelectAllClick: selectAllHandler, backButtonName: (0, groupsFilterStatesHelper_1.getBackButtonName)(state, uiState.currentAdjustmentId), isAllSelected: (0, groupsFilterStatesHelper_1.isAllChildrenSelected)(state, uiState.currentAdjustmentId), children: getGroupsBox() }), uiState.step === groupsFilterInterfaces_1.FilterMenuStep.CurrentlySelected && (0, jsx_runtime_1.jsx)(groupsFilterCurrentlySelectedState_1.GroupsFilterCurrentlySelectedState, { siteWideState: state.sideWideState, relation: state.relation, count: (0, stateReducerHelper_1.getCurrentlySelectedCount)(state), onBackButtonClick: basicHandleBackButtonClick, onSiteWideChange: onSideWideChange, onRelationChange: onRelationChange, children: getGroupsBox() })] }), !uiState.isLoadWithError && !isStateHasData && !Object.keys(state.groupsMap).length && (0, jsx_runtime_1.jsx)(skeletonList_1.SkeletonList, { className: "zen-groups-filter__waiting" })] }) }), uiState.isOpenAdvancedFilter && getAdvancedDialog] });
|
|
253
282
|
};
|
|
254
283
|
exports.GroupsFilter = GroupsFilter;
|
|
255
284
|
exports.TRANSLATIONS = [
|
|
@@ -14,21 +14,24 @@ const headerHelpers_1 = require("../../headerHelpers");
|
|
|
14
14
|
const iconDotVertical_1 = require("../../../icons/iconDotVertical");
|
|
15
15
|
const useDrive_1 = require("../../../utils/theme/useDrive");
|
|
16
16
|
const handleCustomMenuWrapper_1 = require("./utils/handleCustomMenuWrapper");
|
|
17
|
+
const pageHeaderButton_1 = require("../../../pageHeader/pageHeaderButton");
|
|
18
|
+
const pageHeaderMenu_1 = require("../../../pageHeader/pageHeaderMenu");
|
|
19
|
+
const classNames_1 = require("../../../commonHelpers/classNames/classNames");
|
|
17
20
|
exports.HeaderCustomContent = (0, react_1.createContext)({
|
|
18
21
|
content: null,
|
|
19
22
|
setContent: (_1) => { }
|
|
20
23
|
});
|
|
21
24
|
const HeaderCustomContentProvider = ({ children, content, setContent }) => (0, jsx_runtime_1.jsx)(exports.HeaderCustomContent.Provider, { value: { content: content, setContent }, children: children });
|
|
22
25
|
exports.HeaderCustomContentProvider = HeaderCustomContentProvider;
|
|
23
|
-
const PageToolbarCollapsedItemsControl = ({ children }) => {
|
|
26
|
+
const PageToolbarCollapsedItemsControl = ({ children, className }) => {
|
|
24
27
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
25
28
|
const isDrive = (0, useDrive_1.useDrive)();
|
|
26
29
|
const { content } = (0, react_1.useContext)(exports.HeaderCustomContent);
|
|
27
|
-
const adjustmentButton = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { "aria-label": translate("More"), className: "zen-header-more-button", type: buttonType_1.ButtonType.TertiaryBlack, iconPosition: textIconButton_1.ButtonIconPosition.End, iconSize: isDrive ? svgIconSize_1.SvgIconSize.Huge : svgIconSize_1.SvgIconSize.Large, icon: iconDotVertical_1.IconDotVertical }), [isDrive, translate]);
|
|
30
|
+
const adjustmentButton = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { "aria-label": translate("More"), className: (0, classNames_1.classNames)(["zen-header-more-button", className || ""]), type: buttonType_1.ButtonType.TertiaryBlack, iconPosition: textIconButton_1.ButtonIconPosition.End, iconSize: isDrive ? svgIconSize_1.SvgIconSize.Huge : svgIconSize_1.SvgIconSize.Large, icon: iconDotVertical_1.IconDotVertical }), [isDrive, translate, className]);
|
|
28
31
|
const items = [];
|
|
29
32
|
const clickHandler = (0, react_1.useCallback)((propsOnClick) => ((_, e) => { propsOnClick(e); }), []);
|
|
30
33
|
react_1.Children.forEach(children, (child) => {
|
|
31
|
-
if ((0, headerHelpers_1.isNamedChildComponent)(child, headerButton_1.HeaderButtonDisplayName)) {
|
|
34
|
+
if ((0, headerHelpers_1.isNamedChildComponent)(child, headerButton_1.HeaderButtonDisplayName) || (0, headerHelpers_1.isNamedChildComponent)(child, pageHeaderButton_1.PageHeaderButtonDisplayName)) {
|
|
32
35
|
const onClick = child.props.onClick;
|
|
33
36
|
const el = (0, react_1.createElement)(menu_1.Menu.Item, {
|
|
34
37
|
id: child.props.id,
|
|
@@ -47,7 +50,7 @@ const PageToolbarCollapsedItemsControl = ({ children }) => {
|
|
|
47
50
|
});
|
|
48
51
|
items.push(el);
|
|
49
52
|
}
|
|
50
|
-
if ((0, headerHelpers_1.isNamedChildComponent)(child, headerMenu_1.HeaderMenuDisplayName)) {
|
|
53
|
+
if ((0, headerHelpers_1.isNamedChildComponent)(child, headerMenu_1.HeaderMenuDisplayName) || (0, headerHelpers_1.isNamedChildComponent)(child, pageHeaderMenu_1.PageHeaderMenuDisplayName)) {
|
|
51
54
|
const el = (0, react_1.createElement)(menu_1.Menu.Item, {
|
|
52
55
|
id: child.props.id,
|
|
53
56
|
key: child.props.id,
|
|
@@ -12,6 +12,7 @@ export interface IHeaderMenu extends Omit<IButton, "onClick"> {
|
|
|
12
12
|
icon?: FC<IIcon>;
|
|
13
13
|
iconSize?: TSvgIconSize;
|
|
14
14
|
alignment?: TAlignment;
|
|
15
|
+
onlyIcon?: boolean;
|
|
15
16
|
}
|
|
16
17
|
export declare const HeaderMenuDisplayName = "HeaderMenu";
|
|
17
18
|
export declare const HeaderMenu: FC<IHeaderMenu>;
|
|
@@ -24,18 +24,25 @@ const useDrive_1 = require("../utils/theme/useDrive");
|
|
|
24
24
|
const useDriveClassName_1 = require("../utils/theme/useDriveClassName");
|
|
25
25
|
exports.HeaderMenuDisplayName = "HeaderMenu";
|
|
26
26
|
const HeaderMenu = (_a) => {
|
|
27
|
-
var { name, children, icon, iconSize = "large", className = "", important, alignment = "bottom-right", inContextMenu } = _a, restProps = __rest(_a, ["name", "children", "icon", "iconSize", "className", "important", "alignment", "inContextMenu"]);
|
|
27
|
+
var { name, children, icon, iconSize = "large", className = "", important, alignment = "bottom-right", inContextMenu, onlyIcon } = _a, restProps = __rest(_a, ["name", "children", "icon", "iconSize", "className", "important", "alignment", "inContextMenu", "onlyIcon"]);
|
|
28
28
|
const isMobile = (0, useMobile_1.useMobile)();
|
|
29
29
|
const isDrive = (0, useDrive_1.useDrive)();
|
|
30
30
|
const driveClassName = (0, useDriveClassName_1.useDriveClassName)("zen-header-button-with-dropdown");
|
|
31
31
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
32
32
|
const ref = (0, react_1.useRef)(null);
|
|
33
|
-
const fullClassName = (0, classNames_1.classNames)([
|
|
34
|
-
|
|
33
|
+
const fullClassName = (0, classNames_1.classNames)([
|
|
34
|
+
"zen-header-button zen-header-button--with-dropdown",
|
|
35
|
+
"zen-caption",
|
|
36
|
+
isMobile ? "zen-header-button--mobile" : "",
|
|
37
|
+
onlyIcon ? "zen-header-button--hidden-name" : "",
|
|
38
|
+
driveClassName || "",
|
|
39
|
+
className
|
|
40
|
+
]);
|
|
41
|
+
const props = Object.assign(Object.assign(Object.assign({}, restProps), { "data-important": important ? "1" : "0" }), (isMobile || onlyIcon ? { title: restProps.title || name } : {}));
|
|
35
42
|
const onTriggerClick = (0, react_1.useCallback)(() => {
|
|
36
43
|
setIsOpen(!isOpen);
|
|
37
44
|
}, [isOpen]);
|
|
38
|
-
const trigger = (0, jsx_runtime_1.jsxs)(button_1.Button, Object.assign({ onClick: onTriggerClick, ref: ref, className: fullClassName }, props, { children: [icon ? icon({ className: "zen-caption__pre-content", size: isDrive ? (0, svgIconSize_1.driveIconSize)(iconSize) : iconSize }) : null, isMobile ? null : (0, jsx_runtime_1.jsx)("span", { className: "zen-caption__content", children: name }), (0, jsx_runtime_1.jsx)(iconChevronDownSmall_1.IconChevronDownSmall, { size: isDrive ? (0, svgIconSize_1.driveIconSize)("large") : "large", className: "zen-caption__post-content" })] }));
|
|
45
|
+
const trigger = (0, jsx_runtime_1.jsxs)(button_1.Button, Object.assign({ onClick: onTriggerClick, ref: ref, className: fullClassName }, props, { children: [icon ? icon({ className: "zen-caption__pre-content", size: isDrive ? (0, svgIconSize_1.driveIconSize)(iconSize) : iconSize }) : null, isMobile || onlyIcon ? null : (0, jsx_runtime_1.jsx)("span", { className: "zen-caption__content", children: name }), onlyIcon ? null : (0, jsx_runtime_1.jsx)(iconChevronDownSmall_1.IconChevronDownSmall, { size: isDrive ? (0, svgIconSize_1.driveIconSize)("large") : "large", className: "zen-caption__post-content" })] }));
|
|
39
46
|
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [trigger, (0, jsx_runtime_1.jsx)(controlledMenu_1.ControlledMenu, { title: name, triggerRef: ref, isOpen: isOpen, setIsOpen: setIsOpen, alignment: alignment, children: children })] });
|
|
40
47
|
};
|
|
41
48
|
exports.HeaderMenu = HeaderMenu;
|