@itwin/itwinui-react 1.45.0 → 1.47.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 +31 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.d.ts +116 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/cjs/core/ButtonGroup/ButtonGroup.js +1 -1
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/DatePicker/DatePicker.d.ts +24 -4
- package/cjs/core/DatePicker/DatePicker.js +116 -19
- package/cjs/core/Dialog/Dialog.d.ts +5 -5
- package/cjs/core/Dialog/Dialog.js +38 -6
- package/cjs/core/Dialog/DialogBackdrop.d.ts +2 -2
- package/cjs/core/Dialog/DialogBackdrop.js +2 -2
- package/cjs/core/Dialog/DialogContext.d.ts +31 -0
- package/cjs/core/Dialog/DialogDragContext.d.ts +8 -0
- package/cjs/core/Dialog/DialogDragContext.js +28 -0
- package/cjs/core/Dialog/DialogMain.d.ts +2 -2
- package/cjs/core/Dialog/DialogMain.js +46 -6
- package/cjs/core/Dialog/DialogTitleBar.d.ts +2 -2
- package/cjs/core/Dialog/DialogTitleBar.js +12 -2
- package/cjs/core/Modal/Modal.js +1 -1
- package/cjs/core/Table/Table.d.ts +6 -0
- package/cjs/core/Table/Table.js +73 -17
- package/cjs/core/Table/actionHandlers/index.d.ts +1 -1
- package/cjs/core/Table/actionHandlers/index.js +2 -1
- package/cjs/core/Table/actionHandlers/resizeHandler.d.ts +2 -0
- package/cjs/core/Table/actionHandlers/selectHandler.d.ts +5 -0
- package/cjs/core/Table/actionHandlers/selectHandler.js +35 -2
- package/cjs/core/Table/filters/FilterToggle.d.ts +0 -1
- package/cjs/core/Table/filters/FilterToggle.js +3 -3
- package/cjs/core/Table/hooks/useResizeColumns.d.ts +33 -1
- package/cjs/core/Table/hooks/useResizeColumns.js +89 -29
- package/cjs/core/index.d.ts +3 -1
- package/cjs/core/index.js +6 -3
- package/cjs/core/utils/components/Resizer.d.ts +31 -0
- package/cjs/core/utils/components/Resizer.js +206 -0
- package/cjs/core/utils/components/VirtualScroll.js +26 -24
- package/cjs/core/utils/components/index.d.ts +1 -0
- package/cjs/core/utils/components/index.js +1 -0
- package/cjs/core/utils/functions/index.d.ts +1 -0
- package/cjs/core/utils/functions/index.js +1 -0
- package/cjs/core/utils/functions/styles.d.ts +6 -0
- package/cjs/core/utils/functions/styles.js +21 -0
- package/cjs/core/utils/hooks/useContainerWidth.d.ts +1 -1
- package/cjs/core/utils/hooks/useDragAndDrop.d.ts +14 -0
- package/cjs/core/utils/hooks/useDragAndDrop.js +110 -0
- package/cjs/core/utils/hooks/useEventListener.d.ts +1 -1
- package/cjs/core/utils/hooks/useOverflow.d.ts +1 -1
- package/cjs/core/utils/hooks/useResizeObserver.d.ts +1 -1
- package/cjs/types/react-table-config.d.ts +13 -1
- package/esm/core/Breadcrumbs/Breadcrumbs.d.ts +116 -0
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -1
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/DatePicker/DatePicker.d.ts +24 -4
- package/esm/core/DatePicker/DatePicker.js +116 -19
- package/esm/core/Dialog/Dialog.d.ts +5 -5
- package/esm/core/Dialog/Dialog.js +37 -5
- package/esm/core/Dialog/DialogBackdrop.d.ts +2 -2
- package/esm/core/Dialog/DialogBackdrop.js +2 -2
- package/esm/core/Dialog/DialogContext.d.ts +31 -0
- package/esm/core/Dialog/DialogDragContext.d.ts +8 -0
- package/esm/core/Dialog/DialogDragContext.js +21 -0
- package/esm/core/Dialog/DialogMain.d.ts +2 -2
- package/esm/core/Dialog/DialogMain.js +47 -7
- package/esm/core/Dialog/DialogTitleBar.d.ts +2 -2
- package/esm/core/Dialog/DialogTitleBar.js +12 -2
- package/esm/core/Modal/Modal.js +1 -1
- package/esm/core/Table/Table.d.ts +6 -0
- package/esm/core/Table/Table.js +76 -20
- package/esm/core/Table/actionHandlers/index.d.ts +1 -1
- package/esm/core/Table/actionHandlers/index.js +1 -1
- package/esm/core/Table/actionHandlers/resizeHandler.d.ts +2 -0
- package/esm/core/Table/actionHandlers/selectHandler.d.ts +5 -0
- package/esm/core/Table/actionHandlers/selectHandler.js +33 -1
- package/esm/core/Table/filters/FilterToggle.d.ts +0 -1
- package/esm/core/Table/filters/FilterToggle.js +4 -4
- package/esm/core/Table/hooks/useResizeColumns.d.ts +33 -1
- package/esm/core/Table/hooks/useResizeColumns.js +89 -29
- package/esm/core/index.d.ts +3 -1
- package/esm/core/index.js +2 -1
- package/esm/core/utils/components/Resizer.d.ts +31 -0
- package/esm/core/utils/components/Resizer.js +199 -0
- package/esm/core/utils/components/VirtualScroll.js +26 -24
- package/esm/core/utils/components/index.d.ts +1 -0
- package/esm/core/utils/components/index.js +1 -0
- package/esm/core/utils/functions/index.d.ts +1 -0
- package/esm/core/utils/functions/index.js +1 -0
- package/esm/core/utils/functions/styles.d.ts +6 -0
- package/esm/core/utils/functions/styles.js +17 -0
- package/esm/core/utils/hooks/useContainerWidth.d.ts +1 -1
- package/esm/core/utils/hooks/useDragAndDrop.d.ts +14 -0
- package/esm/core/utils/hooks/useDragAndDrop.js +103 -0
- package/esm/core/utils/hooks/useEventListener.d.ts +1 -1
- package/esm/core/utils/hooks/useOverflow.d.ts +1 -1
- package/esm/core/utils/hooks/useResizeObserver.d.ts +1 -1
- package/esm/types/react-table-config.d.ts +13 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
20
20
|
*--------------------------------------------------------------------------------------------*/
|
|
21
21
|
__exportStar(require("./Popover"), exports);
|
|
22
|
+
__exportStar(require("./Resizer"), exports);
|
|
22
23
|
__exportStar(require("./FocusTrap"), exports);
|
|
23
24
|
__exportStar(require("./InputContainer"), exports);
|
|
24
25
|
__exportStar(require("./icons"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns translate values as an array of a given element.
|
|
3
|
+
* @param element HTML element you want to get translate value of
|
|
4
|
+
* @returns Translate values in pixels in a array `[translateX, translateY]`
|
|
5
|
+
*/
|
|
6
|
+
export declare const getTranslateValues: (element: HTMLElement | null | undefined) => number[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getTranslateValues = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Returns translate values as an array of a given element.
|
|
10
|
+
* @param element HTML element you want to get translate value of
|
|
11
|
+
* @returns Translate values in pixels in a array `[translateX, translateY]`
|
|
12
|
+
*/
|
|
13
|
+
var getTranslateValues = function (element) {
|
|
14
|
+
if (!element) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
var transformValue = getComputedStyle(element).getPropertyValue('transform');
|
|
18
|
+
var matrix = new DOMMatrix(transformValue);
|
|
19
|
+
return [matrix.m41, matrix.m42];
|
|
20
|
+
};
|
|
21
|
+
exports.getTranslateValues = getTranslateValues;
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
* ... // do something with width
|
|
14
14
|
* return <div ref={ref}>...</div>;
|
|
15
15
|
*/
|
|
16
|
-
export declare const useContainerWidth: <T extends HTMLElement>(watchResizes?: boolean) => readonly [(instance: HTMLElement | null) => void, number];
|
|
16
|
+
export declare const useContainerWidth: <T extends HTMLElement>(watchResizes?: boolean) => readonly [(instance: HTMLElement | null | undefined) => void, number];
|
|
17
17
|
export default useContainerWidth;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Helper hook that handles elements drag logic.
|
|
4
|
+
* @param elementRef Element ref that is draggable.
|
|
5
|
+
* @param containerRect Bounding rectangle of container element that element can't go outside. If not passed window is used as a container.
|
|
6
|
+
* @returns
|
|
7
|
+
* `onPointerDown` - handler that is called when pointer is down and handles all the dragging logic.
|
|
8
|
+
* `transform` - current transform of the element, it is used to preserve drag position when element visibility is being toggled.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useDragAndDrop: (elementRef: React.RefObject<HTMLElement>, containerRef?: React.RefObject<HTMLElement>, enabled?: boolean) => {
|
|
11
|
+
onPointerDown: (e: React.PointerEvent<HTMLElement>) => void;
|
|
12
|
+
transform: string;
|
|
13
|
+
};
|
|
14
|
+
export default useDragAndDrop;
|
|
@@ -0,0 +1,110 @@
|
|
|
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.useDragAndDrop = 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 functions_1 = require("../functions");
|
|
13
|
+
var useEventListener_1 = require("./useEventListener");
|
|
14
|
+
var useResizeObserver_1 = require("./useResizeObserver");
|
|
15
|
+
var getContainerRect = function (containerRef) {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
17
|
+
var containerRect = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
18
|
+
return {
|
|
19
|
+
top: (_b = containerRect === null || containerRect === void 0 ? void 0 : containerRect.top) !== null && _b !== void 0 ? _b : 0,
|
|
20
|
+
right: (_e = (_c = containerRect === null || containerRect === void 0 ? void 0 : containerRect.right) !== null && _c !== void 0 ? _c : (_d = (0, functions_1.getWindow)()) === null || _d === void 0 ? void 0 : _d.innerWidth) !== null && _e !== void 0 ? _e : 0,
|
|
21
|
+
bottom: (_h = (_f = containerRect === null || containerRect === void 0 ? void 0 : containerRect.bottom) !== null && _f !== void 0 ? _f : (_g = (0, functions_1.getWindow)()) === null || _g === void 0 ? void 0 : _g.innerHeight) !== null && _h !== void 0 ? _h : 0,
|
|
22
|
+
left: (_j = containerRect === null || containerRect === void 0 ? void 0 : containerRect.left) !== null && _j !== void 0 ? _j : 0,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Helper hook that handles elements drag logic.
|
|
27
|
+
* @param elementRef Element ref that is draggable.
|
|
28
|
+
* @param containerRect Bounding rectangle of container element that element can't go outside. If not passed window is used as a container.
|
|
29
|
+
* @returns
|
|
30
|
+
* `onPointerDown` - handler that is called when pointer is down and handles all the dragging logic.
|
|
31
|
+
* `transform` - current transform of the element, it is used to preserve drag position when element visibility is being toggled.
|
|
32
|
+
*/
|
|
33
|
+
var useDragAndDrop = function (elementRef, containerRef, enabled) {
|
|
34
|
+
if (enabled === void 0) { enabled = true; }
|
|
35
|
+
var grabOffsetX = react_1.default.useRef(0);
|
|
36
|
+
var grabOffsetY = react_1.default.useRef(0);
|
|
37
|
+
var translateX = react_1.default.useRef();
|
|
38
|
+
var translateY = react_1.default.useRef();
|
|
39
|
+
var containerRectRef = react_1.default.useRef(getContainerRect(containerRef));
|
|
40
|
+
var adjustTransform = react_1.default.useCallback(function () {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!elementRef.current || !enabled) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var _b = (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(), top = _b.top, right = _b.right, bottom = _b.bottom, left = _b.left;
|
|
46
|
+
var _c = (0, functions_1.getTranslateValues)(elementRef.current), newTranslateX = _c[0], newTranslateY = _c[1];
|
|
47
|
+
containerRectRef.current = getContainerRect(containerRef);
|
|
48
|
+
if (bottom > containerRectRef.current.bottom) {
|
|
49
|
+
newTranslateY -= bottom - containerRectRef.current.bottom;
|
|
50
|
+
}
|
|
51
|
+
if (top < containerRectRef.current.top) {
|
|
52
|
+
newTranslateY += containerRectRef.current.top - top;
|
|
53
|
+
}
|
|
54
|
+
if (right > containerRectRef.current.right) {
|
|
55
|
+
newTranslateX -= right - containerRectRef.current.right;
|
|
56
|
+
}
|
|
57
|
+
if (left < containerRectRef.current.left) {
|
|
58
|
+
newTranslateX += containerRectRef.current.left - left;
|
|
59
|
+
}
|
|
60
|
+
translateX.current = newTranslateX;
|
|
61
|
+
translateY.current = newTranslateY;
|
|
62
|
+
elementRef.current.style.transform = "translate(".concat(newTranslateX, "px, ").concat(newTranslateY, "px)");
|
|
63
|
+
}, [containerRef, elementRef, enabled]);
|
|
64
|
+
var _a = (0, useResizeObserver_1.useResizeObserver)(adjustTransform), resizeRef = _a[0], resizeObserver = _a[1];
|
|
65
|
+
resizeRef(containerRef === null || containerRef === void 0 ? void 0 : containerRef.current);
|
|
66
|
+
react_1.default.useEffect(function () {
|
|
67
|
+
return function () {
|
|
68
|
+
resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
|
|
69
|
+
};
|
|
70
|
+
}, [resizeObserver]);
|
|
71
|
+
(0, useEventListener_1.useEventListener)('resize', function () {
|
|
72
|
+
adjustTransform();
|
|
73
|
+
if (translateX.current != null && translateY.current != null) {
|
|
74
|
+
setTransform("translate(".concat(translateX.current, "px, ").concat(translateY.current, "px)"));
|
|
75
|
+
}
|
|
76
|
+
}, (0, functions_1.getWindow)());
|
|
77
|
+
var _b = react_1.default.useState(''), transform = _b[0], setTransform = _b[1];
|
|
78
|
+
var onPointerMove = react_1.default.useRef(function (event) {
|
|
79
|
+
if (!elementRef.current) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var newTranslateX = event.clientX - grabOffsetX.current;
|
|
83
|
+
var newTranslateY = event.clientY - grabOffsetY.current;
|
|
84
|
+
elementRef.current.style.transform = "translate(".concat(newTranslateX, "px, ").concat(newTranslateY, "px)");
|
|
85
|
+
adjustTransform();
|
|
86
|
+
});
|
|
87
|
+
var originalUserSelect = react_1.default.useRef('');
|
|
88
|
+
var onPointerDown = react_1.default.useCallback(function (e) {
|
|
89
|
+
if (!elementRef.current || e.button !== 0 || !enabled) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
var _a = (0, functions_1.getTranslateValues)(elementRef.current), x = _a[0], y = _a[1];
|
|
93
|
+
grabOffsetX.current = e.clientX - x;
|
|
94
|
+
grabOffsetY.current = e.clientY - y;
|
|
95
|
+
originalUserSelect.current = elementRef.current.style.userSelect;
|
|
96
|
+
// Prevents from selecting inner content when dragging.
|
|
97
|
+
elementRef.current.style.userSelect = 'none';
|
|
98
|
+
elementRef.current.ownerDocument.addEventListener('pointermove', onPointerMove.current);
|
|
99
|
+
elementRef.current.ownerDocument.addEventListener('pointerup', function () {
|
|
100
|
+
setTransform("translate(".concat(translateX.current, "px, ").concat(translateY.current, "px)"));
|
|
101
|
+
document.removeEventListener('pointermove', onPointerMove.current);
|
|
102
|
+
if (elementRef.current) {
|
|
103
|
+
elementRef.current.style.userSelect = originalUserSelect.current;
|
|
104
|
+
}
|
|
105
|
+
}, { once: true });
|
|
106
|
+
}, [elementRef, enabled]);
|
|
107
|
+
return { onPointerDown: onPointerDown, transform: transform };
|
|
108
|
+
};
|
|
109
|
+
exports.useDragAndDrop = useDragAndDrop;
|
|
110
|
+
exports.default = exports.useDragAndDrop;
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* containerRef.current?.ownerDocument,
|
|
8
8
|
* );
|
|
9
9
|
*/
|
|
10
|
-
export declare const useEventListener: (eventName: string, handler: (event: Event) => void, element: HTMLElement | Document | undefined) => void;
|
|
10
|
+
export declare const useEventListener: (eventName: string, handler: (event: Event) => void, element: HTMLElement | Document | Window | undefined) => void;
|
|
@@ -21,4 +21,4 @@ import React from 'react';
|
|
|
21
21
|
* </div>
|
|
22
22
|
* );
|
|
23
23
|
*/
|
|
24
|
-
export declare const useOverflow: <T extends HTMLElement>(items: React.ReactNode[] | string, disabled?: boolean, orientation?: 'horizontal' | 'vertical') => readonly [(instance: T | null) => void, number];
|
|
24
|
+
export declare const useOverflow: <T extends HTMLElement>(items: React.ReactNode[] | string, disabled?: boolean, orientation?: 'horizontal' | 'vertical') => readonly [(instance: T | null | undefined) => void, number];
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
* ...
|
|
11
11
|
* return <div ref={ref}>...</div>;
|
|
12
12
|
*/
|
|
13
|
-
export declare const useResizeObserver: <T extends HTMLElement>(onResize: (size: DOMRectReadOnly) => void) => readonly [(element: T | null) => void, ResizeObserver | undefined];
|
|
13
|
+
export declare const useResizeObserver: <T extends HTMLElement>(onResize: (size: DOMRectReadOnly) => void) => readonly [(element: T | null | undefined) => void, ResizeObserver | undefined];
|
|
@@ -19,7 +19,7 @@ declare module 'react-table' {
|
|
|
19
19
|
*/
|
|
20
20
|
isDisabled?: (rowData: D) => boolean;
|
|
21
21
|
};
|
|
22
|
-
interface TableOptions<D extends object = {}> extends Omit<UseTableOptions<D>, 'data'>, UseRowSelectOptions<D>, UseExpandedOptions<D>, UseFiltersOptions<D>, UsePaginationOptions<D>, Omit<UseResizeColumnsOptions<D>, 'disableResizing'>, UseSortByOptions<D> {
|
|
22
|
+
interface TableOptions<D extends object = {}> extends Omit<UseTableOptions<D>, 'data'>, UseRowSelectOptions<D>, UseExpandedOptions<D>, UseFiltersOptions<D>, UsePaginationOptions<D>, UseGlobalFiltersOptions<D>, UseGlobalFiltersColumnOptions<D>, Omit<UseResizeColumnsOptions<D>, 'disableResizing'>, UseSortByOptions<D> {
|
|
23
23
|
/**
|
|
24
24
|
* Table data list.
|
|
25
25
|
* Must be memoized.
|
|
@@ -28,11 +28,22 @@ declare module 'react-table' {
|
|
|
28
28
|
* If some rows don't have sub-data, it is recommended to pass an empty array to `subRows` for consistent spacing.
|
|
29
29
|
*/
|
|
30
30
|
data: D[];
|
|
31
|
+
/**
|
|
32
|
+
* Column's resize mode.
|
|
33
|
+
* - `fit` - when resizing it affects current and the next column,
|
|
34
|
+
* e.g. when increasing width of current column, next column's width will decrease.
|
|
35
|
+
* - `expand` - when resizing it affects only the current column,
|
|
36
|
+
* e.g. when increasing width of the current column, next column's width remains the same.
|
|
37
|
+
* @default 'fit'
|
|
38
|
+
*/
|
|
39
|
+
columnResizeMode?: 'fit' | 'expand';
|
|
31
40
|
}
|
|
32
41
|
interface Hooks<D extends object = {}> extends UseExpandedHooks<D>, UseGroupByHooks<D>, UseRowSelectHooks<D>, UseSortByHooks<D> {
|
|
33
42
|
}
|
|
34
43
|
interface TableInstance<D extends object = {}> extends UseColumnOrderInstanceProps<D>, UseExpandedInstanceProps<D>, UseFiltersInstanceProps<D>, UseGlobalFiltersInstanceProps<D>, UseGroupByInstanceProps<D>, UsePaginationInstanceProps<D>, UseRowSelectInstanceProps<D>, UseRowStateInstanceProps<D>, UseSortByInstanceProps<D> {
|
|
35
44
|
initialRows: Row<D>[];
|
|
45
|
+
columnResizeMode: TableOptions['columnResizeMode'];
|
|
46
|
+
tableWidth: number;
|
|
36
47
|
}
|
|
37
48
|
interface TableState<D extends object = {}> extends UseColumnOrderState<D>, UseExpandedState<D>, UseFiltersState<D>, UseGlobalFiltersState<D>, UseGroupByState<D>, UsePaginationState<D>, UseRowSelectState<D>, UseRowStateState<D>, UseSortByState<D> {
|
|
38
49
|
columnResizing: {
|
|
@@ -50,6 +61,7 @@ declare module 'react-table' {
|
|
|
50
61
|
isScrolledToRight?: boolean;
|
|
51
62
|
isScrolledToLeft?: boolean;
|
|
52
63
|
};
|
|
64
|
+
lastSelectedRowId?: string;
|
|
53
65
|
}
|
|
54
66
|
interface ColumnInterface<D extends object = {}> extends UseSortByColumnOptions<D>, UseFiltersColumnOptions<D>, UseResizeColumnsColumnOptions<D> {
|
|
55
67
|
/**
|
|
@@ -16,6 +16,64 @@ export declare type BreadcrumbsProps = {
|
|
|
16
16
|
* Defaults to the `SvgChevronRight` icon.
|
|
17
17
|
*/
|
|
18
18
|
separator?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* If specified, this prop will be used to show a custom button when overflow happens,
|
|
21
|
+
* i.e. when there is not enough space to fit all the breadcrumbs.
|
|
22
|
+
*
|
|
23
|
+
* Expects a function that takes the number of items that are visible
|
|
24
|
+
* and returns the `ReactNode` to render.
|
|
25
|
+
*
|
|
26
|
+
* @example <caption>Uses the overflow button to redirect to the previous breadcrumb</caption>
|
|
27
|
+
* <Breadcrumbs
|
|
28
|
+
* overflowButton={(visibleCount: number) => {
|
|
29
|
+
* const previousBreadcrumb = visibleCount > 1 ? items.length - visibleCount : items.length - 2;
|
|
30
|
+
* return (
|
|
31
|
+
* <Tooltip content={`Item ${previousBreadcrumb}`} placement='bottom'>
|
|
32
|
+
* <IconButton
|
|
33
|
+
* onClick={() => {
|
|
34
|
+
* // click on "previousBreadcrumb"
|
|
35
|
+
* }}
|
|
36
|
+
* >
|
|
37
|
+
* <SvgMoreSmall />
|
|
38
|
+
* </IconButton>
|
|
39
|
+
* </Tooltip>
|
|
40
|
+
* );
|
|
41
|
+
* }}
|
|
42
|
+
* >
|
|
43
|
+
* {items}
|
|
44
|
+
* </Breadcrumbs>
|
|
45
|
+
*
|
|
46
|
+
* @example <caption>Uses the overflow button to add a dropdown that contains hidden breadcrumbs</caption>
|
|
47
|
+
* <Breadcrumbs
|
|
48
|
+
* overflowButton={(visibleCount) => (
|
|
49
|
+
* <DropdownMenu
|
|
50
|
+
* menuItems={(close) =>
|
|
51
|
+
* Array(items.length - visibleCount)
|
|
52
|
+
* .fill(null)
|
|
53
|
+
* .map((_, _index) => {
|
|
54
|
+
* const index = visibleCount > 1 ? _index + 1 : _index;
|
|
55
|
+
* const onClick = () => {
|
|
56
|
+
* // click on "index" breadcrumb
|
|
57
|
+
* close();
|
|
58
|
+
* };
|
|
59
|
+
* return (
|
|
60
|
+
* <MenuItem key={index} onClick={onClick}>
|
|
61
|
+
* Item {index}
|
|
62
|
+
* </MenuItem>
|
|
63
|
+
* );
|
|
64
|
+
* })
|
|
65
|
+
* }
|
|
66
|
+
* >
|
|
67
|
+
* <IconButton>
|
|
68
|
+
* <SvgMoreSmall />
|
|
69
|
+
* </IconButton>
|
|
70
|
+
* </DropdownMenu>
|
|
71
|
+
* )}
|
|
72
|
+
* >
|
|
73
|
+
* {items}
|
|
74
|
+
* </Breadcrumbs>
|
|
75
|
+
*/
|
|
76
|
+
overflowButton?: (visibleCount: number) => React.ReactNode;
|
|
19
77
|
} & Omit<CommonProps, 'title'>;
|
|
20
78
|
/**
|
|
21
79
|
* A breadcrumb trail is used as a navigational aid to help users keep track
|
|
@@ -54,5 +112,63 @@ export declare const Breadcrumbs: React.ForwardRefExoticComponent<{
|
|
|
54
112
|
* Defaults to the `SvgChevronRight` icon.
|
|
55
113
|
*/
|
|
56
114
|
separator?: React.ReactNode;
|
|
115
|
+
/**
|
|
116
|
+
* If specified, this prop will be used to show a custom button when overflow happens,
|
|
117
|
+
* i.e. when there is not enough space to fit all the breadcrumbs.
|
|
118
|
+
*
|
|
119
|
+
* Expects a function that takes the number of items that are visible
|
|
120
|
+
* and returns the `ReactNode` to render.
|
|
121
|
+
*
|
|
122
|
+
* @example <caption>Uses the overflow button to redirect to the previous breadcrumb</caption>
|
|
123
|
+
* <Breadcrumbs
|
|
124
|
+
* overflowButton={(visibleCount: number) => {
|
|
125
|
+
* const previousBreadcrumb = visibleCount > 1 ? items.length - visibleCount : items.length - 2;
|
|
126
|
+
* return (
|
|
127
|
+
* <Tooltip content={`Item ${previousBreadcrumb}`} placement='bottom'>
|
|
128
|
+
* <IconButton
|
|
129
|
+
* onClick={() => {
|
|
130
|
+
* // click on "previousBreadcrumb"
|
|
131
|
+
* }}
|
|
132
|
+
* >
|
|
133
|
+
* <SvgMoreSmall />
|
|
134
|
+
* </IconButton>
|
|
135
|
+
* </Tooltip>
|
|
136
|
+
* );
|
|
137
|
+
* }}
|
|
138
|
+
* >
|
|
139
|
+
* {items}
|
|
140
|
+
* </Breadcrumbs>
|
|
141
|
+
*
|
|
142
|
+
* @example <caption>Uses the overflow button to add a dropdown that contains hidden breadcrumbs</caption>
|
|
143
|
+
* <Breadcrumbs
|
|
144
|
+
* overflowButton={(visibleCount) => (
|
|
145
|
+
* <DropdownMenu
|
|
146
|
+
* menuItems={(close) =>
|
|
147
|
+
* Array(items.length - visibleCount)
|
|
148
|
+
* .fill(null)
|
|
149
|
+
* .map((_, _index) => {
|
|
150
|
+
* const index = visibleCount > 1 ? _index + 1 : _index;
|
|
151
|
+
* const onClick = () => {
|
|
152
|
+
* // click on "index" breadcrumb
|
|
153
|
+
* close();
|
|
154
|
+
* };
|
|
155
|
+
* return (
|
|
156
|
+
* <MenuItem key={index} onClick={onClick}>
|
|
157
|
+
* Item {index}
|
|
158
|
+
* </MenuItem>
|
|
159
|
+
* );
|
|
160
|
+
* })
|
|
161
|
+
* }
|
|
162
|
+
* >
|
|
163
|
+
* <IconButton>
|
|
164
|
+
* <SvgMoreSmall />
|
|
165
|
+
* </IconButton>
|
|
166
|
+
* </DropdownMenu>
|
|
167
|
+
* )}
|
|
168
|
+
* >
|
|
169
|
+
* {items}
|
|
170
|
+
* </Breadcrumbs>
|
|
171
|
+
*/
|
|
172
|
+
overflowButton?: ((visibleCount: number) => React.ReactNode) | undefined;
|
|
57
173
|
} & Omit<CommonProps, "title"> & React.RefAttributes<HTMLElement>>;
|
|
58
174
|
export default Breadcrumbs;
|
|
@@ -52,7 +52,7 @@ import '@itwin/itwinui-css/css/breadcrumbs.css';
|
|
|
52
52
|
* </Breadcrumbs>
|
|
53
53
|
*/
|
|
54
54
|
export var Breadcrumbs = React.forwardRef(function (props, ref) {
|
|
55
|
-
var items = props.children, _a = props.currentIndex, currentIndex = _a === void 0 ? items.length - 1 : _a, separator = props.separator, className = props.className, rest = __rest(props, ["children", "currentIndex", "separator", "className"]);
|
|
55
|
+
var items = props.children, _a = props.currentIndex, currentIndex = _a === void 0 ? items.length - 1 : _a, separator = props.separator, overflowButton = props.overflowButton, className = props.className, rest = __rest(props, ["children", "currentIndex", "separator", "overflowButton", "className"]);
|
|
56
56
|
useTheme();
|
|
57
57
|
var _b = useOverflow(items), overflowRef = _b[0], visibleCount = _b[1];
|
|
58
58
|
var refs = useMergedRefs(overflowRef, ref);
|
|
@@ -62,8 +62,7 @@ export var Breadcrumbs = React.forwardRef(function (props, ref) {
|
|
|
62
62
|
React.createElement(ListItem, { item: items[0], isActive: currentIndex === 0 }),
|
|
63
63
|
React.createElement(Separator, { separator: separator }))),
|
|
64
64
|
items.length - visibleCount > 0 && (React.createElement(React.Fragment, null,
|
|
65
|
-
React.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' },
|
|
66
|
-
React.createElement("span", { className: 'iui-breadcrumbs-text' }, "\u2026")),
|
|
65
|
+
React.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' }, overflowButton ? (overflowButton(visibleCount)) : (React.createElement("span", { className: 'iui-breadcrumbs-text' }, "\u2026"))),
|
|
67
66
|
React.createElement(Separator, { separator: separator }))),
|
|
68
67
|
items
|
|
69
68
|
.slice(visibleCount > 1
|
|
@@ -72,7 +72,7 @@ export var ButtonGroup = React.forwardRef(function (props, ref) {
|
|
|
72
72
|
overflowButton &&
|
|
73
73
|
overflowPlacement === 'start' && (React.createElement("div", null, overflowButton(visibleCount))),
|
|
74
74
|
visibleCount < items.length
|
|
75
|
-
? items.slice(0, visibleCount - 1)
|
|
75
|
+
? items.slice(0, Math.max(0, visibleCount - 1))
|
|
76
76
|
: items,
|
|
77
77
|
visibleCount < items.length &&
|
|
78
78
|
overflowButton &&
|
|
@@ -17,5 +17,5 @@ export declare type ColorSwatchProps = {
|
|
|
17
17
|
* <ColorSwatch color='#23450b' onClick={onClick}/>
|
|
18
18
|
* <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
|
|
19
19
|
*/
|
|
20
|
-
export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "children" | "role" | "className" | "onClick" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "
|
|
20
|
+
export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "children" | "role" | "className" | "onClick" | "accessKey" | "onPointerDown" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "isActive"> & React.RefAttributes<HTMLDivElement>>;
|
|
21
21
|
export default ColorSwatch;
|
|
@@ -10,15 +10,35 @@ export declare const generateLocalizedStrings: (locale?: string) => {
|
|
|
10
10
|
shortDays: string[];
|
|
11
11
|
days: string[];
|
|
12
12
|
};
|
|
13
|
-
export declare type
|
|
13
|
+
export declare type DateRangePickerProps = {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Enable date range support.
|
|
16
|
+
* @default false
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
enableRangeSelect?: false;
|
|
19
|
+
/**
|
|
20
|
+
* Selected start date
|
|
21
|
+
*/
|
|
22
|
+
startDate?: undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Selected end date
|
|
25
|
+
*/
|
|
26
|
+
endDate?: undefined;
|
|
18
27
|
/**
|
|
19
28
|
* Callback when date is changed.
|
|
20
29
|
*/
|
|
21
30
|
onChange?: (date: Date) => void;
|
|
31
|
+
} | {
|
|
32
|
+
enableRangeSelect: true;
|
|
33
|
+
startDate: Date;
|
|
34
|
+
endDate: Date;
|
|
35
|
+
onChange?: (startDate: Date, endDate: Date) => void;
|
|
36
|
+
};
|
|
37
|
+
export declare type DatePickerProps = {
|
|
38
|
+
/**
|
|
39
|
+
* Selected date.
|
|
40
|
+
*/
|
|
41
|
+
date?: Date;
|
|
22
42
|
/**
|
|
23
43
|
* Pass localized week days (start from sunday) and months.
|
|
24
44
|
* Use helper function `generateLocalizedStrings` to generate strings using `Intl.DateTimeFormat`.
|
|
@@ -41,7 +61,7 @@ export declare type DatePickerProps = {
|
|
|
41
61
|
* @default false
|
|
42
62
|
*/
|
|
43
63
|
showYearSelection?: boolean;
|
|
44
|
-
} & Omit<TimePickerProps, 'date' | 'onChange' | 'setFocusHour'>;
|
|
64
|
+
} & DateRangePickerProps & Omit<TimePickerProps, 'date' | 'onChange' | 'setFocusHour'>;
|
|
45
65
|
/**
|
|
46
66
|
* Date picker component
|
|
47
67
|
* @example
|