@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.
Files changed (142) hide show
  1. package/CHANGELOG.md +33 -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 +15 -14
  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/Footer/Footer.d.ts +16 -2
  28. package/cjs/core/Footer/Footer.js +57 -45
  29. package/cjs/core/Footer/FooterItem.d.ts +8 -0
  30. package/cjs/core/Footer/FooterItem.js +46 -0
  31. package/cjs/core/Footer/FooterList.d.ts +8 -0
  32. package/cjs/core/Footer/FooterList.js +46 -0
  33. package/cjs/core/Footer/FooterSeparator.d.ts +8 -0
  34. package/cjs/core/Footer/FooterSeparator.js +46 -0
  35. package/cjs/core/Footer/index.d.ts +1 -1
  36. package/cjs/core/Footer/index.js +2 -1
  37. package/cjs/core/Modal/Modal.d.ts +4 -14
  38. package/cjs/core/Modal/Modal.js +9 -74
  39. package/cjs/core/Modal/ModalButtonBar.d.ts +1 -2
  40. package/cjs/core/Modal/ModalButtonBar.js +2 -39
  41. package/cjs/core/Modal/ModalContent.d.ts +1 -2
  42. package/cjs/core/Modal/ModalContent.js +2 -39
  43. package/cjs/core/Slider/Slider.d.ts +10 -0
  44. package/cjs/core/Slider/Slider.js +20 -14
  45. package/cjs/core/Slider/Thumb.d.ts +2 -1
  46. package/cjs/core/Slider/Thumb.js +5 -3
  47. package/cjs/core/Slider/Track.d.ts +2 -1
  48. package/cjs/core/Slider/Track.js +23 -4
  49. package/cjs/core/Table/Table.d.ts +24 -0
  50. package/cjs/core/Table/Table.js +12 -4
  51. package/cjs/core/Table/TableRowMemoized.d.ts +2 -0
  52. package/cjs/core/Table/TableRowMemoized.js +2 -2
  53. package/cjs/core/Table/columns/actionColumn.d.ts +8 -3
  54. package/cjs/core/Table/columns/actionColumn.js +33 -2
  55. package/cjs/core/Table/hooks/index.d.ts +1 -0
  56. package/cjs/core/Table/hooks/index.js +3 -1
  57. package/cjs/core/Table/hooks/useScrollToRow.d.ts +11 -0
  58. package/cjs/core/Table/hooks/useScrollToRow.js +49 -0
  59. package/cjs/core/Tree/Tree.d.ts +9 -0
  60. package/cjs/core/Tree/Tree.js +67 -19
  61. package/cjs/core/Tree/TreeContext.d.ts +4 -0
  62. package/cjs/core/Tree/TreeNode.js +8 -9
  63. package/cjs/core/Typography/Small/Small.js +1 -1
  64. package/cjs/core/index.d.ts +3 -1
  65. package/cjs/core/index.js +6 -3
  66. package/cjs/core/utils/components/FocusTrap.js +1 -1
  67. package/cjs/core/utils/components/MiddleTextTruncation.js +1 -1
  68. package/cjs/core/utils/hooks/index.d.ts +1 -0
  69. package/cjs/core/utils/hooks/index.js +1 -0
  70. package/cjs/core/utils/hooks/useLatestRef.d.ts +9 -0
  71. package/cjs/core/utils/hooks/useLatestRef.js +26 -0
  72. package/esm/core/Backdrop/Backdrop.d.ts +10 -0
  73. package/esm/core/Backdrop/Backdrop.js +35 -0
  74. package/esm/core/Backdrop/index.d.ts +2 -0
  75. package/esm/core/Backdrop/index.js +5 -0
  76. package/esm/core/Breadcrumbs/Breadcrumbs.js +18 -18
  77. package/esm/core/ButtonGroup/ButtonGroup.js +11 -4
  78. package/esm/core/ComboBox/ComboBox.js +16 -15
  79. package/esm/core/Dialog/Dialog.d.ts +41 -0
  80. package/esm/core/Dialog/Dialog.js +53 -0
  81. package/esm/core/Dialog/DialogBackdrop.d.ts +12 -0
  82. package/esm/core/Dialog/DialogBackdrop.js +55 -0
  83. package/esm/core/Dialog/DialogButtonBar.d.ts +18 -0
  84. package/esm/core/Dialog/DialogButtonBar.js +44 -0
  85. package/esm/core/Dialog/DialogContent.d.ts +17 -0
  86. package/esm/core/Dialog/DialogContent.js +43 -0
  87. package/esm/core/Dialog/DialogContext.d.ts +39 -0
  88. package/esm/core/Dialog/DialogContext.js +9 -0
  89. package/esm/core/Dialog/DialogMain.d.ts +36 -0
  90. package/esm/core/Dialog/DialogMain.js +114 -0
  91. package/esm/core/Dialog/DialogTitleBar.d.ts +34 -0
  92. package/esm/core/Dialog/DialogTitleBar.js +63 -0
  93. package/esm/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
  94. package/esm/core/Dialog/DialogTitleBarTitle.js +41 -0
  95. package/esm/core/Dialog/index.d.ts +8 -0
  96. package/esm/core/Dialog/index.js +6 -0
  97. package/esm/core/Footer/Footer.d.ts +16 -2
  98. package/esm/core/Footer/Footer.js +56 -43
  99. package/esm/core/Footer/FooterItem.d.ts +8 -0
  100. package/esm/core/Footer/FooterItem.js +39 -0
  101. package/esm/core/Footer/FooterList.d.ts +8 -0
  102. package/esm/core/Footer/FooterList.js +39 -0
  103. package/esm/core/Footer/FooterSeparator.d.ts +8 -0
  104. package/esm/core/Footer/FooterSeparator.js +39 -0
  105. package/esm/core/Footer/index.d.ts +1 -1
  106. package/esm/core/Footer/index.js +1 -1
  107. package/esm/core/Modal/Modal.d.ts +4 -14
  108. package/esm/core/Modal/Modal.js +10 -75
  109. package/esm/core/Modal/ModalButtonBar.d.ts +1 -2
  110. package/esm/core/Modal/ModalButtonBar.js +2 -35
  111. package/esm/core/Modal/ModalContent.d.ts +1 -2
  112. package/esm/core/Modal/ModalContent.js +2 -35
  113. package/esm/core/Slider/Slider.d.ts +10 -0
  114. package/esm/core/Slider/Slider.js +20 -14
  115. package/esm/core/Slider/Thumb.d.ts +2 -1
  116. package/esm/core/Slider/Thumb.js +5 -3
  117. package/esm/core/Slider/Track.d.ts +2 -1
  118. package/esm/core/Slider/Track.js +23 -4
  119. package/esm/core/Table/Table.d.ts +24 -0
  120. package/esm/core/Table/Table.js +13 -5
  121. package/esm/core/Table/TableRowMemoized.d.ts +2 -0
  122. package/esm/core/Table/TableRowMemoized.js +2 -2
  123. package/esm/core/Table/columns/actionColumn.d.ts +8 -3
  124. package/esm/core/Table/columns/actionColumn.js +33 -2
  125. package/esm/core/Table/hooks/index.d.ts +1 -0
  126. package/esm/core/Table/hooks/index.js +1 -0
  127. package/esm/core/Table/hooks/useScrollToRow.d.ts +11 -0
  128. package/esm/core/Table/hooks/useScrollToRow.js +42 -0
  129. package/esm/core/Tree/Tree.d.ts +9 -0
  130. package/esm/core/Tree/Tree.js +68 -20
  131. package/esm/core/Tree/TreeContext.d.ts +4 -0
  132. package/esm/core/Tree/TreeNode.js +8 -9
  133. package/esm/core/Typography/Small/Small.js +1 -1
  134. package/esm/core/index.d.ts +3 -1
  135. package/esm/core/index.js +2 -1
  136. package/esm/core/utils/components/FocusTrap.js +1 -1
  137. package/esm/core/utils/components/MiddleTextTruncation.js +1 -1
  138. package/esm/core/utils/hooks/index.d.ts +1 -0
  139. package/esm/core/utils/hooks/index.js +1 -0
  140. package/esm/core/utils/hooks/useLatestRef.d.ts +9 -0
  141. package/esm/core/utils/hooks/useLatestRef.js +19 -0
  142. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ### [1.43.1](https://www.github.com/iTwin/iTwinUI-react/compare/v1.43.0...v1.43.1) (2022-08-18)
