@geotab/zenith 3.15.0-beta.0 → 3.15.0-beta.2

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 CHANGED
@@ -57,7 +57,6 @@ Zenith library provides components defined in Zenith Design System. It includes
57
57
  - Add native accessible loading-status support (`isLoading` prop with live-region) to `Waiting`
58
58
  - Add status dot and label support to `Tag` component
59
59
  - Add "trend, neutral" icon to icon library
60
- - Improve select-all behavior in search for `Dropdown`
61
60
  - Add new icons (`IconAce`, `IconBreak`, `IconChevronStepper` and more)
62
61
  - Add `ProgressIndicator` — new table-cell progress component
63
62
  - Fix `DropdownRaw` single-select mode not auto-closing after leaf node selection
@@ -40,6 +40,15 @@ function getInterpolatedValue(xScale, data, datasetIndex, xPixel) {
40
40
  if (x1 === x2) {
41
41
  return y1;
42
42
  }
43
+ // Sub-pixel tolerance: element.x (from Chart.js) and xScale.getPixelForValue()
44
+ // can disagree by a fraction of a pixel, causing the cursor to land just past a
45
+ // data point and interpolate with the next segment instead of returning the exact value.
46
+ if (Math.abs(x - x1) < 0.5) {
47
+ return y1;
48
+ }
49
+ if (Math.abs(x - x2) < 0.5) {
50
+ return y2;
51
+ }
43
52
  const interpolatedY = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
44
53
  return interpolatedY;
45
54
  }
