@itwin/itwinui-react 3.18.3 → 3.19.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 (133) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/DEV-cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
  3. package/DEV-cjs/core/Menu/MenuItem.js +8 -7
  4. package/DEV-cjs/core/Select/Select.js +18 -10
  5. package/DEV-cjs/core/SideNavigation/SideNavigation.js +2 -2
  6. package/DEV-cjs/core/Table/ColumnHeader.js +7 -3
  7. package/DEV-cjs/core/Table/Table.js +65 -5
  8. package/DEV-cjs/core/Table/cells/DefaultCell.js +14 -9
  9. package/DEV-cjs/core/Table/columns/actionColumn.js +1 -0
  10. package/DEV-cjs/core/Table/columns/expanderColumn.js +25 -20
  11. package/DEV-cjs/core/Table/columns/selectionColumn.js +14 -8
  12. package/DEV-cjs/core/Table/hooks/useExpanderCell.js +10 -6
  13. package/DEV-cjs/core/Tag/Tag.js +8 -2
  14. package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +46 -46
  15. package/DEV-cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
  16. package/DEV-cjs/styles.js +1 -1
  17. package/DEV-cjs/utils/components/index.js +1 -1
  18. package/DEV-cjs/utils/components/lineClamp.js +23 -0
  19. package/DEV-cjs/utils/functions/react.js +18 -4
  20. package/DEV-cjs/utils/hooks/useControlledState.js +5 -1
  21. package/DEV-cjs/utils/providers/FutureFlagsProvider.js +48 -0
  22. package/DEV-cjs/utils/providers/index.js +1 -0
  23. package/DEV-esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
  24. package/DEV-esm/core/Menu/MenuItem.js +8 -7
  25. package/DEV-esm/core/Select/Select.js +19 -10
  26. package/DEV-esm/core/SideNavigation/SideNavigation.js +2 -2
  27. package/DEV-esm/core/Table/ColumnHeader.js +8 -4
  28. package/DEV-esm/core/Table/Table.js +65 -5
  29. package/DEV-esm/core/Table/cells/DefaultCell.js +15 -10
  30. package/DEV-esm/core/Table/columns/actionColumn.js +1 -0
  31. package/DEV-esm/core/Table/columns/expanderColumn.js +25 -20
  32. package/DEV-esm/core/Table/columns/selectionColumn.js +14 -8
  33. package/DEV-esm/core/Table/hooks/useExpanderCell.js +10 -6
  34. package/DEV-esm/core/Tag/Tag.js +11 -3
  35. package/DEV-esm/core/ThemeProvider/ThemeProvider.js +48 -42
  36. package/DEV-esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
  37. package/DEV-esm/styles.js +1 -1
  38. package/DEV-esm/utils/components/index.js +1 -1
  39. package/DEV-esm/utils/components/lineClamp.js +13 -0
  40. package/DEV-esm/utils/functions/react.js +6 -1
  41. package/DEV-esm/utils/hooks/useControlledState.js +5 -1
  42. package/DEV-esm/utils/providers/FutureFlagsProvider.js +28 -0
  43. package/DEV-esm/utils/providers/index.js +1 -0
  44. package/cjs/core/Buttons/DropdownButton.d.ts +1 -1
  45. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
  46. package/cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
  47. package/cjs/core/DropdownMenu/DropdownMenu.d.ts +1 -1
  48. package/cjs/core/Menu/MenuItem.d.ts +7 -1
  49. package/cjs/core/Menu/MenuItem.js +8 -7
  50. package/cjs/core/Popover/Popover.d.ts +5 -3
  51. package/cjs/core/Select/Select.js +18 -10
  52. package/cjs/core/SideNavigation/SideNavigation.js +2 -2
  53. package/cjs/core/Table/ColumnHeader.js +7 -3
  54. package/cjs/core/Table/Table.d.ts +2 -2
  55. package/cjs/core/Table/Table.js +65 -5
  56. package/cjs/core/Table/cells/DefaultCell.js +14 -9
  57. package/cjs/core/Table/columns/actionColumn.d.ts +1 -0
  58. package/cjs/core/Table/columns/actionColumn.js +1 -0
  59. package/cjs/core/Table/columns/expanderColumn.d.ts +2 -2
  60. package/cjs/core/Table/columns/expanderColumn.js +25 -20
  61. package/cjs/core/Table/columns/selectionColumn.d.ts +2 -2
  62. package/cjs/core/Table/columns/selectionColumn.js +14 -8
  63. package/cjs/core/Table/hooks/useExpanderCell.js +10 -6
  64. package/cjs/core/Tabs/Tabs.d.ts +4 -1
  65. package/cjs/core/Tag/Tag.js +8 -2
  66. package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -2
  67. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +8 -18
  68. package/cjs/core/ThemeProvider/ThemeProvider.js +46 -46
  69. package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
  70. package/cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
  71. package/cjs/styles.js +1 -1
  72. package/cjs/utils/components/index.d.ts +1 -1
  73. package/cjs/utils/components/index.js +1 -1
  74. package/cjs/utils/components/lineClamp.d.ts +5 -0
  75. package/cjs/utils/components/lineClamp.js +23 -0
  76. package/cjs/utils/functions/react.d.ts +5 -0
  77. package/cjs/utils/functions/react.js +18 -4
  78. package/cjs/utils/hooks/useControlledState.d.ts +5 -2
  79. package/cjs/utils/hooks/useControlledState.js +5 -1
  80. package/cjs/utils/hooks/useGlobals.d.ts +0 -1
  81. package/cjs/utils/providers/FutureFlagsProvider.d.ts +37 -0
  82. package/cjs/utils/providers/FutureFlagsProvider.js +48 -0
  83. package/cjs/utils/providers/index.d.ts +1 -0
  84. package/cjs/utils/providers/index.js +1 -0
  85. package/esm/core/Buttons/DropdownButton.d.ts +1 -1
  86. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
  87. package/esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
  88. package/esm/core/DropdownMenu/DropdownMenu.d.ts +1 -1
  89. package/esm/core/Menu/MenuItem.d.ts +7 -1
  90. package/esm/core/Menu/MenuItem.js +8 -7
  91. package/esm/core/Popover/Popover.d.ts +5 -3
  92. package/esm/core/Select/Select.js +19 -10
  93. package/esm/core/SideNavigation/SideNavigation.js +2 -2
  94. package/esm/core/Table/ColumnHeader.js +8 -4
  95. package/esm/core/Table/Table.d.ts +2 -2
  96. package/esm/core/Table/Table.js +65 -5
  97. package/esm/core/Table/cells/DefaultCell.js +15 -10
  98. package/esm/core/Table/columns/actionColumn.d.ts +1 -0
  99. package/esm/core/Table/columns/actionColumn.js +1 -0
  100. package/esm/core/Table/columns/expanderColumn.d.ts +2 -2
  101. package/esm/core/Table/columns/expanderColumn.js +25 -20
  102. package/esm/core/Table/columns/selectionColumn.d.ts +2 -2
  103. package/esm/core/Table/columns/selectionColumn.js +14 -8
  104. package/esm/core/Table/hooks/useExpanderCell.js +10 -6
  105. package/esm/core/Tabs/Tabs.d.ts +4 -1
  106. package/esm/core/Tag/Tag.js +11 -3
  107. package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -2
  108. package/esm/core/ThemeProvider/ThemeProvider.d.ts +8 -18
  109. package/esm/core/ThemeProvider/ThemeProvider.js +48 -42
  110. package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
  111. package/esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
  112. package/esm/styles.js +1 -1
  113. package/esm/utils/components/index.d.ts +1 -1
  114. package/esm/utils/components/index.js +1 -1
  115. package/esm/utils/components/lineClamp.d.ts +5 -0
  116. package/esm/utils/components/lineClamp.js +13 -0
  117. package/esm/utils/functions/react.d.ts +5 -0
  118. package/esm/utils/functions/react.js +6 -1
  119. package/esm/utils/hooks/useControlledState.d.ts +5 -2
  120. package/esm/utils/hooks/useControlledState.js +5 -1
  121. package/esm/utils/hooks/useGlobals.d.ts +0 -1
  122. package/esm/utils/providers/FutureFlagsProvider.d.ts +37 -0
  123. package/esm/utils/providers/FutureFlagsProvider.js +28 -0
  124. package/esm/utils/providers/index.d.ts +1 -0
  125. package/esm/utils/providers/index.js +1 -0
  126. package/package.json +11 -5
  127. package/styles.css +10 -10
  128. package/DEV-cjs/utils/components/LineClamp.js +0 -50
  129. package/DEV-esm/utils/components/LineClamp.js +0 -36
  130. package/cjs/utils/components/LineClamp.d.ts +0 -5
  131. package/cjs/utils/components/LineClamp.js +0 -50
  132. package/esm/utils/components/LineClamp.d.ts +0 -5
  133. package/esm/utils/components/LineClamp.js +0 -36
