@itwin/itwinui-react 2.12.14 → 2.12.16
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/Table/actionHandlers/selectHandler.d.ts +5 -5
- package/cjs/core/Table/actionHandlers/selectHandler.js +8 -5
- package/cjs/core/ThemeProvider/ThemeProvider.js +7 -3
- package/cjs/core/utils/hooks/useId.js +1 -1
- package/esm/core/Table/actionHandlers/selectHandler.d.ts +5 -5
- package/esm/core/Table/actionHandlers/selectHandler.js +8 -5
- package/esm/core/ThemeProvider/ThemeProvider.js +7 -3
- 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.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fa3a1c35: Made Table's Ctrl+Shift click implementation more consistent with Windows Explorer's implementation.
|
|
8
|
+
- fa3a1c35: Fixed occasional mismatch between the Table's visually selected rows and Table state's selected rows
|
|
9
|
+
- 9f7f66a0: Memoized `useId` fallback for react 17, to prevent unnecessary rerenders.
|
|
10
|
+
|
|
11
|
+
## 2.12.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- df057f24: Fixed `ThemeProvider` to correctly inherit `highContrast` option when using `theme="inherit"`.
|
|
16
|
+
|
|
3
17
|
## 2.12.14
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -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]);
|
|
@@ -62,15 +62,19 @@ const useStyles_js_1 = require("../utils/hooks/useStyles.js");
|
|
|
62
62
|
* </ThemeProvider>
|
|
63
63
|
*/
|
|
64
64
|
exports.ThemeProvider = React.forwardRef((props, ref) => {
|
|
65
|
-
var _a, _b;
|
|
66
|
-
const { theme: themeProp, children, themeOptions, includeCss = { withLayer: true }, ...rest } = props;
|
|
65
|
+
var _a, _b, _c, _d;
|
|
66
|
+
const { theme: themeProp, children, themeOptions = {}, includeCss = { withLayer: true }, ...rest } = props;
|
|
67
67
|
const rootRef = React.useRef(null);
|
|
68
68
|
const mergedRefs = (0, index_js_1.useMergedRefs)(rootRef, ref);
|
|
69
69
|
const hasChildren = React.Children.count(children) > 0;
|
|
70
70
|
const parentContext = React.useContext(exports.ThemeContext);
|
|
71
71
|
const theme = themeProp === 'inherit' ? (_a = parentContext === null || parentContext === void 0 ? void 0 : parentContext.theme) !== null && _a !== void 0 ? _a : 'light' : themeProp;
|
|
72
|
+
// default inherit highContrast option from parent if also inheriting base theme
|
|
73
|
+
(_b = themeOptions.highContrast) !== null && _b !== void 0 ? _b : (themeOptions.highContrast = themeProp === 'inherit'
|
|
74
|
+
? (_c = parentContext === null || parentContext === void 0 ? void 0 : parentContext.themeOptions) === null || _c === void 0 ? void 0 : _c.highContrast
|
|
75
|
+
: undefined);
|
|
72
76
|
const newStylesLoaded = React.useRef(false);
|
|
73
|
-
const stylesLoaded = (
|
|
77
|
+
const stylesLoaded = (_d = parentContext === null || parentContext === void 0 ? void 0 : parentContext.stylesLoaded) !== null && _d !== void 0 ? _d : newStylesLoaded;
|
|
74
78
|
const contextValue = React.useMemo(() => ({
|
|
75
79
|
theme,
|
|
76
80
|
themeOptions,
|
|
@@ -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), []));
|
|
@@ -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]);
|
|
@@ -33,15 +33,19 @@ import { useStyles } from '../utils/hooks/useStyles.js';
|
|
|
33
33
|
* </ThemeProvider>
|
|
34
34
|
*/
|
|
35
35
|
export const ThemeProvider = React.forwardRef((props, ref) => {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
const { theme: themeProp, children, themeOptions, includeCss = { withLayer: true }, ...rest } = props;
|
|
36
|
+
var _a, _b, _c, _d;
|
|
37
|
+
const { theme: themeProp, children, themeOptions = {}, includeCss = { withLayer: true }, ...rest } = props;
|
|
38
38
|
const rootRef = React.useRef(null);
|
|
39
39
|
const mergedRefs = useMergedRefs(rootRef, ref);
|
|
40
40
|
const hasChildren = React.Children.count(children) > 0;
|
|
41
41
|
const parentContext = React.useContext(ThemeContext);
|
|
42
42
|
const theme = themeProp === 'inherit' ? (_a = parentContext === null || parentContext === void 0 ? void 0 : parentContext.theme) !== null && _a !== void 0 ? _a : 'light' : themeProp;
|
|
43
|
+
// default inherit highContrast option from parent if also inheriting base theme
|
|
44
|
+
(_b = themeOptions.highContrast) !== null && _b !== void 0 ? _b : (themeOptions.highContrast = themeProp === 'inherit'
|
|
45
|
+
? (_c = parentContext === null || parentContext === void 0 ? void 0 : parentContext.themeOptions) === null || _c === void 0 ? void 0 : _c.highContrast
|
|
46
|
+
: undefined);
|
|
43
47
|
const newStylesLoaded = React.useRef(false);
|
|
44
|
-
const stylesLoaded = (
|
|
48
|
+
const stylesLoaded = (_d = parentContext === null || parentContext === void 0 ? void 0 : parentContext.stylesLoaded) !== null && _d !== void 0 ? _d : newStylesLoaded;
|
|
45
49
|
const contextValue = React.useMemo(() => ({
|
|
46
50
|
theme,
|
|
47
51
|
themeOptions,
|
|
@@ -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), []));
|