@itwin/itwinui-react 3.0.0-dev.1 → 3.0.0-dev.3

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 (239) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/cjs/core/Alert/Alert.d.ts +47 -28
  3. package/cjs/core/Alert/Alert.js +73 -21
  4. package/cjs/core/Avatar/Avatar.js +1 -1
  5. package/cjs/core/AvatarGroup/AvatarGroup.js +1 -1
  6. package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
  7. package/cjs/core/ButtonGroup/ButtonGroup.js +1 -4
  8. package/cjs/core/Buttons/DropdownButton/DropdownButton.js +3 -5
  9. package/cjs/core/Carousel/Carousel.d.ts +2 -2
  10. package/cjs/core/Carousel/Carousel.js +3 -5
  11. package/cjs/core/Carousel/CarouselDotsList.js +8 -10
  12. package/cjs/core/Carousel/CarouselNavigation.d.ts +2 -2
  13. package/cjs/core/Carousel/CarouselNavigation.js +3 -5
  14. package/cjs/core/Carousel/CarouselSlider.js +10 -15
  15. package/cjs/core/ColorPicker/ColorBuilder.js +7 -10
  16. package/cjs/core/ColorPicker/ColorInputPanel.js +12 -15
  17. package/cjs/core/ColorPicker/ColorPalette.js +4 -6
  18. package/cjs/core/ColorPicker/ColorPicker.js +3 -3
  19. package/cjs/core/ComboBox/ComboBox.js +25 -32
  20. package/cjs/core/ComboBox/ComboBoxDropdown.js +1 -2
  21. package/cjs/core/ComboBox/ComboBoxEndIcon.js +1 -1
  22. package/cjs/core/ComboBox/ComboBoxInput.js +21 -20
  23. package/cjs/core/ComboBox/ComboBoxMenu.js +3 -4
  24. package/cjs/core/ComboBox/ComboBoxMenuItem.js +2 -2
  25. package/cjs/core/ComboBox/helpers.js +4 -5
  26. package/cjs/core/DatePicker/DatePicker.js +32 -32
  27. package/cjs/core/Dialog/Dialog.js +11 -4
  28. package/cjs/core/Dialog/DialogBackdrop.js +1 -1
  29. package/cjs/core/Dialog/DialogContext.d.ts +11 -0
  30. package/cjs/core/Dialog/DialogMain.js +16 -22
  31. package/cjs/core/DropdownMenu/DropdownMenu.js +6 -8
  32. package/cjs/core/ExpandableBlock/ExpandableBlock.js +2 -2
  33. package/cjs/core/FileUpload/FileEmptyCard.js +1 -1
  34. package/cjs/core/FileUpload/FileUpload.d.ts +3 -4
  35. package/cjs/core/FileUpload/FileUpload.js +5 -8
  36. package/cjs/core/FileUpload/FileUploadCard.js +9 -10
  37. package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -0
  38. package/cjs/core/FileUpload/FileUploadTemplate.js +1 -0
  39. package/cjs/core/InformationPanel/InformationPanel.js +1 -4
  40. package/cjs/core/LabeledInput/LabeledInput.js +1 -1
  41. package/cjs/core/LabeledTextarea/LabeledTextarea.js +1 -1
  42. package/cjs/core/Menu/Menu.js +3 -4
  43. package/cjs/core/Menu/MenuItem.js +8 -11
  44. package/cjs/core/Modal/Modal.d.ts +8 -9
  45. package/cjs/core/Modal/Modal.js +7 -17
  46. package/cjs/core/SearchBox/SearchBox.js +12 -12
  47. package/cjs/core/Select/Select.js +12 -17
  48. package/cjs/core/SideNavigation/SideNavigation.js +2 -2
  49. package/cjs/core/Slider/Slider.js +16 -19
  50. package/cjs/core/Slider/Thumb.js +1 -1
  51. package/cjs/core/StatusMessage/StatusMessage.js +1 -1
  52. package/cjs/core/Stepper/Stepper.js +1 -1
  53. package/cjs/core/Stepper/StepperStep.js +1 -1
  54. package/cjs/core/Table/Table.js +15 -15
  55. package/cjs/core/Table/TablePaginator.js +2 -3
  56. package/cjs/core/Table/TableRowMemoized.js +38 -45
  57. package/cjs/core/Table/actionHandlers/expandHandler.js +3 -3
  58. package/cjs/core/Table/actionHandlers/filterHandler.js +4 -5
  59. package/cjs/core/Table/actionHandlers/selectHandler.js +6 -6
  60. package/cjs/core/Table/cells/DefaultCell.js +1 -1
  61. package/cjs/core/Table/cells/EditableCell.js +6 -12
  62. package/cjs/core/Table/columns/actionColumn.js +3 -6
  63. package/cjs/core/Table/columns/expanderColumn.js +3 -3
  64. package/cjs/core/Table/columns/selectionColumn.js +4 -4
  65. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
  66. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
  67. package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
  68. package/cjs/core/Table/filters/TextFilter/TextFilter.js +1 -2
  69. package/cjs/core/Table/hooks/useResizeColumns.js +16 -22
  70. package/cjs/core/Table/hooks/useScrollToRow.js +1 -2
  71. package/cjs/core/Table/hooks/useStickyColumns.js +3 -5
  72. package/cjs/core/Table/hooks/useSubRowFiltering.js +2 -4
  73. package/cjs/core/Tabs/Tabs.js +13 -16
  74. package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
  75. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +2 -3
  76. package/cjs/core/ThemeProvider/ThemeProvider.js +14 -13
  77. package/cjs/core/Tile/Tile.js +2 -3
  78. package/cjs/core/TimePicker/TimePicker.js +13 -13
  79. package/cjs/core/Toast/Toast.d.ts +5 -10
  80. package/cjs/core/Toast/Toast.js +17 -16
  81. package/cjs/core/Toast/Toaster.d.ts +24 -26
  82. package/cjs/core/Toast/Toaster.js +91 -121
  83. package/cjs/core/Toast/index.d.ts +1 -4
  84. package/cjs/core/Toast/index.js +3 -6
  85. package/cjs/core/TransferList/TransferList.js +3 -4
  86. package/cjs/core/Tree/Tree.js +9 -13
  87. package/cjs/core/Tree/TreeNode.js +9 -10
  88. package/cjs/core/index.d.ts +1 -2
  89. package/cjs/core/index.js +2 -5
  90. package/cjs/core/utils/color/ColorValue.js +9 -15
  91. package/cjs/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
  92. package/cjs/core/utils/components/FocusTrap.js +4 -4
  93. package/cjs/core/utils/components/MiddleTextTruncation.js +1 -2
  94. package/cjs/core/utils/components/Popover.d.ts +1 -1
  95. package/cjs/core/utils/components/Popover.js +5 -8
  96. package/cjs/core/utils/components/Resizer.js +7 -6
  97. package/cjs/core/utils/components/VirtualScroll.js +14 -21
  98. package/cjs/core/utils/functions/dom.d.ts +0 -8
  99. package/cjs/core/utils/functions/dom.js +3 -26
  100. package/cjs/core/utils/functions/polymorphic.d.ts +1 -1
  101. package/cjs/core/utils/functions/polymorphic.js +1 -1
  102. package/cjs/core/utils/functions/supports.js +1 -1
  103. package/cjs/core/utils/hooks/index.d.ts +0 -1
  104. package/cjs/core/utils/hooks/index.js +0 -1
  105. package/cjs/core/utils/hooks/useContainerWidth.js +1 -1
  106. package/cjs/core/utils/hooks/useDragAndDrop.js +8 -10
  107. package/cjs/core/utils/hooks/useEventListener.js +1 -1
  108. package/cjs/core/utils/hooks/useGlobals.d.ts +9 -2
  109. package/cjs/core/utils/hooks/useGlobals.js +6 -4
  110. package/cjs/core/utils/hooks/useId.js +1 -2
  111. package/cjs/core/utils/hooks/useIntersection.js +2 -3
  112. package/cjs/core/utils/hooks/useMediaQuery.js +6 -8
  113. package/cjs/core/utils/hooks/useOverflow.js +1 -2
  114. package/cjs/core/utils/hooks/useResizeObserver.js +3 -4
  115. package/cjs/styles.js +1 -4
  116. package/esm/core/Alert/Alert.d.ts +47 -28
  117. package/esm/core/Alert/Alert.js +74 -22
  118. package/esm/core/Avatar/Avatar.js +1 -1
  119. package/esm/core/AvatarGroup/AvatarGroup.js +1 -1
  120. package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
  121. package/esm/core/ButtonGroup/ButtonGroup.js +1 -4
  122. package/esm/core/Buttons/DropdownButton/DropdownButton.js +3 -5
  123. package/esm/core/Carousel/Carousel.d.ts +2 -2
  124. package/esm/core/Carousel/Carousel.js +3 -5
  125. package/esm/core/Carousel/CarouselDotsList.js +8 -10
  126. package/esm/core/Carousel/CarouselNavigation.d.ts +2 -2
  127. package/esm/core/Carousel/CarouselNavigation.js +3 -5
  128. package/esm/core/Carousel/CarouselSlider.js +10 -15
  129. package/esm/core/ColorPicker/ColorBuilder.js +7 -10
  130. package/esm/core/ColorPicker/ColorInputPanel.js +12 -15
  131. package/esm/core/ColorPicker/ColorPalette.js +4 -6
  132. package/esm/core/ColorPicker/ColorPicker.js +3 -3
  133. package/esm/core/ComboBox/ComboBox.js +25 -32
  134. package/esm/core/ComboBox/ComboBoxDropdown.js +1 -2
  135. package/esm/core/ComboBox/ComboBoxEndIcon.js +1 -1
  136. package/esm/core/ComboBox/ComboBoxInput.js +21 -20
  137. package/esm/core/ComboBox/ComboBoxMenu.js +3 -4
  138. package/esm/core/ComboBox/ComboBoxMenuItem.js +2 -2
  139. package/esm/core/ComboBox/helpers.js +4 -5
  140. package/esm/core/DatePicker/DatePicker.js +32 -32
  141. package/esm/core/Dialog/Dialog.js +12 -5
  142. package/esm/core/Dialog/DialogBackdrop.js +1 -1
  143. package/esm/core/Dialog/DialogContext.d.ts +11 -0
  144. package/esm/core/Dialog/DialogMain.js +16 -22
  145. package/esm/core/DropdownMenu/DropdownMenu.js +6 -8
  146. package/esm/core/ExpandableBlock/ExpandableBlock.js +2 -2
  147. package/esm/core/FileUpload/FileEmptyCard.js +1 -1
  148. package/esm/core/FileUpload/FileUpload.d.ts +3 -4
  149. package/esm/core/FileUpload/FileUpload.js +5 -8
  150. package/esm/core/FileUpload/FileUploadCard.js +9 -10
  151. package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -0
  152. package/esm/core/FileUpload/FileUploadTemplate.js +1 -0
  153. package/esm/core/InformationPanel/InformationPanel.js +1 -4
  154. package/esm/core/LabeledInput/LabeledInput.js +1 -1
  155. package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -1
  156. package/esm/core/Menu/Menu.js +3 -4
  157. package/esm/core/Menu/MenuItem.js +8 -11
  158. package/esm/core/Modal/Modal.d.ts +8 -9
  159. package/esm/core/Modal/Modal.js +3 -10
  160. package/esm/core/SearchBox/SearchBox.js +12 -12
  161. package/esm/core/Select/Select.js +12 -17
  162. package/esm/core/SideNavigation/SideNavigation.js +2 -2
  163. package/esm/core/Slider/Slider.js +16 -19
  164. package/esm/core/Slider/Thumb.js +1 -1
  165. package/esm/core/StatusMessage/StatusMessage.js +1 -1
  166. package/esm/core/Stepper/Stepper.js +1 -1
  167. package/esm/core/Stepper/StepperStep.js +1 -1
  168. package/esm/core/Table/Table.js +15 -15
  169. package/esm/core/Table/TablePaginator.js +2 -3
  170. package/esm/core/Table/TableRowMemoized.js +38 -45
  171. package/esm/core/Table/actionHandlers/expandHandler.js +3 -3
  172. package/esm/core/Table/actionHandlers/filterHandler.js +4 -5
  173. package/esm/core/Table/actionHandlers/selectHandler.js +6 -6
  174. package/esm/core/Table/cells/DefaultCell.js +1 -1
  175. package/esm/core/Table/cells/EditableCell.js +6 -12
  176. package/esm/core/Table/columns/actionColumn.js +3 -6
  177. package/esm/core/Table/columns/expanderColumn.js +3 -3
  178. package/esm/core/Table/columns/selectionColumn.js +4 -4
  179. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
  180. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
  181. package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
  182. package/esm/core/Table/filters/TextFilter/TextFilter.js +1 -2
  183. package/esm/core/Table/hooks/useResizeColumns.js +16 -22
  184. package/esm/core/Table/hooks/useScrollToRow.js +1 -2
  185. package/esm/core/Table/hooks/useStickyColumns.js +3 -5
  186. package/esm/core/Table/hooks/useSubRowFiltering.js +2 -4
  187. package/esm/core/Tabs/Tabs.js +13 -16
  188. package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
  189. package/esm/core/ThemeProvider/ThemeProvider.d.ts +2 -3
  190. package/esm/core/ThemeProvider/ThemeProvider.js +15 -14
  191. package/esm/core/Tile/Tile.js +2 -3
  192. package/esm/core/TimePicker/TimePicker.js +13 -13
  193. package/esm/core/Toast/Toast.d.ts +5 -10
  194. package/esm/core/Toast/Toast.js +18 -17
  195. package/esm/core/Toast/Toaster.d.ts +24 -26
  196. package/esm/core/Toast/Toaster.js +85 -121
  197. package/esm/core/Toast/index.d.ts +1 -4
  198. package/esm/core/Toast/index.js +1 -3
  199. package/esm/core/TransferList/TransferList.js +3 -4
  200. package/esm/core/Tree/Tree.js +9 -13
  201. package/esm/core/Tree/TreeNode.js +9 -10
  202. package/esm/core/index.d.ts +1 -2
  203. package/esm/core/index.js +1 -1
  204. package/esm/core/utils/color/ColorValue.js +9 -15
  205. package/esm/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
  206. package/esm/core/utils/components/FocusTrap.js +4 -4
  207. package/esm/core/utils/components/MiddleTextTruncation.js +1 -2
  208. package/esm/core/utils/components/Popover.d.ts +1 -1
  209. package/esm/core/utils/components/Popover.js +5 -8
  210. package/esm/core/utils/components/Resizer.js +7 -6
  211. package/esm/core/utils/components/VirtualScroll.js +14 -21
  212. package/esm/core/utils/functions/dom.d.ts +0 -8
  213. package/esm/core/utils/functions/dom.js +2 -21
  214. package/esm/core/utils/functions/polymorphic.d.ts +1 -1
  215. package/esm/core/utils/functions/polymorphic.js +1 -1
  216. package/esm/core/utils/functions/supports.js +1 -1
  217. package/esm/core/utils/hooks/index.d.ts +0 -1
  218. package/esm/core/utils/hooks/index.js +0 -1
  219. package/esm/core/utils/hooks/useContainerWidth.js +1 -1
  220. package/esm/core/utils/hooks/useDragAndDrop.js +8 -10
  221. package/esm/core/utils/hooks/useEventListener.js +1 -1
  222. package/esm/core/utils/hooks/useGlobals.d.ts +9 -2
  223. package/esm/core/utils/hooks/useGlobals.js +6 -4
  224. package/esm/core/utils/hooks/useId.js +1 -2
  225. package/esm/core/utils/hooks/useIntersection.js +2 -3
  226. package/esm/core/utils/hooks/useMediaQuery.js +6 -8
  227. package/esm/core/utils/hooks/useOverflow.js +1 -2
  228. package/esm/core/utils/hooks/useResizeObserver.js +3 -4
  229. package/esm/styles.js +1 -4
  230. package/package.json +2 -2
  231. package/styles.css +19 -20
  232. package/cjs/core/Toast/ToastWrapper.d.ts +0 -10
  233. package/cjs/core/Toast/ToastWrapper.js +0 -49
  234. package/cjs/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
  235. package/cjs/core/utils/hooks/useIsThemeAlreadySet.js +0 -54
  236. package/esm/core/Toast/ToastWrapper.d.ts +0 -10
  237. package/esm/core/Toast/ToastWrapper.js +0 -20
  238. package/esm/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
  239. package/esm/core/utils/hooks/useIsThemeAlreadySet.js +0 -27
