@geotab/zenith 1.26.1-beta.1 → 1.26.1-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.
@@ -13,6 +13,7 @@ export interface IBulkActionsProps extends IZenComponentProps {
13
13
  onSelectAll?: () => void;
14
14
  gridType?: DeviceType;
15
15
  children?: ReactElement<TBulkAction> | null | (ReactElement<TBulkAction> | null)[];
16
+ turnOffSelectAll?: boolean;
16
17
  /**
17
18
  * @deprecated
18
19
  * @param translate - will be removed in the next major release
@@ -15,7 +15,7 @@ const useResizeObserver_1 = require("../../../../commonHelpers/hooks/useResizeOb
15
15
  const menu_1 = require("../../../../menu/menu");
16
16
  const iconDotVertical_1 = require("../../../../icons/iconDotVertical");
17
17
  const button_1 = require("../../../../button/button");
18
- const BulkActions = ({ selected, allSelected, className, onClearSelection, onSelectAll, gridType = deviceType_1.DeviceType.Desktop, children }) => {
18
+ const BulkActions = ({ selected, allSelected, className, onClearSelection, onSelectAll, gridType = deviceType_1.DeviceType.Desktop, children, turnOffSelectAll }) => {
19
19
  var _a;
20
20
  const { translate } = (0, useLanguage_1.useLanguage)();
21
21
  const childrenArray = (0, react_1.useMemo)(() => react_1.Children.toArray(children), [children]);
@@ -28,7 +28,7 @@ const BulkActions = ({ selected, allSelected, className, onClearSelection, onSel
28
28
  const { visibleElements, nonFittingElements, hiddenContainerRef } = (0, useNonFittingElements_1.useNonFittingElements)({ maxWidth, data: childrenArray, hiddenElementsCountToRender: 10, widthDelta });
29
29
  const isMobile = gridType === deviceType_1.DeviceType.Mobile;
30
30
  const text = translate("{1} selected").replace("{1}", allSelected ? translate("All") : selected.toFixed());
31
- return (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-bulk-actions", className || "", isMobile ? "zen-bulk-actions--condensed" : ""]), ref: bulkActionsElement, children: [(0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { className: "zen-bulk-actions__button-clear", icon: iconClose_1.IconClose, iconPosition: textIconButton_1.ButtonIconPosition.Start, iconSize: "large", type: "tertiary-black", title: translate("Clear selection"), "aria-label": translate("Clear selection"), onClick: onClearSelection }), (0, jsx_runtime_1.jsx)("span", { className: "zen-bulk-actions__number-of-selected ellipsis", children: text }), onSelectAll
31
+ return (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-bulk-actions", className || "", isMobile ? "zen-bulk-actions--condensed" : ""]), ref: bulkActionsElement, children: [(0, jsx_runtime_1.jsx)(textIconButton_1.TextIconButton, { className: "zen-bulk-actions__button-clear", icon: iconClose_1.IconClose, iconPosition: textIconButton_1.ButtonIconPosition.Start, iconSize: "large", type: "tertiary-black", title: translate("Clear selection"), "aria-label": translate("Clear selection"), onClick: onClearSelection }), (0, jsx_runtime_1.jsx)("span", { className: "zen-bulk-actions__number-of-selected ellipsis", children: text }), onSelectAll && !turnOffSelectAll
32
32
  ? (0, jsx_runtime_1.jsx)(button_1.Button, { type: "tertiary", className: "zen-bulk-actions__select-all", disabled: allSelected, onClick: onSelectAll, children: translate("Select all") })
33
33
  : null, (0, jsx_runtime_1.jsxs)("div", { className: "zen-bulk-actions__action-button-holder", ref: buttonHolder, children: [react_1.Children.map(visibleElements, element => (0, react_1.cloneElement)(element, {
34
34
  disabled: selected > 0 || allSelected ? element.props.disabled : true
@@ -142,7 +142,7 @@ const Header = ({ children, className, onFiltersBarOpen }) => {
142
142
  const maxWidth = middleWidth || ((_b = toolbarRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width) || 0;
143
143
  const actionCount = (0, react_1.useMemo)(() => {
144
144
  if (!isMobile) {
145
- return 2;
145
+ return 4;
146
146
  }
147
147
  if (memoizedFiltersBar && !searchComponent) {
148
148
  return 1;
@@ -1,5 +1,5 @@
1
1
  import { ReactElement, ReactNode } from "react";
2
- export declare const useTableChildren: (children: ReactNode, isMobile: boolean, selected: number, allSelected: boolean, clearSelection: () => void, selectAll: () => void, gridRef?: React.RefObject<HTMLElement>) => {
2
+ export declare const useTableChildren: (children: ReactNode, isMobile: boolean, selected: number, allSelected: boolean, clearSelection: () => void, selectAll: () => void, turnOffSelectAll?: boolean, gridRef?: React.RefObject<HTMLElement>) => {
3
3
  bulkActions: ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
4
4
  pagination: ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
5
5
  activePage: number | undefined;
@@ -22,7 +22,7 @@ const isChildElement = (child, expectedType) => {
22
22
  }
23
23
  return child.type.displayName === expectedType;
24
24
  };
25
- const useTableChildren = (children, isMobile, selected, allSelected, clearSelection, selectAll, gridRef) => (0, react_1.useMemo)(() => {
25
+ const useTableChildren = (children, isMobile, selected, allSelected, clearSelection, selectAll, turnOffSelectAll, gridRef) => (0, react_1.useMemo)(() => {
26
26
  let bulkActions = undefined;
27
27
  let tablePagination = undefined;
28
28
  let activePage;
@@ -37,7 +37,7 @@ const useTableChildren = (children, isMobile, selected, allSelected, clearSelect
37
37
  }
38
38
  if (isChildElement(child, tableBulkActions_1.TableBulkActions.displayName)) {
39
39
  const bulkActionButtons = ((_a = child.props) === null || _a === void 0 ? void 0 : _a.children) || [];
40
- bulkActions = (0, jsx_runtime_1.jsx)(bulkActions_1.BulkActions, { gridType: isMobile ? deviceType_1.DeviceType.Mobile : deviceType_1.DeviceType.Desktop, selected: selected, allSelected: allSelected, onClearSelection: clearSelection, onSelectAll: selectAll, children: bulkActionButtons });
40
+ bulkActions = (0, jsx_runtime_1.jsx)(bulkActions_1.BulkActions, { gridType: isMobile ? deviceType_1.DeviceType.Mobile : deviceType_1.DeviceType.Desktop, selected: selected, allSelected: allSelected, onClearSelection: clearSelection, onSelectAll: selectAll, turnOffSelectAll: turnOffSelectAll, children: bulkActionButtons });
41
41
  return;
42
42
  }
43
43
  if (isChildElement(child, tablePagination_1.TablePagination.displayName)) {
@@ -18,6 +18,7 @@ export interface ISelectableRowsOptions<T extends IRowEntity<N>, N extends IEnti
18
18
  turnOffSelectAll?: boolean;
19
19
  checkboxPlaceholder?: boolean;
20
20
  strategy?: TSelectionStrategy;
21
+ selectAll?: boolean;
21
22
  }
22
23
  export declare const getEmptySelection: () => {
23
24
  all: boolean;
@@ -144,7 +144,9 @@ const useSelectableRows = (columns, entities, isMobile, selectMode, setSelectMod
144
144
  },
145
145
  renderHeader(title) {
146
146
  const cell = (0, jsx_runtime_1.jsx)(selectableHeader_1.SelectableHeader, { title: title, label: headerTitle(), checked: state === interfaces_1.SelectionState.CurrentPage || state === interfaces_1.SelectionState.All, indeterminate: state === interfaces_1.SelectionState.Partial, onChange: (newValue) => {
147
- const newState = newValue ? interfaces_1.SelectionState.All : interfaces_1.SelectionState.None;
147
+ const newState = newValue
148
+ ? selectable.turnOffSelectAll ? interfaces_1.SelectionState.CurrentPage : interfaces_1.SelectionState.All
149
+ : interfaces_1.SelectionState.None;
148
150
  setState(newState);
149
151
  onChangeSelectionState(newState);
150
152
  }, calculateSelectionState: () => selectableState, checkboxInHeader: selectable.checkboxInHeader !== undefined
@@ -78,7 +78,7 @@ const TableInner = ({ entities, columns, selectable, sortable, flexible, isLoadi
78
78
  const selectAll = (0, react_1.useCallback)(() => {
79
79
  selectable === null || selectable === void 0 ? void 0 : selectable.onSelect({ all: true, selected: [] });
80
80
  }, [selectable]);
81
- const { bulkActions, pagination, activePage, fullscreenButton, emptyList, footer, other } = (0, useTableChildren_1.useTableChildren)(children, isMobile, selectionQty, ((_c = selectable === null || selectable === void 0 ? void 0 : selectable.selection) === null || _c === void 0 ? void 0 : _c.all) || false, clearSelection, selectAll, gridRef);
81
+ const { bulkActions, pagination, activePage, fullscreenButton, emptyList, footer, other } = (0, useTableChildren_1.useTableChildren)(children, isMobile, selectionQty, ((_c = selectable === null || selectable === void 0 ? void 0 : selectable.selection) === null || _c === void 0 ? void 0 : _c.all) || false, clearSelection, selectAll, selectable === null || selectable === void 0 ? void 0 : selectable.turnOffSelectAll, gridRef);
82
82
  const handleOnHidePanel = (0, react_1.useCallback)(() => setSelectMode(false), []);
83
83
  const handleOnTriggerClick = (0, react_1.useCallback)(() => setSelectMode(prev => !prev), []);
84
84
  const hasPostActions = (0, react_1.useMemo)(() => columnsPopup || (isMobile && selectable) || (!isMobile && fullscreenButton) || isFeedVisible, [columnsPopup, fullscreenButton, isFeedVisible, isMobile, selectable]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geotab/zenith",
3
- "version": "1.26.1-beta.1",
3
+ "version": "1.26.1-beta.2",
4
4
  "description": "Zenith components library on React",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",