@itwin/itwinui-react 1.40.1 → 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 (148) hide show
  1. package/CHANGELOG.md +42 -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/ComboBox/ComboBox.js +22 -18
  9. package/cjs/core/Dialog/Dialog.d.ts +41 -0
  10. package/cjs/core/Dialog/Dialog.js +59 -0
  11. package/cjs/core/Dialog/DialogBackdrop.d.ts +12 -0
  12. package/cjs/core/Dialog/DialogBackdrop.js +61 -0
  13. package/cjs/core/Dialog/DialogButtonBar.d.ts +18 -0
  14. package/cjs/core/Dialog/DialogButtonBar.js +50 -0
  15. package/cjs/core/Dialog/DialogContent.d.ts +17 -0
  16. package/cjs/core/Dialog/DialogContent.js +49 -0
  17. package/cjs/core/Dialog/DialogContext.d.ts +39 -0
  18. package/cjs/core/Dialog/DialogContext.js +16 -0
  19. package/cjs/core/Dialog/DialogMain.d.ts +36 -0
  20. package/cjs/core/Dialog/DialogMain.js +120 -0
  21. package/cjs/core/Dialog/DialogTitleBar.d.ts +34 -0
  22. package/cjs/core/Dialog/DialogTitleBar.js +69 -0
  23. package/cjs/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
  24. package/cjs/core/Dialog/DialogTitleBarTitle.js +47 -0
  25. package/cjs/core/Dialog/index.d.ts +8 -0
  26. package/cjs/core/Dialog/index.js +10 -0
  27. package/cjs/core/ErrorPage/ErrorPage.d.ts +3 -1
  28. package/cjs/core/ErrorPage/ErrorPage.js +31 -1
  29. package/cjs/core/Footer/Footer.d.ts +16 -2
  30. package/cjs/core/Footer/Footer.js +57 -45
  31. package/cjs/core/Footer/FooterItem.d.ts +8 -0
  32. package/cjs/core/Footer/FooterItem.js +46 -0
  33. package/cjs/core/Footer/FooterList.d.ts +8 -0
  34. package/cjs/core/Footer/FooterList.js +46 -0
  35. package/cjs/core/Footer/FooterSeparator.d.ts +8 -0
  36. package/cjs/core/Footer/FooterSeparator.js +46 -0
  37. package/cjs/core/Footer/index.d.ts +1 -1
  38. package/cjs/core/Footer/index.js +2 -1
  39. package/cjs/core/Modal/Modal.d.ts +4 -13
  40. package/cjs/core/Modal/Modal.js +9 -71
  41. package/cjs/core/Modal/ModalButtonBar.d.ts +1 -2
  42. package/cjs/core/Modal/ModalButtonBar.js +2 -39
  43. package/cjs/core/Modal/ModalContent.d.ts +1 -2
  44. package/cjs/core/Modal/ModalContent.js +2 -39
  45. package/cjs/core/Slider/Slider.d.ts +10 -0
  46. package/cjs/core/Slider/Slider.js +20 -14
  47. package/cjs/core/Slider/Thumb.d.ts +2 -1
  48. package/cjs/core/Slider/Thumb.js +5 -3
  49. package/cjs/core/Slider/Track.d.ts +2 -1
  50. package/cjs/core/Slider/Track.js +23 -4
  51. package/cjs/core/Table/Table.d.ts +24 -0
  52. package/cjs/core/Table/Table.js +21 -10
  53. package/cjs/core/Table/TableRowMemoized.d.ts +4 -0
  54. package/cjs/core/Table/TableRowMemoized.js +15 -3
  55. package/cjs/core/Table/cells/EditableCell.js +7 -2
  56. package/cjs/core/Table/columns/actionColumn.d.ts +8 -3
  57. package/cjs/core/Table/columns/actionColumn.js +33 -2
  58. package/cjs/core/Table/hooks/index.d.ts +1 -0
  59. package/cjs/core/Table/hooks/index.js +3 -1
  60. package/cjs/core/Table/hooks/useScrollToRow.d.ts +11 -0
  61. package/cjs/core/Table/hooks/useScrollToRow.js +49 -0
  62. package/cjs/core/Tree/Tree.d.ts +9 -0
  63. package/cjs/core/Tree/Tree.js +67 -19
  64. package/cjs/core/Tree/TreeContext.d.ts +4 -0
  65. package/cjs/core/Tree/TreeNode.js +8 -9
  66. package/cjs/core/Typography/Small/Small.js +1 -1
  67. package/cjs/core/index.d.ts +3 -1
  68. package/cjs/core/index.js +6 -3
  69. package/cjs/core/utils/components/FocusTrap.js +1 -1
  70. package/cjs/core/utils/components/MiddleTextTruncation.js +1 -1
  71. package/cjs/core/utils/hooks/index.d.ts +1 -0
  72. package/cjs/core/utils/hooks/index.js +1 -0
  73. package/cjs/core/utils/hooks/useLatestRef.d.ts +9 -0
  74. package/cjs/core/utils/hooks/useLatestRef.js +26 -0
  75. package/esm/core/Backdrop/Backdrop.d.ts +10 -0
  76. package/esm/core/Backdrop/Backdrop.js +35 -0
  77. package/esm/core/Backdrop/index.d.ts +2 -0
  78. package/esm/core/Backdrop/index.js +5 -0
  79. package/esm/core/Breadcrumbs/Breadcrumbs.js +18 -18
  80. package/esm/core/ButtonGroup/ButtonGroup.js +11 -4
  81. package/esm/core/ComboBox/ComboBox.js +23 -19
  82. package/esm/core/Dialog/Dialog.d.ts +41 -0
  83. package/esm/core/Dialog/Dialog.js +53 -0
  84. package/esm/core/Dialog/DialogBackdrop.d.ts +12 -0
  85. package/esm/core/Dialog/DialogBackdrop.js +55 -0
  86. package/esm/core/Dialog/DialogButtonBar.d.ts +18 -0
  87. package/esm/core/Dialog/DialogButtonBar.js +44 -0
  88. package/esm/core/Dialog/DialogContent.d.ts +17 -0
  89. package/esm/core/Dialog/DialogContent.js +43 -0
  90. package/esm/core/Dialog/DialogContext.d.ts +39 -0
  91. package/esm/core/Dialog/DialogContext.js +9 -0
  92. package/esm/core/Dialog/DialogMain.d.ts +36 -0
  93. package/esm/core/Dialog/DialogMain.js +114 -0
  94. package/esm/core/Dialog/DialogTitleBar.d.ts +34 -0
  95. package/esm/core/Dialog/DialogTitleBar.js +63 -0
  96. package/esm/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
  97. package/esm/core/Dialog/DialogTitleBarTitle.js +41 -0
  98. package/esm/core/Dialog/index.d.ts +8 -0
  99. package/esm/core/Dialog/index.js +6 -0
  100. package/esm/core/ErrorPage/ErrorPage.d.ts +3 -1
  101. package/esm/core/ErrorPage/ErrorPage.js +31 -1
  102. package/esm/core/Footer/Footer.d.ts +16 -2
  103. package/esm/core/Footer/Footer.js +56 -43
  104. package/esm/core/Footer/FooterItem.d.ts +8 -0
  105. package/esm/core/Footer/FooterItem.js +39 -0
  106. package/esm/core/Footer/FooterList.d.ts +8 -0
  107. package/esm/core/Footer/FooterList.js +39 -0
  108. package/esm/core/Footer/FooterSeparator.d.ts +8 -0
  109. package/esm/core/Footer/FooterSeparator.js +39 -0
  110. package/esm/core/Footer/index.d.ts +1 -1
  111. package/esm/core/Footer/index.js +1 -1
  112. package/esm/core/Modal/Modal.d.ts +4 -13
  113. package/esm/core/Modal/Modal.js +10 -72
  114. package/esm/core/Modal/ModalButtonBar.d.ts +1 -2
  115. package/esm/core/Modal/ModalButtonBar.js +2 -35
  116. package/esm/core/Modal/ModalContent.d.ts +1 -2
  117. package/esm/core/Modal/ModalContent.js +2 -35
  118. package/esm/core/Slider/Slider.d.ts +10 -0
  119. package/esm/core/Slider/Slider.js +20 -14
  120. package/esm/core/Slider/Thumb.d.ts +2 -1
  121. package/esm/core/Slider/Thumb.js +5 -3
  122. package/esm/core/Slider/Track.d.ts +2 -1
  123. package/esm/core/Slider/Track.js +23 -4
  124. package/esm/core/Table/Table.d.ts +24 -0
  125. package/esm/core/Table/Table.js +23 -12
  126. package/esm/core/Table/TableRowMemoized.d.ts +4 -0
  127. package/esm/core/Table/TableRowMemoized.js +15 -3
  128. package/esm/core/Table/cells/EditableCell.js +7 -2
  129. package/esm/core/Table/columns/actionColumn.d.ts +8 -3
  130. package/esm/core/Table/columns/actionColumn.js +33 -2
  131. package/esm/core/Table/hooks/index.d.ts +1 -0
  132. package/esm/core/Table/hooks/index.js +1 -0
  133. package/esm/core/Table/hooks/useScrollToRow.d.ts +11 -0
  134. package/esm/core/Table/hooks/useScrollToRow.js +42 -0
  135. package/esm/core/Tree/Tree.d.ts +9 -0
  136. package/esm/core/Tree/Tree.js +68 -20
  137. package/esm/core/Tree/TreeContext.d.ts +4 -0
  138. package/esm/core/Tree/TreeNode.js +8 -9
  139. package/esm/core/Typography/Small/Small.js +1 -1
  140. package/esm/core/index.d.ts +3 -1
  141. package/esm/core/index.js +2 -1
  142. package/esm/core/utils/components/FocusTrap.js +1 -1
  143. package/esm/core/utils/components/MiddleTextTruncation.js +1 -1
  144. package/esm/core/utils/hooks/index.d.ts +1 -0
  145. package/esm/core/utils/hooks/index.js +1 -0
  146. package/esm/core/utils/hooks/useLatestRef.d.ts +9 -0
  147. package/esm/core/utils/hooks/useLatestRef.js +19 -0
  148. package/package.json +8 -7