@@ -55,32 +55,9 @@ const LinePlugin = (containerId, options, isDark) => ({
55
55
  const y = chart.verticalLine.y;
56
56
  const topY = chart.chartArea.top;
57
57
  const bottomY = chart.chartArea.bottom;
58
+ (0, drawLine_1.drawLine)(ctx, x, topY, bottomY);
58
59
  const datasets = chart.data.datasets;
59
60
  let lowestValueY = Infinity;
60
- const xScale = chart.scales.x;
61
- let snappedX = x;
62
- let closestDist = Infinity;
63
- datasets.forEach((dataset, dsIndex) => {
64
- if (!chart.isDatasetVisible(dsIndex)) {
65
- return;
66
- }
67
- if (chart.getDatasetMeta(dsIndex).type !== "line") {
68
- return;
69
- }
70
- const dataPoints = dataset.data;
71
- for (const point of dataPoints) {
72
- if (point.y === null) {
73
- continue;
74
- }
75
- const px = xScale.getPixelForValue(point.x);
76
- const dist = Math.abs(px - x);
77
- if (dist < closestDist) {
78
- closestDist = dist;
79
- snappedX = px;
80
- }
81
- }
82
- });
83
- (0, drawLine_1.drawLine)(ctx, snappedX, topY, bottomY);
84
61
  const items = datasets
85
62
  .map((dataset, dsIndex) => {
86
63
  if (!chart.isDatasetVisible(dsIndex)) {
@@ -89,7 +66,8 @@ const LinePlugin = (containerId, options, isDark) => ({
89
66
  if (chart.getDatasetMeta(dsIndex).type !== "line") {
90
67
  return undefined;
91
68
  }
92
- const value = (0, getInterpolatedValue_1.getInterpolatedValue)(xScale, chart.data, dsIndex, snappedX);
69
+ const xScale = chart.scales.x;
70
+ const value = (0, getInterpolatedValue_1.getInterpolatedValue)(xScale, chart.data, dsIndex, x);
93
71
  const yAxisID = dataset.yAxisID || "y";
94
72
  const yScale = chart.scales[yAxisID];
95
73
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -117,8 +95,8 @@ const LinePlugin = (containerId, options, isDark) => ({
117
95
  return;
118
96
  }
119
97
  const chartRect = chart.canvas.getBoundingClientRect();
120
- const top = chartRect.top + (lowestValueY !== Infinity ? lowestValueY : y);
121
- const left = chartRect.left + snappedX;
98
+ const top = chartRect.top + (lowestValueY || y);
99
+ const left = chartRect.left + x;
122
100
  if (zen_1.zen.document === undefined) {
123
101
  return;
124
102
  }
@@ -135,8 +113,8 @@ const LinePlugin = (containerId, options, isDark) => ({
135
113
  xLabel = scaleLabels[elementIdx];
136
114
  }
137
115
  else {
138
- const xValue = chart.scales.x.getValueForPixel(snappedX);
139
- xLabel = xValue !== undefined ? chart.scales.x.getLabelForValue(xValue) : undefined;
116
+ const xValue = chart.scales.x.getValueForPixel(x);
117
+ xLabel = xValue ? chart.scales.x.getLabelForValue(xValue) : undefined;
140
118
  }
141
119
  (0, renderTooltip_1.renderTooltip)(containerId, left + scrollLeft, top + scrollTop, "top", items, options === null || options === void 0 ? void 0 : options.title, options && options.subtitle !== undefined ? options.subtitle : xLabel, (options === null || options === void 0 ? void 0 : options.note) || undefined, isDark);
142
120
  }
@@ -1,4 +1,6 @@
1
1
  :root {
2
+ fill: var(--text-primary);
3
+
2
4
  // text
3
5
  --text-primary: #1f2833;
4
6
  --text-secondary: #4e677e;
@@ -84,6 +86,8 @@
84
86
 
85
87
  .zen-dark {
86
88
  color: var(--text-primary);
89
+ fill: var(--text-primary);
90
+
87
91
  // text
88
92
  --text-primary: #ffffff;
89
93
  --text-secondary: #c0ccd8;
@@ -24,4 +24,4 @@ const Dropdown = (_a) => {
24
24
  return (0, jsx_runtime_1.jsx)(DropDownFormField, Object.assign({}, props));
25
25
  };
26
26
  exports.Dropdown = Dropdown;
27
- exports.TRANSLATIONS = ["Filter by group", "Open filter", "Clear search", "Select all", "Clear", "Back", "No data"];
27
+ exports.TRANSLATIONS = ["Filter by group", "Open filter", "Clear search", "Select all", "Deselect all", "Clear", "Back", "No data"];
@@ -13,8 +13,7 @@ export interface IDropdownList extends IZenComponentProps {
13
13
  onSelect: (id: string) => void;
14
14
  onSingleSelect: (reset: boolean, selected?: string) => void;
15
15
  backButtonName?: string;
16
- isSelectAllActive?: boolean;
17
- shouldBlockItems?: boolean;
16
+ isAllSelected: boolean;
18
17
  listData: ICheckboxListWithActionOption[] | ISelectListItem[];
19
18
  isWithFooter: boolean;
20
19
  width?: number;
@@ -40,6 +39,6 @@ interface IDropdownEmptyList extends Pick<IDropdownList, "className" | "width" |
40
39
  hasError: boolean;
41
40
  }
42
41
  export declare const EmptyList: ({ className, width, onClearClick, onApplyClick, onCancelClick, hasApplyButton, isApplyDisabled, isClearButtonDisabled, isWithFooter, hasError }: IDropdownEmptyList) => import("react/jsx-runtime").JSX.Element;
43
- export declare const DropdownList: ({ onBackButtonClick, onSelectAllClick, onClearClick, onApplyClick, onCancelClick, onChange, onSelect, onSingleSelect, listData, isSelectAllActive, shouldBlockItems, backButtonName, width, minWidth, isSelectAllButtonDisable, hasSelectAllButton, filterName, isMultiselect, hasApplyButton, isApplyDisabled, isClearButtonDisabled, activeValue, forceSelection, isWithFooter, isMobile, handleCheckboxChange, checkboxLabel, isChecked, listElementRef, listId }: IDropdownList) => import("react/jsx-runtime").JSX.Element;
42
+ export declare 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, listElementRef, listId }: IDropdownList) => import("react/jsx-runtime").JSX.Element;
44
43
  export declare const TRANSLATIONS: string[];
45
44
  export {};
@@ -214,6 +214,39 @@ injectString("ka-GE", "Apply", "\u10D2\u10D0\u10DB\u10DD\u10E7\u10D4\u10DC\u10D4
214
214
  injectString("el-GR", "Apply", "\u0395\u03C6\u03B1\u03C1\u03BC\u03BF\u03B3\u03AE");
215
215
  injectString("et-EE", "Apply", "Rakenda");
216
216
  injectString("bg-BG", "Apply", "\u041F\u0440\u0438\u043B\u0430\u0433\u0430\u043D\u0435");
217
+ injectString("cs", "Deselect all", "Zru\u0161it v\xFDb\u011Br v\u0161ech");
218
+ injectString("da-DK", "Deselect all", "Frav\xE6lg alle");
219
+ injectString("de", "Deselect all", "Auswahl f\xFCr alle aufheben");
220
+ injectString("en", "Deselect all", "Deselect all");
221
+ injectString("es", "Deselect all", "Deseleccionar todo");
222
+ injectString("fi-FI", "Deselect all", "Poista kaikki valinnat");
223
+ injectString("fr", "Deselect all", "D\xE9s\xE9lectionner tout");
224
+ injectString("fr-FR", "Deselect all", "D\xE9s\xE9lectionner tout");
225
+ injectString("hu-HU", "Deselect all", "Ne v\xE1lassz ki semmit.");
226
+ injectString("id", "Deselect all", "Batalkan pilih semua");
227
+ injectString("it", "Deselect all", "Deselezionare tutto");
228
+ injectString("ja", "Deselect all", "\u3059\u3079\u3066\u3092\u9078\u629E\u89E3\u9664");
229
+ injectString("ko-KR", "Deselect all", "\uBAA8\uB450 \uC120\uD0DD \uCDE8\uC18C");
230
+ injectString("ms", "Deselect all", "Nyahpilih semua");
231
+ injectString("nb-NO", "Deselect all", "Fjern alle valg");
232
+ injectString("nl", "Deselect all", "Alles deselecteren");
233
+ injectString("pl", "Deselect all", "Usu\u0144 wyb\xF3r wszystkich");
234
+ injectString("pt-BR", "Deselect all", "Desmarcar tudo");
235
+ injectString("pt-PT", "Deselect all", "Desmarcar tudo");
236
+ injectString("sk-SK", "Deselect all", "Zru\u0161 v\xFDber v\u0161etk\xFDch.");
237
+ injectString("sv", "Deselect all", "Avmarkera alla");
238
+ injectString("th", "Deselect all", "\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01\u0E01\u0E32\u0E23\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14");
239
+ injectString("tr", "Deselect all", "T\xFCm\xFCn\xFCn se\xE7imini iptal et");
240
+ injectString("zh-Hans", "Deselect all", "\u53D6\u6D88\u5168\u9009");
241
+ injectString("zh-TW", "Deselect all", "\u53D6\u6D88\u5168\u9078");
242
+ injectString("ro-RO", "Deselect all", "Deselecta\u021Bi tot");
243
+ injectString("ar", "Deselect all", "\u0625\u0644\u063A\u0627\u0621 \u062A\u062D\u062F\u064A\u062F \u0627\u0644\u0643\u0644");
244
+ injectString("lt-LT", "Deselect all", "At\u017Eym\u0117ti visus");
245
+ injectString("lv-LV", "Deselect all", "Atcelt visas atlases");
246
+ injectString("ka-GE", "Deselect all", "\u10E7\u10D5\u10D4\u10DA\u10D0\u10E1 \u10DB\u10DD\u10EE\u10E1\u10DC\u10D0");
247
+ injectString("el-GR", "Deselect all", "\u039A\u03B1\u03C4\u03AC\u03C1\u03B3\u03B7\u03C3\u03B7 \u03CC\u03BB\u03C9\u03BD \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03CE\u03BD");
248
+ injectString("et-EE", "Deselect all", "T\xFChista k\xF5ik valikud");
249
+ injectString("bg-BG", "Deselect all", "\u041F\u0440\u0435\u043C\u0430\u0445\u0432\u0430\u043D\u0435 \u043D\u0430 \u0432\u0441\u0438\u0447\u043A\u0438 \u0438\u0437\u0431\u043E\u0440\u0438");
217
250
  injectString("cs", "Select all", "Vybrat v\u0161e");
218
251
  injectString("da-DK", "Select all", "V\xE6lg alle");
219
252
  injectString("de", "Select all", "Alle ausw\xE4hlen");
@@ -390,8 +423,7 @@ const DropdownList = ({
390
423
  onSelect,
391
424
  onSingleSelect,
392
425
  listData,
393
- isSelectAllActive,
394
- shouldBlockItems,
426
+ isAllSelected,
395
427
  backButtonName,
396
428
  width,
397
429
  minWidth,
@@ -420,7 +452,7 @@ const DropdownList = ({
420
452
  const internalListId = (0, react_1.useId)();
421
453
  const selectListId = listId || internalListId;
422
454
  const handleSelectAllClick = () => {
423
- onSelectAllClick(!!isSelectAllActive);
455
+ onSelectAllClick(isAllSelected);
424
456
  };
425
457
  const handleBackButtonKeyDown = (0, react_1.useCallback)(event => {
426
458
  if (event.key === "ArrowLeft") {
@@ -448,14 +480,13 @@ const DropdownList = ({
448
480
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
449
481
  forceSelection ? onSingleSelect(false, newActiveEl || activeValue) : onSingleSelect(false, newActiveEl);
450
482
  }, [activeValue, forceSelection, onSingleSelect]);
451
- const selectButtonLabel = translate("Select all");
452
- const getActionButton = (label, title, icon, isDisabled, clickHandler, size, onKeyDown, isSelected) => (0, jsx_runtime_1.jsx)("button", {
483
+ const selectButtonLabel = isAllSelected ? translate("Deselect all") : translate("Select all");
484
+ const getActionButton = (label, title, icon, isDisabled, clickHandler, size, onKeyDown) => (0, jsx_runtime_1.jsx)("button", {
453
485
  type: "button",
454
486
  disabled: isDisabled,
455
487
  onClick: clickHandler,
456
488
  onKeyDown: onKeyDown,
457
- "aria-pressed": isSelected,
458
- className: (0, classNames_1.classNames)(["zen-dropdown-list__item zen-dropdown-list__item--interactive zen-dropdown-list__action-button zen-dropdown-list__action-button-back", isSelected ? "zen-dropdown-list__action-button--selected" : ""]),
489
+ className: "zen-dropdown-list__item zen-dropdown-list__item--interactive zen-dropdown-list__action-button zen-dropdown-list__action-button-back",
459
490
  title: title,
460
491
  children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
461
492
  children: [react_1.default.createElement(icon, {
@@ -491,14 +522,11 @@ const DropdownList = ({
491
522
  });
492
523
  return values;
493
524
  };
494
- const multiselectOptions = shouldBlockItems ? listData.map(item => Object.assign(Object.assign({}, item), {
495
- blocked: true
496
- })) : listData;
497
525
  return (0, jsx_runtime_1.jsx)("div", {
498
526
  className: "zen-dropdown-list__elements",
499
527
  ref: listElementRef,
500
528
  children: isMultiselect ? (0, jsx_runtime_1.jsx)(checkboxListWithAction_1.CheckboxListWithAction, {
501
- options: multiselectOptions,
529
+ options: listData,
502
530
  label: "",
503
531
  onChange: handleChange,
504
532
  onClick: handleClick
@@ -514,7 +542,7 @@ const DropdownList = ({
514
542
  value: createValue(listData, activeValue)
515
543
  })
516
544
  });
517
- }, [listElementRef, isMultiselect, shouldBlockItems, listData, handleChange, handleClick, handleSingleChange, translate, selectListId, forceSelection, activeValue]);
545
+ }, [listElementRef, isMultiselect, listData, handleChange, handleClick, handleSingleChange, translate, selectListId, forceSelection, activeValue]);
518
546
  return (0, jsx_runtime_1.jsxs)("div", Object.assign({
519
547
  className: (0, classNames_1.classNames)(["zen-dropdown-list", driveComponentClass || ""])
520
548
  }, styleWidth, {
@@ -532,7 +560,7 @@ const DropdownList = ({
532
560
  }) : null, backButtonName ? (0, jsx_runtime_1.jsx)("div", {
533
561
  className: "zen-dropdown-list__item-wrapper",
534
562
  children: getActionButton(backButtonName, translate("Back"), iconBackArrow_1.IconBackArrow, false, onBackButtonClick, "large", handleBackButtonKeyDown)
535
- }) : null, hasSelectAllButton ? getActionButton(selectButtonLabel, selectButtonLabel, iconCheckRadio_1.IconCheckRadio, !!isSelectAllButtonDisable, handleSelectAllClick, isDrive ? "huger" : "huge", undefined, isSelectAllActive) : null, listDataComponent, isWithFooter ? (0, jsx_runtime_1.jsxs)("div", {
563
+ }) : null, hasSelectAllButton ? getActionButton(selectButtonLabel, selectButtonLabel, iconCheckRadio_1.IconCheckRadio, !!isSelectAllButtonDisable, handleSelectAllClick, isDrive ? "huger" : "huge") : null, listDataComponent, isWithFooter ? (0, jsx_runtime_1.jsxs)("div", {
536
564
  className: "zen-dropdown-list__footer",
537
565
  children: [(0, jsx_runtime_1.jsx)(button_1.Button, {
538
566
  onClick: isMultiselect ? onClearClick : handleClearClick,
@@ -561,4 +589,4 @@ const DropdownList = ({
561
589
  }));
562
590
  };
563
591
  exports.DropdownList = DropdownList;
564
- exports.TRANSLATIONS = ["Select all", "Clear", "Back", "No data"];
592
+ exports.TRANSLATIONS = ["Select all", "Deselect all", "Clear", "Back", "No data"];
@@ -117,10 +117,7 @@ const DropdownRaw = props => {
117
117
  mobileSheetStackingClassName,
118
118
  isError,
119
119
  firstParentNodeIsVisible,
120
- dataAnalyticsId,
121
- hideSelectAllOnSearch = false,
122
- blockItemsOnSelectAll = false,
123
- autoPromoteSelectAll = false
120
+ dataAnalyticsId
124
121
  } = props;
125
122
  const {
126
123
  isFormSection
@@ -158,7 +155,7 @@ const DropdownRaw = props => {
158
155
  const isQueryMode = (0, react_1.useMemo)(() => typeof getData === "undefined" && typeof dataItems === "undefined", [getData, dataItems]);
159
156
  const isCheckboxMode = (0, react_1.useMemo)(() => checkboxLabel && typeof value === "object" && "isChecked" in value && typeof value.isChecked === "boolean" || false, [checkboxLabel, value]);
160
157
  const [initialInChecked] = (0, react_1.useState)(isCheckboxMode ? value.isChecked : undefined);
161
- const [state, dispatchState] = (0, react_1.useReducer)(stateReducer_1.stateReducer, (0, stateReducer_1.getInitialState)(isFullSelectionMode, isQueryMode ? (fetchState === null || fetchState === void 0 ? void 0 : fetchState.data) || [] : dataItems || [], isFullSelectionMode || isCheckboxMode ? value.selected : value, listLimit, 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, firstParentNodeIsVisible, autoPromoteSelectAll));
158
+ const [state, dispatchState] = (0, react_1.useReducer)(stateReducer_1.stateReducer, (0, stateReducer_1.getInitialState)(isFullSelectionMode, isQueryMode ? (fetchState === null || fetchState === void 0 ? void 0 : fetchState.data) || [] : dataItems || [], isFullSelectionMode || isCheckboxMode ? value.selected : value, listLimit, 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, firstParentNodeIsVisible));
162
159
  const chipStatus = (0, chipStatusProvider_1.useChipStatus)();
163
160
  const isMobile = (0, useMobile_1.useMobile)();
164
161
  const popupId = (0, react_1.useId)();
@@ -896,15 +893,7 @@ const DropdownRaw = props => {
896
893
  });
897
894
  }
898
895
  if (state.showList) {
899
- const isSearchMode = Boolean(state.inputValue) && !state.currentId;
900
- const selectAllActiveForCurrentLevel = state.selectAllActiveForId === (state.currentId || state.rootId);
901
- // DESIGN INTENT: button state (isSelectAllActive) is truth-based — shows pressed whenever
902
- // all items are actually selected, including after search+clear where selectAllActiveForId
903
- // was cleared. shouldBlockItems is intent-based — only activates when "Select all" was
904
- // explicitly clicked (selectAllActiveForCurrentLevel), never from manual individual selection.
905
- // This asymmetry is intentional: the button restores its visual state post-search, but
906
- // blocking does not, to avoid unexpected UX when users manually select all items.
907
- const isAllCurrentLevelSelected = !isSearchMode && !isFullSelectionMode ? (0, dropdownHelper_1.isEveryItemSelected)((0, dropdownHelper_1.getListDataWithDisabled)(state.listData, state.isNestedList), state.selectedIds) : false;
896
+ const isSearchMode = state.inputValue && !state.currentId;
908
897
  const currentListData = (0, dropdownHelper_1.createListDataOptions)(state, translate, isSearchMode ? (0, dropdownHelper_1.sortDropdownItemArray)(state.listData, sortFn).slice(0, listLimit).filter(el => el.id !== state.rootId) :
909
898
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
910
899
  (0, dropdownHelper_1.sortDropdownItemArray)(((_b = state.groupsMap[state.currentId || state.rootId]) === null || _b === void 0 ? void 0 : _b.children) || [], sortFn).slice(0, listLimit) || [], multiselect, currentAllSelected);
@@ -920,17 +909,16 @@ const DropdownRaw = props => {
920
909
  activeValue: state.selectedIds.length ? state.selectedIds[0] : "root",
921
910
  backButtonName: state.currentId && state.groupsMap[state.currentId] ? (0, groupsHelper_1.getGroupDescription)(state.groupsMap[state.currentId], translate) : undefined,
922
911
  filterName: isMobile ? undefined : filterName,
923
- isSelectAllActive: isFullSelectionMode ? currentAllSelected : isSearchMode ? (0, dropdownHelper_1.isEveryItemSelected)((0, dropdownHelper_1.getListDataWithDisabled)(state.listData, state.isNestedList), state.selectedIds) : selectAllActiveForCurrentLevel || isAllCurrentLevelSelected,
924
- shouldBlockItems: blockItemsOnSelectAll && !state.inputValue && !isFullSelectionMode && selectAllActiveForCurrentLevel,
912
+ isAllSelected: currentAllSelected ? currentAllSelected : isSearchMode ? (0, dropdownHelper_1.isEveryItemSelected)((0, dropdownHelper_1.getListDataWithDisabled)(state.listData, state.isNestedList), state.selectedIds) : currentAllSelected === undefined ? (0, dropdownHelper_1.isAllChildrenSelected)(state, state.currentId || state.rootId) : false,
925
913
  isMultiselect: multiselect,
926
914
  forceSelection: forceSelection,
927
915
  listData: currentListData,
928
916
  width: width || currentWidth === 180 ? undefined : currentWidth,
929
917
  minWidth: currentWidth,
930
- hasSelectAllButton: selectAllButton && multiselect && !(hideSelectAllOnSearch && state.inputValue),
918
+ hasSelectAllButton: selectAllButton && multiselect,
931
919
  hasApplyButton: hasApplyButton,
932
920
  isApplyDisabled: memoizedIsApplyButtonDisabled,
933
- isSelectAllButtonDisable: currentListData.length === 0 || isSearchMode && state.isNestedList && (0, dropdownHelper_1.isAllItemsHasOneParent)(state.listData.filter(el => el.id !== state.rootId), (((_c = state.groupsMap[state.rootId]) === null || _c === void 0 ? void 0 : _c.children) || []).map(el => el.id)),
921
+ isSelectAllButtonDisable: currentListData.length === 0 || isSearchMode !== "" && state.isNestedList && (0, dropdownHelper_1.isAllItemsHasOneParent)(state.listData.filter(el => el.id !== state.rootId), (((_c = state.groupsMap[state.rootId]) === null || _c === void 0 ? void 0 : _c.children) || []).map(el => el.id)),
934
922
  isClearButtonDisabled: memoizedIsClearButtonDisabled,
935
923
  isWithFooter: memoizedWithFooter && !isMobile,
936
924
  isMobile: isMobile,
@@ -942,7 +930,7 @@ const DropdownRaw = props => {
942
930
  });
943
931
  }
944
932
  return null;
945
- }, [state, isLoading, isQueryMode, fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading, fetchState === null || fetchState === void 0 ? void 0 : fetchState.error, handleClearClick, handleCancelClick, handleApplyClick, hasApplyButton, memoizedWithFooter, translate, sortFn, listLimit, multiselect, currentAllSelected, handleBackButtonClick, handleSelectAllInSearch, handleSelectAllClick, handleSelect, handleChangeCurrentId, handleSingleSelection, isMobile, filterName, forceSelection, width, selectAllButton, hideSelectAllOnSearch, memoizedIsApplyButtonDisabled, memoizedIsClearButtonDisabled, isCheckboxMode, handleCheckboxChange, checkboxLabel, selectListId, isFullSelectionMode, blockItemsOnSelectAll]);
933
+ }, [state, isLoading, isQueryMode, fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading, fetchState === null || fetchState === void 0 ? void 0 : fetchState.error, handleClearClick, handleCancelClick, handleApplyClick, hasApplyButton, memoizedWithFooter, translate, sortFn, listLimit, multiselect, currentAllSelected, handleBackButtonClick, handleSelectAllInSearch, handleSelectAllClick, handleSelect, handleChangeCurrentId, handleSingleSelection, isMobile, filterName, forceSelection, width, selectAllButton, memoizedIsApplyButtonDisabled, memoizedIsClearButtonDisabled, isCheckboxMode, handleCheckboxChange, checkboxLabel, selectListId]);
946
934
  const currentStringFromSelected = isFullSelectionMode && hasApplyButton && state.globalIsAllSelected || isFullSelectionMode && !hasApplyButton && state.isAllSelected ? (0, dropdownHelper_1.getStringFromAllSelected)(state.groupsMap, translate, state.rootId) : (0, dropdownHelper_1.getStringFromSelected)(hasApplyButton ? state.globalSelectedIds : state.selectedIds, state.groupsMapSelected, translate, state.rootId);
947
935
  const memoizedCurrentSelection = (0, react_1.useMemo)(() => showSelection && !state.inputValue ? currentStringFromSelected : "", [showSelection, state.inputValue, currentStringFromSelected]);
948
936
  const parentTriggerWidth = ((_b = comboboxRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width) || 420;
@@ -1041,4 +1029,4 @@ const DropdownRaw = props => {
1041
1029
  };
1042
1030
  exports.DropdownRaw = DropdownRaw;
1043
1031
  exports.DropdownRaw.displayName = "DropdownRaw";
1044
- exports.TRANSLATIONS = ["Filter by group", "Open filter", "Clear search", "Select all", "Clear", "Back", "No data"];
1032
+ exports.TRANSLATIONS = ["Filter by group", "Open filter", "Clear search", "Select all", "Deselect all", "Clear", "Back", "No data"];
@@ -25,8 +25,6 @@ export interface IDropdownState {
25
25
  listLimit: number;
26
26
  resultsExceedListLimit?: boolean;
27
27
  isAllSelected?: boolean;
28
- selectAllActiveForId?: string;
29
- autoPromoteSelectAll?: boolean;
30
28
  globalIsAllSelected?: boolean;
31
29
  defaultValueIsAllSelected?: boolean;
32
30
  isChecked?: boolean;
@@ -36,7 +34,7 @@ export interface IDropdownState {
36
34
  }
37
35
  export interface IStateReducer extends Reducer<IDropdownState, TStateAction> {
38
36
  }
39
- export declare const getInitialState: (isFullSelectionMode: boolean, comboItems: IDropdownRawItem[], selection: string[], listLimit: number, defaultValue?: string[], isAllSelected?: boolean, defaultValueIsAllSelected?: boolean, isChecked?: boolean, defaultValueIsChecked?: boolean, firstParentNodeIsVisible?: boolean, autoPromoteSelectAll?: boolean) => {
37
+ export declare const getInitialState: (isFullSelectionMode: boolean, comboItems: IDropdownRawItem[], selection: string[], listLimit: number, defaultValue?: string[], isAllSelected?: boolean, defaultValueIsAllSelected?: boolean, isChecked?: boolean, defaultValueIsChecked?: boolean, firstParentNodeIsVisible?: boolean) => {
40
38
  groupsMap: ITypedHash<IGroupTree>;
41
39
  selectedIds: string[];
42
40
  globalSelectedIds: string[];
@@ -64,6 +62,5 @@ export declare const getInitialState: (isFullSelectionMode: boolean, comboItems:
64
62
  listLimit: number;
65
63
  resultsExceedListLimit: boolean;
66
64
  firstParentNodeIsVisible: boolean | undefined;
67
- autoPromoteSelectAll: boolean | undefined;
68
65
  };
69
66
  export declare function stateReducer(state: IDropdownState, action: TStateAction): IDropdownState;
@@ -6,7 +6,7 @@ const stateActionType_1 = require("./stateActionType");
6
6
  const stateReducerHelper_1 = require("./stateReducerHelper");
7
7
  const groupsFilterHelper_1 = require("../../groupsFilterRaw/groupsFilterHelper");
8
8
  exports.ROOT_GROUP_ID = "zen_dropdown_root_group_id";
9
- const getInitialState = (isFullSelectionMode, comboItems, selection, listLimit, defaultValue, isAllSelected, defaultValueIsAllSelected, isChecked, defaultValueIsChecked, firstParentNodeIsVisible, autoPromoteSelectAll) => {
9
+ const getInitialState = (isFullSelectionMode, comboItems, selection, listLimit, defaultValue, isAllSelected, defaultValueIsAllSelected, isChecked, defaultValueIsChecked, firstParentNodeIsVisible) => {
10
10
  const updatedGroupsMapSelected = new Map();
11
11
  const updatedGroupsMap = comboItems.length ? (0, groupsFilterHelper_1.createGroupsMap)(comboItems, exports.ROOT_GROUP_ID) : {};
12
12
  const namelessIds = new Set();
@@ -51,8 +51,7 @@ const getInitialState = (isFullSelectionMode, comboItems, selection, listLimit,
51
51
  globalIsChecked: isChecked,
52
52
  listLimit,
53
53
  resultsExceedListLimit: false,
54
- firstParentNodeIsVisible: firstParentNodeIsVisible,
55
- autoPromoteSelectAll: autoPromoteSelectAll
54
+ firstParentNodeIsVisible: firstParentNodeIsVisible
56
55
  };
57
56
  };
58
57
  exports.getInitialState = getInitialState;
@@ -77,14 +76,12 @@ function stateReducer(state, action) {
77
76
  }
78
77
  });
79
78
  }
80
- const updatedGroupsMapCount = Object.keys(updatedGroupsMap).length;
81
- const isCurrentListNested = updatedGroupsMapCount > 0 && (updatedGroupsMap[exports.ROOT_GROUP_ID].children || []).some(el => el.children && el.children.length);
82
- const groupsMapLength = updatedGroupsMapCount - 1;
83
- const newResultsExceedListLimit = groupsMapLength >= state.listLimit;
84
- const selectedInNewMap = state.selectedIds.filter(id => id in updatedGroupsMap).length - newNamelessIds.size;
85
- const newIsAllSelected = (0, stateReducerHelper_1.computeIsAllSelected)(state.isAllSelected, state.isFullSelectionMode, newResultsExceedListLimit, groupsMapLength, selectedInNewMap);
79
+ const isCurrentListNested = Object.keys(updatedGroupsMap).length > 0 &&
80
+ (updatedGroupsMap[exports.ROOT_GROUP_ID].children || []).some(el => el.children && el.children.length);
81
+ state.groupsMap = updatedGroupsMap;
82
+ const additionalStateUpdates = (0, stateReducerHelper_1.updateAllSelectedStateValueBasedOnTotalSelected)(state, state.selectedIds.length - newNamelessIds.size);
86
83
  const rootId = (0, stateReducerHelper_1.getRootId)(updatedGroupsMap, exports.ROOT_GROUP_ID, state.firstParentNodeIsVisible);
87
- return Object.assign(Object.assign({}, state), { groupsMap: updatedGroupsMap, rootId: rootId || exports.ROOT_GROUP_ID, namelessIds: newNamelessIds, isNestedList: state.isNestedList ? state.isNestedList : isCurrentListNested, resultsExceedListLimit: newResultsExceedListLimit, isAllSelected: newIsAllSelected });
84
+ return Object.assign(Object.assign(Object.assign({}, state), { rootId: rootId || exports.ROOT_GROUP_ID, namelessIds: newNamelessIds, isNestedList: state.isNestedList ? state.isNestedList : isCurrentListNested, resultsExceedListLimit: Object.keys(updatedGroupsMap).length - 1 >= state.listLimit }), additionalStateUpdates);
88
85
  }
89
86
  case stateActionType_1.StateActionType.SetListData: {
90
87
  state.selectedIds.forEach(id => {
@@ -109,9 +106,9 @@ function stateReducer(state, action) {
109
106
  case stateActionType_1.StateActionType.SetIsOpenCombo:
110
107
  return Object.assign(Object.assign({}, state), { isOpenCombo: payload });
111
108
  case stateActionType_1.StateActionType.ResetSelection:
112
- return Object.assign(Object.assign({}, state), { selectedIds: [...state.defaultValue], isAllSelected: state.defaultValueIsAllSelected, isChecked: typeof state.isChecked === "boolean" ? state.defaultValueIsChecked || false : undefined, selectAllActiveForId: undefined });
109
+ return Object.assign(Object.assign({}, state), { selectedIds: [...state.defaultValue], isAllSelected: state.defaultValueIsAllSelected, isChecked: typeof state.isChecked === "boolean" ? state.defaultValueIsChecked || false : undefined });
113
110
  case stateActionType_1.StateActionType.ResetStateToGlobal:
114
- return Object.assign(Object.assign({}, state), { selectedIds: [...state.globalSelectedIds], isAllSelected: state.globalIsAllSelected, isChecked: state.globalIsChecked, selectAllActiveForId: undefined });
111
+ return Object.assign(Object.assign({}, state), { selectedIds: [...state.globalSelectedIds], isAllSelected: state.globalIsAllSelected, isChecked: state.globalIsChecked });
115
112
  case stateActionType_1.StateActionType.NothingToShow:
116
113
  return Object.assign(Object.assign({}, state), { showWaiting: false, showEmptyList: false, showList: false });
117
114
  case stateActionType_1.StateActionType.Show:
@@ -123,7 +120,7 @@ function stateReducer(state, action) {
123
120
  case stateActionType_1.StateActionType.ShowList:
124
121
  return Object.assign(Object.assign({}, state), { showWaiting: false, showEmptyList: false, showList: true });
125
122
  case stateActionType_1.StateActionType.SetInputValue:
126
- return Object.assign(Object.assign({}, state), { inputValue: payload, selectAllActiveForId: undefined });
123
+ return Object.assign(Object.assign({}, state), { inputValue: payload });
127
124
  case stateActionType_1.StateActionType.SetState: {
128
125
  const newNamelessIds = new Set(state.namelessIds);
129
126
  payload.selected.forEach(id => {
@@ -227,10 +224,8 @@ function stateReducer(state, action) {
227
224
  state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
228
225
  }
229
226
  });
230
- const newIsAllSelected = state.autoPromoteSelectAll
231
- ? currentSelectedIds.size >= Object.keys(state.groupsMap).length - 1
232
- : state.isAllSelected;
233
- return Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds), selectAllActiveForId: undefined, isAllSelected: newIsAllSelected });
227
+ const additionalStateUpdates = (0, stateReducerHelper_1.updateAllSelectedStateValueBasedOnTotalSelected)(state, currentSelectedIds.size);
228
+ return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds) }), additionalStateUpdates);
234
229
  }
235
230
  case stateActionType_1.StateActionType.ChangeBulkSelection: {
236
231
  const { itemsIds, value } = payload;
@@ -263,10 +258,8 @@ function stateReducer(state, action) {
263
258
  state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
264
259
  }
265
260
  });
266
- const newIsAllSelected = state.autoPromoteSelectAll
267
- ? currentSelectedIds.size >= Object.keys(state.groupsMap).length - 1
268
- : state.isAllSelected;
269
- return Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds), selectAllActiveForId: undefined, isAllSelected: newIsAllSelected });
261
+ const additionalStateUpdates = (0, stateReducerHelper_1.updateAllSelectedStateValueBasedOnTotalSelected)(state, currentSelectedIds.size);
262
+ return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds) }), additionalStateUpdates);
270
263
  }
271
264
  case stateActionType_1.StateActionType.SelectAllChildren: {
272
265
  const currentEl = state.groupsMap[payload];
@@ -303,7 +296,7 @@ function stateReducer(state, action) {
303
296
  state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
304
297
  }
305
298
  });
306
- return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected), selectAllActiveForId: payload });
299
+ return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected) });
307
300
  }
308
301
  case stateActionType_1.StateActionType.DeselectItemsFromAllSelected: {
309
302
  const currentEl = state.groupsMap[state.rootId];
@@ -327,16 +320,12 @@ function stateReducer(state, action) {
327
320
  state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
328
321
  }
329
322
  });
330
- return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected), isAllSelected: state.isFullSelectionMode ? false : undefined, selectAllActiveForId: undefined });
323
+ return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected), isAllSelected: state.isFullSelectionMode ? false : undefined });
331
324
  }
