@itwin/itwinui-react 3.14.1 → 3.15.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 (113) hide show
  1. package/CHANGELOG.md +76 -2
  2. package/DEV-cjs/core/Carousel/CarouselDotsList.js +11 -4
  3. package/DEV-cjs/core/Carousel/CarouselSlider.js +3 -3
  4. package/DEV-cjs/core/ColorPicker/ColorBuilder.js +72 -24
  5. package/DEV-cjs/core/ColorPicker/ColorInputPanel.js +35 -7
  6. package/DEV-cjs/core/ColorPicker/ColorPalette.js +21 -3
  7. package/DEV-cjs/core/ComboBox/ComboBox.js +2 -1
  8. package/DEV-cjs/core/ComboBox/ComboBoxMenu.js +2 -2
  9. package/DEV-cjs/core/DropdownMenu/DropdownMenu.js +20 -19
  10. package/DEV-cjs/core/Footer/Footer.js +7 -7
  11. package/DEV-cjs/core/Overlay/Overlay.js +0 -18
  12. package/DEV-cjs/core/Popover/Popover.js +17 -10
  13. package/DEV-cjs/core/Select/Select.js +4 -2
  14. package/DEV-cjs/core/Table/Table.js +51 -26
  15. package/DEV-cjs/core/Table/TableExpandableContentMemoized.js +47 -0
  16. package/DEV-cjs/core/Table/TableRowMemoized.js +0 -18
  17. package/DEV-cjs/core/Table/cells/DefaultCell.js +5 -5
  18. package/DEV-cjs/core/Table/hooks/useColumnDragAndDrop.js +12 -14
  19. package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +19 -1
  20. package/DEV-cjs/core/Toast/Toast.js +6 -7
  21. package/DEV-cjs/styles.js +1 -1
  22. package/DEV-cjs/utils/components/ShadowRoot.js +22 -8
  23. package/DEV-cjs/utils/hooks/useWarningLogger.js +5 -3
  24. package/DEV-esm/core/Carousel/CarouselDotsList.js +10 -5
  25. package/DEV-esm/core/Carousel/CarouselSlider.js +2 -3
  26. package/DEV-esm/core/ColorPicker/ColorBuilder.js +56 -22
  27. package/DEV-esm/core/ColorPicker/ColorInputPanel.js +37 -8
  28. package/DEV-esm/core/ColorPicker/ColorPalette.js +18 -3
  29. package/DEV-esm/core/ComboBox/ComboBox.js +2 -1
  30. package/DEV-esm/core/ComboBox/ComboBoxMenu.js +2 -2
  31. package/DEV-esm/core/DropdownMenu/DropdownMenu.js +20 -19
  32. package/DEV-esm/core/Footer/Footer.js +7 -7
  33. package/DEV-esm/core/Overlay/Overlay.js +1 -19
  34. package/DEV-esm/core/Popover/Popover.js +18 -10
  35. package/DEV-esm/core/Select/Select.js +4 -2
  36. package/DEV-esm/core/Table/Table.js +51 -26
  37. package/DEV-esm/core/Table/TableExpandableContentMemoized.js +33 -0
  38. package/DEV-esm/core/Table/TableRowMemoized.js +1 -21
  39. package/DEV-esm/core/Table/cells/DefaultCell.js +5 -5
  40. package/DEV-esm/core/Table/hooks/useColumnDragAndDrop.js +12 -6
  41. package/DEV-esm/core/ThemeProvider/ThemeProvider.js +19 -1
  42. package/DEV-esm/core/Toast/Toast.js +5 -5
  43. package/DEV-esm/styles.js +1 -1
  44. package/DEV-esm/utils/components/ShadowRoot.js +22 -8
  45. package/DEV-esm/utils/hooks/useWarningLogger.js +4 -3
  46. package/cjs/core/Buttons/SplitButton.d.ts +5 -0
  47. package/cjs/core/Carousel/CarouselDotsList.js +11 -4
  48. package/cjs/core/Carousel/CarouselSlider.js +3 -3
  49. package/cjs/core/ColorPicker/ColorBuilder.d.ts +22 -1
  50. package/cjs/core/ColorPicker/ColorBuilder.js +72 -24
  51. package/cjs/core/ColorPicker/ColorInputPanel.d.ts +18 -0
  52. package/cjs/core/ColorPicker/ColorInputPanel.js +35 -7
  53. package/cjs/core/ColorPicker/ColorPalette.d.ts +8 -0
  54. package/cjs/core/ColorPicker/ColorPalette.js +21 -3
  55. package/cjs/core/ComboBox/ComboBox.d.ts +3 -2
  56. package/cjs/core/ComboBox/ComboBox.js +2 -1
  57. package/cjs/core/ComboBox/ComboBoxMenu.js +2 -2
  58. package/cjs/core/DropdownMenu/DropdownMenu.d.ts +11 -0
  59. package/cjs/core/DropdownMenu/DropdownMenu.js +20 -19
  60. package/cjs/core/Footer/Footer.d.ts +5 -5
  61. package/cjs/core/Footer/Footer.js +7 -7
  62. package/cjs/core/Overlay/Overlay.js +0 -18
  63. package/cjs/core/Popover/Popover.d.ts +4 -1
  64. package/cjs/core/Popover/Popover.js +17 -10
  65. package/cjs/core/Select/Select.d.ts +14 -2
  66. package/cjs/core/Select/Select.js +4 -2
  67. package/cjs/core/Table/Table.js +51 -26
  68. package/cjs/core/Table/TableExpandableContentMemoized.d.ts +10 -0
  69. package/cjs/core/Table/TableExpandableContentMemoized.js +47 -0
  70. package/cjs/core/Table/TableRowMemoized.js +0 -18
  71. package/cjs/core/Table/cells/DefaultCell.js +5 -5
  72. package/cjs/core/Table/hooks/useColumnDragAndDrop.js +12 -14
  73. package/cjs/core/Table/utils.d.ts +2 -2
  74. package/cjs/core/ThemeProvider/ThemeProvider.js +19 -1
  75. package/cjs/core/Toast/Toast.js +6 -7
  76. package/cjs/styles.js +1 -1
  77. package/cjs/utils/components/ShadowRoot.js +22 -8
  78. package/cjs/utils/hooks/useWarningLogger.js +1 -0
  79. package/esm/core/Buttons/SplitButton.d.ts +5 -0
  80. package/esm/core/Carousel/CarouselDotsList.js +10 -5
  81. package/esm/core/Carousel/CarouselSlider.js +2 -3
  82. package/esm/core/ColorPicker/ColorBuilder.d.ts +22 -1
  83. package/esm/core/ColorPicker/ColorBuilder.js +56 -22
  84. package/esm/core/ColorPicker/ColorInputPanel.d.ts +18 -0
  85. package/esm/core/ColorPicker/ColorInputPanel.js +37 -8
  86. package/esm/core/ColorPicker/ColorPalette.d.ts +8 -0
  87. package/esm/core/ColorPicker/ColorPalette.js +18 -3
  88. package/esm/core/ComboBox/ComboBox.d.ts +3 -2
  89. package/esm/core/ComboBox/ComboBox.js +2 -1
  90. package/esm/core/ComboBox/ComboBoxMenu.js +2 -2
  91. package/esm/core/DropdownMenu/DropdownMenu.d.ts +11 -0
  92. package/esm/core/DropdownMenu/DropdownMenu.js +20 -19
  93. package/esm/core/Footer/Footer.d.ts +5 -5
  94. package/esm/core/Footer/Footer.js +7 -7
  95. package/esm/core/Overlay/Overlay.js +1 -19
  96. package/esm/core/Popover/Popover.d.ts +4 -1
  97. package/esm/core/Popover/Popover.js +18 -10
  98. package/esm/core/Select/Select.d.ts +14 -2
  99. package/esm/core/Select/Select.js +4 -2
  100. package/esm/core/Table/Table.js +51 -26
  101. package/esm/core/Table/TableExpandableContentMemoized.d.ts +10 -0
  102. package/esm/core/Table/TableExpandableContentMemoized.js +33 -0
  103. package/esm/core/Table/TableRowMemoized.js +1 -21
  104. package/esm/core/Table/cells/DefaultCell.js +5 -5
  105. package/esm/core/Table/hooks/useColumnDragAndDrop.js +12 -6
  106. package/esm/core/Table/utils.d.ts +2 -2
  107. package/esm/core/ThemeProvider/ThemeProvider.js +19 -1
  108. package/esm/core/Toast/Toast.js +5 -5
  109. package/esm/styles.js +1 -1
  110. package/esm/utils/components/ShadowRoot.js +22 -8
  111. package/esm/utils/hooks/useWarningLogger.js +1 -0
  112. package/package.json +8 -6
  113. package/styles.css +8 -8
