@geotab/zenith 3.10.0-beta.4 → 3.10.0-beta.7
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 +1 -2
- package/dist/checkboxListWithAction/checkboxListWithAction.js +1 -2
- package/dist/commonStyles/pillStyles/pillContent.less +9 -9
- package/dist/commonStyles/pillStyles/pillStyles.less +2 -2
- package/dist/dataGrid/cell/cell.d.ts +1 -2
- package/dist/dataGrid/cell/cell.js +2 -2
- package/dist/dataGrid/dataGrid.js +4 -6
- package/dist/dataGrid/listColumn.d.ts +0 -2
- package/dist/dataGrid/row/row.js +7 -11
- package/dist/dataGrid/withFlexibleColumns/components/columnSettingsList.js +1 -2
- package/dist/dataGrid/withSelectableRows/components/bulkActions/bulkActions.d.ts +0 -4
- package/dist/dateRangeRaw/utils/parseLabel.js +1 -1
- package/dist/dropdown/dropdown.js +1 -1
- package/dist/dropdownRaw/dropdownList.d.ts +2 -3
- package/dist/dropdownRaw/dropdownList.js +34 -8
- package/dist/dropdownRaw/dropdownRaw.js +28 -19
- package/dist/dropdownRaw/stateReducer/stateReducer.d.ts +0 -1
- package/dist/dropdownRaw/stateReducer/stateReducer.js +14 -13
- package/dist/dropdownRaw/stateReducer/stateReducerHelper.d.ts +2 -1
- package/dist/dropdownRaw/stateReducer/stateReducerHelper.js +12 -5
- package/dist/filtersBar/filtersContainer/filtersContainer.js +4 -14
- package/dist/index.css +655 -720
- package/dist/radioGroupRaw/radioGroupRaw.js +1 -2
- package/dist/selectList/selectList.helpers.d.ts +1 -1
- package/dist/selectList/selectList.helpers.js +9 -30
- package/dist/selectList/selectList.js +1 -3
- package/dist/selectList/selectList.reducer.js +2 -1
- package/dist/sortControl/sortControl.js +2 -58
- package/dist/table/children/useTableChildren.d.ts +1 -1
- package/dist/table/children/useTableChildren.js +3 -3
- package/dist/table/flexible/columnsList.js +2 -4
- package/dist/table/selectable/useSelectableRows.d.ts +0 -8
- package/dist/table/selectable/useSelectableRows.js +6 -14
- package/dist/table/table.js +7 -1
- package/dist/utils/localization/translations/ar.json +1 -3
- package/dist/utils/localization/translations/cs.json +1 -3
- package/dist/utils/localization/translations/da-DK.json +1 -3
- package/dist/utils/localization/translations/de.json +1 -3
- package/dist/utils/localization/translations/en.json +1 -3
- package/dist/utils/localization/translations/es.json +1 -3
- package/dist/utils/localization/translations/fi-FI.json +1 -3
- package/dist/utils/localization/translations/fr-FR.json +1 -3
- package/dist/utils/localization/translations/fr.json +1 -3
- package/dist/utils/localization/translations/hu-HU.json +1 -3
- package/dist/utils/localization/translations/id.json +1 -3
- package/dist/utils/localization/translations/it.json +1 -3
- package/dist/utils/localization/translations/ja.json +1 -3
- package/dist/utils/localization/translations/ko-KR.json +1 -3
- package/dist/utils/localization/translations/ms.json +1 -3
- package/dist/utils/localization/translations/nb-NO.json +1 -3
- package/dist/utils/localization/translations/nl.json +1 -3
- package/dist/utils/localization/translations/pl.json +1 -3
- package/dist/utils/localization/translations/pt-BR.json +1 -3
- package/dist/utils/localization/translations/pt-PT.json +1 -3
- package/dist/utils/localization/translations/ro-RO.json +1 -3
- package/dist/utils/localization/translations/sk-SK.json +1 -3
- package/dist/utils/localization/translations/sv.json +1 -3
- package/dist/utils/localization/translations/th.json +1 -3
- package/dist/utils/localization/translations/tr.json +1 -3
- package/dist/utils/localization/translations/zh-Hans.json +1 -3
- package/dist/utils/localization/translations/zh-TW.json +1 -3
- package/esm/checkboxListWithAction/checkboxListWithAction.js +1 -2
- package/esm/dataGrid/cell/cell.d.ts +1 -2
- package/esm/dataGrid/cell/cell.js +2 -2
- package/esm/dataGrid/dataGrid.js +4 -6
- package/esm/dataGrid/listColumn.d.ts +0 -2
- package/esm/dataGrid/row/row.js +7 -11
- package/esm/dataGrid/withFlexibleColumns/components/columnSettingsList.js +1 -2
- package/esm/dataGrid/withSelectableRows/components/bulkActions/bulkActions.d.ts +0 -4
- package/esm/dateRangeRaw/utils/parseLabel.js +1 -1
- package/esm/dropdown/dropdown.js +1 -1
- package/esm/dropdownRaw/dropdownList.d.ts +2 -3
- package/esm/dropdownRaw/dropdownList.js +34 -8
- package/esm/dropdownRaw/dropdownRaw.js +29 -20
- package/esm/dropdownRaw/stateReducer/stateReducer.d.ts +0 -1
- package/esm/dropdownRaw/stateReducer/stateReducer.js +15 -14
- package/esm/dropdownRaw/stateReducer/stateReducerHelper.d.ts +2 -1
- package/esm/dropdownRaw/stateReducer/stateReducerHelper.js +10 -3
- package/esm/filtersBar/filtersContainer/filtersContainer.js +4 -14
- package/esm/radioGroupRaw/radioGroupRaw.js +1 -2
- package/esm/selectList/selectList.helpers.d.ts +1 -1
- package/esm/selectList/selectList.helpers.js +9 -30
- package/esm/selectList/selectList.js +1 -3
- package/esm/selectList/selectList.reducer.js +2 -1
- package/esm/sortControl/sortControl.js +2 -58
- package/esm/table/children/useTableChildren.d.ts +1 -1
- package/esm/table/children/useTableChildren.js +3 -3
- package/esm/table/flexible/columnsList.js +2 -4
- package/esm/table/selectable/useSelectableRows.d.ts +0 -8
- package/esm/table/selectable/useSelectableRows.js +6 -14
- package/esm/table/table.js +7 -1
- package/esm/utils/localization/translations/ar.json +1 -3
- package/esm/utils/localization/translations/cs.json +1 -3
- package/esm/utils/localization/translations/da-DK.json +1 -3
- package/esm/utils/localization/translations/de.json +1 -3
- package/esm/utils/localization/translations/en.json +1 -3
- package/esm/utils/localization/translations/es.json +1 -3
- package/esm/utils/localization/translations/fi-FI.json +1 -3
- package/esm/utils/localization/translations/fr-FR.json +1 -3
- package/esm/utils/localization/translations/fr.json +1 -3
- package/esm/utils/localization/translations/hu-HU.json +1 -3
- package/esm/utils/localization/translations/id.json +1 -3
- package/esm/utils/localization/translations/it.json +1 -3
- package/esm/utils/localization/translations/ja.json +1 -3
- package/esm/utils/localization/translations/ko-KR.json +1 -3
- package/esm/utils/localization/translations/ms.json +1 -3
- package/esm/utils/localization/translations/nb-NO.json +1 -3
- package/esm/utils/localization/translations/nl.json +1 -3
- package/esm/utils/localization/translations/pl.json +1 -3
- package/esm/utils/localization/translations/pt-BR.json +1 -3
- package/esm/utils/localization/translations/pt-PT.json +1 -3
- package/esm/utils/localization/translations/ro-RO.json +1 -3
- package/esm/utils/localization/translations/sk-SK.json +1 -3
- package/esm/utils/localization/translations/sv.json +1 -3
- package/esm/utils/localization/translations/th.json +1 -3
- package/esm/utils/localization/translations/tr.json +1 -3
- package/esm/utils/localization/translations/zh-Hans.json +1 -3
- package/esm/utils/localization/translations/zh-TW.json +1 -3
- package/package.json +1 -2
|
@@ -13,9 +13,8 @@ export interface IDataGridCell<T extends IEntityWithId> extends IZenComponentPro
|
|
|
13
13
|
defaultValue: string | undefined;
|
|
14
14
|
entity: T;
|
|
15
15
|
width?: number;
|
|
16
|
-
maxWidth?: number;
|
|
17
16
|
colspan?: number;
|
|
18
17
|
onClick?: () => void;
|
|
19
18
|
isActive?: boolean;
|
|
20
19
|
}
|
|
21
|
-
export declare const DataGridCell: <T extends IEntityWithId>({ index, limited, visibleOnHover, isVisible, width,
|
|
20
|
+
export declare const DataGridCell: <T extends IEntityWithId>({ index, limited, visibleOnHover, isVisible, width, render, renderWrappers, renderPlaceholder, defaultValue, entity, colspan, className, onClick, isActive }: IDataGridCell<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { classNames } from "../../commonHelpers/classNames/classNames";
|
|
|
4
4
|
import { isPromiseLike } from "../columns/basicColumn";
|
|
5
5
|
import { isActiveElement } from "../../list/utils/isActiveElement";
|
|
6
6
|
import { zen } from "../../utils/zen";
|
|
7
|
-
const Cell = ({ index, limited, visibleOnHover, isVisible, width,
|
|
7
|
+
const Cell = ({ index, limited, visibleOnHover, isVisible, width, render, renderWrappers, renderPlaceholder, defaultValue, entity, colspan, className, onClick, isActive }) => {
|
|
8
8
|
const [content, setContent] = useState("");
|
|
9
9
|
const placeholderRenderer = useCallback(() => {
|
|
10
10
|
const renderFn = renderPlaceholder || (() => "...");
|
|
@@ -69,6 +69,6 @@ const Cell = ({ index, limited, visibleOnHover, isVisible, width, maxWidth, rend
|
|
|
69
69
|
visibleOnHover ? "zen-data-grid__row-cell--visible-on-hover" : "",
|
|
70
70
|
onClick ? "zen-data-grid__row-cell--clickable" : "",
|
|
71
71
|
limited ? "zen-ellipsis" : ""
|
|
72
|
-
]), style: { minWidth: width || "auto", maxWidth:
|
|
72
|
+
]), style: { minWidth: width || "auto", maxWidth: width || "auto" }, role: "gridcell", children: content }));
|
|
73
73
|
};
|
|
74
74
|
export const DataGridCell = memo(Cell);
|
package/esm/dataGrid/dataGrid.js
CHANGED
|
@@ -49,7 +49,7 @@ const getHeaderPropsFromWrappers = wrappers => wrappers.reduce((result, wrapper)
|
|
|
49
49
|
const props = (_a = wrapper.getHeaderProps) === null || _a === void 0 ? void 0 : _a.call(wrapper);
|
|
50
50
|
return props ? Object.assign(Object.assign({}, result), props) : result;
|
|
51
51
|
}, {});
|
|
52
|
-
const getColumnWidth =
|
|
52
|
+
const getColumnWidth = defaultWidth => Math.floor(Math.max(defaultWidth, MIN_CELL_WIDTH));
|
|
53
53
|
export const EmptyList = ({
|
|
54
54
|
children
|
|
55
55
|
}) => _jsx("div", {
|
|
@@ -144,13 +144,12 @@ const DataGridInner = ({
|
|
|
144
144
|
setVisibleRows(visible);
|
|
145
145
|
}, [entities]);
|
|
146
146
|
const listOfDefaultWidthColumns = useMemo(() => columnsList.map(column => column.meta.defaultWidth), [columnsList]);
|
|
147
|
-
const listOfMinWidthColumns = useMemo(() => columnsList.map(column => column.meta.minWidth), [columnsList]);
|
|
148
147
|
const {
|
|
149
148
|
result: observerResult
|
|
150
149
|
} = useResizeObserver({
|
|
151
150
|
target: gridRef.current
|
|
152
151
|
});
|
|
153
|
-
const allocatedSpace = listOfDefaultWidthColumns.reduce((acc, width
|
|
152
|
+
const allocatedSpace = listOfDefaultWidthColumns.reduce((acc, width) => acc + (width === undefined ? 0 : getColumnWidth(width)), 0);
|
|
154
153
|
const unallocatedSpace = observerResult && observerResult.contentRect.width - allocatedSpace || 0;
|
|
155
154
|
const flexibleColumnsQty = listOfDefaultWidthColumns.filter(width => width === undefined).length;
|
|
156
155
|
const flexibleColumnWidth = getColumnWidth(unallocatedSpace / flexibleColumnsQty);
|
|
@@ -173,19 +172,18 @@ const DataGridInner = ({
|
|
|
173
172
|
}, [updateScroll, scheduleLazyRender]);
|
|
174
173
|
const getCellParams = useCallback(columnIndex => {
|
|
175
174
|
const defaultWidth = listOfDefaultWidthColumns[columnIndex];
|
|
176
|
-
const minWidth = listOfMinWidthColumns[columnIndex];
|
|
177
175
|
const limited = !!defaultWidth && defaultWidth > 0;
|
|
178
176
|
const isFirst = columnIndex === 0;
|
|
179
177
|
const isLast = columnIndex === listOfDefaultWidthColumns.length - 1;
|
|
180
178
|
// If the column is the last one or doesn't have a default width, it should be limited to the remaining space
|
|
181
|
-
const width = getColumnWidth(defaultWidth || flexibleColumnWidth
|
|
179
|
+
const width = getColumnWidth(defaultWidth || flexibleColumnWidth);
|
|
182
180
|
return {
|
|
183
181
|
limited,
|
|
184
182
|
isFirst,
|
|
185
183
|
isLast,
|
|
186
184
|
width
|
|
187
185
|
};
|
|
188
|
-
}, [listOfDefaultWidthColumns,
|
|
186
|
+
}, [listOfDefaultWidthColumns, flexibleColumnWidth]);
|
|
189
187
|
const renderHeaderCell = useCallback((column, columnIndex) => {
|
|
190
188
|
var _a;
|
|
191
189
|
const {
|
|
@@ -2,8 +2,6 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { ColumnSortDirection } from "../table/table";
|
|
3
3
|
export interface IListColumnMeta<T, N = T> {
|
|
4
4
|
readonly defaultWidth?: number;
|
|
5
|
-
readonly minWidth?: number;
|
|
6
|
-
readonly maxWidth?: number;
|
|
7
5
|
readonly defaultValue?: string;
|
|
8
6
|
readonly lazyLoad?: boolean;
|
|
9
7
|
readonly visibleOnHover?: boolean;
|
package/esm/dataGrid/row/row.js
CHANGED
|
@@ -3,12 +3,10 @@ import { memo, useCallback, useId, useMemo } from "react";
|
|
|
3
3
|
import { classNames } from "../../commonHelpers/classNames/classNames";
|
|
4
4
|
import { DataGridCell } from "../cell/cell";
|
|
5
5
|
export const MIN_CELL_WIDTH = 100;
|
|
6
|
-
const getColumnWidth = (defaultWidth
|
|
6
|
+
const getColumnWidth = (defaultWidth) => Math.floor(Math.max(defaultWidth, MIN_CELL_WIDTH));
|
|
7
7
|
const Row = ({ id, entity, columns, visibleRows, flexibleColumnWidth, isLastRow, className, expanded, onExpandedChange, isTreeGrid, ariaPosinset, ariaSetsize, onClick, isActive }) => {
|
|
8
8
|
const isVisible = visibleRows.has(entity.id);
|
|
9
9
|
const listOfDefaultWidthColumns = useMemo(() => columns.map(column => column.meta.defaultWidth), [columns]);
|
|
10
|
-
const listOfMinWidthColumns = useMemo(() => columns.map(column => column.meta.minWidth), [columns]);
|
|
11
|
-
const listOfMaxWidthColumns = useMemo(() => columns.map(column => column.meta.maxWidth), [columns]);
|
|
12
10
|
const getColWidth = useCallback((columnIndex, colspan) => {
|
|
13
11
|
const colsp = colspan || 1;
|
|
14
12
|
let columnWidth = 0;
|
|
@@ -17,28 +15,26 @@ const Row = ({ id, entity, columns, visibleRows, flexibleColumnWidth, isLastRow,
|
|
|
17
15
|
continue;
|
|
18
16
|
}
|
|
19
17
|
const defaultWidth = listOfDefaultWidthColumns[columnIndex + i];
|
|
20
|
-
const minWidth = listOfMinWidthColumns[columnIndex + i];
|
|
21
18
|
// If the column is the last one or doesn't have a default width, it should be limited to the remaining space
|
|
22
|
-
const width = getColumnWidth(defaultWidth || flexibleColumnWidth
|
|
19
|
+
const width = getColumnWidth(defaultWidth || flexibleColumnWidth);
|
|
23
20
|
columnWidth += width;
|
|
24
21
|
}
|
|
25
22
|
return columnWidth;
|
|
26
|
-
}, [flexibleColumnWidth, listOfDefaultWidthColumns
|
|
23
|
+
}, [flexibleColumnWidth, listOfDefaultWidthColumns]);
|
|
27
24
|
const getCellParams = useCallback((columnIndex, colspan) => {
|
|
28
25
|
const width = getColWidth(columnIndex, colspan);
|
|
29
26
|
const defaultWidth = listOfDefaultWidthColumns[columnIndex];
|
|
30
|
-
const maxWidth = listOfMaxWidthColumns[columnIndex];
|
|
31
27
|
const limited = !!defaultWidth && defaultWidth > 0;
|
|
32
28
|
const isFirst = columnIndex === 0;
|
|
33
29
|
const isLast = columnIndex === listOfDefaultWidthColumns.length - 1;
|
|
34
|
-
return { limited, isFirst, isLast, width
|
|
35
|
-
}, [getColWidth, listOfDefaultWidthColumns
|
|
30
|
+
return { limited, isFirst, isLast, width };
|
|
31
|
+
}, [getColWidth, listOfDefaultWidthColumns]);
|
|
36
32
|
const mainRowId = useId();
|
|
37
33
|
const renderCells = useCallback((rowEntity, isNested) => columns.reduce((acc, column, index) => {
|
|
38
34
|
const colspanFn = column.colspan;
|
|
39
35
|
let colspan = colspanFn ? (typeof colspanFn === "function" ? colspanFn(rowEntity) : colspanFn) : undefined;
|
|
40
36
|
colspan = colspan && colspan > 1 ? colspan : undefined;
|
|
41
|
-
const { limited, width
|
|
37
|
+
const { limited, width } = getCellParams(index, colspan);
|
|
42
38
|
if (acc.colspan > 0) {
|
|
43
39
|
acc.colspan--;
|
|
44
40
|
return acc;
|
|
@@ -53,7 +49,7 @@ const Row = ({ id, entity, columns, visibleRows, flexibleColumnWidth, isLastRow,
|
|
|
53
49
|
? column.columnComponent.renderNested.bind(column.columnComponent)
|
|
54
50
|
: column.columnComponent.render.bind(column.columnComponent))
|
|
55
51
|
: column.columnComponent.render.bind(column.columnComponent);
|
|
56
|
-
acc.cells.push(_jsx(DataGridCell, { render: e => renderFn(e, isNested), renderPlaceholder: column.meta.renderPlaceholder, renderWrappers: renderWrappers, defaultValue: column.meta.defaultValue, entity: rowEntity, index: index, limited: limited, visibleOnHover: column.meta.visibleOnHover, width: column.meta.visibleOnHover ? 0 : width,
|
|
52
|
+
acc.cells.push(_jsx(DataGridCell, { render: e => renderFn(e, isNested), renderPlaceholder: column.meta.renderPlaceholder, renderWrappers: renderWrappers, defaultValue: column.meta.defaultValue, entity: rowEntity, index: index, limited: limited, visibleOnHover: column.meta.visibleOnHover, width: column.meta.visibleOnHover ? 0 : width, isVisible: isVisible, colspan: colspan, onClick: !isNested && onExpandedChange ? () => onExpandedChange(!expanded) : onClick ? () => onClick(rowEntity.id) : undefined, isActive: isActive, className: isNested ? "zen-data-grid__row-cell--nested" : "" }, `${rowEntity.id}_${column.name}`));
|
|
57
53
|
return acc;
|
|
58
54
|
}, { cells: [], colspan: 0 }).cells, [columns, expanded, getCellParams, isVisible, onExpandedChange, isActive, onClick]);
|
|
59
55
|
const cells = useMemo(() => renderCells(entity, false), [entity, renderCells]);
|
|
@@ -18,7 +18,6 @@ const SubColumnsList = ({ title, columns, settings, disabledColumns, onChange, s
|
|
|
18
18
|
showCheckbox: true,
|
|
19
19
|
children: c.title
|
|
20
20
|
})), [columns, disabledColumns, sortColumnsInt]);
|
|
21
|
-
const allDisabled = useMemo(() => items.every(item => item.disabled), [items]);
|
|
22
21
|
const state = columns.reduce((res, c) => {
|
|
23
22
|
res.set(c.id, settings.get(c.name) !== false ? CheckboxState.On : CheckboxState.Off);
|
|
24
23
|
return res;
|
|
@@ -31,7 +30,7 @@ const SubColumnsList = ({ title, columns, settings, disabledColumns, onChange, s
|
|
|
31
30
|
});
|
|
32
31
|
onChange && onChange(newSettings);
|
|
33
32
|
}, [columns, settings, onChange]);
|
|
34
|
-
const list = useMemo(() =>
|
|
33
|
+
const list = useMemo(() => _jsx(SelectList, { id: id, items: items, value: state, title: title || "", multiselect: true, showCheckbox: true, onChange: onChangeItem }), [id, items, state, title, onChangeItem]);
|
|
35
34
|
if (!title) {
|
|
36
35
|
return list;
|
|
37
36
|
}
|
|
@@ -7,10 +7,6 @@ import { DeviceType } from "../../../../commonHelpers/hooks/deviceType";
|
|
|
7
7
|
type TBulkAction = IBulkActionLink | IBulkActionButton;
|
|
8
8
|
export interface IBulkActionsProps extends IZenComponentProps {
|
|
9
9
|
selected: number;
|
|
10
|
-
/**
|
|
11
|
-
* When `true`, displays "All selected" instead of a count, and enables action buttons
|
|
12
|
-
* even when `selected` is 0 (i.e., cross-page "select all" is active).
|
|
13
|
-
*/
|
|
14
10
|
allSelected?: boolean;
|
|
15
11
|
onClearSelection: () => void;
|
|
16
12
|
onSelectAll?: () => void;
|
|
@@ -7,5 +7,5 @@ export const parseLabel = (option, dateFormat, translate, toLocalFn) => {
|
|
|
7
7
|
localeFrom.getFullYear() === localeTo.getFullYear()) {
|
|
8
8
|
return formatDate(localeFrom, dateFormat, translate);
|
|
9
9
|
}
|
|
10
|
-
return `${formatDate(localeFrom, dateFormat, translate)}
|
|
10
|
+
return `${formatDate(localeFrom, dateFormat, translate)} - ${formatDate(localeTo, dateFormat, translate)}`;
|
|
11
11
|
};
|
package/esm/dropdown/dropdown.js
CHANGED
|
@@ -20,4 +20,4 @@ export const Dropdown = (_a) => {
|
|
|
20
20
|
var props = __rest(_a, []);
|
|
21
21
|
return _jsx(DropDownFormField, Object.assign({}, props));
|
|
22
22
|
};
|
|
23
|
-
export const TRANSLATIONS = ["Filter by group", "Open filter", "Clear search", "Select all", "Clear", "Back", "No data"];
|
|
23
|
+
export const 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
|
-
isAllSelected
|
|
17
|
-
isSelectAllActive?: 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,
|
|
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 {};
|
|
@@ -148,6 +148,33 @@ injectString("zh-Hans", "Apply", "\u5E94\u7528");
|
|
|
148
148
|
injectString("zh-TW", "Apply", "\u5957\u7528");
|
|
149
149
|
injectString("ro-RO", "Apply", "Aplica\u021Bi");
|
|
150
150
|
injectString("ar-SA", "Apply", "\u062A\u0637\u0628\u064A\u0642");
|
|
151
|
+
injectString("cs", "Deselect all", "Zru\u0161it v\xFDb\u011Br v\u0161ech");
|
|
152
|
+
injectString("da-DK", "Deselect all", "Frav\xE6lg alle");
|
|
153
|
+
injectString("de", "Deselect all", "Auswahl f\xFCr alle aufheben");
|
|
154
|
+
injectString("en", "Deselect all", "Deselect all");
|
|
155
|
+
injectString("es", "Deselect all", "Deseleccionar todo");
|
|
156
|
+
injectString("fi-FI", "Deselect all", "Poista kaikki valinnat");
|
|
157
|
+
injectString("fr", "Deselect all", "D\xE9s\xE9lectionner tout");
|
|
158
|
+
injectString("fr-FR", "Deselect all", "D\xE9s\xE9lectionner tout");
|
|
159
|
+
injectString("hu-HU", "Deselect all", "Ne v\xE1lassz ki semmit.");
|
|
160
|
+
injectString("id", "Deselect all", "Batalkan pilih semua");
|
|
161
|
+
injectString("it", "Deselect all", "Deselezionare tutto");
|
|
162
|
+
injectString("ja", "Deselect all", "\u3059\u3079\u3066\u3092\u9078\u629E\u89E3\u9664");
|
|
163
|
+
injectString("ko-KR", "Deselect all", "\uBAA8\uB450 \uC120\uD0DD \uCDE8\uC18C");
|
|
164
|
+
injectString("ms", "Deselect all", "Nyahpilih semua");
|
|
165
|
+
injectString("nb-NO", "Deselect all", "Fjern alle valg");
|
|
166
|
+
injectString("nl", "Deselect all", "Alles deselecteren");
|
|
167
|
+
injectString("pl", "Deselect all", "Usu\u0144 wyb\xF3r wszystkich");
|
|
168
|
+
injectString("pt-BR", "Deselect all", "Desmarcar tudo");
|
|
169
|
+
injectString("pt-PT", "Deselect all", "Desmarcar tudo");
|
|
170
|
+
injectString("sk-SK", "Deselect all", "Zru\u0161 v\xFDber v\u0161etk\xFDch.");
|
|
171
|
+
injectString("sv", "Deselect all", "Avmarkera alla");
|
|
172
|
+
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");
|
|
173
|
+
injectString("tr", "Deselect all", "T\xFCm\xFCn\xFCn se\xE7imini iptal et");
|
|
174
|
+
injectString("zh-Hans", "Deselect all", "\u53D6\u6D88\u5168\u9009");
|
|
175
|
+
injectString("zh-TW", "Deselect all", "\u53D6\u6D88\u5168\u9078");
|
|
176
|
+
injectString("ro-RO", "Deselect all", "Deselecta\u021Bi tot");
|
|
177
|
+
injectString("ar-SA", "Deselect all", "\u0625\u0644\u063A\u0627\u0621 \u062A\u062D\u062F\u064A\u062F \u0627\u0644\u0643\u0644");
|
|
151
178
|
injectString("cs", "Select all", "Vybrat v\u0161e");
|
|
152
179
|
injectString("da-DK", "Select all", "V\xE6lg alle");
|
|
153
180
|
injectString("de", "Select all", "Alle ausw\xE4hlen");
|
|
@@ -292,7 +319,7 @@ export const DropdownList = ({
|
|
|
292
319
|
onSelect,
|
|
293
320
|
onSingleSelect,
|
|
294
321
|
listData,
|
|
295
|
-
|
|
322
|
+
isAllSelected,
|
|
296
323
|
backButtonName,
|
|
297
324
|
width,
|
|
298
325
|
minWidth,
|
|
@@ -321,7 +348,7 @@ export const DropdownList = ({
|
|
|
321
348
|
const internalListId = useId();
|
|
322
349
|
const selectListId = listId || internalListId;
|
|
323
350
|
const handleSelectAllClick = () => {
|
|
324
|
-
onSelectAllClick(
|
|
351
|
+
onSelectAllClick(isAllSelected);
|
|
325
352
|
};
|
|
326
353
|
const handleBackButtonKeyDown = useCallback(event => {
|
|
327
354
|
if (event.key === "ArrowLeft") {
|
|
@@ -349,14 +376,13 @@ export const DropdownList = ({
|
|
|
349
376
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
350
377
|
forceSelection ? onSingleSelect(false, newActiveEl || activeValue) : onSingleSelect(false, newActiveEl);
|
|
351
378
|
}, [activeValue, forceSelection, onSingleSelect]);
|
|
352
|
-
const selectButtonLabel = translate("Select all");
|
|
353
|
-
const getActionButton = (label, title, icon, isDisabled, clickHandler, size, onKeyDown
|
|
379
|
+
const selectButtonLabel = isAllSelected ? translate("Deselect all") : translate("Select all");
|
|
380
|
+
const getActionButton = (label, title, icon, isDisabled, clickHandler, size, onKeyDown) => _jsx("button", {
|
|
354
381
|
type: "button",
|
|
355
382
|
disabled: isDisabled,
|
|
356
383
|
onClick: clickHandler,
|
|
357
384
|
onKeyDown: onKeyDown,
|
|
358
|
-
"
|
|
359
|
-
className: 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" : ""]),
|
|
385
|
+
className: "zen-dropdown-list__item zen-dropdown-list__item--interactive zen-dropdown-list__action-button zen-dropdown-list__action-button-back",
|
|
360
386
|
title: title,
|
|
361
387
|
children: _jsxs(_Fragment, {
|
|
362
388
|
children: [React.createElement(icon, {
|
|
@@ -430,7 +456,7 @@ export const DropdownList = ({
|
|
|
430
456
|
}) : null, backButtonName ? _jsx("div", {
|
|
431
457
|
className: "zen-dropdown-list__item-wrapper",
|
|
432
458
|
children: getActionButton(backButtonName, translate("Back"), IconBackArrow, false, onBackButtonClick, "large", handleBackButtonKeyDown)
|
|
433
|
-
}) : null, hasSelectAllButton ? getActionButton(selectButtonLabel, selectButtonLabel, IconCheckRadio, !!isSelectAllButtonDisable, handleSelectAllClick, isDrive ? "huger" : "huge"
|
|
459
|
+
}) : null, hasSelectAllButton ? getActionButton(selectButtonLabel, selectButtonLabel, IconCheckRadio, !!isSelectAllButtonDisable, handleSelectAllClick, isDrive ? "huger" : "huge") : null, listDataComponent, isWithFooter ? _jsxs("div", {
|
|
434
460
|
className: "zen-dropdown-list__footer",
|
|
435
461
|
children: [_jsx(Button, {
|
|
436
462
|
onClick: isMultiselect ? onClearClick : handleClearClick,
|
|
@@ -458,4 +484,4 @@ export const DropdownList = ({
|
|
|
458
484
|
}) : null]
|
|
459
485
|
}));
|
|
460
486
|
};
|
|
461
|
-
export const TRANSLATIONS = ["Select all", "Clear", "Back", "No data"];
|
|
487
|
+
export const TRANSLATIONS = ["Select all", "Deselect all", "Clear", "Back", "No data"];
|
|
@@ -8,7 +8,7 @@ import { getInitialState, stateReducer, ROOT_GROUP_ID } from "./stateReducer/sta
|
|
|
8
8
|
import { StateActionType } from "./stateReducer/stateActionType";
|
|
9
9
|
import { FOCUSABLE_SELECTOR } from "../utils/focusableSelector";
|
|
10
10
|
import { useEscape } from "../commonHelpers/hooks/useEscape";
|
|
11
|
-
import { checkIsDataProblem, compareObjectsArrays, compareStringsArrays, createListDataOptions, getListDataWithDisabled, getSelectedCount, getStringFromAllSelected, getStringFromSelected, isAllChildrenSelected, isAllItemsHasOneParent, isEveryItemSelected, prepareSelectedIdsToItems, sortDropdownItemArray } from "./dropdownHelper";
|
|
11
|
+
import { checkIsDataProblem, compareObjectsArrays, compareStringsArrays, createListDataOptions, getDataForChange, getListDataWithDisabled, getSelectedCount, getStringFromAllSelected, getStringFromSelected, isAllChildrenSelected, isAllItemsHasOneParent, isEveryItemSelected, prepareSelectedIdsToItems, sortDropdownItemArray } from "./dropdownHelper";
|
|
12
12
|
import { DropdownTrigger } from "./dropdownTrigger";
|
|
13
13
|
import { isFocusable } from "../dialog/dialogHelpers";
|
|
14
14
|
import { useLanguage } from "../utils/localization/useLanguage";
|
|
@@ -391,6 +391,23 @@ export const DropdownRaw = props => {
|
|
|
391
391
|
payload: state.currentId || state.rootId
|
|
392
392
|
});
|
|
393
393
|
}, [isFullSelectionMode, state.currentId, state.rootId]);
|
|
394
|
+
const handleSelectAllInSearch = useCallback(isAllSelect => {
|
|
395
|
+
if (isFullSelectionMode && state.isAllSelected) {
|
|
396
|
+
dispatchState({
|
|
397
|
+
type: StateActionType.DeselectItemsFromAllSelected,
|
|
398
|
+
payload: undefined
|
|
399
|
+
});
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
const dataForChange = getDataForChange(getListDataWithDisabled(state.listData, state.isNestedList), state.selectedIds, isAllSelect);
|
|
403
|
+
dispatchState({
|
|
404
|
+
type: StateActionType.ChangeBulkSelection,
|
|
405
|
+
payload: {
|
|
406
|
+
itemsIds: dataForChange,
|
|
407
|
+
value: !isAllSelect
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}, [isFullSelectionMode, state.isAllSelected, state.listData, state.isNestedList, state.selectedIds]);
|
|
394
411
|
const handleClearClick = useCallback(() => {
|
|
395
412
|
var _a, _b;
|
|
396
413
|
dispatchState({
|
|
@@ -526,18 +543,12 @@ export const DropdownRaw = props => {
|
|
|
526
543
|
}, [setChecked, setSearch]);
|
|
527
544
|
const debouncedGetData = useDebounce((signal, searchValue, isChecked) => getData ? (isCheckboxMode ? getData(signal, searchValue, isChecked) : getData(signal, searchValue)).then(dta => handleData(dta, searchValue)).catch(handleError) : customGetData(searchValue).then(dta => handleData(dta, searchValue)).catch(handleError), 200);
|
|
528
545
|
const controlData = useCallback((signal, searchValue, isChecked) => {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
type: StateActionType.ShowWaiting,
|
|
536
|
-
payload: undefined
|
|
537
|
-
});
|
|
538
|
-
debouncedGetData(signal, searchValue, isChecked);
|
|
539
|
-
}
|
|
540
|
-
}, [debouncedGetData, handleData, handleQueryMode, isQueryMode, getData, dataItems]);
|
|
546
|
+
!isQueryMode && dispatchState({
|
|
547
|
+
type: StateActionType.ShowWaiting,
|
|
548
|
+
payload: undefined
|
|
549
|
+
});
|
|
550
|
+
isQueryMode ? handleQueryMode(searchValue, isChecked) : debouncedGetData(signal, searchValue, isChecked);
|
|
551
|
+
}, [debouncedGetData, handleQueryMode, isQueryMode]);
|
|
541
552
|
useEffect(() => {
|
|
542
553
|
var _a;
|
|
543
554
|
const timeoutId = (_a = zen.setTimeout) === null || _a === void 0 ? void 0 : _a.call(zen, () => {
|
|
@@ -843,14 +854,13 @@ export const DropdownRaw = props => {
|
|
|
843
854
|
});
|
|
844
855
|
}
|
|
845
856
|
if (state.showList) {
|
|
846
|
-
const isSearchMode =
|
|
857
|
+
const isSearchMode = state.inputValue && !state.currentId;
|
|
847
858
|
const currentListData = createListDataOptions(state, translate, isSearchMode ? sortDropdownItemArray(state.listData, sortFn).slice(0, listLimit).filter(el => el.id !== state.rootId) :
|
|
848
859
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
849
860
|
sortDropdownItemArray(((_b = state.groupsMap[state.currentId || state.rootId]) === null || _b === void 0 ? void 0 : _b.children) || [], sortFn).slice(0, listLimit) || [], multiselect, currentAllSelected);
|
|
850
|
-
const selectAllActiveForCurrentLevel = state.selectAllActiveForId === (state.currentId || state.rootId);
|
|
851
861
|
return _jsx(DropdownList, {
|
|
852
862
|
onBackButtonClick: handleBackButtonClick,
|
|
853
|
-
onSelectAllClick: handleSelectAllClick,
|
|
863
|
+
onSelectAllClick: isSearchMode ? handleSelectAllInSearch : handleSelectAllClick,
|
|
854
864
|
onClearClick: handleClearClick,
|
|
855
865
|
onCancelClick: handleCancelClick,
|
|
856
866
|
onApplyClick: handleApplyClick,
|
|
@@ -861,7 +871,6 @@ export const DropdownRaw = props => {
|
|
|
861
871
|
backButtonName: state.currentId && state.groupsMap[state.currentId] ? getGroupDescription(state.groupsMap[state.currentId], translate) : undefined,
|
|
862
872
|
filterName: isMobile ? undefined : filterName,
|
|
863
873
|
isAllSelected: currentAllSelected ? currentAllSelected : isSearchMode ? isEveryItemSelected(getListDataWithDisabled(state.listData, state.isNestedList), state.selectedIds) : currentAllSelected === undefined ? isAllChildrenSelected(state, state.currentId || state.rootId) : false,
|
|
864
|
-
isSelectAllActive: isFullSelectionMode ? currentAllSelected : selectAllActiveForCurrentLevel,
|
|
865
874
|
isMultiselect: multiselect,
|
|
866
875
|
forceSelection: forceSelection,
|
|
867
876
|
listData: currentListData,
|
|
@@ -870,7 +879,7 @@ export const DropdownRaw = props => {
|
|
|
870
879
|
hasSelectAllButton: selectAllButton && multiselect,
|
|
871
880
|
hasApplyButton: hasApplyButton,
|
|
872
881
|
isApplyDisabled: memoizedIsApplyButtonDisabled,
|
|
873
|
-
isSelectAllButtonDisable: currentListData.length === 0 || isSearchMode && state.isNestedList && 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)),
|
|
882
|
+
isSelectAllButtonDisable: currentListData.length === 0 || isSearchMode !== "" && state.isNestedList && 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)),
|
|
874
883
|
isClearButtonDisabled: memoizedIsClearButtonDisabled,
|
|
875
884
|
isWithFooter: memoizedWithFooter && !isMobile,
|
|
876
885
|
isMobile: isMobile,
|
|
@@ -882,7 +891,7 @@ export const DropdownRaw = props => {
|
|
|
882
891
|
});
|
|
883
892
|
}
|
|
884
893
|
return null;
|
|
885
|
-
}, [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, handleSelectAllClick, handleSelect, handleChangeCurrentId, handleSingleSelection, isMobile, filterName, forceSelection, width, selectAllButton, memoizedIsApplyButtonDisabled, memoizedIsClearButtonDisabled, isCheckboxMode, handleCheckboxChange, checkboxLabel, selectListId
|
|
894
|
+
}, [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]);
|
|
886
895
|
const currentStringFromSelected = isFullSelectionMode && hasApplyButton && state.globalIsAllSelected || isFullSelectionMode && !hasApplyButton && state.isAllSelected ? getStringFromAllSelected(state.groupsMap, translate, state.rootId) : getStringFromSelected(hasApplyButton ? state.globalSelectedIds : state.selectedIds, state.groupsMapSelected, translate, state.rootId);
|
|
887
896
|
const memoizedCurrentSelection = useMemo(() => showSelection && !state.inputValue ? currentStringFromSelected : "", [showSelection, state.inputValue, currentStringFromSelected]);
|
|
888
897
|
const parentTriggerWidth = ((_b = comboboxRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width) || 420;
|
|
@@ -979,4 +988,4 @@ export const DropdownRaw = props => {
|
|
|
979
988
|
});
|
|
980
989
|
};
|
|
981
990
|
DropdownRaw.displayName = "DropdownRaw";
|
|
982
|
-
export const TRANSLATIONS = ["Filter by group", "Open filter", "Clear search", "Select all", "Clear", "Back", "No data"];
|
|
991
|
+
export const TRANSLATIONS = ["Filter by group", "Open filter", "Clear search", "Select all", "Deselect all", "Clear", "Back", "No data"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StateActionType } from "./stateActionType";
|
|
2
|
-
import { getChildList,
|
|
2
|
+
import { getChildList, updateAllSelectedStateValueBasedOnTotalSelected, getRootId } from "./stateReducerHelper";
|
|
3
3
|
import { createGroupsMap } from "../../groupsFilterRaw/groupsFilterHelper";
|
|
4
4
|
export const ROOT_GROUP_ID = "zen_dropdown_root_group_id";
|
|
5
5
|
export const getInitialState = (isFullSelectionMode, comboItems, selection, listLimit, defaultValue, isAllSelected, defaultValueIsAllSelected, isChecked, defaultValueIsChecked, firstParentNodeIsVisible) => {
|
|
@@ -73,12 +73,10 @@ export function stateReducer(state, action) {
|
|
|
73
73
|
}
|
|
74
74
|
const isCurrentListNested = Object.keys(updatedGroupsMap).length > 0 &&
|
|
75
75
|
(updatedGroupsMap[ROOT_GROUP_ID].children || []).some(el => el.children && el.children.length);
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const selectedInNewMap = state.selectedIds.filter(id => id in updatedGroupsMap).length;
|
|
79
|
-
const newIsAllSelected = computeIsAllSelected(state.isAllSelected, state.isFullSelectionMode, newResultsExceedListLimit, groupsMapLength, selectedInNewMap);
|
|
76
|
+
state.groupsMap = updatedGroupsMap;
|
|
77
|
+
const additionalStateUpdates = updateAllSelectedStateValueBasedOnTotalSelected(state, state.selectedIds.length - newNamelessIds.size);
|
|
80
78
|
const rootId = getRootId(updatedGroupsMap, ROOT_GROUP_ID, state.firstParentNodeIsVisible);
|
|
81
|
-
return Object.assign(Object.assign({}, state), {
|
|
79
|
+
return Object.assign(Object.assign(Object.assign({}, state), { rootId: rootId || ROOT_GROUP_ID, namelessIds: newNamelessIds, isNestedList: state.isNestedList ? state.isNestedList : isCurrentListNested, resultsExceedListLimit: Object.keys(updatedGroupsMap).length - 1 >= state.listLimit }), additionalStateUpdates);
|
|
82
80
|
}
|
|
83
81
|
case StateActionType.SetListData: {
|
|
84
82
|
state.selectedIds.forEach(id => {
|
|
@@ -103,9 +101,9 @@ export function stateReducer(state, action) {
|
|
|
103
101
|
case StateActionType.SetIsOpenCombo:
|
|
104
102
|
return Object.assign(Object.assign({}, state), { isOpenCombo: payload });
|
|
105
103
|
case StateActionType.ResetSelection:
|
|
106
|
-
return Object.assign(Object.assign({}, state), { selectedIds: [...state.defaultValue], isAllSelected: state.defaultValueIsAllSelected, isChecked: typeof state.isChecked === "boolean" ? state.defaultValueIsChecked || false : undefined
|
|
104
|
+
return Object.assign(Object.assign({}, state), { selectedIds: [...state.defaultValue], isAllSelected: state.defaultValueIsAllSelected, isChecked: typeof state.isChecked === "boolean" ? state.defaultValueIsChecked || false : undefined });
|
|
107
105
|
case StateActionType.ResetStateToGlobal:
|
|
108
|
-
return Object.assign(Object.assign({}, state), { selectedIds: [...state.globalSelectedIds], isAllSelected: state.globalIsAllSelected, isChecked: state.globalIsChecked
|
|
106
|
+
return Object.assign(Object.assign({}, state), { selectedIds: [...state.globalSelectedIds], isAllSelected: state.globalIsAllSelected, isChecked: state.globalIsChecked });
|
|
109
107
|
case StateActionType.NothingToShow:
|
|
110
108
|
return Object.assign(Object.assign({}, state), { showWaiting: false, showEmptyList: false, showList: false });
|
|
111
109
|
case StateActionType.Show:
|
|
@@ -221,7 +219,8 @@ export function stateReducer(state, action) {
|
|
|
221
219
|
state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
222
220
|
}
|
|
223
221
|
});
|
|
224
|
-
|
|
222
|
+
const additionalStateUpdates = updateAllSelectedStateValueBasedOnTotalSelected(state, currentSelectedIds.size);
|
|
223
|
+
return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds) }), additionalStateUpdates);
|
|
225
224
|
}
|
|
226
225
|
case StateActionType.ChangeBulkSelection: {
|
|
227
226
|
const { itemsIds, value } = payload;
|
|
@@ -254,7 +253,8 @@ export function stateReducer(state, action) {
|
|
|
254
253
|
state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
255
254
|
}
|
|
256
255
|
});
|
|
257
|
-
|
|
256
|
+
const additionalStateUpdates = updateAllSelectedStateValueBasedOnTotalSelected(state, currentSelectedIds.size);
|
|
257
|
+
return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: Array.from(currentSelectedIds) }), additionalStateUpdates);
|
|
258
258
|
}
|
|
259
259
|
case StateActionType.SelectAllChildren: {
|
|
260
260
|
const currentEl = state.groupsMap[payload];
|
|
@@ -291,7 +291,7 @@ export function stateReducer(state, action) {
|
|
|
291
291
|
state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
292
292
|
}
|
|
293
293
|
});
|
|
294
|
-
return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected)
|
|
294
|
+
return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected) });
|
|
295
295
|
}
|
|
296
296
|
case StateActionType.DeselectItemsFromAllSelected: {
|
|
297
297
|
const currentEl = state.groupsMap[state.rootId];
|
|
@@ -315,7 +315,7 @@ export function stateReducer(state, action) {
|
|
|
315
315
|
state.groupsMapSelected.set(id, Object.assign(Object.assign({ id }, (item.name ? { name: item.name } : {})), (item.color ? { color: item.color } : {})));
|
|
316
316
|
}
|
|
317
317
|
});
|
|
318
|
-
return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected), isAllSelected: state.isFullSelectionMode ? false : undefined
|
|
318
|
+
return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected), isAllSelected: state.isFullSelectionMode ? false : undefined });
|
|
319
319
|
}
|
|
320
320
|
case StateActionType.ToggleValueForAllSelected: {
|
|
321
321
|
const currentEl = state.groupsMap[state.rootId];
|
|
@@ -334,7 +334,8 @@ export function stateReducer(state, action) {
|
|
|
334
334
|
}
|
|
335
335
|
});
|
|
336
336
|
const updatedIsAllSelectedValue = state.isFullSelectionMode ? !state.isAllSelected : undefined;
|
|
337
|
-
|
|
337
|
+
const additionalStateUpdates = updateAllSelectedStateValueBasedOnTotalSelected(state, newSelected.size);
|
|
338
|
+
return Object.assign(Object.assign(Object.assign({}, state), { selectedIds: state.isAllSelected ? Array.from(newSelected) : [], isAllSelected: updatedIsAllSelectedValue }), additionalStateUpdates);
|
|
338
339
|
}
|
|
339
340
|
case StateActionType.DeselectAllChildren: {
|
|
340
341
|
const childrenForDeselect = [];
|
|
@@ -346,7 +347,7 @@ export function stateReducer(state, action) {
|
|
|
346
347
|
});
|
|
347
348
|
const newSelected = new Set(state.selectedIds);
|
|
348
349
|
childrenForDeselect.forEach(childId => newSelected.delete(childId));
|
|
349
|
-
return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected)
|
|
350
|
+
return Object.assign(Object.assign({}, state), { selectedIds: Array.from(newSelected) });
|
|
350
351
|
}
|
|
351
352
|
case StateActionType.SetFirstParentNodeIsVisible: {
|
|
352
353
|
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
|
|
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;
|
|
@@ -13,9 +13,16 @@ export function getChildList(childArr) {
|
|
|
13
13
|
});
|
|
14
14
|
return list;
|
|
15
15
|
}
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export const updateAllSelectedStateValueBasedOnTotalSelected = (state, totalSelected) => {
|
|
17
|
+
const additionalStateUpdates = {};
|
|
18
|
+
const groupsMapLength = Object.keys(state.groupsMap).length - 1;
|
|
19
|
+
if (!state.resultsExceedListLimit && !state.isAllSelected && state.isFullSelectionMode && groupsMapLength > 0) {
|
|
20
|
+
if (totalSelected >= groupsMapLength) {
|
|
21
|
+
additionalStateUpdates.isAllSelected = true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return additionalStateUpdates;
|
|
25
|
+
};
|
|
19
26
|
export const getRootId = (groupsMap, rootIdKey, firstParentNodeIsVisible) => {
|
|
20
27
|
var _a;
|
|
21
28
|
if (Object.keys(groupsMap).length === 0) {
|
|
@@ -4,10 +4,8 @@ import { ButtonIconPosition, TextIconButton } from "../../textIconButton/textIco
|
|
|
4
4
|
import { classNames } from "../../commonHelpers/classNames/classNames";
|
|
5
5
|
import { useEffect, useRef, useState, Children, cloneElement, useCallback } from "react";
|
|
6
6
|
import { IconChevronRight } from "../../icons/iconChevronRight";
|
|
7
|
-
import { IconChevronLeft } from "../../icons/iconChevronLeft";
|
|
8
7
|
import { useLanguage } from "../../utils/localization/useLanguage";
|
|
9
8
|
import { useDriveClassName } from "../../utils/theme/useDriveClassName";
|
|
10
|
-
import { useIsRTL } from "../../utils/localization/useIsRTL";
|
|
11
9
|
import { zen } from "../../utils/zen";
|
|
12
10
|
injectString("cs", "Scroll left", "P\u0159ej\xEDt doleva");
|
|
13
11
|
injectString("da-DK", "Scroll left", "Rul til venstre");
|
|
@@ -78,10 +76,6 @@ const getScrollButtonType = element => {
|
|
|
78
76
|
}
|
|
79
77
|
return "start";
|
|
80
78
|
};
|
|
81
|
-
const getScrollIcons = isRTL => ({
|
|
82
|
-
start: isRTL ? IconChevronRight : IconChevronLeft,
|
|
83
|
-
end: isRTL ? IconChevronLeft : IconChevronRight
|
|
84
|
-
});
|
|
85
79
|
export const FiltersContainer = ({
|
|
86
80
|
className,
|
|
87
81
|
children
|
|
@@ -91,11 +85,6 @@ export const FiltersContainer = ({
|
|
|
91
85
|
const {
|
|
92
86
|
translate
|
|
93
87
|
} = useLanguage();
|
|
94
|
-
const isRTL = useIsRTL();
|
|
95
|
-
const {
|
|
96
|
-
start: startScrollIcon,
|
|
97
|
-
end: endScrollIcon
|
|
98
|
-
} = getScrollIcons(isRTL);
|
|
99
88
|
const gradientClass = "zen-filters-toolbar__gradient";
|
|
100
89
|
const scrollerClass = "zen-filters-toolbar__scroller";
|
|
101
90
|
const driveClassNameScroller = useDriveClassName(scrollerClass);
|
|
@@ -208,9 +197,10 @@ export const FiltersContainer = ({
|
|
|
208
197
|
}), _jsx(TextIconButton, {
|
|
209
198
|
title: translate("Scroll left"),
|
|
210
199
|
className: classNames(["zen-filters-toolbar__scroller", driveClassNameScroller || "", "zen-filters-toolbar__start", showLeft ? `${scrollerClass}--visible` : "", isHiddenDisplay.left ? `${scrollerClass}--hidden` : ""]),
|
|
211
|
-
icon:
|
|
200
|
+
icon: IconChevronRight,
|
|
212
201
|
iconPosition: ButtonIconPosition.Start,
|
|
213
|
-
onClick: handleScrollButtonClick(-scrollableStep)
|
|
202
|
+
onClick: handleScrollButtonClick(-scrollableStep),
|
|
203
|
+
iconClasses: "zen-filters-toolbar__start-icon"
|
|
214
204
|
}), _jsx("div", {
|
|
215
205
|
ref: scrollableRef,
|
|
216
206
|
className: classNames(["zen-filters-toolbar__scrollable", !isHiddenDisplay.left ? "has-left-scroller" : "", !isHiddenDisplay.right ? "has-right-scroller" : ""]),
|
|
@@ -223,7 +213,7 @@ export const FiltersContainer = ({
|
|
|
223
213
|
}), _jsx(TextIconButton, {
|
|
224
214
|
title: translate("Scroll right"),
|
|
225
215
|
className: classNames([scrollerClass, driveClassNameScroller || "", "zen-filters-toolbar__end", showRight ? `${scrollerClass}--visible` : "", isHiddenDisplay.right ? `${scrollerClass}--hidden` : ""]),
|
|
226
|
-
icon:
|
|
216
|
+
icon: IconChevronRight,
|
|
227
217
|
onClick: handleScrollButtonClick(scrollableStep),
|
|
228
218
|
iconPosition: ButtonIconPosition.End
|
|
229
219
|
})]
|
|
@@ -63,7 +63,6 @@ export const RadioGroupRaw = (props) => {
|
|
|
63
63
|
"zen-radio-group__item",
|
|
64
64
|
wrappedInLabel ? "zen-radio-group__item--no-paddings" : "",
|
|
65
65
|
type === "interactive" ? "zen-radio--interactive" : "",
|
|
66
|
-
size === "small" ? "zen-radio-group__item--small" : ""
|
|
67
|
-
direction === "horizontal" ? "zen-radio--align-start" : ""
|
|
66
|
+
size === "small" ? "zen-radio-group__item--small" : ""
|
|
68
67
|
]), key: ind, checked: item.value === value, disabled: disabled ? disabled : item.disabled, name: name, reverse: reverse, fullWidth: fullWidth, value: item.value, onChange: onChangeInner, wrappedInLabel: wrappedInLabel, tabIndex: selectItemOnFocus || disabled || item.disabled ? undefined : ind === focusedIndex ? 0 : -1, ref: selectItemOnFocus ? undefined : ind === focusedIndex ? focusElementRef : undefined, role: itemRole }), item.children) }, `${ind}-li`))) })) }));
|
|
69
68
|
};
|
|
@@ -5,7 +5,7 @@ export declare const getItemIdByIndex: (state: Map<string, CheckboxState>, index
|
|
|
5
5
|
export declare const getItemIndexById: (state: Map<string, CheckboxState>, id: string) => number;
|
|
6
6
|
export declare const updateItemState: (initialState: Map<string, CheckboxState>, multiselect: boolean, updatedId: string, newState: CheckboxState) => [Map<string, CheckboxState>, boolean];
|
|
7
7
|
export declare const searchItemIndex: (items: ISelectListItem[], searchStr: string) => number;
|
|
8
|
-
export declare const getFirstIndex: (items: ISelectListItem[]) =>
|
|
8
|
+
export declare const getFirstIndex: (items: ISelectListItem[]) => 0 | -1;
|
|
9
9
|
export declare const getLastIndex: (items: ISelectListItem[]) => number;
|
|
10
10
|
export declare const getNextIndex: (currIndex: number, items: ISelectListItem[]) => number;
|
|
11
11
|
export declare const getPrevIndex: (currIndex: number, items: ISelectListItem[]) => number;
|