@itwin/itwinui-react 1.39.0 → 1.40.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 +12 -0
- package/cjs/core/ComboBox/ComboBox.d.ts +10 -1
- package/cjs/core/ComboBox/ComboBox.js +31 -14
- package/cjs/core/ComboBox/ComboBoxInput.js +1 -0
- package/cjs/core/ComboBox/helpers.js +1 -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/Table/Table.js +39 -6
- package/cjs/core/Table/TableCell.js +10 -3
- package/cjs/core/Table/TableRowMemoized.js +5 -1
- package/cjs/core/Table/actionHandlers/resizeHandler.d.ts +8 -0
- package/cjs/core/Table/actionHandlers/selectHandler.d.ts +4 -0
- 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/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 +31 -14
- package/esm/core/ComboBox/ComboBoxInput.js +1 -0
- package/esm/core/ComboBox/helpers.js +1 -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/Table/Table.js +41 -8
- package/esm/core/Table/TableCell.js +11 -4
- package/esm/core/Table/TableRowMemoized.js +5 -1
- package/esm/core/Table/actionHandlers/resizeHandler.d.ts +8 -0
- package/esm/core/Table/actionHandlers/selectHandler.d.ts +4 -0
- 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/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 +2 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
/*---------------------------------------------------------------------------------------------
|
|
22
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
23
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
24
|
+
*--------------------------------------------------------------------------------------------*/
|
|
25
|
+
import { actions, } from 'react-table';
|
|
26
|
+
actions.setScrolledLeft = 'setScrolledLeft';
|
|
27
|
+
actions.setScrolledRight = 'setScrolledRight';
|
|
28
|
+
export var useStickyColumns = function (hooks) {
|
|
29
|
+
hooks.stateReducers.push(reducer);
|
|
30
|
+
hooks.useInstance.push(useInstance);
|
|
31
|
+
};
|
|
32
|
+
var reducer = function (newState, action) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
if (action.type === actions.init) {
|
|
35
|
+
return __assign(__assign({}, newState), { sticky: {} });
|
|
36
|
+
}
|
|
37
|
+
if (action.type === actions.setScrolledLeft &&
|
|
38
|
+
((_a = newState.sticky) === null || _a === void 0 ? void 0 : _a.isScrolledToLeft) !== action.value // Prevents unnecessary re-render
|
|
39
|
+
) {
|
|
40
|
+
return __assign(__assign({}, newState), { sticky: __assign(__assign({}, newState.sticky), { isScrolledToLeft: action.value }) });
|
|
41
|
+
}
|
|
42
|
+
if (action.type === actions.setScrolledRight &&
|
|
43
|
+
((_b = newState.sticky) === null || _b === void 0 ? void 0 : _b.isScrolledToRight) !== action.value // Prevents unnecessary re-render
|
|
44
|
+
) {
|
|
45
|
+
return __assign(__assign({}, newState), { sticky: __assign(__assign({}, newState.sticky), { isScrolledToRight: action.value }) });
|
|
46
|
+
}
|
|
47
|
+
return newState;
|
|
48
|
+
};
|
|
49
|
+
var useInstance = function (instance) {
|
|
50
|
+
var flatHeaders = instance.flatHeaders;
|
|
51
|
+
// Edge case. Saving original sticky state in case sticky columns are reordered.
|
|
52
|
+
flatHeaders.forEach(function (header) {
|
|
53
|
+
var _a;
|
|
54
|
+
if (!header.originalSticky) {
|
|
55
|
+
header.originalSticky = (_a = header.sticky) !== null && _a !== void 0 ? _a : 'none';
|
|
56
|
+
}
|
|
57
|
+
header.sticky =
|
|
58
|
+
header.originalSticky === 'none' ? undefined : header.originalSticky;
|
|
59
|
+
});
|
|
60
|
+
// If there is a column that is sticked to the left, make every column prior to that sticky too.
|
|
61
|
+
var hasLeftStickyColumn = false;
|
|
62
|
+
__spreadArray([], flatHeaders, true).reverse().forEach(function (header) {
|
|
63
|
+
if (header.sticky === 'left') {
|
|
64
|
+
hasLeftStickyColumn = true;
|
|
65
|
+
}
|
|
66
|
+
if (hasLeftStickyColumn) {
|
|
67
|
+
header.sticky = 'left';
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
// If there is a column that is sticked to the right, make every column after to that sticky too.
|
|
71
|
+
var hasRightStickyColumn = false;
|
|
72
|
+
flatHeaders.forEach(function (header) {
|
|
73
|
+
if (header.sticky === 'right') {
|
|
74
|
+
hasRightStickyColumn = true;
|
|
75
|
+
}
|
|
76
|
+
if (hasRightStickyColumn) {
|
|
77
|
+
header.sticky = 'right';
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
@@ -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/esm/core/Table/utils.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
1
10
|
export var getCellStyle = function (column, isTableResizing) {
|
|
2
11
|
var style = {};
|
|
3
12
|
style.flex = "1 1 145px";
|
|
@@ -20,3 +29,28 @@ export var getCellStyle = function (column, isTableResizing) {
|
|
|
20
29
|
}
|
|
21
30
|
return style;
|
|
22
31
|
};
|
|
32
|
+
export var getStickyStyle = function (column, columnList) {
|
|
33
|
+
if (!column.sticky) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
var left = 0;
|
|
37
|
+
for (var _i = 0, columnList_1 = columnList; _i < columnList_1.length; _i++) {
|
|
38
|
+
var col = columnList_1[_i];
|
|
39
|
+
if (col.id === column.id) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
left += Number(col.width || col.resizeWidth || 0);
|
|
43
|
+
}
|
|
44
|
+
var right = 0;
|
|
45
|
+
for (var _a = 0, _b = __spreadArray([], columnList, true).reverse(); _a < _b.length; _a++) {
|
|
46
|
+
var col = _b[_a];
|
|
47
|
+
if (col.id === column.id) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
right += Number(col.width || col.resizeWidth || 0);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
'--iui-table-sticky-left': column.sticky === 'left' ? "".concat(left, "px") : undefined,
|
|
54
|
+
'--iui-table-sticky-right': column.sticky === 'right' ? "".concat(right, "px") : undefined,
|
|
55
|
+
};
|
|
56
|
+
};
|
package/esm/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/esm/core/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export { LabeledInput } from './LabeledInput';
|
|
|
27
27
|
export { InputGroup } from './InputGroup';
|
|
28
28
|
export { LabeledSelect } from './LabeledSelect';
|
|
29
29
|
export { LabeledTextarea } from './LabeledTextarea';
|
|
30
|
-
export { Menu, MenuItem, MenuDivider, MenuExtraContent } from './Menu';
|
|
30
|
+
export { Menu, MenuItem, MenuDivider, MenuExtraContent, MenuItemSkeleton, } from './Menu';
|
|
31
31
|
export { Modal, ModalButtonBar, ModalContent } from './Modal';
|
|
32
32
|
export { ProgressLinear, ProgressRadial } from './ProgressIndicators';
|
|
33
33
|
export { Radio } from './Radio';
|
|
@@ -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,38 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
import { useTheme } from '../hooks';
|
|
30
|
+
/**
|
|
31
|
+
* Hides content visually but is still accessible to screen readers.
|
|
32
|
+
*/
|
|
33
|
+
export var VisuallyHidden = React.forwardRef(function (props, ref) {
|
|
34
|
+
var className = props.className, rest = __rest(props, ["className"]);
|
|
35
|
+
useTheme();
|
|
36
|
+
return (React.createElement("div", __assign({ className: cx('iui-visually-hidden', className), ref: ref }, rest)));
|
|
37
|
+
});
|
|
38
|
+
export default 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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.0",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dev": "yarn build:watch"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@itwin/itwinui-css": "^0.59.
|
|
46
|
+
"@itwin/itwinui-css": "^0.59.2",
|
|
47
47
|
"@itwin/itwinui-icons-react": "^1.10.1",
|
|
48
48
|
"@itwin/itwinui-illustrations-react": "^1.3.1",
|
|
49
49
|
"@tippyjs/react": "^4.2.5",
|