@itwin/itwinui-react 1.42.0 → 1.43.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cjs/core/Backdrop/Backdrop.d.ts +10 -0
  3. package/cjs/core/Backdrop/Backdrop.js +41 -0
  4. package/cjs/core/Backdrop/index.d.ts +2 -0
  5. package/cjs/core/Backdrop/index.js +9 -0
  6. package/cjs/core/Breadcrumbs/Breadcrumbs.js +18 -18
  7. package/cjs/core/ButtonGroup/ButtonGroup.js +11 -4
  8. package/cjs/core/Dialog/Dialog.d.ts +41 -0
  9. package/cjs/core/Dialog/Dialog.js +59 -0
  10. package/cjs/core/Dialog/DialogBackdrop.d.ts +12 -0
  11. package/cjs/core/Dialog/DialogBackdrop.js +61 -0
  12. package/cjs/core/Dialog/DialogButtonBar.d.ts +18 -0
  13. package/cjs/core/Dialog/DialogButtonBar.js +50 -0
  14. package/cjs/core/Dialog/DialogContent.d.ts +17 -0
  15. package/cjs/core/Dialog/DialogContent.js +49 -0
  16. package/cjs/core/Dialog/DialogContext.d.ts +39 -0
  17. package/cjs/core/Dialog/DialogContext.js +16 -0
  18. package/cjs/core/Dialog/DialogMain.d.ts +36 -0
  19. package/cjs/core/Dialog/DialogMain.js +120 -0
  20. package/cjs/core/Dialog/DialogTitleBar.d.ts +34 -0
  21. package/cjs/core/Dialog/DialogTitleBar.js +69 -0
  22. package/cjs/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
  23. package/cjs/core/Dialog/DialogTitleBarTitle.js +47 -0
  24. package/cjs/core/Dialog/index.d.ts +8 -0
  25. package/cjs/core/Dialog/index.js +10 -0
  26. package/cjs/core/Footer/Footer.d.ts +16 -2
  27. package/cjs/core/Footer/Footer.js +57 -45
  28. package/cjs/core/Footer/FooterItem.d.ts +8 -0
  29. package/cjs/core/Footer/FooterItem.js +46 -0
  30. package/cjs/core/Footer/FooterList.d.ts +8 -0
  31. package/cjs/core/Footer/FooterList.js +46 -0
  32. package/cjs/core/Footer/FooterSeparator.d.ts +8 -0
  33. package/cjs/core/Footer/FooterSeparator.js +46 -0
  34. package/cjs/core/Footer/index.d.ts +1 -1
  35. package/cjs/core/Footer/index.js +2 -1
  36. package/cjs/core/Modal/Modal.d.ts +4 -14
  37. package/cjs/core/Modal/Modal.js +9 -74
  38. package/cjs/core/Modal/ModalButtonBar.d.ts +1 -2
  39. package/cjs/core/Modal/ModalButtonBar.js +2 -39
  40. package/cjs/core/Modal/ModalContent.d.ts +1 -2
  41. package/cjs/core/Modal/ModalContent.js +2 -39
  42. package/cjs/core/Slider/Slider.d.ts +10 -0
  43. package/cjs/core/Slider/Slider.js +20 -14
  44. package/cjs/core/Slider/Thumb.d.ts +2 -1
  45. package/cjs/core/Slider/Thumb.js +5 -3
  46. package/cjs/core/Slider/Track.d.ts +2 -1
  47. package/cjs/core/Slider/Track.js +23 -4
  48. package/cjs/core/Table/Table.d.ts +2 -1
  49. package/cjs/core/Table/Table.js +6 -1
  50. package/cjs/core/Table/columns/actionColumn.d.ts +8 -3
  51. package/cjs/core/Table/columns/actionColumn.js +33 -2
  52. package/cjs/core/Table/hooks/useScrollToRow.d.ts +1 -1
  53. package/cjs/core/Table/hooks/useScrollToRow.js +3 -3
  54. package/cjs/core/index.d.ts +3 -1
  55. package/cjs/core/index.js +6 -3
  56. package/cjs/core/utils/components/FocusTrap.js +1 -1
  57. package/cjs/core/utils/components/MiddleTextTruncation.js +1 -1
  58. package/esm/core/Backdrop/Backdrop.d.ts +10 -0
  59. package/esm/core/Backdrop/Backdrop.js +35 -0
  60. package/esm/core/Backdrop/index.d.ts +2 -0
  61. package/esm/core/Backdrop/index.js +5 -0
  62. package/esm/core/Breadcrumbs/Breadcrumbs.js +18 -18
  63. package/esm/core/ButtonGroup/ButtonGroup.js +11 -4
  64. package/esm/core/Dialog/Dialog.d.ts +41 -0
  65. package/esm/core/Dialog/Dialog.js +53 -0
  66. package/esm/core/Dialog/DialogBackdrop.d.ts +12 -0
  67. package/esm/core/Dialog/DialogBackdrop.js +55 -0
  68. package/esm/core/Dialog/DialogButtonBar.d.ts +18 -0
  69. package/esm/core/Dialog/DialogButtonBar.js +44 -0
  70. package/esm/core/Dialog/DialogContent.d.ts +17 -0
  71. package/esm/core/Dialog/DialogContent.js +43 -0
  72. package/esm/core/Dialog/DialogContext.d.ts +39 -0
  73. package/esm/core/Dialog/DialogContext.js +9 -0
  74. package/esm/core/Dialog/DialogMain.d.ts +36 -0
  75. package/esm/core/Dialog/DialogMain.js +114 -0
  76. package/esm/core/Dialog/DialogTitleBar.d.ts +34 -0
  77. package/esm/core/Dialog/DialogTitleBar.js +63 -0
  78. package/esm/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
  79. package/esm/core/Dialog/DialogTitleBarTitle.js +41 -0
  80. package/esm/core/Dialog/index.d.ts +8 -0
  81. package/esm/core/Dialog/index.js +6 -0
  82. package/esm/core/Footer/Footer.d.ts +16 -2
  83. package/esm/core/Footer/Footer.js +56 -43
  84. package/esm/core/Footer/FooterItem.d.ts +8 -0
  85. package/esm/core/Footer/FooterItem.js +39 -0
  86. package/esm/core/Footer/FooterList.d.ts +8 -0
  87. package/esm/core/Footer/FooterList.js +39 -0
  88. package/esm/core/Footer/FooterSeparator.d.ts +8 -0
  89. package/esm/core/Footer/FooterSeparator.js +39 -0
  90. package/esm/core/Footer/index.d.ts +1 -1
  91. package/esm/core/Footer/index.js +1 -1
  92. package/esm/core/Modal/Modal.d.ts +4 -14
  93. package/esm/core/Modal/Modal.js +10 -75
  94. package/esm/core/Modal/ModalButtonBar.d.ts +1 -2
  95. package/esm/core/Modal/ModalButtonBar.js +2 -35
  96. package/esm/core/Modal/ModalContent.d.ts +1 -2
  97. package/esm/core/Modal/ModalContent.js +2 -35
  98. package/esm/core/Slider/Slider.d.ts +10 -0
  99. package/esm/core/Slider/Slider.js +20 -14
  100. package/esm/core/Slider/Thumb.d.ts +2 -1
  101. package/esm/core/Slider/Thumb.js +5 -3
  102. package/esm/core/Slider/Track.d.ts +2 -1
  103. package/esm/core/Slider/Track.js +23 -4
  104. package/esm/core/Table/Table.d.ts +2 -1
  105. package/esm/core/Table/Table.js +6 -1
  106. package/esm/core/Table/columns/actionColumn.d.ts +8 -3
  107. package/esm/core/Table/columns/actionColumn.js +33 -2
  108. package/esm/core/Table/hooks/useScrollToRow.d.ts +1 -1
  109. package/esm/core/Table/hooks/useScrollToRow.js +3 -3
  110. package/esm/core/index.d.ts +3 -1
  111. package/esm/core/index.js +2 -1
  112. package/esm/core/utils/components/FocusTrap.js +1 -1
  113. package/esm/core/utils/components/MiddleTextTruncation.js +1 -1
  114. package/package.json +6 -5