332
325
  case stateActionType_1.StateActionType.ToggleValueForAllSelected: {
333
326
  const currentEl = state.groupsMap[state.rootId];
334
- // selectAllActiveForId tracks when "Select all" was clicked at this level, even when
335
- // autoPromoteSelectAll=false keeps isAllSelected=false. Without this fallback, a second
336
- // click would incorrectly clear selections and leave the button stuck as pressed.
337
- const effectiveIsAllSelected = !!state.isAllSelected || state.selectAllActiveForId === (state.currentId || state.rootId);
338
327
  const newSelected = new Set();
339
- effectiveIsAllSelected &&
328
+ state.isAllSelected &&
340
329
  ((currentEl === null || currentEl === void 0 ? void 0 : currentEl.children) || []).forEach(el => {
341
330
  if (!newSelected.has(el.id) && el.disabled) {
342
331
  newSelected.add(el.id);
@@ -349,8 +338,9 @@ function stateReducer(state, action) {
349
338
  state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
350
339
  }
351
340
  });
352
- const updatedIsAllSelectedValue = state.isFullSelectionMode ? !effectiveIsAllSelected : undefined;
353
- return Object.assign(Object.assign({}, state), { selectedIds: effectiveIsAllSelected ? Array.from(newSelected) : [], isAllSelected: updatedIsAllSelectedValue, selectAllActiveForId: undefined });
341
+ const updatedIsAllSelectedValue = state.isFullSelectionMode ? !state.isAllSelected : undefined;
342
+ const additionalStateUpdates = (0, stateReducerHelper_1.updateAllSelectedStateValueBasedOnTotalSelected)(state, newSelected.size);
343
+ return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: state.isAllSelected ? Array.from(newSelected) : [], isAllSelected: updatedIsAllSelectedValue }), additionalStateUpdates);
354
344
  }
