@itwin/itwinui-react 1.35.0 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  3. package/cjs/core/Menu/Menu.js +8 -3
  4. package/cjs/core/Table/Table.d.ts +1 -0
  5. package/cjs/core/Table/Table.js +26 -13
  6. package/cjs/core/Table/TableCell.js +3 -3
  7. package/cjs/core/Table/TableRowMemoized.js +12 -7
  8. package/cjs/core/Table/actionHandlers/index.d.ts +2 -1
  9. package/cjs/core/Table/actionHandlers/index.js +5 -1
  10. package/cjs/core/Table/cells/DefaultCell.d.ts +1 -1
  11. package/cjs/core/Table/cells/DefaultCell.js +5 -2
  12. package/cjs/core/Table/columns/actionColumn.d.ts +35 -0
  13. package/cjs/core/Table/columns/actionColumn.js +91 -0
  14. package/cjs/core/Table/columns/expanderColumn.d.ts +47 -0
  15. package/cjs/core/Table/columns/expanderColumn.js +81 -0
  16. package/cjs/core/Table/columns/index.d.ts +3 -0
  17. package/cjs/core/Table/columns/index.js +15 -0
  18. package/cjs/core/Table/columns/selectionColumn.d.ts +35 -0
  19. package/cjs/core/Table/columns/selectionColumn.js +67 -0
  20. package/cjs/core/Table/hooks/index.d.ts +2 -2
  21. package/cjs/core/Table/hooks/index.js +1 -3
  22. package/cjs/core/Table/hooks/useExpanderCell.d.ts +0 -1
  23. package/cjs/core/Table/hooks/useExpanderCell.js +25 -39
  24. package/cjs/core/Table/hooks/useResizeColumns.js +8 -2
  25. package/cjs/core/Table/hooks/useSelectionCell.d.ts +0 -1
  26. package/cjs/core/Table/hooks/useSelectionCell.js +6 -52
  27. package/cjs/core/Table/index.d.ts +1 -0
  28. package/cjs/core/Table/index.js +5 -1
  29. package/cjs/core/Table/utils.js +1 -1
  30. package/cjs/core/Toast/Toast.js +1 -1
  31. package/cjs/core/Typography/Anchor/Anchor.d.ts +1 -0
  32. package/cjs/core/Typography/Anchor/Anchor.js +1 -0
  33. package/cjs/core/index.d.ts +1 -1
  34. package/cjs/core/index.js +5 -2
  35. package/cjs/core/utils/components/Popover.js +13 -1
  36. package/cjs/types/react-table-config.d.ts +18 -0
  37. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  38. package/esm/core/Menu/Menu.js +8 -3
  39. package/esm/core/Table/Table.d.ts +1 -0
  40. package/esm/core/Table/Table.js +22 -9
  41. package/esm/core/Table/TableCell.js +2 -2
  42. package/esm/core/Table/TableRowMemoized.js +12 -7
  43. package/esm/core/Table/actionHandlers/index.d.ts +2 -1
  44. package/esm/core/Table/actionHandlers/index.js +2 -1
  45. package/esm/core/Table/cells/DefaultCell.d.ts +1 -1
  46. package/esm/core/Table/cells/DefaultCell.js +5 -2
  47. package/esm/core/Table/columns/actionColumn.d.ts +35 -0
  48. package/esm/core/Table/columns/actionColumn.js +84 -0
  49. package/esm/core/Table/columns/expanderColumn.d.ts +47 -0
  50. package/esm/core/Table/columns/expanderColumn.js +74 -0
  51. package/esm/core/Table/columns/index.d.ts +3 -0
  52. package/esm/core/Table/columns/index.js +7 -0
  53. package/esm/core/Table/columns/selectionColumn.d.ts +35 -0
  54. package/esm/core/Table/columns/selectionColumn.js +60 -0
  55. package/esm/core/Table/hooks/index.d.ts +2 -2
  56. package/esm/core/Table/hooks/index.js +2 -2
  57. package/esm/core/Table/hooks/useExpanderCell.d.ts +0 -1
  58. package/esm/core/Table/hooks/useExpanderCell.js +24 -35
  59. package/esm/core/Table/hooks/useResizeColumns.js +8 -2
  60. package/esm/core/Table/hooks/useSelectionCell.d.ts +0 -1
  61. package/esm/core/Table/hooks/useSelectionCell.js +5 -48
  62. package/esm/core/Table/index.d.ts +1 -0
  63. package/esm/core/Table/index.js +1 -0
  64. package/esm/core/Table/utils.js +1 -1
  65. package/esm/core/Toast/Toast.js +1 -1
  66. package/esm/core/Typography/Anchor/Anchor.d.ts +1 -0
  67. package/esm/core/Typography/Anchor/Anchor.js +1 -0
  68. package/esm/core/index.d.ts +1 -1
  69. package/esm/core/index.js +1 -1
  70. package/esm/core/utils/components/Popover.js +13 -1
  71. package/esm/types/react-table-config.d.ts +18 -0
  72. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.36.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.35.0...v1.36.0) (2022-04-15)
