@itwin/itwinui-react 1.34.2 → 1.37.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 (158) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/cjs/core/ButtonGroup/ButtonGroup.js +1 -0
  3. package/cjs/core/Carousel/Carousel.d.ts +68 -0
  4. package/cjs/core/Carousel/Carousel.js +130 -0
  5. package/cjs/core/Carousel/CarouselContext.d.ts +37 -0
  6. package/cjs/core/Carousel/CarouselContext.js +12 -0
  7. package/cjs/core/Carousel/CarouselDot.d.ts +13 -0
  8. package/cjs/core/Carousel/CarouselDot.js +46 -0
  9. package/cjs/core/Carousel/CarouselDotsList.d.ts +32 -0
  10. package/cjs/core/Carousel/CarouselDotsList.js +132 -0
  11. package/cjs/core/Carousel/CarouselNavigation.d.ts +15 -0
  12. package/cjs/core/Carousel/CarouselNavigation.js +88 -0
  13. package/cjs/core/Carousel/CarouselSlide.d.ts +14 -0
  14. package/cjs/core/Carousel/CarouselSlide.js +63 -0
  15. package/cjs/core/Carousel/CarouselSlider.d.ts +5 -0
  16. package/cjs/core/Carousel/CarouselSlider.js +94 -0
  17. package/cjs/core/Carousel/index.d.ts +4 -0
  18. package/cjs/core/Carousel/index.js +10 -0
  19. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  20. package/cjs/core/DatePicker/DatePicker.d.ts +5 -0
  21. package/cjs/core/DatePicker/DatePicker.js +38 -13
  22. package/cjs/core/Header/HeaderButton.js +1 -0
  23. package/cjs/core/Menu/Menu.js +8 -3
  24. package/cjs/core/Modal/Modal.d.ts +5 -0
  25. package/cjs/core/Modal/Modal.js +11 -9
  26. package/cjs/core/Modal/ModalContent.d.ts +14 -0
  27. package/cjs/core/Modal/ModalContent.js +46 -0
  28. package/cjs/core/Modal/index.d.ts +2 -0
  29. package/cjs/core/Modal/index.js +3 -1
  30. package/cjs/core/SkipToContentLink/SkipToContentLink.d.ts +33 -0
  31. package/cjs/core/SkipToContentLink/SkipToContentLink.js +50 -0
  32. package/cjs/core/SkipToContentLink/index.d.ts +4 -0
  33. package/cjs/core/SkipToContentLink/index.js +10 -0
  34. package/cjs/core/Surface/Surface.d.ts +32 -0
  35. package/cjs/core/Surface/Surface.js +70 -0
  36. package/cjs/core/Surface/index.d.ts +4 -0
  37. package/cjs/core/Surface/index.js +10 -0
  38. package/cjs/core/Table/Table.d.ts +7 -0
  39. package/cjs/core/Table/Table.js +51 -27
  40. package/cjs/core/Table/TableCell.js +3 -3
  41. package/cjs/core/Table/TableRowMemoized.js +12 -7
  42. package/cjs/core/Table/actionHandlers/index.d.ts +2 -1
  43. package/cjs/core/Table/actionHandlers/index.js +5 -1
  44. package/cjs/core/Table/cells/DefaultCell.d.ts +1 -1
  45. package/cjs/core/Table/cells/DefaultCell.js +5 -2
  46. package/cjs/core/Table/columns/actionColumn.d.ts +35 -0
  47. package/cjs/core/Table/columns/actionColumn.js +91 -0
  48. package/cjs/core/Table/columns/expanderColumn.d.ts +47 -0
  49. package/cjs/core/Table/columns/expanderColumn.js +81 -0
  50. package/cjs/core/Table/columns/index.d.ts +3 -0
  51. package/cjs/core/Table/columns/index.js +15 -0
  52. package/cjs/core/Table/columns/selectionColumn.d.ts +35 -0
  53. package/cjs/core/Table/columns/selectionColumn.js +67 -0
  54. package/cjs/core/Table/hooks/index.d.ts +2 -2
  55. package/cjs/core/Table/hooks/index.js +1 -3
  56. package/cjs/core/Table/hooks/useExpanderCell.d.ts +0 -1
  57. package/cjs/core/Table/hooks/useExpanderCell.js +25 -39
  58. package/cjs/core/Table/hooks/useResizeColumns.js +8 -2
  59. package/cjs/core/Table/hooks/useSelectionCell.d.ts +1 -2
  60. package/cjs/core/Table/hooks/useSelectionCell.js +8 -53
  61. package/cjs/core/Table/index.d.ts +1 -0
  62. package/cjs/core/Table/index.js +5 -1
  63. package/cjs/core/Table/utils.js +1 -1
  64. package/cjs/core/Tag/Tag.js +6 -3
  65. package/cjs/core/Tile/Tile.d.ts +6 -2
  66. package/cjs/core/Tile/Tile.js +7 -2
  67. package/cjs/core/Toast/Toast.js +1 -1
  68. package/cjs/core/Typography/Anchor/Anchor.d.ts +1 -0
  69. package/cjs/core/Typography/Anchor/Anchor.js +1 -0
  70. package/cjs/core/index.d.ts +9 -3
  71. package/cjs/core/index.js +13 -2
  72. package/cjs/core/utils/components/Popover.js +13 -1
  73. package/cjs/core/utils/hooks/index.d.ts +1 -0
  74. package/cjs/core/utils/hooks/index.js +1 -0
  75. package/cjs/core/utils/hooks/useMediaQuery.d.ts +2 -0
  76. package/cjs/core/utils/hooks/useMediaQuery.js +46 -0
  77. package/cjs/core/utils/hooks/useTheme.d.ts +5 -0
  78. package/cjs/core/utils/hooks/useTheme.js +20 -14
  79. package/cjs/types/react-table-config.d.ts +18 -0
  80. package/esm/core/ButtonGroup/ButtonGroup.js +1 -0
  81. package/esm/core/Carousel/Carousel.d.ts +68 -0
  82. package/esm/core/Carousel/Carousel.js +124 -0
  83. package/esm/core/Carousel/CarouselContext.d.ts +37 -0
  84. package/esm/core/Carousel/CarouselContext.js +6 -0
  85. package/esm/core/Carousel/CarouselDot.d.ts +13 -0
  86. package/esm/core/Carousel/CarouselDot.js +40 -0
  87. package/esm/core/Carousel/CarouselDotsList.d.ts +32 -0
  88. package/esm/core/Carousel/CarouselDotsList.js +126 -0
  89. package/esm/core/Carousel/CarouselNavigation.d.ts +15 -0
  90. package/esm/core/Carousel/CarouselNavigation.js +82 -0
  91. package/esm/core/Carousel/CarouselSlide.d.ts +14 -0
  92. package/esm/core/Carousel/CarouselSlide.js +57 -0
  93. package/esm/core/Carousel/CarouselSlider.d.ts +5 -0
  94. package/esm/core/Carousel/CarouselSlider.js +88 -0
  95. package/esm/core/Carousel/index.d.ts +4 -0
  96. package/esm/core/Carousel/index.js +6 -0
  97. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  98. package/esm/core/DatePicker/DatePicker.d.ts +5 -0
  99. package/esm/core/DatePicker/DatePicker.js +38 -13
  100. package/esm/core/Header/HeaderButton.js +1 -0
  101. package/esm/core/Menu/Menu.js +8 -3
  102. package/esm/core/Modal/Modal.d.ts +5 -0
  103. package/esm/core/Modal/Modal.js +11 -9
  104. package/esm/core/Modal/ModalContent.d.ts +14 -0
  105. package/esm/core/Modal/ModalContent.js +39 -0
  106. package/esm/core/Modal/index.d.ts +2 -0
  107. package/esm/core/Modal/index.js +1 -0
  108. package/esm/core/SkipToContentLink/SkipToContentLink.d.ts +33 -0
  109. package/esm/core/SkipToContentLink/SkipToContentLink.js +44 -0
  110. package/esm/core/SkipToContentLink/index.d.ts +4 -0
  111. package/esm/core/SkipToContentLink/index.js +6 -0
  112. package/esm/core/Surface/Surface.d.ts +32 -0
  113. package/esm/core/Surface/Surface.js +64 -0
  114. package/esm/core/Surface/index.d.ts +4 -0
  115. package/esm/core/Surface/index.js +6 -0
  116. package/esm/core/Table/Table.d.ts +7 -0
  117. package/esm/core/Table/Table.js +47 -23
  118. package/esm/core/Table/TableCell.js +2 -2
  119. package/esm/core/Table/TableRowMemoized.js +12 -7
  120. package/esm/core/Table/actionHandlers/index.d.ts +2 -1
  121. package/esm/core/Table/actionHandlers/index.js +2 -1
  122. package/esm/core/Table/cells/DefaultCell.d.ts +1 -1
  123. package/esm/core/Table/cells/DefaultCell.js +5 -2
  124. package/esm/core/Table/columns/actionColumn.d.ts +35 -0
  125. package/esm/core/Table/columns/actionColumn.js +84 -0
  126. package/esm/core/Table/columns/expanderColumn.d.ts +47 -0
  127. package/esm/core/Table/columns/expanderColumn.js +74 -0
  128. package/esm/core/Table/columns/index.d.ts +3 -0
  129. package/esm/core/Table/columns/index.js +7 -0
  130. package/esm/core/Table/columns/selectionColumn.d.ts +35 -0
  131. package/esm/core/Table/columns/selectionColumn.js +60 -0
  132. package/esm/core/Table/hooks/index.d.ts +2 -2
  133. package/esm/core/Table/hooks/index.js +2 -2
  134. package/esm/core/Table/hooks/useExpanderCell.d.ts +0 -1
  135. package/esm/core/Table/hooks/useExpanderCell.js +24 -35
  136. package/esm/core/Table/hooks/useResizeColumns.js +8 -2
  137. package/esm/core/Table/hooks/useSelectionCell.d.ts +1 -2
  138. package/esm/core/Table/hooks/useSelectionCell.js +7 -49
  139. package/esm/core/Table/index.d.ts +1 -0
  140. package/esm/core/Table/index.js +1 -0
  141. package/esm/core/Table/utils.js +1 -1
  142. package/esm/core/Tag/Tag.js +6 -3
  143. package/esm/core/Tile/Tile.d.ts +6 -2
  144. package/esm/core/Tile/Tile.js +7 -2
  145. package/esm/core/Toast/Toast.js +1 -1
  146. package/esm/core/Typography/Anchor/Anchor.d.ts +1 -0
  147. package/esm/core/Typography/Anchor/Anchor.js +1 -0
  148. package/esm/core/index.d.ts +9 -3
  149. package/esm/core/index.js +5 -2
  150. package/esm/core/utils/components/Popover.js +13 -1
  151. package/esm/core/utils/hooks/index.d.ts +1 -0
  152. package/esm/core/utils/hooks/index.js +1 -0
  153. package/esm/core/utils/hooks/useMediaQuery.d.ts +2 -0
  154. package/esm/core/utils/hooks/useMediaQuery.js +39 -0
  155. package/esm/core/utils/hooks/useTheme.d.ts +5 -0
  156. package/esm/core/utils/hooks/useTheme.js +20 -14
  157. package/esm/types/react-table-config.d.ts +18 -0
  158. package/package.json +3 -2
