@itwin/itwinui-react 2.12.15 → 2.12.17
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 +14 -0
- package/cjs/core/Menu/MenuItem.js +9 -7
- package/cjs/core/Table/actionHandlers/selectHandler.d.ts +5 -5
- package/cjs/core/Table/actionHandlers/selectHandler.js +8 -5
- package/cjs/core/utils/hooks/useId.js +1 -1
- package/esm/core/Menu/MenuItem.js +9 -7
- package/esm/core/Table/actionHandlers/selectHandler.d.ts +5 -5
- package/esm/core/Table/actionHandlers/selectHandler.js +8 -5
- package/esm/core/utils/hooks/useId.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.12.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1698](https://github.com/iTwin/iTwinUI/pull/1698): Fixed an issue where submenu items were not appearing because of overflow on parent menu.
|
|
8
|
+
|
|
9
|
+
## 2.12.16
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fa3a1c35: Made Table's Ctrl+Shift click implementation more consistent with Windows Explorer's implementation.
|
|
14
|
+
- fa3a1c35: Fixed occasional mismatch between the Table's visually selected rows and Table state's selected rows
|
|
15
|
+
- 9f7f66a0: Memoized `useId` fallback for react 17, to prevent unnecessary rerenders.
|
|
16
|
+
|
|
3
17
|
## 2.12.15
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -67,13 +67,11 @@ exports.MenuItem = React.forwardRef((props, ref) => {
|
|
|
67
67
|
if (subMenuItems.length > 0) {
|
|
68
68
|
setIsSubmenuVisible(true);
|
|
69
69
|
event.preventDefault();
|
|
70
|
-
event.stopPropagation();
|
|
71
70
|
}
|
|
72
71
|
break;
|
|
73
72
|
}
|
|
74
73
|
case 'ArrowLeft': {
|
|
75
74
|
(_a = parentMenuItemRef === null || parentMenuItemRef === void 0 ? void 0 : parentMenuItemRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
76
|
-
event.stopPropagation();
|
|
77
75
|
event.preventDefault();
|
|
78
76
|
break;
|
|
79
77
|
}
|
|
@@ -105,12 +103,16 @@ exports.MenuItem = React.forwardRef((props, ref) => {
|
|
|
105
103
|
className: (0, classnames_1.default)(badge.props.className, 'iui-icon'),
|
|
106
104
|
})));
|
|
107
105
|
return subMenuItems.length === 0 ? (listItem) : (React.createElement(MenuItemContext.Provider, { value: { ref: menuItemRef } },
|
|
108
|
-
React.createElement(index_js_1.Popover, { placement: 'right-start', visible: isSubmenuVisible, appendTo:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
React.createElement(index_js_1.Popover, { placement: 'right-start', visible: isSubmenuVisible, appendTo: (item) => {
|
|
107
|
+
var _a;
|
|
108
|
+
// we want the div wrapping the parent menu because the menu has overflow,
|
|
109
|
+
// which can cause the submenu to be cut off
|
|
110
|
+
return (_a = item.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
111
|
+
}, delay: 100, content: React.createElement("div", { onMouseLeave: () => setIsSubmenuVisible(false), onKeyDown: (e) => {
|
|
112
|
+
if (!e.altKey && e.key === 'ArrowLeft') {
|
|
113
113
|
setIsSubmenuVisible(false);
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
}
|
|
114
116
|
} },
|
|
115
117
|
React.createElement(Menu_js_1.Menu, { ref: subMenuRef, className: 'iui-scroll' }, subMenuItems)) }, listItem)));
|
|
116
118
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionType, TableInstance, TableState } from 'react-table';
|
|
1
|
+
import type { ActionType, TableInstance, TableState, IdType } from 'react-table';
|
|
2
2
|
/**
|
|
3
3
|
* Handles selection when toggling a row (Ctrl click or checkbox click)
|
|
4
4
|
*/
|
|
@@ -9,7 +9,7 @@ export declare const onToggleHandler: <T extends Record<string, unknown>>(newSta
|
|
|
9
9
|
export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(state: TableState<T>, action: ActionType, instance?: TableInstance<T> | undefined, onSelect?: ((selectedData: T[] | undefined, tableState?: TableState<T> | undefined) => void) | undefined, isRowDisabled?: ((rowData: T) => boolean) | undefined) => {
|
|
10
10
|
lastSelectedRowId: any;
|
|
11
11
|
selectedRowIds: Record<string, boolean>;
|
|
12
|
-
hiddenColumns?:
|
|
12
|
+
hiddenColumns?: IdType<T>[] | undefined;
|
|
13
13
|
columnResizing: {
|
|
14
14
|
startX?: number | undefined;
|
|
15
15
|
columnWidth?: number | undefined;
|
|
@@ -25,11 +25,11 @@ export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(
|
|
|
25
25
|
isScrolledToRight?: boolean | undefined;
|
|
26
26
|
isScrolledToLeft?: boolean | undefined;
|
|
27
27
|
};
|
|
28
|
-
columnOrder:
|
|
29
|
-
expanded: Record<
|
|
28
|
+
columnOrder: IdType<T>[];
|
|
29
|
+
expanded: Record<IdType<T>, boolean>;
|
|
30
30
|
filters: import("react-table").Filters<T>;
|
|
31
31
|
globalFilter: any;
|
|
32
|
-
groupBy:
|
|
32
|
+
groupBy: IdType<T>[];
|
|
33
33
|
pageSize: number;
|
|
34
34
|
pageIndex: number;
|
|
35
35
|
rowState: Record<string, {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.onShiftSelectHandler = exports.onSingleSelectHandler = exports.onToggleHandler = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Handles subrow selection and validation.
|
|
6
|
+
* - Calls onSelect() with selected data
|
|
6
7
|
* - Subrow selection: Selecting a row and calling this method automatically selects all the subrows that can be selected
|
|
7
8
|
* - Validation: Ensures that any disabled/unselectable row/subrow is not selected
|
|
8
9
|
*/
|
|
@@ -83,19 +84,21 @@ const onShiftSelectHandler = (state, action, instance, onSelect, isRowDisabled)
|
|
|
83
84
|
startIndex = endIndex;
|
|
84
85
|
endIndex = temp;
|
|
85
86
|
}
|
|
87
|
+
const isLastSelectedRowIdSelected = state.lastSelectedRowId == null || // When no row is selected before shift click, start selecting from first row to clicked row
|
|
88
|
+
!!state.selectedRowIds[state.lastSelectedRowId];
|
|
86
89
|
// If ctrl + shift click, do not lose previous selection
|
|
87
90
|
// If shift click, start new selection
|
|
88
91
|
const selectedRowIds = !!action.ctrlPressed
|
|
89
|
-
? state.selectedRowIds
|
|
92
|
+
? { ...state.selectedRowIds }
|
|
90
93
|
: {};
|
|
91
|
-
// 1.
|
|
94
|
+
// 1. All rows between start and end are assigned the state of the last selected row
|
|
92
95
|
instance.flatRows
|
|
93
96
|
.slice(startIndex, endIndex + 1)
|
|
94
|
-
.forEach((r) => (selectedRowIds[r.id] =
|
|
95
|
-
// 2.
|
|
97
|
+
.forEach((r) => (selectedRowIds[r.id] = isLastSelectedRowIdSelected));
|
|
98
|
+
// 2. All children of the last row (endIndex) also are assigned the state of the last selected row
|
|
96
99
|
// Since lastRow's children come after endIndex + 1 (not selected in step 1)
|
|
97
100
|
const handleRow = (row) => {
|
|
98
|
-
selectedRowIds[row.id] =
|
|
101
|
+
selectedRowIds[row.id] = isLastSelectedRowIdSelected;
|
|
99
102
|
row.subRows.forEach((r) => handleRow(r));
|
|
100
103
|
};
|
|
101
104
|
handleRow(instance.flatRows[endIndex]);
|
|
@@ -43,4 +43,4 @@ exports.useId = useId;
|
|
|
43
43
|
// This is needed to avoid bundlers trying to import non-existing export.
|
|
44
44
|
// Read more: https://github.com/webpack/webpack/issues/14814
|
|
45
45
|
const _React = React;
|
|
46
|
-
const useUniqueValue = (_a = _React.useId) !== null && _a !== void 0 ? _a : (() => (0, numbers_js_1.getRandomValue)(10));
|
|
46
|
+
const useUniqueValue = (_a = _React.useId) !== null && _a !== void 0 ? _a : (() => React.useMemo(() => (0, numbers_js_1.getRandomValue)(10), []));
|
|
@@ -38,13 +38,11 @@ export const MenuItem = React.forwardRef((props, ref) => {
|
|
|
38
38
|
if (subMenuItems.length > 0) {
|
|
39
39
|
setIsSubmenuVisible(true);
|
|
40
40
|
event.preventDefault();
|
|
41
|
-
event.stopPropagation();
|
|
42
41
|
}
|
|
43
42
|
break;
|
|
44
43
|
}
|
|
45
44
|
case 'ArrowLeft': {
|
|
46
45
|
(_a = parentMenuItemRef === null || parentMenuItemRef === void 0 ? void 0 : parentMenuItemRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
47
|
-
event.stopPropagation();
|
|
48
46
|
event.preventDefault();
|
|
49
47
|
break;
|
|
50
48
|
}
|
|
@@ -76,12 +74,16 @@ export const MenuItem = React.forwardRef((props, ref) => {
|
|
|
76
74
|
className: cx(badge.props.className, 'iui-icon'),
|
|
77
75
|
})));
|
|
78
76
|
return subMenuItems.length === 0 ? (listItem) : (React.createElement(MenuItemContext.Provider, { value: { ref: menuItemRef } },
|
|
79
|
-
React.createElement(Popover, { placement: 'right-start', visible: isSubmenuVisible, appendTo:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
React.createElement(Popover, { placement: 'right-start', visible: isSubmenuVisible, appendTo: (item) => {
|
|
78
|
+
var _a;
|
|
79
|
+
// we want the div wrapping the parent menu because the menu has overflow,
|
|
80
|
+
// which can cause the submenu to be cut off
|
|
81
|
+
return (_a = item.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
82
|
+
}, delay: 100, content: React.createElement("div", { onMouseLeave: () => setIsSubmenuVisible(false), onKeyDown: (e) => {
|
|
83
|
+
if (!e.altKey && e.key === 'ArrowLeft') {
|
|
84
84
|
setIsSubmenuVisible(false);
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
}
|
|
85
87
|
} },
|
|
86
88
|
React.createElement(Menu, { ref: subMenuRef, className: 'iui-scroll' }, subMenuItems)) }, listItem)));
|
|
87
89
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionType, TableInstance, TableState } from 'react-table';
|
|
1
|
+
import type { ActionType, TableInstance, TableState, IdType } from 'react-table';
|
|
2
2
|
/**
|
|
3
3
|
* Handles selection when toggling a row (Ctrl click or checkbox click)
|
|
4
4
|
*/
|
|
@@ -9,7 +9,7 @@ export declare const onToggleHandler: <T extends Record<string, unknown>>(newSta
|
|
|
9
9
|
export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(state: TableState<T>, action: ActionType, instance?: TableInstance<T> | undefined, onSelect?: ((selectedData: T[] | undefined, tableState?: TableState<T> | undefined) => void) | undefined, isRowDisabled?: ((rowData: T) => boolean) | undefined) => {
|
|
10
10
|
lastSelectedRowId: any;
|
|
11
11
|
selectedRowIds: Record<string, boolean>;
|
|
12
|
-
hiddenColumns?:
|
|
12
|
+
hiddenColumns?: IdType<T>[] | undefined;
|
|
13
13
|
columnResizing: {
|
|
14
14
|
startX?: number | undefined;
|
|
15
15
|
columnWidth?: number | undefined;
|
|
@@ -25,11 +25,11 @@ export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(
|
|
|
25
25
|
isScrolledToRight?: boolean | undefined;
|
|
26
26
|
isScrolledToLeft?: boolean | undefined;
|
|
27
27
|
};
|
|
28
|
-
columnOrder:
|
|
29
|
-
expanded: Record<
|
|
28
|
+
columnOrder: IdType<T>[];
|
|
29
|
+
expanded: Record<IdType<T>, boolean>;
|
|
30
30
|
filters: import("react-table").Filters<T>;
|
|
31
31
|
globalFilter: any;
|
|
32
|
-
groupBy:
|
|
32
|
+
groupBy: IdType<T>[];
|
|
33
33
|
pageSize: number;
|
|
34
34
|
pageIndex: number;
|
|
35
35
|
rowState: Record<string, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Handles subrow selection and validation.
|
|
3
|
+
* - Calls onSelect() with selected data
|
|
3
4
|
* - Subrow selection: Selecting a row and calling this method automatically selects all the subrows that can be selected
|
|
4
5
|
* - Validation: Ensures that any disabled/unselectable row/subrow is not selected
|
|
5
6
|
*/
|
|
@@ -78,19 +79,21 @@ export const onShiftSelectHandler = (state, action, instance, onSelect, isRowDis
|
|
|
78
79
|
startIndex = endIndex;
|
|
79
80
|
endIndex = temp;
|
|
80
81
|
}
|
|
82
|
+
const isLastSelectedRowIdSelected = state.lastSelectedRowId == null || // When no row is selected before shift click, start selecting from first row to clicked row
|
|
83
|
+
!!state.selectedRowIds[state.lastSelectedRowId];
|
|
81
84
|
// If ctrl + shift click, do not lose previous selection
|
|
82
85
|
// If shift click, start new selection
|
|
83
86
|
const selectedRowIds = !!action.ctrlPressed
|
|
84
|
-
? state.selectedRowIds
|
|
87
|
+
? { ...state.selectedRowIds }
|
|
85
88
|
: {};
|
|
86
|
-
// 1.
|
|
89
|
+
// 1. All rows between start and end are assigned the state of the last selected row
|
|
87
90
|
instance.flatRows
|
|
88
91
|
.slice(startIndex, endIndex + 1)
|
|
89
|
-
.forEach((r) => (selectedRowIds[r.id] =
|
|
90
|
-
// 2.
|
|
92
|
+
.forEach((r) => (selectedRowIds[r.id] = isLastSelectedRowIdSelected));
|
|
93
|
+
// 2. All children of the last row (endIndex) also are assigned the state of the last selected row
|
|
91
94
|
// Since lastRow's children come after endIndex + 1 (not selected in step 1)
|
|
92
95
|
const handleRow = (row) => {
|
|
93
|
-
selectedRowIds[row.id] =
|
|
96
|
+
selectedRowIds[row.id] = isLastSelectedRowIdSelected;
|
|
94
97
|
row.subRows.forEach((r) => handleRow(r));
|
|
95
98
|
};
|
|
96
99
|
handleRow(instance.flatRows[endIndex]);
|
|
@@ -16,4 +16,4 @@ export const useId = () => {
|
|
|
16
16
|
// This is needed to avoid bundlers trying to import non-existing export.
|
|
17
17
|
// Read more: https://github.com/webpack/webpack/issues/14814
|
|
18
18
|
const _React = React;
|
|
19
|
-
const useUniqueValue = (_a = _React.useId) !== null && _a !== void 0 ? _a : (() => getRandomValue(10));
|
|
19
|
+
const useUniqueValue = (_a = _React.useId) !== null && _a !== void 0 ? _a : (() => React.useMemo(() => getRandomValue(10), []));
|