@@ -0,0 +1,53 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import React from 'react';
6
+ import '@itwin/itwinui-css/css/dialog.css';
7
+ import { DialogTitleBar } from './DialogTitleBar';
8
+ import { DialogContent } from './DialogContent';
9
+ import { DialogBackdrop } from './DialogBackdrop';
10
+ import { DialogContext } from './DialogContext';
11
+ import { DialogButtonBar } from './DialogButtonBar';
12
+ import DialogMain from './DialogMain';
13
+ /**
14
+ * Dialog component.
15
+ * @example
16
+ * <Dialog
17
+ * isOpen={isOpen}
18
+ * onClose={() => setIsOpen(false)}
19
+ * trapFocus
20
+ * preventDocumentScroll
21
+ * >
22
+ * <Dialog.Backdrop />
23
+ * <Dialog.Main aria-modal>
24
+ * <Dialog.TitleBar>My dialog title</Dialog.TitleBar>
25
+ * <Dialog.Content>
26
+ * Here is my dialog content
27
+ * </Dialog.Content>
28
+ * <Dialog.ButtonBar>
29
+ * <Button styleType='high-visibility'>Confirm</Button>
30
+ * <Button>Close</Button>
31
+ * </Dialog.ButtonBar>
32
+ * </Dialog.Main>
33
+ * </Dialog>
34
+ */
35
+ export var Dialog = Object.assign(function (props) {
36
+ var children = props.children, _a = props.trapFocus, trapFocus = _a === void 0 ? false : _a, _b = props.preventDocumentScroll, preventDocumentScroll = _b === void 0 ? false : _b, _c = props.isOpen, isOpen = _c === void 0 ? false : _c, _d = props.isDismissible, isDismissible = _d === void 0 ? true : _d, _e = props.closeOnEsc, closeOnEsc = _e === void 0 ? true : _e, _f = props.closeOnExternalClick, closeOnExternalClick = _f === void 0 ? false : _f, onClose = props.onClose;
37
+ return (React.createElement(DialogContext.Provider, { value: {
38
+ isOpen: isOpen,
39
+ onClose: onClose,
40
+ closeOnEsc: closeOnEsc,
41
+ closeOnExternalClick: closeOnExternalClick,
42
+ isDismissible: isDismissible,
43
+ preventDocumentScroll: preventDocumentScroll,
44
+ trapFocus: trapFocus,
45
+ } }, children));
46
+ }, {
47
+ Backdrop: DialogBackdrop,
48
+ Main: DialogMain,
49
+ TitleBar: DialogTitleBar,
50
+ Content: DialogContent,
51
+ ButtonBar: DialogButtonBar,
52
+ });
53
+ export default Dialog;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { BackdropProps } from '../Backdrop';
3
+ import { DialogContextProps } from './DialogContext';
4
+ export declare type DialogBackdropProps = BackdropProps & Pick<DialogContextProps, 'onClose' | 'isDismissible' | 'closeOnExternalClick'>;
5
+ /**
6
+ * Backdrop component for dialog. Recommended to be used with `Dialog`
7
+ * then its visibility is being controlled by dialog's `isOpen` prop.
8
+ * @example
9
+ * <Dialog.Backdrop />
10
+ */
11
+ export declare const DialogBackdrop: React.ForwardRefExoticComponent<Pick<DialogBackdropProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible" | "isDismissible" | "closeOnExternalClick"> & React.RefAttributes<HTMLDivElement>>;
12
+ export default DialogBackdrop;
@@ -0,0 +1,55 @@
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 { Backdrop } from '../Backdrop';
29
+ import { useMergedRefs } from '../utils';
30
+ import { useDialogContext } from './DialogContext';
31
+ /**
32
+ * Backdrop component for dialog. Recommended to be used with `Dialog`
33
+ * then its visibility is being controlled by dialog's `isOpen` prop.
34
+ * @example
35
+ * <Dialog.Backdrop />
36
+ */
37
+ export var DialogBackdrop = React.forwardRef(function (props, ref) {
38
+ var dialogContext = useDialogContext();
39
+ 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"]);
40
+ var backdropRef = React.useRef(null);
41
+ var refs = useMergedRefs(backdropRef, ref);
42
+ var handleMouseDown = function (event) {
43
+ // Prevents React from resetting its properties
44
+ event.persist();
45
+ if (event.target !== backdropRef.current) {
46
+ return;
47
+ }
48
+ if (isDismissible && closeOnExternalClick && onClose) {
49
+ onClose(event);
50
+ }
51
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
52
+ };
53
+ return (React.createElement(Backdrop, __assign({ isVisible: isVisible, ref: refs, onMouseDown: handleMouseDown }, rest)));
54
+ });
55
+ export default DialogBackdrop;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import '@itwin/itwinui-css/css/dialog.css';
3
+ export declare type DialogButtonBarProps = {
4
+ /**
5
+ * Buttons in the dialog bar.
6
+ */
7
+ children: React.ReactNode;
8
+ } & React.ComponentPropsWithRef<'div'>;
9
+ /**
10
+ * Container for Buttons in `Dialog`. Recommended to be used as a child of `Dialog`.
11
+ * @example
12
+ * <Dialog.ButtonBar>
13
+ * <Button styleType='high-visibility'>Confirm</Button>
14
+ * <Button>Close</Button>
15
+ * </Dialog.ButtonBar>
16
+ */
17
+ export declare const DialogButtonBar: React.ForwardRefExoticComponent<Pick<DialogButtonBarProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
18
+ export default DialogButtonBar;
@@ -0,0 +1,44 @@
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';
31
+ /**
32
+ * Container for Buttons in `Dialog`. Recommended to be used as a child of `Dialog`.
33
+ * @example
34
+ * <Dialog.ButtonBar>
35
+ * <Button styleType='high-visibility'>Confirm</Button>
36
+ * <Button>Close</Button>
37
+ * </Dialog.ButtonBar>
38
+ */
39
+ export var DialogButtonBar = React.forwardRef(function (props, ref) {
40
+ var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
41
+ useTheme();
42
+ return (React.createElement("div", __assign({ className: cx('iui-dialog-button-bar', className), ref: ref }, rest), children));
43
+ });
44
+ export default DialogButtonBar;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import '@itwin/itwinui-css/css/dialog.css';
3
+ export declare type DialogContentProps = {
4
+ /**
5
+ * Main content in the `Dialog`.
6
+ */
7
+ children: React.ReactNode;
8
+ } & React.ComponentPropsWithRef<'div'>;
9
+ /**
10
+ * Container for content in `Dialog`. Recommended to be used as a child of `Dialog`.
11
+ * @example
12
+ * <Dialog.Content>
13
+ * My dialog content
14
+ * </Dialog.Content>
15
+ */
16
+ export declare const DialogContent: React.ForwardRefExoticComponent<Pick<DialogContentProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
17
+ export default DialogContent;
@@ -0,0 +1,43 @@
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';
31
+ /**
32
+ * Container for content in `Dialog`. Recommended to be used as a child of `Dialog`.
33
+ * @example
34
+ * <Dialog.Content>
35
+ * My dialog content
36
+ * </Dialog.Content>
37
+ */
38
+ export var DialogContent = React.forwardRef(function (props, ref) {
39
+ var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
40
+ useTheme();
41
+ return (React.createElement("div", __assign({ className: cx('iui-dialog-content', className), ref: ref }, rest), children));
42
+ });
43
+ export default DialogContent;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ export declare type DialogContextProps = {
3
+ /**
4
+ * Flag whether dialog should be shown.
5
+ * @default false
6
+ */
7
+ isOpen?: boolean;
8
+ /**
9
+ * Handler that is called when dialog is closed.
10
+ */
11
+ onClose?: (event?: React.SyntheticEvent) => void;
12
+ /**
13
+ * Flag whether dialog is dismissible. If false, you can't close it.
14
+ * @default true
15
+ */
16
+ isDismissible?: boolean;
17
+ /**
18
+ * Flag whether dialog should be closed on backdrop press.
19
+ * @default false
20
+ */
21
+ closeOnExternalClick?: boolean;
22
+ /**
23
+ * Flag whether dialog should be closed on Escape key press.
24
+ * @default true
25
+ */
26
+ closeOnEsc?: boolean;
27
+ /**
28
+ * Traps the focus inside the dialog. This is useful when the dialog is modal.
29
+ * @default false
30
+ */
31
+ trapFocus?: boolean;
32
+ /**
33
+ * Prevents body from being scrollable. This is useful when the dialog is modal.
34
+ * @default false
35
+ */
36
+ preventDocumentScroll?: boolean;
37
+ };
38
+ export declare const DialogContext: React.Context<DialogContextProps | undefined>;
39
+ export declare const useDialogContext: () => DialogContextProps;
@@ -0,0 +1,9 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import React from 'react';
6
+ export var DialogContext = React.createContext(undefined);
7
+ export var useDialogContext = function () {
8
+ return React.useContext(DialogContext) || {};
9
+ };
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import '@itwin/itwinui-css/css/dialog.css';
3
+ import { DialogContextProps } from './DialogContext';
4
+ export declare type DialogMainProps = {
5
+ /**
6
+ * Type of the dialog.
7
+ * @default 'default'
8
+ */
9
+ styleType?: 'default' | 'fullPage';
10
+ /**
11
+ * Content of the dialog.
12
+ */
13
+ children: React.ReactNode;
14
+ } & Omit<DialogContextProps, 'closeOnExternalClick'> & React.ComponentPropsWithRef<'div'>;
15
+ /**
16
+ * Dialog component which can wrap any content.
17
+ * @example
18
+ * <Dialog.Main>
19
+ * <Dialog.TitleBar>
20
+ * My dialog title
21
+ * </Dialog.TitleBar>
22
+ * <Dialog.Content>
23
+ * Here is my dialog content
24
+ * </Dialog.Content>
25
+ * <Dialog.ButtonBar>
26
+ * <Button styleType='high-visibility'>
27
+ * Primary button
28
+ * </Button>
29
+ * <Button>
30
+ * Secondary button
31
+ * </Button>
32
+ * </Dialog.ButtonBar>
33
+ * </Dialog.Main>
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>>;
36
+ export default DialogMain;
@@ -0,0 +1,114 @@
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 { FocusTrap, useMergedRefs, useTheme } from '../utils';
30
+ import '@itwin/itwinui-css/css/dialog.css';
31
+ import { useDialogContext } from './DialogContext';
32
+ import { CSSTransition } from 'react-transition-group';
33
+ /**
34
+ * Dialog component which can wrap any content.
35
+ * @example
36
+ * <Dialog.Main>
37
+ * <Dialog.TitleBar>
38
+ * My dialog title
39
+ * </Dialog.TitleBar>
40
+ * <Dialog.Content>
41
+ * Here is my dialog content
42
+ * </Dialog.Content>
43
+ * <Dialog.ButtonBar>
44
+ * <Button styleType='high-visibility'>
45
+ * Primary button
46
+ * </Button>
47
+ * <Button>
48
+ * Secondary button
49
+ * </Button>
50
+ * </Dialog.ButtonBar>
51
+ * </Dialog.Main>
52
+ */
53
+ export var DialogMain = React.forwardRef(function (props, ref) {
54
+ var dialogContext = useDialogContext();
55
+ 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 = _g === void 0 ? dialogContext.preventDocumentScroll : _g, onKeyDown = props.onKeyDown, rest = __rest(props, ["className", "children", "styleType", "isOpen", "isDismissible", "onClose", "closeOnEsc", "trapFocus", "preventDocumentScroll", "onKeyDown"]);
56
+ useTheme();
57
+ var dialogRef = React.useRef(null);
58
+ var refs = useMergedRefs(dialogRef, ref);
59
+ // Focuses dialog when opened and brings back focus to the previously focused element when closed.
60
+ var previousFocusedElement = React.useRef();
61
+ React.useEffect(function () {
62
+ var _a, _b, _c;
63
+ if (isOpen) {
64
+ previousFocusedElement.current = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.activeElement;
65
+ (_b = dialogRef.current) === null || _b === void 0 ? void 0 : _b.focus();
66
+ }
67
+ else {
68
+ (_c = previousFocusedElement.current) === null || _c === void 0 ? void 0 : _c.focus();
69
+ }
70
+ var ref = dialogRef.current;
71
+ return function () {
72
+ var _a;
73
+ (ref === null || ref === void 0 ? void 0 : ref.contains(document.activeElement)) &&
74
+ ((_a = previousFocusedElement.current) === null || _a === void 0 ? void 0 : _a.focus());
75
+ };
76
+ }, [isOpen]);
77
+ // Prevents document from scrolling when the dialog is open.
78
+ var originalBodyOverflow = React.useRef('');
79
+ React.useEffect(function () {
80
+ var _a;
81
+ var ownerDocument = (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument;
82
+ if (!ownerDocument || !preventDocumentScroll) {
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, preventDocumentScroll]);
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
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
103
+ };
104
+ var content = (React.createElement("div", __assign({ className: cx('iui-dialog', {
105
+ 'iui-dialog-default': styleType === 'default',
106
+ 'iui-dialog-full-page': styleType === 'fullPage',
107
+ 'iui-dialog-visible': isOpen,
108
+ }, className), role: 'dialog', ref: refs, onKeyDown: handleKeyDown, tabIndex: -1 }, rest), children));
109
+ return (React.createElement(CSSTransition, { in: isOpen, classNames: 'iui-dialog-animation', timeout: { exit: 600 }, unmountOnExit: true, nodeRef: dialogRef },
110
+ React.createElement(React.Fragment, null,
111
+ trapFocus && React.createElement(FocusTrap, null, content),
112
+ !trapFocus && content)));
113
+ });
114
+ export default DialogMain;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import '@itwin/itwinui-css/css/dialog.css';
3
+ import { DialogContextProps } from './DialogContext';
4
+ export declare type DialogTitleBarProps = {
5
+ /**
6
+ * Dialog title bar content. If passed, then `title` prop is ignored.
7
+ */
8
+ children?: React.ReactNode;
9
+ /**
10
+ * Dialog title.
11
+ */
12
+ titleText?: React.ReactNode;
13
+ } & Pick<DialogContextProps, 'isDismissible' | 'onClose'> & React.ComponentPropsWithRef<'div'>;
14
+ /**
15
+ * Dialog title bar. Recommended to be used as a child of `Dialog`.
16
+ * @example
17
+ * <Dialog.TitleBar title='My dialog title' />
18
+ * @example
19
+ * <Dialog.TitleBar>
20
+ * <Dialog.TitleBar.Title>My dialog title</Dialog.TitleBar.Title>
21
+ * <IconButton
22
+ * size='small'
23
+ * styleType='borderless'
24
+ * onClick={onClose}
25
+ * aria-label='Close'
26
+ * >
27
+ * <SvgClose />
28
+ * </IconButton>
29
+ * </Dialog.TitleBar>
30
+ */
31
+ export declare const DialogTitleBar: React.ForwardRefExoticComponent<Pick<DialogTitleBarProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isDismissible" | "titleText"> & React.RefAttributes<HTMLDivElement>> & {
32
+ Title: React.ForwardRefExoticComponent<Pick<import("./DialogTitleBarTitle").DialogTitleBarTitleProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
33
+ };
34
+ export default DialogTitleBar;
@@ -0,0 +1,63 @@
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 SvgClose from '@itwin/itwinui-icons-react/cjs/icons/Close';
30
+ import { useTheme } from '@storybook/theming';
31
+ import { IconButton } from '../Buttons';
32
+ import '@itwin/itwinui-css/css/dialog.css';
33
+ import { useDialogContext } from './DialogContext';
34
+ import { DialogTitleBarTitle } from './DialogTitleBarTitle';
35
+ /**
36
+ * Dialog title bar. Recommended to be used as a child of `Dialog`.
37
+ * @example
38
+ * <Dialog.TitleBar title='My dialog title' />
39
+ * @example
40
+ * <Dialog.TitleBar>
41
+ * <Dialog.TitleBar.Title>My dialog title</Dialog.TitleBar.Title>
42
+ * <IconButton
43
+ * size='small'
44
+ * styleType='borderless'
45
+ * onClick={onClose}
46
+ * aria-label='Close'
47
+ * >
48
+ * <SvgClose />
49
+ * </IconButton>
50
+ * </Dialog.TitleBar>
51
+ */
52
+ export var DialogTitleBar = Object.assign(React.forwardRef(function (props, ref) {
53
+ var dialogContext = useDialogContext();
54
+ 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"]);
55
+ useTheme();
56
+ return (React.createElement("div", __assign({ className: cx('iui-dialog-title-bar', className), ref: ref }, rest), children ? (children) : (React.createElement(React.Fragment, null,
57
+ React.createElement(DialogTitleBarTitle, null, titleText),
58
+ isDismissible && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
59
+ React.createElement(SvgClose, null)))))));
60
+ }), {
61
+ Title: DialogTitleBarTitle,
62
+ });
63
+ export default DialogTitleBar;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import '@itwin/itwinui-css/css/dialog.css';
3
+ export declare type DialogTitleBarTitleProps = {
4
+ /**
5
+ * Dialog title content.
6
+ */
7
+ children: React.ReactNode;
8
+ } & React.ComponentPropsWithRef<'div'>;
9
+ /**
10
+ * Dialog title bar. Recommended to be used as a child of `Dialog`.
11
+ * @example
12
+ * <Dialog.TitleBar>My dialog title</Dialog.TitleBar>
13
+ */
14
+ export declare const DialogTitleBarTitle: React.ForwardRefExoticComponent<Pick<DialogTitleBarTitleProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
15
+ export default DialogTitleBarTitle;
@@ -0,0 +1,41 @@
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 '@storybook/theming';
30
+ import '@itwin/itwinui-css/css/dialog.css';
31
+ /**
32
+ * Dialog title bar. Recommended to be used as a child of `Dialog`.
33
+ * @example
34
+ * <Dialog.TitleBar>My dialog title</Dialog.TitleBar>
35
+ */
36
+ export var DialogTitleBarTitle = React.forwardRef(function (props, ref) {
37
+ var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
38
+ useTheme();
39
+ return (React.createElement("div", __assign({ className: cx('iui-dialog-title', className), ref: ref }, rest), children));
40
+ });
41
+ export default DialogTitleBarTitle;
@@ -0,0 +1,8 @@
1
+ export { Dialog } from './Dialog';
2
+ export type { DialogProps } from './Dialog';
3
+ export type { DialogMainProps } from './DialogMain';
4
+ export type { DialogTitleBarProps } from './DialogTitleBar';
5
+ export type { DialogContentProps } from './DialogContent';
6
+ export type { DialogButtonBarProps } from './DialogButtonBar';
7
+ declare const _default: "./Dialog";
8
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ export { Dialog } from './Dialog';
6
+ export default './Dialog';
@@ -1,14 +1,16 @@
1
1
  import React from 'react';
2
2
  import { CommonProps } from '../utils';
3
3
  import '@itwin/itwinui-css/css/non-ideal-state.css';
4
- export declare type ErrorPageType = '401' | '403' | '404' | '500' | '502' | '503' | 'generic';
4
+ export declare type ErrorPageType = '300' | '301' | '302' | '303' | '304' | '305' | '307' | '308' | '401' | '403' | '404' | '408' | '500' | '502' | '503' | '504' | 'generic';
5
5
  export declare type ErrorTypeTranslations = {
6
6
  badGateway: string;
7
7
  error: string;
8
8
  forbidden: string;
9
9
  internalServerError: string;
10
+ redirect?: string;
10
11
  pageNotFound: string;
11
12
  serviceUnavailable: string;
13
+ timedOut?: string;
12
14
  unauthorized: string;
13
15
  };
14
16
  export declare type ErrorPageProps = {