@itwin/itwinui-react 3.18.3 → 3.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +52 -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/Buttons/IconButton.d.ts +1 -1
  46. package/cjs/core/Carousel/Carousel.d.ts +4 -4
  47. package/cjs/core/Carousel/CarouselNavigation.d.ts +4 -4
  48. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
  49. package/cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
  50. package/cjs/core/DropdownMenu/DropdownMenu.d.ts +1 -1
  51. package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +1 -1
  52. package/cjs/core/Menu/MenuItem.d.ts +7 -1
  53. package/cjs/core/Menu/MenuItem.js +8 -7
  54. package/cjs/core/Popover/Popover.d.ts +5 -3
  55. package/cjs/core/Select/Select.js +18 -10
  56. package/cjs/core/SideNavigation/SideNavigation.js +2 -2
  57. package/cjs/core/Table/ColumnHeader.js +7 -3
  58. package/cjs/core/Table/Table.d.ts +2 -2
  59. package/cjs/core/Table/Table.js +65 -5
  60. package/cjs/core/Table/cells/DefaultCell.js +14 -9
  61. package/cjs/core/Table/columns/actionColumn.d.ts +1 -0
  62. package/cjs/core/Table/columns/actionColumn.js +1 -0
  63. package/cjs/core/Table/columns/expanderColumn.d.ts +2 -2
  64. package/cjs/core/Table/columns/expanderColumn.js +25 -20
  65. package/cjs/core/Table/columns/selectionColumn.d.ts +2 -2
  66. package/cjs/core/Table/columns/selectionColumn.js +14 -8
  67. package/cjs/core/Table/hooks/useExpanderCell.js +10 -6
  68. package/cjs/core/Tabs/Tabs.d.ts +4 -1
  69. package/cjs/core/Tag/Tag.js +8 -2
  70. package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -2
  71. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +8 -18
  72. package/cjs/core/ThemeProvider/ThemeProvider.js +46 -46
  73. package/cjs/core/Tile/Tile.d.ts +2 -2
  74. package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
  75. package/cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
  76. package/cjs/core/TransferList/TransferList.d.ts +7 -5
  77. package/cjs/styles.js +1 -1
  78. package/cjs/utils/components/index.d.ts +1 -1
  79. package/cjs/utils/components/index.js +1 -1
  80. package/cjs/utils/components/lineClamp.d.ts +5 -0
  81. package/cjs/utils/components/lineClamp.js +23 -0
  82. package/cjs/utils/functions/react.d.ts +5 -0
  83. package/cjs/utils/functions/react.js +18 -4
  84. package/cjs/utils/hooks/useControlledState.d.ts +5 -2
  85. package/cjs/utils/hooks/useControlledState.js +5 -1
  86. package/cjs/utils/hooks/useGlobals.d.ts +0 -1
  87. package/cjs/utils/providers/FutureFlagsProvider.d.ts +37 -0
  88. package/cjs/utils/providers/FutureFlagsProvider.js +48 -0
  89. package/cjs/utils/providers/index.d.ts +1 -0
  90. package/cjs/utils/providers/index.js +1 -0
  91. package/esm/core/Buttons/DropdownButton.d.ts +1 -1
  92. package/esm/core/Buttons/IconButton.d.ts +1 -1
  93. package/esm/core/Carousel/Carousel.d.ts +4 -4
  94. package/esm/core/Carousel/CarouselNavigation.d.ts +4 -4
  95. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
  96. package/esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
  97. package/esm/core/DropdownMenu/DropdownMenu.d.ts +1 -1
  98. package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +1 -1
  99. package/esm/core/Menu/MenuItem.d.ts +7 -1
  100. package/esm/core/Menu/MenuItem.js +8 -7
  101. package/esm/core/Popover/Popover.d.ts +5 -3
  102. package/esm/core/Select/Select.js +19 -10
  103. package/esm/core/SideNavigation/SideNavigation.js +2 -2
  104. package/esm/core/Table/ColumnHeader.js +8 -4
  105. package/esm/core/Table/Table.d.ts +2 -2
  106. package/esm/core/Table/Table.js +65 -5
  107. package/esm/core/Table/cells/DefaultCell.js +15 -10
  108. package/esm/core/Table/columns/actionColumn.d.ts +1 -0
  109. package/esm/core/Table/columns/actionColumn.js +1 -0
  110. package/esm/core/Table/columns/expanderColumn.d.ts +2 -2
  111. package/esm/core/Table/columns/expanderColumn.js +25 -20
  112. package/esm/core/Table/columns/selectionColumn.d.ts +2 -2
  113. package/esm/core/Table/columns/selectionColumn.js +14 -8
  114. package/esm/core/Table/hooks/useExpanderCell.js +10 -6
  115. package/esm/core/Tabs/Tabs.d.ts +4 -1
  116. package/esm/core/Tag/Tag.js +11 -3
  117. package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -2
  118. package/esm/core/ThemeProvider/ThemeProvider.d.ts +8 -18
  119. package/esm/core/ThemeProvider/ThemeProvider.js +48 -42
  120. package/esm/core/Tile/Tile.d.ts +2 -2
  121. package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
  122. package/esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
  123. package/esm/core/TransferList/TransferList.d.ts +7 -5
  124. package/esm/styles.js +1 -1
  125. package/esm/utils/components/index.d.ts +1 -1
  126. package/esm/utils/components/index.js +1 -1
  127. package/esm/utils/components/lineClamp.d.ts +5 -0
  128. package/esm/utils/components/lineClamp.js +13 -0
  129. package/esm/utils/functions/react.d.ts +5 -0
  130. package/esm/utils/functions/react.js +6 -1
  131. package/esm/utils/hooks/useControlledState.d.ts +5 -2
  132. package/esm/utils/hooks/useControlledState.js +5 -1
  133. package/esm/utils/hooks/useGlobals.d.ts +0 -1
  134. package/esm/utils/providers/FutureFlagsProvider.d.ts +37 -0
  135. package/esm/utils/providers/FutureFlagsProvider.js +28 -0
  136. package/esm/utils/providers/index.d.ts +1 -0
  137. package/esm/utils/providers/index.js +1 -0
  138. package/package.json +11 -5
  139. package/styles.css +10 -10
  140. package/DEV-cjs/utils/components/LineClamp.js +0 -50
  141. package/DEV-esm/utils/components/LineClamp.js +0 -36
  142. package/cjs/utils/components/LineClamp.d.ts +0 -5
  143. package/cjs/utils/components/LineClamp.js +0 -50
  144. package/esm/utils/components/LineClamp.d.ts +0 -5
  145. package/esm/utils/components/LineClamp.js +0 -36
