@geotab/zenith 1.24.2 → 1.25.1-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 +15 -0
- package/dist/card/components/title.js +2 -2
- package/dist/commonStyles/zIndex.less +49 -0
- package/dist/dropdown/dropdown.d.ts +39 -1
- package/dist/dropdown/dropdown.js +119 -52
- package/dist/dropdown/dropdownList.d.ts +3 -0
- package/dist/dropdown/dropdownList.js +5 -4
- package/dist/dropdown/dropdownPopup.d.ts +3 -0
- package/dist/dropdown/dropdownPopup.js +3 -2
- package/dist/dropdown/stateReducer/stateAction.d.ts +10 -1
- package/dist/dropdown/stateReducer/stateActionType.d.ts +3 -1
- package/dist/dropdown/stateReducer/stateActionType.js +2 -0
- package/dist/dropdown/stateReducer/stateReducer.d.ts +7 -1
- package/dist/dropdown/stateReducer/stateReducer.js +12 -5
- package/dist/filtersBar/components/filtersBarDropdown/filtersBarDropdown.d.ts +2 -2
- package/dist/filtersBar/components/filtersBarDropdownWithCheckbox/filtersBarDropdownWithCheckbox.d.ts +29 -0
- package/dist/filtersBar/components/filtersBarDropdownWithCheckbox/filtersBarDropdownWithCheckbox.js +67 -0
- package/dist/filtersBar/filtersBar.d.ts +2 -0
- package/dist/filtersBar/filtersBar.js +2 -0
- package/dist/filtersBar/filtersBarInterfaces.d.ts +5 -2
- package/dist/filtersBar/filtersBarSidePanel/components/filtersBarSidePanelDropdownWithCheckbox/filtersBarSidePanelDropdownWithCheckbox.d.ts +21 -0
- package/dist/filtersBar/filtersBarSidePanel/components/filtersBarSidePanelDropdownWithCheckbox/filtersBarSidePanelDropdownWithCheckbox.js +50 -0
- package/dist/formStepper/components/formStep.d.ts +16 -0
- package/dist/formStepper/components/formStep.js +17 -0
- package/dist/formStepper/components/formStepRaw.d.ts +13 -0
- package/dist/formStepper/components/formStepRaw.js +15 -0
- package/dist/formStepper/formStepper.d.ts +12 -0
- package/dist/formStepper/formStepper.js +27 -0
- package/dist/formStepper/utils/getAriaLabelMobile.d.ts +1 -0
- package/dist/formStepper/utils/getAriaLabelMobile.js +10 -0
- package/dist/formStepper/utils/getOnClick.d.ts +2 -0
- package/dist/formStepper/utils/getOnClick.js +10 -0
- package/dist/formStepper/utils/getTabIndex.d.ts +2 -0
- package/dist/formStepper/utils/getTabIndex.js +15 -0
- package/dist/formStepper/utils/isAreaSelected.d.ts +2 -0
- package/dist/formStepper/utils/isAreaSelected.js +15 -0
- package/dist/formStepperButtons/formStepperButtons.d.ts +10 -0
- package/dist/formStepperButtons/formStepperButtons.js +36 -0
- package/dist/gridLayout/utils/getAllowedComponent.js +5 -0
- package/dist/gridLayout/utils/updateGridStateWithDefaultValues.js +8 -0
- package/dist/header/headerButton.d.ts +1 -0
- package/dist/header/headerButton.js +1 -1
- package/dist/header/headerMenu.d.ts +1 -0
- package/dist/header/headerMenu.js +1 -1
- package/dist/header/hooks/useNonFittingElements.d.ts +1 -0
- package/dist/header/hooks/useNonFittingElements.js +3 -2
- package/dist/index.css +304 -13
- package/dist/index.d.ts +6 -2
- package/dist/index.js +20 -14
- package/dist/pillExpandable/pillContent.js +3 -4
- package/dist/sidePanel/sidePanel.d.ts +2 -0
- package/dist/sidePanel/sidePanel.js +22 -4
- package/dist/timePicker/timePicker.d.ts +1 -0
- package/dist/timePicker/timePicker.js +5 -3
- package/dist/utils/localization/getSupportedLanguage.d.ts +1 -1
- package/dist/utils/localization/getSupportedLanguage.js +1 -1
- package/dist/utils/localization/languageContext.d.ts +1 -1
- package/dist/utils/localization/translations/cs-json.d.ts +6 -0
- package/dist/utils/localization/translations/cs-json.js +7 -1
- package/dist/utils/localization/translations/de-json.d.ts +6 -0
- package/dist/utils/localization/translations/de-json.js +7 -1
- package/dist/utils/localization/translations/en-json.d.ts +6 -0
- package/dist/utils/localization/translations/en-json.js +7 -1
- package/dist/utils/localization/translations/es-json.d.ts +6 -0
- package/dist/utils/localization/translations/es-json.js +7 -1
- package/dist/utils/localization/translations/fr-FR-json.d.ts +6 -0
- package/dist/utils/localization/translations/fr-FR-json.js +7 -1
- package/dist/utils/localization/translations/fr-json.d.ts +6 -0
- package/dist/utils/localization/translations/fr-json.js +7 -1
- package/dist/utils/localization/translations/id-json.d.ts +6 -0
- package/dist/utils/localization/translations/id-json.js +7 -1
- package/dist/utils/localization/translations/it-json.d.ts +6 -0
- package/dist/utils/localization/translations/it-json.js +7 -1
- package/dist/utils/localization/translations/ja-json.d.ts +6 -0
- package/dist/utils/localization/translations/ja-json.js +7 -1
- package/dist/utils/localization/translations/ko-KR-json.d.ts +6 -0
- package/dist/utils/localization/translations/ko-KR-json.js +7 -1
- package/dist/utils/localization/translations/ms-json.d.ts +6 -0
- package/dist/utils/localization/translations/ms-json.js +7 -1
- package/dist/utils/localization/translations/nl-json.d.ts +6 -0
- package/dist/utils/localization/translations/nl-json.js +7 -1
- package/dist/utils/localization/translations/pl-json.d.ts +6 -0
- package/dist/utils/localization/translations/pl-json.js +7 -1
- package/dist/utils/localization/translations/pt-BR-json.d.ts +6 -0
- package/dist/utils/localization/translations/pt-BR-json.js +7 -1
- package/dist/utils/localization/translations/sv-json.d.ts +6 -0
- package/dist/utils/localization/translations/sv-json.js +7 -1
- package/dist/utils/localization/translations/th-json.d.ts +6 -0
- package/dist/utils/localization/translations/th-json.js +7 -1
- package/dist/utils/localization/translations/tr-json.d.ts +6 -0
- package/dist/utils/localization/translations/tr-json.js +7 -1
- package/dist/utils/localization/translations/zh-Hans-json.d.ts +6 -0
- package/dist/utils/localization/translations/zh-Hans-json.js +7 -1
- package/dist/utils/localization/translations/zh-TW-json.d.ts +252 -0
- package/dist/utils/localization/translations/zh-TW-json.js +255 -0
- package/dist/utils/localization/useLanguage.js +3 -1
- package/package.json +2 -2
- package/dist/pillExpandable/sanitizeJSX.d.ts +0 -2
- package/dist/pillExpandable/sanitizeJSX.js +0 -26
package/README.md
CHANGED
|
@@ -40,6 +40,21 @@ Zenith library provides components defined in Zenith Design System. It includes
|
|
|
40
40
|
|
|
41
41
|
## Change log
|
|
42
42
|
|
|
43
|
+
### 1.25.1
|
|
44
|
+
|
|
45
|
+
* `FiltersBar.DropdownWithCheckbox` has been added
|
|
46
|
+
* `FormStepper` has been added
|
|
47
|
+
* Add tooltip for a long title in `Card`
|
|
48
|
+
* Add property to configure `SidePanel` width
|
|
49
|
+
* Add translations for tranditional chinese language
|
|
50
|
+
* Fix `Chart` tooltip in `Modal`
|
|
51
|
+
* Description can be a `ReactNode` in `PillExpandable`
|
|
52
|
+
* Allow buttons in `Header` to be in context menu by default
|
|
53
|
+
* Fix visual appearance of `PillExpandable`
|
|
54
|
+
* Fix loading option names in pills under the `Dropdown`
|
|
55
|
+
* Add `aria-label` to single-select dropdown
|
|
56
|
+
* Add the property `error` to `TimePicker`
|
|
57
|
+
|
|
43
58
|
### 1.24.2
|
|
44
59
|
|
|
45
60
|
* Add Summary component in Charts
|
|
@@ -15,7 +15,7 @@ const Title = ({ isMobile, link, title, id, icon, iconType, className = "" }) =>
|
|
|
15
15
|
return (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-card-title", driveClassNames || ""]), children: [icon
|
|
16
16
|
? (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-card-title__icon", iconClassName]), children: (0, react_1.createElement)(icon, { size: iconSize }) })
|
|
17
17
|
: null, link
|
|
18
|
-
? (0, jsx_runtime_1.jsxs)("a", { id: id, className: (0, classNames_1.classNames)(["zen-card-title__link"]), href: link, children: [(0, jsx_runtime_1.jsx)("span", { className: (0, classNames_1.classNames)(["zen-card-title__link-text"]), children: title }), (0, jsx_runtime_1.jsx)("div", { className: "zen-card-title__link-chevron", children: (0, jsx_runtime_1.jsx)(iconChevronRightSmall_1.IconChevronRightSmall, { size: iconSize, className: "zen-card-title__chevron-icon" }) })] })
|
|
19
|
-
: (0, jsx_runtime_1.jsx)("span", { id: id, className: (0, classNames_1.classNames)(["zen-card-title__text", (isMobile && !isDrive) ? "zen-card-title__text--mobile" : "", className]), children: title })] });
|
|
18
|
+
? (0, jsx_runtime_1.jsxs)("a", { id: id, className: (0, classNames_1.classNames)(["zen-card-title__link"]), href: link, children: [(0, jsx_runtime_1.jsx)("span", { title: title, className: (0, classNames_1.classNames)(["zen-card-title__link-text"]), children: title }), (0, jsx_runtime_1.jsx)("div", { className: "zen-card-title__link-chevron", children: (0, jsx_runtime_1.jsx)(iconChevronRightSmall_1.IconChevronRightSmall, { size: iconSize, className: "zen-card-title__chevron-icon" }) })] })
|
|
19
|
+
: (0, jsx_runtime_1.jsx)("span", { title: title, id: id, className: (0, classNames_1.classNames)(["zen-card-title__text", (isMobile && !isDrive) ? "zen-card-title__text--mobile" : "", className]), children: title })] });
|
|
20
20
|
};
|
|
21
21
|
exports.Title = Title;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// ---- Dropdowns, Tooltips, Popups, Modals ----
|
|
2
|
+
|
|
1
3
|
@z-index-11100: 11100;
|
|
2
4
|
// Tooltip
|
|
3
5
|
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
// Modal
|
|
47
49
|
// GroupsFilter
|
|
48
50
|
|
|
51
|
+
// AdvancedGroupsFilter (inner; part of GroupsFilter)
|
|
49
52
|
// DialogContent (deprecated)
|
|
50
53
|
|
|
51
54
|
@z-index-11000: 11000;
|
|
@@ -57,6 +60,9 @@
|
|
|
57
60
|
// ModalShield (inner)
|
|
58
61
|
// Dialog shield (deprecated)
|
|
59
62
|
|
|
63
|
+
@z-index-10999: 10999; // hidden in storybook
|
|
64
|
+
// GroupsFilter (when AdvancedGroupsFilter is open)
|
|
65
|
+
|
|
60
66
|
@z-index-10007: 10007;
|
|
61
67
|
// SidePanel
|
|
62
68
|
|
|
@@ -65,3 +71,46 @@
|
|
|
65
71
|
|
|
66
72
|
@z-index-10005: 10005;
|
|
67
73
|
// Waiting
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// ---- Non modal/internal items (hidden in storybook) ----
|
|
77
|
+
|
|
78
|
+
@z-index-5001: 5001;
|
|
79
|
+
// DataGrid (flexibleColumnsReorder, inner)
|
|
80
|
+
|
|
81
|
+
@z-index-5000: 5000;
|
|
82
|
+
// DataGrid (FlexibleColumnsResizer, inner)
|
|
83
|
+
|
|
84
|
+
@z-index-1000: 1000;
|
|
85
|
+
// FiltersBar inner items (Drive)
|
|
86
|
+
// PageLayout (deprecated)
|
|
87
|
+
|
|
88
|
+
@z-index-10: 10;
|
|
89
|
+
// Header
|
|
90
|
+
// Layout (inner items)
|
|
91
|
+
|
|
92
|
+
@z-index-4: 4;
|
|
93
|
+
// DataGrid inner items
|
|
94
|
+
|
|
95
|
+
@z-index-3: 3;
|
|
96
|
+
// DataGrid inner items
|
|
97
|
+
|
|
98
|
+
@z-index-2: 2;
|
|
99
|
+
// Calendar inner items
|
|
100
|
+
// DataGrid inner items
|
|
101
|
+
// BulkActions inner items (internal component)
|
|
102
|
+
// SearchableField inner items (deprecated)
|
|
103
|
+
// SortControl inner items
|
|
104
|
+
|
|
105
|
+
@z-index-1: 1;
|
|
106
|
+
// Calendar inner items
|
|
107
|
+
// GroupsFilter inner items
|
|
108
|
+
// SearchableField inner items (deprecated)
|
|
109
|
+
// DateRange inner items
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@z-index--1: -1;
|
|
113
|
+
// BulkActions inner items (internal component)
|
|
114
|
+
// Header inner items
|
|
115
|
+
|
|
116
|
+
|
|
@@ -48,15 +48,39 @@ interface IDropdownBase {
|
|
|
48
48
|
classNamePopup?: string;
|
|
49
49
|
error?: string;
|
|
50
50
|
sortFn?: (a: IDropdownItem, b: IDropdownItem) => number;
|
|
51
|
+
checkboxLabel?: string;
|
|
51
52
|
}
|
|
52
53
|
export interface IDropdownValueFullSelection {
|
|
53
54
|
selected: string[];
|
|
54
55
|
isAllSelected: boolean;
|
|
55
56
|
}
|
|
57
|
+
export interface IDropdownWithCheckboxValue {
|
|
58
|
+
selected: string[];
|
|
59
|
+
isChecked: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface IDropdownWithCheckboxSelected {
|
|
62
|
+
selected: ISelectionItem[];
|
|
63
|
+
isChecked: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface IDropdownValueFullSelectionWithCheckbox {
|
|
66
|
+
selected: string[];
|
|
67
|
+
isAllSelected: boolean;
|
|
68
|
+
isChecked: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface IDropdownPrevValueFullSelection {
|
|
71
|
+
selected: string[];
|
|
72
|
+
isAllSelected?: boolean;
|
|
73
|
+
isChecked?: boolean;
|
|
74
|
+
}
|
|
56
75
|
export interface IDropdownFullSelectedValue {
|
|
57
76
|
selected: ISelectionItem[];
|
|
58
77
|
isAllSelected: boolean;
|
|
59
78
|
}
|
|
79
|
+
export interface IDropdownFullSelectedValueWithCheckbox {
|
|
80
|
+
selected: ISelectionItem[];
|
|
81
|
+
isAllSelected: boolean;
|
|
82
|
+
isChecked: boolean;
|
|
83
|
+
}
|
|
60
84
|
export interface IDropdownFullSelection extends IDropdownBase {
|
|
61
85
|
multiselect: true;
|
|
62
86
|
selectAllButton: true;
|
|
@@ -71,6 +95,20 @@ export interface IDropdown extends IDropdownBase {
|
|
|
71
95
|
selectAllButton?: boolean;
|
|
72
96
|
defaultValue?: string[];
|
|
73
97
|
}
|
|
74
|
-
export
|
|
98
|
+
export interface IDropdownWithCheckbox extends Omit<IDropdown, "value" | "onChange" | "getData" | "defaultValue"> {
|
|
99
|
+
checkboxLabel: string;
|
|
100
|
+
value: IDropdownWithCheckboxValue;
|
|
101
|
+
getData: (signal?: AbortSignal, searchValue?: string, isChecked?: boolean) => Promise<IDropdownItem[]>;
|
|
102
|
+
defaultValue?: IDropdownWithCheckboxValue;
|
|
103
|
+
onChange: (selected: IDropdownWithCheckboxSelected) => void;
|
|
104
|
+
}
|
|
105
|
+
export interface IDropdownFullSelectionWithCheckbox extends Omit<IDropdownFullSelection, "value" | "onChange" | "getData" | "defaultValue"> {
|
|
106
|
+
checkboxLabel: string;
|
|
107
|
+
value: IDropdownValueFullSelectionWithCheckbox;
|
|
108
|
+
getData: (signal?: AbortSignal, searchValue?: string, isChecked?: boolean) => Promise<IDropdownItem[]>;
|
|
109
|
+
defaultValue?: IDropdownValueFullSelectionWithCheckbox;
|
|
110
|
+
onChange: (selected: IDropdownFullSelectedValueWithCheckbox) => void;
|
|
111
|
+
}
|
|
112
|
+
export declare const Dropdown: React.FC<IDropdown | IDropdownFullSelection | IDropdownWithCheckbox | IDropdownFullSelectionWithCheckbox>;
|
|
75
113
|
export declare const TRANSLATIONS: string[];
|
|
76
114
|
export {};
|
|
@@ -19,36 +19,46 @@ const dropdownPopup_1 = require("./dropdownPopup");
|
|
|
19
19
|
const useMobile_1 = require("../commonHelpers/hooks/useMobile");
|
|
20
20
|
const useDebounce_1 = require("../commonHelpers/hooks/useDebounce");
|
|
21
21
|
const skeletonList_1 = require("../skeletonList/skeletonList");
|
|
22
|
-
const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems, onChange, value, defaultValue, placeholder, dialogAriaLabel, width, isLoading, title, triggerAriaLabel, disabled, inputId, filterName, showCounterPill = true, showSelection, fullWidthTriggerButton, hasApplyButton, searchField = true, multiselect = true, forceSelection = false, selectAllButton = true, getNamedItems, getSelectedItem, buttonType = "secondary", listLimit = 500, alignment = "bottom-left", error, sortFn }) => {
|
|
22
|
+
const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems, onChange, value, defaultValue, placeholder, dialogAriaLabel, width, isLoading, title, triggerAriaLabel, disabled, inputId, filterName, showCounterPill = true, showSelection, fullWidthTriggerButton, hasApplyButton, searchField = true, multiselect = true, forceSelection = false, selectAllButton = true, getNamedItems, getSelectedItem, buttonType = "secondary", listLimit = 500, alignment = "bottom-left", error, sortFn, checkboxLabel }) => {
|
|
23
23
|
var _a;
|
|
24
|
-
const isFullSelectionMode = (0, react_1.useMemo)(() =>
|
|
25
|
-
|
|
24
|
+
const isFullSelectionMode = (0, react_1.useMemo)(() => typeof value === "object" &&
|
|
25
|
+
"selected" in value &&
|
|
26
|
+
Array.isArray(value.selected) &&
|
|
27
|
+
"isAllSelected" in value &&
|
|
28
|
+
typeof value.isAllSelected === "boolean", [value]);
|
|
29
|
+
const isCheckboxMode = (0, react_1.useMemo)(() => checkboxLabel && typeof value === "object" && "isChecked" in value && typeof value.isChecked === "boolean" || false, [checkboxLabel, value]);
|
|
30
|
+
const [initialInChecked] = (0, react_1.useState)(isCheckboxMode ? value.isChecked : undefined);
|
|
31
|
+
const [state, dispatchState] = (0, react_1.useReducer)(stateReducer_1.stateReducer, (0, stateReducer_1.getInitialState)(isFullSelectionMode, dataItems || [], isFullSelectionMode || isCheckboxMode ? value.selected : value, defaultValue ? (isFullSelectionMode || isCheckboxMode ? defaultValue.selected : defaultValue) : undefined, isFullSelectionMode ? value.isAllSelected : undefined, defaultValue ? (isFullSelectionMode ? defaultValue.isAllSelected : undefined) : undefined, isCheckboxMode ? value.isChecked : undefined, isCheckboxMode && defaultValue ? defaultValue.isChecked : undefined));
|
|
26
32
|
const isMobile = (0, useMobile_1.useMobile)();
|
|
27
33
|
const abortToken = (0, react_1.useRef)(new AbortController());
|
|
28
34
|
const triggerRef = (0, react_1.useRef)(null);
|
|
29
35
|
const comboboxRef = (0, react_1.useRef)(null);
|
|
30
36
|
const inputRef = (0, react_1.useRef)(null);
|
|
31
37
|
const contentRef = (0, react_1.useRef)(null);
|
|
32
|
-
const prevSelectedIds = (0, react_1.useRef)({ selected: [], isAllSelected: undefined });
|
|
33
|
-
const prevSelection = (0, react_1.useRef)({ selected: [], isAllSelected: undefined });
|
|
38
|
+
const prevSelectedIds = (0, react_1.useRef)({ selected: [], isAllSelected: undefined, isChecked: initialInChecked });
|
|
39
|
+
const prevSelection = (0, react_1.useRef)({ selected: [], isAllSelected: undefined, isChecked: initialInChecked });
|
|
34
40
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
35
41
|
const getNamedItemsHasBeenCalled = (0, react_1.useRef)(false);
|
|
36
42
|
const selectedItemsLoader = (0, react_1.useRef)(undefined);
|
|
37
43
|
const previousMapDataItems = (0, react_1.useRef)(!getData && (dataItems === null || dataItems === void 0 ? void 0 : dataItems.length) ? dataItems : []);
|
|
44
|
+
const prevIsLoading = (0, react_1.useRef)(isLoading);
|
|
45
|
+
const prevIsChecked = (0, react_1.useRef)(isCheckboxMode ? value.isChecked : undefined);
|
|
38
46
|
const currentAllSelected = (0, react_1.useMemo)(() => (state.isNestedList || !multiselect || !isFullSelectionMode)
|
|
39
47
|
? undefined : state.isAllSelected, [state.isNestedList, state.isAllSelected, multiselect, isFullSelectionMode]);
|
|
48
|
+
const currentIsChecked = (0, react_1.useMemo)(() => isCheckboxMode ?
|
|
49
|
+
value.isChecked : undefined, [isCheckboxMode, value]);
|
|
40
50
|
(0, react_1.useEffect)(() => {
|
|
41
51
|
const timeoutId = setTimeout(() => {
|
|
42
52
|
if (Object.keys(state.groupsMap).length === 0 && getData) {
|
|
43
53
|
const currentAbort = abortToken.current;
|
|
44
|
-
getData(currentAbort.signal, undefined).then((data) => {
|
|
54
|
+
(initialInChecked !== undefined ? getData(currentAbort.signal, undefined, initialInChecked) : getData(currentAbort.signal, undefined)).then((data) => {
|
|
45
55
|
data.length && dispatchState({ type: stateActionType_1.StateActionType.CreateMap, payload: data });
|
|
46
56
|
previousMapDataItems.current = [...data];
|
|
47
57
|
}).catch(errorHandler);
|
|
48
58
|
}
|
|
49
59
|
});
|
|
50
60
|
return () => clearTimeout(timeoutId);
|
|
51
|
-
}, [getData, errorHandler, state.groupsMap]);
|
|
61
|
+
}, [getData, errorHandler, state.groupsMap, initialInChecked]);
|
|
52
62
|
(0, react_1.useEffect)(() => {
|
|
53
63
|
const timeoutId = setTimeout(() => {
|
|
54
64
|
if (!getData && dataItems && dataItems.length && !(0, dropdownHelper_1.compareObjectsArrays)(dataItems, previousMapDataItems.current)) {
|
|
@@ -59,16 +69,28 @@ const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems,
|
|
|
59
69
|
return () => clearTimeout(timeoutId);
|
|
60
70
|
}, [dataItems, getData, state.groupsMap]);
|
|
61
71
|
(0, react_1.useEffect)(() => {
|
|
62
|
-
|
|
72
|
+
if (prevIsLoading.current !== isLoading && Object.keys(state.groupsMap).length !== 0) {
|
|
73
|
+
isLoading === false && dispatchState({ type: stateActionType_1.StateActionType.ShowList, payload: undefined });
|
|
74
|
+
prevIsLoading.current = isLoading;
|
|
75
|
+
}
|
|
76
|
+
}, [isLoading, dataItems, state.groupsMap]);
|
|
77
|
+
(0, react_1.useEffect)(() => {
|
|
78
|
+
const defaultSelectedValue = defaultValue ? (isFullSelectionMode || isCheckboxMode ? defaultValue.selected : defaultValue) : [];
|
|
63
79
|
const defaultAllSelectedValue = defaultValue ? (isFullSelectionMode ? defaultValue.isAllSelected : undefined)
|
|
64
80
|
: (isFullSelectionMode ? false : undefined);
|
|
81
|
+
const defaultIsCheckedValue = defaultValue ?
|
|
82
|
+
(isCheckboxMode ? defaultValue.isChecked || false : undefined)
|
|
83
|
+
: (isCheckboxMode ? false : undefined);
|
|
84
|
+
if (defaultIsCheckedValue !== state.defaultValueIsChecked) {
|
|
85
|
+
defaultIsCheckedValue !== undefined && dispatchState({ type: stateActionType_1.StateActionType.SetDefaultIsChecked, payload: defaultIsCheckedValue });
|
|
86
|
+
}
|
|
65
87
|
if ((0, dropdownHelper_1.compareStringsArrays)(defaultSelectedValue, state.defaultValue) && defaultAllSelectedValue === state.defaultValueIsAllSelected) {
|
|
66
88
|
return;
|
|
67
89
|
}
|
|
68
90
|
dispatchState({ type: stateActionType_1.StateActionType.SetDefaultValue, payload: defaultSelectedValue });
|
|
69
91
|
isFullSelectionMode && defaultAllSelectedValue !== state.defaultValueIsAllSelected
|
|
70
92
|
&& dispatchState({ type: stateActionType_1.StateActionType.SetDefaultAllSelected, payload: defaultAllSelectedValue });
|
|
71
|
-
}, [defaultValue, isFullSelectionMode, state.defaultValue, state.defaultValueIsAllSelected]);
|
|
93
|
+
}, [defaultValue, isCheckboxMode, isFullSelectionMode, state.defaultValue, state.defaultValueIsAllSelected, state.defaultValueIsChecked]);
|
|
72
94
|
const loadSelectedItems = (0, react_1.useCallback)((ids) => {
|
|
73
95
|
if (!getSelectedItem || !ids.size) {
|
|
74
96
|
return;
|
|
@@ -175,7 +197,7 @@ const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems,
|
|
|
175
197
|
handleClose();
|
|
176
198
|
}, [handleClose]);
|
|
177
199
|
const handleApplyClick = (0, react_1.useCallback)(() => {
|
|
178
|
-
dispatchState({ type: stateActionType_1.StateActionType.SetGlobalState, payload: { selected: state.selectedIds, isAllSelected: state.isAllSelected } });
|
|
200
|
+
dispatchState({ type: stateActionType_1.StateActionType.SetGlobalState, payload: Object.assign({ selected: state.selectedIds, isAllSelected: state.isAllSelected }, (isCheckboxMode ? { isChecked: state.isChecked } : {})) });
|
|
179
201
|
dispatchState({ type: stateActionType_1.StateActionType.SetIsOpenCombo, payload: false });
|
|
180
202
|
dispatchState({ type: stateActionType_1.StateActionType.SetCurrentId, payload: undefined });
|
|
181
203
|
abortToken.current.abort();
|
|
@@ -184,12 +206,18 @@ const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems,
|
|
|
184
206
|
dispatchState({ type: stateActionType_1.StateActionType.SetDataProblem, payload: (0, dropdownHelper_1.checkIsDataProblem)(state.selectedIds, state.groupsMap) });
|
|
185
207
|
const preparedItems = (0, dropdownHelper_1.prepareSelectedIdsToItems)(state.selectedIds, state.groupsMap, state.groupsMapSelected);
|
|
186
208
|
if (isFullSelectionMode) {
|
|
187
|
-
|
|
209
|
+
const newValue = (isCheckboxMode
|
|
210
|
+
? { selected: preparedItems, isAllSelected: state.isAllSelected || false, isChecked: state.isChecked }
|
|
211
|
+
: { selected: preparedItems, isAllSelected: state.isAllSelected || false });
|
|
212
|
+
onChange(newValue);
|
|
188
213
|
}
|
|
189
214
|
else {
|
|
190
|
-
|
|
215
|
+
const newValue = isCheckboxMode
|
|
216
|
+
? { selected: preparedItems, isChecked: state.isChecked }
|
|
217
|
+
: preparedItems;
|
|
218
|
+
onChange(newValue);
|
|
191
219
|
}
|
|
192
|
-
}, [state.selectedIds, state.groupsMap, state.groupsMapSelected, state.
|
|
220
|
+
}, [state.selectedIds, state.isAllSelected, state.groupsMap, state.groupsMapSelected, state.isChecked, handleClose, isFullSelectionMode, isCheckboxMode, onChange]);
|
|
193
221
|
const customGetData = (0, react_1.useCallback)((str) => (str && dataItems
|
|
194
222
|
? Promise.resolve(dataItems.filter(el => { var _a; return (((_a = el.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) || "").indexOf(str.trim().toLocaleLowerCase()) > -1; }))
|
|
195
223
|
: Promise.resolve(dataItems || [])), [dataItems]);
|
|
@@ -206,73 +234,109 @@ const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems,
|
|
|
206
234
|
errorHandler(e);
|
|
207
235
|
dispatchState({ type: stateActionType_1.StateActionType.NothingToShow, payload: undefined });
|
|
208
236
|
}, [errorHandler]);
|
|
209
|
-
const debouncedGetData = (0, useDebounce_1.useDebounce)((signal, searchValue) => getData ? getData(signal, searchValue).then((data) => handleData(data, searchValue)).catch(handleError)
|
|
237
|
+
const debouncedGetData = (0, useDebounce_1.useDebounce)((signal, searchValue, isChecked) => getData ? (isCheckboxMode ? getData(signal, searchValue, isChecked) : getData(signal, searchValue)).then((data) => handleData(data, searchValue)).catch(handleError)
|
|
210
238
|
: customGetData(searchValue).then((data) => handleData(data, searchValue)).catch(handleError), 200);
|
|
211
|
-
const controlData = (0, react_1.useCallback)((signal, searchValue) => {
|
|
239
|
+
const controlData = (0, react_1.useCallback)((signal, searchValue, isChecked) => {
|
|
212
240
|
dispatchState({ type: stateActionType_1.StateActionType.ShowWaiting, payload: undefined });
|
|
213
|
-
debouncedGetData(signal, searchValue);
|
|
241
|
+
debouncedGetData(signal, searchValue, isChecked);
|
|
214
242
|
}, [debouncedGetData]);
|
|
215
243
|
(0, react_1.useEffect)(() => {
|
|
244
|
+
// when change inside
|
|
216
245
|
if (hasApplyButton) {
|
|
217
246
|
return;
|
|
218
247
|
}
|
|
219
|
-
|
|
248
|
+
const prevIsCheckedValue = isCheckboxMode ?
|
|
249
|
+
prevSelectedIds.current.isChecked : undefined;
|
|
250
|
+
if ((0, dropdownHelper_1.compareStringsArrays)(prevSelectedIds.current.selected, state.selectedIds)
|
|
251
|
+
&& prevSelectedIds.current.isAllSelected === state.isAllSelected
|
|
252
|
+
&& prevIsCheckedValue === state.isChecked) {
|
|
220
253
|
return;
|
|
221
254
|
}
|
|
222
|
-
prevSelectedIds.current = { selected: state.selectedIds, isAllSelected: state.isAllSelected };
|
|
223
|
-
if ((0, dropdownHelper_1.compareStringsArrays)(state.selectedIds, isFullSelectionMode ? value.selected : value)
|
|
224
|
-
&& state.isAllSelected === (isFullSelectionMode ? value.isAllSelected : undefined)
|
|
255
|
+
prevSelectedIds.current = { selected: state.selectedIds, isAllSelected: state.isAllSelected, isChecked: state.isChecked };
|
|
256
|
+
if ((0, dropdownHelper_1.compareStringsArrays)(state.selectedIds, isFullSelectionMode || isCheckboxMode ? value.selected : value)
|
|
257
|
+
&& state.isAllSelected === (isFullSelectionMode ? value.isAllSelected : undefined)
|
|
258
|
+
&& state.isChecked === (isCheckboxMode ? value.isChecked : undefined)) {
|
|
225
259
|
return;
|
|
226
260
|
}
|
|
227
261
|
dispatchState({ type: stateActionType_1.StateActionType.SetDataProblem, payload: (0, dropdownHelper_1.checkIsDataProblem)(state.selectedIds, state.groupsMap) });
|
|
228
262
|
const preparedItems = (0, dropdownHelper_1.prepareSelectedIdsToItems)(state.selectedIds, state.groupsMap, state.groupsMapSelected);
|
|
229
263
|
if (isFullSelectionMode) {
|
|
230
|
-
|
|
264
|
+
const newValue = (isCheckboxMode
|
|
265
|
+
? { selected: preparedItems, isAllSelected: state.isAllSelected || false, isChecked: state.isChecked }
|
|
266
|
+
: { selected: preparedItems, isAllSelected: state.isAllSelected || false });
|
|
267
|
+
onChange(newValue);
|
|
231
268
|
}
|
|
232
269
|
else {
|
|
233
|
-
|
|
270
|
+
const newValue = isCheckboxMode
|
|
271
|
+
? { selected: preparedItems, isChecked: state.isChecked }
|
|
272
|
+
: preparedItems;
|
|
273
|
+
onChange(newValue);
|
|
234
274
|
}
|
|
235
|
-
}, [onChange, value, state.selectedIds, state.groupsMapSelected, state.groupsMap, hasApplyButton, state.isAllSelected, isFullSelectionMode]);
|
|
275
|
+
}, [onChange, value, state.selectedIds, state.groupsMapSelected, state.groupsMap, hasApplyButton, state.isAllSelected, isFullSelectionMode, state.isChecked, isCheckboxMode]);
|
|
236
276
|
(0, react_1.useEffect)(() => {
|
|
237
|
-
|
|
277
|
+
// when change outside
|
|
278
|
+
const selectedValue = isFullSelectionMode || isCheckboxMode ? value.selected : value;
|
|
238
279
|
const isAllSelectedValue = isFullSelectionMode ? value.isAllSelected : undefined;
|
|
239
|
-
|
|
280
|
+
const isCheckedValue = isCheckboxMode ? value.isChecked : undefined;
|
|
281
|
+
if ((0, dropdownHelper_1.compareStringsArrays)(prevSelection.current.selected, selectedValue) && isAllSelectedValue === prevSelection.current.isAllSelected && prevSelection.current.isChecked === isCheckedValue) {
|
|
240
282
|
return;
|
|
241
283
|
}
|
|
242
|
-
prevSelection.current = { selected: selectedValue, isAllSelected: isAllSelectedValue };
|
|
284
|
+
prevSelection.current = { selected: selectedValue, isAllSelected: isAllSelectedValue, isChecked: isCheckedValue };
|
|
243
285
|
if ((0, dropdownHelper_1.compareStringsArrays)(hasApplyButton ? state.globalSelectedIds : state.selectedIds, selectedValue)
|
|
244
|
-
&& isAllSelectedValue === (hasApplyButton ? state.globalIsAllSelected : state.isAllSelected)
|
|
286
|
+
&& isAllSelectedValue === (hasApplyButton ? state.globalIsAllSelected : state.isAllSelected)
|
|
287
|
+
&& isCheckedValue === (hasApplyButton ? state.globalIsChecked : state.isChecked)) {
|
|
245
288
|
return;
|
|
246
289
|
}
|
|
290
|
+
// prevSelectedIds.current = { selected: selectedValue, isAllSelected: isAllSelectedValue, isChecked: isCheckedValue };
|
|
247
291
|
hasApplyButton && dispatchState({ type: stateActionType_1.StateActionType.SetGlobalState,
|
|
248
|
-
payload: { selected: selectedValue, isAllSelected: isAllSelectedValue } });
|
|
292
|
+
payload: { selected: selectedValue, isAllSelected: isAllSelectedValue, isChecked: isCheckedValue } });
|
|
249
293
|
dispatchState({ type: stateActionType_1.StateActionType.SetState,
|
|
250
294
|
payload: { selected: selectedValue, isAllSelected: isAllSelectedValue } });
|
|
251
|
-
|
|
295
|
+
isCheckboxMode && isCheckedValue !== undefined && dispatchState({ type: stateActionType_1.StateActionType.SetIsChecked, payload: isCheckedValue });
|
|
296
|
+
}, [value, state.selectedIds, state.globalSelectedIds, hasApplyButton, isFullSelectionMode, state.isAllSelected, state.globalIsAllSelected, isCheckboxMode,
|
|
297
|
+
state.globalIsChecked, state.isChecked]);
|
|
298
|
+
(0, react_1.useEffect)(() => {
|
|
299
|
+
if (!isCheckboxMode || prevIsChecked.current === undefined) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (state.isChecked === prevIsChecked.current) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
prevIsChecked.current = state.isChecked;
|
|
306
|
+
const currentAbort = abortToken.current;
|
|
307
|
+
controlData(currentAbort.signal, state.inputValue, state.isChecked);
|
|
308
|
+
}, [controlData, state.inputValue, state.isChecked, isCheckboxMode]);
|
|
252
309
|
(0, useEscape_1.useEscape)(triggerRef, handleEscape, state.isOpenCombo);
|
|
253
310
|
const onSearchChange = (0, react_1.useCallback)((event) => {
|
|
254
311
|
const newValue = event ? event.currentTarget.value : "";
|
|
255
312
|
dispatchState({ type: stateActionType_1.StateActionType.SetInputValue, payload: newValue });
|
|
256
313
|
const currentAbort = abortToken.current;
|
|
257
|
-
controlData(currentAbort.signal, newValue);
|
|
258
|
-
}, [controlData]);
|
|
314
|
+
controlData(currentAbort.signal, newValue, state.isChecked);
|
|
315
|
+
}, [controlData, state.isChecked]);
|
|
259
316
|
const onInputChange = (0, react_1.useCallback)((newValue) => {
|
|
260
317
|
dispatchState({ type: stateActionType_1.StateActionType.SetInputValue, payload: newValue || "" });
|
|
261
318
|
const currentAbort = abortToken.current;
|
|
262
|
-
controlData(currentAbort.signal, newValue);
|
|
263
|
-
}, [controlData]);
|
|
319
|
+
controlData(currentAbort.signal, newValue, state.isChecked);
|
|
320
|
+
}, [controlData, state.isChecked]);
|
|
264
321
|
const containerClassName = (0, classNames_1.classNames)([
|
|
265
322
|
"zen-dropdown",
|
|
266
323
|
"zen-dropdown__container",
|
|
267
324
|
className || ""
|
|
268
325
|
]);
|
|
326
|
+
const handleCheckboxChange = (0, react_1.useCallback)((e) => {
|
|
327
|
+
const isChecked = e.target.checked;
|
|
328
|
+
dispatchState({ type: stateActionType_1.StateActionType.SetIsChecked, payload: isChecked });
|
|
329
|
+
prevIsChecked.current = isChecked;
|
|
330
|
+
const currentAbort = abortToken.current;
|
|
331
|
+
controlData(currentAbort.signal, state.inputValue, isChecked);
|
|
332
|
+
}, [controlData, state.inputValue]);
|
|
269
333
|
const handleTriggerClick = (0, react_1.useCallback)((newVal) => {
|
|
270
334
|
const currentAbort = abortToken.current;
|
|
271
335
|
dispatchState({ type: stateActionType_1.StateActionType.SetCurrentId, payload: undefined });
|
|
272
336
|
dispatchState({ type: stateActionType_1.StateActionType.SetIsOpenCombo, payload: newVal });
|
|
273
|
-
newVal && controlData(currentAbort.signal, state.inputValue);
|
|
337
|
+
newVal && controlData(currentAbort.signal, state.inputValue, state.isChecked);
|
|
274
338
|
!newVal && dispatchState({ type: stateActionType_1.StateActionType.SetInputValue, payload: "" });
|
|
275
|
-
}, [controlData, state.inputValue]);
|
|
339
|
+
}, [controlData, state.inputValue, state.isChecked]);
|
|
276
340
|
const handleReadyForFocus = (0, react_1.useCallback)((isCurrentOpen) => {
|
|
277
341
|
var _a;
|
|
278
342
|
if (!state.showList) {
|
|
@@ -305,15 +369,16 @@ const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems,
|
|
|
305
369
|
}
|
|
306
370
|
}, [state.isOpenCombo, state.currentId, state.showList, searchField]);
|
|
307
371
|
(0, react_1.useEffect)(() => {
|
|
308
|
-
|
|
309
|
-
|
|
372
|
+
const shouldExit = !getNamedItems ||
|
|
373
|
+
(Object.keys(state.groupsMap).length === 0 && Object.keys(state.groupsMapSelected).length === 0) ||
|
|
374
|
+
getNamedItemsHasBeenCalled.current ||
|
|
375
|
+
state.groupsMapSelected.size === 0;
|
|
376
|
+
if (shouldExit) {
|
|
377
|
+
return;
|
|
310
378
|
}
|
|
311
379
|
getNamedItemsHasBeenCalled.current = true;
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}, 200);
|
|
315
|
-
return () => clearTimeout(timeoutId);
|
|
316
|
-
}, [getNamedItems, state.groupsMap, state.groupsMapSelected]);
|
|
380
|
+
getNamedItems((items) => (0, dropdownHelper_1.prepareSelectedIdsToItems)(items, state.groupsMap, state.groupsMapSelected));
|
|
381
|
+
}, [getNamedItems, state.groupsMap, state.groupsMapSelected, state.namelessIds]);
|
|
317
382
|
(0, react_1.useEffect)(() => {
|
|
318
383
|
if (state.hasDataProblem && multiselect && state.isNestedList) {
|
|
319
384
|
// eslint-disable-next-line max-len
|
|
@@ -332,13 +397,15 @@ const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems,
|
|
|
332
397
|
return true;
|
|
333
398
|
}
|
|
334
399
|
const isStringsTheSame = (0, dropdownHelper_1.compareStringsArrays)(state.selectedIds, state.defaultValue);
|
|
335
|
-
|
|
400
|
+
const isCheckedEqualDefault = currentIsChecked !== undefined ? currentIsChecked === state.defaultValueIsChecked : true;
|
|
401
|
+
if (currentAllSelected !== undefined && state.defaultValueIsAllSelected !== undefined && state.defaultValueIsAllSelected && isCheckedEqualDefault) {
|
|
336
402
|
return currentAllSelected === state.defaultValueIsAllSelected;
|
|
337
403
|
}
|
|
338
|
-
return currentAllSelected !== undefined ? state.defaultValueIsAllSelected === currentAllSelected && isStringsTheSame : isStringsTheSame;
|
|
339
|
-
}, [currentAllSelected, forceSelection, multiselect, state.defaultValue, state.defaultValueIsAllSelected, state.selectedIds]);
|
|
404
|
+
return currentAllSelected !== undefined ? state.defaultValueIsAllSelected === currentAllSelected && isStringsTheSame && isCheckedEqualDefault : isStringsTheSame && isCheckedEqualDefault;
|
|
405
|
+
}, [currentAllSelected, currentIsChecked, forceSelection, multiselect, state.defaultValue, state.defaultValueIsAllSelected, state.defaultValueIsChecked, state.selectedIds]);
|
|
340
406
|
const memoizedIsApplyButtonDisabled = (0, react_1.useMemo)(() => (0, dropdownHelper_1.compareStringsArrays)(state.globalSelectedIds, state.selectedIds)
|
|
341
|
-
&& (isFullSelectionMode ? state.globalIsAllSelected === state.isAllSelected : true)
|
|
407
|
+
&& (isFullSelectionMode ? state.globalIsAllSelected === state.isAllSelected : true)
|
|
408
|
+
&& (isCheckboxMode ? state.globalIsChecked === state.isChecked : true), [isCheckboxMode, isFullSelectionMode, state.globalIsAllSelected, state.globalIsChecked, state.globalSelectedIds, state.isAllSelected, state.isChecked, state.selectedIds]);
|
|
342
409
|
const countSelected = (0, react_1.useMemo)(() => {
|
|
343
410
|
var _a, _b;
|
|
344
411
|
if (hasApplyButton && state.globalIsAllSelected || !hasApplyButton && state.isAllSelected) {
|
|
@@ -363,7 +430,7 @@ const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems,
|
|
|
363
430
|
}
|
|
364
431
|
if (state.showEmptyList) {
|
|
365
432
|
const isClearButtonDisabled = (0, dropdownHelper_1.compareStringsArrays)(state.selectedIds, state.defaultValue);
|
|
366
|
-
return (0, jsx_runtime_1.jsx)(dropdownList_1.EmptyList, { width: currentWidth, onClearClick: handleClearClick, onCancelClick: handleCancelClick, onApplyClick: handleApplyClick, hasApplyButton: hasApplyButton, isApplyDisabled: (0, dropdownHelper_1.compareStringsArrays)(state.globalSelectedIds, state.selectedIds), isClearButtonDisabled: isClearButtonDisabled, isWithFooter: Object.keys(state.groupsMap).length === 0 && ((!hasApplyButton && !isClearButtonDisabled) || hasApplyButton || false) });
|
|
433
|
+
return (0, jsx_runtime_1.jsx)(dropdownList_1.EmptyList, { width: currentWidth, onClearClick: handleClearClick, onCancelClick: handleCancelClick, onApplyClick: handleApplyClick, hasApplyButton: hasApplyButton, isApplyDisabled: (0, dropdownHelper_1.compareStringsArrays)(state.globalSelectedIds, state.selectedIds), isClearButtonDisabled: isClearButtonDisabled, isWithFooter: memoizedWithFooter && Object.keys(state.groupsMap).length === 0 && ((!hasApplyButton && !isClearButtonDisabled) || hasApplyButton || false) });
|
|
367
434
|
}
|
|
368
435
|
if (state.showList) {
|
|
369
436
|
const isSearchMode = state.inputValue && !state.currentId;
|
|
@@ -379,18 +446,18 @@ const Dropdown = ({ className, classNamePopup, getData, errorHandler, dataItems,
|
|
|
379
446
|
|| isSearchMode !== "" && state.isNestedList
|
|
380
447
|
&& (0, dropdownHelper_1.isAllItemsHasOneParent)(state.listData.filter(el => el.id !== groupsHelper_1.ENTIRE_ORGANIZATION_GROUP_ID),
|
|
381
448
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
382
|
-
(((_c = state.groupsMap[groupsHelper_1.ENTIRE_ORGANIZATION_GROUP_ID]) === null || _c === void 0 ? void 0 : _c.children) || []).map(el => el.id)), isClearButtonDisabled: memoizedIsClearButtonDisabled, isWithFooter: memoizedWithFooter && !isMobile, isMobile: isMobile });
|
|
449
|
+
(((_c = state.groupsMap[groupsHelper_1.ENTIRE_ORGANIZATION_GROUP_ID]) === null || _c === void 0 ? void 0 : _c.children) || []).map(el => el.id)), isClearButtonDisabled: memoizedIsClearButtonDisabled, isWithFooter: memoizedWithFooter && !isMobile, isMobile: isMobile, handleCheckboxChange: isCheckboxMode && !isMobile ? handleCheckboxChange : undefined, checkboxLabel: checkboxLabel, isChecked: state.isChecked });
|
|
383
450
|
}
|
|
384
451
|
return null;
|
|
385
|
-
}, [state, isLoading,
|
|
386
|
-
handleSelectAllInSearch, handleSelectAllClick, handleSelect, handleChangeCurrentId, handleSingleSelection, isMobile, filterName, forceSelection,
|
|
387
|
-
memoizedIsApplyButtonDisabled, memoizedIsClearButtonDisabled, memoizedWithFooter,
|
|
452
|
+
}, [state, isLoading, handleClearClick, handleCancelClick, handleApplyClick, hasApplyButton, translate, sortFn, listLimit, multiselect, currentAllSelected,
|
|
453
|
+
handleBackButtonClick, handleSelectAllInSearch, handleSelectAllClick, handleSelect, handleChangeCurrentId, handleSingleSelection, isMobile, filterName, forceSelection,
|
|
454
|
+
width, selectAllButton, memoizedIsApplyButtonDisabled, memoizedIsClearButtonDisabled, memoizedWithFooter, checkboxLabel, isCheckboxMode, handleCheckboxChange]);
|
|
388
455
|
const currentStringFromSelected = isFullSelectionMode && hasApplyButton && state.globalIsAllSelected ||
|
|
389
456
|
isFullSelectionMode && !hasApplyButton && state.isAllSelected ? (0, dropdownHelper_1.getStringFromAllSelected)(state.groupsMap, translate)
|
|
390
457
|
: (0, dropdownHelper_1.getStringFromSelected)(hasApplyButton ? state.globalSelectedIds : state.selectedIds, state.groupsMapSelected, translate);
|
|
391
458
|
const memoizedCurrentSelection = (0, react_1.useMemo)(() => showSelection && !state.inputValue ? currentStringFromSelected : "", [showSelection, state.inputValue, currentStringFromSelected]);
|
|
392
459
|
const parentTriggerWidth = ((_a = comboboxRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) || 420;
|
|
393
|
-
return (0, jsx_runtime_1.jsxs)("div", { className: containerClassName, ref: comboboxRef, children: [(0, jsx_runtime_1.jsx)(dropdownTrigger_1.DropdownTrigger, { className: (0, classNames_1.classNames)([!width && !fullWidthTriggerButton && parentTriggerWidth < 420 && !searchField ? "zen-dropdown__trigger-button--width-parent" : ""]), currentSelection: memoizedCurrentSelection, isActive: state.isOpenCombo, id: inputId, disabled: disabled, count: showCounterPill ? countSelected : 0, fullWidth: fullWidthTriggerButton, inputValue: state.inputValue, placeholder: placeholder || translate("Filter by group"), searchField: searchField && !isMobile ? searchField : false, onSearchChange: onSearchChange, handleClick: handleTriggerClick, width: width && width > 420 ? 420 : width, title: title, triggerAriaLabel: triggerAriaLabel, triggerRef: triggerRef, inputRef: inputRef, buttonType: buttonType, error: error }), (0, jsx_runtime_1.jsx)(dropdownPopup_1.DropdownPopup, { alignment: alignment, triggerRef: triggerRef, classNamePopup: classNamePopup, isMobile: isMobile, dialogAriaLabel: dialogAriaLabel, disabled: disabled, filterName: filterName, hasApplyButton: hasApplyButton, inputId: inputId, isClearButtonDisabled: memoizedIsClearButtonDisabled, isApplyButtonDisabled: memoizedIsApplyButtonDisabled, isWithFooter: memoizedWithFooter, isOpenCombo: state.isOpenCombo, searchField: searchField, placeholder: placeholder, inputValue: state.inputValue, handleApplyClick: handleApplyClick, handleClearClick: multiselect ? handleClearClick : handleSingleSelection.bind(this, true), handleTriggerClick: handleTriggerClick, onInputChange: onInputChange, inputRef: inputRef, contentRef: contentRef, onReadyForFocus: handleReadyForFocus, children: getPopupContent })] });
|
|
460
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: containerClassName, ref: comboboxRef, children: [(0, jsx_runtime_1.jsx)(dropdownTrigger_1.DropdownTrigger, { className: (0, classNames_1.classNames)([!width && !fullWidthTriggerButton && parentTriggerWidth < 420 && !searchField ? "zen-dropdown__trigger-button--width-parent" : ""]), currentSelection: memoizedCurrentSelection, isActive: state.isOpenCombo, id: inputId, disabled: disabled, count: showCounterPill ? countSelected : 0, fullWidth: fullWidthTriggerButton, inputValue: state.inputValue, placeholder: placeholder || translate("Filter by group"), searchField: searchField && !isMobile ? searchField : false, onSearchChange: onSearchChange, handleClick: handleTriggerClick, width: width && width > 420 ? 420 : width, title: title, triggerAriaLabel: triggerAriaLabel, triggerRef: triggerRef, inputRef: inputRef, buttonType: buttonType, error: error }), (0, jsx_runtime_1.jsx)(dropdownPopup_1.DropdownPopup, { alignment: alignment, triggerRef: triggerRef, classNamePopup: classNamePopup, isMobile: isMobile, dialogAriaLabel: dialogAriaLabel, disabled: disabled, filterName: filterName, hasApplyButton: hasApplyButton, inputId: inputId, isClearButtonDisabled: memoizedIsClearButtonDisabled, isApplyButtonDisabled: memoizedIsApplyButtonDisabled, isWithFooter: memoizedWithFooter, isOpenCombo: state.isOpenCombo, searchField: searchField, placeholder: placeholder, inputValue: state.inputValue, handleApplyClick: handleApplyClick, handleClearClick: multiselect ? handleClearClick : handleSingleSelection.bind(this, true), handleTriggerClick: handleTriggerClick, onInputChange: onInputChange, inputRef: inputRef, contentRef: contentRef, onReadyForFocus: handleReadyForFocus, handleCheckboxChange: isCheckboxMode && isMobile ? handleCheckboxChange : undefined, checkboxLabel: checkboxLabel, isChecked: state.isChecked, children: getPopupContent })] });
|
|
394
461
|
};
|
|
395
462
|
exports.Dropdown = Dropdown;
|
|
396
463
|
exports.TRANSLATIONS = [
|
|
@@ -34,6 +34,9 @@ export interface IDropdownList extends IZenComponentProps {
|
|
|
34
34
|
isClearButtonDisabled?: boolean;
|
|
35
35
|
forceSelection?: boolean;
|
|
36
36
|
isMobile: boolean;
|
|
37
|
+
handleCheckboxChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
38
|
+
checkboxLabel?: string;
|
|
39
|
+
isChecked?: boolean;
|
|
37
40
|
}
|
|
38
41
|
interface IDropdownEmptyList extends Pick<IDropdownList, "translate" | "className" | "width" | "onClearClick" | "onApplyClick" | "onCancelClick" | "hasApplyButton" | "isApplyDisabled" | "isClearButtonDisabled" | "isWithFooter"> {
|
|
39
42
|
}
|
|
@@ -37,13 +37,14 @@ const checkboxState_1 = require("../checkbox/checkboxState");
|
|
|
37
37
|
const useDrive_1 = require("../utils/theme/useDrive");
|
|
38
38
|
const useDriveClassName_1 = require("../utils/theme/useDriveClassName");
|
|
39
39
|
const useLanguage_1 = require("../utils/localization/useLanguage");
|
|
40
|
+
const checkbox_1 = require("../checkbox/checkbox");
|
|
40
41
|
const EmptyList = ({ className, width, onClearClick, onApplyClick, onCancelClick, hasApplyButton, isApplyDisabled, isClearButtonDisabled, isWithFooter }) => {
|
|
41
42
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
42
43
|
const styleWidth = width ? { style: { width: `${width}px` } } : {};
|
|
43
44
|
return (0, jsx_runtime_1.jsxs)("div", Object.assign({}, styleWidth, { className: (0, classNames_1.classNames)(["zen-dropdown-list__container", className || ""]), children: [(0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__container--empty", children: translate("No data") }), isWithFooter ? (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__footer", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onClearClick, disabled: isClearButtonDisabled, className: "zen-dropdown-list__clear-button", type: buttonType_1.ButtonType.Tertiary, title: translate("Clear"), children: translate("Clear") }), hasApplyButton && (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__button-group", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onCancelClick, className: "zen-dropdown-list__cancel-button", title: translate("Cancel"), children: translate("Cancel") }), (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onApplyClick, type: buttonType_1.ButtonType.Primary, disabled: isApplyDisabled, className: "zen-dropdown-list__apply-button", title: translate("Apply"), children: translate("Apply") })] })] }) : null] }));
|
|
44
45
|
};
|
|
45
46
|
exports.EmptyList = EmptyList;
|
|
46
|
-
const DropdownList = ({ onBackButtonClick, onSelectAllClick, onClearClick, onApplyClick, onCancelClick, onChange, onSelect, onSingleSelect, listData, isAllSelected, backButtonName, width, minWidth, isSelectAllButtonDisable, hasSelectAllButton, filterName, isMultiselect, hasApplyButton, isApplyDisabled, isClearButtonDisabled, activeValue, forceSelection, isWithFooter, isMobile }) => {
|
|
47
|
+
const DropdownList = ({ onBackButtonClick, onSelectAllClick, onClearClick, onApplyClick, onCancelClick, onChange, onSelect, onSingleSelect, listData, isAllSelected, backButtonName, width, minWidth, isSelectAllButtonDisable, hasSelectAllButton, filterName, isMultiselect, hasApplyButton, isApplyDisabled, isClearButtonDisabled, activeValue, forceSelection, isWithFooter, isMobile, handleCheckboxChange, checkboxLabel, isChecked }) => {
|
|
47
48
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
48
49
|
const isDrive = (0, useDrive_1.useDrive)();
|
|
49
50
|
const driveComponentClass = (0, useDriveClassName_1.useDriveClassName)("zen-dropdown-list");
|
|
@@ -86,9 +87,9 @@ const DropdownList = ({ onBackButtonClick, onSelectAllClick, onClearClick, onApp
|
|
|
86
87
|
});
|
|
87
88
|
return values;
|
|
88
89
|
};
|
|
89
|
-
return (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__elements", children: isMultiselect ? (0, jsx_runtime_1.jsx)(checkboxListWithAction_1.CheckboxListWithAction, { options: listData, label: "", onChange: handleChange, onClick: handleClick }) : (0, jsx_runtime_1.jsx)(selectList_1.SelectList, { onChange: handleSingleChange, onClick: handleClick, title: "", id: listId, multiselect: false, selectItemOnFocus: false, items: listData, forceSelection: forceSelection, value: createValue(listData, activeValue) }) });
|
|
90
|
-
}, [isMultiselect, listData, handleChange, handleClick, handleSingleChange, listId, forceSelection, activeValue]);
|
|
91
|
-
return (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classNames_1.classNames)(["zen-dropdown-list", driveComponentClass || ""]) }, styleWidth, { children: [filterName ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__label", children: filterName }) : null, backButtonName ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__item-wrapper", children: getActionButton(backButtonName, translate("Back"), iconBackArrow_1.IconBackArrow, false, onBackButtonClick, "large") }) : null, hasSelectAllButton ? getActionButton(selectButtonLabel, selectButtonLabel, iconCheckRadio_1.IconCheckRadio, isSelectAllButtonDisable, handleSelectAllClick, isDrive ? "huger" : "huge") : null, listDataComponent, isWithFooter ? (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__footer", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: isMultiselect ? onClearClick : handleClearClick, disabled: isClearButtonDisabled, className: "zen-dropdown-list__clear-button zen-ellipsis", type: buttonType_1.ButtonType.Tertiary, title: translate("Clear"), children: translate("Clear") }), hasApplyButton && (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__button-group", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onCancelClick, className: "zen-dropdown-list__cancel-button zen-ellipsis", title: translate("Cancel"), children: translate("Cancel") }), (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onApplyClick, type: buttonType_1.ButtonType.Primary, disabled: isApplyDisabled, className: "zen-dropdown-list__apply-button zen-ellipsis", title: translate("Apply"), children: translate("Apply") })] })] }) : null] }));
|
|
90
|
+
return (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__elements", children: isMultiselect ? (0, jsx_runtime_1.jsx)(checkboxListWithAction_1.CheckboxListWithAction, { options: listData, label: "", onChange: handleChange, onClick: handleClick }) : (0, jsx_runtime_1.jsx)(selectList_1.SelectList, { onChange: handleSingleChange, onClick: handleClick, title: translate("Select option"), id: listId, multiselect: false, selectItemOnFocus: false, items: listData, forceSelection: forceSelection, value: createValue(listData, activeValue) }) });
|
|
91
|
+
}, [isMultiselect, listData, handleChange, handleClick, handleSingleChange, translate, listId, forceSelection, activeValue]);
|
|
92
|
+
return (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classNames_1.classNames)(["zen-dropdown-list", driveComponentClass || ""]) }, styleWidth, { children: [filterName ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__label", children: filterName }) : null, handleCheckboxChange ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__checkbox-container", children: (0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { checked: isChecked, onChange: handleCheckboxChange, children: checkboxLabel }) }) : null, backButtonName ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-list__item-wrapper", children: getActionButton(backButtonName, translate("Back"), iconBackArrow_1.IconBackArrow, false, onBackButtonClick, "large") }) : null, hasSelectAllButton ? getActionButton(selectButtonLabel, selectButtonLabel, iconCheckRadio_1.IconCheckRadio, isSelectAllButtonDisable, handleSelectAllClick, isDrive ? "huger" : "huge") : null, listDataComponent, isWithFooter ? (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__footer", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: isMultiselect ? onClearClick : handleClearClick, disabled: isClearButtonDisabled, className: "zen-dropdown-list__clear-button zen-ellipsis", type: buttonType_1.ButtonType.Tertiary, title: translate("Clear"), children: translate("Clear") }), hasApplyButton && (0, jsx_runtime_1.jsxs)("div", { className: "zen-dropdown-list__button-group", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onCancelClick, className: "zen-dropdown-list__cancel-button zen-ellipsis", title: translate("Cancel"), children: translate("Cancel") }), (0, jsx_runtime_1.jsx)(button_1.Button, { onClick: onApplyClick, type: buttonType_1.ButtonType.Primary, disabled: isApplyDisabled, className: "zen-dropdown-list__apply-button zen-ellipsis", title: translate("Apply"), children: translate("Apply") })] })] }) : null] }));
|
|
92
93
|
};
|
|
93
94
|
exports.DropdownList = DropdownList;
|
|
94
95
|
exports.TRANSLATIONS = [
|
|
@@ -25,5 +25,8 @@ export interface IDropdownPopup extends IZenComponentProps {
|
|
|
25
25
|
inputRef: React.MutableRefObject<HTMLInputElement>;
|
|
26
26
|
contentRef: React.RefObject<HTMLDivElement>;
|
|
27
27
|
onReadyForFocus?: (isCurrentOpen: boolean) => void;
|
|
28
|
+
handleCheckboxChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
29
|
+
checkboxLabel?: string;
|
|
30
|
+
isChecked?: boolean;
|
|
28
31
|
}
|
|
29
32
|
export declare const DropdownPopup: React.FC<IDropdownPopup>;
|
|
@@ -11,13 +11,14 @@ const classNames_1 = require("../commonHelpers/classNames/classNames");
|
|
|
11
11
|
const searchInput_1 = require("../searchInput/searchInput");
|
|
12
12
|
const useLanguage_1 = require("../utils/localization/useLanguage");
|
|
13
13
|
const footerButtons_1 = require("../footerButtons/footerButtons");
|
|
14
|
-
const
|
|
14
|
+
const checkbox_1 = require("../checkbox/checkbox");
|
|
15
|
+
const DropdownPopup = ({ alignment, triggerRef, classNamePopup, isMobile, inputValue, dialogAriaLabel, disabled, filterName, handleApplyClick, handleClearClick, handleTriggerClick, onInputChange, hasApplyButton, inputId, isClearButtonDisabled, isWithFooter, placeholder, searchField, isApplyButtonDisabled, isOpenCombo, inputRef, contentRef, children, onReadyForFocus, handleCheckboxChange, checkboxLabel, isChecked }) => {
|
|
15
16
|
const { translate } = (0, useLanguage_1.useLanguage)();
|
|
16
17
|
const triggerId = (0, react_1.useId)();
|
|
17
18
|
const memoizedHandleHide = (0, react_1.useCallback)(() => {
|
|
18
19
|
handleTriggerClick(false);
|
|
19
20
|
}, [handleTriggerClick]);
|
|
20
|
-
const memoizedMobileContent = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [searchField ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-mobile-sheet__search-container", children: (0, jsx_runtime_1.jsx)(searchInput_1.SearchInput, { className: "zen-dropdown-mobile-sheet__search", onChange: onInputChange, value: inputValue || "", ref: inputRef, id: inputId || triggerId, disabled: disabled, placeholder: placeholder || translate("Filter by group") }) }) : null, (0, jsx_runtime_1.jsx)("div", { ref: contentRef, children: children })] }), [children, contentRef, disabled, inputId, inputRef, inputValue, onInputChange, placeholder, searchField, translate, triggerId]);
|
|
21
|
+
const memoizedMobileContent = (0, react_1.useMemo)(() => (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [searchField ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-mobile-sheet__search-container", children: (0, jsx_runtime_1.jsx)(searchInput_1.SearchInput, { className: "zen-dropdown-mobile-sheet__search", onChange: onInputChange, value: inputValue || "", ref: inputRef, id: inputId || triggerId, disabled: disabled, placeholder: placeholder || translate("Filter by group") }) }) : null, handleCheckboxChange ? (0, jsx_runtime_1.jsx)("div", { className: "zen-dropdown-mobile-sheet__checkbox-container", children: (0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { checked: isChecked, onChange: handleCheckboxChange, children: checkboxLabel }) }) : null, (0, jsx_runtime_1.jsx)("div", { ref: contentRef, children: children })] }), [checkboxLabel, children, contentRef, disabled, handleCheckboxChange, inputId, inputRef, inputValue, isChecked, onInputChange, placeholder, searchField, translate, triggerId]);
|
|
21
22
|
const memoizedMobileFooter = (0, react_1.useMemo)(() => {
|
|
22
23
|
if (!isWithFooter) {
|
|
23
24
|
return null;
|
|
@@ -15,6 +15,7 @@ interface IPayloadSingleSelectionAction {
|
|
|
15
15
|
interface IStateActionPayload {
|
|
16
16
|
selected: string[];
|
|
17
17
|
isAllSelected?: boolean;
|
|
18
|
+
isChecked?: boolean;
|
|
18
19
|
}
|
|
19
20
|
interface ISetStateAction {
|
|
20
21
|
type: StateActionType.SetState;
|
|
@@ -116,9 +117,17 @@ interface ISetPendingStateAction {
|
|
|
116
117
|
type: StateActionType.SetPendingState;
|
|
117
118
|
payload: boolean;
|
|
118
119
|
}
|
|
120
|
+
interface ISetDefaultIsCheckedAction {
|
|
121
|
+
type: StateActionType.SetDefaultIsChecked;
|
|
122
|
+
payload: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface ISetIsCheckedAction {
|
|
125
|
+
type: StateActionType.SetIsChecked;
|
|
126
|
+
payload: boolean;
|
|
127
|
+
}
|
|
119
128
|
interface IUpdateNamelessItemsAction {
|
|
120
129
|
type: StateActionType.UpdateNamelessItems;
|
|
121
130
|
payload: undefined;
|
|
122
131
|
}
|
|
123
|
-
export type TStateAction = ICreateMapAction | ISetStateAction | ISetGlobalStateAction | ISetListDataAction | ISetIsOpenComboAction | IShowAction | IShowWaitingAction | IShowEmptyListAction | IShowListAction | ISetInputValueAction | INothingToShowAction | ISetCurrentIdAction | IChangeSelectionAction | IChangeSingleSelectionAction | ISelectAllChildrenAction | IDeselectAllChildrenAction | IResetSelection | IResetStateToGlobal | ISetDataProblemAction | ISetDefaultValueAction | IUpdateSelectedItemsAction | ISetPendingStateAction | IUpdateNamelessItemsAction | IToggleValueForAllSelectedAction | IDeselectItemsFromAllSelectedAction | ISetDefaultAllSelectedAction;
|
|
132
|
+
export type TStateAction = ICreateMapAction | ISetStateAction | ISetGlobalStateAction | ISetListDataAction | ISetIsOpenComboAction | IShowAction | IShowWaitingAction | IShowEmptyListAction | IShowListAction | ISetInputValueAction | INothingToShowAction | ISetCurrentIdAction | IChangeSelectionAction | IChangeSingleSelectionAction | ISelectAllChildrenAction | IDeselectAllChildrenAction | IResetSelection | IResetStateToGlobal | ISetDataProblemAction | ISetDefaultValueAction | IUpdateSelectedItemsAction | ISetPendingStateAction | IUpdateNamelessItemsAction | IToggleValueForAllSelectedAction | IDeselectItemsFromAllSelectedAction | ISetDefaultAllSelectedAction | ISetIsCheckedAction | ISetIsCheckedAction | ISetDefaultIsCheckedAction;
|
|
124
133
|
export {};
|