@@ -0,0 +1,39 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ import React from 'react';
28
+ import { useTheme } from '../utils';
29
+ import cx from 'classnames';
30
+ import '@itwin/itwinui-css/css/footer.css';
31
+ /**
32
+ * Footer separator. Recommended to use inside `Footer.List`.
33
+ */
34
+ export var FooterSeparator = function (props) {
35
+ var className = props.className, rest = __rest(props, ["className"]);
36
+ useTheme();
37
+ return (React.createElement("li", __assign({ className: cx('iui-legal-footer-separator', className), "aria-hidden": true }, rest)));
38
+ };
39
+ export default FooterSeparator;
@@ -1,4 +1,4 @@
1
- export { Footer } from './Footer';
1
+ export { Footer, defaultFooterElements } from './Footer';
2
2
  export type { FooterElement, FooterProps, TitleTranslations } from './Footer';
3
3
  declare const _default: "./Footer";
4
4
  export default _default;
@@ -2,5 +2,5 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- export { Footer } from './Footer';
5
+ export { Footer, defaultFooterElements } from './Footer';
6
6
  export default './Footer';
@@ -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 '@itwin/itwinui-css/css/backdrop.css';
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
- * <div>
57
+ * <ModalContent>
68
58
  * Here is my modal content
69
- * </div>
59
+ * </ModalContent>
70
60
  * <ModalButtonBar>
71
61
  * <Button styleType='high-visibility'>
72
62
  * Primary button
@@ -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 cx from 'classnames';
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 '@itwin/itwinui-css/css/backdrop.css';
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
- * <div>
40
+ * <ModalContent>
45
41
  * Here is my modal content