4
+
5
+ ### Fixes
6
+
7
+ * **Dialog:** Fixed import path for `useTheme` ([#780](https://www.github.com/iTwin/iTwinUI-react/issues/780)) ([dc5f65a](https://www.github.com/iTwin/iTwinUI-react/commit/dc5f65af8a4a7e8d50f05952084a2ffe98bc0800))
8
+
9
+ ## [1.43.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.42.0...v1.43.0) (2022-08-17)
10
+
11
+ ### What's new
12
+
13
+ * **Footer:** Allows to use composition to customize Footer as you wish ([#754](https://www.github.com/iTwin/iTwinUI-react/issues/754)) ([48dfe52](https://www.github.com/iTwin/iTwinUI-react/commit/48dfe524f4ac45a81cd98504f38c50420f47664a))
14
+ * **Slider:** Adding vertical orientation support ([#747](https://www.github.com/iTwin/iTwinUI-react/issues/747)) ([18cb893](https://www.github.com/iTwin/iTwinUI-react/commit/18cb89317118081ab425606f5679be56e1b60552))
15
+ * **Table:** Style `DropdownMenu` inside of `ActionColumn` in `Table` ([#756](https://www.github.com/iTwin/iTwinUI-react/issues/756)) ([1116369](https://www.github.com/iTwin/iTwinUI-react/commit/111636962076797cbbc0f0b8b5ae4077a7e5a8d2))
16
+
17
+ ### Fixes
18
+
19
+ * **Breadcrumbs**, **ButtonGroup**: Fix focus getting lost while resizing on overflow ([#777](https://www.github.com/iTwin/iTwinUI-react/issues/777)) ([8ee9c7b](https://www.github.com/iTwin/iTwinUI-react/commit/8ee9c7b57829b330cea7db5f89864c90211ec4d1))
20
+ * **Table:** Enabled scrollToRow for lazy-loading tables ([#775](https://www.github.com/iTwin/iTwinUI-react/issues/775)) ([c57b458](https://www.github.com/iTwin/iTwinUI-react/commit/c57b458e7d74609d44d3f0d304e49ee2c1f22d54))
21
+ * **Table:** Syncing header and body horizontal scroll state ([#760](https://www.github.com/iTwin/iTwinUI-react/issues/760)) ([5ceeec2](https://www.github.com/iTwin/iTwinUI-react/commit/5ceeec279585ca5af92f1b26440c354ee6eeb027))
22
+
23
+ ## [1.42.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.41.0...v1.42.0) (2022-07-26)
24
+
25
+ ### Fixes
26
+
27
+ * **ComboBox:** Prevent infinite loop when `options` change ([#738](https://www.github.com/iTwin/iTwinUI-react/issues/738)) ([7788f45](https://www.github.com/iTwin/iTwinUI-react/commit/7788f451fcbf9dd7959d3fa727c0cdee3485bbcd))
28
+ * **Small:** Use `small` element instead of `p` ([#735](https://www.github.com/iTwin/iTwinUI-react/issues/735)) ([c59f213](https://www.github.com/iTwin/iTwinUI-react/commit/c59f21326e049bce50e24c729a46482b74ef63c3))
29
+
30
+
31
+ ### What's new
32
+
33
+ * **Table:** Scroll table to selected item ([#689](https://www.github.com/iTwin/iTwinUI-react/issues/689)) ([afa947b](https://www.github.com/iTwin/iTwinUI-react/commit/afa947b15411305c1bfc57b239d916fc599acfbe))
34
+ * **Tree:** Virtualization ([#713](https://www.github.com/iTwin/iTwinUI-react/issues/713)) ([d4d3575](https://www.github.com/iTwin/iTwinUI-react/commit/d4d35758fa0c8f00811f387cc8453b82e9773c85))
35
+
3
36
  ## [1.41.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.40.1...v1.41.0) (2022-07-13)
4
37
 
5
38
  ### What's new
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import '@itwin/itwinui-css/css/backdrop.css';
3
+ export declare type BackdropProps = {
4
+ /**
5
+ * Flag whether backdrop should be shown.
6
+ * @default true
7
+ */
8
+ isVisible?: boolean;
9
+ } & React.ComponentPropsWithRef<'div'>;
10
+ export declare const Backdrop: React.ForwardRefExoticComponent<Pick<BackdropProps, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible"> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.Backdrop = void 0;
29
+ /*---------------------------------------------------------------------------------------------
30
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
31
+ * See LICENSE.md in the project root for license terms and full copyright notice.
32
+ *--------------------------------------------------------------------------------------------*/
33
+ var react_1 = __importDefault(require("react"));
34
+ var classnames_1 = __importDefault(require("classnames"));
35
+ var utils_1 = require("../utils");
36
+ require("@itwin/itwinui-css/css/backdrop.css");
37
+ exports.Backdrop = react_1.default.forwardRef(function (props, ref) {
38
+ var _a = props.isVisible, isVisible = _a === void 0 ? true : _a, className = props.className, rest = __rest(props, ["isVisible", "className"]);
39
+ (0, utils_1.useTheme)();
40
+ return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-backdrop', { 'iui-backdrop-visible': isVisible }, className), ref: ref }, rest)));
41
+ });
@@ -0,0 +1,2 @@
1
+ export { Backdrop } from './Backdrop';
2
+ export type { BackdropProps } from './Backdrop';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Backdrop = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ var Backdrop_1 = require("./Backdrop");
9
+ Object.defineProperty(exports, "Backdrop", { enumerable: true, get: function () { return Backdrop_1.Backdrop; } });
@@ -62,28 +62,15 @@ exports.Breadcrumbs = react_1.default.forwardRef(function (props, ref) {
62
62
  (0, utils_1.useTheme)();
63
63
  var _b = (0, utils_1.useOverflow)(items), overflowRef = _b[0], visibleCount = _b[1];
64
64
  var refs = (0, utils_1.useMergedRefs)(overflowRef, ref);
65
- var Separator = function () { return (react_1.default.createElement("li", { className: 'iui-breadcrumbs-separator', "aria-hidden": true }, separator !== null && separator !== void 0 ? separator : react_1.default.createElement(ChevronRight_1.default, null))); };
66
- var ListItem = function (_a) {
67
- var _b;
68
- var index = _a.index;
69
- var item = items[index];
70
- return (react_1.default.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' }, react_1.default.isValidElement(item)
71
- ? react_1.default.cloneElement(item, {
72
- 'aria-current': ((_b = item.props['aria-current']) !== null && _b !== void 0 ? _b : currentIndex === index)
73
- ? 'location'
74
- : undefined,
75
- })
76
- : item));
77
- };
78
65
  return (react_1.default.createElement("nav", __assign({ className: (0, classnames_1.default)('iui-breadcrumbs', className), ref: refs, "aria-label": 'Breadcrumb' }, rest),
79
66
  react_1.default.createElement("ol", { className: 'iui-breadcrumbs-list' },
80
67
  visibleCount > 1 && (react_1.default.createElement(react_1.default.Fragment, null,
81
- react_1.default.createElement(ListItem, { index: 0 }),
82
- react_1.default.createElement(Separator, null))),
68
+ react_1.default.createElement(ListItem, { item: items[0], isActive: currentIndex === 0 }),
69
+ react_1.default.createElement(Separator, { separator: separator }))),
83
70
  items.length - visibleCount > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
84
71
  react_1.default.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' },
85
72
  react_1.default.createElement("span", { className: 'iui-breadcrumbs-text' }, "\u2026")),
86
- react_1.default.createElement(Separator, null))),
73
+ react_1.default.createElement(Separator, { separator: separator }))),
87
74
  items
88
75
  .slice(visibleCount > 1
89
76
  ? items.length - visibleCount + 1
@@ -93,8 +80,21 @@ exports.Breadcrumbs = react_1.default.forwardRef(function (props, ref) {
93
80
  ? 1 + (items.length - visibleCount) + _index
94
81
  : items.length - 1;
95
82
  return (react_1.default.createElement(react_1.default.Fragment, { key: index },
96
- react_1.default.createElement(ListItem, { index: index }),
97
- index < items.length - 1 && react_1.default.createElement(Separator, null)));
83
+ react_1.default.createElement(ListItem, { item: items[index], isActive: currentIndex === index }),
84
+ index < items.length - 1 && (react_1.default.createElement(Separator, { separator: separator }))));
98
85
  }))));
99
86
  });
87
+ var ListItem = function (_a) {
88
+ var _b;
89
+ var item = _a.item, isActive = _a.isActive;
90
+ return (react_1.default.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' }, react_1.default.isValidElement(item)
91
+ ? react_1.default.cloneElement(item, {
92
+ 'aria-current': ((_b = item.props['aria-current']) !== null && _b !== void 0 ? _b : isActive) ? 'location' : undefined,
93
+ })
94
+ : item));
95
+ };
96
+ var Separator = function (_a) {
97
+ var separator = _a.separator;
98
+ return (react_1.default.createElement("li", { className: 'iui-breadcrumbs-separator', "aria-hidden": true }, separator !== null && separator !== void 0 ? separator : react_1.default.createElement(ChevronRight_1.default, null)));
99
+ };
100
100
  exports.default = exports.Breadcrumbs;
@@ -72,9 +72,16 @@ exports.ButtonGroup = react_1.default.forwardRef(function (props, ref) {
72
72
  'iui-button-group': orientation === 'horizontal',
73
73
  'iui-button-group-vertical': orientation === 'vertical',
74
74
  'iui-button-group-overflow-x': !!overflowButton && orientation === 'horizontal',
75
- }, className), "aria-orientation": orientation, ref: refs }, rest), !!overflowButton && visibleCount < items.length ? (react_1.default.createElement(react_1.default.Fragment, null,
76
- overflowButton && overflowPlacement === 'start' && (react_1.default.createElement("div", null, overflowButton(visibleCount))),
77
- items.slice(0, visibleCount - 1),
78
- overflowButton && overflowPlacement === 'end' && (react_1.default.createElement("div", null, overflowButton(visibleCount))))) : (items)));
75
+ }, className), "aria-orientation": orientation, ref: refs }, rest),
76
+ react_1.default.createElement(react_1.default.Fragment, null,
77
+ visibleCount < items.length &&
78
+ overflowButton &&
79
+ overflowPlacement === 'start' && (react_1.default.createElement("div", null, overflowButton(visibleCount))),
80
+ visibleCount < items.length
81
+ ? items.slice(0, visibleCount - 1)
82
+ : items,
83
+ visibleCount < items.length &&
84
+ overflowButton &&
85
+ overflowPlacement === 'end' && (react_1.default.createElement("div", null, overflowButton(visibleCount))))));
79
86
  });