4
+
5
+ ### What's new
6
+
7
+ * **Table:** Added `ColumnManager` for hiding columns ([#564](https://www.github.com/iTwin/iTwinUI-react/issues/564)) ([71cf927](https://www.github.com/iTwin/iTwinUI-react/commit/71cf9278d1e75dc426f24976a497d40b18da3c87))
8
+ - `ActionColumn` was added to use with `ColumnManager`. It can be used for fixed width columns (i.e. column with menu).
9
+ * **Table:** Default columns customization ([#599](https://www.github.com/iTwin/iTwinUI-react/issues/599)) ([e665821](https://www.github.com/iTwin/iTwinUI-react/commit/e665821b66972136873797058da6cd4036f4dd2d))
10
+ - `ExpanderColumn` and `SelectionColumn` were added for custom implementation of expansion and selection.
11
+
12
+ ### Fixes
13
+
14
+ * **Menu:** Fixed keyboard navigation when `MenuItem` contains selectable children ([#625](https://www.github.com/iTwin/iTwinUI-react/issues/625)) ([082e384](https://www.github.com/iTwin/iTwinUI-react/commit/082e384ed5ccc1fb2ded9ccc69bca06be6e3f29b))
15
+ * **Popover:** Stop propagation of click in `Popover` ([#619](https://www.github.com/iTwin/iTwinUI-react/issues/619)) ([298cbf3](https://www.github.com/iTwin/iTwinUI-react/commit/298cbf3aba050763b481252ba76f5c945b5c2e17))
16
+
3
17
  ## [1.35.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.34.2...v1.35.0) (2022-04-05)
4
18
 
5
19
  ### What's new
@@ -17,5 +17,5 @@ export declare type ColorSwatchProps = {
17
17
  * <ColorSwatch color='#23450b' onClick={onClick}/>
18
18
  * <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
19
19
  */
20
- export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "isActive"> & React.RefAttributes<HTMLDivElement>>;
20
+ export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "role" | "children" | "className" | "onClick" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "isActive"> & React.RefAttributes<HTMLDivElement>>;
21
21
  export default ColorSwatch;
@@ -46,9 +46,14 @@ exports.Menu = react_1.default.forwardRef(function (props, ref) {
46
46
  react_1.default.useEffect(function () {
47
47
  setFocusedIndex(null);
48
48
  }, [children]);
49
+ var getFocusableNodes = react_1.default.useCallback(function () {
50
+ var focusableItems = (0, utils_1.getFocusableElements)(menuRef.current);
51
+ // Filter out focusable elements that are inside each menu item, e.g. checkbox, anchor
52
+ return focusableItems.filter(function (i) { return !focusableItems.some(function (p) { return p.contains(i.parentElement); }); });
53
+ }, []);
49
54
  react_1.default.useEffect(function () {
50
55
  var _a;
51
- var items = (0, utils_1.getFocusableElements)(menuRef.current);
56
+ var items = getFocusableNodes();
52
57
  if (focusedIndex != null) {
53
58
  (_a = items === null || items === void 0 ? void 0 : items[focusedIndex]) === null || _a === void 0 ? void 0 : _a.focus();
54
59
  return;
@@ -57,9 +62,9 @@ exports.Menu = react_1.default.forwardRef(function (props, ref) {
57
62
  if (setFocus) {
58
63
  setFocusedIndex(selectedIndex > -1 ? selectedIndex : 0);
59
64
  }
60
- }, [setFocus, focusedIndex]);
65
+ }, [setFocus, focusedIndex, getFocusableNodes]);
61
66
  var onKeyDown = function (event) {
62
- var items = (0, utils_1.getFocusableElements)(menuRef.current);
67
+ var items = getFocusableNodes();
63
68
  if (!(items === null || items === void 0 ? void 0 : items.length)) {
64
69
  return;
65
70
  }
@@ -3,6 +3,7 @@ import { CellProps, TableOptions, Row, TableState } from 'react-table';
3
3
  import { CommonProps } from '../utils';
4
4
  import '@itwin/itwinui-css/css/table.css';
5
5
  import { TableFilterValue } from './filters';
6
+ export declare const tableResizeStartAction = "tableResizeStart";
6
7
  export declare type TablePaginatorRendererProps = {
7
8
  /**
8
9
  * The zero-based index of the current page.
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.Table = void 0;
28
+ exports.Table = exports.tableResizeStartAction = void 0;
29
29
  /*---------------------------------------------------------------------------------------------
30
30
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
31
31
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -44,11 +44,10 @@ var filters_1 = require("./filters");
44
44
  var customFilterFunctions_1 = require("./filters/customFilterFunctions");
45
45
  var hooks_1 = require("./hooks");
46
46
  var actionHandlers_1 = require("./actionHandlers");
47
- var selectHandler_1 = require("./actionHandlers/selectHandler");
48
- var resizeHandler_1 = require("./actionHandlers/resizeHandler");
49
47
  var VirtualScroll_1 = __importDefault(require("../utils/components/VirtualScroll"));
48
+ var columns_1 = require("./columns");
50
49
  var singleRowSelectedAction = 'singleRowSelected';
51
- var tableResizeStartAction = 'tableResizeStart';
50
+ exports.tableResizeStartAction = 'tableResizeStart';
52
51
  var tableResizeEndAction = 'tableResizeEnd';
53
52
  /**
54
53
  * Table based on [react-table](https://react-table.tanstack.com/docs/api/overview).
@@ -94,9 +93,10 @@ var tableResizeEndAction = 'tableResizeEnd';
94
93
  */
95
94
  var Table = function (props) {
96
95
  var _a;
97
- var data = props.data, columns = props.columns, _b = props.isLoading, isLoading = _b === void 0 ? false : _b, emptyTableContent = props.emptyTableContent, className = props.className, style = props.style, id = props.id, _c = props.isSelectable, isSelectable = _c === void 0 ? false : _c, onSelect = props.onSelect, onRowClick = props.onRowClick, _d = props.isSortable, isSortable = _d === void 0 ? false : _d, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _e = props.intersectionMargin, intersectionMargin = _e === void 0 ? 300 : _e, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _f = props.density, density = _f === void 0 ? 'default' : _f, _g = props.selectSubRows, selectSubRows = _g === void 0 ? true : _g, getSubRows = props.getSubRows, _h = props.selectRowOnClick, selectRowOnClick = _h === void 0 ? true : _h, paginatorRenderer = props.paginatorRenderer, _j = props.pageSize, pageSize = _j === void 0 ? 25 : _j, _k = props.isResizable, isResizable = _k === void 0 ? false : _k, _l = props.styleType, styleType = _l === void 0 ? 'default' : _l, _m = props.enableVirtualization, enableVirtualization = _m === void 0 ? false : _m, _o = props.enableColumnReordering, enableColumnReordering = _o === void 0 ? false : _o, rest = __rest(props, ["data", "columns", "isLoading", "emptyTableContent", "className", "style", "id", "isSelectable", "onSelect", "onRowClick", "isSortable", "onSort", "stateReducer", "onBottomReached", "onRowInViewport", "intersectionMargin", "subComponent", "onExpand", "onFilter", "emptyFilteredTableContent", "filterTypes", "expanderCell", "isRowDisabled", "rowProps", "density", "selectSubRows", "getSubRows", "selectRowOnClick", "paginatorRenderer", "pageSize", "isResizable", "styleType", "enableVirtualization", "enableColumnReordering"]);
96
+ var _b;
97
+ var data = props.data, columns = props.columns, _c = props.isLoading, isLoading = _c === void 0 ? false : _c, emptyTableContent = props.emptyTableContent, className = props.className, style = props.style, id = props.id, _d = props.isSelectable, isSelectable = _d === void 0 ? false : _d, onSelect = props.onSelect, onRowClick = props.onRowClick, _e = props.isSortable, isSortable = _e === void 0 ? false : _e, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _f = props.intersectionMargin, intersectionMargin = _f === void 0 ? 300 : _f, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _g = props.density, density = _g === void 0 ? 'default' : _g, _h = props.selectSubRows, selectSubRows = _h === void 0 ? true : _h, getSubRows = props.getSubRows, _j = props.selectRowOnClick, selectRowOnClick = _j === void 0 ? true : _j, paginatorRenderer = props.paginatorRenderer, _k = props.pageSize, pageSize = _k === void 0 ? 25 : _k, _l = props.isResizable, isResizable = _l === void 0 ? false : _l, _m = props.styleType, styleType = _m === void 0 ? 'default' : _m, _o = props.enableVirtualization, enableVirtualization = _o === void 0 ? false : _o, _p = props.enableColumnReordering, enableColumnReordering = _p === void 0 ? false : _p, rest = __rest(props, ["data", "columns", "isLoading", "emptyTableContent", "className", "style", "id", "isSelectable", "onSelect", "onRowClick", "isSortable", "onSort", "stateReducer", "onBottomReached", "onRowInViewport", "intersectionMargin", "subComponent", "onExpand", "onFilter", "emptyFilteredTableContent", "filterTypes", "expanderCell", "isRowDisabled", "rowProps", "density", "selectSubRows", "getSubRows", "selectRowOnClick", "paginatorRenderer", "pageSize", "isResizable", "styleType", "enableVirtualization", "enableColumnReordering"]);
98
98
  (0, utils_1.useTheme)();
99
- var _p = react_1.default.useState(), ownerDocument = _p[0], setOwnerDocument = _p[1];
99
+ var _q = react_1.default.useState(), ownerDocument = _q[0], setOwnerDocument = _q[1];
100
100
  var defaultColumn = react_1.default.useMemo(function () { return ({
101
101
  maxWidth: 0,
102
102
  minWidth: 0,
@@ -109,6 +109,7 @@ var Table = function (props) {
109
109
  onBottomReachedRef.current = onBottomReached;
110
110
  onRowInViewportRef.current = onRowInViewport;
111
111
  }, [onBottomReached, onRowInViewport]);
112
+ var hasManualSelectionColumn = (_b = columns[0]) === null || _b === void 0 ? void 0 : _b.columns.some(function (column) { return column.id === columns_1.SELECTION_CELL_ID; });
112
113
  var tableStateReducer = react_1.default.useCallback(function (newState, action, previousState, instance) {
113
114
  switch (action.type) {
114
115
  case react_table_1.actions.toggleSortBy:
@@ -122,21 +123,25 @@ var Table = function (props) {
122
123
  (0, actionHandlers_1.onExpandHandler)(newState, instance, onExpand);
123
124
  break;
124
125
  case singleRowSelectedAction: {
125
- newState = (0, selectHandler_1.onSingleSelectHandler)(newState, action, instance, onSelect, isRowDisabled);
126
+ newState = (0, actionHandlers_1.onSingleSelectHandler)(newState, action, instance, onSelect,
127
+ // If it has manual selection column, then we can't check whether row is disabled
128
+ hasManualSelectionColumn ? undefined : isRowDisabled);
126
129
  break;
127
130
  }
128
131
  case react_table_1.actions.toggleRowSelected:
129
132
  case react_table_1.actions.toggleAllRowsSelected:
130
133
  case react_table_1.actions.toggleAllPageRowsSelected: {
131
- (0, actionHandlers_1.onSelectHandler)(newState, instance, onSelect, isRowDisabled);
134
+ (0, actionHandlers_1.onSelectHandler)(newState, instance, onSelect,
135
+ // If it has manual selection column, then we can't check whether row is disabled
136
+ hasManualSelectionColumn ? undefined : isRowDisabled);
132
137
  break;
133
138
  }
134
- case tableResizeStartAction: {
135
- newState = (0, resizeHandler_1.onTableResizeStart)(newState);
139
+ case exports.tableResizeStartAction: {
140
+ newState = (0, actionHandlers_1.onTableResizeStart)(newState);
136
141
  break;
137
142
  }
138
143
  case tableResizeEndAction: {
139
- newState = (0, resizeHandler_1.onTableResizeEnd)(newState, action);
144
+ newState = (0, actionHandlers_1.onTableResizeEnd)(newState, action);
140
145
  break;
141
146
  }
142
147
  default:
@@ -145,7 +150,15 @@ var Table = function (props) {
145
150
  return stateReducer
146
151
  ? stateReducer(newState, action, previousState, instance)
147
152
  : newState;
148
- }, [isRowDisabled, onExpand, onFilter, onSelect, onSort, stateReducer]);
153
+ }, [
154
+ hasManualSelectionColumn,
155
+ isRowDisabled,
156
+ onExpand,
157
+ onFilter,
158
+ onSelect,
159
+ onSort,
160
+ stateReducer,
161
+ ]);
149
162
  var filterTypes = react_1.default.useMemo(function () { return (__assign(__assign({}, customFilterFunctions_1.customFilterFunctions), filterFunctions)); }, [filterFunctions]);
150
163
  var hasAnySubRows = react_1.default.useMemo(function () {
151
164
  return data.some(function (item, index) {
@@ -217,7 +230,7 @@ var Table = function (props) {
217
230
  if (Object.keys(state.columnResizing.columnWidths).length === 0) {
218
231
  return;
219
232
  }
220
- dispatch({ type: tableResizeStartAction });
233
+ dispatch({ type: exports.tableResizeStartAction });
221
234
  }, [dispatch, state.columnResizing.columnWidths, flatHeaders]);
222
235
  var resizeRef = (0, utils_1.useResizeObserver)(onTableResize)[0];
223
236
  // Flexbox handles columns resize so we take new column widths before browser repaints.
@@ -23,12 +23,12 @@ var react_1 = __importDefault(require("react"));
23
23
  var classnames_1 = __importDefault(require("classnames"));
24
24
  var utils_1 = require("./utils");
25
25
  var SubRowExpander_1 = require("./SubRowExpander");
26
- var hooks_1 = require("./hooks");
26
+ var columns_1 = require("./columns");
27
27
  var cells_1 = require("./cells");
28
28
  var TableCell = function (props) {
29
29
  var cell = props.cell, cellIndex = props.cellIndex, isDisabled = props.isDisabled, tableHasSubRows = props.tableHasSubRows, tableInstance = props.tableInstance, expanderCell = props.expanderCell;
30
30
  var hasSubRowExpander = cellIndex ===
31
- cell.row.cells.findIndex(function (c) { return c.column.id !== hooks_1.SELECTION_CELL_ID; });
31
+ cell.row.cells.findIndex(function (c) { return c.column.id !== columns_1.SELECTION_CELL_ID; });
32
32
  var getSubRowStyle = function () {
33
33
  if (!tableHasSubRows || !hasSubRowExpander) {
34
34
  return undefined;
@@ -52,7 +52,7 @@ var TableCell = function (props) {
52
52
  cellProps: cellProps,
53
53
  children: cellContent,
54
54
  };
55
- return (react_1.default.createElement(react_1.default.Fragment, null, cell.column.cellRenderer ? (cell.column.cellRenderer(cellRendererProps)) : (react_1.default.createElement(cells_1.DefaultCell, __assign({}, cellRendererProps)))));
55
+ return (react_1.default.createElement(react_1.default.Fragment, null, cell.column.cellRenderer ? (cell.column.cellRenderer(__assign(__assign({}, cellRendererProps), { isDisabled: function () { return isDisabled; } }))) : (react_1.default.createElement(cells_1.DefaultCell, __assign({}, cellRendererProps, { isDisabled: function () { return isDisabled; } })))));
56
56
  };
57
57
  exports.TableCell = TableCell;
58
58
  exports.default = exports.TableCell;
@@ -57,7 +57,9 @@ var TableRow = function (props) {
57
57
  return (react_1.default.createElement(TableCell_1.TableCell, { key: cell.getCellProps().key, cell: cell, cellIndex: index, isDisabled: isDisabled, tableHasSubRows: tableHasSubRows, tableInstance: tableInstance, expanderCell: expanderCell }));
58
58
  })),
59
59
  subComponent && (react_1.default.createElement(utils_1.WithCSSTransition, { in: row.isExpanded },
60
- react_1.default.createElement("div", { className: 'iui-row iui-expanded-content' }, subComponent(row))))));
60
+ react_1.default.createElement("div", { className: (0, classnames_1.default)('iui-row', 'iui-expanded-content', {
61
+ 'iui-disabled': isDisabled,
62
+ }) }, subComponent(row))))));
61
63
  };
62
64
  exports.TableRow = TableRow;
63
65
  var hasAnySelectedSubRow = function (row, selectedRowIds) {
@@ -69,14 +71,17 @@ var hasAnySelectedSubRow = function (row, selectedRowIds) {
69
71
  });
70
72
  };
71
73
  exports.TableRowMemoized = react_1.default.memo(exports.TableRow, function (prevProp, nextProp) {
72
- var _a, _b, _c, _d;
74
+ var _a, _b, _c, _d, _e, _f, _g;
73
75
  return prevProp.isLast === nextProp.isLast &&
76
+ ((_a = prevProp.state.hiddenColumns) === null || _a === void 0 ? void 0 : _a.length) ===
77
+ ((_b = nextProp.state.hiddenColumns) === null || _b === void 0 ? void 0 : _b.length) &&
78
+ !!((_c = prevProp.state.hiddenColumns) === null || _c === void 0 ? void 0 : _c.every(function (column, index) { var _a; return ((_a = nextProp.state.hiddenColumns) === null || _a === void 0 ? void 0 : _a[index]) === column; })) &&
74
79
  prevProp.onRowInViewport === nextProp.onRowInViewport &&
75
80
  prevProp.onBottomReached === nextProp.onBottomReached &&
76
81
  prevProp.onClick === nextProp.onClick &&
77
82
  prevProp.row.original === nextProp.row.original &&
78
- ((_a = prevProp.state.selectedRowIds) === null || _a === void 0 ? void 0 : _a[prevProp.row.id]) ===
79
- ((_b = nextProp.state.selectedRowIds) === null || _b === void 0 ? void 0 : _b[nextProp.row.id]) &&
83
+ ((_d = prevProp.state.selectedRowIds) === null || _d === void 0 ? void 0 : _d[prevProp.row.id]) ===
84
+ ((_e = nextProp.state.selectedRowIds) === null || _e === void 0 ? void 0 : _e[nextProp.row.id]) &&
80
85
  // Check if sub-rows selection has changed and whether to show indeterminate state or not
81
86
  prevProp.row.subRows.some(function (subRow) {
82
87
  return hasAnySelectedSubRow(subRow, prevProp.state.selectedRowIds);
@@ -84,8 +89,8 @@ exports.TableRowMemoized = react_1.default.memo(exports.TableRow, function (prev
84
89
  nextProp.row.subRows.some(function (subRow) {
85
90
  return hasAnySelectedSubRow(subRow, nextProp.state.selectedRowIds);
86
91
  }) &&
87
- ((_c = prevProp.state.expanded) === null || _c === void 0 ? void 0 : _c[prevProp.row.id]) ===
88
- ((_d = nextProp.state.expanded) === null || _d === void 0 ? void 0 : _d[nextProp.row.id]) &&
92
+ ((_f = prevProp.state.expanded) === null || _f === void 0 ? void 0 : _f[prevProp.row.id]) ===
93
+ ((_g = nextProp.state.expanded) === null || _g === void 0 ? void 0 : _g[nextProp.row.id]) &&
89
94
  prevProp.subComponent === nextProp.subComponent &&
90
95
  prevProp.row.cells.every(function (cell, index) { return nextProp.row.cells[index].column === cell.column; }) &&
91
96
  prevProp.isDisabled === nextProp.isDisabled &&
@@ -94,5 +99,5 @@ exports.TableRowMemoized = react_1.default.memo(exports.TableRow, function (prev
94
99
  prevProp.tableHasSubRows === nextProp.tableHasSubRows &&
95
100
  prevProp.state.columnOrder === nextProp.state.columnOrder &&
96
101
  !nextProp.state.columnResizing.isResizingColumn &&
97
- !nextProp.state.isTableResizing;
102
+ prevProp.state.isTableResizing === nextProp.state.isTableResizing;
98
103
  });
@@ -1,3 +1,4 @@
1
1
  export { onExpandHandler } from './expandHandler';
2
2
  export { onFilterHandler } from './filterHandler';
3
- export { onSelectHandler } from './selectHandler';
3
+ export { onSelectHandler, onSingleSelectHandler } from './selectHandler';
4
+ export { onTableResizeStart, onTableResizeEnd } from './resizeHandler';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onSelectHandler = exports.onFilterHandler = exports.onExpandHandler = void 0;
3
+ exports.onTableResizeEnd = exports.onTableResizeStart = exports.onSingleSelectHandler = exports.onSelectHandler = exports.onFilterHandler = exports.onExpandHandler = void 0;
4
4
  /*---------------------------------------------------------------------------------------------
5
5
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
6
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -11,3 +11,7 @@ var filterHandler_1 = require("./filterHandler");
11
11
  Object.defineProperty(exports, "onFilterHandler", { enumerable: true, get: function () { return filterHandler_1.onFilterHandler; } });
12
12
  var selectHandler_1 = require("./selectHandler");
13
13
  Object.defineProperty(exports, "onSelectHandler", { enumerable: true, get: function () { return selectHandler_1.onSelectHandler; } });
14
+ Object.defineProperty(exports, "onSingleSelectHandler", { enumerable: true, get: function () { return selectHandler_1.onSingleSelectHandler; } });
15
+ var resizeHandler_1 = require("./resizeHandler");
16
+ Object.defineProperty(exports, "onTableResizeStart", { enumerable: true, get: function () { return resizeHandler_1.onTableResizeStart; } });
17
+ Object.defineProperty(exports, "onTableResizeEnd", { enumerable: true, get: function () { return resizeHandler_1.onTableResizeEnd; } });
@@ -12,5 +12,5 @@ export declare type DefaultCellProps<T extends Record<string, unknown>> = CellRe
12
12
  * cellRenderer: (props) => <DefaultCell {...props} />,
13
13
  * }
14
14
  */
15
- export declare const DefaultCell: <T extends Record<string, unknown>>(props: CellRendererProps<T>) => JSX.Element;
15
+ export declare const DefaultCell: <T extends Record<string, unknown>>(props: DefaultCellProps<T>) => JSX.Element;
16
16
  export default DefaultCell;
@@ -31,6 +31,7 @@ exports.DefaultCell = void 0;
31
31
  * See LICENSE.md in the project root for license terms and full copyright notice.
32
32
  *--------------------------------------------------------------------------------------------*/
33
33
  var react_1 = __importDefault(require("react"));
34
+ var classnames_1 = __importDefault(require("classnames"));
34
35
  /**
35
36
  * Default cell.
36
37
  * It should be passed to `cellRenderer`.
@@ -45,8 +46,10 @@ var react_1 = __importDefault(require("react"));
45
46
  var DefaultCell = function (props) {
46
47
  // Omitting `cellProps`
47
48
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
- var cellElementProps = props.cellElementProps, children = props.children, cellProps = props.cellProps, rest = __rest(props, ["cellElementProps", "children", "cellProps"]);
49
- return (react_1.default.createElement("div", __assign({}, cellElementProps, rest), children));
49
+ var _a = props.cellElementProps, cellElementClassName = _a.className, cellElementStyle = _a.style, cellElementProps = __rest(_a, ["className", "style"]), children = props.children, cellProps = props.cellProps, isDisabled = props.isDisabled, className = props.className, style = props.style, rest = __rest(props, ["cellElementProps", "children", "cellProps", "isDisabled", "className", "style"]);
50
+ return (react_1.default.createElement("div", __assign({}, cellElementProps, rest, { className: (0, classnames_1.default)(cellElementClassName, className, {
51
+ 'iui-disabled': isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(cellProps.row.original),
52
+ }), style: __assign(__assign({}, cellElementStyle), style) }), children));
50
53
  };
51
54
  exports.DefaultCell = DefaultCell;
52
55
  exports.default = exports.DefaultCell;
@@ -0,0 +1,35 @@
1
+ /// <reference types="react" />
2
+ import { HeaderProps } from 'react-table';
3
+ /**
4
+ * Action column that adds column manager to the Table header.
5
+ * It is recommended to add this column to the end of the Table
6
+ * and to override its `Cell` prop with your row actions menu.
7
+ * @example
8
+ * {
9
+ * ...ActionColumn({ columnManager: true }),
10
+ * Cell: () => (
11
+ * <DropdownMenu menuItems={menuItems}>
12
+ * <IconButton
13
+ * styleType='borderless'
14
+ * onClick={(e) => e.stopPropagation()}
15
+ * >
16
+ * <SvgMore />
17
+ * </IconButton>
18
+ * </DropdownMenu>
19
+ * ),
20
+ * },
21
+ */
22
+ export declare const ActionColumn: <T extends Record<string, unknown>>({ columnManager, }?: {
23
+ columnManager?: boolean | undefined;
24
+ }) => {
25
+ id: string;
26
+ disableResizing: boolean;
27
+ disableGroupBy: boolean;
28
+ minWidth: number;
29
+ width: number;
30
+ maxWidth: number;
31
+ columnClassName: string;
32
+ cellClassName: string;
33
+ disableReordering: boolean;
34
+ Header: ({ allColumns, dispatch, state }: HeaderProps<T>) => JSX.Element | null;
35
+ };
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ActionColumn = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ var react_1 = __importDefault(require("react"));
12
+ var Checkbox_1 = require("../../Checkbox");
13
+ var ColumnManager_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/ColumnManager"));
14
+ var DropdownMenu_1 = require("../../DropdownMenu");
15
+ var IconButton_1 = require("../../Buttons/IconButton");
16
+ var Menu_1 = require("../../Menu");
17
+ var Table_1 = require("../Table");
18
+ var selectionColumn_1 = require("./selectionColumn");
19
+ var expanderColumn_1 = require("./expanderColumn");
20
+ var ACTION_CELL_ID = 'iui-table-action';
21
+ /**
22
+ * Action column that adds column manager to the Table header.
23
+ * It is recommended to add this column to the end of the Table
24
+ * and to override its `Cell` prop with your row actions menu.
25
+ * @example
26
+ * {
27
+ * ...ActionColumn({ columnManager: true }),
28
+ * Cell: () => (
29
+ * <DropdownMenu menuItems={menuItems}>
30
+ * <IconButton
31
+ * styleType='borderless'
32
+ * onClick={(e) => e.stopPropagation()}
33
+ * >
34
+ * <SvgMore />
35
+ * </IconButton>
36
+ * </DropdownMenu>
37
+ * ),
38
+ * },
39
+ */
40
+ var ActionColumn = function (_a) {
41
+ var _b = _a === void 0 ? {} : _a, _c = _b.columnManager, columnManager = _c === void 0 ? false : _c;
42
+ return {
43
+ id: ACTION_CELL_ID,
44
+ disableResizing: true,
45
+ disableGroupBy: true,
46
+ minWidth: 48,
47
+ width: 48,
48
+ maxWidth: 48,
49
+ columnClassName: 'iui-slot',
50
+ cellClassName: 'iui-slot',
51
+ disableReordering: true,
52
+ Header: function (_a) {
53
+ var allColumns = _a.allColumns, dispatch = _a.dispatch, state = _a.state;
54
+ var _b = react_1.default.useState(false), isOpen = _b[0], setIsOpen = _b[1];
55
+ if (!columnManager) {
56
+ return null;
57
+ }
58
+ var defaultColumnIds = [
59
+ selectionColumn_1.SELECTION_CELL_ID,
60
+ expanderColumn_1.EXPANDER_CELL_ID,
61
+ ACTION_CELL_ID,
62
+ ];
63
+ var headerCheckBoxes = function () {
64
+ return allColumns
65
+ //Filters out any default columns made such as selection and expansion
66
+ .filter(function (_a) {
67
+ var id = _a.id;
68
+ return !defaultColumnIds.includes(id);
69
+ })
70
+ .map(function (column) {
71
+ var checked = column.getToggleHiddenProps().checked;
72
+ var onClick = function () {
73
+ column.toggleHidden(checked);
74
+ // If no column was resized then leave table resize handling to the flexbox
75
+ if (Object.keys(state.columnResizing.columnWidths).length === 0) {
76
+ return;
77
+ }
78
+ // Triggers an update to resize the widths of all visible columns
79
+ dispatch({ type: Table_1.tableResizeStartAction });
80
+ };
81
+ return (react_1.default.createElement(Menu_1.MenuItem, { key: column.id, icon: react_1.default.createElement(Checkbox_1.Checkbox, { checked: checked, disabled: column.disableToggleVisibility, onClick: function (e) { return e.stopPropagation(); }, onChange: onClick, "aria-labelledby": "iui-column-" + column.id }), onClick: onClick, disabled: column.disableToggleVisibility },
82
+ react_1.default.createElement("div", { id: "iui-column-" + column.id }, column.render('Header'))));
83
+ });
84
+ };
85
+ return (react_1.default.createElement(DropdownMenu_1.DropdownMenu, { menuItems: headerCheckBoxes, onHide: function () { return setIsOpen(false); }, onShow: function () { return setIsOpen(true); } },
86
+ react_1.default.createElement(IconButton_1.IconButton, { styleType: 'borderless', isActive: isOpen },
87
+ react_1.default.createElement(ColumnManager_1.default, null))));
88
+ },
89
+ };
90
+ };
91
+ exports.ActionColumn = ActionColumn;
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { CellProps, CellRendererProps, Row } from 'react-table';
3
+ export declare const EXPANDER_CELL_ID = "iui-table-expander";
4
+ /**
5
+ * Expander column that adds sub-content expander column to the Table.
6
+ * It is recommended to use it as the first column or after selection column.
7
+ * @example
8
+ * const subComponent = useCallback(
9
+ * (row: Row) => (
10
+ * <div style={{ padding: 16 }}>
11
+ * <Leading>Extra information</Leading>
12
+ * <pre>
13
+ * <code>{JSON.stringify({ values: row.values }, null, 2)}</code>
14
+ * </pre>
15
+ * </div>
16
+ * ),
17
+ * [],
18
+ * );
19
+ * const isExpanderDisabled = useCallback((rowData) => {
20
+ * return rowData.name === 'Name2';
21
+ * }, []);
22
+ * const columns = useMemo(() => [
23
+ * Header: 'Table',
24
+ * columns: [
25
+ * ExpanderColumn({ subComponent, isDisabled: isExpanderDisabled }),
26
+ * // Rest of your columns
27
+ * ],
28
+ * ], [isExpanderDisabled, subComponent]);
29
+ */
30
+ export declare const ExpanderColumn: <T extends Record<string, unknown>>(props?: {
31
+ /** Function that returns expanded content. If row doesn't have it, then should return `false`/`null`. */
32
+ subComponent?: ((row: Row<T>) => React.ReactNode) | undefined;
33
+ /** Function that returns whether expander is disabled */
34
+ isDisabled?: ((rowData: T) => boolean) | undefined;
35
+ }) => {
36
+ id: string;
37
+ disableResizing: boolean;
38
+ disableGroupBy: boolean;
39
+ disableReordering: boolean;
40
+ minWidth: number;
41
+ width: number;
42
+ maxWidth: number;
43
+ columnClassName: string;
44
+ cellClassName: string;
45
+ Cell: (props: CellProps<T, any>) => JSX.Element | null;
46
+ cellRenderer: (props: CellRendererProps<T>) => JSX.Element;
47
+ };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ExpanderColumn = exports.EXPANDER_CELL_ID = void 0;
18
+ /*---------------------------------------------------------------------------------------------
19
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
20
+ * See LICENSE.md in the project root for license terms and full copyright notice.
21
+ *--------------------------------------------------------------------------------------------*/
22
+ var react_1 = __importDefault(require("react"));
23
+ var ChevronRight_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/ChevronRight"));
24
+ var Buttons_1 = require("../../Buttons");
25
+ var cells_1 = require("../cells");
26
+ exports.EXPANDER_CELL_ID = 'iui-table-expander';
27
+ /**
28
+ * Expander column that adds sub-content expander column to the Table.
29
+ * It is recommended to use it as the first column or after selection column.
30
+ * @example
31
+ * const subComponent = useCallback(
32
+ * (row: Row) => (
33
+ * <div style={{ padding: 16 }}>
34
+ * <Leading>Extra information</Leading>
35
+ * <pre>
36
+ * <code>{JSON.stringify({ values: row.values }, null, 2)}</code>
37
+ * </pre>
38
+ * </div>
39
+ * ),
40
+ * [],
41
+ * );
42
+ * const isExpanderDisabled = useCallback((rowData) => {
43
+ * return rowData.name === 'Name2';
44
+ * }, []);
45
+ * const columns = useMemo(() => [
46
+ * Header: 'Table',
47
+ * columns: [
48
+ * ExpanderColumn({ subComponent, isDisabled: isExpanderDisabled }),
49
+ * // Rest of your columns
50
+ * ],
51
+ * ], [isExpanderDisabled, subComponent]);
52
+ */
53
+ var ExpanderColumn = function (props) {
54
+ if (props === void 0) { props = {}; }
55
+ var subComponent = props.subComponent, isDisabled = props.isDisabled;
56
+ return {
57
+ id: exports.EXPANDER_CELL_ID,
58
+ disableResizing: true,
59
+ disableGroupBy: true,
60
+ disableReordering: true,
61
+ minWidth: 48,
62
+ width: 48,
63
+ maxWidth: 48,
64
+ columnClassName: 'iui-slot',
65
+ cellClassName: 'iui-slot',
66
+ Cell: function (props) {
67
+ var row = props.row;
68
+ if (!(subComponent === null || subComponent === void 0 ? void 0 : subComponent(row))) {
69
+ return null;
70
+ }
71
+ else {
72
+ return (react_1.default.createElement(Buttons_1.IconButton, { className: 'iui-row-expander', styleType: 'borderless', size: 'small', onClick: function (e) {
73
+ e.stopPropagation();
74
+ row.toggleRowExpanded();
75
+ }, disabled: isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(props.row.original) }, react_1.default.createElement(ChevronRight_1.default, null)));
76
+ }
77
+ },
78
+ cellRenderer: function (props) { return (react_1.default.createElement(cells_1.DefaultCell, __assign({}, props, { isDisabled: function (rowData) { return !!(isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(rowData)); } }))); },
79
+ };
80
+ };
81
+ exports.ExpanderColumn = ExpanderColumn;
@@ -0,0 +1,3 @@
1
+ export { ActionColumn } from './actionColumn';
2
+ export { SELECTION_CELL_ID, SelectionColumn } from './selectionColumn';
3
+ export { EXPANDER_CELL_ID, ExpanderColumn } from './expanderColumn';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpanderColumn = exports.EXPANDER_CELL_ID = exports.SelectionColumn = exports.SELECTION_CELL_ID = exports.ActionColumn = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ var actionColumn_1 = require("./actionColumn");
9
+ Object.defineProperty(exports, "ActionColumn", { enumerable: true, get: function () { return actionColumn_1.ActionColumn; } });
10
+ var selectionColumn_1 = require("./selectionColumn");
11
+ Object.defineProperty(exports, "SELECTION_CELL_ID", { enumerable: true, get: function () { return selectionColumn_1.SELECTION_CELL_ID; } });
12
+ Object.defineProperty(exports, "SelectionColumn", { enumerable: true, get: function () { return selectionColumn_1.SelectionColumn; } });
13
+ var expanderColumn_1 = require("./expanderColumn");
14
+ Object.defineProperty(exports, "EXPANDER_CELL_ID", { enumerable: true, get: function () { return expanderColumn_1.EXPANDER_CELL_ID; } });
15
+ Object.defineProperty(exports, "ExpanderColumn", { enumerable: true, get: function () { return expanderColumn_1.ExpanderColumn; } });