@@ -14,6 +14,16 @@ type ToggleSwitchProps = {
14
14
  * @default 'right'
15
15
  */
16
16
  labelPosition?: 'left' | 'right';
17
+ /**
18
+ * Passes props to wrapper.
19
+ *
20
+ * By default, `className` and `style` are applied on the wrapper element, and all other DOM props are passed to
21
+ * `<input>` element.
22
+ *
23
+ * When `wrapperProps` is passed or when the `ToggleSwitch.consistentPropsSpread` future flag is enabled, `className`
24
+ * and `style` are applied on the `<input>` element, similar to other DOM props.
25
+ */
26
+ wrapperProps?: React.HTMLAttributes<HTMLElement>;
17
27
  } & ({
18
28
  /**
19
29
  * Size of the toggle switch.
@@ -32,6 +42,17 @@ type ToggleSwitchProps = {
32
42
  });
33
43
  /**
34
44
  * A switch for turning on and off.
45
+ *
46
+ * ---
47
+ *
48
+ * By default, `className` and `style` are applied on the wrapper element, and all other DOM props are passed to `<input>`
49
+ * element.
50
+ *
51
+ * When `wrapperProps` is passed or when the `ToggleSwitch.consistentPropsSpread` future flag is enabled, `className`
52
+ * and `style` are applied on the `<input>` element, similar to other DOM props.
53
+ *
54
+ * ---
55
+ *
35
56
  * @example
36
57
  * <caption>Basic toggle</caption>
37
58
  * <ToggleSwitch onChange={(e) => console.log(e.target.checked)} defaultChecked />
@@ -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(
@@ -32,25 +32,27 @@ type TransferListListboxLabelOwnProps = {
32
32
  */
33
33
  export declare const TransferList: PolymorphicForwardRefComponent<"div", {}> & {
34
34
  /**
35
- * TransferList listbox wrapper subcomponent
35
+ * TransferList listbox wrapper subcomponent
36
36
  */
37
37
  ListboxWrapper: PolymorphicForwardRefComponent<"div", TransferListListboxWrapperOwnProps>;
38
38
  /**
39
- * TransferList listbox subcomponent
39
+ * TransferList listbox subcomponent
40
40
  */
41
41
  Listbox: PolymorphicForwardRefComponent<"ul", Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "as"> & {
42
42
  as?: "div" | undefined;
43
43
  }>;
44
44
  /**
45
- * TransferList item subcomponent
45
+ * TransferList item subcomponent.
46
+ *
47
+ * Renders a `ListItem` and is compatible with `ListItem`'s [subcomponents](https://itwinui.bentley.com/docs/list#with-subcomponents).
46
48
  */
47
49
  Item: PolymorphicForwardRefComponent<"li", TransferListItemOwnProps>;
48
50
  /**
49
- * TransferList listbox label subcomponent
51
+ * TransferList listbox label subcomponent
50
52
  */
51
53
  ListboxLabel: PolymorphicForwardRefComponent<"div", TransferListListboxLabelOwnProps>;
52
54
  /**
53
- * TransferList toolbar subcomponent
55
+ * TransferList toolbar subcomponent
54
56
  */
55
57
  Toolbar: PolymorphicForwardRefComponent<"div", object>;
56
58
  };
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.1';
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.
@@ -25,7 +25,7 @@ export type IconButtonProps = {
25
25
  * @deprecated Use `label` instead.
26
26
  */
27
27
  title?: string;
28
- } & Omit<ButtonProps, 'startIcon' | 'endIcon' | 'startIconProps' | 'endIconProps' | 'labelProps' | 'loading'>;
28
+ } & Omit<ButtonProps, 'startIcon' | 'endIcon' | 'startIconProps' | 'endIconProps' | 'labelProps' | 'loading' | 'stretched'>;
29
29
  /**
30
30
  * Icon button
31
31
  * @example
@@ -40,22 +40,22 @@ export declare const Carousel: PolymorphicForwardRefComponent<"section", Carouse
40
40
  * Contains the dots and previous/next buttons for navigating the slides. Must be present _before_ the slides in DOM.
41
41
  */
42
42
  Navigation: PolymorphicForwardRefComponent<"div", {}> & {
43
- PreviousButton: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "stretched" | "isActive" | "iconProps"> & {
43
+ PreviousButton: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "isActive" | "iconProps"> & {
44
44
  isActive?: boolean;
45
45
  label?: React.ReactNode;
46
46
  labelProps?: Omit<React.ComponentPropsWithoutRef<typeof import("../Tooltip/Tooltip.js").Tooltip>, "content" | "reference" | "ariaStrategy" | "children">;
47
47
  iconProps?: React.ComponentProps<"span">;
48
48
  title?: string;
49
- } & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
49
+ } & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps" | "stretched"> & {
50
50
  as?: "button" | undefined;
51
51
  }>;
52
- NextButton: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "stretched" | "isActive" | "iconProps"> & {
52
+ NextButton: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "isActive" | "iconProps"> & {
53
53
  isActive?: boolean;
54
54
  label?: React.ReactNode;
55
55
  labelProps?: Omit<React.ComponentPropsWithoutRef<typeof import("../Tooltip/Tooltip.js").Tooltip>, "content" | "reference" | "ariaStrategy" | "children">;
56
56
  iconProps?: React.ComponentProps<"span">;
57
57
  title?: string;
58
- } & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
58
+ } & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps" | "stretched"> & {
59
59
  as?: "button" | undefined;
60
60
  }>;