@@ -24,15 +24,22 @@ const ToggleSwitch = _react.forwardRef((props, ref) => {
24
24
  style,
25
25
  size = 'default',
26
26
  labelProps = {},
27
+ wrapperProps,
27
28
  icon: iconProp,
28
29
  ...rest
29
30
  } = props;
31
+ let { consistentPropsSpread } =
32
+ (0, _index.useFutureFlag)('ToggleSwitch') || {};
33
+ let shouldApplyClassNameAndStyleOnInput =
34
+ null != wrapperProps || consistentPropsSpread;
30
35
  let shouldShowIcon =
31
36
  void 0 === iconProp || (null !== iconProp && 'small' !== size);
32
37
  return _react.createElement(
33
38
  _index.Box,
34
39
  {
35
40
  as: label ? 'label' : 'div',
41
+ style: shouldApplyClassNameAndStyleOnInput ? void 0 : style,
42
+ ...wrapperProps,
36
43
  className: (0, _classnames.default)(
37
44
  'iui-toggle-switch-wrapper',
38
45
  {
@@ -40,19 +47,23 @@ const ToggleSwitch = _react.forwardRef((props, ref) => {
40
47
  'iui-label-on-right': label && 'right' === labelPosition,
41
48
  'iui-label-on-left': label && 'left' === labelPosition,
42
49
  },
43
- className,
50
+ shouldApplyClassNameAndStyleOnInput ? void 0 : className,
51
+ wrapperProps?.className,
44
52
  ),
45
53
  'data-iui-size': size,
46
- style: style,
47
54
  },
48
55
  _react.createElement(_index.Box, {
49
56
  as: 'input',
50
- className: 'iui-toggle-switch',
51
57
  type: 'checkbox',
52
58
  role: 'switch',
59
+ style: shouldApplyClassNameAndStyleOnInput ? style : void 0,
60
+ ...rest,
61
+ className: (0, _classnames.default)(
62
+ 'iui-toggle-switch',
63
+ shouldApplyClassNameAndStyleOnInput ? className : void 0,
64
+ ),
53
65
  disabled: disabled,
54
66
  ref: ref,
55
- ...rest,
56
67
  }),
57
68
  shouldShowIcon &&
58
69
  _react.createElement(
package/cjs/styles.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
- const e = '3.18.3';
3
+ const e = '3.19.0';
4
4
  const u = new Proxy(
5
5
  {},
6
6
  {
@@ -9,6 +9,6 @@ export * from './Box.js';
9
9
  export * from './ButtonBase.js';
10
10
  export * from './Portal.js';
11
11
  export * from './ShadowRoot.js';
12
- export * from './LineClamp.js';
12
+ export * from './lineClamp.js';
13
13
  export * from './FieldsetBase.js';
14
14
  export * from './OverflowContainer.js';
@@ -14,6 +14,6 @@ _export_star._(require('./Box.js'), exports);
14
14
  _export_star._(require('./ButtonBase.js'), exports);
15
15
  _export_star._(require('./Portal.js'), exports);
16
16
  _export_star._(require('./ShadowRoot.js'), exports);
17
- _export_star._(require('./LineClamp.js'), exports);
17
+ _export_star._(require('./lineClamp.js'), exports);
18
18
  _export_star._(require('./FieldsetBase.js'), exports);
19
19
  _export_star._(require('./OverflowContainer.js'), exports);
@@ -0,0 +1,5 @@
1
+ /** @private */
2
+ export declare const lineClamp: {
3
+ css: string;
4
+ className: string;
5
+ };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', {
3
+ value: true,
4
+ });
5
+ Object.defineProperty(exports, 'lineClamp', {
6
+ enumerable: true,
7
+ get: function () {
8
+ return lineClamp;
9
+ },
10
+ });
11
+ const className = '_iui-line-clamp';
12
+ const css = `
13
+ .${className} {
14
+ overflow: hidden;
15
+ display: -webkit-box;
16
+ -webkit-line-clamp: var(--_iui-line-clamp, 3);
17
+ -webkit-box-orient: vertical;
18
+ }
19
+ `;
20
+ const lineClamp = {
21
+ css,
22
+ className,
23
+ };
@@ -1,4 +1,9 @@
1
1
  import * as React from 'react';
2
+ /**
3
+ * `true` if the current React version is 17 or 18. Else, is `false`.
4
+ * @private
5
+ */
6
+ export declare const isReact17or18: boolean;
2
7
  /**
3
8
  * Wrapper over `cloneElement` that automatically checks for `isValidElement`
4
9
  * and automatically merges `children.ref` with the ref passed in props.
@@ -2,19 +2,33 @@
2
2
  Object.defineProperty(exports, '__esModule', {
3
3
  value: true,
4
4
  });
5
- Object.defineProperty(exports, 'cloneElementWithRef', {
6
- enumerable: true,
7
- get: function () {
5
+ function _export(target, all) {
6
+ for (var name in all)
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name],
10
+ });
11
+ }
12
+ _export(exports, {
13
+ cloneElementWithRef: function () {
8
14
  return cloneElementWithRef;
9
15
  },
16
+ isReact17or18: function () {
17
+ return isReact17or18;
18
+ },
10
19
  });
11
20
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
12
21
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
13
22
  const _useMergedRefs = require('../hooks/useMergedRefs.js');
23
+ const _React = _react;
24
+ const isReact17or18 = (() => {
25
+ let version = _React.version?.split('.')?.[0];
26
+ return ['17', '18'].includes(version);
27
+ })();
14
28
  const cloneElementWithRef = (children, getProps) => {
15
29
  if (!children) return null;
16
30
  if (!_react.isValidElement(children)) return children;
17
- let childrenRef = children.props?.ref || children?.ref;
31
+ let childrenRef = isReact17or18 ? children?.ref : children.props?.ref;
18
32
  let props = getProps(children);
19
33
  let ref = (0, _useMergedRefs.mergeRefs)(
20
34
  ...[childrenRef, 'ref' in props ? props.ref : null].filter(Boolean),
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
1
  /**
3
2
  * Wrapper over `useState` that always gives preference to the
4
3
  * controlled state (which often comes from a prop).
@@ -6,8 +5,12 @@ import * as React from 'react';
6
5
  * This is helpful when a component needs to support both uncontrolled
7
6
  * and controlled states. If controlled value/setter is not passed,
8
7
  * then it will work just like a regular `useState`.
8
+ * The only exception is that the set function only accepts the new state. It does not accept a function.
9
+ *
10
+ * **NOTE**: `setControlledState` is called only when the value *changes* (uncontrolled mode) or should *change*
11
+ * (controlled mode).
9
12
  *
10
13
  * @example
11
14
  * const [state, setState] = useControlledState(null, props.value, props.onChange);
12
15
  */
13
- export declare const useControlledState: <T>(initialValue: T, controlledState: T | undefined, setControlledState?: React.Dispatch<React.SetStateAction<T>>) => readonly [T, React.Dispatch<React.SetStateAction<T>>];
16
+ export declare const useControlledState: <T>(initialValue: T, controlledState: T | undefined, setControlledState?: (value: T) => void) => readonly [T, (value: T) => void];
@@ -10,6 +10,7 @@ Object.defineProperty(exports, 'useControlledState', {
10
10
  });
11
11
  const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
12
12
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
13
+ const _useLatestRef = require('./useLatestRef.js');
13
14
  const useControlledState = (
14
15
  initialValue,
15
16
  controlledState,
@@ -20,12 +21,15 @@ const useControlledState = (
20
21
  () => (void 0 !== controlledState ? controlledState : uncontrolledState),
21
22
  [controlledState, uncontrolledState],
22
23
  );
24
+ let oldState = (0, _useLatestRef.useLatestRef)(state);
23
25
  let setState = _react.useCallback(
24
26
  (value) => {
27
+ if (value === oldState.current) return;
28
+ oldState.current = value;
25
29
  setUncontrolledState(value);
26
30
  setControlledState?.(value);
27
31
  },
28
- [setControlledState, setUncontrolledState],
32
+ [oldState, setControlledState],
29
33
  );
30
34
  return [state, setState];
31
35
  };
@@ -10,7 +10,6 @@ export declare const useGlobals: () => {
10
10
  theme?: import("../../index.js").ThemeType;
11
11
  themeOptions?: import("../../core/ThemeProvider/ThemeProvider.js").ThemeOptions;
12
12
  portalContainer?: HTMLElement | null;
13
- future?: import("../../core/ThemeProvider/ThemeProvider.js").FutureOptions;
14
13
  } | undefined;
15
14
  /** Shows console error if ThemeProvider is not used */
16
15
  export declare const useThemeProviderWarning: (themeContext: React.ContextType<typeof ThemeContext>) => void;
@@ -0,0 +1,37 @@
1
+ import * as React from 'react';
2
+ export type FutureOptions = {
3
+ /**
4
+ * @alpha
5
+ *
6
+ * If enabled, the theme resembles the future iTwinUI version's theme (including alphas) *whenever possible*.
7
+ *
8
+ * This is useful in making apps looks like future versions of iTwinUI to help with incremental adoption.
9
+ *
10
+ * **NOTE**: Since this is a theme bridge to *future* versions, the theme could have breaking changes.
11
+ */
12
+ themeBridge?: boolean;
13
+ ToggleSwitch?: {
14
+ /**
15
+ * When `true`, `className` and `style` will be applied on the
16
+ * input element, along with the rest of the DOM props.
17
+ *
18
+ * By default (without this flag), `className` and `style` get
19
+ * applied on the wrapper element, unless `wrapperProps` is also passed.
20
+ */
21
+ consistentPropsSpread?: boolean;
22
+ };
23
+ };
24
+ /**
25
+ * Hook to access future flags.
26
+ * @private
27
+ *
28
+ * @example
29
+ * ```jsx
30
+ * const themeBridge = useFutureFlag('themeBridge');
31
+ * ```
32
+ */
33
+ export declare function useFutureFlag<K extends keyof FutureOptions>(key: K): FutureOptions[K];
34
+ /** @private */
35
+ export declare const FutureFlagsProvider: ({ children, value, }: React.PropsWithChildren<{
36
+ value: true | FutureOptions;
37
+ }>) => React.JSX.Element;
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', {
3
+ value: true,
4
+ });
5
+ function _export(target, all) {
6
+ for (var name in all)
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name],
10
+ });
11
+ }
12
+ _export(exports, {
13
+ FutureFlagsProvider: function () {
14
+ return FutureFlagsProvider;
15
+ },
16
+ useFutureFlag: function () {
17
+ return useFutureFlag;
18
+ },
19
+ });
20
+ const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
21
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
22
+ const _useSafeContext = require('../hooks/useSafeContext.js');
23
+ const FutureFlagsContext = _react.createContext({});
24
+ function useFutureFlag(key) {
25
+ let context = (0, _useSafeContext.useSafeContext)(FutureFlagsContext);
26
+ return context[key];
27
+ }
28
+ const FutureFlagsProvider = ({ children, value }) => {
29
+ if (true === value)
30
+ value = {
31
+ themeBridge: true,
32
+ };
33
+ let context = _react.useContext(FutureFlagsContext);
34
+ let combinedValue = {
35
+ ...context,
36
+ ...value,
37
+ };
38
+ return _react.createElement(
39
+ FutureFlagsContext.Provider,
40
+ {
41
+ value: _react.useMemo(
42
+ () => combinedValue,
43
+ [JSON.stringify(combinedValue)],
44
+ ),
45
+ },
46
+ children,
47
+ );
48
+ };
@@ -1 +1,2 @@
1
+ export * from './FutureFlagsProvider.js';
1
2
  export * from './HydrationProvider.js';
