@itwin/itwinui-react 1.41.0 → 1.43.1
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 +33 -0
- package/cjs/core/Backdrop/Backdrop.d.ts +10 -0
- package/cjs/core/Backdrop/Backdrop.js +41 -0
- package/cjs/core/Backdrop/index.d.ts +2 -0
- package/cjs/core/Backdrop/index.js +9 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +18 -18
- package/cjs/core/ButtonGroup/ButtonGroup.js +11 -4
- package/cjs/core/ComboBox/ComboBox.js +15 -14
- package/cjs/core/Dialog/Dialog.d.ts +41 -0
- package/cjs/core/Dialog/Dialog.js +59 -0
- package/cjs/core/Dialog/DialogBackdrop.d.ts +12 -0
- package/cjs/core/Dialog/DialogBackdrop.js +61 -0
- package/cjs/core/Dialog/DialogButtonBar.d.ts +18 -0
- package/cjs/core/Dialog/DialogButtonBar.js +50 -0
- package/cjs/core/Dialog/DialogContent.d.ts +17 -0
- package/cjs/core/Dialog/DialogContent.js +49 -0
- package/cjs/core/Dialog/DialogContext.d.ts +39 -0
- package/cjs/core/Dialog/DialogContext.js +16 -0
- package/cjs/core/Dialog/DialogMain.d.ts +36 -0
- package/cjs/core/Dialog/DialogMain.js +120 -0
- package/cjs/core/Dialog/DialogTitleBar.d.ts +34 -0
- package/cjs/core/Dialog/DialogTitleBar.js +69 -0
- package/cjs/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
- package/cjs/core/Dialog/DialogTitleBarTitle.js +47 -0
- package/cjs/core/Dialog/index.d.ts +8 -0
- package/cjs/core/Dialog/index.js +10 -0
- package/cjs/core/Footer/Footer.d.ts +16 -2
- package/cjs/core/Footer/Footer.js +57 -45
- package/cjs/core/Footer/FooterItem.d.ts +8 -0
- package/cjs/core/Footer/FooterItem.js +46 -0
- package/cjs/core/Footer/FooterList.d.ts +8 -0
- package/cjs/core/Footer/FooterList.js +46 -0
- package/cjs/core/Footer/FooterSeparator.d.ts +8 -0
- package/cjs/core/Footer/FooterSeparator.js +46 -0
- package/cjs/core/Footer/index.d.ts +1 -1
- package/cjs/core/Footer/index.js +2 -1
- package/cjs/core/Modal/Modal.d.ts +4 -14
- package/cjs/core/Modal/Modal.js +9 -74
- package/cjs/core/Modal/ModalButtonBar.d.ts +1 -2
- package/cjs/core/Modal/ModalButtonBar.js +2 -39
- package/cjs/core/Modal/ModalContent.d.ts +1 -2
- package/cjs/core/Modal/ModalContent.js +2 -39
- package/cjs/core/Slider/Slider.d.ts +10 -0
- package/cjs/core/Slider/Slider.js +20 -14
- package/cjs/core/Slider/Thumb.d.ts +2 -1
- package/cjs/core/Slider/Thumb.js +5 -3
- package/cjs/core/Slider/Track.d.ts +2 -1
- package/cjs/core/Slider/Track.js +23 -4
- package/cjs/core/Table/Table.d.ts +24 -0
- package/cjs/core/Table/Table.js +12 -4
- package/cjs/core/Table/TableRowMemoized.d.ts +2 -0
- package/cjs/core/Table/TableRowMemoized.js +2 -2
- package/cjs/core/Table/columns/actionColumn.d.ts +8 -3
- package/cjs/core/Table/columns/actionColumn.js +33 -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/useScrollToRow.d.ts +11 -0
- package/cjs/core/Table/hooks/useScrollToRow.js +49 -0
- package/cjs/core/Tree/Tree.d.ts +9 -0
- package/cjs/core/Tree/Tree.js +67 -19
- package/cjs/core/Tree/TreeContext.d.ts +4 -0
- package/cjs/core/Tree/TreeNode.js +8 -9
- package/cjs/core/Typography/Small/Small.js +1 -1
- package/cjs/core/index.d.ts +3 -1
- package/cjs/core/index.js +6 -3
- package/cjs/core/utils/components/FocusTrap.js +1 -1
- package/cjs/core/utils/components/MiddleTextTruncation.js +1 -1
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useLatestRef.d.ts +9 -0
- package/cjs/core/utils/hooks/useLatestRef.js +26 -0
- package/esm/core/Backdrop/Backdrop.d.ts +10 -0
- package/esm/core/Backdrop/Backdrop.js +35 -0
- package/esm/core/Backdrop/index.d.ts +2 -0
- package/esm/core/Backdrop/index.js +5 -0
- package/esm/core/Breadcrumbs/Breadcrumbs.js +18 -18
- package/esm/core/ButtonGroup/ButtonGroup.js +11 -4
- package/esm/core/ComboBox/ComboBox.js +16 -15
- package/esm/core/Dialog/Dialog.d.ts +41 -0
- package/esm/core/Dialog/Dialog.js +53 -0
- package/esm/core/Dialog/DialogBackdrop.d.ts +12 -0
- package/esm/core/Dialog/DialogBackdrop.js +55 -0
- package/esm/core/Dialog/DialogButtonBar.d.ts +18 -0
- package/esm/core/Dialog/DialogButtonBar.js +44 -0
- package/esm/core/Dialog/DialogContent.d.ts +17 -0
- package/esm/core/Dialog/DialogContent.js +43 -0
- package/esm/core/Dialog/DialogContext.d.ts +39 -0
- package/esm/core/Dialog/DialogContext.js +9 -0
- package/esm/core/Dialog/DialogMain.d.ts +36 -0
- package/esm/core/Dialog/DialogMain.js +114 -0
- package/esm/core/Dialog/DialogTitleBar.d.ts +34 -0
- package/esm/core/Dialog/DialogTitleBar.js +63 -0
- package/esm/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
- package/esm/core/Dialog/DialogTitleBarTitle.js +41 -0
- package/esm/core/Dialog/index.d.ts +8 -0
- package/esm/core/Dialog/index.js +6 -0
- package/esm/core/Footer/Footer.d.ts +16 -2
- package/esm/core/Footer/Footer.js +56 -43
- package/esm/core/Footer/FooterItem.d.ts +8 -0
- package/esm/core/Footer/FooterItem.js +39 -0
- package/esm/core/Footer/FooterList.d.ts +8 -0
- package/esm/core/Footer/FooterList.js +39 -0
- package/esm/core/Footer/FooterSeparator.d.ts +8 -0
- package/esm/core/Footer/FooterSeparator.js +39 -0
- package/esm/core/Footer/index.d.ts +1 -1
- package/esm/core/Footer/index.js +1 -1
- package/esm/core/Modal/Modal.d.ts +4 -14
- package/esm/core/Modal/Modal.js +10 -75
- package/esm/core/Modal/ModalButtonBar.d.ts +1 -2
- package/esm/core/Modal/ModalButtonBar.js +2 -35
- package/esm/core/Modal/ModalContent.d.ts +1 -2
- package/esm/core/Modal/ModalContent.js +2 -35
- package/esm/core/Slider/Slider.d.ts +10 -0
- package/esm/core/Slider/Slider.js +20 -14
- package/esm/core/Slider/Thumb.d.ts +2 -1
- package/esm/core/Slider/Thumb.js +5 -3
- package/esm/core/Slider/Track.d.ts +2 -1
- package/esm/core/Slider/Track.js +23 -4
- package/esm/core/Table/Table.d.ts +24 -0
- package/esm/core/Table/Table.js +13 -5
- package/esm/core/Table/TableRowMemoized.d.ts +2 -0
- package/esm/core/Table/TableRowMemoized.js +2 -2
- package/esm/core/Table/columns/actionColumn.d.ts +8 -3
- package/esm/core/Table/columns/actionColumn.js +33 -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/useScrollToRow.d.ts +11 -0
- package/esm/core/Table/hooks/useScrollToRow.js +42 -0
- package/esm/core/Tree/Tree.d.ts +9 -0
- package/esm/core/Tree/Tree.js +68 -20
- package/esm/core/Tree/TreeContext.d.ts +4 -0
- package/esm/core/Tree/TreeNode.js +8 -9
- package/esm/core/Typography/Small/Small.js +1 -1
- package/esm/core/index.d.ts +3 -1
- package/esm/core/index.js +2 -1
- package/esm/core/utils/components/FocusTrap.js +1 -1
- package/esm/core/utils/components/MiddleTextTruncation.js +1 -1
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useLatestRef.d.ts +9 -0
- package/esm/core/utils/hooks/useLatestRef.js +19 -0
- package/package.json +6 -5
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CommonProps } from '../utils';
|
|
3
3
|
import '@itwin/itwinui-css/css/dialog.css';
|
|
4
|
-
import '
|
|
4
|
+
import { DialogMainProps } from '../Dialog';
|
|
5
5
|
export declare type ModalProps = {
|
|
6
|
-
/**
|
|
7
|
-
* Flag whether modal should be shown.
|
|
8
|
-
* @default false
|
|
9
|
-
*/
|
|
10
|
-
isOpen?: boolean;
|
|
11
6
|
/**
|
|
12
7
|
* Modal title.
|
|
13
8
|
*/
|
|
@@ -46,16 +41,11 @@ export declare type ModalProps = {
|
|
|
46
41
|
* @default document
|
|
47
42
|
*/
|
|
48
43
|
ownerDocument?: Document;
|
|
49
|
-
/**
|
|
50
|
-
* Type of the modal.
|
|
51
|
-
* @default 'default'
|
|
52
|
-
*/
|
|
53
|
-
styleType?: 'default' | 'fullPage';
|
|
54
44
|
/**
|
|
55
45
|
* Content of the modal.
|
|
56
46
|
*/
|
|
57
47
|
children: React.ReactNode;
|
|
58
|
-
} & Omit<CommonProps, 'title'>;
|
|
48
|
+
} & Pick<DialogMainProps, 'isOpen' | 'styleType'> & Omit<CommonProps, 'title'>;
|
|
59
49
|
/**
|
|
60
50
|
* Modal component which can wrap any content.
|
|
61
51
|
* @example
|
|
@@ -64,9 +54,9 @@ export declare type ModalProps = {
|
|
|
64
54
|
* title='My modal'
|
|
65
55
|
* onClose={onClose}
|
|
66
56
|
* >
|
|
67
|
-
* <
|
|
57
|
+
* <ModalContent>
|
|
68
58
|
* Here is my modal content
|
|
69
|
-
* </
|
|
59
|
+
* </ModalContent>
|
|
70
60
|
* <ModalButtonBar>
|
|
71
61
|
* <Button styleType='high-visibility'>
|
|
72
62
|
* Primary button
|
package/esm/core/Modal/Modal.js
CHANGED
|
@@ -26,13 +26,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
26
26
|
*--------------------------------------------------------------------------------------------*/
|
|
27
27
|
import React from 'react';
|
|
28
28
|
import ReactDOM from 'react-dom';
|
|
29
|
-
import
|
|
30
|
-
import SvgClose from '@itwin/itwinui-icons-react/cjs/icons/Close';
|
|
31
|
-
import { useTheme, getContainer, getDocument, FocusTrap, } from '../utils';
|
|
29
|
+
import { useTheme, getContainer, getDocument } from '../utils';
|
|
32
30
|
import '@itwin/itwinui-css/css/dialog.css';
|
|
33
|
-
import '
|
|
34
|
-
import { IconButton } from '../Buttons/IconButton';
|
|
35
|
-
import { CSSTransition } from 'react-transition-group';
|
|
31
|
+
import { Dialog } from '../Dialog';
|
|
36
32
|
/**
|
|
37
33
|
* Modal component which can wrap any content.
|
|
38
34
|
* @example
|
|
@@ -41,9 +37,9 @@ import { CSSTransition } from 'react-transition-group';
|
|
|
41
37
|
* title='My modal'
|
|
42
38
|
* onClose={onClose}
|
|
43
39
|
* >
|
|
44
|
-
* <
|
|
40
|
+
* <ModalContent>
|
|
45
41
|
* Here is my modal content
|
|
46
|
-
* </
|
|
42
|
+
* </ModalContent>
|
|
47
43
|
* <ModalButtonBar>
|
|
48
44
|
* <Button styleType='high-visibility'>
|
|
49
45
|
* Primary button
|
|
@@ -55,74 +51,13 @@ import { CSSTransition } from 'react-transition-group';
|
|
|
55
51
|
* </Modal>
|
|
56
52
|
*/
|
|
57
53
|
export var Modal = function (props) {
|
|
58
|
-
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,
|
|
54
|
+
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 ? getDocument() : _f, rest = __rest(props, ["isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "title", "children", "modalRootId", "ownerDocument"]);
|
|
59
55
|
useTheme();
|
|
60
56
|
var container = getContainer(modalRootId, ownerDocument);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var _a, _b;
|
|
67
|
-
if (isOpen) {
|
|
68
|
-
previousFocusedElement.current = document.activeElement;
|
|
69
|
-
(_a = overlayRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
(_b = previousFocusedElement.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
73
|
-
}
|
|
74
|
-
var modalOverlayRef = overlayRef.current;
|
|
75
|
-
return function () {
|
|
76
|
-
var _a;
|
|
77
|
-
(modalOverlayRef === null || modalOverlayRef === void 0 ? void 0 : modalOverlayRef.contains(document.activeElement)) &&
|
|
78
|
-
((_a = previousFocusedElement.current) === null || _a === void 0 ? void 0 : _a.focus());
|
|
79
|
-
};
|
|
80
|
-
}, [isOpen]);
|
|
81
|
-
React.useEffect(function () {
|
|
82
|
-
if (!ownerDocument) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (isOpen) {
|
|
86
|
-
originalBodyOverflow.current = ownerDocument.body.style.overflow;
|
|
87
|
-
ownerDocument.body.style.overflow = 'hidden';
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
ownerDocument.body.style.overflow = originalBodyOverflow.current;
|
|
91
|
-
}
|
|
92
|
-
return function () {
|
|
93
|
-
ownerDocument.body.style.overflow = originalBodyOverflow.current;
|
|
94
|
-
};
|
|
95
|
-
}, [isOpen, ownerDocument]);
|
|
96
|
-
var handleKeyDown = function (event) {
|
|
97
|
-
// Prevents React from resetting its properties
|
|
98
|
-
event.persist();
|
|
99
|
-
if (isDismissible && closeOnEsc && event.key === 'Escape' && onClose) {
|
|
100
|
-
onClose(event);
|
|
101
|
-
}
|
|
102
|
-
if (onKeyDown) {
|
|
103
|
-
onKeyDown(event);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var handleMouseDown = function (event) {
|
|
107
|
-
// Prevents React from resetting its properties
|
|
108
|
-
event.persist();
|
|
109
|
-
if (event.target !== overlayRef.current) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (isDismissible && closeOnExternalClick && onClose) {
|
|
113
|
-
onClose(event);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
return !!container ? (ReactDOM.createPortal(React.createElement(React.Fragment, null,
|
|
117
|
-
React.createElement("div", { className: cx('iui-backdrop', { 'iui-backdrop-visible': isOpen }), tabIndex: -1, onKeyDown: handleKeyDown, ref: overlayRef, onMouseDown: handleMouseDown }),
|
|
118
|
-
React.createElement(FocusTrap, null,
|
|
119
|
-
React.createElement("div", null,
|
|
120
|
-
React.createElement(CSSTransition, { in: isOpen, classNames: 'iui-dialog-animation', timeout: { exit: 600 }, unmountOnExit: true },
|
|
121
|
-
React.createElement("div", __assign({ className: cx('iui-dialog', { 'iui-dialog-default': styleType === 'default' }, { 'iui-dialog-full-page': styleType === 'fullPage' }, { 'iui-dialog-visible': isOpen }, className), id: id, style: style, role: 'dialog', "aria-modal": 'true' }, rest),
|
|
122
|
-
React.createElement("div", { className: 'iui-dialog-title-bar' },
|
|
123
|
-
React.createElement("div", { className: 'iui-dialog-title' }, title),
|
|
124
|
-
isDismissible && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
125
|
-
React.createElement(SvgClose, null)))),
|
|
126
|
-
children))))), container)) : (React.createElement(React.Fragment, null));
|
|
57
|
+
return !!container ? (ReactDOM.createPortal(React.createElement(Dialog, { isOpen: isOpen, closeOnEsc: closeOnEsc, closeOnExternalClick: closeOnExternalClick, isDismissible: isDismissible, onClose: onClose, preventDocumentScroll: true, trapFocus: true },
|
|
58
|
+
React.createElement(Dialog.Backdrop, null),
|
|
59
|
+
React.createElement(Dialog.Main, __assign({ "aria-modal": true }, rest),
|
|
60
|
+
React.createElement(Dialog.TitleBar, { titleText: title }),
|
|
61
|
+
children)), container)) : (React.createElement(React.Fragment, null));
|
|
127
62
|
};
|
|
128
63
|
export default Modal;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CommonProps } from '../utils';
|
|
3
|
-
import '@itwin/itwinui-css/css/dialog.css';
|
|
4
3
|
export declare type ModalButtonBarProps = {
|
|
5
4
|
/**
|
|
6
5
|
* Buttons in the modal bar.
|
|
@@ -10,5 +9,5 @@ export declare type ModalButtonBarProps = {
|
|
|
10
9
|
/**
|
|
11
10
|
* Container for Buttons in modal.
|
|
12
11
|
*/
|
|
13
|
-
export declare const ModalButtonBar: (
|
|
12
|
+
export declare const ModalButtonBar: React.ForwardRefExoticComponent<Pick<import("../Dialog/DialogButtonBar").DialogButtonBarProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
|
|
14
13
|
export default ModalButtonBar;
|
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
|
|
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 '../utils';
|
|
30
|
-
import '@itwin/itwinui-css/css/dialog.css';
|
|
1
|
+
import { DialogButtonBar } from '../Dialog/DialogButtonBar';
|
|
31
2
|
/**
|
|
32
3
|
* Container for Buttons in modal.
|
|
33
4
|
*/
|
|
34
|
-
export var ModalButtonBar =
|
|
35
|
-
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
36
|
-
useTheme();
|
|
37
|
-
return (React.createElement("div", __assign({ className: cx('iui-dialog-button-bar', className) }, rest), children));
|
|
38
|
-
};
|
|
5
|
+
export var ModalButtonBar = DialogButtonBar;
|
|
39
6
|
export default ModalButtonBar;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CommonProps } from '../utils';
|
|
3
|
-
import '@itwin/itwinui-css/css/dialog.css';
|
|
4
3
|
export declare type ModalContentProps = {
|
|
5
4
|
/**
|
|
6
5
|
* Main content in the `Modal`.
|
|
@@ -10,5 +9,5 @@ export declare type ModalContentProps = {
|
|
|
10
9
|
/**
|
|
11
10
|
* Container for content in `Modal`.
|
|
12
11
|
*/
|
|
13
|
-
export declare const ModalContent: (
|
|
12
|
+
export declare const ModalContent: React.ForwardRefExoticComponent<Pick<import("../Dialog/DialogContent").DialogContentProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
|
|
14
13
|
export default ModalContent;
|
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
|
|
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 '../utils';
|
|
30
|
-
import '@itwin/itwinui-css/css/dialog.css';
|
|
1
|
+
import { DialogContent } from '../Dialog/DialogContent';
|
|
31
2
|
/**
|
|
32
3
|
* Container for content in `Modal`.
|
|
33
4
|
*/
|
|
34
|
-
export var ModalContent =
|
|
35
|
-
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
36
|
-
useTheme();
|
|
37
|
-
return (React.createElement("div", __assign({ className: cx('iui-dialog-content', className) }, rest), children));
|
|
38
|
-
};
|
|
5
|
+
export var ModalContent = DialogContent;
|
|
39
6
|
export default ModalContent;
|
|
@@ -96,6 +96,11 @@ export declare type SliderProps = {
|
|
|
96
96
|
* high-volume of updates will occur when dragging.
|
|
97
97
|
*/
|
|
98
98
|
onUpdate?: (values: ReadonlyArray<number>) => void;
|
|
99
|
+
/**
|
|
100
|
+
* The orientation of slider
|
|
101
|
+
* @default 'horizontal'
|
|
102
|
+
*/
|
|
103
|
+
orientation?: 'horizontal' | 'vertical';
|
|
99
104
|
} & Omit<CommonProps, 'title'>;
|
|
100
105
|
/**
|
|
101
106
|
* Slider component that display Thumbs for each value specified along a Rail.
|
|
@@ -195,5 +200,10 @@ export declare const Slider: React.ForwardRefExoticComponent<{
|
|
|
195
200
|
* high-volume of updates will occur when dragging.
|
|
196
201
|
*/
|
|
197
202
|
onUpdate?: ((values: ReadonlyArray<number>) => void) | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* The orientation of slider
|
|
205
|
+
* @default 'horizontal'
|
|
206
|
+
*/
|
|
207
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
198
208
|
} & Omit<CommonProps, "title"> & React.RefAttributes<HTMLDivElement>>;
|
|
199
209
|
export default Slider;
|
|
@@ -39,9 +39,13 @@ import { useTheme, getBoundedValue, useEventListener, } from '../utils';
|
|
|
39
39
|
import '@itwin/itwinui-css/css/slider.css';
|
|
40
40
|
import { Track } from './Track';
|
|
41
41
|
import { Thumb } from './Thumb';
|
|
42
|
-
var getPercentageOfRectangle = function (rect,
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
var getPercentageOfRectangle = function (rect, pointerX, pointerY, orientation) {
|
|
43
|
+
if (orientation === 'horizontal') {
|
|
44
|
+
var position_1 = getBoundedValue(pointerX, rect.left, rect.right);
|
|
45
|
+
return (position_1 - rect.left) / rect.width;
|
|
46
|
+
}
|
|
47
|
+
var position = getBoundedValue(pointerY, rect.top, rect.bottom);
|
|
48
|
+
return (rect.bottom - position) / rect.height;
|
|
45
49
|
};
|
|
46
50
|
var getClosestValueIndex = function (values, pointerValue) {
|
|
47
51
|
if (1 === values.length) {
|
|
@@ -88,20 +92,20 @@ var focusThumb = function (sliderContainer, activeIndex) {
|
|
|
88
92
|
*/
|
|
89
93
|
export var Slider = React.forwardRef(function (props, ref) {
|
|
90
94
|
var _a, _b;
|
|
91
|
-
var _c = props.min, min = _c === void 0 ? 0 : _c, _d = props.max, max = _d === void 0 ? 100 : _d, values = props.values, _e = props.step, step = _e === void 0 ? 1 : _e, _f = props.setFocus, setFocus = _f === void 0 ? false : _f, tooltipProps = props.tooltipProps, _g = props.disabled, disabled = _g === void 0 ? false : _g, tickLabels = props.tickLabels, minLabel = props.minLabel, maxLabel = props.maxLabel, _h = props.trackDisplayMode, trackDisplayMode = _h === void 0 ? 'auto' : _h, _j = props.thumbMode, thumbMode = _j === void 0 ? 'inhibit-crossing' : _j, onChange = props.onChange, onUpdate = props.onUpdate, thumbProps = props.thumbProps, className = props.className, railContainerProps = props.railContainerProps, rest = __rest(props, ["min", "max", "values", "step", "setFocus", "tooltipProps", "disabled", "tickLabels", "minLabel", "maxLabel", "trackDisplayMode", "thumbMode", "onChange", "onUpdate", "thumbProps", "className", "railContainerProps"]);
|
|
92
|
-
var
|
|
95
|
+
var _c = props.min, min = _c === void 0 ? 0 : _c, _d = props.max, max = _d === void 0 ? 100 : _d, values = props.values, _e = props.step, step = _e === void 0 ? 1 : _e, _f = props.setFocus, setFocus = _f === void 0 ? false : _f, tooltipProps = props.tooltipProps, _g = props.disabled, disabled = _g === void 0 ? false : _g, tickLabels = props.tickLabels, minLabel = props.minLabel, maxLabel = props.maxLabel, _h = props.trackDisplayMode, trackDisplayMode = _h === void 0 ? 'auto' : _h, _j = props.thumbMode, thumbMode = _j === void 0 ? 'inhibit-crossing' : _j, onChange = props.onChange, onUpdate = props.onUpdate, thumbProps = props.thumbProps, className = props.className, railContainerProps = props.railContainerProps, _k = props.orientation, orientation = _k === void 0 ? 'horizontal' : _k, rest = __rest(props, ["min", "max", "values", "step", "setFocus", "tooltipProps", "disabled", "tickLabels", "minLabel", "maxLabel", "trackDisplayMode", "thumbMode", "onChange", "onUpdate", "thumbProps", "className", "railContainerProps", "orientation"]);
|
|
96
|
+
var _l = React.useState(values), currentValues = _l[0], setCurrentValues = _l[1];
|
|
93
97
|
React.useEffect(function () {
|
|
94
98
|
setCurrentValues(values);
|
|
95
99
|
}, [values]);
|
|
96
|
-
var
|
|
100
|
+
var _m = React.useState(function () { return minLabel !== null && minLabel !== void 0 ? minLabel : min.toString(); }), minValueLabel = _m[0], setMinValueLabel = _m[1];
|
|
97
101
|
React.useEffect(function () {
|
|
98
102
|
setMinValueLabel(minLabel !== null && minLabel !== void 0 ? minLabel : min.toString());
|
|
99
103
|
}, [minLabel, min]);
|
|
100
|
-
var
|
|
104
|
+
var _o = React.useState(function () { return maxLabel !== null && maxLabel !== void 0 ? maxLabel : max.toString(); }), maxValueLabel = _o[0], setMaxValueLabel = _o[1];
|
|
101
105
|
React.useEffect(function () {
|
|
102
106
|
setMaxValueLabel(maxLabel !== null && maxLabel !== void 0 ? maxLabel : max.toString());
|
|
103
107
|
}, [maxLabel, max]);
|
|
104
|
-
var
|
|
108
|
+
var _p = React.useState(function () { return getDefaultTrackDisplay(trackDisplayMode, currentValues); }), trackDisplay = _p[0], setTrackDisplay = _p[1];
|
|
105
109
|
React.useEffect(function () {
|
|
106
110
|
setTrackDisplay(getDefaultTrackDisplay(trackDisplayMode, currentValues));
|
|
107
111
|
}, [trackDisplayMode, currentValues]);
|
|
@@ -127,10 +131,10 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
127
131
|
}
|
|
128
132
|
return [min, max];
|
|
129
133
|
}, [max, min, step, thumbMode, currentValues]);
|
|
130
|
-
var
|
|
134
|
+
var _q = React.useState(undefined), activeThumbIndex = _q[0], setActiveThumbIndex = _q[1];
|
|
131
135
|
var updateThumbValue = React.useCallback(function (event, callbackType) {
|
|
132
136
|
if (containerRef.current && undefined !== activeThumbIndex) {
|
|
133
|
-
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX);
|
|
137
|
+
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX, event.clientY, orientation);
|
|
134
138
|
var pointerValue = min + (max - min) * percent;
|
|
135
139
|
pointerValue = roundValueToClosestStep(pointerValue, step, min);
|
|
136
140
|
var _a = getAllowableThumbRange(activeThumbIndex), minVal = _a[0], maxVal = _a[1];
|
|
@@ -156,6 +160,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
156
160
|
currentValues,
|
|
157
161
|
onUpdate,
|
|
158
162
|
onChange,
|
|
163
|
+
orientation,
|
|
159
164
|
]);
|
|
160
165
|
var handlePointerMove = React.useCallback(function (event) {
|
|
161
166
|
if (activeThumbIndex === undefined) {
|
|
@@ -189,7 +194,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
189
194
|
}, [activeThumbIndex, updateThumbValue]);
|
|
190
195
|
var handlePointerDownOnSlider = React.useCallback(function (event) {
|
|
191
196
|
if (containerRef.current) {
|
|
192
|
-
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX);
|
|
197
|
+
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX, event.clientY, orientation);
|
|
193
198
|
var pointerValue = min + (max - min) * percent;
|
|
194
199
|
pointerValue = roundValueToClosestStep(pointerValue, step, min);
|
|
195
200
|
var closestValueIndex = getClosestValueIndex(currentValues, pointerValue);
|
|
@@ -215,6 +220,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
215
220
|
getAllowableThumbRange,
|
|
216
221
|
onChange,
|
|
217
222
|
onUpdate,
|
|
223
|
+
orientation,
|
|
218
224
|
]);
|
|
219
225
|
useEventListener('pointermove', handlePointerMove, (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument);
|
|
220
226
|
useEventListener('pointerup', handlePointerUp, (_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.ownerDocument);
|
|
@@ -235,7 +241,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
235
241
|
? outProps.content
|
|
236
242
|
: formatNumberValue(val, step, getNumDecimalPlaces) });
|
|
237
243
|
}, [getNumDecimalPlaces, step, tooltipProps]);
|
|
238
|
-
return (React.createElement("div", __assign({ ref: ref, className: cx('iui-slider-component-container', { 'iui-disabled': disabled }, className) }, rest),
|
|
244
|
+
return (React.createElement("div", __assign({ ref: ref, className: cx('iui-slider-component-container', "iui-slider-".concat(orientation), { 'iui-disabled': disabled }, className) }, rest),
|
|
239
245
|
minValueLabel && (React.createElement("span", { className: 'iui-slider-min' }, minValueLabel)),
|
|
240
246
|
React.createElement("div", __assign({ ref: containerRef, className: cx('iui-slider-container', {
|
|
241
247
|
'iui-grabbing': undefined !== activeThumbIndex,
|
|
@@ -245,9 +251,9 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
245
251
|
var _a;
|
|
246
252
|
var _b = getAllowableThumbRange(index), minVal = _b[0], maxVal = _b[1];
|
|
247
253
|
var thisThumbProps = thumbProps === null || thumbProps === void 0 ? void 0 : thumbProps(index);
|
|
248
|
-
return (React.createElement(Thumb, { key: (_a = thisThumbProps === null || thisThumbProps === void 0 ? void 0 : thisThumbProps.id) !== null && _a !== void 0 ? _a : index, index: index, disabled: disabled, isActive: activeThumbIndex === index, onThumbActivated: onThumbActivated, onThumbValueChanged: onThumbValueChanged, minVal: minVal, maxVal: maxVal, value: thumbValue, tooltipProps: generateTooltipProps(index, thumbValue), thumbProps: thisThumbProps, step: step, sliderMin: min, sliderMax: max }));
|
|
254
|
+
return (React.createElement(Thumb, { key: (_a = thisThumbProps === null || thisThumbProps === void 0 ? void 0 : thisThumbProps.id) !== null && _a !== void 0 ? _a : index, index: index, disabled: disabled, isActive: activeThumbIndex === index, onThumbActivated: onThumbActivated, onThumbValueChanged: onThumbValueChanged, minVal: minVal, maxVal: maxVal, value: thumbValue, tooltipProps: generateTooltipProps(index, thumbValue), thumbProps: thisThumbProps, step: step, sliderMin: min, sliderMax: max, orientation: orientation }));
|
|
249
255
|
}),
|
|
250
|
-
React.createElement(Track, { trackDisplayMode: trackDisplay, sliderMin: min, sliderMax: max, values: currentValues }),
|
|
256
|
+
React.createElement(Track, { trackDisplayMode: trackDisplay, sliderMin: min, sliderMax: max, values: currentValues, orientation: orientation }),
|
|
251
257
|
tickMarkArea),
|
|
252
258
|
maxValueLabel && (React.createElement("span", { className: 'iui-slider-max' }, maxValueLabel))));
|
|
253
259
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TooltipProps } from '../Tooltip';
|
|
3
|
+
import { SliderProps } from './Slider';
|
|
3
4
|
export declare type ThumbProps = {
|
|
4
5
|
/**
|
|
5
6
|
* Thumb value.
|
|
@@ -53,7 +54,7 @@ export declare type ThumbProps = {
|
|
|
53
54
|
* Additional props for Thumb.
|
|
54
55
|
*/
|
|
55
56
|
thumbProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
56
|
-
}
|
|
57
|
+
} & Pick<SliderProps, 'orientation'>;
|
|
57
58
|
/**
|
|
58
59
|
* Thumb is a local component used to show and modify the values maintained by the Slider.
|
|
59
60
|
* Only one Thumb can be active at a time. A Thumb is made active when the user selects
|
package/esm/core/Slider/Thumb.js
CHANGED
|
@@ -33,7 +33,7 @@ import { Tooltip } from '../Tooltip';
|
|
|
33
33
|
* it with pointer. Whenever a Thumb is active, focused, or hovered its tooltip is shown.
|
|
34
34
|
*/
|
|
35
35
|
export var Thumb = function (props) {
|
|
36
|
-
var value = props.value, index = props.index, minVal = props.minVal, maxVal = props.maxVal, step = props.step, sliderMin = props.sliderMin, sliderMax = props.sliderMax, isActive = props.isActive, onThumbActivated = props.onThumbActivated, onThumbValueChanged = props.onThumbValueChanged, tooltipProps = props.tooltipProps, thumbProps = props.thumbProps, disabled = props.disabled;
|
|
36
|
+
var value = props.value, index = props.index, minVal = props.minVal, maxVal = props.maxVal, step = props.step, sliderMin = props.sliderMin, sliderMax = props.sliderMax, isActive = props.isActive, onThumbActivated = props.onThumbActivated, onThumbValueChanged = props.onThumbValueChanged, tooltipProps = props.tooltipProps, thumbProps = props.thumbProps, disabled = props.disabled, orientation = props.orientation;
|
|
37
37
|
var thumbRef = React.useRef(null);
|
|
38
38
|
var handleOnKeyDown = React.useCallback(function (event) {
|
|
39
39
|
if (disabled || event.altKey) {
|
|
@@ -73,7 +73,7 @@ export var Thumb = function (props) {
|
|
|
73
73
|
}
|
|
74
74
|
return value;
|
|
75
75
|
}, [sliderMax, sliderMin, value]);
|
|
76
|
-
var
|
|
76
|
+
var lowPercent = React.useMemo(function () {
|
|
77
77
|
if (sliderMax === sliderMin) {
|
|
78
78
|
return 0;
|
|
79
79
|
}
|
|
@@ -81,5 +81,7 @@ export var Thumb = function (props) {
|
|
|
81
81
|
}, [adjustedValue, sliderMax, sliderMin]);
|
|
82
82
|
var _c = thumbProps || {}, style = _c.style, className = _c.className, rest = __rest(_c, ["style", "className"]);
|
|
83
83
|
return (React.createElement(Tooltip, __assign({ visible: isActive || hasFocus || isHovered, placement: 'top' }, tooltipProps),
|
|
84
|
-
React.createElement("div", __assign({}, rest, { "data-index": index, ref: thumbRef, style: __assign(__assign({}, style),
|
|
84
|
+
React.createElement("div", __assign({}, rest, { "data-index": index, ref: thumbRef, style: __assign(__assign({}, style), (orientation === 'horizontal'
|
|
85
|
+
? { left: "".concat(lowPercent, "%") }
|
|
86
|
+
: { bottom: "".concat(lowPercent, "%") })), className: cx('iui-slider-thumb', { 'iui-active': isActive }, className), role: 'slider', tabIndex: disabled ? undefined : 0, "aria-valuemin": minVal, "aria-valuenow": value, "aria-valuemax": maxVal, "aria-disabled": disabled, onPointerDown: handlePointerDownOnThumb, onKeyDown: handleOnKeyDown, onFocus: function () { return setHasFocus(true); }, onBlur: function () { return setHasFocus(false); }, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }))));
|
|
85
87
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { TrackDisplayMode } from './Slider';
|
|
2
|
+
import { SliderProps, TrackDisplayMode } from './Slider';
|
|
3
3
|
export declare type TrackProps = {
|
|
4
4
|
trackDisplayMode: TrackDisplayMode;
|
|
5
5
|
sliderMin: number;
|
|
6
6
|
sliderMax: number;
|
|
7
7
|
values: number[];
|
|
8
|
+
orientation: SliderProps['orientation'];
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* Track displays color segments above Rail. Which, if any, segments that are
|
package/esm/core/Slider/Track.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
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
|
+
};
|
|
1
12
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
13
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
14
|
if (ar || !(i in from)) {
|
|
@@ -44,7 +55,7 @@ function generateSegments(values, min, max) {
|
|
|
44
55
|
* colorized is based on `trackDisplayMode`.
|
|
45
56
|
*/
|
|
46
57
|
export var Track = function (props) {
|
|
47
|
-
var trackDisplayMode = props.trackDisplayMode, sliderMin = props.sliderMin, sliderMax = props.sliderMax, values = props.values;
|
|
58
|
+
var trackDisplayMode = props.trackDisplayMode, sliderMin = props.sliderMin, sliderMax = props.sliderMax, values = props.values, orientation = props.orientation;
|
|
48
59
|
var _a = React.useState(function () {
|
|
49
60
|
return generateSegments(values, sliderMin, sliderMax);
|
|
50
61
|
}), segments = _a[0], setSegments = _a[1];
|
|
@@ -53,13 +64,21 @@ export var Track = function (props) {
|
|
|
53
64
|
}, [values, sliderMin, sliderMax]);
|
|
54
65
|
return (React.createElement(React.Fragment, null, 'none' !== trackDisplayMode &&
|
|
55
66
|
segments.map(function (segment, index) {
|
|
56
|
-
var
|
|
67
|
+
var lowPercent = segment.left >= sliderMin && sliderMax !== sliderMin
|
|
57
68
|
? (100.0 * (segment.left - sliderMin)) / (sliderMax - sliderMin)
|
|
58
69
|
: 0;
|
|
59
|
-
var
|
|
70
|
+
var highPercent = segment.right >= sliderMin && sliderMax !== sliderMin
|
|
60
71
|
? 100.0 -
|
|
61
72
|
(100.0 * (segment.right - sliderMin)) / (sliderMax - sliderMin)
|
|
62
73
|
: 100;
|
|
63
|
-
return (React.createElement(React.Fragment, { key: index }, shouldDisplaySegment(index, trackDisplayMode) ? (React.createElement("div", { className: 'iui-slider-track', style: {
|
|
74
|
+
return (React.createElement(React.Fragment, { key: index }, shouldDisplaySegment(index, trackDisplayMode) ? (React.createElement("div", { className: 'iui-slider-track', style: __assign({}, (orientation === 'horizontal'
|
|
75
|
+
? {
|
|
76
|
+
left: "".concat(lowPercent, "%"),
|
|
77
|
+
right: "".concat(highPercent, "%"),
|
|
78
|
+
}
|
|
79
|
+
: {
|
|
80
|
+
top: "".concat(highPercent, "%"),
|
|
81
|
+
bottom: "".concat(lowPercent, "%"),
|
|
82
|
+
})) })) : null));
|
|
64
83
|
})));
|
|
65
84
|
};
|
|
@@ -182,6 +182,30 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
|
|
|
182
182
|
* @default false
|
|
183
183
|
*/
|
|
184
184
|
enableColumnReordering?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Function that returns index of the row that you want to scroll to.
|
|
187
|
+
*
|
|
188
|
+
* When using with lazy-loading table, you need to take care that row is already loaded.
|
|
189
|
+
* It doesn't work with paginated tables.
|
|
190
|
+
* @beta
|
|
191
|
+
* @example
|
|
192
|
+
* <Table
|
|
193
|
+
* scrollToRow={React.useCallback(
|
|
194
|
+
* (rows, data) => rows.findIndex((row) => row.original === data[250]),
|
|
195
|
+
* []
|
|
196
|
+
* )}
|
|
197
|
+
* {...restProps}
|
|
198
|
+
* />
|
|
199
|
+
* @example
|
|
200
|
+
* <Table
|
|
201
|
+
* scrollToRow={React.useCallback(
|
|
202
|
+
* (rows, data) => rows.findIndex((row) => row.original.id === data[250].id),
|
|
203
|
+
* []
|
|
204
|
+
* )}
|
|
205
|
+
* {...restProps}
|
|
206
|
+
* />
|
|
207
|
+
*/
|
|
208
|
+
scrollToRow?: (rows: Row<T>[], data: T[]) => number;
|
|
185
209
|
} & Omit<CommonProps, 'title'>;
|
|
186
210
|
/**
|
|
187
211
|
* Table based on [react-table](https://react-table.tanstack.com/docs/api/overview).
|
package/esm/core/Table/Table.js
CHANGED
|
@@ -36,7 +36,7 @@ import { getCellStyle, getStickyStyle } from './utils';
|
|
|
36
36
|
import { TableRowMemoized } from './TableRowMemoized';
|
|
37
37
|
import { FilterToggle } from './filters';
|
|
38
38
|
import { customFilterFunctions } from './filters/customFilterFunctions';
|
|
39
|
-
import { useExpanderCell, useSelectionCell, useSubRowFiltering, useSubRowSelection, useResizeColumns, useColumnDragAndDrop, useStickyColumns, } from './hooks';
|
|
39
|
+
import { useExpanderCell, useSelectionCell, useSubRowFiltering, useSubRowSelection, useResizeColumns, useColumnDragAndDrop, useScrollToRow, useStickyColumns, } from './hooks';
|
|
40
40
|
import { onExpandHandler, onFilterHandler, onSelectHandler, onSingleSelectHandler, onTableResizeEnd, onTableResizeStart, } from './actionHandlers';
|
|
41
41
|
import VirtualScroll from '../utils/components/VirtualScroll';
|
|
42
42
|
import { SELECTION_CELL_ID } from './columns';
|
|
@@ -234,6 +234,7 @@ export var Table = function (props) {
|
|
|
234
234
|
state.pageIndex,
|
|
235
235
|
state.pageSize,
|
|
236
236
|
]);
|
|
237
|
+
var _r = useScrollToRow(__assign(__assign({}, props), { page: page })), scrollToIndex = _r.scrollToIndex, tableRowRef = _r.tableRowRef;
|
|
237
238
|
var columnRefs = React.useRef({});
|
|
238
239
|
var previousTableWidth = React.useRef(0);
|
|
239
240
|
var onTableResize = React.useCallback(function (_a) {
|
|
@@ -270,11 +271,11 @@ export var Table = function (props) {
|
|
|
270
271
|
var headerRef = React.useRef(null);
|
|
271
272
|
var bodyRef = React.useRef(null);
|
|
272
273
|
// Using `useState` to rerender rows when table body ref is available
|
|
273
|
-
var
|
|
274
|
+
var _s = React.useState(null), bodyRefState = _s[0], setBodyRefState = _s[1];
|
|
274
275
|
var getPreparedRow = React.useCallback(function (index) {
|
|
275
276
|
var row = page[index];
|
|
276
277
|
prepareRow(row);
|
|
277
|
-
return (React.createElement(TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!(isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRefState }));
|
|
278
|
+
return (React.createElement(TableRowMemoized, { row: row, rowProps: rowProps, isLast: index === page.length - 1, onRowInViewport: onRowInViewportRef, onBottomReached: onBottomReachedRef, intersectionMargin: intersectionMargin, state: state, key: row.getRowProps().key, onClick: onRowClickHandler, subComponent: subComponent, isDisabled: !!(isRowDisabled === null || isRowDisabled === void 0 ? void 0 : isRowDisabled(row.original)), tableHasSubRows: hasAnySubRows, tableInstance: instance, expanderCell: expanderCell, bodyRef: bodyRefState, tableRowRef: enableVirtualization ? undefined : tableRowRef(row) }));
|
|
278
279
|
}, [
|
|
279
280
|
page,
|
|
280
281
|
prepareRow,
|
|
@@ -288,6 +289,8 @@ export var Table = function (props) {
|
|
|
288
289
|
instance,
|
|
289
290
|
expanderCell,
|
|
290
291
|
bodyRefState,
|
|
292
|
+
enableVirtualization,
|
|
293
|
+
tableRowRef,
|
|
291
294
|
]);
|
|
292
295
|
var virtualizedItemRenderer = React.useCallback(function (index) { return getPreparedRow(index); }, [getPreparedRow]);
|
|
293
296
|
var updateStickyState = function () {
|
|
@@ -324,7 +327,12 @@ export var Table = function (props) {
|
|
|
324
327
|
className: cx('iui-table', (_a = {}, _a["iui-".concat(density)] = density !== 'default', _a), className),
|
|
325
328
|
style: __assign({ minWidth: 0 }, style),
|
|
326
329
|
}), ariaDataAttributes),
|
|
327
|
-
React.createElement("div", { className: 'iui-table-header-wrapper', ref: headerRef
|
|
330
|
+
React.createElement("div", { className: 'iui-table-header-wrapper', ref: headerRef, onScroll: function () {
|
|
331
|
+
if (headerRef.current && bodyRef.current) {
|
|
332
|
+
bodyRef.current.scrollLeft = headerRef.current.scrollLeft;
|
|
333
|
+
updateStickyState();
|
|
334
|
+
}
|
|
335
|
+
} },
|
|
328
336
|
React.createElement("div", { className: 'iui-table-header' }, headerGroups.slice(1).map(function (headerGroup) {
|
|
329
337
|
var headerGroupProps = headerGroup.getHeaderGroupProps({
|
|
330
338
|
className: 'iui-row',
|
|
@@ -369,7 +377,7 @@ export var Table = function (props) {
|
|
|
369
377
|
updateStickyState();
|
|
370
378
|
}
|
|
371
379
|
}, tabIndex: -1 }),
|
|
372
|
-
data.length !== 0 && (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualScroll, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer })) : (page.map(function (_, index) { return getPreparedRow(index); })))),
|
|
380
|
+
data.length !== 0 && (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualScroll, { itemsLength: page.length, itemRenderer: virtualizedItemRenderer, scrollToIndex: scrollToIndex })) : (page.map(function (_, index) { return getPreparedRow(index); })))),
|
|
373
381
|
isLoading && data.length === 0 && (React.createElement("div", { className: 'iui-table-empty' },
|
|
374
382
|
React.createElement(ProgressRadial, { indeterminate: true }))),
|
|
375
383
|
isLoading && data.length !== 0 && (React.createElement("div", { className: 'iui-row' },
|
|
@@ -21,6 +21,7 @@ export declare const TableRow: <T extends Record<string, unknown>>(props: {
|
|
|
21
21
|
tableInstance: TableInstance<T>;
|
|
22
22
|
expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
|
|
23
23
|
bodyRef: HTMLDivElement | null;
|
|
24
|
+
tableRowRef?: React.Ref<HTMLDivElement> | undefined;
|
|
24
25
|
}) => JSX.Element;
|
|
25
26
|
export declare const TableRowMemoized: <T extends Record<string, unknown>>(props: {
|
|
26
27
|
row: Row<T>;
|
|
@@ -37,4 +38,5 @@ export declare const TableRowMemoized: <T extends Record<string, unknown>>(props
|
|
|
37
38
|
tableInstance: TableInstance<T>;
|
|
38
39
|
expanderCell?: ((cellProps: CellProps<T, any>) => React.ReactNode) | undefined;
|
|
39
40
|
bodyRef: HTMLDivElement | null;
|
|
41
|
+
tableRowRef?: React.Ref<HTMLDivElement> | undefined;
|
|
40
42
|
}) => JSX.Element;
|