@itwin/itwinui-react 1.34.1 → 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.
- package/CHANGELOG.md +35 -0
- package/cjs/core/ButtonGroup/ButtonGroup.js +1 -0
- package/cjs/core/Carousel/Carousel.d.ts +68 -0
- package/cjs/core/Carousel/Carousel.js +130 -0
- package/cjs/core/Carousel/CarouselContext.d.ts +37 -0
- package/cjs/core/Carousel/CarouselContext.js +12 -0
- package/cjs/core/Carousel/CarouselDot.d.ts +13 -0
- package/cjs/core/Carousel/CarouselDot.js +46 -0
- package/cjs/core/Carousel/CarouselDotsList.d.ts +32 -0
- package/cjs/core/Carousel/CarouselDotsList.js +132 -0
- package/cjs/core/Carousel/CarouselNavigation.d.ts +15 -0
- package/cjs/core/Carousel/CarouselNavigation.js +88 -0
- package/cjs/core/Carousel/CarouselSlide.d.ts +14 -0
- package/cjs/core/Carousel/CarouselSlide.js +63 -0
- package/cjs/core/Carousel/CarouselSlider.d.ts +5 -0
- package/cjs/core/Carousel/CarouselSlider.js +94 -0
- package/cjs/core/Carousel/index.d.ts +4 -0
- package/cjs/core/Carousel/index.js +10 -0
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/DatePicker/DatePicker.d.ts +5 -0
- package/cjs/core/DatePicker/DatePicker.js +38 -13
- package/cjs/core/Menu/Menu.js +8 -3
- package/cjs/core/Modal/Modal.d.ts +5 -0
- package/cjs/core/Modal/Modal.js +11 -9
- package/cjs/core/Modal/ModalContent.d.ts +14 -0
- package/cjs/core/Modal/ModalContent.js +46 -0
- package/cjs/core/Modal/index.d.ts +2 -0
- package/cjs/core/Modal/index.js +3 -1
- package/cjs/core/Table/Table.d.ts +1 -0
- package/cjs/core/Table/Table.js +34 -20
- package/cjs/core/Table/TableCell.js +3 -3
- package/cjs/core/Table/TableRowMemoized.js +12 -7
- package/cjs/core/Table/actionHandlers/index.d.ts +2 -1
- package/cjs/core/Table/actionHandlers/index.js +5 -1
- package/cjs/core/Table/cells/DefaultCell.d.ts +1 -1
- package/cjs/core/Table/cells/DefaultCell.js +5 -2
- package/cjs/core/Table/columns/actionColumn.d.ts +35 -0
- package/cjs/core/Table/columns/actionColumn.js +91 -0
- package/cjs/core/Table/columns/expanderColumn.d.ts +47 -0
- package/cjs/core/Table/columns/expanderColumn.js +81 -0
- package/cjs/core/Table/columns/index.d.ts +3 -0
- package/cjs/core/Table/columns/index.js +15 -0
- package/cjs/core/Table/columns/selectionColumn.d.ts +35 -0
- package/cjs/core/Table/columns/selectionColumn.js +67 -0
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +18 -2
- package/cjs/core/Table/hooks/index.d.ts +2 -2
- package/cjs/core/Table/hooks/index.js +1 -3
- package/cjs/core/Table/hooks/useExpanderCell.d.ts +0 -1
- package/cjs/core/Table/hooks/useExpanderCell.js +25 -39
- package/cjs/core/Table/hooks/useResizeColumns.js +8 -2
- package/cjs/core/Table/hooks/useSelectionCell.d.ts +0 -1
- package/cjs/core/Table/hooks/useSelectionCell.js +6 -52
- package/cjs/core/Table/index.d.ts +1 -0
- package/cjs/core/Table/index.js +5 -1
- package/cjs/core/Table/utils.js +1 -1
- package/cjs/core/Toast/Toast.js +1 -1
- package/cjs/core/Typography/Anchor/Anchor.d.ts +1 -0
- package/cjs/core/Typography/Anchor/Anchor.js +1 -0
- package/cjs/core/index.d.ts +5 -3
- package/cjs/core/index.js +9 -2
- package/cjs/core/utils/components/Popover.js +13 -1
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useMediaQuery.d.ts +2 -0
- package/cjs/core/utils/hooks/useMediaQuery.js +46 -0
- package/cjs/core/utils/hooks/useTheme.d.ts +5 -0
- package/cjs/core/utils/hooks/useTheme.js +20 -14
- package/cjs/types/react-table-config.d.ts +18 -0
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -0
- package/esm/core/Carousel/Carousel.d.ts +68 -0
- package/esm/core/Carousel/Carousel.js +124 -0
- package/esm/core/Carousel/CarouselContext.d.ts +37 -0
- package/esm/core/Carousel/CarouselContext.js +6 -0
- package/esm/core/Carousel/CarouselDot.d.ts +13 -0
- package/esm/core/Carousel/CarouselDot.js +40 -0
- package/esm/core/Carousel/CarouselDotsList.d.ts +32 -0
- package/esm/core/Carousel/CarouselDotsList.js +126 -0
- package/esm/core/Carousel/CarouselNavigation.d.ts +15 -0
- package/esm/core/Carousel/CarouselNavigation.js +82 -0
- package/esm/core/Carousel/CarouselSlide.d.ts +14 -0
- package/esm/core/Carousel/CarouselSlide.js +57 -0
- package/esm/core/Carousel/CarouselSlider.d.ts +5 -0
- package/esm/core/Carousel/CarouselSlider.js +88 -0
- package/esm/core/Carousel/index.d.ts +4 -0
- package/esm/core/Carousel/index.js +6 -0
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/DatePicker/DatePicker.d.ts +5 -0
- package/esm/core/DatePicker/DatePicker.js +38 -13
- package/esm/core/Menu/Menu.js +8 -3
- package/esm/core/Modal/Modal.d.ts +5 -0
- package/esm/core/Modal/Modal.js +11 -9
- package/esm/core/Modal/ModalContent.d.ts +14 -0
- package/esm/core/Modal/ModalContent.js +39 -0
- package/esm/core/Modal/index.d.ts +2 -0
- package/esm/core/Modal/index.js +1 -0
- package/esm/core/Table/Table.d.ts +1 -0
- package/esm/core/Table/Table.js +30 -16
- package/esm/core/Table/TableCell.js +2 -2
- package/esm/core/Table/TableRowMemoized.js +12 -7
- package/esm/core/Table/actionHandlers/index.d.ts +2 -1
- package/esm/core/Table/actionHandlers/index.js +2 -1
- package/esm/core/Table/cells/DefaultCell.d.ts +1 -1
- package/esm/core/Table/cells/DefaultCell.js +5 -2
- package/esm/core/Table/columns/actionColumn.d.ts +35 -0
- package/esm/core/Table/columns/actionColumn.js +84 -0
- package/esm/core/Table/columns/expanderColumn.d.ts +47 -0
- package/esm/core/Table/columns/expanderColumn.js +74 -0
- package/esm/core/Table/columns/index.d.ts +3 -0
- package/esm/core/Table/columns/index.js +7 -0
- package/esm/core/Table/columns/selectionColumn.d.ts +35 -0
- package/esm/core/Table/columns/selectionColumn.js +60 -0
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +18 -2
- package/esm/core/Table/hooks/index.d.ts +2 -2
- package/esm/core/Table/hooks/index.js +2 -2
- package/esm/core/Table/hooks/useExpanderCell.d.ts +0 -1
- package/esm/core/Table/hooks/useExpanderCell.js +24 -35
- package/esm/core/Table/hooks/useResizeColumns.js +8 -2
- package/esm/core/Table/hooks/useSelectionCell.d.ts +0 -1
- package/esm/core/Table/hooks/useSelectionCell.js +5 -48
- package/esm/core/Table/index.d.ts +1 -0
- package/esm/core/Table/index.js +1 -0
- package/esm/core/Table/utils.js +1 -1
- package/esm/core/Toast/Toast.js +1 -1
- package/esm/core/Typography/Anchor/Anchor.d.ts +1 -0
- package/esm/core/Typography/Anchor/Anchor.js +1 -0
- package/esm/core/index.d.ts +5 -3
- package/esm/core/index.js +3 -2
- package/esm/core/utils/components/Popover.js +13 -1
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useMediaQuery.d.ts +2 -0
- package/esm/core/utils/hooks/useMediaQuery.js +39 -0
- package/esm/core/utils/hooks/useTheme.d.ts +5 -0
- package/esm/core/utils/hooks/useTheme.js +20 -14
- package/esm/types/react-table-config.d.ts +18 -0
- package/package.json +3 -2
package/cjs/core/Table/Table.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
139
|
+
case exports.tableResizeStartAction: {
|
|
140
|
+
newState = (0, actionHandlers_1.onTableResizeStart)(newState);
|
|
136
141
|
break;
|
|
137
142
|
}
|
|
138
143
|
case tableResizeEndAction: {
|
|
139
|
-
newState = (0,
|
|
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
|
-
}, [
|
|
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.
|
|
@@ -234,11 +247,12 @@ var Table = function (props) {
|
|
|
234
247
|
});
|
|
235
248
|
var headerRef = react_1.default.useRef(null);
|
|
236
249
|
var bodyRef = react_1.default.useRef(null);
|
|
237
|
-
var getPreparedRow = react_1.default.useCallback(function (
|
|
250
|
+
var getPreparedRow = react_1.default.useCallback(function (index) {
|
|
251
|
+
var row = page[index];
|
|
238
252
|
prepareRow(row);
|
|
239
|
-
return (react_1.default.createElement(TableRowMemoized_1.TableRowMemoized, { row: row, rowProps: rowProps, isLast:
|
|
253
|
+
return (react_1.default.createElement(TableRowMemoized_1.TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!(isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell }));
|
|
240
254
|
}, [
|
|
241
|
-
|
|
255
|
+
page,
|
|
242
256
|
expanderCell,
|
|
243
257
|
hasAnySubRows,
|
|
244
258
|
instance,
|
|
@@ -250,7 +264,7 @@ var Table = function (props) {
|
|
|
250
264
|
state,
|
|
251
265
|
subComponent,
|
|
252
266
|
]);
|
|
253
|
-
var virtualizedItemRenderer = react_1.default.useCallback(function (index) { return getPreparedRow(
|
|
267
|
+
var virtualizedItemRenderer = react_1.default.useCallback(function (index) { return getPreparedRow(index); }, [getPreparedRow]);
|
|
254
268
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
255
269
|
react_1.default.createElement("div", __assign({ ref: function (element) {
|
|
256
270
|
setOwnerDocument(element === null || element === void 0 ? void 0 : element.ownerDocument);
|
|
@@ -274,8 +288,8 @@ var Table = function (props) {
|
|
|
274
288
|
}
|
|
275
289
|
} }),
|
|
276
290
|
column.render('Header'),
|
|
277
|
-
|
|
278
|
-
|
|
291
|
+
(data.length !== 0 || areFiltersSet) && (react_1.default.createElement(filters_1.FilterToggle, { column: column, ownerDocument: ownerDocument })),
|
|
292
|
+
data.length !== 0 && column.canSort && (react_1.default.createElement("div", { className: 'iui-cell-end-icon' }, column.isSorted && column.isSortedDesc ? (react_1.default.createElement(SortUp_1.default, { className: 'iui-icon iui-sort', "aria-hidden": true })) : (react_1.default.createElement(SortDown_1.default, { className: 'iui-icon iui-sort', "aria-hidden": true })))),
|
|
279
293
|
isResizable &&
|
|
280
294
|
column.isResizerVisible &&
|
|
281
295
|
index !== headerGroup.headers.length - 1 && (react_1.default.createElement("div", __assign({}, column.getResizerProps(), { className: 'iui-resizer' }),
|
|
@@ -293,7 +307,7 @@ var Table = function (props) {
|
|
|
293
307
|
headerRef.current.scrollLeft = bodyRef.current.scrollLeft;
|
|
294
308
|
}
|
|
295
309
|
}, tabIndex: -1 }),
|
|
296
|
-
data.length !== 0 && (react_1.default.createElement(react_1.default.Fragment, null, enableVirtualization ? (react_1.default.createElement(VirtualScroll_1.default, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer })) : (page.map(function (
|
|
310
|
+
data.length !== 0 && (react_1.default.createElement(react_1.default.Fragment, null, enableVirtualization ? (react_1.default.createElement(VirtualScroll_1.default, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer })) : (page.map(function (_, index) { return getPreparedRow(index); })))),
|
|
297
311
|
isLoading && data.length === 0 && (react_1.default.createElement("div", { className: 'iui-table-empty' },
|
|
298
312
|
react_1.default.createElement(ProgressIndicators_1.ProgressRadial, { indeterminate: true }))),
|
|
299
313
|
isLoading && data.length !== 0 && (react_1.default.createElement("div", { className: 'iui-row' },
|
|
@@ -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
|
|
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 !==
|
|
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'
|
|
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
|
-
((
|
|
79
|
-
((
|
|
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
|
-
((
|
|
88
|
-
((
|
|
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
|
-
|
|
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:
|
|
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
|
|
49
|
-
return (react_1.default.createElement("div", __assign({}, cellElementProps, rest),
|
|
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,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; } });
|
|
@@ -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
|
+
};
|