80
87
  exports.default = exports.ButtonGroup;
@@ -75,11 +75,9 @@ var ComboBox = function (props) {
75
75
  var menuRef = react_1.default.useRef(null);
76
76
  var toggleButtonRef = react_1.default.useRef(null);
77
77
  var mounted = react_1.default.useRef(false);
78
- // Latest value of the onChange prop
79
- var onChangeProp = react_1.default.useRef(onChange);
80
- react_1.default.useEffect(function () {
81
- onChangeProp.current = onChange;
82
- }, [onChange]);
78
+ var valuePropRef = (0, utils_1.useLatestRef)(valueProp);
79
+ var onChangeProp = (0, utils_1.useLatestRef)(onChange);
80
+ var optionsRef = (0, utils_1.useLatestRef)(options);
83
81
  // Record to store all extra information (e.g. original indexes), where the key is the id of the option
84
82
  var optionsExtraInfoRef = react_1.default.useRef({});
85
83
  // Clear the extra info when the options change so that it can be reinitialized below
@@ -99,7 +97,7 @@ var ComboBox = function (props) {
99
97
  var _e = react_1.default.useReducer(helpers_1.comboBoxReducer, {
100
98
  isOpen: false,
101
99
  selectedIndex: valueProp
102
- ? options.findIndex(function (option) { return option.value === valueProp; })
100
+ ? optionsRef.current.findIndex(function (option) { return option.value === valueProp; })
103
101
  : -1,
104
102
  focusedIndex: -1,
105
103
  }), _f = _e[0], isOpen = _f.isOpen, selectedIndex = _f.selectedIndex, focusedIndex = _f.focusedIndex, dispatch = _e[1];
@@ -108,7 +106,7 @@ var ComboBox = function (props) {
108
106
  // When the dropdown opens
109
107
  if (isOpen) {
110
108
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); // Focus the input
111
- setFilteredOptions(options); // Reset the filtered list
109
+ setFilteredOptions(optionsRef.current); // Reset the filtered list
112
110
  dispatch(['focus']);
113
111
  }
114
112
  // When the dropdown closes
@@ -117,10 +115,10 @@ var ComboBox = function (props) {
117
115
  dispatch(['focus']);
118
116
  // Reset the input value
119
117
  setInputValue(selectedIndex != undefined && selectedIndex >= 0
120
- ? (_b = options[selectedIndex]) === null || _b === void 0 ? void 0 : _b.label
118
+ ? (_b = optionsRef.current[selectedIndex]) === null || _b === void 0 ? void 0 : _b.label
121
119
  : '');
122
120
  }
123
- }, [isOpen, options, selectedIndex]);
121
+ }, [isOpen, optionsRef, selectedIndex]);
124
122
  // Set min-width of menu to be same as input
