@itwin/itwinui-react 1.39.0 → 1.41.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 +33 -0
- package/cjs/core/ComboBox/ComboBox.d.ts +10 -1
- package/cjs/core/ComboBox/ComboBox.js +42 -22
- package/cjs/core/ComboBox/ComboBoxInput.js +1 -0
- package/cjs/core/ComboBox/helpers.js +1 -1
- package/cjs/core/ErrorPage/ErrorPage.d.ts +3 -1
- package/cjs/core/ErrorPage/ErrorPage.js +31 -1
- package/cjs/core/Menu/MenuItemSkeleton.d.ts +32 -0
- package/cjs/core/Menu/MenuItemSkeleton.js +53 -0
- package/cjs/core/Menu/index.d.ts +2 -0
- package/cjs/core/Menu/index.js +3 -1
- package/cjs/core/Modal/Modal.d.ts +1 -0
- package/cjs/core/Modal/Modal.js +11 -8
- package/cjs/core/Table/Table.js +50 -14
- package/cjs/core/Table/TableCell.js +10 -3
- package/cjs/core/Table/TableRowMemoized.d.ts +2 -0
- package/cjs/core/Table/TableRowMemoized.js +20 -4
- package/cjs/core/Table/actionHandlers/resizeHandler.d.ts +8 -0
- package/cjs/core/Table/actionHandlers/selectHandler.d.ts +4 -0
- package/cjs/core/Table/cells/EditableCell.js +7 -2
- package/cjs/core/Table/columns/selectionColumn.js +4 -2
- package/cjs/core/Table/hooks/index.d.ts +1 -0
- package/cjs/core/Table/hooks/index.js +3 -1
- package/cjs/core/Table/hooks/useStickyColumns.d.ts +2 -0
- package/cjs/core/Table/hooks/useStickyColumns.js +84 -0
- package/cjs/core/Table/utils.d.ts +1 -0
- package/cjs/core/Table/utils.js +36 -1
- package/cjs/core/index.d.ts +2 -2
- package/cjs/core/index.js +4 -3
- package/cjs/core/utils/components/VirtualScroll.js +2 -2
- package/cjs/core/utils/components/VisuallyHidden.d.ts +9 -0
- package/cjs/core/utils/components/VisuallyHidden.js +44 -0
- package/cjs/core/utils/components/index.d.ts +1 -0
- package/cjs/core/utils/components/index.js +1 -0
- package/cjs/types/react-table-config.d.ts +9 -0
- package/esm/core/ComboBox/ComboBox.d.ts +10 -1
- package/esm/core/ComboBox/ComboBox.js +42 -22
- package/esm/core/ComboBox/ComboBoxInput.js +1 -0
- package/esm/core/ComboBox/helpers.js +1 -1
- package/esm/core/ErrorPage/ErrorPage.d.ts +3 -1
- package/esm/core/ErrorPage/ErrorPage.js +31 -1
- package/esm/core/Menu/MenuItemSkeleton.d.ts +32 -0
- package/esm/core/Menu/MenuItemSkeleton.js +46 -0
- package/esm/core/Menu/index.d.ts +2 -0
- package/esm/core/Menu/index.js +1 -0
- package/esm/core/Modal/Modal.d.ts +1 -0
- package/esm/core/Modal/Modal.js +11 -8
- package/esm/core/Table/Table.js +53 -17
- package/esm/core/Table/TableCell.js +11 -4
- package/esm/core/Table/TableRowMemoized.d.ts +2 -0
- package/esm/core/Table/TableRowMemoized.js +20 -4
- package/esm/core/Table/actionHandlers/resizeHandler.d.ts +8 -0
- package/esm/core/Table/actionHandlers/selectHandler.d.ts +4 -0
- package/esm/core/Table/cells/EditableCell.js +7 -2
- package/esm/core/Table/columns/selectionColumn.js +4 -2
- package/esm/core/Table/hooks/index.d.ts +1 -0
- package/esm/core/Table/hooks/index.js +1 -0
- package/esm/core/Table/hooks/useStickyColumns.d.ts +2 -0
- package/esm/core/Table/hooks/useStickyColumns.js +80 -0
- package/esm/core/Table/utils.d.ts +1 -0
- package/esm/core/Table/utils.js +34 -0
- package/esm/core/index.d.ts +2 -2
- package/esm/core/index.js +1 -1
- package/esm/core/utils/components/VirtualScroll.js +2 -2
- package/esm/core/utils/components/VisuallyHidden.d.ts +9 -0
- package/esm/core/utils/components/VisuallyHidden.js +38 -0
- package/esm/core/utils/components/index.d.ts +1 -0
- package/esm/core/utils/components/index.js +1 -0
- package/esm/types/react-table-config.d.ts +9 -0
- package/package.json +4 -4
|
@@ -20,6 +20,7 @@ export declare const TableRow: <T extends Record<string, unknown>>(props: {
|
|
|
20
20
|
tableHasSubRows: boolean;
|
|
21
21
|
tableInstance: TableInstance<T>;
|
|
22
22
|
expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
|
|
23
|
+
bodyRef: HTMLDivElement | null;
|
|
23
24
|
}) => JSX.Element;
|
|
24
25
|
export declare const TableRowMemoized: <T extends Record<string, unknown>>(props: {
|
|
25
26
|
row: Row<T>;
|
|
@@ -35,4 +36,5 @@ export declare const TableRowMemoized: <T extends Record<string, unknown>>(props
|
|
|
35
36
|
tableHasSubRows: boolean;
|
|
36
37
|
tableInstance: TableInstance<T>;
|
|
37
38
|
expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
|
|
39
|
+
bodyRef: HTMLDivElement | null;
|
|
38
40
|
}) => JSX.Element;
|
|
@@ -30,14 +30,25 @@ var TableCell_1 = require("./TableCell");
|
|
|
30
30
|
* When adding new features check whether it changes state that affects row. If it does then add equality check to `React.memo`.
|
|
31
31
|
*/
|
|
32
32
|
var TableRow = function (props) {
|
|
33
|
-
var row = props.row, rowProps = props.rowProps, isLast = props.isLast, onRowInViewport = props.onRowInViewport, onBottomReached = props.onBottomReached, intersectionMargin = props.intersectionMargin, onClick = props.onClick, subComponent = props.subComponent, isDisabled = props.isDisabled, tableHasSubRows = props.tableHasSubRows, tableInstance = props.tableInstance, expanderCell = props.expanderCell;
|
|
33
|
+
var row = props.row, rowProps = props.rowProps, isLast = props.isLast, onRowInViewport = props.onRowInViewport, onBottomReached = props.onBottomReached, intersectionMargin = props.intersectionMargin, onClick = props.onClick, subComponent = props.subComponent, isDisabled = props.isDisabled, tableHasSubRows = props.tableHasSubRows, tableInstance = props.tableInstance, expanderCell = props.expanderCell, bodyRef = props.bodyRef;
|
|
34
34
|
var onIntersect = react_1.default.useCallback(function () {
|
|
35
35
|
var _a, _b;
|
|
36
36
|
(_a = onRowInViewport.current) === null || _a === void 0 ? void 0 : _a.call(onRowInViewport, row.original);
|
|
37
37
|
isLast && ((_b = onBottomReached.current) === null || _b === void 0 ? void 0 : _b.call(onBottomReached));
|
|
38
38
|
}, [isLast, onBottomReached, onRowInViewport, row.original]);
|
|
39
|
-
var
|
|
39
|
+
var intersectionRoot = react_1.default.useMemo(function () {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
var isTableBodyScrollable = ((_a = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.scrollHeight) !== null && _a !== void 0 ? _a : 0) > ((_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.offsetHeight) !== null && _b !== void 0 ? _b : 0);
|
|
42
|
+
// If table body is scrollable, make it the intersection root
|
|
43
|
+
if (isTableBodyScrollable) {
|
|
44
|
+
return bodyRef;
|
|
45
|
+
}
|
|
46
|
+
// Otherwise, make the viewport the intersection root
|
|
47
|
+
return undefined;
|
|
48
|
+
}, [bodyRef]);
|
|
49
|
+
var intersectionRef = (0, utils_1.useIntersection)(onIntersect, {
|
|
40
50
|
rootMargin: "".concat(intersectionMargin, "px"),
|
|
51
|
+
root: intersectionRoot,
|
|
41
52
|
});
|
|
42
53
|
var userRowProps = rowProps === null || rowProps === void 0 ? void 0 : rowProps(row);
|
|
43
54
|
var mergedProps = __assign(__assign(__assign({}, row.getRowProps({ style: { flex: "0 0 auto", minWidth: '100%' } })), userRowProps), {
|
|
@@ -47,7 +58,7 @@ var TableRow = function (props) {
|
|
|
47
58
|
'iui-disabled': isDisabled,
|
|
48
59
|
}, userRowProps === null || userRowProps === void 0 ? void 0 : userRowProps.className),
|
|
49
60
|
});
|
|
50
|
-
var refs = (0, utils_1.useMergedRefs)(
|
|
61
|
+
var refs = (0, utils_1.useMergedRefs)(intersectionRef, mergedProps.ref);
|
|
51
62
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
52
63
|
react_1.default.createElement("div", __assign({}, mergedProps, { ref: refs, onClick: function (event) {
|
|
53
64
|
var _a;
|
|
@@ -97,7 +108,12 @@ exports.TableRowMemoized = react_1.default.memo(exports.TableRow, function (prev
|
|
|
97
108
|
prevProp.rowProps === nextProp.rowProps &&
|
|
98
109
|
prevProp.expanderCell === nextProp.expanderCell &&
|
|
99
110
|
prevProp.tableHasSubRows === nextProp.tableHasSubRows &&
|
|
111
|
+
prevProp.bodyRef === nextProp.bodyRef &&
|
|
100
112
|
prevProp.state.columnOrder === nextProp.state.columnOrder &&
|
|
101
113
|
!nextProp.state.columnResizing.isResizingColumn &&
|
|
102
|
-
prevProp.state.isTableResizing === nextProp.state.isTableResizing
|
|
114
|
+
prevProp.state.isTableResizing === nextProp.state.isTableResizing &&
|
|
115
|
+
prevProp.state.sticky.isScrolledToLeft ===
|
|
116
|
+
nextProp.state.sticky.isScrolledToLeft &&
|
|
117
|
+
prevProp.state.sticky.isScrolledToRight ===
|
|
118
|
+
nextProp.state.sticky.isScrolledToRight;
|
|
103
119
|
});
|
|
@@ -12,6 +12,10 @@ export declare const onTableResizeStart: <T extends Record<string, unknown>>(sta
|
|
|
12
12
|
isResizingColumn?: string | undefined;
|
|
13
13
|
};
|
|
14
14
|
columnReorderStartIndex: number;
|
|
15
|
+
sticky: {
|
|
16
|
+
isScrolledToRight?: boolean | undefined;
|
|
17
|
+
isScrolledToLeft?: boolean | undefined;
|
|
18
|
+
};
|
|
15
19
|
columnOrder: import("react-table").IdType<T>[];
|
|
16
20
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
17
21
|
filters: import("react-table").Filters<T>;
|
|
@@ -38,6 +42,10 @@ export declare const onTableResizeEnd: <T extends Record<string, unknown>>(state
|
|
|
38
42
|
};
|
|
39
43
|
hiddenColumns?: import("react-table").IdType<T>[] | undefined;
|
|
40
44
|
columnReorderStartIndex: number;
|
|
45
|
+
sticky: {
|
|
46
|
+
isScrolledToRight?: boolean | undefined;
|
|
47
|
+
isScrolledToLeft?: boolean | undefined;
|
|
48
|
+
};
|
|
41
49
|
columnOrder: import("react-table").IdType<T>[];
|
|
42
50
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
43
51
|
filters: import("react-table").Filters<T>;
|
|
@@ -20,6 +20,10 @@ export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(
|
|
|
20
20
|
};
|
|
21
21
|
isTableResizing?: boolean | undefined;
|
|
22
22
|
columnReorderStartIndex: number;
|
|
23
|
+
sticky: {
|
|
24
|
+
isScrolledToRight?: boolean | undefined;
|
|
25
|
+
isScrolledToLeft?: boolean | undefined;
|
|
26
|
+
};
|
|
23
27
|
columnOrder: import("react-table").IdType<T>[];
|
|
24
28
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
25
29
|
filters: import("react-table").Filters<T>;
|
|
@@ -31,6 +31,7 @@ exports.EditableCell = 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 utils_1 = require("../../utils");
|
|
34
35
|
/**
|
|
35
36
|
* Editable cell.
|
|
36
37
|
* It should be passed to `cellRenderer`.
|
|
@@ -53,8 +54,9 @@ var EditableCell = function (props) {
|
|
|
53
54
|
react_1.default.useEffect(function () {
|
|
54
55
|
setValue(sanitizeString(cellProps.value));
|
|
55
56
|
}, [cellProps.value]);
|
|
56
|
-
var _b = react_1.default.useState(
|
|
57
|
-
|
|
57
|
+
var _b = react_1.default.useState((0, utils_1.getRandomValue)(10)), key = _b[0], setKey = _b[1];
|
|
58
|
+
var _c = react_1.default.useState(false), isDirty = _c[0], setIsDirty = _c[1];
|
|
59
|
+
return (react_1.default.createElement("div", __assign({}, cellElementProps, { contentEditable: true, suppressContentEditableWarning: true, key: key }, rest, { onInput: function (e) {
|
|
58
60
|
var _a;
|
|
59
61
|
setValue(sanitizeString(e.target.innerText));
|
|
60
62
|
setIsDirty(true);
|
|
@@ -65,6 +67,9 @@ var EditableCell = function (props) {
|
|
|
65
67
|
onCellEdit(cellProps.column.id, value, cellProps.row.original);
|
|
66
68
|
}
|
|
67
69
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
70
|
+
// Prevents error when text is cleared.
|
|
71
|
+
// New key makes React to reattach with the DOM so it won't complain about deleted text node.
|
|
72
|
+
setKey((0, utils_1.getRandomValue)(10));
|
|
68
73
|
}, onKeyDown: function (e) {
|
|
69
74
|
var _a;
|
|
70
75
|
// Prevents from adding HTML elements (div, br) inside a cell on Enter press
|
|
@@ -55,11 +55,13 @@ var SelectionColumn = function (props) {
|
|
|
55
55
|
var getToggleAllRowsSelectedProps = _a.getToggleAllRowsSelectedProps, rows = _a.rows, initialRows = _a.initialRows, state = _a.state;
|
|
56
56
|
var disabled = rows.every(function (row) { return isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(row.original); });
|
|
57
57
|
var checked = initialRows.every(function (row) { return state.selectedRowIds[row.id] || (isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(row.original)); });
|
|
58
|
-
return (react_1.default.createElement(Checkbox_1.Checkbox, __assign({}, getToggleAllRowsSelectedProps(), { style: {},
|
|
58
|
+
return (react_1.default.createElement(Checkbox_1.Checkbox, __assign({}, getToggleAllRowsSelectedProps(), { style: {}, title: '' // Removes default title that comes from react-table
|
|
59
|
+
, checked: checked && !disabled, indeterminate: !checked && Object.keys(state.selectedRowIds).length > 0, disabled: disabled })));
|
|
59
60
|
},
|
|
60
61
|
Cell: function (_a) {
|
|
61
62
|
var row = _a.row;
|
|
62
|
-
return (react_1.default.createElement(Checkbox_1.Checkbox, __assign({}, row.getToggleRowSelectedProps(), { style: {},
|
|
63
|
+
return (react_1.default.createElement(Checkbox_1.Checkbox, __assign({}, row.getToggleRowSelectedProps(), { style: {}, title: '' // Removes default title that comes from react-table
|
|
64
|
+
, disabled: isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(row.original), onClick: function (e) { return e.stopPropagation(); } })));
|
|
63
65
|
},
|
|
64
66
|
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)); } }))); },
|
|
65
67
|
};
|
|
@@ -4,3 +4,4 @@ export { useSubRowFiltering } from './useSubRowFiltering';
|
|
|
4
4
|
export { useSubRowSelection } from './useSubRowSelection';
|
|
5
5
|
export { useResizeColumns } from './useResizeColumns';
|
|
6
6
|
export { useColumnDragAndDrop } from './useColumnDragAndDrop';
|
|
7
|
+
export { useStickyColumns } from './useStickyColumns';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useColumnDragAndDrop = exports.useResizeColumns = exports.useSubRowSelection = exports.useSubRowFiltering = exports.useSelectionCell = exports.useExpanderCell = void 0;
|
|
3
|
+
exports.useStickyColumns = exports.useColumnDragAndDrop = exports.useResizeColumns = exports.useSubRowSelection = exports.useSubRowFiltering = exports.useSelectionCell = exports.useExpanderCell = 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.
|
|
@@ -17,3 +17,5 @@ var useResizeColumns_1 = require("./useResizeColumns");
|
|
|
17
17
|
Object.defineProperty(exports, "useResizeColumns", { enumerable: true, get: function () { return useResizeColumns_1.useResizeColumns; } });
|
|
18
18
|
var useColumnDragAndDrop_1 = require("./useColumnDragAndDrop");
|
|
19
19
|
Object.defineProperty(exports, "useColumnDragAndDrop", { enumerable: true, get: function () { return useColumnDragAndDrop_1.useColumnDragAndDrop; } });
|
|
20
|
+
var useStickyColumns_1 = require("./useStickyColumns");
|
|
21
|
+
Object.defineProperty(exports, "useStickyColumns", { enumerable: true, get: function () { return useStickyColumns_1.useStickyColumns; } });
|
|
@@ -0,0 +1,84 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.useStickyColumns = void 0;
|
|
24
|
+
/*---------------------------------------------------------------------------------------------
|
|
25
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
26
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
27
|
+
*--------------------------------------------------------------------------------------------*/
|
|
28
|
+
var react_table_1 = require("react-table");
|
|
29
|
+
react_table_1.actions.setScrolledLeft = 'setScrolledLeft';
|
|
30
|
+
react_table_1.actions.setScrolledRight = 'setScrolledRight';
|
|
31
|
+
var useStickyColumns = function (hooks) {
|
|
32
|
+
hooks.stateReducers.push(reducer);
|
|
33
|
+
hooks.useInstance.push(useInstance);
|
|
34
|
+
};
|
|
35
|
+
exports.useStickyColumns = useStickyColumns;
|
|
36
|
+
var reducer = function (newState, action) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
if (action.type === react_table_1.actions.init) {
|
|
39
|
+
return __assign(__assign({}, newState), { sticky: {} });
|
|
40
|
+
}
|
|
41
|
+
if (action.type === react_table_1.actions.setScrolledLeft &&
|
|
42
|
+
((_a = newState.sticky) === null || _a === void 0 ? void 0 : _a.isScrolledToLeft) !== action.value // Prevents unnecessary re-render
|
|
43
|
+
) {
|
|
44
|
+
return __assign(__assign({}, newState), { sticky: __assign(__assign({}, newState.sticky), { isScrolledToLeft: action.value }) });
|
|
45
|
+
}
|
|
46
|
+
if (action.type === react_table_1.actions.setScrolledRight &&
|
|
47
|
+
((_b = newState.sticky) === null || _b === void 0 ? void 0 : _b.isScrolledToRight) !== action.value // Prevents unnecessary re-render
|
|
48
|
+
) {
|
|
49
|
+
return __assign(__assign({}, newState), { sticky: __assign(__assign({}, newState.sticky), { isScrolledToRight: action.value }) });
|
|
50
|
+
}
|
|
51
|
+
return newState;
|
|
52
|
+
};
|
|
53
|
+
var useInstance = function (instance) {
|
|
54
|
+
var flatHeaders = instance.flatHeaders;
|
|
55
|
+
// Edge case. Saving original sticky state in case sticky columns are reordered.
|
|
56
|
+
flatHeaders.forEach(function (header) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (!header.originalSticky) {
|
|
59
|
+
header.originalSticky = (_a = header.sticky) !== null && _a !== void 0 ? _a : 'none';
|
|
60
|
+
}
|
|
61
|
+
header.sticky =
|
|
62
|
+
header.originalSticky === 'none' ? undefined : header.originalSticky;
|
|
63
|
+
});
|
|
64
|
+
// If there is a column that is sticked to the left, make every column prior to that sticky too.
|
|
65
|
+
var hasLeftStickyColumn = false;
|
|
66
|
+
__spreadArray([], flatHeaders, true).reverse().forEach(function (header) {
|
|
67
|
+
if (header.sticky === 'left') {
|
|
68
|
+
hasLeftStickyColumn = true;
|
|
69
|
+
}
|
|
70
|
+
if (hasLeftStickyColumn) {
|
|
71
|
+
header.sticky = 'left';
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// If there is a column that is sticked to the right, make every column after to that sticky too.
|
|
75
|
+
var hasRightStickyColumn = false;
|
|
76
|
+
flatHeaders.forEach(function (header) {
|
|
77
|
+
if (header.sticky === 'right') {
|
|
78
|
+
hasRightStickyColumn = true;
|
|
79
|
+
}
|
|
80
|
+
if (hasRightStickyColumn) {
|
|
81
|
+
header.sticky = 'right';
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { ColumnInstance } from 'react-table';
|
|
2
2
|
export declare const getCellStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, isTableResizing: boolean) => React.CSSProperties | undefined;
|
|
3
|
+
export declare const getStickyStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, columnList: ColumnInstance<T>[]) => React.CSSProperties;
|
package/cjs/core/Table/utils.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCellStyle = void 0;
|
|
12
|
+
exports.getStickyStyle = exports.getCellStyle = void 0;
|
|
4
13
|
var getCellStyle = function (column, isTableResizing) {
|
|
5
14
|
var style = {};
|
|
6
15
|
style.flex = "1 1 145px";
|
|
@@ -24,3 +33,29 @@ var getCellStyle = function (column, isTableResizing) {
|
|
|
24
33
|
return style;
|
|
25
34
|
};
|
|
26
35
|
exports.getCellStyle = getCellStyle;
|
|
36
|
+
var getStickyStyle = function (column, columnList) {
|
|
37
|
+
if (!column.sticky) {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
var left = 0;
|
|
41
|
+
for (var _i = 0, columnList_1 = columnList; _i < columnList_1.length; _i++) {
|
|
42
|
+
var col = columnList_1[_i];
|
|
43
|
+
if (col.id === column.id) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
left += Number(col.width || col.resizeWidth || 0);
|
|
47
|
+
}
|
|
48
|
+
var right = 0;
|
|
49
|
+
for (var _a = 0, _b = __spreadArray([], columnList, true).reverse(); _a < _b.length; _a++) {
|
|
50
|
+
var col = _b[_a];
|
|
51
|
+
if (col.id === column.id) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
right += Number(col.width || col.resizeWidth || 0);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
'--iui-table-sticky-left': column.sticky === 'left' ? "".concat(left, "px") : undefined,
|
|
58
|
+
'--iui-table-sticky-right': column.sticky === 'right' ? "".concat(right, "px") : undefined,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.getStickyStyle = getStickyStyle;
|
package/cjs/core/index.d.ts
CHANGED
|
@@ -48,8 +48,8 @@ export { LabeledSelect } from './LabeledSelect';
|
|
|
48
48
|
export type { LabeledSelectProps } from './LabeledSelect';
|
|
49
49
|
export { LabeledTextarea } from './LabeledTextarea';
|
|
50
50
|
export type { LabeledTextareaProps } from './LabeledTextarea';
|
|
51
|
-
export { Menu, MenuItem, MenuDivider, MenuExtraContent } from './Menu';
|
|
52
|
-
export type { MenuProps, MenuItemProps, MenuDividerProps, MenuExtraContentProps, } from './Menu';
|
|
51
|
+
export { Menu, MenuItem, MenuDivider, MenuExtraContent, MenuItemSkeleton, } from './Menu';
|
|
52
|
+
export type { MenuProps, MenuItemProps, MenuDividerProps, MenuExtraContentProps, MenuItemSkeletonProps, } from './Menu';
|
|
53
53
|
export { Modal, ModalButtonBar, ModalContent } from './Modal';
|
|
54
54
|
export type { ModalProps, ModalButtonBarProps, ModalContentProps, } from './Modal';
|
|
55
55
|
export { ProgressLinear, ProgressRadial } from './ProgressIndicators';
|
package/cjs/core/index.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.MiddleTextTruncation = exports.ColorValue = exports.useTheme = exports.getUserColor = exports.Wizard = exports.UserIconGroup = void 0;
|
|
6
|
+
exports.MenuItemSkeleton = exports.MenuExtraContent = exports.MenuDivider = exports.MenuItem = exports.Menu = exports.LabeledTextarea = exports.LabeledSelect = exports.InputGroup = exports.LabeledInput = exports.Label = exports.Input = exports.InformationPanelContent = exports.InformationPanelBody = exports.InformationPanelHeader = exports.InformationPanelWrapper = exports.InformationPanel = exports.HorizontalTab = exports.HorizontalTabs = exports.Tab = exports.VerticalTabs = exports.HeaderLogo = exports.HeaderButton = exports.HeaderBreadcrumbs = exports.Header = exports.Footer = exports.FileUploadTemplate = exports.FileUpload = exports.Fieldset = exports.ExpandableBlock = exports.ErrorPage = exports.DropdownMenu = exports.generateLocalizedStrings = exports.DatePicker = exports.ComboBox = exports.ColorPalette = exports.ColorInputPanel = exports.ColorBuilder = exports.ColorSwatch = exports.ColorPicker = exports.Checkbox = exports.Carousel = exports.ButtonGroup = exports.SplitButton = exports.IdeasButton = exports.IconButton = exports.DropdownButton = exports.Button = exports.Breadcrumbs = exports.Badge = exports.Alert = void 0;
|
|
7
|
+
exports.Text = exports.KbdKeys = exports.Kbd = exports.Code = exports.Blockquote = exports.Title = exports.Subheading = exports.Small = exports.Leading = exports.Headline = exports.Body = exports.Anchor = exports.TreeNodeExpander = exports.TreeNode = exports.Tree = exports.Tooltip = exports.ToggleSwitch = exports.ThemeProvider = exports.toaster = exports.TimePicker = exports.Tile = exports.Textarea = exports.TagContainer = exports.Tag = exports.SelectionColumn = exports.ExpanderColumn = exports.ActionColumn = exports.TablePaginator = exports.EditableCell = exports.DefaultCell = exports.FilterButtonBar = exports.tableFilters = exports.Table = exports.Surface = exports.StatusMessage = exports.Slider = exports.SkipToContentLink = exports.SidenavSubmenuHeader = exports.SidenavSubmenu = exports.SidenavButton = exports.SideNavigation = exports.Select = exports.RadioTileGroup = exports.RadioTile = exports.Radio = exports.ProgressRadial = exports.ProgressLinear = exports.ModalContent = exports.ModalButtonBar = exports.Modal = void 0;
|
|
8
|
+
exports.MiddleTextTruncation = exports.ColorValue = exports.useTheme = exports.getUserColor = exports.Wizard = exports.UserIconGroup = exports.UserIcon = void 0;
|
|
9
9
|
/*---------------------------------------------------------------------------------------------
|
|
10
10
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
11
11
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -85,6 +85,7 @@ Object.defineProperty(exports, "Menu", { enumerable: true, get: function () { re
|
|
|
85
85
|
Object.defineProperty(exports, "MenuItem", { enumerable: true, get: function () { return Menu_1.MenuItem; } });
|
|
86
86
|
Object.defineProperty(exports, "MenuDivider", { enumerable: true, get: function () { return Menu_1.MenuDivider; } });
|
|
87
87
|
Object.defineProperty(exports, "MenuExtraContent", { enumerable: true, get: function () { return Menu_1.MenuExtraContent; } });
|
|
88
|
+
Object.defineProperty(exports, "MenuItemSkeleton", { enumerable: true, get: function () { return Menu_1.MenuItemSkeleton; } });
|
|
88
89
|
var Modal_1 = require("./Modal");
|
|
89
90
|
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return Modal_1.Modal; } });
|
|
90
91
|
Object.defineProperty(exports, "ModalButtonBar", { enumerable: true, get: function () { return Modal_1.ModalButtonBar; } });
|
|
@@ -291,11 +291,11 @@ var useVirtualization = function (props) {
|
|
|
291
291
|
updateVirtualScroll();
|
|
292
292
|
}, [scrollContainerHeight, updateVirtualScroll]);
|
|
293
293
|
return {
|
|
294
|
-
outerProps: __assign({ style: __assign({
|
|
294
|
+
outerProps: __assign({ style: __assign({ minHeight: itemsLength > 1
|
|
295
295
|
? Math.max(itemsLength - 2, 0) * childHeight.current.middle +
|
|
296
296
|
childHeight.current.first +
|
|
297
297
|
childHeight.current.last
|
|
298
|
-
: childHeight.current.middle,
|
|
298
|
+
: childHeight.current.middle, minWidth: '100%' }, style) }, rest),
|
|
299
299
|
innerProps: {
|
|
300
300
|
style: { willChange: 'transform' },
|
|
301
301
|
ref: (0, hooks_1.mergeRefs)(parentRef), // convert object ref to callback ref for better types
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type VisuallyHiddenProps = React.ComponentPropsWithRef<'div'>;
|
|
3
|
+
/**
|
|
4
|
+
* Hides content visually but is still accessible to screen readers.
|
|
5
|
+
*/
|
|
6
|
+
export declare const VisuallyHidden: React.ForwardRefExoticComponent<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
7
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
8
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export default VisuallyHidden;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.VisuallyHidden = void 0;
|
|
29
|
+
/*---------------------------------------------------------------------------------------------
|
|
30
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
31
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
32
|
+
*--------------------------------------------------------------------------------------------*/
|
|
33
|
+
var react_1 = __importDefault(require("react"));
|
|
34
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
35
|
+
var hooks_1 = require("../hooks");
|
|
36
|
+
/**
|
|
37
|
+
* Hides content visually but is still accessible to screen readers.
|
|
38
|
+
*/
|
|
39
|
+
exports.VisuallyHidden = react_1.default.forwardRef(function (props, ref) {
|
|
40
|
+
var className = props.className, rest = __rest(props, ["className"]);
|
|
41
|
+
(0, hooks_1.useTheme)();
|
|
42
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-visually-hidden', className), ref: ref }, rest)));
|
|
43
|
+
});
|
|
44
|
+
exports.default = exports.VisuallyHidden;
|
|
@@ -46,6 +46,10 @@ declare module 'react-table' {
|
|
|
46
46
|
};
|
|
47
47
|
isTableResizing?: boolean;
|
|
48
48
|
columnReorderStartIndex: number;
|
|
49
|
+
sticky: {
|
|
50
|
+
isScrolledToRight?: boolean;
|
|
51
|
+
isScrolledToLeft?: boolean;
|
|
52
|
+
};
|
|
49
53
|
}
|
|
50
54
|
interface ColumnInterface<D extends object = {}> extends UseSortByColumnOptions<D>, UseFiltersColumnOptions<D>, UseResizeColumnsColumnOptions<D> {
|
|
51
55
|
/**
|
|
@@ -91,12 +95,17 @@ declare module 'react-table' {
|
|
|
91
95
|
* @default false
|
|
92
96
|
*/
|
|
93
97
|
disableToggleVisibility?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Side on which column should be sticked to.
|
|
100
|
+
*/
|
|
101
|
+
sticky?: 'left' | 'right';
|
|
94
102
|
}
|
|
95
103
|
interface ColumnInstance<D extends object = {}> extends UseFiltersColumnProps<D>, UseGroupByColumnProps<D>, UseResizeColumnsColumnProps<D>, UseSortByColumnProps<D> {
|
|
96
104
|
originalWidth: number;
|
|
97
105
|
resizeWidth?: number;
|
|
98
106
|
isResizerVisible?: boolean;
|
|
99
107
|
getDragAndDropProps: () => TableKeyedProps;
|
|
108
|
+
originalSticky?: 'left' | 'right' | 'none';
|
|
100
109
|
}
|
|
101
110
|
interface Cell<D extends object = {}> extends UseGroupByCellProps<D>, UseRowStateCellProps<D> {
|
|
102
111
|
}
|
|
@@ -35,9 +35,10 @@ export declare type ComboBoxProps<T> = {
|
|
|
35
35
|
dropdownMenuProps?: PopoverProps;
|
|
36
36
|
/**
|
|
37
37
|
* Message shown when no options are available.
|
|
38
|
+
* If `JSX.Element` is provided, it will be rendered as is and won't be wrapped with `MenuExtraContent`.
|
|
38
39
|
* @default 'No options found'
|
|
39
40
|
*/
|
|
40
|
-
emptyStateMessage?:
|
|
41
|
+
emptyStateMessage?: React.ReactNode;
|
|
41
42
|
/**
|
|
42
43
|
* A custom item renderer can be specified to control the rendering.
|
|
43
44
|
*
|
|
@@ -58,6 +59,14 @@ export declare type ComboBoxProps<T> = {
|
|
|
58
59
|
* @beta
|
|
59
60
|
*/
|
|
60
61
|
enableVirtualization?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Callback fired when dropdown menu is opened.
|
|
64
|
+
*/
|
|
65
|
+
onShow?: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* Callback fired when dropdown menu is closed.
|
|
68
|
+
*/
|
|
69
|
+
onHide?: () => void;
|
|
61
70
|
} & Pick<InputContainerProps, 'status'> & Omit<CommonProps, 'title'>;
|
|
62
71
|
/**
|
|
63
72
|
* ComboBox component that allows typing a value to filter the options in dropdown list.
|
|
@@ -56,8 +56,8 @@ var getOptionId = function (option, idPrefix) {
|
|
|
56
56
|
* />
|
|
57
57
|
*/
|
|
58
58
|
export var ComboBox = function (props) {
|
|
59
|
-
var _a;
|
|
60
|
-
var options = props.options, valueProp = props.value, onChange = props.onChange, filterFunction = props.filterFunction, inputProps = props.inputProps, dropdownMenuProps = props.dropdownMenuProps,
|
|
59
|
+
var _a, _b;
|
|
60
|
+
var options = props.options, valueProp = props.value, onChange = props.onChange, filterFunction = props.filterFunction, inputProps = props.inputProps, dropdownMenuProps = props.dropdownMenuProps, _c = props.emptyStateMessage, emptyStateMessage = _c === void 0 ? 'No options found' : _c, itemRenderer = props.itemRenderer, _d = props.enableVirtualization, enableVirtualization = _d === void 0 ? false : _d, onShow = props.onShow, onHide = props.onHide, rest = __rest(props, ["options", "value", "onChange", "filterFunction", "inputProps", "dropdownMenuProps", "emptyStateMessage", "itemRenderer", "enableVirtualization", "onShow", "onHide"]);
|
|
61
61
|
// Generate a stateful random id if not specified
|
|
62
62
|
var id = React.useState(function () {
|
|
63
63
|
var _a, _b;
|
|
@@ -68,6 +68,7 @@ export var ComboBox = function (props) {
|
|
|
68
68
|
var inputRef = React.useRef(null);
|
|
69
69
|
var menuRef = React.useRef(null);
|
|
70
70
|
var toggleButtonRef = React.useRef(null);
|
|
71
|
+
var mounted = React.useRef(false);
|
|
71
72
|
// Latest value of the onChange prop
|
|
72
73
|
var onChangeProp = React.useRef(onChange);
|
|
73
74
|
React.useEffect(function () {
|
|
@@ -89,12 +90,14 @@ export var ComboBox = function (props) {
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
// Reducer where all the component-wide state is stored
|
|
92
|
-
var
|
|
93
|
+
var _e = React.useReducer(comboBoxReducer, {
|
|
93
94
|
isOpen: false,
|
|
94
|
-
selectedIndex:
|
|
95
|
+
selectedIndex: valueProp
|
|
96
|
+
? options.findIndex(function (option) { return option.value === valueProp; })
|
|
97
|
+
: -1,
|
|
95
98
|
focusedIndex: -1,
|
|
96
|
-
}),
|
|
97
|
-
React.
|
|
99
|
+
}), _f = _e[0], isOpen = _f.isOpen, selectedIndex = _f.selectedIndex, focusedIndex = _f.focusedIndex, dispatch = _e[1];
|
|
100
|
+
React.useLayoutEffect(function () {
|
|
98
101
|
var _a, _b;
|
|
99
102
|
// When the dropdown opens
|
|
100
103
|
if (isOpen) {
|
|
@@ -113,20 +116,30 @@ export var ComboBox = function (props) {
|
|
|
113
116
|
}
|
|
114
117
|
}, [isOpen, options, selectedIndex]);
|
|
115
118
|
// Set min-width of menu to be same as input
|
|
116
|
-
var
|
|
119
|
+
var _g = React.useState(0), minWidth = _g[0], setMinWidth = _g[1];
|
|
117
120
|
React.useEffect(function () {
|
|
118
121
|
if (inputRef.current) {
|
|
119
122
|
setMinWidth(inputRef.current.offsetWidth);
|
|
120
123
|
}
|
|
121
124
|
}, [isOpen]);
|
|
122
|
-
//
|
|
123
|
-
var
|
|
125
|
+
// Update filtered options to the latest value options according to input value
|
|
126
|
+
var _h = React.useState(options), filteredOptions = _h[0], setFilteredOptions = _h[1];
|
|
124
127
|
React.useEffect(function () {
|
|
125
|
-
|
|
128
|
+
var _a;
|
|
129
|
+
if (inputValue) {
|
|
130
|
+
setFilteredOptions((_a = filterFunction === null || filterFunction === void 0 ? void 0 : filterFunction(options, inputValue)) !== null && _a !== void 0 ? _a : options.filter(function (option) {
|
|
131
|
+
return option.label.toLowerCase().includes(inputValue.toLowerCase());
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
setFilteredOptions(options);
|
|
136
|
+
}
|
|
126
137
|
dispatch(['focus']);
|
|
138
|
+
// Only need to call on options update
|
|
139
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
127
140
|
}, [options]);
|
|
128
141
|
// Filter options based on input value
|
|
129
|
-
var
|
|
142
|
+
var _j = React.useState((_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''), inputValue = _j[0], setInputValue = _j[1];
|
|
130
143
|
var handleOnInput = React.useCallback(function (event) {
|
|
131
144
|
var _a, _b;
|
|
132
145
|
var value = event.currentTarget.value;
|
|
@@ -150,14 +163,14 @@ export var ComboBox = function (props) {
|
|
|
150
163
|
// Call user-defined onChange when the value actually changes
|
|
151
164
|
React.useEffect(function () {
|
|
152
165
|
var _a, _b;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
(_b = onChangeProp.current) === null || _b === void 0 ? void 0 : _b.call(onChangeProp, value);
|
|
166
|
+
// Prevent user-defined onChange to be called on mount
|
|
167
|
+
if (!mounted.current) {
|
|
168
|
+
mounted.current = true;
|
|
169
|
+
return;
|
|
159
170
|
}
|
|
160
|
-
|
|
171
|
+
var value = (_a = options[selectedIndex]) === null || _a === void 0 ? void 0 : _a.value;
|
|
172
|
+
(_b = onChangeProp.current) === null || _b === void 0 ? void 0 : _b.call(onChangeProp, value);
|
|
173
|
+
}, [options, selectedIndex]);
|
|
161
174
|
var getMenuItem = React.useCallback(function (option, filteredIndex) {
|
|
162
175
|
var optionId = getOptionId(option, id);
|
|
163
176
|
var __originalIndex = optionsExtraInfoRef.current[optionId].__originalIndex;
|
|
@@ -173,6 +186,7 @@ export var ComboBox = function (props) {
|
|
|
173
186
|
onClick: function (e) {
|
|
174
187
|
var _a, _b;
|
|
175
188
|
dispatch(['select', __originalIndex]);
|
|
189
|
+
dispatch(['close']);
|
|
176
190
|
(_b = (_a = customItem.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
177
191
|
},
|
|
178
192
|
// ComboBox.MenuItem handles scrollIntoView, data-iui-index and iui-focused through context
|
|
@@ -187,8 +201,13 @@ export var ComboBox = function (props) {
|
|
|
187
201
|
el === null || el === void 0 ? void 0 : el.scrollIntoView({ block: 'nearest' });
|
|
188
202
|
}
|
|
189
203
|
}),
|
|
190
|
-
})) : (React.createElement(ComboBoxMenuItem, __assign({ key: optionId, id: optionId }, option, { isSelected: selectedIndex === __originalIndex, onClick: function () {
|
|
204
|
+
})) : (React.createElement(ComboBoxMenuItem, __assign({ key: optionId, id: optionId }, option, { isSelected: selectedIndex === __originalIndex, onClick: function () {
|
|
205
|
+
dispatch(['select', __originalIndex]);
|
|
206
|
+
dispatch(['close']);
|
|
207
|
+
}, index: __originalIndex, "data-iui-filtered-index": filteredIndex }), option.label));
|
|
191
208
|
}, [enableVirtualization, focusedIndex, id, itemRenderer, selectedIndex]);
|
|
209
|
+
var emptyContent = React.useMemo(function () { return (React.createElement(React.Fragment, null, React.isValidElement(emptyStateMessage) ? (emptyStateMessage) : (React.createElement(MenuExtraContent, null,
|
|
210
|
+
React.createElement(Text, { isMuted: true }, emptyStateMessage))))); }, [emptyStateMessage]);
|
|
192
211
|
return (React.createElement(ComboBoxRefsContext.Provider, { value: { inputRef: inputRef, menuRef: menuRef, toggleButtonRef: toggleButtonRef, optionsExtraInfoRef: optionsExtraInfoRef } },
|
|
193
212
|
React.createElement(ComboBoxActionContext.Provider, { value: dispatch },
|
|
194
213
|
React.createElement(ComboBoxStateContext.Provider, { value: {
|
|
@@ -203,8 +222,9 @@ export var ComboBox = function (props) {
|
|
|
203
222
|
React.createElement(ComboBoxInputContainer, __assign({ disabled: inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled }, rest),
|
|
204
223
|
React.createElement(ComboBoxInput, __assign({ value: inputValue }, inputProps, { onChange: handleOnInput })),
|
|
205
224
|
React.createElement(ComboBoxEndIcon, { disabled: inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled, isOpen: isOpen })),
|
|
206
|
-
React.createElement(ComboBoxDropdown, __assign({}, dropdownMenuProps),
|
|
207
|
-
React.createElement(ComboBoxMenu, null, filteredOptions.length > 0 && !enableVirtualization
|
|
208
|
-
|
|
225
|
+
React.createElement(ComboBoxDropdown, __assign({}, dropdownMenuProps, { onShow: onShow, onHide: onHide }),
|
|
226
|
+
React.createElement(ComboBoxMenu, null, filteredOptions.length > 0 && !enableVirtualization
|
|
227
|
+
? filteredOptions.map(getMenuItem)
|
|
228
|
+
: emptyContent))))));
|
|
209
229
|
};
|
|
210
230
|
export default ComboBox;
|