46
- * </div>
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, onKeyDown = props.onKeyDown, id = props.id, className = props.className, style = props.style, children = props.children, _e = props.styleType, styleType = _e === void 0 ? 'default' : _e, _f = props.modalRootId, modalRootId = _f === void 0 ? 'iui-react-portal-container' : _f, _g = props.ownerDocument, ownerDocument = _g === void 0 ? getDocument() : _g, rest = __rest(props, ["isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "title", "onKeyDown", "id", "className", "style", "children", "styleType", "modalRootId", "ownerDocument"]);
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
- var overlayRef = React.useRef(null);
62
- var originalBodyOverflow = React.useRef('');
63
- var previousFocusedElement = React.useRef();
64
- // Give focus to overlay for key handling to work.
65
- React.useLayoutEffect(function () {
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: (props: ModalButtonBarProps) => JSX.Element;
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
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- /*---------------------------------------------------------------------------------------------
24
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
- * See LICENSE.md in the project root for license terms and full copyright notice.
26
- *--------------------------------------------------------------------------------------------*/
27
- import React from 'react';
28
- import cx from 'classnames';
29
- import { useTheme } from '../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 = function (props) {
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: (props: ModalContentProps) => JSX.Element;
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
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- /*---------------------------------------------------------------------------------------------
24
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
- * See LICENSE.md in the project root for license terms and full copyright notice.
26
- *--------------------------------------------------------------------------------------------*/
27
- import React from 'react';
28
- import cx from 'classnames';
29
- import { useTheme } from '../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 = function (props) {
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, pointer) {
43
- var position = getBoundedValue(pointer, rect.left, rect.right);
44
- return (position - rect.left) / rect.width;
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 _k = React.useState(values), currentValues = _k[0], setCurrentValues = _k[1];
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 _l = React.useState(function () { return minLabel !== null && minLabel !== void 0 ? minLabel : min.toString(); }), minValueLabel = _l[0], setMinValueLabel = _l[1];
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 _m = React.useState(function () { return maxLabel !== null && maxLabel !== void 0 ? maxLabel : max.toString(); }), maxValueLabel = _m[0], setMaxValueLabel = _m[1];
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 _o = React.useState(function () { return getDefaultTrackDisplay(trackDisplayMode, currentValues); }), trackDisplay = _o[0], setTrackDisplay = _o[1];
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 _p = React.useState(undefined), activeThumbIndex = _p[0], setActiveThumbIndex = _p[1];
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
@@ -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 leftPercent = React.useMemo(function () {
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), { left: "".concat(leftPercent, "%") }), 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); } }))));
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
@@ -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 leftPercent = segment.left >= sliderMin && sliderMax !== sliderMin
67
+ var lowPercent = segment.left >= sliderMin && sliderMax !== sliderMin
57
68
  ? (100.0 * (segment.left - sliderMin)) / (sliderMax - sliderMin)
58
69
  : 0;
59
- var rightPercent = segment.right >= sliderMin && sliderMax !== sliderMin
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: { left: "".concat(leftPercent, "%"), right: "".concat(rightPercent, "%") } })) : null));
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
  };
@@ -185,7 +185,8 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
185
185
  /**
186
186
  * Function that returns index of the row that you want to scroll to.
187
187
  *
188
- * It doesn't work with paginated tables and with lazy-loading.
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.
189
190
  * @beta
190
191
  * @example
191
192
  * <Table
@@ -327,7 +327,12 @@ export var Table = function (props) {
327
327
  className: cx('iui-table', (_a = {}, _a["iui-".concat(density)] = density !== 'default', _a), className),
328
328
  style: __assign({ minWidth: 0 }, style),
329
329
  }), ariaDataAttributes),
330
- 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
+ } },
331
336
  React.createElement("div", { className: 'iui-table-header' }, headerGroups.slice(1).map(function (headerGroup) {
332
337
  var headerGroupProps = headerGroup.getHeaderGroupProps({
333
338
  className: 'iui-row',
@@ -1,5 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { HeaderProps } from 'react-table';
3
+ import { DropdownMenuProps } from '../../DropdownMenu';
4
+ declare type ActionColumnProps = {
5
+ columnManager?: boolean | {
6
+ dropdownMenuProps: Omit<DropdownMenuProps, 'menuItems' | 'children'>;
7
+ };
8
+ };
3
9
  /**
4
10
  * Action column that adds column manager to the Table header.
5
11
  * It is recommended to add this column to the end of the Table
@@ -19,9 +25,7 @@ import { HeaderProps } from 'react-table';
19
25
  * ),
20
26
  * },
21
27
  */
22
- export declare const ActionColumn: <T extends Record<string, unknown>>({ columnManager, }?: {
23
- columnManager?: boolean | undefined;
24
- }) => {
28
+ export declare const ActionColumn: <T extends Record<string, unknown>>({ columnManager, }?: ActionColumnProps) => {
25
29
  id: string;
26
30
  disableResizing: boolean;
27
31
  disableGroupBy: boolean;
@@ -33,3 +37,4 @@ export declare const ActionColumn: <T extends Record<string, unknown>>({ columnM
33
37
  disableReordering: boolean;
34
38
  Header: ({ allColumns, dispatch, state }: HeaderProps<T>) => JSX.Element | null;
35
39
  };
40
+ export {};