@@ -3,130 +3,94 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import * as React from 'react';
6
- import * as ReactDOM from 'react-dom';
7
- import { getContainer, getDocument } from '../utils/index.js';
8
- import { ToastWrapper } from './ToastWrapper.js';
9
- const TOASTS_CONTAINER_ID = 'iui-toasts-container';
10
- export default class Toaster {
11
- constructor() {
12
- this.toasts = [];
13
- this.lastId = 0;
14
- this.settings = {
15
- order: 'descending',
6
+ import cx from 'classnames';
7
+ import { Box, useSafeContext } from '../utils/index.js';
8
+ import { Toast } from './Toast.js';
9
+ // ----------------------------------------------------------------------------
10
+ export const useToaster = () => {
11
+ const dispatch = useSafeContext(ToasterDispatchContext);
12
+ const showToast = React.useCallback((category) => (content, options) => {
13
+ const id = nextId();
14
+ dispatch({
15
+ type: 'add',
16
+ toast: { ...options, id, content, category },
17
+ });
18
+ return { close: () => dispatch({ type: 'remove', id }) };
19
+ }, [dispatch]);
20
+ return {
21
+ positive: showToast('positive'),
22
+ informational: showToast('informational'),
23
+ negative: showToast('negative'),
24
+ warning: showToast('warning'),
25
+ closeAll: () => {
26
+ dispatch({ type: 'close-all' });
27
+ },
28
+ setSettings: (settings) => {
29
+ dispatch({ type: 'settings', settings });
30
+ },
31
+ };
32
+ };
33
+ // ----------------------------------------------------------------------------
34
+ export const Toaster = () => {
35
+ const { toasts, settings } = useSafeContext(ToasterStateContext);
36
+ return (React.createElement(Box, { className: cx(`iui-toast-wrapper`, `iui-placement-${settings.placement}`) }, toasts.map((toastProps) => {
37
+ return React.createElement(Toast, { key: toastProps.id, ...toastProps });
38
+ })));
39
+ };
40
+ // ----------------------------------------------------------------------------
41
+ export const ToastProvider = ({ children }) => {
42
+ const [toasterState, dispatch] = React.useReducer(toastReducer, {
43
+ toasts: [],
44
+ settings: {
45
+ order: 'auto',
16
46
  placement: 'top',
47
+ },
48
+ });
49
+ return (React.createElement(ToasterDispatchContext.Provider, { value: dispatch },
50
+ React.createElement(ToasterStateContext.Provider, { value: toasterState }, children)));
51
+ };
52
+ const toastReducer = (state, action) => {
53
+ if (action.type === 'add') {
54
+ let order = state.settings.order;
55
+ if (order === 'auto') {
56
+ order = state.settings.placement.startsWith('top')
57
+ ? 'descending'
58
+ : 'ascending';
59
+ }
60
+ return {
61
+ ...state,
62
+ toasts: [
63
+ ...(order === 'ascending' ? state.toasts : []),
64
+ action.toast,
65
+ ...(order === 'descending' ? state.toasts : []),
66
+ ],
17
67
  };
18
- this.toastsRef = React.createRef();
19
- this.isInitialized = false;
20
- // Create container on demand.
21
- // Cannot do it in constructor, because SSG/SSR apps would fail.
22
- this.asyncInit = async () => {
23
- var _a, _b;
24
- if (this.isInitialized) {
25
- return;
26
- }
27
- const container = (_a = getContainer(TOASTS_CONTAINER_ID)) !== null && _a !== void 0 ? _a : (_b = getDocument()) === null || _b === void 0 ? void 0 : _b.body;
28
- if (!container) {
29
- return;
30
- }
31
- this.isInitialized = true;
32
- const toastWrapper = React.createElement(ToastWrapper, { ref: this.toastsRef });
33
- const _ReactDOM = ReactDOM; // eslint-disable-line @typescript-eslint/no-explicit-any
34
- // v18 mode
35
- if (_ReactDOM.createRoot) {
36
- const _ReactDOMInternals = _ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
37
- // suppress warning about importing createRoot from react-dom/client
38
- if (_ReactDOMInternals) {
39
- _ReactDOMInternals.usingClientEntryPoint = true;
40
- }
41
- const root = _ReactDOM.createRoot(container);
42
- root.render(toastWrapper);
43
- // revert suppression, not to influence users app
44
- if (_ReactDOMInternals) {
45
- _ReactDOMInternals.usingClientEntryPoint = false;
46
- }
47
- }
48
- else {
49
- // v17 and before
50
- ReactDOM.render(toastWrapper, container);
51
- }
52
- };
53
- }
54
- /**
55
- * Set global Toaster settings for toasts order and placement.
56
- * Settings will be applied to new toasts on the page.
57
- */
58
- setSettings(newSettings) {
59
- var _a, _b, _c;
60
- (_a = newSettings.placement) !== null && _a !== void 0 ? _a : (newSettings.placement = this.settings.placement);
61
- (_b = newSettings.order) !== null && _b !== void 0 ? _b : (newSettings.order = ((_c = newSettings.placement) === null || _c === void 0 ? void 0 : _c.startsWith('bottom'))
62
- ? 'ascending'
63
- : 'descending');
64
- this.settings = newSettings;
65
- this.asyncInit().then(() => {
66
- var _a, _b;
67
- (_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setPlacement((_b = this.settings.placement) !== null && _b !== void 0 ? _b : 'top');
68
- });
69
- }
70
- positive(content, options) {
71
- return this.createToast(content, 'positive', options);
72
- }
73
- informational(content, options) {
74
- return this.createToast(content, 'informational', options);
75
- }
76
- negative(content, options) {
77
- return this.createToast(content, 'negative', options);
78
- }
79
- warning(content, options) {
80
- return this.createToast(content, 'warning', options);
81
68
  }
82
- createToast(content, category, options) {
83
- ++this.lastId;
84
- const currentId = this.lastId;
85
- this.toasts = [
86
- ...(this.settings.order === 'ascending' ? this.toasts : []),
87
- {
88
- ...options,
89
- content,
90
- category,
91
- onRemove: () => {
92
- var _a;
93
- this.removeToast(currentId);
94
- (_a = options === null || options === void 0 ? void 0 : options.onRemove) === null || _a === void 0 ? void 0 : _a.call(options);
95
- },
96
- id: currentId,
97
- isVisible: true,
98
- },
99
- ...(this.settings.order === 'descending' ? this.toasts : []),
100
- ];
101
- this.updateView();
102
- return { close: () => this.closeToast(currentId) };
103
- }
104
- removeToast(id) {
105
- this.toasts = this.toasts.filter((toast) => toast.id !== id);
106
- this.updateView();
107
- }
108
- updateView() {
109
- this.asyncInit().then(() => {
110
- var _a;
111
- (_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setToasts(this.toasts);
112
- });
69
+ if (action.type === 'remove') {
70
+ return {
71
+ ...state,
72
+ toasts: state.toasts.filter((toast) => toast.id !== action.id),
73
+ };
113
74
  }
114
- closeToast(toastId) {
115
- this.toasts = this.toasts.map((toast) => {
116
- return {
117
- ...toast,
118
- isVisible: toast.id !== toastId,
119
- };
120
- });
121
- this.updateView();
75
+ if (action.type === 'close-all') {
76
+ return {
77
+ ...state,
78
+ toasts: state.toasts.map((toast) => ({ ...toast, isVisible: false })),
79
+ };
122
80
  }
123
- closeAll() {
124
- this.toasts = this.toasts.map((toast) => {
125
- return {
126
- ...toast,
127
- isVisible: false,
128
- };
129
- });
130
- this.updateView();
81
+ if (action.type === 'settings') {
82
+ return { ...state, settings: { ...state.settings, ...action.settings } };
131
83
  }
132
- }
84
+ return state;
85
+ };
86
+ // ----------------------------------------------------------------------------
87
+ export const ToasterStateContext = React.createContext(undefined);
88
+ ToasterStateContext.displayName = 'ToasterStateContext';
89
+ // ----------------------------------------------------------------------------
90
+ const ToasterDispatchContext = React.createContext(undefined);
91
+ ToasterDispatchContext.displayName = 'ToasterDispatchContext';
92
+ // ----------------------------------------------------------------------------
93
+ const nextId = (() => {
94
+ let count = 0;
95
+ return () => ++count;
96
+ })();
@@ -1,4 +1 @@
1
- import Toaster from './Toaster.js';
2
- export type { ToastOptions } from './Toaster.js';
3
- declare const toaster: Toaster;
4
- export default toaster;
1
+ export { useToaster } from './Toaster.js';
@@ -2,6 +2,4 @@
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
- import Toaster from './Toaster.js';
6
- const toaster = new Toaster();
7
- export default toaster;
5
+ export { useToaster } from './Toaster.js';
@@ -30,10 +30,9 @@ const TransferListListbox = React.forwardRef((props, ref) => {
30
30
  return focusableItems.filter((i) => !focusableItems.some((p) => p.contains(i.parentElement)));
31
31
  }, []);
32
32
  React.useEffect(() => {
33
- var _a;
34
33
  const items = getFocusableNodes();
35
34
  if (focusedIndex != null) {
36
- (_a = items === null || items === void 0 ? void 0 : items[focusedIndex]) === null || _a === void 0 ? void 0 : _a.focus();
35
+ items?.[focusedIndex]?.focus();
37
36
  return;
38
37
  }
39
38
  }, [focusedIndex, getFocusableNodes]);
@@ -42,10 +41,10 @@ const TransferListListbox = React.forwardRef((props, ref) => {
42
41
  return;
43
42
  }
44
43
  const items = getFocusableNodes();
45
- if (!(items === null || items === void 0 ? void 0 : items.length)) {
44
+ if (!items?.length) {
46
45
  return;
47
46
  }
48
- const currentIndex = focusedIndex !== null && focusedIndex !== void 0 ? focusedIndex : 0;
47
+ const currentIndex = focusedIndex ?? 0;
49
48
  switch (event.key) {
50
49
  case 'ArrowDown': {
51
50
  setFocusedIndex(Math.min(currentIndex + 1, items.length - 1));
@@ -73,10 +73,10 @@ export const Tree = (props) => {
73
73
  return;
74
74
  }
75
75
  const items = getFocusableNodes();
76
- if (!(items === null || items === void 0 ? void 0 : items.length)) {
76
+ if (!items?.length) {
77
77
  return;
78
78
  }
79
- const activeIndex = items.findIndex((el) => { var _a; return el.contains((_a = treeRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.activeElement); });
79
+ const activeIndex = items.findIndex((el) => el.contains(treeRef.current?.ownerDocument.activeElement));
80
80
  const currentIndex = activeIndex > -1 ? activeIndex : 0;
81
81
  switch (event.key) {
82
82
  case 'ArrowUp': {
@@ -126,20 +126,18 @@ export const Tree = (props) => {
126
126
  return [flatList, firstLevelNodes];
127
127
  }, [data, getNode]);
128
128
  const itemRenderer = React.useCallback((index) => {
129
- var _a, _b, _c, _d;
130
129
  const node = flatNodesList[index];
131
130
  return (React.createElement(TreeContext.Provider, { key: node.nodeProps.nodeId, value: {
132
131
  nodeDepth: node.depth,
133
132
  subNodeIds: node.subNodeIds,
134
133
  groupSize: node.depth === 0
135
134
  ? firstLevelNodesList.length
136
- : (_c = (_b = (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.subNodeIds) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0,
135
+ : node.parentNode?.subNodeIds?.length ?? 0,
137
136
  indexInGroup: node.indexInGroup,
138
- parentNodeId: (_d = node.parentNode) === null || _d === void 0 ? void 0 : _d.nodeProps.nodeId,
137
+ parentNodeId: node.parentNode?.nodeProps.nodeId,
139
138
  scrollToParent: node.parentNode
140
139
  ? () => {
141
- var _a;
142
- const parentNodeId = (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.nodeProps.nodeId;
140
+ const parentNodeId = node.parentNode?.nodeProps.nodeId;
143
141
  const parentNodeIndex = flatNodesList.findIndex((n) => n.nodeProps.nodeId === parentNodeId);
144
142
  setScrollToIndex(parentNodeIndex);
145
143
  }
@@ -153,11 +151,10 @@ export const Tree = (props) => {
153
151
  }, [flatNodesList]);
154
152
  React.useEffect(() => {
155
153
  setTimeout(() => {
156
- var _a;
157
154
  if (scrollToIndex !== undefined) {
158
155
  const nodeId = flatNodesListRef.current[scrollToIndex].nodeProps.nodeId;
159
- const nodeElement = (_a = treeRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.querySelector(`#${nodeId}`);
160
- nodeElement === null || nodeElement === void 0 ? void 0 : nodeElement.focus();
156
+ const nodeElement = treeRef.current?.ownerDocument.querySelector(`#${nodeId}`);
157
+ nodeElement?.focus();
161
158
  // Need to reset that if navigating with mouse and keyboard,
162
159
  // e.g. pressing arrow left to go to parent node and then with mouse
163
160
  // clicking some other child node and then pressing arrow left
@@ -166,13 +163,12 @@ export const Tree = (props) => {
166
163
  });
167
164
  }, [scrollToIndex]);
168
165
  const handleFocus = (event) => {
169
- var _a, _b;
170
- if ((_a = treeRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.relatedTarget)) {
166
+ if (treeRef.current?.contains(event.relatedTarget)) {
171
167
  return;
172
168
  }
173
169
  const items = getFocusableNodes();
174
170
  if (items.length > 0) {
175
- (_b = items[focusedIndex.current]) === null || _b === void 0 ? void 0 : _b.focus();
171
+ items[focusedIndex.current]?.focus();
176
172
  }
177
173
  };
178
174
  return (React.createElement(React.Fragment, null, enableVirtualization ? (React.createElement(VirtualizedTree, { flatNodesList: flatNodesList, itemRenderer: itemRenderer, scrollToIndex: scrollToIndex, onFocus: handleFocus, onKeyDown: handleKeyDown, ref: treeRef, className: className, style: style, ...rest })) : (React.createElement(TreeElement, { onKeyDown: handleKeyDown, onFocus: handleFocus, className: className, style: style, ref: treeRef, ...rest }, flatNodesList.map((_, i) => itemRenderer(i))))));
@@ -32,11 +32,10 @@ export const TreeNode = (props) => {
32
32
  const [isFocused, setIsFocused] = React.useState(false);
33
33
  const nodeRef = React.useRef(null);
34
34
  const onKeyDown = (event) => {
35
- var _a, _b, _c, _d, _e, _f;
36
35
  if (event.altKey) {
37
36
  return;
38
37
  }
39
- const isNodeFocused = nodeRef.current === ((_a = nodeRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument.activeElement);
38
+ const isNodeFocused = nodeRef.current === nodeRef.current?.ownerDocument.activeElement;
40
39
  switch (event.key) {
41
40
  case 'ArrowLeft': {
42
41
  event.preventDefault();
@@ -46,19 +45,19 @@ export const TreeNode = (props) => {
46
45
  break;
47
46
  }
48
47
  if (parentNodeId) {
49
- scrollToParent === null || scrollToParent === void 0 ? void 0 : scrollToParent();
48
+ scrollToParent?.();
50
49
  break;
51
50
  }
52
51
  // If it is top level node (doesn't have parent node), then do nothing.
53
52
  break;
54
53
  }
55
54
  const focusableElements = getFocusableElements(nodeRef.current);
56
- const currentIndex = focusableElements.indexOf((_b = nodeRef.current) === null || _b === void 0 ? void 0 : _b.ownerDocument.activeElement);
55
+ const currentIndex = focusableElements.indexOf(nodeRef.current?.ownerDocument.activeElement);
57
56
  if (currentIndex === 0) {
58
- (_c = nodeRef.current) === null || _c === void 0 ? void 0 : _c.focus();
57
+ nodeRef.current?.focus();
59
58
  }
60
59
  else {
61
- (_d = focusableElements[currentIndex - 1]) === null || _d === void 0 ? void 0 : _d.focus();
60
+ focusableElements[currentIndex - 1]?.focus();
62
61
  }
63
62
  break;
64
63
  }
@@ -70,10 +69,10 @@ export const TreeNode = (props) => {
70
69
  onExpanded(nodeId, true);
71
70
  break;
72
71
  }
73
- (_e = focusableElements[0]) === null || _e === void 0 ? void 0 : _e.focus();
72
+ focusableElements[0]?.focus();
74
73
  break;
75
74
  }
76
- const currentIndex = focusableElements.indexOf((_f = nodeRef.current) === null || _f === void 0 ? void 0 : _f.ownerDocument.activeElement);
75
+ const currentIndex = focusableElements.indexOf(nodeRef.current?.ownerDocument.activeElement);
77
76
  if (currentIndex < focusableElements.length - 1) {
78
77
  focusableElements[currentIndex + 1].focus();
79
78
  break;
@@ -89,7 +88,7 @@ export const TreeNode = (props) => {
89
88
  }
90
89
  event.preventDefault();
91
90
  if (!isDisabled) {
92
- onSelected === null || onSelected === void 0 ? void 0 : onSelected(nodeId, !isSelected);
91
+ onSelected?.(nodeId, !isSelected);
93
92
  }
94
93
  break;
95
94
  }
@@ -111,7 +110,7 @@ export const TreeNode = (props) => {
111
110
  React.createElement(Box, { className: cx('iui-tree-node', {
112
111
  'iui-active': isSelected,
113
112
  'iui-disabled': isDisabled,
114
- }), style: { '--level': nodeDepth }, onClick: () => !isDisabled && (onSelected === null || onSelected === void 0 ? void 0 : onSelected(nodeId, !isSelected)) },
113
+ }), style: { '--level': nodeDepth }, onClick: () => !isDisabled && onSelected?.(nodeId, !isSelected) },
115
114
  checkbox && (React.createElement(Box, { className: 'iui-tree-node-checkbox' }, React.isValidElement(checkbox)
116
115
  ? React.cloneElement(checkbox, {
117
116
  tabIndex: isFocused ? 0 : -1,
@@ -51,8 +51,7 @@ export { Textarea } from './Textarea/index.js';
51
51
  export { Tile } from './Tile/index.js';
52
52
  export { TimePicker } from './TimePicker/index.js';
53
53
  export type { MeridiemType } from './TimePicker/index.js';
54
- export { default as toaster } from './Toast/index.js';
55
- export type { ToastOptions } from './Toast/index.js';
54
+ export { useToaster } from './Toast/index.js';
56
55
  export { ThemeProvider } from './ThemeProvider/index.js';
57
56
  export type { ThemeType } from './ThemeProvider/index.js';
58
57
  export { ToggleSwitch } from './ToggleSwitch/index.js';
package/esm/core/index.js CHANGED
@@ -50,7 +50,7 @@ export { Tag, TagContainer } from './Tag/index.js';
50
50
  export { Textarea } from './Textarea/index.js';
51
51
  export { Tile } from './Tile/index.js';
52
52
  export { TimePicker } from './TimePicker/index.js';
53
- export { default as toaster } from './Toast/index.js';
53
+ export { useToaster } from './Toast/index.js';
54
54
  export { ThemeProvider } from './ThemeProvider/index.js';
55
55
  export { ToggleSwitch } from './ToggleSwitch/index.js';
56
56
  export { Tooltip } from './Tooltip/index.js';
@@ -110,27 +110,24 @@ export class ColorValue {
110
110
  * This allows component builders to know if they received bad input from user.
111
111
  */
112
112
  static fromString(val, defaultColorIfNotParsed) {
113
- const [tbgr, hue] = this.computeTbgrFromString(val, defaultColorIfNotParsed === null || defaultColorIfNotParsed === void 0 ? void 0 : defaultColorIfNotParsed.toTbgr());
113
+ const [tbgr, hue] = this.computeTbgrFromString(val, defaultColorIfNotParsed?.toTbgr());
114
114
  return new ColorValue(tbgr, hue);
115
115
  }
116
116
  /** Create a ColorValue from hue, saturation, lightness values. */
117
117
  static fromHSL(hsl) {
118
- var _a;
119
- const alpha = (_a = hsl.a) !== null && _a !== void 0 ? _a : 1;
118
+ const alpha = hsl.a ?? 1;
120
119
  return new ColorValue(this.computeTbgrFromHSL(hsl.h / 360, hsl.s / 100, hsl.l / 100, Math.round((1 - alpha) * 255)), hsl.h);
121
120
  }
122
121
  /** Create a ColorValue from an RgbColor */
123
122
  static fromRGB(rgb) {
124
- var _a;
125
- const alpha = (_a = rgb.a) !== null && _a !== void 0 ? _a : 1;
123
+ const alpha = rgb.a ?? 1;
126
124
  return ColorValue.fromRgbt(rgb.r, rgb.g, rgb.b, Math.round((1 - alpha) * 255));
127
125
  }
128
126
  /**
129
127
  * Create a ColorValue from an HsvColor
130
128
  */
131
129
  static fromHSV(hsv) {
132
- var _a;
133
- const alpha = (_a = hsv.a) !== null && _a !== void 0 ? _a : 1;
130
+ const alpha = hsv.a ?? 1;
134
131
  const transparency = Math.round((1 - alpha) * 255);
135
132
  // Check for simple case first.
136
133
  if (!hsv.s || hsv.h === -1) {
@@ -481,33 +478,30 @@ export class ColorValue {
481
478
  }
482
479
  /** Convert the 0xTTBBGGRR color to a string of the form "rgba(r,g,b,a)" where the color components are specified in decimal and the alpha component is a fraction. */
483
480
  toRgbString(includeAlpha) {
484
- var _a;
485
481
  const rgb = this.toRgbColor();
486
482
  const rgbString = `${rgb.r}, ${rgb.g}, ${rgb.b}`;
487
483
  if (includeAlpha) {
488
- const alpha = (_a = rgb.a) !== null && _a !== void 0 ? _a : 1;
484
+ const alpha = rgb.a ?? 1;
489
485
  return `rgba(${rgbString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
490
486
  }
491
487
  return `rgb(${rgbString})`;
492
488
  }
493
489
  /** Convert this ColorValue to a string in the form "hsl(h,s,l) or hsla(h,s,l,a)" - i.e hsl(120,50%,50%). */
494
490
  toHslString(includeAlpha) {
495
- var _a, _b;
496
491
  const hsl = this.toHslColor();
497
- const hslString = `${ColorValue.getFormattedColorNumber((_a = this._hue) !== null && _a !== void 0 ? _a : hsl.h)}, ${ColorValue.getFormattedColorNumber(hsl.s)}%, ${ColorValue.getFormattedColorNumber(hsl.l)}%`;
492
+ const hslString = `${ColorValue.getFormattedColorNumber(this._hue ?? hsl.h)}, ${ColorValue.getFormattedColorNumber(hsl.s)}%, ${ColorValue.getFormattedColorNumber(hsl.l)}%`;
498
493
  if (includeAlpha) {
499
- const alpha = (_b = hsl.a) !== null && _b !== void 0 ? _b : 1;
494
+ const alpha = hsl.a ?? 1;
500
495
  return `hsla(${hslString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
501
496
  }
502
497
  return `hsl(${hslString})`;
503
498
  }
504
499
  /** Convert this ColorValue to a string in the form "hsv(h,s,v) or hsva(h,s,v,a)" - i.e hsv(120,50%,50%). */
505
500
  toHsvString(includeAlpha) {
506
- var _a, _b;
507
501
  const hsv = this.toHsvColor();
508
- const hsvString = `${(_a = this._hue) !== null && _a !== void 0 ? _a : hsv.h}, ${hsv.s}%, ${hsv.v}%`;
502
+ const hsvString = `${this._hue ?? hsv.h}, ${hsv.s}%, ${hsv.v}%`;
509
503
  if (includeAlpha) {
510
- const alpha = (_b = hsv.a) !== null && _b !== void 0 ? _b : 1;
504
+ const alpha = hsv.a ?? 1;
511
505
  return `hsva(${hsvString}, ${ColorValue.getFormattedColorNumber(alpha, 2)})`;
512
506
  }
513
507
  return `hsv(${hsvString})`;
@@ -16,10 +16,9 @@ import { getWindow } from '../functions/index.js';
16
16
  export const AutoclearingHiddenLiveRegion = ({ text = '' }) => {
17
17
  const [maybeText, setMaybeText] = React.useState(text);
18
18
  React.useEffect(() => {
19
- var _a;
20
19
  setMaybeText(text);
21
- const timeout = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.setTimeout(() => setMaybeText(''), 5000);
22
- return () => { var _a; return void ((_a = getWindow()) === null || _a === void 0 ? void 0 : _a.clearTimeout(timeout)); };
20
+ const timeout = getWindow()?.setTimeout(() => setMaybeText(''), 5000);
21
+ return () => void getWindow()?.clearTimeout(timeout);
23
22
  }, [text]);
24
23
  return (React.createElement(VisuallyHidden, { as: 'div', "aria-live": 'polite', "aria-atomic": 'true' }, maybeText));
25
24
  };
@@ -21,19 +21,19 @@ export const FocusTrap = (props) => {
21
21
  const onFirstFocus = (event) => {
22
22
  const [firstElement, lastElement] = getFirstLastFocusables();
23
23
  if (event.relatedTarget === firstElement) {
24
- lastElement === null || lastElement === void 0 ? void 0 : lastElement.focus();
24
+ lastElement?.focus();
25
25
  }
26
26
  else {
27
- firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
27
+ firstElement?.focus();
28
28
  }
29
29
  };
30
30
  const onLastFocus = (event) => {
31
31
  const [firstElement, lastElement] = getFirstLastFocusables();
32
32
  if (event.relatedTarget === lastElement) {
33
- firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
33
+ firstElement?.focus();
34
34
  }
35
35
  else {
36
- lastElement === null || lastElement === void 0 ? void 0 : lastElement.focus();
36
+ lastElement?.focus();
37
37
  }
38
38
  };
39
39
  return (React.createElement(React.Fragment, null,
@@ -22,7 +22,6 @@ const ELLIPSIS_CHAR = '…';
22
22
  * />
23
23
  */
24
24
  export const MiddleTextTruncation = (props) => {
25
- var _a;
26
25
  const { text, endCharsCount = 6, textRenderer, style, ...rest } = props;
27
26
  const [ref, visibleCount] = useOverflow(text);
28
27
  const truncatedText = React.useMemo(() => {
@@ -39,6 +38,6 @@ export const MiddleTextTruncation = (props) => {
39
38
  flexGrow: 1,
40
39
  whiteSpace: 'nowrap',
41
40
  ...style,
42
- }, ref: ref, ...rest }, (_a = textRenderer === null || textRenderer === void 0 ? void 0 : textRenderer(truncatedText, text)) !== null && _a !== void 0 ? _a : truncatedText));
41
+ }, ref: ref, ...rest }, textRenderer?.(truncatedText, text) ?? truncatedText));
43
42
  };
44
43
  export default MiddleTextTruncation;
@@ -25,7 +25,7 @@ export declare type PopoverProps = {
25
25
  * with pre-configured props and plugins (e.g. lazy mounting, focus, etc).
26
26
  * @private
27
27
  */
28
- export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "disabled" | "className" | "role" | "offset" | "children" | "content" | "plugins" | "theme" | "placement" | "trigger" | "visible" | "render" | "animateFill" | "appendTo" | "aria" | "delay" | "duration" | "followCursor" | "getReferenceClientRect" | "hideOnClick" | "ignoreAttributes" | "inlinePositioning" | "interactive" | "interactiveBorder" | "interactiveDebounce" | "moveTransition" | "popperOptions" | "showOnCreate" | "sticky" | "touch" | "triggerTarget" | "onAfterUpdate" | "onBeforeUpdate" | "onCreate" | "onDestroy" | "onHidden" | "onHide" | "onMount" | "onShow" | "onShown" | "onTrigger" | "onUntrigger" | "onClickOutside" | "allowHTML" | "animation" | "arrow" | "inertia" | "maxWidth" | "zIndex" | "singleton" | "reference"> & React.RefAttributes<unknown>>;
28
+ export declare const Popover: React.ForwardRefExoticComponent<Pick<PopoverProps, "disabled" | "className" | "role" | "offset" | "children" | "content" | "plugins" | "placement" | "trigger" | "visible" | "render" | "animateFill" | "appendTo" | "aria" | "delay" | "duration" | "followCursor" | "getReferenceClientRect" | "hideOnClick" | "ignoreAttributes" | "inlinePositioning" | "interactive" | "interactiveBorder" | "interactiveDebounce" | "moveTransition" | "popperOptions" | "showOnCreate" | "sticky" | "touch" | "triggerTarget" | "onAfterUpdate" | "onBeforeUpdate" | "onCreate" | "onDestroy" | "onHidden" | "onHide" | "onMount" | "onShow" | "onShown" | "onTrigger" | "onUntrigger" | "onClickOutside" | "allowHTML" | "animation" | "arrow" | "inertia" | "maxWidth" | "theme" | "zIndex" | "singleton" | "reference"> & React.RefAttributes<unknown>>;
29
29
  /**
30
30
  * Plugin to hide Popover when either Esc key is pressed,
31
31
  * or when the content inside is not tabbable and Tab key is pressed.
@@ -13,7 +13,6 @@ import { ThemeContext } from '../../ThemeProvider/ThemeContext.js';
13
13
  * @private
14
14
  */
15
15
  export const Popover = React.forwardRef((props, ref) => {
16
- var _a;
17
16
  const [mounted, setMounted] = React.useState(false);
18
17
  const themeInfo = React.useContext(ThemeContext);
19
18
  const isDomAvailable = useIsClient();
@@ -30,15 +29,14 @@ export const Popover = React.forwardRef((props, ref) => {
30
29
  const removeTabIndex = {
31
30
  fn: () => ({
32
31
  onCreate: (instance) => {
33
- var _a;
34
- (_a = instance.popper.firstElementChild) === null || _a === void 0 ? void 0 : _a.removeAttribute('tabindex');
32
+ instance.popper.firstElementChild?.removeAttribute('tabindex');
35
33
  },
36
34
  }),
37
35
  };
38
36
  const computedProps = {
39
37
  allowHTML: true,
40
38
  animation: false,
41
- appendTo: (el) => (themeInfo === null || themeInfo === void 0 ? void 0 : themeInfo.rootRef.current) || el.ownerDocument.body,
39
+ appendTo: (el) => themeInfo?.portalContainerRef?.current || el.ownerDocument.body,
42
40
  arrow: false,
43
41
  duration: 0,
44
42
  interactive: true,
@@ -63,7 +61,7 @@ export const Popover = React.forwardRef((props, ref) => {
63
61
  modifiers: [
64
62
  { name: 'flip' },
65
63
  { name: 'preventOverflow', options: { padding: 0 } },
66
- ...(((_a = props.popperOptions) === null || _a === void 0 ? void 0 : _a.modifiers) || []),
64
+ ...(props.popperOptions?.modifiers || []),
67
65
  ],
68
66
  },
69
67
  };
@@ -78,9 +76,8 @@ export const Popover = React.forwardRef((props, ref) => {
78
76
  const clonedContent = React.isValidElement(props.content)
79
77
  ? React.cloneElement(props.content, {
80
78
  onClick: (e) => {
81
- var _a, _b;
82
79
  e.stopPropagation();
83
- (_b = (_a = props.content.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
80
+ props.content.props.onClick?.(e);
84
81
  },
85
82
  })
86
83
  : props.content;
@@ -97,7 +94,7 @@ export const hideOnEscOrTab = {
97
94
  /** @returns true if none of the children are tabbable */
98
95
  const shouldHideOnTab = () => {
99
96
  const descendents = Array.from(instance.popper.querySelectorAll('*'));
100
- return !descendents.some((el) => (el === null || el === void 0 ? void 0 : el.tabIndex) >= 0);
97
+ return !descendents.some((el) => el?.tabIndex >= 0);
101
98
  };
102
99
  const onKeyDown = (event) => {
103
100
  if (event.altKey) {
@@ -38,17 +38,18 @@ export const Resizer = (props) => {
38
38
  const originalUserSelect = ownerDocument.body.style.userSelect;
39
39
  ownerDocument.body.style.userSelect = 'none';
40
40
  const onResizePointerMove = (event) => {
41
- var _a, _b, _c, _d, _e, _f, _g;
42
41
  if (!elementRef.current) {
43
42
  return;
44
43
  }
45
44
  if (!isResizing.current) {
46
45
  isResizing.current = true;
47
- onResizeStart === null || onResizeStart === void 0 ? void 0 : onResizeStart();
46
+ onResizeStart?.();
48
47
  }
49
- const containerRect = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
50
- const clientX = getBoundedValue(event.clientX, (_b = containerRect === null || containerRect === void 0 ? void 0 : containerRect.left) !== null && _b !== void 0 ? _b : 0, (_d = (_c = containerRect === null || containerRect === void 0 ? void 0 : containerRect.right) !== null && _c !== void 0 ? _c : ownerDocument.documentElement.clientWidth) !== null && _d !== void 0 ? _d : 0);
51
- const clientY = getBoundedValue(event.clientY, (_e = containerRect === null || containerRect === void 0 ? void 0 : containerRect.top) !== null && _e !== void 0 ? _e : 0, (_g = (_f = containerRect === null || containerRect === void 0 ? void 0 : containerRect.bottom) !== null && _f !== void 0 ? _f : ownerDocument.documentElement.clientHeight) !== null && _g !== void 0 ? _g : 0);
48
+ const containerRect = containerRef?.current?.getBoundingClientRect();
49
+ const clientX = getBoundedValue(event.clientX, containerRect?.left ?? 0, containerRect?.right ?? ownerDocument.documentElement.clientWidth ?? 0);
50
+ const clientY = getBoundedValue(event.clientY, containerRect?.top ?? 0, containerRect?.bottom ??
51
+ ownerDocument.documentElement.clientHeight ??
52
+ 0);
52
53
  const diffX = initialPointerX - clientX;
53
54
  const diffY = initialPointerY - clientY;
54
55
  switch (resizer) {
@@ -129,7 +130,7 @@ export const Resizer = (props) => {
129
130
  if (elementRef.current) {
130
131
  ownerDocument.body.style.userSelect = originalUserSelect;
131
132
  isResizing.current = false;
132
- onResizeEnd === null || onResizeEnd === void 0 ? void 0 : onResizeEnd({
133
+ onResizeEnd?.({
133
134
  width,
134
135
  height,
135
136
  transform: `translate(${translateX}px, ${translateY}px)`,