@@ -3,4 +3,5 @@ Object.defineProperty(exports, '__esModule', {
3
3
  value: true,
4
4
  });
5
5
  const _export_star = require('@swc/helpers/_/_export_star');
6
+ _export_star._(require('./FutureFlagsProvider.js'), exports);
6
7
  _export_star._(require('./HydrationProvider.js'), exports);
@@ -8,7 +8,7 @@ export type DropdownButtonProps = {
8
8
  * Pass a function that takes the `close` argument (to close the menu),
9
9
  * and returns a list of `MenuItem` components.
10
10
  */
11
- menuItems: (close: () => void) => React.JSX.Element[];
11
+ menuItems: ((close: () => void) => React.JSX.Element[]) | React.JSX.Element[] | React.JSX.Element;
12
12
  /**
13
13
  * Style of the dropdown button.
14
14
  * Use 'borderless' to hide outline.
@@ -1,20 +1,9 @@
1
1
  import * as React from 'react';
2
- export declare const ComboBoxMenuItem: React.NamedExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children" | "as" | "role" | "onClick" | "size" | "icon" | "disabled" | "value" | "startIcon" | "endIcon" | "index" | "focused" | "isSelected" | "sublabel" | "badge" | "subMenuItems"> & {
3
- isSelected?: boolean;
4
- disabled?: boolean;
5
- value?: unknown;
6
- onClick?: (value?: unknown) => void;
7
- size?: "default" | "large";
8
- sublabel?: React.ReactNode;
9
- startIcon?: React.JSX.Element;
10
- icon?: React.JSX.Element;
11
- endIcon?: React.JSX.Element;
12
- badge?: React.JSX.Element;
13
- role?: string;
14
- subMenuItems?: React.JSX.Element[];
15
- children?: React.ReactNode;
16
- } & Pick<import("../List/ListItem.js").ListItemOwnProps, "focused"> & {
2
+ import type { MenuItemProps } from '../Menu/MenuItem.js';
3
+ type ComboBoxMenuItemProps = MenuItemProps & {
17
4
  index: number;
18
- } & {
5
+ };
6
+ export declare const ComboBoxMenuItem: React.NamedExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children" | "as" | "role" | "onClick" | "size" | "icon" | "disabled" | "value" | "startIcon" | "endIcon" | "index" | "focused" | "isSelected" | "sublabel" | "badge" | "subMenuItems"> & ComboBoxMenuItemProps & {
19
7
  as?: "div" | undefined;
20
8
  }>;
9
+ export {};
@@ -41,7 +41,7 @@ export const ComboBoxMenuItem = React.memo(
41
41
  disabled: disabled,
42
42
  focused: focusedIndex === index,
43
43
  ref: refs,
44
- onClick: () => onClick?.(value),
44
+ onClick: () => onClick?.(),
45
45
  role: role,
46
46
  tabIndex: 'presentation' === role ? void 0 : -1,
47
47
  'aria-selected': isSelected,
@@ -16,7 +16,7 @@ export type DropdownMenuProps = {
16
16
  /**
17
17
  * Child element to wrap dropdown with.
18
18
  */
19
- children: React.ReactNode;
19
+ children: React.JSX.Element;
20
20
  /**
21
21
  * Middleware options.
22
22
  *
@@ -10,14 +10,20 @@ export type MenuItemProps = {
10
10
  * Item is disabled.
11
11
  */
12
12
  disabled?: boolean;
13
+ } & ({
13
14
  /**
14
15
  * Value of the item.
16
+ * @deprecated
15
17
  */
16
- value?: unknown;
18
+ value: unknown;
17
19
  /**
18
20
  * Callback function that handles click and keyboard submit actions.
19
21
  */
20
22
  onClick?: (value?: unknown) => void;
23
+ } | {
24
+ /** @deprecated */ value?: never;
25
+ onClick?: (event?: React.MouseEvent) => void;
26
+ }) & {
21
27
  /**
22
28
  * Modify height of the item.
23
29
  * Use 'large' when any of the sibling items have `sublabel`.
@@ -63,13 +63,10 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
63
63
  }),
64
64
  [hasSubMenu],
65
65
  );
66
- let onClick = () => {
66
+ let onClick = (event) => {
67
67
  if (disabled) return;
68
68
  if (shouldCloseMenuOnClick) dropdownMenu?.close();
69
- onClickProp?.(value);
70
- };
71
- let handlers = {
72
- onClick,
69
+ onClickProp?.(value ?? event);
73
70
  };
74
71
  let focusableItemIndex = parentMenu?.focusableElements.findIndex(
75
72
  (el) => el === menuItemRef.current,
@@ -94,9 +91,13 @@ export const MenuItem = React.forwardRef((props, forwardedRef) => {
94
91
  ...(parentMenu?.popoverGetItemProps != null
95
92
  ? parentMenu.popoverGetItemProps({
96
93
  focusableItemIndex,
97
- userProps: handlers,
94
+ userProps: {
95
+ onClick,
96
+ },
98
97
  })
99
- : handlers),
98
+ : {
99
+ onClick,
100
+ }),
100
101
  ...rest,
101
102
  },
102
103
  startIcon &&
@@ -14,8 +14,10 @@ type PopoverOptions = {
14
14
  */
15
15
  visible?: boolean;
16
16
  /**
17
- * Callback invoked every time the popover visibility changes as a result
18
- * of internal logic. Should be used alongside `visible` prop.
17
+ * Callback invoked every time the popover visibility *changes* (uncontrolled mode) or should *change*
18
+ * (controlled mode) as a result of internal logic.
19
+ *
20
+ * Should be used alongside `visible` prop.
19
21
  */
20
22
  onVisibleChange?: (visible: boolean) => void;
21
23
  /**
@@ -147,7 +149,7 @@ export declare const usePopover: (options: PopoverOptions & PopoverInternalProps
147
149
  elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
148
150
  };
149
151
  open: boolean;
150
- onOpenChange: React.Dispatch<React.SetStateAction<boolean>>;
152
+ onOpenChange: (value: boolean) => void;
151
153
  getReferenceProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
152
154
  getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
153
155
  };
@@ -12,6 +12,7 @@ import {
12
12
  useLatestRef,
13
13
  InputWithIcon,
14
14
  mergeEventHandlers,
15
+ isReact17or18,
15
16
  } from '../../utils/index.js';
16
17
  import { SelectTag } from './SelectTag.js';
17
18
  import { SelectTagContainer } from './SelectTagContainer.js';
@@ -174,7 +175,13 @@ let CustomSelect = React.forwardRef((props, forwardedRef) => {
174
175
  isSelected,
175
176
  })
176
177
  : React.createElement(MenuItem, null, option.label);
177
- let { label, icon, startIcon: startIconProp, ...restOption } = option;
178
+ let {
179
+ label,
180
+ icon,
181
+ startIcon: startIconProp,
182
+ value: _,
183
+ ...restOption
184
+ } = option;
178
185
  let startIcon = startIconProp ?? icon;
179
186
  return React.cloneElement(menuItem, {
180
187
  key: `${label}-${index}`,
@@ -451,15 +458,17 @@ let SelectListbox = React.forwardRef((props, forwardedRef) => {
451
458
  }, []);
452
459
  let children = React.useMemo(
453
460
  () =>
454
- React.Children.map(childrenProp, (child, index) =>
455
- React.isValidElement(child)
456
- ? React.createElement(CompositeItem, {
457
- key: index,
458
- render: child,
459
- ref: child.props.ref || child.ref,
460
- })
461
- : child,
462
- ),
461
+ React.Children.map(childrenProp, (child, index) => {
462
+ if (React.isValidElement(child)) {
463
+ let ref = isReact17or18 ? child.ref : child.props.ref;
464
+ return React.createElement(CompositeItem, {
465
+ key: index,
466
+ ref: ref,
467
+ render: child,
468
+ });
469
+ }
470
+ return child;
471
+ }),
463
472
  [childrenProp],
464
473
  );
465
474
  return React.createElement(
@@ -30,9 +30,9 @@ export const SideNavigation = React.forwardRef((props, forwardedRef) => {
30
30
  className: 'iui-sidenav-button iui-expand',
31
31
  size: 'small',
32
32
  onClick: React.useCallback(() => {
33
- setIsExpanded((expanded) => !expanded);
33
+ setIsExpanded(!isExpanded);
34
34
  onExpanderClick?.();
35
- }, [onExpanderClick, setIsExpanded]),
35
+ }, [isExpanded, onExpanderClick, setIsExpanded]),
36
36
  },
37
37
  React.createElement(SvgChevronRight, null),
38
38
  );
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import {
3
3
  Box,
4
4
  ShadowRoot,
5
- LineClamp,
5
+ lineClamp,
6
6
  SvgSortDown,
7
7
  SvgSortUp,
8
8
  useMergedRefs,
@@ -103,10 +103,14 @@ export const ColumnHeader = React.forwardRef((props, forwardedRef) => {
103
103
  'string' == typeof column.Header
104
104
  ? React.createElement(
105
105
  ShadowRoot,
106
- null,
106
+ {
107
+ css: lineClamp.css,
108
+ },
107
109
  React.createElement(
108
- LineClamp,
109
- null,
110
+ 'div',
111
+ {
112
+ className: lineClamp.className,
113
+ },
110
114
  React.createElement('slot', null),
111
115
  ),
112
116
  React.createElement('slot', {
@@ -206,8 +206,8 @@ export type TableProps<T extends Record<string, unknown> = Record<string, unknow
206
206
  /**
207
207
  * Passes props to the `role="table"` element within the wrapper.
208
208
  *
209
- * If `tableProps` or `role` is passed to `Table`, all ARIA attributes passed to `Table` will be passed to the wrapper.
210
- * Else, all ARIA attributes will be passed to the inner element with `role="table"`.
209
+ * - If `tableProps` or `role` is passed to `Table`, all ARIA attributes passed to `Table` will be passed to the wrapper.
210
+ * - Else, all ARIA attributes will be passed to the inner element with `role="table"`.
211
211
  */
212
212
  tableProps?: React.ComponentProps<'div'>;
213
213
  /**
@@ -113,6 +113,38 @@ export const Table = (props) => {
113
113
  caption = 'Table',
114
114
  role,
115
115
  scrollToRow,
116
+ useControlledState,
117
+ autoResetExpanded,
118
+ autoResetFilters,
119
+ autoResetGlobalFilter,
120
+ autoResetHiddenColumns,
121
+ autoResetPage,
122
+ autoResetResize,
123
+ autoResetSelectedRows,
124
+ autoResetSortBy,
125
+ defaultCanFilter,
126
+ defaultCanSort,
127
+ defaultColumn: defaultColumnProp,
128
+ disableFilters,
129
+ disableGlobalFilter,
130
+ disableMultiSort,
131
+ disableSortRemove,
132
+ disabledMultiRemove,
133
+ expandSubRows,
134
+ globalFilter,
135
+ initialState,
136
+ isMultiSortEvent,
137
+ manualExpandedKey,
138
+ manualFilters,
139
+ manualGlobalFilter,
140
+ manualRowSelectedKey,
141
+ manualSortBy,
142
+ maxMultiSortColCount,
143
+ orderByFn,
144
+ pageCount,
145
+ sortTypes,
146
+ manualPagination,
147
+ paginateExpandedRows,
116
148
  ..._rest
117
149
  } = props;
118
150
  let { ariaRestAttributes, nonAriaRestAttributes } = React.useMemo(
@@ -153,8 +185,9 @@ export const Table = (props) => {
153
185
  maxWidth: 0,
154
186
  minWidth: 0,
155
187
  width: 0,
188
+ ...defaultColumnProp,
156
189
  }),
157
- [],
190
+ [defaultColumnProp],
158
191
  );
159
192
  let rowHeight = React.useMemo(() => {
160
193
  if ('condensed' === density) return 50;
@@ -306,9 +339,36 @@ export const Table = (props) => {
306
339
  );
307
340
  let instance = useTable(
308
341
  {
309
- manualPagination: !paginatorRenderer,
310
- paginateExpandedRows: false,
311
- ...props,
342
+ manualPagination: manualPagination ?? !paginatorRenderer,
343
+ paginateExpandedRows: paginateExpandedRows ?? false,
344
+ useControlledState,
345
+ autoResetExpanded,
346
+ autoResetFilters,
347
+ autoResetGlobalFilter,
348
+ autoResetHiddenColumns,
349
+ autoResetPage,
350
+ autoResetResize,
351
+ autoResetSelectedRows,
352
+ autoResetSortBy,
353
+ defaultCanFilter,
354
+ defaultCanSort,
355
+ disableFilters,
356
+ disableGlobalFilter,
357
+ disableMultiSort,
358
+ disableSortRemove,
359
+ disabledMultiRemove,
360
+ expandSubRows,
361
+ globalFilter,
362
+ isMultiSortEvent,
363
+ manualExpandedKey,
364
+ manualFilters,
365
+ manualGlobalFilter,
366
+ manualRowSelectedKey,
367
+ manualSortBy,
368
+ maxMultiSortColCount,
369
+ orderByFn,
370
+ pageCount: pageCount ?? -1,
371
+ sortTypes,
312
372
  columns,
313
373
  defaultColumn,
314
374
  disableSortBy: !isSortable,
@@ -319,7 +379,7 @@ export const Table = (props) => {
319
379
  getSubRows: subComponent ? getSubRowsWithSubComponents : getSubRows,
320
380
  initialState: {
321
381
  pageSize,
322
- ...props.initialState,
382
+ ...initialState,
323
383
  },
324
384
  columnResizeMode,
325
385
  getRowId: subComponent ? getRowIdWithSubComponents : getRowId,