@@ -5,7 +5,7 @@ import { FooterItem } from './FooterItem.js';
5
5
  import { FooterSeparator } from './FooterSeparator.js';
6
6
  import { FooterList } from './FooterList.js';
7
7
  import { Anchor } from '../Typography/Anchor.js';
8
- let footerTranslations = {
8
+ let defaultTranslatedTitles = {
9
9
  cookies: 'Cookies',
10
10
  legalNotices: 'Legal notices',
11
11
  privacy: 'Privacy',
@@ -19,27 +19,27 @@ export const defaultFooterElements = [
19
19
  },
20
20
  {
21
21
  key: 'termsOfService',
22
- title: footerTranslations.termsOfService,
22
+ title: defaultTranslatedTitles.termsOfService,
23
23
  url: 'https://connect-agreementportal.bentley.com/AgreementApp/Home/Eula/view/readonly/BentleyConnect',
24
24
  },
25
25
  {
26
26
  key: 'privacy',
27
- title: footerTranslations.privacy,
27
+ title: defaultTranslatedTitles.privacy,
28
28
  url: 'https://www.bentley.com/en/privacy-policy',
29
29
  },
30
30
  {
31
31
  key: 'termsOfUse',
32
- title: footerTranslations.termsOfUse,
32
+ title: defaultTranslatedTitles.termsOfUse,
33
33
  url: 'https://www.bentley.com/en/terms-of-use-and-select-online-agreement',
34
34
  },
35
35
  {
36
36
  key: 'cookies',
37
- title: footerTranslations.cookies,
37
+ title: defaultTranslatedTitles.cookies,
38
38
  url: 'https://www.bentley.com/en/cookie-policy',
39
39
  },
40
40
  {
41
41
  key: 'legalNotices',
42
- title: footerTranslations.legalNotices,
42
+ title: defaultTranslatedTitles.legalNotices,
43
43
  url: 'https://connect.bentley.com/Legal',
44
44
  },
45
45
  ];
@@ -48,7 +48,7 @@ export const Footer = Object.assign(
48
48
  let { children, customElements, translatedTitles, className, ...rest } =
49
49
  props;
50
50
  let titles = {
51
- ...footerTranslations,
51
+ ...defaultTranslatedTitles,
52
52
  ...translatedTitles,
53
53
  };
54
54
  let translatedElements = defaultFooterElements.map((element) => {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { Box, isUnitTest, polymorphic } from '../../utils/index.js';
2
+ import { Box, polymorphic } from '../../utils/index.js';
3
3
  let OverlayComponent = React.forwardRef((props, forwardedRef) => {
4
4
  let { content, children, ...rest } = props;
5
5
  return React.createElement(
@@ -14,7 +14,6 @@ let OverlayComponent = React.forwardRef((props, forwardedRef) => {
14
14
  });
15
15
  let OverlayHiddenContent = React.forwardRef((props, ref) => {
16
16
  let { children, ...rest } = props;
17
- useInertPolyfill();
18
17
  return React.createElement(
19
18
  Box,
20
19
  {
@@ -32,20 +31,3 @@ export const Overlay = Object.assign(OverlayComponent, {
32
31
  HiddenContent: OverlayHiddenContent,
33
32
  Overlay: OverlayOverlay,
34
33
  });
35
- let useInertPolyfill = () => {
36
- let loaded = React.useRef(false);
37
- let modulePath =
38
- 'https://cdn.jsdelivr.net/npm/wicg-inert@3.1.2/dist/inert.min.js';
39
- React.useEffect(() => {
40
- (async () => {
41
- if (
42
- !HTMLElement.prototype.hasOwnProperty('inert') &&
43
- !loaded.current &&
44
- !isUnitTest
45
- ) {
46
- await new Function('url', 'return import(url)')(modulePath);
47
- loaded.current = true;
48
- }
49
- })();
50
- }, []);
51
- };
@@ -26,7 +26,10 @@ type PopoverOptions = {
26
26
  /**
27
27
  * Middleware options.
28
28
  *
29
- * By default, `flip`, `shift` and `size` are enabled.
29
+ * By default, `flip`, `shift`, `size`, and `hide` are enabled.
30
+ *
31
+ * If the floating content gets hidden even when it shouldn't (e.g. some custom styles interfering with the trigger's
32
+ * hide detection) consider disabling the `hide` middleware.
30
33
  *
31
34
  * @see https://floating-ui.com/docs/middleware
32
35
  */
@@ -25,6 +25,7 @@ import {
25
25
  Box,
26
26
  ShadowRoot,
27
27
  cloneElementWithRef,
28
+ isUnitTest,
28
29
  mergeEventHandlers,
29
30
  useControlledState,
30
31
  useId,
@@ -47,21 +48,22 @@ export const usePopover = (options) => {
47
48
  } = options;
48
49
  let mergedInteractions = React.useMemo(
49
50
  () => ({
50
- click: true,
51
- dismiss: true,
52
- hover: false,
53
- focus: false,
54
51
  ...interactionsProp,
52
+ click: interactionsProp?.click ?? true,
53
+ dismiss: interactionsProp?.dismiss ?? true,
54
+ hover: interactionsProp?.hover ?? false,
55
+ focus: interactionsProp?.focus ?? false,
55
56
  }),
56
57
  [interactionsProp],
57
58
  );
58
59
  let tree = useFloatingTree();
59
60
  let middleware = React.useMemo(
60
61
  () => ({
61
- flip: true,
62
- shift: true,
63
- size: true,
64
62
  ...options.middleware,
63
+ flip: options.middleware?.flip ?? true,
64
+ shift: options.middleware?.shift ?? true,
65
+ size: options.middleware?.size ?? true,
66
+ hide: options.middleware?.hide || !isUnitTest,
65
67
  }),
66
68
  [options.middleware],
67
69
  );
@@ -166,17 +168,23 @@ export const usePopover = (options) => {
166
168
  maxInlineSize: `min(${2 * referenceWidth}px, 90vw)`,
167
169
  }
168
170
  : {}),
171
+ ...(middleware.hide &&
172
+ floating.middlewareData.hide?.referenceHidden && {
173
+ visibility: 'hidden',
174
+ }),
169
175
  ...userProps?.style,
170
176
  },
171
177
  }),
172
178
  [
173
- floating.floatingStyles,
174
179
  interactions,
175
- matchWidth,
176
- referenceWidth,
180
+ floating.floatingStyles,
181
+ floating.middlewareData.hide?.referenceHidden,
177
182
  middleware.size,
183
+ middleware.hide,
178
184
  availableHeight,
179
185
  maxHeight,
186
+ matchWidth,
187
+ referenceWidth,
180
188
  ],
181
189
  );
182
190
  let getReferenceProps = React.useCallback(
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { CommonProps } from '../../utils/index.js';
2
+ import type { CommonProps, PortalProps } from '../../utils/index.js';
3
3
  import { usePopover } from '../Popover/Popover.js';
4
4
  /**
5
5
  * Select component to select value from options.
@@ -182,7 +182,19 @@ export type CustomSelectProps<T> = SelectCommonProps & {
182
182
  /**
183
183
  * Props to customize Popover behavior.
184
184
  */
185
- popoverProps?: Pick<Parameters<typeof usePopover>[0], 'visible' | 'onVisibleChange' | 'placement' | 'matchWidth' | 'closeOnOutsideClick'>;
185
+ popoverProps?: Pick<Parameters<typeof usePopover>[0], 'visible' | 'onVisibleChange' | 'placement' | 'matchWidth' | 'closeOnOutsideClick'> & {
186
+ /**
187
+ * Middleware options.
188
+ *
189
+ * By default, `hide` is enabled. If the floating options get hidden even when they shouldn't (e.g. some custom
190
+ * styles interfering with the trigger's hide detection) consider disabling the `hide` middleware.
191
+ *
192
+ * @see https://floating-ui.com/docs/middleware
193
+ */
194
+ middleware?: {
195
+ hide?: boolean;
196
+ };
197
+ } & Pick<PortalProps, 'portal'>;
186
198
  /**
187
199
  * Props to pass to the select button (trigger) element.
188
200
  */
@@ -109,7 +109,7 @@ let CustomSelect = React.forwardRef((props, forwardedRef) => {
109
109
  multiple = false,
110
110
  triggerProps,
111
111
  status,
112
- popoverProps,
112
+ popoverProps: { portal = true, ...popoverProps } = {},
113
113
  styleType,
114
114
  ...rest
115
115
  } = props;
@@ -303,7 +303,9 @@ let CustomSelect = React.forwardRef((props, forwardedRef) => {
303
303
  popover.open &&
304
304
  React.createElement(
305
305
  Portal,
306
- null,
306
+ {
307
+ portal: portal,
308
+ },
307
309
  React.createElement(
308
310
  SelectListbox,
309
311
  {
@@ -48,6 +48,7 @@ import {
48
48
  } from './actionHandlers/index.js';
49
49
  import { SELECTION_CELL_ID } from './columns/index.js';
50
50
  import { ColumnHeader } from './ColumnHeader.js';
51
+ import { TableExpandableContentMemoized } from './TableExpandableContentMemoized.js';
51
52
  let singleRowSelectedAction = 'singleRowSelected';
52
53
  let shiftRowSelectedAction = 'shiftRowSelected';
53
54
  export const tableResizeStartAction = 'tableResizeStart';
@@ -239,6 +240,17 @@ export const Table = (props) => {
239
240
  ),
240
241
  [data, getSubRows],
241
242
  );
243
+ let [rowHasParent] = React.useState(() => new WeakSet());
244
+ let getSubRowsWithSubComponents = React.useCallback(
245
+ (originalRow) => {
246
+ if (!rowHasParent.has(originalRow)) {
247
+ rowHasParent.add(originalRow);
248
+ return [originalRow];
249
+ }
250
+ return originalRow.subRows || [];
251
+ },
252
+ [rowHasParent],
253
+ );
242
254
  let instance = useTable(
243
255
  {
244
256
  manualPagination: !paginatorRenderer,
@@ -251,7 +263,7 @@ export const Table = (props) => {
251
263
  filterTypes,
252
264
  selectSubRows,
253
265
  data,
254
- getSubRows,
266
+ getSubRows: subComponent ? getSubRowsWithSubComponents : getSubRows,
255
267
  initialState: {
256
268
  pageSize,
257
269
  ...props.initialState,
@@ -443,39 +455,54 @@ export const Table = (props) => {
443
455
  useLayoutEffect(() => {
444
456
  if (scrollToIndex)
445
457
  virtualizer.scrollToIndex(scrollToIndex, {
446
- align: 'center',
458
+ align: 'start',
447
459
  });
448
460
  }, [virtualizer, scrollToIndex]);
449
461
  let getPreparedRow = React.useCallback(
450
462
  (index, virtualItem, virtualizer) => {
451
463
  let row = page[index];
452
464
  prepareRow(row);
453
- return React.createElement(TableRowMemoized, {
454
- row: row,
455
- rowProps: rowProps,
456
- isLast: index === page.length - 1,
457
- onRowInViewport: onRowInViewportRef,
458
- onBottomReached: onBottomReachedRef,
459
- intersectionMargin: intersectionMargin,
460
- state: state,
461
- key: row.getRowProps().key,
462
- onClick: onRowClickHandler,
463
- subComponent: subComponent,
464
- isDisabled: !!isRowDisabled?.(row.original),
465
- tableHasSubRows: hasAnySubRows,
466
- tableInstance: instance,
467
- expanderCell: expanderCell,
468
- scrollContainerRef: tableRef.current,
469
- tableRowRef: enableVirtualization ? void 0 : tableRowRef(row),
470
- density: density,
471
- virtualItem: virtualItem,
472
- virtualizer: virtualizer,
473
- });
465
+ if (row.subRows.length > 0 || !subComponent)
466
+ return React.createElement(TableRowMemoized, {
467
+ row: row,
468
+ rowProps: rowProps,
469
+ isLast: index === page.length - 1,
470
+ onRowInViewport: onRowInViewportRef,
471
+ onBottomReached: onBottomReachedRef,
472
+ intersectionMargin: intersectionMargin,
473
+ state: state,
474
+ key: row.getRowProps().key,
475
+ onClick: onRowClickHandler,
476
+ subComponent: subComponent,
477
+ isDisabled: !!isRowDisabled?.(row.original),
478
+ tableHasSubRows: hasAnySubRows,
479
+ tableInstance: instance,
480
+ expanderCell: expanderCell,
481
+ scrollContainerRef: tableRef.current,
482
+ tableRowRef: enableVirtualization ? void 0 : tableRowRef(row),
483
+ density: density,
484
+ virtualItem: virtualItem,
485
+ virtualizer: virtualizer,
486
+ });
487
+ return React.createElement(
488
+ TableExpandableContentMemoized,
489
+ {
490
+ key: row.getRowProps().key,
491
+ virtualItem: virtualItem,
492
+ ref: enableVirtualization
493
+ ? virtualizer?.measureElement
494
+ : tableRowRef(row),
495
+ isDisabled: !!isRowDisabled?.(row.original),
496
+ },
497
+ subComponent(row),
498
+ );
474
499
  },
475
500
  [
476
501
  page,
477
502
  prepareRow,
478
503
  rowProps,
504
+ onRowInViewportRef,
505
+ onBottomReachedRef,
479
506
  intersectionMargin,
480
507
  state,
481
508
  onRowClickHandler,
@@ -487,8 +514,6 @@ export const Table = (props) => {
487
514
  enableVirtualization,
488
515
  tableRowRef,
489
516
  density,
490
- onBottomReachedRef,
491
- onRowInViewportRef,
492
517
  ],
493
518
  );
494
519
  let updateStickyState = () => {
@@ -520,7 +545,7 @@ export const Table = (props) => {
520
545
  return React.createElement(
521
546
  TableColumnsContext.Provider,
522
547
  {
523
- value: columns,
548
+ value: instance.columns,
524
549
  },
525
550
  React.createElement(
526
551
  Box,
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
3
+ import type { VirtualItem } from '@tanstack/react-virtual';
4
+ type TableExpandableContentProps = {
5
+ children: React.ReactNode;
6
+ virtualItem?: VirtualItem<Element>;
7
+ isDisabled?: boolean;
8
+ };
9
+ export declare const TableExpandableContentMemoized: React.MemoExoticComponent<PolymorphicForwardRefComponent<"div", TableExpandableContentProps>>;
10
+ export {};
@@ -0,0 +1,33 @@
1
+ import cx from 'classnames';
2
+ import * as React from 'react';
3
+ import { Box } from '../../utils/index.js';
4
+ let TableExpandableContent = React.forwardRef((props, ref) => {
5
+ let { children, className, style, isDisabled, virtualItem, ...rest } = props;
6
+ return React.createElement(
7
+ Box,
8
+ {
9
+ className: cx('iui-table-row', 'iui-table-expanded-content', className),
10
+ style: {
11
+ flex: '0 0 auto',
12
+ minWidth: '100%',
13
+ ...(null != virtualItem
14
+ ? {
15
+ transform: `translateY(${virtualItem.start}px)`,
16
+ }
17
+ : {}),
18
+ ...style,
19
+ },
20
+ 'aria-disabled': isDisabled,
21
+ 'data-iui-index': virtualItem?.index,
22
+ ...(null != virtualItem && {
23
+ 'data-iui-virtualizer': 'item',
24
+ }),
25
+ ref: ref,
26
+ ...rest,
27
+ },
28
+ children,
29
+ );
30
+ });
31
+ export const TableExpandableContentMemoized = React.memo(
32
+ TableExpandableContent,
33
+ );
@@ -1,11 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import cx from 'classnames';
3
- import {
4
- Box,
5
- useIntersection,
6
- useMergedRefs,
7
- WithCSSTransition,
8
- } from '../../utils/index.js';
3
+ import { Box, useIntersection, useMergedRefs } from '../../utils/index.js';
9
4
  import { TableCell } from './TableCell.js';
10
5
  export const TableRow = (props) => {
11
6
  let {
@@ -106,21 +101,6 @@ export const TableRow = (props) => {
106
101
  }),
107
102
  ),
108
103
  ),
109
- subComponent &&
110
- React.createElement(
111
- WithCSSTransition,
112
- {
113
- in: row.isExpanded,
114
- },
115
- React.createElement(
116
- Box,
117
- {
118
- className: cx('iui-table-row', 'iui-table-expanded-content'),
119
- 'aria-disabled': isDisabled,
120
- },
121
- subComponent(row),
122
- ),
123
- ),
124
104
  );
125
105
  };
126
106
  let hasAnySelectedSubRow = (row, selectedRowIds) => {
@@ -1,15 +1,15 @@
1
1
  import * as React from 'react';
2
+ import { defaultColumn } from 'react-table';
2
3
  import cx from 'classnames';
3
4
  import { Box, LineClamp, ShadowRoot } from '../../../utils/index.js';
4
5
  import { TableColumnsContext } from '../utils.js';
5
6
  export const DefaultCell = (props) => {
6
- let columnsProp = React.useContext(TableColumnsContext);
7
+ let instanceColumns = React.useContext(TableColumnsContext);
7
8
  let isCustomCell = React.useMemo(
8
9
  () =>
9
- columnsProp
10
- .find(({ id }) => props.cellProps.column.id === id)
11
- ?.hasOwnProperty('Cell'),
12
- [props.cellProps.column.id, columnsProp],
10
+ instanceColumns.find(({ id }) => props.cellProps.column.id === id)
11
+ ?.Cell !== defaultColumn.Cell,
12
+ [instanceColumns, props.cellProps.column.id],
13
13
  );
14
14
  let {
15
15
  cellElementProps: {
@@ -1,5 +1,7 @@
1
1
  import { actions, makePropGetter, useGetLatest } from 'react-table';
2
2
  import { styles } from '../../../styles.js';
3
+ let leftClassName = styles['iui-table-reorder-column-left'];
4
+ let rightClassName = styles['iui-table-reorder-column-right'];
3
5
  let REORDER_ACTIONS = {
4
6
  columnDragStart: 'columnDragStart',
5
7
  columnDragEnd: 'columnDragEnd',
@@ -21,12 +23,16 @@ let defaultGetDragAndDropProps =
21
23
  };
22
24
  let setOnDragColumnStyle = (event, position) => {
23
25
  let columnElement = event.currentTarget;
24
- columnElement.classList.remove(styles['iui-table-reorder-column-right']);
25
- columnElement.classList.remove(styles['iui-table-reorder-column-left']);
26
- if ('left' === position)
27
- columnElement.classList.add(styles['iui-table-reorder-column-left']);
28
- else if ('right' === position)
29
- columnElement.classList.add(styles['iui-table-reorder-column-right']);
26
+ if ('left' === position) {
27
+ columnElement.classList.remove(rightClassName);
28
+ columnElement.classList.add(leftClassName);
29
+ } else if ('right' === position) {
30
+ columnElement.classList.remove(leftClassName);
31
+ columnElement.classList.add(rightClassName);
32
+ } else {
33
+ columnElement.classList.remove(leftClassName);
34
+ columnElement.classList.remove(rightClassName);
35
+ }
30
36
  };
31
37
  let reorderColumns = (tableColumns, srcIndex, dstIndex) => {
32
38
  let newTableColumns = [...tableColumns];
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { ColumnInstance, Column } from '../../react-table/react-table.js';
2
+ import type { ColumnInstance } from '../../react-table/react-table.js';
3
3
  export declare const getCellStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, isTableResizing: boolean) => React.CSSProperties | undefined;
4
4
  export declare const getStickyStyle: <T extends Record<string, unknown>>(column: ColumnInstance<T>, columnList: ColumnInstance<T>[]) => React.CSSProperties;
5
5
  export declare const getSubRowStyle: ({ density, depth }: {
@@ -8,4 +8,4 @@ export declare const getSubRowStyle: ({ density, depth }: {
8
8
  }) => {
9
9
  paddingInlineStart: number;
10
10
  };
11
- export declare const TableColumnsContext: React.Context<Column<Record<string, unknown>>[]>;
11
+ export declare const TableColumnsContext: React.Context<ColumnInstance<{}>[]>;
@@ -32,6 +32,7 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => {
32
32
  includeCss = 'inherit' === themeProp,
33
33
  ...rest
34
34
  } = props;
35
+ useInertPolyfill();
35
36
  let [rootElement, setRootElement] = React.useState(null);
36
37
  let parent = useParentThemeAndContext(rootElement);
37
38
  let theme = 'inherit' === themeProp ? parent.theme || 'light' : themeProp;
@@ -233,7 +234,7 @@ let FallbackStyles = ({ root }) => {
233
234
  } catch (error) {
234
235
  console.log('Error loading styles.css locally', error);
235
236
  let css = await importCss(
236
- 'https://cdn.jsdelivr.net/npm/@itwin/itwinui-react@3/styles.css',
237
+ `https://cdn.jsdelivr.net/npm/@itwin/itwinui-react@${meta.version}/styles.css`,
237
238
  );
238
239
  document.adoptedStyleSheets = [
239
240
  ...document.adoptedStyleSheets,
@@ -254,3 +255,20 @@ let useIuiDebugRef = () => {
254
255
  var version, version1;
255
256
  _globalThis1.__iui.versions.add(JSON.stringify(meta));
256
257
  };
258
+ let useInertPolyfill = () => {
259
+ let loaded = React.useRef(false);
260
+ let modulePath =
261
+ 'https://cdn.jsdelivr.net/npm/wicg-inert@3.1.2/dist/inert.min.js';
262
+ React.useEffect(() => {
263
+ (async () => {
264
+ if (
265
+ !HTMLElement.prototype.hasOwnProperty('inert') &&
266
+ !loaded.current &&
267
+ !isUnitTest
268
+ ) {
269
+ await new Function('url', 'return import(url)')(modulePath);
270
+ loaded.current = true;
271
+ }
272
+ })();
273
+ }, []);
274
+ };
@@ -8,11 +8,10 @@ import {
8
8
  Box,
9
9
  useSafeContext,
10
10
  ButtonBase,
11
+ useMediaQuery,
11
12
  } from '../../utils/index.js';
12
13
  import { IconButton } from '../Buttons/IconButton.js';
13
14
  import { ToasterStateContext } from './Toaster.js';
14
- let isMotionOk = () =>
15
- getWindow()?.matchMedia?.('(prefers-reduced-motion: no-preference)')?.matches;
16
15
  export const Toast = (props) => {
17
16
  let {
18
17
  content,
@@ -34,6 +33,7 @@ export const Toast = (props) => {
34
33
  let [height, setHeight] = React.useState(0);
35
34
  let thisElement = React.useRef(null);
36
35
  let [margin, setMargin] = React.useState(0);
36
+ let motionOk = useMediaQuery('(prefers-reduced-motion: no-preference)');
37
37
  let marginStyle = () => {
38
38
  if ('top' === placementPosition)
39
39
  return {
@@ -98,16 +98,16 @@ export const Toast = (props) => {
98
98
  appear: true,
99
99
  unmountOnExit: true,
100
100
  onEnter: (node) => {
101
- if (isMotionOk()) {
101
+ if (motionOk) {
102
102
  node.style.transform = 'translateY(15%)';
103
103
  node.style.transitionTimingFunction = 'ease';
104
104
  }
105
105
  },
106
106
  onEntered: (node) => {
107
- if (isMotionOk()) node.style.transform = 'translateY(0)';
107
+ if (motionOk) node.style.transform = 'translateY(0)';
108
108
  },
109
109
  onExiting: (node) => {
110
- if (isMotionOk()) {
110
+ if (motionOk) {
111
111
  let { translateX, translateY } = calculateOutAnimation(node);
112
112
  node.style.transform = animateOutTo
113
113
  ? `scale(0.9) translate(${translateX}px,${translateY}px)`
package/esm/styles.js CHANGED
@@ -1,4 +1,4 @@
1
- const t = '3.14.1';
1
+ const t = '3.15.0';
2
2
  const u = new Proxy(
3
3
  {},
4
4
  {
@@ -50,6 +50,19 @@ function useShadowRoot(templateRef, { css = '' }) {
50
50
  let styleSheet = React.useRef();
51
51
  let latestCss = useLatestRef(css);
52
52
  let latestShadowRoot = useLatestRef(shadowRoot);
53
+ let createStyleSheet = React.useCallback(
54
+ (shadow) => {
55
+ if (shadow && supportsAdoptedStylesheets) {
56
+ let currentWindow = shadow.ownerDocument.defaultView || globalThis;
57
+ if (styleSheet.current instanceof currentWindow.CSSStyleSheet) return;
58
+ styleSheet.current = new currentWindow.CSSStyleSheet();
59
+ shadow.adoptedStyleSheets.push(styleSheet.current);
60
+ if (latestCss.current)
61
+ styleSheet.current.replaceSync(latestCss.current);
62
+ }
63
+ },
64
+ [latestCss],
65
+ );
53
66
  useLayoutEffect(() => {
54
67
  let parent = templateRef.current?.parentElement;
55
68
  if (!parent) return;
@@ -61,22 +74,23 @@ function useShadowRoot(templateRef, { css = '' }) {
61
74
  parent.attachShadow({
62
75
  mode: 'open',
63
76
  });
64
- if (supportsAdoptedStylesheets) {
65
- let currentWindow = shadow.ownerDocument.defaultView || globalThis;
66
- styleSheet.current = new currentWindow.CSSStyleSheet();
67
- shadow.adoptedStyleSheets = [styleSheet.current];
68
- if (latestCss.current)
69
- styleSheet.current.replaceSync(latestCss.current);
70
- }
77
+ createStyleSheet(shadow);
71
78
  ReactDOM.flushSync(() => setShadowRoot(shadow));
72
79
  };
73
80
  queueMicrotask(() => {
74
81
  setupOrReuseShadowRoot();
75
82
  });
76
83
  return () => void setShadowRoot(null);
77
- }, [templateRef, latestCss, latestShadowRoot]);
84
+ }, [templateRef, createStyleSheet, latestShadowRoot]);
78
85
  useLayoutEffect(() => {
79
86
  if (css && supportsAdoptedStylesheets) styleSheet.current?.replaceSync(css);
80
87
  }, [css]);
88
+ React.useEffect(() => {
89
+ let listener = () => createStyleSheet(latestShadowRoot.current);
90
+ window.addEventListener('appui:reparent', listener);
91
+ return () => {
92
+ window.removeEventListener('appui:reparent', listener);
93
+ };
94
+ }, [createStyleSheet, latestShadowRoot]);
81
95
  return shadowRoot;
82
96
  }
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { isUnitTest } from '../functions/dev.js';
3
+ import { getWindow } from '../functions/dom.js';
3
4
  let _React = React;
4
5
  let ReactInternals = _React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
5
6
  export const useWarningLogger = () => () => {};