125
123
  var _g = react_1.default.useState(0), minWidth = _g[0], setMinWidth = _g[1];
126
124
  react_1.default.useEffect(function () {
@@ -151,14 +149,14 @@ var ComboBox = function (props) {
151
149
  var value = event.currentTarget.value;
152
150
  setInputValue(value);
153
151
  dispatch(['open']); // reopen when typing
154
- setFilteredOptions((_a = filterFunction === null || filterFunction === void 0 ? void 0 : filterFunction(options, value)) !== null && _a !== void 0 ? _a : options.filter(function (option) {
152
+ setFilteredOptions((_a = filterFunction === null || filterFunction === void 0 ? void 0 : filterFunction(optionsRef.current, value)) !== null && _a !== void 0 ? _a : optionsRef.current.filter(function (option) {
155
153
  return option.label.toLowerCase().includes(value.toLowerCase());
156
154
  }));
157
155
  if (focusedIndex != -1) {
158
156
  dispatch(['focus', -1]);
159
157
  }
160
158
  (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onChange) === null || _b === void 0 ? void 0 : _b.call(inputProps, event);
161
- }, [filterFunction, focusedIndex, inputProps, options]);
159
+ }, [filterFunction, focusedIndex, inputProps, optionsRef]);
162
160
  // When the value prop changes, update the selectedIndex
163
161
  react_1.default.useEffect(function () {
164
162
  dispatch([
@@ -174,9 +172,12 @@ var ComboBox = function (props) {
174
172
  mounted.current = true;
175
173
  return;
176
174
  }
177
- var value = (_a = options[selectedIndex]) === null || _a === void 0 ? void 0 : _a.value;
178
- (_b = onChangeProp.current) === null || _b === void 0 ? void 0 : _b.call(onChangeProp, value);
179
- }, [options, selectedIndex]);
175
+ var currentValue = (_a = optionsRef.current[selectedIndex]) === null || _a === void 0 ? void 0 : _a.value;
176
+ if (currentValue === valuePropRef.current || selectedIndex === -1) {
177
+ return;
178
+ }
179
+ (_b = onChangeProp.current) === null || _b === void 0 ? void 0 : _b.call(onChangeProp, currentValue);
180
+ }, [onChangeProp, optionsRef, selectedIndex, valuePropRef]);
180
181
  var getMenuItem = react_1.default.useCallback(function (option, filteredIndex) {
181
182
  var optionId = getOptionId(option, id);
182
183
  var __originalIndex = optionsExtraInfoRef.current[optionId].__originalIndex;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import '@itwin/itwinui-css/css/dialog.css';
3
+ import { DialogContextProps } from './DialogContext';
4
+ export declare type DialogProps = {
5
+ /**
6
+ * Dialog content.
7
+ */
8
+ children: React.ReactNode;
9
+ } & DialogContextProps;
10
+ /**
11
+ * Dialog component.
12
+ * @example
13
+ * <Dialog
14
+ * isOpen={isOpen}
15
+ * onClose={() => setIsOpen(false)}
16
+ * trapFocus
17
+ * preventDocumentScroll
18
+ * >
19
+ * <Dialog.Backdrop />
20
+ * <Dialog.Main aria-modal>
21
+ * <Dialog.TitleBar>My dialog title</Dialog.TitleBar>
22
+ * <Dialog.Content>
23
+ * Here is my dialog content
24
+ * </Dialog.Content>
25
+ * <Dialog.ButtonBar>
26
+ * <Button styleType='high-visibility'>Confirm</Button>
27
+ * <Button>Close</Button>
28
+ * </Dialog.ButtonBar>
29
+ * </Dialog.Main>
30
+ * </Dialog>
31
+ */
32
+ export declare const Dialog: ((props: DialogProps) => JSX.Element) & {
33
+ Backdrop: React.ForwardRefExoticComponent<Pick<import("./DialogBackdrop").DialogBackdropProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible" | "isDismissible" | "closeOnExternalClick"> & React.RefAttributes<HTMLDivElement>>;
34
+ Main: React.ForwardRefExoticComponent<Pick<import("./DialogMain").DialogMainProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "styleType" | "isOpen" | "isDismissible" | "closeOnEsc" | "trapFocus" | "preventDocumentScroll"> & React.RefAttributes<HTMLDivElement>>;
35
+ TitleBar: React.ForwardRefExoticComponent<Pick<import("./DialogTitleBar").DialogTitleBarProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isDismissible" | "titleText"> & React.RefAttributes<HTMLDivElement>> & {
36
+ Title: React.ForwardRefExoticComponent<Pick<import("./DialogTitleBarTitle").DialogTitleBarTitleProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
37
+ };
38
+ Content: React.ForwardRefExoticComponent<Pick<import("./DialogContent").DialogContentProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
39
+ ButtonBar: React.ForwardRefExoticComponent<Pick<import("./DialogButtonBar").DialogButtonBarProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
40
+ };
41
+ export default Dialog;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Dialog = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ var react_1 = __importDefault(require("react"));
12
+ require("@itwin/itwinui-css/css/dialog.css");
13
+ var DialogTitleBar_1 = require("./DialogTitleBar");
14
+ var DialogContent_1 = require("./DialogContent");
15
+ var DialogBackdrop_1 = require("./DialogBackdrop");
16
+ var DialogContext_1 = require("./DialogContext");
17
+ var DialogButtonBar_1 = require("./DialogButtonBar");
18
+ var DialogMain_1 = __importDefault(require("./DialogMain"));
19
+ /**
20
+ * Dialog component.
21
+ * @example
22
+ * <Dialog
23
+ * isOpen={isOpen}
24
+ * onClose={() => setIsOpen(false)}
25
+ * trapFocus
26
+ * preventDocumentScroll
27
+ * >
28
+ * <Dialog.Backdrop />
29
+ * <Dialog.Main aria-modal>
30
+ * <Dialog.TitleBar>My dialog title</Dialog.TitleBar>
31
+ * <Dialog.Content>
32
+ * Here is my dialog content
33
+ * </Dialog.Content>
34
+ * <Dialog.ButtonBar>
35
+ * <Button styleType='high-visibility'>Confirm</Button>
36
+ * <Button>Close</Button>
37
+ * </Dialog.ButtonBar>
38
+ * </Dialog.Main>
39
+ * </Dialog>
40
+ */
41
+ exports.Dialog = Object.assign(function (props) {
42
+ 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;
43
+ return (react_1.default.createElement(DialogContext_1.DialogContext.Provider, { value: {
44
+ isOpen: isOpen,
45
+ onClose: onClose,
46
+ closeOnEsc: closeOnEsc,
47
+ closeOnExternalClick: closeOnExternalClick,
48
+ isDismissible: isDismissible,
49
+ preventDocumentScroll: preventDocumentScroll,
50
+ trapFocus: trapFocus,
51
+ } }, children));
52
+ }, {
53
+ Backdrop: DialogBackdrop_1.DialogBackdrop,
54
+ Main: DialogMain_1.default,
55
+ TitleBar: DialogTitleBar_1.DialogTitleBar,
56
+ Content: DialogContent_1.DialogContent,
57
+ ButtonBar: DialogButtonBar_1.DialogButtonBar,
58
+ });
59
+ exports.default = exports.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,61 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.DialogBackdrop = void 0;
29
+ /*---------------------------------------------------------------------------------------------
30
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
31
+ * See LICENSE.md in the project root for license terms and full copyright notice.
32
+ *--------------------------------------------------------------------------------------------*/
33
+ var react_1 = __importDefault(require("react"));
34
+ var Backdrop_1 = require("../Backdrop");
35
+ var utils_1 = require("../utils");
36
+ var DialogContext_1 = require("./DialogContext");
37
+ /**
38
+ * Backdrop component for dialog. Recommended to be used with `Dialog`
39
+ * then its visibility is being controlled by dialog's `isOpen` prop.
40
+ * @example
41
+ * <Dialog.Backdrop />
42
+ */
43
+ exports.DialogBackdrop = react_1.default.forwardRef(function (props, ref) {
44
+ var dialogContext = (0, DialogContext_1.useDialogContext)();
45
+ var _a = props.isVisible, isVisible = _a === void 0 ? dialogContext.isOpen : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? dialogContext.isDismissible : _b, _c = props.onClose, onClose = _c === void 0 ? dialogContext.onClose : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? dialogContext.closeOnExternalClick : _d, onMouseDown = props.onMouseDown, rest = __rest(props, ["isVisible", "isDismissible", "onClose", "closeOnExternalClick", "onMouseDown"]);
46
+ var backdropRef = react_1.default.useRef(null);
47
+ var refs = (0, utils_1.useMergedRefs)(backdropRef, ref);
48
+ var handleMouseDown = function (event) {
49
+ // Prevents React from resetting its properties
50
+ event.persist();
51
+ if (event.target !== backdropRef.current) {
52
+ return;
53
+ }
54
+ if (isDismissible && closeOnExternalClick && onClose) {
55
+ onClose(event);
56
+ }
57
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
58
+ };
59
+ return (react_1.default.createElement(Backdrop_1.Backdrop, __assign({ isVisible: isVisible, ref: refs, onMouseDown: handleMouseDown }, rest)));
60
+ });
61
+ exports.default = exports.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,50 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.DialogButtonBar = void 0;
29
+ /*---------------------------------------------------------------------------------------------
30
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
31
+ * See LICENSE.md in the project root for license terms and full copyright notice.
32
+ *--------------------------------------------------------------------------------------------*/
33
+ var react_1 = __importDefault(require("react"));
34
+ var classnames_1 = __importDefault(require("classnames"));
35
+ var utils_1 = require("../utils");
36
+ require("@itwin/itwinui-css/css/dialog.css");
37
+ /**
38
+ * Container for Buttons in `Dialog`. Recommended to be used as a child of `Dialog`.
39
+ * @example
40
+ * <Dialog.ButtonBar>
41
+ * <Button styleType='high-visibility'>Confirm</Button>
42
+ * <Button>Close</Button>
43
+ * </Dialog.ButtonBar>
44
+ */
45
+ exports.DialogButtonBar = react_1.default.forwardRef(function (props, ref) {
46
+ var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
47
+ (0, utils_1.useTheme)();
48
+ return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-dialog-button-bar', className), ref: ref }, rest), children));
49
+ });
50
+ exports.default = exports.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,49 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.DialogContent = void 0;
29
+ /*---------------------------------------------------------------------------------------------
30
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
31
+ * See LICENSE.md in the project root for license terms and full copyright notice.
32
+ *--------------------------------------------------------------------------------------------*/
33
+ var react_1 = __importDefault(require("react"));
34
+ var classnames_1 = __importDefault(require("classnames"));
35
+ var utils_1 = require("../utils");
36
+ require("@itwin/itwinui-css/css/dialog.css");
37
+ /**
38
+ * Container for content in `Dialog`. Recommended to be used as a child of `Dialog`.
39
+ * @example
40
+ * <Dialog.Content>
41
+ * My dialog content
42
+ * </Dialog.Content>
43
+ */
44
+ exports.DialogContent = react_1.default.forwardRef(function (props, ref) {
45
+ var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
46
+ (0, utils_1.useTheme)();
47
+ return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-dialog-content', className), ref: ref }, rest), children));
48
+ });
49
+ exports.default = exports.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,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useDialogContext = exports.DialogContext = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ var react_1 = __importDefault(require("react"));
12
+ exports.DialogContext = react_1.default.createContext(undefined);
13
+ var useDialogContext = function () {
14
+ return react_1.default.useContext(exports.DialogContext) || {};
15
+ };
16
+ exports.useDialogContext = useDialogContext;