355
345
  case stateActionType_1.StateActionType.DeselectAllChildren: {
356
346
  const childrenForDeselect = [];
@@ -362,7 +352,7 @@ function stateReducer(state, action) {
362
352
  });
363
353
  const newSelected = new Set(state.selectedIds);
364
354
  childrenForDeselect.forEach(childId => newSelected.delete(childId));
365
- return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected), selectAllActiveForId: undefined });
355
+ return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected) });
366
356
  }
367
357
  case stateActionType_1.StateActionType.SetFirstParentNodeIsVisible: {
368
358
  if (state.firstParentNodeIsVisible === payload) {
@@ -1,5 +1,6 @@
1
+ import { IDropdownState } from "./stateReducer";
1
2
  import { IDropdownRawItem } from "../types";
2
3
  import { IGroupTree, ITypedHash } from "../../groupsFilterRaw/groupsFilterInterfaces";
3
4
  export declare function getChildList(childArr: IDropdownRawItem[] | undefined): IDropdownRawItem[];
4
- export declare const computeIsAllSelected: (currentIsAllSelected: boolean | undefined, isFullSelectionMode: boolean, resultsExceedListLimit: boolean | undefined, groupsMapLength: number, selectedCount: number) => boolean | undefined;
5
+ export declare const updateAllSelectedStateValueBasedOnTotalSelected: (state: IDropdownState, totalSelected: number) => Partial<Pick<IDropdownState, "isAllSelected">>;
5
6
  export declare const getRootId: (groupsMap: ITypedHash<IGroupTree>, rootIdKey: string, firstParentNodeIsVisible?: boolean) => string | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRootId = exports.computeIsAllSelected = void 0;
3
+ exports.getRootId = exports.updateAllSelectedStateValueBasedOnTotalSelected = void 0;
4
4
  exports.getChildList = getChildList;
5
5
  const groupsHelper_1 = require("../../groupsFilterRaw/groupsHelper");
6
6
  function getChildList(childArr) {
@@ -17,12 +17,17 @@ function getChildList(childArr) {
17
17
  });
18
18
  return list;
19
19
  }
20
- const computeIsAllSelected = (currentIsAllSelected, isFullSelectionMode, resultsExceedListLimit, groupsMapLength, selectedCount) => !resultsExceedListLimit && isFullSelectionMode && groupsMapLength > 0
21
- ? selectedCount >= groupsMapLength
22
- ? true
23
- : currentIsAllSelected
24
- : currentIsAllSelected;
25
- exports.computeIsAllSelected = computeIsAllSelected;
20
+ const updateAllSelectedStateValueBasedOnTotalSelected = (state, totalSelected) => {
21
+ const additionalStateUpdates = {};
22
+ const groupsMapLength = Object.keys(state.groupsMap).length - 1;
23
+ if (!state.resultsExceedListLimit && !state.isAllSelected && state.isFullSelectionMode && groupsMapLength > 0) {
24
+ if (totalSelected >= groupsMapLength) {
25
+ additionalStateUpdates.isAllSelected = true;
26
+ }
27
+ }
28
+ return additionalStateUpdates;
29
+ };
30
+ exports.updateAllSelectedStateValueBasedOnTotalSelected = updateAllSelectedStateValueBasedOnTotalSelected;
26
31
  const getRootId = (groupsMap, rootIdKey, firstParentNodeIsVisible) => {
27
32
  var _a;
28
33
  if (Object.keys(groupsMap).length === 0) {
@@ -62,26 +62,6 @@ interface IDropdownBase extends IChipsParent {
62
62
  mobileSheetStackingClassName?: string;
63
63
  firstParentNodeIsVisible?: boolean;
64
64
  dataAnalyticsId?: string;
65
- /**
66
- * When `true`, hides the "Select all" button while the user has an active search query.
67
- * The button reappears when the search field is cleared.
68
- * @default false
69
- */
70
- hideSelectAllOnSearch?: boolean;
71
- /**
72
- * When `true`, individual list items are visually blocked (disabled) while "Select all" is
73
- * active at the current level, preventing partial deselection after a bulk selection.
74
- * Has no effect in full-selection mode (`value` with `isAllSelected`).
75
- * @default false
76
- */
77
- blockItemsOnSelectAll?: boolean;
78
- /**
79
- * When `true`, automatically promotes `isAllSelected` to `true` when all available items
80
- * are individually checked. Only applies in full-selection mode (value with `isAllSelected`).
81
- * Has no effect in standard mode (`value: string[]`).
82
- * @default false
83
- */
84
- autoPromoteSelectAll?: boolean;
85
65
  }
86
66
  interface IDropdownBaseDefault {
87
67
  disabled?: boolean;