61
61
  };
@@ -7,22 +7,22 @@ import type { PolymorphicForwardRefComponent } from '../../utils/index.js';
7
7
  * `children` can be specified to override what is shown in this navigation section.
8
8
  */
9
9
  export declare const CarouselNavigation: PolymorphicForwardRefComponent<"div", {}> & {
10
- PreviousButton: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "stretched" | "isActive" | "iconProps"> & {
10
+ PreviousButton: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "isActive" | "iconProps"> & {
11
11
  isActive?: boolean;
12
12
  label?: React.ReactNode;
13
13
  labelProps?: Omit<React.ComponentPropsWithoutRef<typeof import("../Tooltip/Tooltip.js").Tooltip>, "content" | "reference" | "ariaStrategy" | "children">;
14
14
  iconProps?: React.ComponentProps<"span">;
15
15
  title?: string;
16
- } & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
16
+ } & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps" | "stretched"> & {
17
17
  as?: "button" | undefined;
18
18
  }>;
19
- NextButton: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "stretched" | "isActive" | "iconProps"> & {
19
+ NextButton: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "isActive" | "iconProps"> & {
20
20
  isActive?: boolean;
21
21
  label?: React.ReactNode;
22
22
  labelProps?: Omit<React.ComponentPropsWithoutRef<typeof import("../Tooltip/Tooltip.js").Tooltip>, "content" | "reference" | "ariaStrategy" | "children">;
23
23
  iconProps?: React.ComponentProps<"span">;
24
24
  title?: string;
25
- } & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps"> & {
25
+ } & Omit<import("../Buttons/Button.js").ButtonProps, "loading" | "startIcon" | "endIcon" | "labelProps" | "startIconProps" | "endIconProps" | "stretched"> & {
26
26
  as?: "button" | undefined;
27
27
  }>;
28
28
  };
@@ -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
  *
@@ -28,7 +28,7 @@ export declare const InputWithDecorations: PolymorphicForwardRefComponent<"div",
28
28
  * Although similar to `IconButton`, this subcomponent additionally collapses the padding between the button and the input/textarea
29
29
  * in `InputWithDecorations`.
30
30
  */
31
- Button: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "stretched" | "isActive" | "iconProps"> & Omit<import("../Buttons/IconButton.js").IconButtonProps, "styleType"> & {
31
+ Button: PolymorphicForwardRefComponent<"button", Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "label" | "title" | "as" | "size" | "htmlDisabled" | "styleType" | "labelProps" | "isActive" | "iconProps"> & Omit<import("../Buttons/IconButton.js").IconButtonProps, "styleType"> & {
32
32
  styleType?: import("../Buttons/IconButton.js").IconButtonProps["styleType"];
33
33
  } & {
34
34
  as?: "button" | undefined;
@@ -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(