@@ -25,6 +25,7 @@ var __rest = (this && this.__rest) || function (s, e) {
25
25
  * See LICENSE.md in the project root for license terms and full copyright notice.
26
26
  *--------------------------------------------------------------------------------------------*/
27
27
  import React from 'react';
28
+ import cx from 'classnames';
28
29
  /**
29
30
  * Default cell.
30
31
  * It should be passed to `cellRenderer`.
@@ -39,7 +40,9 @@ import React from 'react';
39
40
  export var DefaultCell = function (props) {
40
41
  // Omitting `cellProps`
41
42
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
- var cellElementProps = props.cellElementProps, children = props.children, cellProps = props.cellProps, rest = __rest(props, ["cellElementProps", "children", "cellProps"]);
43
- return (React.createElement("div", __assign({}, cellElementProps, rest), children));
43
+ 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"]);
44
+ return (React.createElement("div", __assign({}, cellElementProps, rest, { className: cx(cellElementClassName, className, {
45
+ 'iui-disabled': isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(cellProps.row.original),
46
+ }), style: __assign(__assign({}, cellElementStyle), style) }), children));
44
47
  };
45
48
  export default 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,84 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import React from 'react';
6
+ import { Checkbox } from '../../Checkbox';
7
+ import SvgColumnManager from '@itwin/itwinui-icons-react/cjs/icons/ColumnManager';
8
+ import { DropdownMenu } from '../../DropdownMenu';
9
+ import { IconButton } from '../../Buttons/IconButton';
10
+ import { MenuItem } from '../../Menu';
11
+ import { tableResizeStartAction } from '../Table';
12
+ import { SELECTION_CELL_ID } from './selectionColumn';
13
+ import { EXPANDER_CELL_ID } from './expanderColumn';
14
+ var ACTION_CELL_ID = 'iui-table-action';
15
+ /**
16
+ * Action column that adds column manager to the Table header.
17
+ * It is recommended to add this column to the end of the Table
18
+ * and to override its `Cell` prop with your row actions menu.
19
+ * @example
20
+ * {
21
+ * ...ActionColumn({ columnManager: true }),
22
+ * Cell: () => (
23
+ * <DropdownMenu menuItems={menuItems}>
24
+ * <IconButton
25
+ * styleType='borderless'
26
+ * onClick={(e) => e.stopPropagation()}
27
+ * >
28
+ * <SvgMore />
29
+ * </IconButton>
30
+ * </DropdownMenu>
31
+ * ),
32
+ * },
33
+ */
34
+ export var ActionColumn = function (_a) {
35
+ var _b = _a === void 0 ? {} : _a, _c = _b.columnManager, columnManager = _c === void 0 ? false : _c;
36
+ return {
37
+ id: ACTION_CELL_ID,
38
+ disableResizing: true,
39
+ disableGroupBy: true,
40
+ minWidth: 48,
41
+ width: 48,
42
+ maxWidth: 48,
43
+ columnClassName: 'iui-slot',
44
+ cellClassName: 'iui-slot',
45
+ disableReordering: true,
46
+ Header: function (_a) {
47
+ var allColumns = _a.allColumns, dispatch = _a.dispatch, state = _a.state;
48
+ var _b = React.useState(false), isOpen = _b[0], setIsOpen = _b[1];
49
+ if (!columnManager) {
50
+ return null;
51
+ }
52
+ var defaultColumnIds = [
53
+ SELECTION_CELL_ID,
54
+ EXPANDER_CELL_ID,
55
+ ACTION_CELL_ID,
56
+ ];
57
+ var headerCheckBoxes = function () {
58
+ return allColumns
59
+ //Filters out any default columns made such as selection and expansion
60
+ .filter(function (_a) {
61
+ var id = _a.id;
62
+ return !defaultColumnIds.includes(id);
63
+ })
64
+ .map(function (column) {
65
+ var checked = column.getToggleHiddenProps().checked;
66
+ var onClick = function () {
67
+ column.toggleHidden(checked);
68
+ // If no column was resized then leave table resize handling to the flexbox
69
+ if (Object.keys(state.columnResizing.columnWidths).length === 0) {
70
+ return;
71
+ }
72
+ // Triggers an update to resize the widths of all visible columns
73
+ dispatch({ type: tableResizeStartAction });
74
+ };
75
+ return (React.createElement(MenuItem, { key: column.id, icon: React.createElement(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 },
76
+ React.createElement("div", { id: "iui-column-" + column.id }, column.render('Header'))));
77
+ });
78
+ };
79
+ return (React.createElement(DropdownMenu, { menuItems: headerCheckBoxes, onHide: function () { return setIsOpen(false); }, onShow: function () { return setIsOpen(true); } },
80
+ React.createElement(IconButton, { styleType: 'borderless', isActive: isOpen },
81
+ React.createElement(SvgColumnManager, null))));
82
+ },
83
+ };
84
+ };
@@ -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,74 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ /*---------------------------------------------------------------------------------------------
13
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
14
+ * See LICENSE.md in the project root for license terms and full copyright notice.
15
+ *--------------------------------------------------------------------------------------------*/
16
+ import React from 'react';
17
+ import SvgChevronRight from '@itwin/itwinui-icons-react/cjs/icons/ChevronRight';
18
+ import { IconButton } from '../../Buttons';
19
+ import { DefaultCell } from '../cells';
20
+ export var EXPANDER_CELL_ID = 'iui-table-expander';
21
+ /**
22
+ * Expander column that adds sub-content expander column to the Table.
23
+ * It is recommended to use it as the first column or after selection column.
24
+ * @example
25
+ * const subComponent = useCallback(
26
+ * (row: Row) => (
27
+ * <div style={{ padding: 16 }}>
28
+ * <Leading>Extra information</Leading>
29
+ * <pre>
30
+ * <code>{JSON.stringify({ values: row.values }, null, 2)}</code>
31
+ * </pre>
32
+ * </div>
33
+ * ),
34
+ * [],
35
+ * );
36
+ * const isExpanderDisabled = useCallback((rowData) => {
37
+ * return rowData.name === 'Name2';
38
+ * }, []);
39
+ * const columns = useMemo(() => [
40
+ * Header: 'Table',
41
+ * columns: [
42
+ * ExpanderColumn({ subComponent, isDisabled: isExpanderDisabled }),
43
+ * // Rest of your columns
44
+ * ],
45
+ * ], [isExpanderDisabled, subComponent]);
46
+ */
47
+ export var ExpanderColumn = function (props) {
48
+ if (props === void 0) { props = {}; }
49
+ var subComponent = props.subComponent, isDisabled = props.isDisabled;
50
+ return {
51
+ id: EXPANDER_CELL_ID,
52
+ disableResizing: true,
53
+ disableGroupBy: true,
54
+ disableReordering: true,
55
+ minWidth: 48,
56
+ width: 48,
57
+ maxWidth: 48,
58
+ columnClassName: 'iui-slot',
59
+ cellClassName: 'iui-slot',
60
+ Cell: function (props) {
61
+ var row = props.row;
62
+ if (!(subComponent === null || subComponent === void 0 ? void 0 : subComponent(row))) {
63
+ return null;
64
+ }
65
+ else {
66
+ return (React.createElement(IconButton, { className: 'iui-row-expander', styleType: 'borderless', size: 'small', onClick: function (e) {
67
+ e.stopPropagation();
68
+ row.toggleRowExpanded();
69
+ }, disabled: isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(props.row.original) }, React.createElement(SvgChevronRight, null)));
70
+ }
71
+ },
72
+ cellRenderer: function (props) { return (React.createElement(DefaultCell, __assign({}, props, { isDisabled: function (rowData) { return !!(isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(rowData)); } }))); },
73
+ };
74
+ };
@@ -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,7 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ export { ActionColumn } from './actionColumn';
6
+ export { SELECTION_CELL_ID, SelectionColumn } from './selectionColumn';
7
+ export { EXPANDER_CELL_ID, ExpanderColumn } from './expanderColumn';
@@ -0,0 +1,35 @@
1
+ /// <reference types="react" />
2
+ import { CellProps, CellRendererProps, HeaderProps } from 'react-table';
3
+ export declare const SELECTION_CELL_ID = "iui-table-checkbox-selector";
4
+ /**
5
+ * Selection column that adds selection checkbox column to the Table.
6
+ * It is recommended to use it as the first column.
7
+ * @example
8
+ * const isCheckboxDisabled = useCallback((rowData) => {
9
+ * return rowData.name === 'Name1';
10
+ * }, []);
11
+ * const columns = useMemo(() => [
12
+ * Header: 'Table',
13
+ * columns: [
14
+ * SelectionColumn({ isDisabled: isCheckboxDisabled }),
15
+ * // Rest of your columns
16
+ * ],
17
+ * ], [isCheckboxDisabled]);
18
+ */
19
+ export declare const SelectionColumn: <T extends Record<string, unknown>>(props?: {
20
+ /** Function that returns whether row checkbox should be disabled. */
21
+ isDisabled?: ((rowData: T) => boolean) | undefined;
22
+ }) => {
23
+ id: string;
24
+ disableResizing: boolean;
25
+ disableGroupBy: boolean;
26
+ disableReordering: boolean;
27
+ minWidth: number;
28
+ width: number;
29
+ maxWidth: number;
30
+ columnClassName: string;
31
+ cellClassName: string;
32
+ Header: ({ getToggleAllRowsSelectedProps, rows, initialRows, state, }: HeaderProps<T>) => JSX.Element;
33
+ Cell: ({ row }: CellProps<T, any>) => JSX.Element;
34
+ cellRenderer: (props: CellRendererProps<T>) => JSX.Element;
35
+ };
@@ -0,0 +1,60 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ /*---------------------------------------------------------------------------------------------
13
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
14
+ * See LICENSE.md in the project root for license terms and full copyright notice.
15
+ *--------------------------------------------------------------------------------------------*/
16
+ import React from 'react';
17
+ import { Checkbox } from '../../Checkbox';
18
+ import { DefaultCell } from '../cells';
19
+ export var SELECTION_CELL_ID = 'iui-table-checkbox-selector';
20
+ /**
21
+ * Selection column that adds selection checkbox column to the Table.
22
+ * It is recommended to use it as the first column.
23
+ * @example
24
+ * const isCheckboxDisabled = useCallback((rowData) => {
25
+ * return rowData.name === 'Name1';
26
+ * }, []);
27
+ * const columns = useMemo(() => [
28
+ * Header: 'Table',
29
+ * columns: [
30
+ * SelectionColumn({ isDisabled: isCheckboxDisabled }),
31
+ * // Rest of your columns
32
+ * ],
33
+ * ], [isCheckboxDisabled]);
34
+ */
35
+ export var SelectionColumn = function (props) {
36
+ if (props === void 0) { props = {}; }
37
+ var isDisabled = props.isDisabled;
38
+ return {
39
+ id: SELECTION_CELL_ID,
40
+ disableResizing: true,
41
+ disableGroupBy: true,
42
+ disableReordering: true,
43
+ minWidth: 48,
44
+ width: 48,
45
+ maxWidth: 48,
46
+ columnClassName: 'iui-slot',
47
+ cellClassName: 'iui-slot',
48
+ Header: function (_a) {
49
+ var getToggleAllRowsSelectedProps = _a.getToggleAllRowsSelectedProps, rows = _a.rows, initialRows = _a.initialRows, state = _a.state;
50
+ var disabled = rows.every(function (row) { return isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(row.original); });
51
+ var checked = initialRows.every(function (row) { return state.selectedRowIds[row.id] || (isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(row.original)); });
52
+ return (React.createElement(Checkbox, __assign({}, getToggleAllRowsSelectedProps(), { style: {}, checked: checked && !disabled, indeterminate: !checked && Object.keys(state.selectedRowIds).length > 0, disabled: disabled })));
53
+ },
54
+ Cell: function (_a) {
55
+ var row = _a.row;
56
+ return (React.createElement(Checkbox, __assign({}, row.getToggleRowSelectedProps(), { style: {}, disabled: isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(row.original), onClick: function (e) { return e.stopPropagation(); } })));
57
+ },
58
+ cellRenderer: function (props) { return (React.createElement(DefaultCell, __assign({}, props, { isDisabled: function (rowData) { return !!(isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(rowData)); } }))); },
59
+ };
60
+ };
@@ -1,5 +1,5 @@
1
- export { EXPANDER_CELL_ID, useExpanderCell } from './useExpanderCell';
2
- export { SELECTION_CELL_ID, useSelectionCell } from './useSelectionCell';
1
+ export { useExpanderCell } from './useExpanderCell';
2
+ export { useSelectionCell } from './useSelectionCell';
3
3
  export { useSubRowFiltering } from './useSubRowFiltering';
4
4
  export { useSubRowSelection } from './useSubRowSelection';
5
5
  export { useResizeColumns } from './useResizeColumns';
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- export { EXPANDER_CELL_ID, useExpanderCell } from './useExpanderCell';
6
- export { SELECTION_CELL_ID, useSelectionCell } from './useSelectionCell';
5
+ export { useExpanderCell } from './useExpanderCell';
6
+ export { useSelectionCell } from './useSelectionCell';
7
7
  export { useSubRowFiltering } from './useSubRowFiltering';
8
8
  export { useSubRowSelection } from './useSubRowSelection';
9
9
  export { useResizeColumns } from './useResizeColumns';
@@ -1,4 +1,3 @@
1
1
  import React from 'react';
2
2
  import { CellProps, Hooks, Row } from 'react-table';
3
- export declare const EXPANDER_CELL_ID = "iui-table-expander";
4
3
  export declare const useExpanderCell: <T extends Record<string, unknown>>(subComponent?: ((row: Row<T>) => React.ReactNode) | undefined, expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined, isRowDisabled?: ((rowData: T) => boolean) | undefined) => (hooks: Hooks<T>) => void;
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
13
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
14
  if (ar || !(i in from)) {
@@ -7,44 +18,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
18
  }
8
19
  return to.concat(ar || Array.prototype.slice.call(from));
9
20
  };
10
- /*---------------------------------------------------------------------------------------------
11
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
12
- * See LICENSE.md in the project root for license terms and full copyright notice.
13
- *--------------------------------------------------------------------------------------------*/
14
- import SvgChevronRight from '@itwin/itwinui-icons-react/cjs/icons/ChevronRight';
15
- import React from 'react';
16
- import { IconButton } from '../../Buttons';
17
- export var EXPANDER_CELL_ID = 'iui-table-expander';
21
+ import { ExpanderColumn, EXPANDER_CELL_ID } from '../columns';
18
22
  export var useExpanderCell = function (subComponent, expanderCell, isRowDisabled) { return function (hooks) {
19
23
  if (!subComponent) {
20
24
  return;
21
25
  }
22
- hooks.allColumns.push(function (columns) { return __spreadArray([
23
- {
24
- id: EXPANDER_CELL_ID,
25
- disableResizing: true,
26
- disableGroupBy: true,
27
- minWidth: 48,
28
- width: 48,
29
- maxWidth: 48,
30
- columnClassName: 'iui-slot',
31
- cellClassName: 'iui-slot',
32
- disableReordering: true,
33
- Cell: function (props) {
34
- var row = props.row;
35
- if (!subComponent(row)) {
36
- return null;
37
- }
38
- else if (expanderCell) {
39
- return expanderCell(props);
40
- }
41
- else {
42
- return (React.createElement(IconButton, { className: 'iui-row-expander', styleType: 'borderless', size: 'small', onClick: function (e) {
43
- e.stopPropagation();
44
- row.toggleRowExpanded();
45
- }, disabled: isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(props.row.original) }, React.createElement(SvgChevronRight, null)));
46
- }
47
- },
26
+ hooks.allColumns.push(function (columns) {
27
+ var hasExpanderColumn = columns.find(function (c) { return c.id === EXPANDER_CELL_ID; });
28
+ if (hasExpanderColumn) {
29
+ return columns;
48
30
  }
49
- ], columns, true); });
31
+ var expanderColumn = ExpanderColumn({
32
+ subComponent: subComponent,
33
+ isDisabled: isRowDisabled,
34
+ });
35
+ return __spreadArray([
36
+ __assign(__assign({}, expanderColumn), { Cell: expanderCell !== null && expanderCell !== void 0 ? expanderCell : expanderColumn.Cell })
37
+ ], columns, true);
38
+ });
50
39
  }; };
@@ -225,7 +225,10 @@ var useInstanceBeforeDimensions = function (instance) {
225
225
  };
226
226
  var getPreviousResizableHeader = function (headerColumn, instance) {
227
227
  var _a;
228
- var headersList = ((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders;
228
+ var headersList = (((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders).filter(function (_a) {
229
+ var isVisible = _a.isVisible;
230
+ return isVisible;
231
+ });
229
232
  var headerIndex = headersList.findIndex(function (h) { return h.id === headerColumn.id; });
230
233
  return __spreadArray([], headersList, true).slice(0, headerIndex)
231
234
  .reverse()
@@ -233,7 +236,10 @@ var getPreviousResizableHeader = function (headerColumn, instance) {
233
236
  };
234
237
  var getNextResizableHeader = function (headerColumn, instance) {
235
238
  var _a;
236
- var headersList = ((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders;
239
+ var headersList = (((_a = headerColumn.parent) === null || _a === void 0 ? void 0 : _a.columns) || instance.flatHeaders).filter(function (_a) {
240
+ var isVisible = _a.isVisible;
241
+ return isVisible;
242
+ });
237
243
  var headerIndex = headersList.findIndex(function (h) { return h.id === headerColumn.id; });
238
244
  return __spreadArray([], headersList, true).slice(headerIndex + 1)
239
245
  .find(function (h) { return !h.disableResizing; });
@@ -1,3 +1,2 @@
1
1
  import { Hooks } from 'react-table';
2
- export declare const SELECTION_CELL_ID = "iui-table-checkbox-selector";
3
- export declare const useSelectionCell: <T extends Record<string, unknown>>(isSelectable: boolean, isRowDisabled?: ((rowData: T) => boolean) | undefined) => (hooks: Hooks<T>) => void;
2
+ export declare const useSelectionCell: <T extends Record<string, unknown>>(isSelectable: boolean, selectionMode: 'multi' | 'single', isRowDisabled?: ((rowData: T) => boolean) | undefined) => (hooks: Hooks<T>) => void;
@@ -1,14 +1,3 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
2
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
3
  if (ar || !(i in from)) {
@@ -18,46 +7,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
7
  }
19
8
  return to.concat(ar || Array.prototype.slice.call(from));
20
9
  };
21
- /*---------------------------------------------------------------------------------------------
22
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
23
- * See LICENSE.md in the project root for license terms and full copyright notice.
24
- *--------------------------------------------------------------------------------------------*/
25
- import React from 'react';
26
- import { Checkbox } from '../../Checkbox';
27
- export var SELECTION_CELL_ID = 'iui-table-checkbox-selector';
28
- export var useSelectionCell = function (isSelectable, isRowDisabled) { return function (hooks) {
10
+ import { SelectionColumn, SELECTION_CELL_ID } from '../columns';
11
+ export var useSelectionCell = function (isSelectable, selectionMode, isRowDisabled) { return function (hooks) {
29
12
  if (!isSelectable) {
30
13
  return;
31
14
  }
32
- hooks.allColumns.push(function (columns) { return __spreadArray([
33
- {
34
- id: SELECTION_CELL_ID,
35
- disableResizing: true,
36
- disableGroupBy: true,
37
- minWidth: 48,
38
- width: 48,
39
- maxWidth: 48,
40
- columnClassName: 'iui-slot',
41
- cellClassName: 'iui-slot',
42
- disableReordering: true,
43
- Header: function (_a) {
44
- var getToggleAllRowsSelectedProps = _a.getToggleAllRowsSelectedProps, rows = _a.rows, initialRows = _a.initialRows, state = _a.state;
45
- var disabled = rows.every(function (row) { return isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original); });
46
- var checked = initialRows.every(function (row) {
47
- return state.selectedRowIds[row.id] || (isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original));
48
- });
49
- return (React.createElement(Checkbox, __assign({}, getToggleAllRowsSelectedProps(), { checked: checked && !disabled, indeterminate: !checked && Object.keys(state.selectedRowIds).length > 0, disabled: disabled })));
50
- },
51
- Cell: function (_a) {
52
- var row = _a.row;
53
- return (React.createElement(Checkbox, __assign({}, row.getToggleRowSelectedProps(), { disabled: isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original), onClick: function (e) { return e.stopPropagation(); } })));
54
- },
55
- }
56
- ], columns, true); });
57
- hooks.useInstanceBeforeDimensions.push(function (_a) {
58
- var headerGroups = _a.headerGroups;
59
- // Fix the parent group of the selection button to not be resizable
60
- var selectionGroupHeader = headerGroups[0].headers[0];
61
- selectionGroupHeader.canResize = false;
15
+ hooks.allColumns.push(function (columns) {
16
+ return selectionMode === 'single' ||
17
+ columns.find(function (c) { return c.id === SELECTION_CELL_ID; })
18
+ ? columns
19
+ : __spreadArray([SelectionColumn({ isDisabled: isRowDisabled })], columns, true);
62
20
  });
63
21
  }; };
@@ -6,5 +6,6 @@ export { DefaultCell, EditableCell } from './cells';
6
6
  export type { DefaultCellProps, EditableCellProps } from './cells';
7
7
  export { TablePaginator } from './TablePaginator';
8
8
  export type { TablePaginatorProps } from './TablePaginator';
9
+ export { ActionColumn, ExpanderColumn, SelectionColumn } from './columns';
9
10
  declare const _default: "./Table";
10
11
  export default _default;
@@ -6,4 +6,5 @@ export { Table } from './Table';
6
6
  export { BaseFilter, FilterButtonBar, tableFilters } from './filters';
7
7
  export { DefaultCell, EditableCell } from './cells';
8
8
  export { TablePaginator } from './TablePaginator';
9
+ export { ActionColumn, ExpanderColumn, SelectionColumn } from './columns';
9
10
  export default './Table';
@@ -6,7 +6,7 @@ export var getCellStyle = function (column, isTableResizing) {
6
6
  style.width = width;
7
7
  // This allows flexbox to handle the width of the column on table resize
8
8
  if (isTableResizing && column.canResize) {
9
- style.flex = Number(column.width) + " 1 " + width;
9
+ style.flex = Number(column.width) + " " + Number(column.width) + " " + width;
10
10
  }
11
11
  else {
12
12
  style.flex = "0 0 " + width;
@@ -39,9 +39,12 @@ import { IconButton } from '../Buttons';
39
39
  export var Tag = function (props) {
40
40
  var className = props.className, _a = props.variant, variant = _a === void 0 ? 'default' : _a, children = props.children, onRemove = props.onRemove, rest = __rest(props, ["className", "variant", "children", "onRemove"]);
41
41
  useTheme();
42
- return (React.createElement("span", __assign({ className: cx('iui-tag', { 'iui-basic': variant === 'basic' }, className) }, rest),
43
- React.createElement("span", { className: 'iui-label' }, children),
44
- onRemove && (React.createElement(IconButton, { styleType: 'borderless', size: 'small', onClick: onRemove, "aria-label": 'Delete tag' },
42
+ return (React.createElement("span", __assign({ className: cx({
43
+ 'iui-tag-basic': variant === 'basic',
44
+ 'iui-tag': variant === 'default',
45
+ }, className) }, rest),
46
+ variant === 'default' ? (React.createElement("span", { className: 'iui-tag-label' }, children)) : (children),
47
+ onRemove && (React.createElement(IconButton, { styleType: 'borderless', size: 'small', onClick: onRemove, "aria-label": 'Delete tag', className: 'iui-tag-button' },
45
48
  React.createElement(SvgCloseSmall, { "aria-hidden": true })))));
46
49
  };
47
50
  export default Tag;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { CommonProps } from '../utils';
3
2
  import '@itwin/itwinui-css/css/tile.css';
4
3
  export declare type TileProps = {
5
4
  /**
@@ -80,7 +79,12 @@ export declare type TileProps = {
80
79
  * Any custom nodes that will be appended to the tile's main content.
81
80
  */
82
81
  children?: React.ReactNode;
83
- } & Omit<CommonProps, 'title'>;
82
+ /**
83
+ * Whether the tile is expected to be interactable (i.e. `onClick`).
84
+ * It becomes focusable and gets on hover styling.
85
+ */
86
+ isActionable?: boolean;
87
+ } & React.ComponentPropsWithoutRef<'div'>;
84
88
  /**
85
89
  * Tile component that displays content and actions in a card-like format.
86
90
  * @example