@itwin/itwinui-react 1.44.0 → 1.46.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 +27 -0
- package/README.md +2 -2
- 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 +9 -1
- package/cjs/core/Table/Table.js +51 -6
- package/cjs/core/Table/TableRowMemoized.d.ts +10 -2
- package/cjs/core/Table/TableRowMemoized.js +23 -7
- 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/cells/DefaultCell.d.ts +14 -1
- package/cjs/core/Table/cells/DefaultCell.js +10 -4
- package/cjs/core/index.d.ts +3 -1
- package/cjs/core/index.js +6 -3
- package/cjs/core/utils/components/MiddleTextTruncation.d.ts +15 -1
- package/cjs/core/utils/components/MiddleTextTruncation.js +14 -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 +2 -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 +9 -1
- package/esm/core/Table/Table.js +53 -8
- package/esm/core/Table/TableRowMemoized.d.ts +10 -2
- package/esm/core/Table/TableRowMemoized.js +23 -7
- 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/cells/DefaultCell.d.ts +14 -1
- package/esm/core/Table/cells/DefaultCell.js +10 -4
- package/esm/core/index.d.ts +3 -1
- package/esm/core/index.js +2 -1
- package/esm/core/utils/components/MiddleTextTruncation.d.ts +15 -1
- package/esm/core/utils/components/MiddleTextTruncation.js +14 -3
- 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 +2 -1
- package/package.json +1 -1
|
@@ -42,7 +42,7 @@ var DialogContext_1 = require("./DialogContext");
|
|
|
42
42
|
*/
|
|
43
43
|
exports.DialogBackdrop = react_1.default.forwardRef(function (props, ref) {
|
|
44
44
|
var dialogContext = (0, DialogContext_1.useDialogContext)();
|
|
45
|
-
var _a = props.isVisible, isVisible = _a === void 0 ? dialogContext.isOpen : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? dialogContext.isDismissible : _b, _c = props.onClose, onClose = _c === void 0 ? dialogContext.onClose : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? dialogContext.closeOnExternalClick : _d, onMouseDown = props.onMouseDown, rest = __rest(props, ["isVisible", "isDismissible", "onClose", "closeOnExternalClick", "onMouseDown"]);
|
|
45
|
+
var _a = props.isVisible, isVisible = _a === void 0 ? dialogContext.isOpen : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? dialogContext.isDismissible : _b, _c = props.onClose, onClose = _c === void 0 ? dialogContext.onClose : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? dialogContext.closeOnExternalClick : _d, _e = props.relativeTo, relativeTo = _e === void 0 ? dialogContext.relativeTo : _e, onMouseDown = props.onMouseDown, style = props.style, rest = __rest(props, ["isVisible", "isDismissible", "onClose", "closeOnExternalClick", "relativeTo", "onMouseDown", "style"]);
|
|
46
46
|
var backdropRef = react_1.default.useRef(null);
|
|
47
47
|
var refs = (0, utils_1.useMergedRefs)(backdropRef, ref);
|
|
48
48
|
var handleMouseDown = function (event) {
|
|
@@ -56,6 +56,6 @@ exports.DialogBackdrop = react_1.default.forwardRef(function (props, ref) {
|
|
|
56
56
|
}
|
|
57
57
|
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
58
58
|
};
|
|
59
|
-
return (react_1.default.createElement(Backdrop_1.Backdrop, __assign({ isVisible: isVisible, ref: refs, onMouseDown: handleMouseDown }, rest)));
|
|
59
|
+
return (react_1.default.createElement(Backdrop_1.Backdrop, __assign({ isVisible: isVisible, ref: refs, onMouseDown: handleMouseDown, style: __assign({ pointerEvents: 'auto', position: relativeTo === 'container' ? 'absolute' : 'fixed' }, style) }, rest)));
|
|
60
60
|
});
|
|
61
61
|
exports.default = exports.DialogBackdrop;
|
|
@@ -29,11 +29,42 @@ export declare type DialogContextProps = {
|
|
|
29
29
|
* @default false
|
|
30
30
|
*/
|
|
31
31
|
trapFocus?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* If true, focuses the dialog.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
setFocus?: boolean;
|
|
32
37
|
/**
|
|
33
38
|
* Prevents body from being scrollable. This is useful when the dialog is modal.
|
|
34
39
|
* @default false
|
|
35
40
|
*/
|
|
36
41
|
preventDocumentScroll?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Flag whether dialog is draggable.
|
|
44
|
+
*
|
|
45
|
+
* If you want to make dialog draggable relatively to the container, you should use set `relativeTo` to `container`.
|
|
46
|
+
*
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
isDraggable?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Flag whether dialog is resizable.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
isResizable?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether dialog should be positioned relatively to a container or the viewport.
|
|
57
|
+
*
|
|
58
|
+
* Using `'container'` will absolutely position this dialog relative to the closest positioned ancestor.
|
|
59
|
+
* In other words, you must place the dialog as a child of an element that has `position` set to
|
|
60
|
+
* something other than `static`, e.g. `position: relative`.
|
|
61
|
+
* @default 'viewport'
|
|
62
|
+
*/
|
|
63
|
+
relativeTo?: 'container' | 'viewport';
|
|
64
|
+
/**
|
|
65
|
+
* Dialog root ref. For internal use.
|
|
66
|
+
*/
|
|
67
|
+
dialogRootRef?: React.RefObject<HTMLDivElement>;
|
|
37
68
|
};
|
|
38
69
|
export declare const DialogContext: React.Context<DialogContextProps | undefined>;
|
|
39
70
|
export declare const useDialogContext: () => DialogContextProps;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type DialogDragContextProps = {
|
|
3
|
+
onPointerDown?: (e: React.PointerEvent<HTMLElement>) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare const DialogDragContext: React.Context<DialogDragContextProps | undefined>;
|
|
6
|
+
export declare const useDialogDragContext: () => {
|
|
7
|
+
onPointerDown?: ((e: React.PointerEvent<HTMLElement>) => void) | undefined;
|
|
8
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.useDialogDragContext = exports.DialogDragContext = void 0;
|
|
18
|
+
/*---------------------------------------------------------------------------------------------
|
|
19
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
20
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
21
|
+
*--------------------------------------------------------------------------------------------*/
|
|
22
|
+
var react_1 = __importDefault(require("react"));
|
|
23
|
+
exports.DialogDragContext = react_1.default.createContext(undefined);
|
|
24
|
+
var useDialogDragContext = function () {
|
|
25
|
+
var context = react_1.default.useContext(exports.DialogDragContext);
|
|
26
|
+
return __assign({}, context);
|
|
27
|
+
};
|
|
28
|
+
exports.useDialogDragContext = useDialogDragContext;
|
|
@@ -11,7 +11,7 @@ export declare type DialogMainProps = {
|
|
|
11
11
|
* Content of the dialog.
|
|
12
12
|
*/
|
|
13
13
|
children: React.ReactNode;
|
|
14
|
-
} & Omit<DialogContextProps, 'closeOnExternalClick'> & React.ComponentPropsWithRef<'div'>;
|
|
14
|
+
} & Omit<DialogContextProps, 'closeOnExternalClick' | 'dialogRootRef'> & React.ComponentPropsWithRef<'div'>;
|
|
15
15
|
/**
|
|
16
16
|
* Dialog component which can wrap any content.
|
|
17
17
|
* @example
|
|
@@ -32,5 +32,5 @@ export declare type DialogMainProps = {
|
|
|
32
32
|
* </Dialog.ButtonBar>
|
|
33
33
|
* </Dialog.Main>
|
|
34
34
|
*/
|
|
35
|
-
export declare const DialogMain: React.ForwardRefExoticComponent<Pick<DialogMainProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "styleType" | "isOpen" | "isDismissible" | "closeOnEsc" | "trapFocus" | "preventDocumentScroll"> & React.RefAttributes<HTMLDivElement>>;
|
|
35
|
+
export declare const DialogMain: React.ForwardRefExoticComponent<Pick<DialogMainProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "styleType" | "setFocus" | "isOpen" | "isDismissible" | "isDraggable" | "closeOnEsc" | "trapFocus" | "preventDocumentScroll" | "isResizable" | "relativeTo"> & React.RefAttributes<HTMLDivElement>>;
|
|
36
36
|
export default DialogMain;
|
|
@@ -36,6 +36,8 @@ var utils_1 = require("../utils");
|
|
|
36
36
|
require("@itwin/itwinui-css/css/dialog.css");
|
|
37
37
|
var DialogContext_1 = require("./DialogContext");
|
|
38
38
|
var react_transition_group_1 = require("react-transition-group");
|
|
39
|
+
var DialogDragContext_1 = require("./DialogDragContext");
|
|
40
|
+
var useDragAndDrop_1 = __importDefault(require("../utils/hooks/useDragAndDrop"));
|
|
39
41
|
/**
|
|
40
42
|
* Dialog component which can wrap any content.
|
|
41
43
|
* @example
|
|
@@ -58,14 +60,19 @@ var react_transition_group_1 = require("react-transition-group");
|
|
|
58
60
|
*/
|
|
59
61
|
exports.DialogMain = react_1.default.forwardRef(function (props, ref) {
|
|
60
62
|
var dialogContext = (0, DialogContext_1.useDialogContext)();
|
|
61
|
-
var className = props.className, children = props.children, _a = props.styleType, styleType = _a === void 0 ? 'default' : _a, _b = props.isOpen, isOpen = _b === void 0 ? dialogContext.isOpen : _b, _c = props.isDismissible, isDismissible = _c === void 0 ? dialogContext.isDismissible : _c, _d = props.onClose, onClose = _d === void 0 ? dialogContext.onClose : _d, _e = props.closeOnEsc, closeOnEsc = _e === void 0 ? dialogContext.closeOnEsc : _e, _f = props.trapFocus, trapFocus = _f === void 0 ? dialogContext.trapFocus : _f, _g = props.preventDocumentScroll, preventDocumentScroll =
|
|
63
|
+
var className = props.className, children = props.children, _a = props.styleType, styleType = _a === void 0 ? 'default' : _a, _b = props.isOpen, isOpen = _b === void 0 ? dialogContext.isOpen : _b, _c = props.isDismissible, isDismissible = _c === void 0 ? dialogContext.isDismissible : _c, _d = props.onClose, onClose = _d === void 0 ? dialogContext.onClose : _d, _e = props.closeOnEsc, closeOnEsc = _e === void 0 ? dialogContext.closeOnEsc : _e, _f = props.trapFocus, trapFocus = _f === void 0 ? dialogContext.trapFocus : _f, _g = props.setFocus, setFocus = _g === void 0 ? dialogContext.setFocus : _g, _h = props.preventDocumentScroll, preventDocumentScroll = _h === void 0 ? dialogContext.preventDocumentScroll : _h, onKeyDown = props.onKeyDown, _j = props.isDraggable, isDraggable = _j === void 0 ? dialogContext.isDraggable : _j, _k = props.isResizable, isResizable = _k === void 0 ? dialogContext.isResizable : _k, propStyle = props.style, rest = __rest(props, ["className", "children", "styleType", "isOpen", "isDismissible", "onClose", "closeOnEsc", "trapFocus", "setFocus", "preventDocumentScroll", "onKeyDown", "isDraggable", "isResizable", "style"]);
|
|
62
64
|
(0, utils_1.useTheme)();
|
|
65
|
+
var _l = react_1.default.useState(), style = _l[0], setStyle = _l[1];
|
|
63
66
|
var dialogRef = react_1.default.useRef(null);
|
|
64
67
|
var refs = (0, utils_1.useMergedRefs)(dialogRef, ref);
|
|
65
68
|
// Focuses dialog when opened and brings back focus to the previously focused element when closed.
|
|
66
69
|
var previousFocusedElement = react_1.default.useRef();
|
|
70
|
+
var setFocusRef = (0, utils_1.useLatestRef)(setFocus);
|
|
67
71
|
react_1.default.useEffect(function () {
|
|
68
72
|
var _a, _b, _c;
|
|
73
|
+
if (!setFocusRef.current) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
69
76
|
if (isOpen) {
|
|
70
77
|
previousFocusedElement.current = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.activeElement;
|
|
71
78
|
(_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
@@ -79,17 +86,25 @@ exports.DialogMain = react_1.default.forwardRef(function (props, ref) {
|
|
|
79
86
|
(ref === null || ref === void 0 ? void 0 : ref.contains(document.activeElement)) &&
|
|
80
87
|
((_a = previousFocusedElement.current) === null || _a === void 0 ? void 0 : _a.focus());
|
|
81
88
|
};
|
|
89
|
+
}, [isOpen, setFocusRef]);
|
|
90
|
+
var originalBodyOverflow = react_1.default.useRef('');
|
|
91
|
+
react_1.default.useEffect(function () {
|
|
92
|
+
if (isOpen) {
|
|
93
|
+
originalBodyOverflow.current = document.body.style.overflow;
|
|
94
|
+
}
|
|
82
95
|
}, [isOpen]);
|
|
83
96
|
// Prevents document from scrolling when the dialog is open.
|
|
84
|
-
var originalBodyOverflow = react_1.default.useRef('');
|
|
85
97
|
react_1.default.useEffect(function () {
|
|
86
98
|
var _a;
|
|
87
99
|
var ownerDocument = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument;
|
|
88
|
-
|
|
100
|
+
// If there is no `ownerDocument` or `preventDocumentScroll` is false or
|
|
101
|
+
// document body originally has `overflow: hidden` (possibly from other/parent dialog), then do nothing.
|
|
102
|
+
if (!ownerDocument ||
|
|
103
|
+
!preventDocumentScroll ||
|
|
104
|
+
originalBodyOverflow.current === 'hidden') {
|
|
89
105
|
return;
|
|
90
106
|
}
|
|
91
107
|
if (isOpen) {
|
|
92
|
-
originalBodyOverflow.current = ownerDocument.body.style.overflow;
|
|
93
108
|
ownerDocument.body.style.overflow = 'hidden';
|
|
94
109
|
}
|
|
95
110
|
else {
|
|
@@ -107,13 +122,38 @@ exports.DialogMain = react_1.default.forwardRef(function (props, ref) {
|
|
|
107
122
|
}
|
|
108
123
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
109
124
|
};
|
|
125
|
+
var _m = (0, useDragAndDrop_1.default)(dialogRef, dialogContext.dialogRootRef, isDraggable), onPointerDown = _m.onPointerDown, transform = _m.transform;
|
|
126
|
+
var handlePointerDown = react_1.default.useCallback(function (event) {
|
|
127
|
+
if (isDraggable) {
|
|
128
|
+
onPointerDown(event);
|
|
129
|
+
}
|
|
130
|
+
}, [isDraggable, onPointerDown]);
|
|
131
|
+
// Prevents dialog from moving when window is being resized
|
|
132
|
+
react_1.default.useLayoutEffect(function () {
|
|
133
|
+
var _a;
|
|
134
|
+
if (!isDraggable || !isOpen) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
var rect = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
138
|
+
var _b = (0, utils_1.getTranslateValues)(dialogRef.current), translateX = _b[0], translateY = _b[1];
|
|
139
|
+
setStyle(function (oldStyle) {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
return (__assign(__assign({}, oldStyle), { width: rect === null || rect === void 0 ? void 0 : rect.width, height: rect === null || rect === void 0 ? void 0 : rect.height, left: (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.offsetLeft, top: (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.offsetTop, transform: "translate(".concat(translateX, "px,").concat(translateY, "px)") }));
|
|
142
|
+
});
|
|
143
|
+
}, [isDraggable, isOpen]);
|
|
144
|
+
var setResizeStyle = react_1.default.useCallback(function (newStyle) {
|
|
145
|
+
setStyle(function (oldStyle) { return (__assign(__assign({}, oldStyle), newStyle)); });
|
|
146
|
+
}, []);
|
|
110
147
|
var content = (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-dialog', {
|
|
111
148
|
'iui-dialog-default': styleType === 'default',
|
|
112
149
|
'iui-dialog-full-page': styleType === 'fullPage',
|
|
113
150
|
'iui-dialog-visible': isOpen,
|
|
114
|
-
|
|
151
|
+
'iui-dialog-draggable': isDraggable,
|
|
152
|
+
}, className), role: 'dialog', ref: refs, onKeyDown: handleKeyDown, tabIndex: -1, style: __assign(__assign({ transform: transform, overflow: 'unset' }, style), propStyle) }, rest),
|
|
153
|
+
isResizable && (react_1.default.createElement(utils_1.Resizer, { elementRef: dialogRef, containerRef: dialogContext.dialogRootRef, onResizeEnd: setResizeStyle })),
|
|
154
|
+
children));
|
|
115
155
|
return (react_1.default.createElement(react_transition_group_1.CSSTransition, { in: isOpen, classNames: 'iui-dialog-animation', timeout: { exit: 600 }, unmountOnExit: true, nodeRef: dialogRef },
|
|
116
|
-
react_1.default.createElement(
|
|
156
|
+
react_1.default.createElement(DialogDragContext_1.DialogDragContext.Provider, { value: { onPointerDown: handlePointerDown } },
|
|
117
157
|
trapFocus && react_1.default.createElement(utils_1.FocusTrap, null, content),
|
|
118
158
|
!trapFocus && content)));
|
|
119
159
|
});
|
|
@@ -10,7 +10,7 @@ export declare type DialogTitleBarProps = {
|
|
|
10
10
|
* Dialog title.
|
|
11
11
|
*/
|
|
12
12
|
titleText?: React.ReactNode;
|
|
13
|
-
} & Pick<DialogContextProps, 'isDismissible' | 'onClose'> & React.ComponentPropsWithRef<'div'>;
|
|
13
|
+
} & Pick<DialogContextProps, 'isDismissible' | 'onClose' | 'isDraggable'> & React.ComponentPropsWithRef<'div'>;
|
|
14
14
|
/**
|
|
15
15
|
* Dialog title bar. Recommended to be used as a child of `Dialog`.
|
|
16
16
|
* @example
|
|
@@ -28,7 +28,7 @@ export declare type DialogTitleBarProps = {
|
|
|
28
28
|
* </IconButton>
|
|
29
29
|
* </Dialog.TitleBar>
|
|
30
30
|
*/
|
|
31
|
-
export declare const DialogTitleBar: React.ForwardRefExoticComponent<Pick<DialogTitleBarProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isDismissible" | "titleText"> & React.RefAttributes<HTMLDivElement>> & {
|
|
31
|
+
export declare const DialogTitleBar: React.ForwardRefExoticComponent<Pick<DialogTitleBarProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isDismissible" | "isDraggable" | "titleText"> & React.RefAttributes<HTMLDivElement>> & {
|
|
32
32
|
Title: React.ForwardRefExoticComponent<Pick<import("./DialogTitleBarTitle").DialogTitleBarTitleProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
|
|
33
33
|
};
|
|
34
34
|
export default DialogTitleBar;
|
|
@@ -38,6 +38,7 @@ var Buttons_1 = require("../Buttons");
|
|
|
38
38
|
require("@itwin/itwinui-css/css/dialog.css");
|
|
39
39
|
var DialogContext_1 = require("./DialogContext");
|
|
40
40
|
var DialogTitleBarTitle_1 = require("./DialogTitleBarTitle");
|
|
41
|
+
var DialogDragContext_1 = require("./DialogDragContext");
|
|
41
42
|
/**
|
|
42
43
|
* Dialog title bar. Recommended to be used as a child of `Dialog`.
|
|
43
44
|
* @example
|
|
@@ -57,9 +58,18 @@ var DialogTitleBarTitle_1 = require("./DialogTitleBarTitle");
|
|
|
57
58
|
*/
|
|
58
59
|
exports.DialogTitleBar = Object.assign(react_1.default.forwardRef(function (props, ref) {
|
|
59
60
|
var dialogContext = (0, DialogContext_1.useDialogContext)();
|
|
60
|
-
var children = props.children, titleText = props.titleText, _a = props.isDismissible, isDismissible = _a === void 0 ? dialogContext.isDismissible : _a, _b = props.onClose, onClose = _b === void 0 ? dialogContext.onClose : _b, className = props.className, rest = __rest(props, ["children", "titleText", "isDismissible", "onClose", "className"]);
|
|
61
|
+
var children = props.children, titleText = props.titleText, _a = props.isDismissible, isDismissible = _a === void 0 ? dialogContext.isDismissible : _a, _b = props.onClose, onClose = _b === void 0 ? dialogContext.onClose : _b, _c = props.isDraggable, isDraggable = _c === void 0 ? dialogContext.isDraggable : _c, className = props.className, onPointerDownProp = props.onPointerDown, rest = __rest(props, ["children", "titleText", "isDismissible", "onClose", "isDraggable", "className", "onPointerDown"]);
|
|
62
|
+
var onPointerDown = (0, DialogDragContext_1.useDialogDragContext)().onPointerDown;
|
|
63
|
+
var handlePointerDown = react_1.default.useCallback(function (event) {
|
|
64
|
+
onPointerDownProp === null || onPointerDownProp === void 0 ? void 0 : onPointerDownProp(event);
|
|
65
|
+
if (!event.defaultPrevented) {
|
|
66
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
67
|
+
}
|
|
68
|
+
}, [onPointerDown, onPointerDownProp]);
|
|
61
69
|
(0, utils_1.useTheme)();
|
|
62
|
-
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-dialog-title-bar', className
|
|
70
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-dialog-title-bar', className, {
|
|
71
|
+
'iui-dialog-title-bar-filled': isDraggable,
|
|
72
|
+
}), ref: ref, onPointerDown: handlePointerDown }, rest), children ? (children) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
63
73
|
react_1.default.createElement(DialogTitleBarTitle_1.DialogTitleBarTitle, null, titleText),
|
|
64
74
|
isDismissible && (react_1.default.createElement(Buttons_1.IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
65
75
|
react_1.default.createElement(Close_1.default, null)))))));
|
package/cjs/core/Modal/Modal.js
CHANGED
|
@@ -60,7 +60,7 @@ var Modal = function (props) {
|
|
|
60
60
|
var _a = props.isOpen, isOpen = _a === void 0 ? false : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? true : _b, _c = props.closeOnEsc, closeOnEsc = _c === void 0 ? true : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? true : _d, onClose = props.onClose, title = props.title, children = props.children, _e = props.modalRootId, modalRootId = _e === void 0 ? 'iui-react-portal-container' : _e, _f = props.ownerDocument, ownerDocument = _f === void 0 ? (0, utils_1.getDocument)() : _f, rest = __rest(props, ["isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "title", "children", "modalRootId", "ownerDocument"]);
|
|
61
61
|
(0, utils_1.useTheme)();
|
|
62
62
|
var container = (0, utils_1.getContainer)(modalRootId, ownerDocument);
|
|
63
|
-
return !!container ? (react_dom_1.default.createPortal(react_1.default.createElement(Dialog_1.Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true },
|
|
63
|
+
return !!container ? (react_dom_1.default.createPortal(react_1.default.createElement(Dialog_1.Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true, setFocus: true },
|
|
64
64
|
react_1.default.createElement(Dialog_1.Dialog.Backdrop, null),
|
|
65
65
|
react_1.default.createElement(Dialog_1.Dialog.Main, __assign({ "aria-modal": true }, rest),
|
|
66
66
|
react_1.default.createElement(Dialog_1.Dialog.TitleBar, { titleText: title }),
|
|
@@ -116,6 +116,12 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
|
|
|
116
116
|
* Must be memoized.
|
|
117
117
|
*/
|
|
118
118
|
onFilter?: (filters: TableFilterValue<T>[], state: TableState<T>) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Value used for global filtering.
|
|
121
|
+
* Use with `globalFilter` and/or `manualGlobalFilter` to handle filtering yourself e.g. filter in server-side.
|
|
122
|
+
* Must be memoized.
|
|
123
|
+
*/
|
|
124
|
+
globalFilterValue?: unknown;
|
|
119
125
|
/**
|
|
120
126
|
* Content shown when there is no data after filtering.
|
|
121
127
|
*/
|
|
@@ -129,7 +135,9 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
|
|
|
129
135
|
* Function that should return custom props passed to the each row.
|
|
130
136
|
* Must be memoized.
|
|
131
137
|
*/
|
|
132
|
-
rowProps?: (row: Row<T>) => React.ComponentPropsWithRef<'div'
|
|
138
|
+
rowProps?: (row: Row<T>) => React.ComponentPropsWithRef<'div'> & {
|
|
139
|
+
status?: 'positive' | 'warning' | 'negative';
|
|
140
|
+
};
|
|
133
141
|
/**
|
|
134
142
|
* Modify the density of the table (adjusts the row height).
|
|
135
143
|
* @default 'default'
|
package/cjs/core/Table/Table.js
CHANGED
|
@@ -47,6 +47,7 @@ var actionHandlers_1 = require("./actionHandlers");
|
|
|
47
47
|
var VirtualScroll_1 = __importDefault(require("../utils/components/VirtualScroll"));
|
|
48
48
|
var columns_1 = require("./columns");
|
|
49
49
|
var singleRowSelectedAction = 'singleRowSelected';
|
|
50
|
+
var shiftRowSelectedAction = 'shiftRowSelected';
|
|
50
51
|
exports.tableResizeStartAction = 'tableResizeStart';
|
|
51
52
|
var tableResizeEndAction = 'tableResizeEnd';
|
|
52
53
|
var flattenColumns = function (columns) {
|
|
@@ -103,7 +104,7 @@ var flattenColumns = function (columns) {
|
|
|
103
104
|
*/
|
|
104
105
|
var Table = function (props) {
|
|
105
106
|
var _a;
|
|
106
|
-
var data = props.data, columns = props.columns, _b = props.isLoading, isLoading = _b === void 0 ? false : _b, emptyTableContent = props.emptyTableContent, className = props.className, style = props.style, id = props.id, _c = props.isSelectable, isSelectable = _c === void 0 ? false : _c, onSelect = props.onSelect, onRowClick = props.onRowClick, _d = props.selectionMode, selectionMode = _d === void 0 ? 'multi' : _d, _e = props.isSortable, isSortable = _e === void 0 ? false : _e, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _f = props.intersectionMargin, intersectionMargin = _f === void 0 ? 300 : _f, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _g = props.density, density = _g === void 0 ? 'default' : _g, _h = props.selectSubRows, selectSubRows = _h === void 0 ? true : _h, getSubRows = props.getSubRows, _j = props.selectRowOnClick, selectRowOnClick = _j === void 0 ? true : _j, paginatorRenderer = props.paginatorRenderer, _k = props.pageSize, pageSize = _k === void 0 ? 25 : _k, _l = props.isResizable, isResizable = _l === void 0 ? false : _l, _m = props.styleType, styleType = _m === void 0 ? 'default' : _m, _o = props.enableVirtualization, enableVirtualization = _o === void 0 ? false : _o, _p = props.enableColumnReordering, enableColumnReordering = _p === void 0 ? false : _p, rest = __rest(props, ["data", "columns", "isLoading", "emptyTableContent", "className", "style", "id", "isSelectable", "onSelect", "onRowClick", "selectionMode", "isSortable", "onSort", "stateReducer", "onBottomReached", "onRowInViewport", "intersectionMargin", "subComponent", "onExpand", "onFilter", "emptyFilteredTableContent", "filterTypes", "expanderCell", "isRowDisabled", "rowProps", "density", "selectSubRows", "getSubRows", "selectRowOnClick", "paginatorRenderer", "pageSize", "isResizable", "styleType", "enableVirtualization", "enableColumnReordering"]);
|
|
107
|
+
var data = props.data, columns = props.columns, _b = props.isLoading, isLoading = _b === void 0 ? false : _b, emptyTableContent = props.emptyTableContent, className = props.className, style = props.style, id = props.id, _c = props.isSelectable, isSelectable = _c === void 0 ? false : _c, onSelect = props.onSelect, onRowClick = props.onRowClick, _d = props.selectionMode, selectionMode = _d === void 0 ? 'multi' : _d, _e = props.isSortable, isSortable = _e === void 0 ? false : _e, onSort = props.onSort, stateReducer = props.stateReducer, onBottomReached = props.onBottomReached, onRowInViewport = props.onRowInViewport, _f = props.intersectionMargin, intersectionMargin = _f === void 0 ? 300 : _f, subComponent = props.subComponent, onExpand = props.onExpand, onFilter = props.onFilter, globalFilterValue = props.globalFilterValue, emptyFilteredTableContent = props.emptyFilteredTableContent, filterFunctions = props.filterTypes, expanderCell = props.expanderCell, isRowDisabled = props.isRowDisabled, rowProps = props.rowProps, _g = props.density, density = _g === void 0 ? 'default' : _g, _h = props.selectSubRows, selectSubRows = _h === void 0 ? true : _h, getSubRows = props.getSubRows, _j = props.selectRowOnClick, selectRowOnClick = _j === void 0 ? true : _j, paginatorRenderer = props.paginatorRenderer, _k = props.pageSize, pageSize = _k === void 0 ? 25 : _k, _l = props.isResizable, isResizable = _l === void 0 ? false : _l, _m = props.styleType, styleType = _m === void 0 ? 'default' : _m, _o = props.enableVirtualization, enableVirtualization = _o === void 0 ? false : _o, _p = props.enableColumnReordering, enableColumnReordering = _p === void 0 ? false : _p, rest = __rest(props, ["data", "columns", "isLoading", "emptyTableContent", "className", "style", "id", "isSelectable", "onSelect", "onRowClick", "selectionMode", "isSortable", "onSort", "stateReducer", "onBottomReached", "onRowInViewport", "intersectionMargin", "subComponent", "onExpand", "onFilter", "globalFilterValue", "emptyFilteredTableContent", "filterTypes", "expanderCell", "isRowDisabled", "rowProps", "density", "selectSubRows", "getSubRows", "selectRowOnClick", "paginatorRenderer", "pageSize", "isResizable", "styleType", "enableVirtualization", "enableColumnReordering"]);
|
|
107
108
|
(0, utils_1.useTheme)();
|
|
108
109
|
var _q = react_1.default.useState(), ownerDocument = _q[0], setOwnerDocument = _q[1];
|
|
109
110
|
var defaultColumn = react_1.default.useMemo(function () { return ({
|
|
@@ -122,6 +123,34 @@ var Table = function (props) {
|
|
|
122
123
|
var flatColumns = flattenColumns(columns);
|
|
123
124
|
return flatColumns.some(function (column) { return column.id === columns_1.SELECTION_CELL_ID; });
|
|
124
125
|
}, [columns]);
|
|
126
|
+
var disableUserSelect = react_1.default.useCallback(function (e) {
|
|
127
|
+
if (e.key === 'Shift') {
|
|
128
|
+
ownerDocument &&
|
|
129
|
+
(ownerDocument.documentElement.style.userSelect = 'none');
|
|
130
|
+
}
|
|
131
|
+
}, [ownerDocument]);
|
|
132
|
+
var enableUserSelect = react_1.default.useCallback(function (e) {
|
|
133
|
+
if (e.key === 'Shift') {
|
|
134
|
+
ownerDocument && (ownerDocument.documentElement.style.userSelect = '');
|
|
135
|
+
}
|
|
136
|
+
}, [ownerDocument]);
|
|
137
|
+
react_1.default.useEffect(function () {
|
|
138
|
+
if (!isSelectable || selectionMode !== 'multi') {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.addEventListener('keydown', disableUserSelect);
|
|
142
|
+
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.addEventListener('keyup', enableUserSelect);
|
|
143
|
+
return function () {
|
|
144
|
+
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.removeEventListener('keydown', disableUserSelect);
|
|
145
|
+
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.removeEventListener('keyup', enableUserSelect);
|
|
146
|
+
};
|
|
147
|
+
}, [
|
|
148
|
+
isSelectable,
|
|
149
|
+
selectionMode,
|
|
150
|
+
ownerDocument,
|
|
151
|
+
disableUserSelect,
|
|
152
|
+
enableUserSelect,
|
|
153
|
+
]);
|
|
125
154
|
var tableStateReducer = react_1.default.useCallback(function (newState, action, previousState, instance) {
|
|
126
155
|
switch (action.type) {
|
|
127
156
|
case react_table_1.actions.toggleSortBy:
|
|
@@ -140,6 +169,12 @@ var Table = function (props) {
|
|
|
140
169
|
hasManualSelectionColumn ? undefined : isRowDisabled);
|
|
141
170
|
break;
|
|
142
171
|
}
|
|
172
|
+
case shiftRowSelectedAction: {
|
|
173
|
+
newState = (0, actionHandlers_1.onShiftSelectHandler)(newState, action, instance, onSelect,
|
|
174
|
+
// If it has manual selection column, then we can't check whether row is disabled
|
|
175
|
+
hasManualSelectionColumn ? undefined : isRowDisabled);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
143
178
|
case react_table_1.actions.toggleRowSelected:
|
|
144
179
|
case react_table_1.actions.toggleAllRowsSelected:
|
|
145
180
|
case react_table_1.actions.toggleAllPageRowsSelected: {
|
|
@@ -177,8 +212,8 @@ var Table = function (props) {
|
|
|
177
212
|
return getSubRows ? getSubRows(item, index) : item.subRows;
|
|
178
213
|
});
|
|
179
214
|
}, [data, getSubRows]);
|
|
180
|
-
var instance = (0, react_table_1.useTable)(__assign(__assign({ manualPagination: !paginatorRenderer, paginateExpandedRows: false }, props), { columns: columns, defaultColumn: defaultColumn, disableSortBy: !isSortable, stateReducer: tableStateReducer, filterTypes: filterTypes, selectSubRows: selectSubRows, data: data, getSubRows: getSubRows, initialState: __assign({ pageSize: pageSize }, props.initialState) }), react_table_1.useFlexLayout, (0, hooks_1.useResizeColumns)(ownerDocument), react_table_1.useFilters, (0, hooks_1.useSubRowFiltering)(hasAnySubRows), react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, hooks_1.useSubRowSelection, (0, hooks_1.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, hooks_1.useSelectionCell)(isSelectable, selectionMode, isRowDisabled), react_table_1.useColumnOrder, (0, hooks_1.useColumnDragAndDrop)(enableColumnReordering), hooks_1.useStickyColumns);
|
|
181
|
-
var getTableProps = instance.getTableProps, rows = instance.rows, headerGroups = instance.headerGroups, getTableBodyProps = instance.getTableBodyProps, prepareRow = instance.prepareRow, state = instance.state, allColumns = instance.allColumns,
|
|
215
|
+
var instance = (0, react_table_1.useTable)(__assign(__assign({ manualPagination: !paginatorRenderer, paginateExpandedRows: false }, props), { columns: columns, defaultColumn: defaultColumn, disableSortBy: !isSortable, stateReducer: tableStateReducer, filterTypes: filterTypes, selectSubRows: selectSubRows, data: data, getSubRows: getSubRows, initialState: __assign({ pageSize: pageSize }, props.initialState) }), react_table_1.useFlexLayout, (0, hooks_1.useResizeColumns)(ownerDocument), react_table_1.useFilters, (0, hooks_1.useSubRowFiltering)(hasAnySubRows), react_table_1.useGlobalFilter, react_table_1.useSortBy, react_table_1.useExpanded, react_table_1.usePagination, react_table_1.useRowSelect, hooks_1.useSubRowSelection, (0, hooks_1.useExpanderCell)(subComponent, expanderCell, isRowDisabled), (0, hooks_1.useSelectionCell)(isSelectable, selectionMode, isRowDisabled), react_table_1.useColumnOrder, (0, hooks_1.useColumnDragAndDrop)(enableColumnReordering), hooks_1.useStickyColumns);
|
|
216
|
+
var getTableProps = instance.getTableProps, rows = instance.rows, headerGroups = instance.headerGroups, getTableBodyProps = instance.getTableBodyProps, prepareRow = instance.prepareRow, state = instance.state, allColumns = instance.allColumns, dispatch = instance.dispatch, page = instance.page, gotoPage = instance.gotoPage, setPageSize = instance.setPageSize, flatHeaders = instance.flatHeaders, visibleColumns = instance.visibleColumns, setGlobalFilter = instance.setGlobalFilter;
|
|
182
217
|
var ariaDataAttributes = Object.entries(rest).reduce(function (result, _a) {
|
|
183
218
|
var key = _a[0], value = _a[1];
|
|
184
219
|
if (key.startsWith('data-') || key.startsWith('aria-')) {
|
|
@@ -186,7 +221,7 @@ var Table = function (props) {
|
|
|
186
221
|
}
|
|
187
222
|
return result;
|
|
188
223
|
}, {});
|
|
189
|
-
var areFiltersSet = allColumns.some(function (column) { return column.filterValue != null && column.filterValue !== ''; });
|
|
224
|
+
var areFiltersSet = allColumns.some(function (column) { return column.filterValue != null && column.filterValue !== ''; }) || !!globalFilterValue;
|
|
190
225
|
var showFilterButton = function (column) {
|
|
191
226
|
return (data.length !== 0 || areFiltersSet) && column.canFilter;
|
|
192
227
|
};
|
|
@@ -202,7 +237,14 @@ var Table = function (props) {
|
|
|
202
237
|
!isDisabled &&
|
|
203
238
|
selectRowOnClick &&
|
|
204
239
|
!event.isDefaultPrevented()) {
|
|
205
|
-
if (
|
|
240
|
+
if (selectionMode === 'multi' && event.shiftKey) {
|
|
241
|
+
dispatch({
|
|
242
|
+
type: shiftRowSelectedAction,
|
|
243
|
+
id: row.id,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
else if (!row.isSelected &&
|
|
247
|
+
(selectionMode === 'single' || !event.ctrlKey)) {
|
|
206
248
|
dispatch({
|
|
207
249
|
type: singleRowSelectedAction,
|
|
208
250
|
id: row.id,
|
|
@@ -220,6 +262,9 @@ var Table = function (props) {
|
|
|
220
262
|
dispatch,
|
|
221
263
|
onRowClick,
|
|
222
264
|
]);
|
|
265
|
+
react_1.default.useEffect(function () {
|
|
266
|
+
setGlobalFilter(globalFilterValue);
|
|
267
|
+
}, [globalFilterValue, setGlobalFilter]);
|
|
223
268
|
react_1.default.useEffect(function () {
|
|
224
269
|
setPageSize(pageSize);
|
|
225
270
|
}, [pageSize, setPageSize]);
|
|
@@ -393,7 +438,7 @@ var Table = function (props) {
|
|
|
393
438
|
!isLoading && data.length === 0 && !areFiltersSet && (react_1.default.createElement("div", { className: 'iui-table-empty' },
|
|
394
439
|
react_1.default.createElement("div", null, emptyTableContent))),
|
|
395
440
|
!isLoading &&
|
|
396
|
-
(data.length === 0 ||
|
|
441
|
+
(data.length === 0 || rows.length === 0) &&
|
|
397
442
|
areFiltersSet && (react_1.default.createElement("div", { className: 'iui-table-empty' },
|
|
398
443
|
react_1.default.createElement("div", null, emptyFilteredTableContent)))), paginatorRenderer === null || paginatorRenderer === void 0 ? void 0 :
|
|
399
444
|
paginatorRenderer(paginatorRendererProps))));
|
|
@@ -8,7 +8,11 @@ import { CellProps, Row, TableInstance, TableState } from 'react-table';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const TableRow: <T extends Record<string, unknown>>(props: {
|
|
10
10
|
row: Row<T>;
|
|
11
|
-
rowProps?: ((row: Row<T>) => React.
|
|
11
|
+
rowProps?: ((row: Row<T>) => Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
12
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
13
|
+
} & {
|
|
14
|
+
status?: "positive" | "warning" | "negative" | undefined;
|
|
15
|
+
}) | undefined;
|
|
12
16
|
isLast: boolean;
|
|
13
17
|
onRowInViewport: React.MutableRefObject<((rowData: T) => void) | undefined>;
|
|
14
18
|
onBottomReached: React.MutableRefObject<(() => void) | undefined>;
|
|
@@ -25,7 +29,11 @@ export declare const TableRow: <T extends Record<string, unknown>>(props: {
|
|
|
25
29
|
}) => JSX.Element;
|
|
26
30
|
export declare const TableRowMemoized: <T extends Record<string, unknown>>(props: {
|
|
27
31
|
row: Row<T>;
|
|
28
|
-
rowProps?: ((row: Row<T>) => React.
|
|
32
|
+
rowProps?: ((row: Row<T>) => Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
33
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
34
|
+
} & {
|
|
35
|
+
status?: "positive" | "warning" | "negative" | undefined;
|
|
36
|
+
}) | undefined;
|
|
29
37
|
isLast: boolean;
|
|
30
38
|
onRowInViewport: React.MutableRefObject<((rowData: T) => void) | undefined>;
|
|
31
39
|
onBottomReached: React.MutableRefObject<(() => void) | undefined>;
|
|
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
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
|
+
};
|
|
13
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
26
|
};
|
|
@@ -30,6 +41,8 @@ var TableCell_1 = require("./TableCell");
|
|
|
30
41
|
* When adding new features check whether it changes state that affects row. If it does then add equality check to `React.memo`.
|
|
31
42
|
*/
|
|
32
43
|
var TableRow = function (props) {
|
|
44
|
+
var _a;
|
|
45
|
+
var _b;
|
|
33
46
|
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, tableRowRef = props.tableRowRef;
|
|
34
47
|
var onIntersect = react_1.default.useCallback(function () {
|
|
35
48
|
var _a, _b;
|
|
@@ -50,13 +63,16 @@ var TableRow = function (props) {
|
|
|
50
63
|
rootMargin: "".concat(intersectionMargin, "px"),
|
|
51
64
|
root: intersectionRoot,
|
|
52
65
|
});
|
|
53
|
-
var userRowProps = rowProps === null || rowProps === void 0 ? void 0 : rowProps(row);
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
var userRowProps = (_b = rowProps === null || rowProps === void 0 ? void 0 : rowProps(row)) !== null && _b !== void 0 ? _b : {};
|
|
67
|
+
var status = userRowProps.status, restUserRowProps = __rest(userRowProps, ["status"]);
|
|
68
|
+
var mergedProps = __assign(__assign(__assign({}, row.getRowProps({ style: { flex: "0 0 auto", minWidth: '100%' } })), restUserRowProps), {
|
|
69
|
+
className: (0, classnames_1.default)('iui-row', (_a = {
|
|
70
|
+
'iui-selected': row.isSelected,
|
|
71
|
+
'iui-row-expanded': row.isExpanded && subComponent,
|
|
72
|
+
'iui-disabled': isDisabled
|
|
73
|
+
},
|
|
74
|
+
_a["iui-".concat(status)] = !!status,
|
|
75
|
+
_a), userRowProps === null || userRowProps === void 0 ? void 0 : userRowProps.className),
|
|
60
76
|
});
|
|
61
77
|
var refs = (0, utils_1.useMergedRefs)(intersectionRef, mergedProps.ref, tableRowRef);
|
|
62
78
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { onExpandHandler } from './expandHandler';
|
|
2
2
|
export { onFilterHandler } from './filterHandler';
|
|
3
|
-
export { onSelectHandler, onSingleSelectHandler } from './selectHandler';
|
|
3
|
+
export { onSelectHandler, onSingleSelectHandler, onShiftSelectHandler, } from './selectHandler';
|
|
4
4
|
export { onTableResizeStart, onTableResizeEnd } from './resizeHandler';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.onTableResizeEnd = exports.onTableResizeStart = exports.onSingleSelectHandler = exports.onSelectHandler = exports.onFilterHandler = exports.onExpandHandler = void 0;
|
|
3
|
+
exports.onTableResizeEnd = exports.onTableResizeStart = exports.onShiftSelectHandler = exports.onSingleSelectHandler = exports.onSelectHandler = exports.onFilterHandler = exports.onExpandHandler = 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.
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "onFilterHandler", { enumerable: true, get: funct
|
|
|
12
12
|
var selectHandler_1 = require("./selectHandler");
|
|
13
13
|
Object.defineProperty(exports, "onSelectHandler", { enumerable: true, get: function () { return selectHandler_1.onSelectHandler; } });
|
|
14
14
|
Object.defineProperty(exports, "onSingleSelectHandler", { enumerable: true, get: function () { return selectHandler_1.onSingleSelectHandler; } });
|
|
15
|
+
Object.defineProperty(exports, "onShiftSelectHandler", { enumerable: true, get: function () { return selectHandler_1.onShiftSelectHandler; } });
|
|
15
16
|
var resizeHandler_1 = require("./resizeHandler");
|
|
16
17
|
Object.defineProperty(exports, "onTableResizeStart", { enumerable: true, get: function () { return resizeHandler_1.onTableResizeStart; } });
|
|
17
18
|
Object.defineProperty(exports, "onTableResizeEnd", { enumerable: true, get: function () { return resizeHandler_1.onTableResizeEnd; } });
|
|
@@ -16,6 +16,7 @@ export declare const onTableResizeStart: <T extends Record<string, unknown>>(sta
|
|
|
16
16
|
isScrolledToRight?: boolean | undefined;
|
|
17
17
|
isScrolledToLeft?: boolean | undefined;
|
|
18
18
|
};
|
|
19
|
+
lastSelectedRowId?: string | undefined;
|
|
19
20
|
columnOrder: import("react-table").IdType<T>[];
|
|
20
21
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
21
22
|
filters: import("react-table").Filters<T>;
|
|
@@ -46,6 +47,7 @@ export declare const onTableResizeEnd: <T extends Record<string, unknown>>(state
|
|
|
46
47
|
isScrolledToRight?: boolean | undefined;
|
|
47
48
|
isScrolledToLeft?: boolean | undefined;
|
|
48
49
|
};
|
|
50
|
+
lastSelectedRowId?: string | undefined;
|
|
49
51
|
columnOrder: import("react-table").IdType<T>[];
|
|
50
52
|
expanded: Record<import("react-table").IdType<T>, boolean>;
|
|
51
53
|
filters: import("react-table").Filters<T>;
|
|
@@ -7,6 +7,7 @@ export declare const onSelectHandler: <T extends Record<string, unknown>>(newSta
|
|
|
7
7
|
* Handles selection when clicked on a row.
|
|
8
8
|
*/
|
|
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
|
+
lastSelectedRowId: any;
|
|
10
11
|
selectedRowIds: Record<string, boolean>;
|
|
11
12
|
hiddenColumns?: import("react-table").IdType<T>[] | undefined;
|
|
12
13
|
columnResizing: {
|
|
@@ -36,3 +37,7 @@ export declare const onSingleSelectHandler: <T extends Record<string, unknown>>(
|
|
|
36
37
|
}>;
|
|
37
38
|
sortBy: import("react-table").SortingRule<T>[];
|
|
38
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Handles selection when clicked on a row while shift key is pressed.
|
|
42
|
+
*/
|
|
43
|
+
export declare const onShiftSelectHandler: <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) => TableState<T>;
|