@itwin/itwinui-react 3.0.0-dev.7 → 3.0.0-dev.8

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 (189) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/cjs/core/Alert/Alert.d.ts +20 -9
  3. package/cjs/core/Alert/Alert.js +48 -10
  4. package/cjs/core/ButtonGroup/ButtonGroup.js +41 -36
  5. package/cjs/core/Buttons/IconButton/IconButton.js +27 -44
  6. package/cjs/core/Buttons/SplitButton/SplitButton.js +3 -0
  7. package/cjs/core/ColorPicker/ColorInputPanel.js +172 -231
  8. package/cjs/core/ComboBox/ComboBox.js +3 -3
  9. package/cjs/core/ComboBox/ComboBoxDropdown.js +4 -9
  10. package/cjs/core/ComboBox/ComboBoxEndIcon.js +3 -22
  11. package/cjs/core/ComboBox/ComboBoxMenu.d.ts +2 -2
  12. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
  13. package/cjs/core/ComboBox/ComboBoxMenuItem.js +8 -6
  14. package/cjs/core/ComboBox/helpers.d.ts +1 -2
  15. package/cjs/core/DatePicker/DatePicker.d.ts +30 -8
  16. package/cjs/core/DatePicker/DatePicker.js +40 -5
  17. package/cjs/core/Dialog/Dialog.js +10 -16
  18. package/cjs/core/Dialog/DialogContext.d.ts +3 -4
  19. package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
  20. package/cjs/core/ExpandableBlock/ExpandableBlock.js +38 -15
  21. package/cjs/core/Header/HeaderSplitButton.js +1 -0
  22. package/cjs/core/Input/Input.d.ts +4 -0
  23. package/cjs/core/Input/Input.js +2 -1
  24. package/cjs/core/InputGrid/InputGrid.d.ts +25 -0
  25. package/cjs/core/InputGrid/InputGrid.js +39 -0
  26. package/cjs/core/InputGrid/index.d.ts +3 -0
  27. package/cjs/core/InputGrid/index.js +15 -0
  28. package/cjs/core/InputGroup/InputGroup.d.ts +13 -0
  29. package/cjs/core/InputGroup/InputGroup.js +35 -9
  30. package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
  31. package/cjs/core/InputWithDecorations/InputWithDecorations.js +81 -0
  32. package/cjs/core/InputWithDecorations/index.d.ts +3 -0
  33. package/cjs/core/InputWithDecorations/index.js +15 -0
  34. package/cjs/core/Label/Label.d.ts +5 -0
  35. package/cjs/core/Label/Label.js +2 -0
  36. package/cjs/core/LabeledInput/LabeledInput.d.ts +22 -16
  37. package/cjs/core/LabeledInput/LabeledInput.js +52 -29
  38. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +17 -7
  39. package/cjs/core/LabeledSelect/LabeledSelect.js +36 -17
  40. package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
  41. package/cjs/core/LabeledTextarea/LabeledTextarea.js +12 -45
  42. package/cjs/core/Menu/Menu.d.ts +1 -1
  43. package/cjs/core/Menu/Menu.js +1 -1
  44. package/cjs/core/Menu/MenuDivider.d.ts +2 -1
  45. package/cjs/core/Menu/MenuDivider.js +1 -1
  46. package/cjs/core/Menu/MenuItem.d.ts +1 -1
  47. package/cjs/core/Menu/MenuItem.js +1 -0
  48. package/cjs/core/Menu/MenuItemSkeleton.d.ts +1 -1
  49. package/cjs/core/Menu/MenuItemSkeleton.js +0 -1
  50. package/cjs/core/SearchBox/SearchBox.js +1 -1
  51. package/cjs/core/Select/Select.d.ts +4 -0
  52. package/cjs/core/Select/Select.js +10 -9
  53. package/cjs/core/SideNavigation/SideNavigation.js +2 -0
  54. package/cjs/core/Slider/Thumb.js +1 -0
  55. package/cjs/core/StatusMessage/StatusMessage.d.ts +12 -2
  56. package/cjs/core/StatusMessage/StatusMessage.js +23 -9
  57. package/cjs/core/Table/SubRowExpander.js +2 -0
  58. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
  59. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +46 -18
  60. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
  61. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
  62. package/cjs/core/Textarea/Textarea.d.ts +7 -1
  63. package/cjs/core/Textarea/Textarea.js +6 -11
  64. package/cjs/core/ThemeProvider/ThemeProvider.js +1 -1
  65. package/cjs/core/Tile/Tile.d.ts +139 -15
  66. package/cjs/core/Tile/Tile.js +107 -16
  67. package/cjs/core/Toast/Toast.d.ts +12 -4
  68. package/cjs/core/Toast/Toast.js +20 -4
  69. package/cjs/core/Tooltip/Tooltip.d.ts +35 -28
  70. package/cjs/core/Tooltip/Tooltip.js +116 -117
  71. package/cjs/core/TransferList/TransferList.js +4 -12
  72. package/cjs/core/index.d.ts +2 -0
  73. package/cjs/core/index.js +20 -4
  74. package/cjs/core/utils/components/Icon.d.ts +5 -0
  75. package/cjs/core/utils/components/Icon.js +8 -1
  76. package/cjs/core/utils/components/InputContainer.d.ts +0 -1
  77. package/cjs/core/utils/components/InputContainer.js +14 -34
  78. package/cjs/core/utils/components/InputFlexContainer.d.ts +1 -0
  79. package/cjs/core/utils/components/InputFlexContainer.js +3 -1
  80. package/cjs/core/utils/components/Portal.d.ts +27 -0
  81. package/cjs/core/utils/components/Portal.js +43 -0
  82. package/cjs/core/utils/components/index.d.ts +1 -0
  83. package/cjs/core/utils/components/index.js +1 -0
  84. package/cjs/core/utils/functions/index.d.ts +1 -0
  85. package/cjs/core/utils/functions/index.js +1 -0
  86. package/cjs/core/utils/functions/react.d.ts +8 -0
  87. package/cjs/core/utils/functions/react.js +40 -0
  88. package/cjs/core/utils/hooks/index.d.ts +1 -1
  89. package/cjs/core/utils/hooks/index.js +1 -1
  90. package/cjs/core/utils/hooks/useControlledState.d.ts +13 -0
  91. package/cjs/core/utils/hooks/useControlledState.js +39 -0
  92. package/cjs/styles.js +10 -28
  93. package/esm/core/Alert/Alert.d.ts +20 -9
  94. package/esm/core/Alert/Alert.js +49 -10
  95. package/esm/core/ButtonGroup/ButtonGroup.js +41 -36
  96. package/esm/core/Buttons/IconButton/IconButton.js +25 -40
  97. package/esm/core/Buttons/SplitButton/SplitButton.js +9 -1
  98. package/esm/core/ColorPicker/ColorInputPanel.js +173 -232
  99. package/esm/core/ComboBox/ComboBox.js +3 -3
  100. package/esm/core/ComboBox/ComboBoxDropdown.js +4 -9
  101. package/esm/core/ComboBox/ComboBoxEndIcon.js +4 -25
  102. package/esm/core/ComboBox/ComboBoxMenu.d.ts +2 -2
  103. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
  104. package/esm/core/ComboBox/ComboBoxMenuItem.js +9 -7
  105. package/esm/core/ComboBox/helpers.d.ts +1 -2
  106. package/esm/core/DatePicker/DatePicker.d.ts +30 -8
  107. package/esm/core/DatePicker/DatePicker.js +25 -5
  108. package/esm/core/Dialog/Dialog.js +11 -23
  109. package/esm/core/Dialog/DialogContext.d.ts +3 -4
  110. package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
  111. package/esm/core/ExpandableBlock/ExpandableBlock.js +39 -17
  112. package/esm/core/Header/HeaderSplitButton.js +1 -0
  113. package/esm/core/Input/Input.d.ts +4 -0
  114. package/esm/core/Input/Input.js +2 -1
  115. package/esm/core/InputGrid/InputGrid.d.ts +25 -0
  116. package/esm/core/InputGrid/InputGrid.js +35 -0
  117. package/esm/core/InputGrid/index.d.ts +3 -0
  118. package/esm/core/InputGrid/index.js +6 -0
  119. package/esm/core/InputGroup/InputGroup.d.ts +13 -0
  120. package/esm/core/InputGroup/InputGroup.js +34 -10
  121. package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
  122. package/esm/core/InputWithDecorations/InputWithDecorations.js +80 -0
  123. package/esm/core/InputWithDecorations/index.d.ts +3 -0
  124. package/esm/core/InputWithDecorations/index.js +6 -0
  125. package/esm/core/Label/Label.d.ts +5 -0
  126. package/esm/core/Label/Label.js +2 -0
  127. package/esm/core/LabeledInput/LabeledInput.d.ts +22 -16
  128. package/esm/core/LabeledInput/LabeledInput.js +53 -29
  129. package/esm/core/LabeledSelect/LabeledSelect.d.ts +17 -7
  130. package/esm/core/LabeledSelect/LabeledSelect.js +37 -18
  131. package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
  132. package/esm/core/LabeledTextarea/LabeledTextarea.js +14 -45
  133. package/esm/core/Menu/Menu.d.ts +1 -1
  134. package/esm/core/Menu/Menu.js +1 -1
  135. package/esm/core/Menu/MenuDivider.d.ts +2 -1
  136. package/esm/core/Menu/MenuDivider.js +1 -1
  137. package/esm/core/Menu/MenuItem.d.ts +1 -1
  138. package/esm/core/Menu/MenuItem.js +1 -0
  139. package/esm/core/Menu/MenuItemSkeleton.d.ts +1 -1
  140. package/esm/core/Menu/MenuItemSkeleton.js +0 -1
  141. package/esm/core/SearchBox/SearchBox.js +1 -1
  142. package/esm/core/Select/Select.d.ts +4 -0
  143. package/esm/core/Select/Select.js +10 -9
  144. package/esm/core/SideNavigation/SideNavigation.js +2 -0
  145. package/esm/core/Slider/Thumb.js +1 -0
  146. package/esm/core/StatusMessage/StatusMessage.d.ts +12 -2
  147. package/esm/core/StatusMessage/StatusMessage.js +23 -16
  148. package/esm/core/Table/SubRowExpander.js +2 -0
  149. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
  150. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +45 -17
  151. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
  152. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
  153. package/esm/core/Textarea/Textarea.d.ts +7 -1
  154. package/esm/core/Textarea/Textarea.js +6 -11
  155. package/esm/core/ThemeProvider/ThemeProvider.js +4 -3
  156. package/esm/core/Tile/Tile.d.ts +139 -15
  157. package/esm/core/Tile/Tile.js +107 -16
  158. package/esm/core/Toast/Toast.d.ts +12 -4
  159. package/esm/core/Toast/Toast.js +21 -4
  160. package/esm/core/Tooltip/Tooltip.d.ts +35 -28
  161. package/esm/core/Tooltip/Tooltip.js +119 -116
  162. package/esm/core/TransferList/TransferList.js +4 -9
  163. package/esm/core/index.d.ts +2 -0
  164. package/esm/core/index.js +2 -0
  165. package/esm/core/utils/components/Icon.d.ts +5 -0
  166. package/esm/core/utils/components/Icon.js +8 -1
  167. package/esm/core/utils/components/InputContainer.d.ts +0 -1
  168. package/esm/core/utils/components/InputContainer.js +14 -30
  169. package/esm/core/utils/components/InputFlexContainer.d.ts +1 -0
  170. package/esm/core/utils/components/InputFlexContainer.js +3 -1
  171. package/esm/core/utils/components/Portal.d.ts +27 -0
  172. package/esm/core/utils/components/Portal.js +36 -0
  173. package/esm/core/utils/components/index.d.ts +1 -0
  174. package/esm/core/utils/components/index.js +1 -0
  175. package/esm/core/utils/functions/index.d.ts +1 -0
  176. package/esm/core/utils/functions/index.js +1 -0
  177. package/esm/core/utils/functions/react.d.ts +8 -0
  178. package/esm/core/utils/functions/react.js +35 -0
  179. package/esm/core/utils/hooks/index.d.ts +1 -1
  180. package/esm/core/utils/hooks/index.js +1 -1
  181. package/esm/core/utils/hooks/useControlledState.d.ts +13 -0
  182. package/esm/core/utils/hooks/useControlledState.js +34 -0
  183. package/esm/styles.js +10 -28
  184. package/package.json +3 -3
  185. package/styles.css +22 -19
  186. package/cjs/core/utils/hooks/useUncontrolledState.d.ts +0 -6
  187. package/cjs/core/utils/hooks/useUncontrolledState.js +0 -18
  188. package/esm/core/utils/hooks/useUncontrolledState.d.ts +0 -6
  189. package/esm/core/utils/hooks/useUncontrolledState.js +0 -13
@@ -13,6 +13,7 @@ import {
13
13
  polymorphic,
14
14
  } from '../utils/index.js';
15
15
  import { List, ListItem } from '../List/index.js';
16
+ import { Label } from '../Label/index.js';
16
17
  // ----------------------------------------------------------------------------
17
18
  // TransferListComponent
18
19
  const TransferListComponent = polymorphic('iui-transfer-list-wrapper');
@@ -143,7 +144,7 @@ const TransferListItem = React.forwardRef((props, ref) => {
143
144
  });
144
145
  TransferListItem.displayName = 'TransferList.Item';
145
146
  const TransferListListboxLabel = React.forwardRef((props, ref) => {
146
- const { children, className, id, ...rest } = props;
147
+ const { children, id, ...rest } = props;
147
148
  const { labelId, setLabelId } = useSafeContext(TransferListContext);
148
149
  React.useEffect(() => {
149
150
  if (id && id !== labelId) {
@@ -151,14 +152,8 @@ const TransferListListboxLabel = React.forwardRef((props, ref) => {
151
152
  }
152
153
  }, [id, labelId, setLabelId]);
153
154
  return React.createElement(
154
- Box,
155
- {
156
- as: 'div',
157
- className: cx('iui-transfer-list-listbox-label', className),
158
- id: labelId,
159
- ref: ref,
160
- ...rest,
161
- },
155
+ Label,
156
+ { as: 'div', id: labelId, ref: ref, ...rest },
162
157
  children,
163
158
  );
164
159
  });
@@ -26,6 +26,8 @@ export { TransferList } from './TransferList/index.js';
26
26
  export { Tabs, Tab } from './Tabs/index.js';
27
27
  export { InformationPanel, InformationPanelWrapper, InformationPanelHeader, InformationPanelBody, InformationPanelContent, } from './InformationPanel/index.js';
28
28
  export { Input } from './Input/index.js';
29
+ export { InputWithDecorations } from './InputWithDecorations/InputWithDecorations.js';
30
+ export { InputGrid } from './InputGrid/InputGrid.js';
29
31
  export { Label } from './Label/index.js';
30
32
  export { LabeledInput } from './LabeledInput/index.js';
31
33
  export { InputGroup } from './InputGroup/index.js';
package/esm/core/index.js CHANGED
@@ -56,6 +56,8 @@ export {
56
56
  InformationPanelContent,
57
57
  } from './InformationPanel/index.js';
58
58
  export { Input } from './Input/index.js';
59
+ export { InputWithDecorations } from './InputWithDecorations/InputWithDecorations.js';
60
+ export { InputGrid } from './InputGrid/InputGrid.js';
59
61
  export { Label } from './Label/index.js';
60
62
  export { LabeledInput } from './LabeledInput/index.js';
61
63
  export { InputGroup } from './InputGroup/index.js';
@@ -24,6 +24,11 @@ export type IconProps = {
24
24
  * @default 'default'
25
25
  */
26
26
  fill?: 'default' | 'positive' | 'informational' | 'negative' | 'warning' | AnyString;
27
+ /**
28
+ * Option to add padding to the icon.
29
+ * @default false
30
+ */
31
+ padded?: boolean;
27
32
  } & React.ComponentPropsWithoutRef<'span'>;
28
33
  /**
29
34
  * A utility component to provide size and fill to svgs.
@@ -32,12 +32,19 @@ const getSizeValue = (size) => {
32
32
  * </Icon>
33
33
  */
34
34
  export const Icon = React.forwardRef((props, ref) => {
35
- const { size = 'medium', fill = 'default', className, ...rest } = props;
35
+ const {
36
+ size = 'medium',
37
+ fill = 'default',
38
+ className,
39
+ padded = false,
40
+ ...rest
41
+ } = props;
36
42
  return React.createElement(Box, {
37
43
  as: 'span',
38
44
  className: cx('iui-svg-icon', className),
39
45
  'data-iui-icon-size': getSizeValue(size),
40
46
  'data-iui-icon-color': fill,
47
+ 'data-iui-padded': padded ? 'true' : undefined,
41
48
  ref: ref,
42
49
  ...rest,
43
50
  });
@@ -8,7 +8,6 @@ export type InputContainerProps<T extends React.ElementType = 'div'> = {
8
8
  message?: React.ReactNode;
9
9
  icon?: JSX.Element;
10
10
  isLabelInline?: boolean;
11
- isIconInline?: boolean;
12
11
  statusMessage?: React.ReactNode;
13
12
  inputId?: string;
14
13
  labelId?: string;
@@ -5,6 +5,8 @@
5
5
  import * as React from 'react';
6
6
  import cx from 'classnames';
7
7
  import { Box } from './Box.js';
8
+ import { Label } from '../../Label/index.js';
9
+ import { StatusMessage } from '../../StatusMessage/index.js';
8
10
  /**
9
11
  * Input container to wrap inputs with label, and add optional message and icon.
10
12
  * @private
@@ -18,7 +20,6 @@ export const InputContainer = (props) => {
18
20
  message,
19
21
  icon,
20
22
  isLabelInline,
21
- isIconInline,
22
23
  children,
23
24
  className,
24
25
  style,
@@ -30,29 +31,19 @@ export const InputContainer = (props) => {
30
31
  return React.createElement(
31
32
  Box,
32
33
  {
33
- className: cx(
34
- 'iui-input-container',
35
- {
36
- 'iui-disabled': disabled,
37
- [`iui-${status}`]: !!status,
38
- 'iui-inline-label': isLabelInline,
39
- 'iui-inline-icon': isIconInline,
40
- 'iui-with-message':
41
- (!!message || !!icon || !!statusMessage) && !isLabelInline,
42
- },
43
- className,
44
- ),
34
+ className: cx('iui-input-grid', className),
35
+ 'data-iui-status': status,
36
+ 'data-iui-label-placement': isLabelInline ? 'inline' : undefined,
45
37
  style: style,
46
38
  ...rest,
47
39
  },
48
40
  label &&
49
41
  React.createElement(
50
- Box,
42
+ Label,
51
43
  {
52
44
  as: inputId && props.as !== 'label' ? 'label' : 'div',
53
- className: cx('iui-label', {
54
- 'iui-required': required,
55
- }),
45
+ required: required,
46
+ disabled: disabled,
56
47
  htmlFor: inputId,
57
48
  id: labelId,
58
49
  },
@@ -61,18 +52,11 @@ export const InputContainer = (props) => {
61
52
  children,
62
53
  statusMessage
63
54
  ? statusMessage
64
- : React.createElement(
65
- React.Fragment,
66
- null,
67
- icon &&
68
- React.createElement(
69
- Box,
70
- { as: 'span', className: 'iui-input-icon', 'aria-hidden': true },
71
- icon,
72
- ),
73
- message &&
74
- !isLabelInline &&
75
- React.createElement(Box, { className: 'iui-message' }, message),
76
- ),
55
+ : message &&
56
+ React.createElement(
57
+ StatusMessage,
58
+ { startIcon: icon, status: status },
59
+ message,
60
+ ),
77
61
  );
78
62
  };
@@ -2,6 +2,7 @@ import type { PolymorphicForwardRefComponent } from '../props.js';
2
2
  export type InputFlexContainerProps = {
3
3
  isDisabled?: boolean;
4
4
  status?: 'positive' | 'warning' | 'negative';
5
+ size?: 'small' | 'large';
5
6
  };
6
7
  /**
7
8
  * Utility component for input container with display flex abilities.
@@ -10,12 +10,14 @@ import { Box } from './Box.js';
10
10
  * @private
11
11
  */
12
12
  export const InputFlexContainer = React.forwardRef((props, ref) => {
13
- const { isDisabled, status, children, className, style, ...rest } = props;
13
+ const { isDisabled, status, children, className, size, style, ...rest } =
14
+ props;
14
15
  return React.createElement(
15
16
  Box,
16
17
  {
17
18
  className: cx('iui-input-flex-container', className),
18
19
  'data-iui-status': status,
20
+ 'data-iui-size': size,
19
21
  'data-iui-disabled': isDisabled ? 'true' : undefined,
20
22
  ref: ref,
21
23
  style: style,
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ export type PortalProps = {
3
+ /**
4
+ * Where should the element be portaled to?
5
+ *
6
+ * If true, it will portal into nearest ThemeContext.portalContainer.
7
+ *
8
+ * If false, it will not be portaled.
9
+ *
10
+ * Otherwise, it will portal to the element passed to `to`.
11
+ *
12
+ * @default true
13
+ */
14
+ portal?: boolean | {
15
+ to: HTMLElement | (() => HTMLElement);
16
+ };
17
+ };
18
+ /**
19
+ * Helper component that portals children according to the following conditions:
20
+ * - renders null on server
21
+ * - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
22
+ * - if `portal` is set to false, renders as-is without portal
23
+ * - otherwise renders into `portal.to` (can be an element or a function)
24
+ *
25
+ * @private
26
+ */
27
+ export declare const Portal: (props: React.PropsWithChildren<PortalProps>) => React.ReactNode;
@@ -0,0 +1,36 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from 'react';
6
+ import * as ReactDOM from 'react-dom';
7
+ import { ThemeContext } from '../../ThemeProvider/ThemeContext.js';
8
+ import { getDocument } from '../functions/dom.js';
9
+ import { useIsClient } from '../hooks/useIsClient.js';
10
+ // ----------------------------------------------------------------------------
11
+ /**
12
+ * Helper component that portals children according to the following conditions:
13
+ * - renders null on server
14
+ * - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
15
+ * - if `portal` is set to false, renders as-is without portal
16
+ * - otherwise renders into `portal.to` (can be an element or a function)
17
+ *
18
+ * @private
19
+ */
20
+ export const Portal = (props) => {
21
+ const { portal = true, children } = props;
22
+ const isClient = useIsClient();
23
+ const portalTo = usePortalTo(portal);
24
+ if (!isClient) {
25
+ return null;
26
+ }
27
+ return portalTo ? ReactDOM.createPortal(children, portalTo) : children;
28
+ };
29
+ // ----------------------------------------------------------------------------
30
+ const usePortalTo = (portal) => {
31
+ const themeInfo = React.useContext(ThemeContext);
32
+ if (typeof portal === 'boolean') {
33
+ return portal ? themeInfo?.portalContainer ?? getDocument()?.body : null;
34
+ }
35
+ return typeof portal.to === 'function' ? portal.to() : portal.to;
36
+ };
@@ -14,3 +14,4 @@ export * from './LinkAction.js';
14
14
  export * from './AutoclearingHiddenLiveRegion.js';
15
15
  export * from './Box.js';
16
16
  export * from './ButtonBase.js';
17
+ export * from './Portal.js';
@@ -18,3 +18,4 @@ export * from './LinkAction.js';
18
18
  export * from './AutoclearingHiddenLiveRegion.js';
19
19
  export * from './Box.js';
20
20
  export * from './ButtonBase.js';
21
+ export * from './Portal.js';
@@ -6,3 +6,4 @@ export * from './focusable.js';
6
6
  export * from './supports.js';
7
7
  export * from './polymorphic.js';
8
8
  export * from './import.js';
9
+ export * from './react.js';
@@ -10,3 +10,4 @@ export * from './focusable.js';
10
10
  export * from './supports.js';
11
11
  export * from './polymorphic.js';
12
12
  export * from './import.js';
13
+ export * from './react.js';
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Wrapper over `cloneElement` that automatically checks for `isValidElement`
4
+ * and automatically merges `children.ref` with the ref passed in props.
5
+ *
6
+ * @private
7
+ */
8
+ export declare const cloneElementWithRef: (children: React.ReactNode, getProps: (children: JSX.Element) => Record<string, unknown>) => string | number | true | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null;
@@ -0,0 +1,35 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from 'react';
6
+ import { mergeRefs } from '../hooks/useMergedRefs.js';
7
+ /**
8
+ * Wrapper over `cloneElement` that automatically checks for `isValidElement`
9
+ * and automatically merges `children.ref` with the ref passed in props.
10
+ *
11
+ * @private
12
+ */
13
+ export const cloneElementWithRef = (children, getProps) => {
14
+ if (!children) {
15
+ return null;
16
+ }
17
+ if (!React.isValidElement(children)) {
18
+ return children;
19
+ }
20
+ const props = getProps(children);
21
+ const ref = mergeRefs(
22
+ ...[
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ 'ref' in children ? children.ref : null,
25
+ 'ref' in props ? props.ref : null,
26
+ ].filter(Boolean),
27
+ );
28
+ return React.cloneElement(children, {
29
+ ...props,
30
+ // we already checked ref above and handled null, so ts-ignore is ok
31
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
32
+ // @ts-ignore
33
+ ref,
34
+ });
35
+ };
@@ -11,4 +11,4 @@ export * from './useLatestRef.js';
11
11
  export * from './useIsomorphicLayoutEffect.js';
12
12
  export * from './useIsClient.js';
13
13
  export * from './useId.js';
14
- export * from './useUncontrolledState.js';
14
+ export * from './useControlledState.js';
@@ -15,4 +15,4 @@ export * from './useLatestRef.js';
15
15
  export * from './useIsomorphicLayoutEffect.js';
16
16
  export * from './useIsClient.js';
17
17
  export * from './useId.js';
18
- export * from './useUncontrolledState.js';
18
+ export * from './useControlledState.js';
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Wrapper over `useState` that always gives preference to the
4
+ * controlled state (which often comes from a prop).
5
+ *
6
+ * This is helpful when a component needs to support both uncontrolled
7
+ * and controlled states. If controlled value/setter is not passed,
8
+ * then it will work just like a regular `useState`.
9
+ *
10
+ * @example
11
+ * const [state, setState] = useControlledState(null, props.value, props.onChange);
12
+ */
13
+ export declare const useControlledState: <T>(initialValue: T, controlledState: T, setControlledState?: React.Dispatch<React.SetStateAction<T>> | undefined) => readonly [T, React.Dispatch<React.SetStateAction<T>>];
@@ -0,0 +1,34 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from 'react';
6
+ /**
7
+ * Wrapper over `useState` that always gives preference to the
8
+ * controlled state (which often comes from a prop).
9
+ *
10
+ * This is helpful when a component needs to support both uncontrolled
11
+ * and controlled states. If controlled value/setter is not passed,
12
+ * then it will work just like a regular `useState`.
13
+ *
14
+ * @example
15
+ * const [state, setState] = useControlledState(null, props.value, props.onChange);
16
+ */
17
+ export const useControlledState = (
18
+ initialValue,
19
+ controlledState,
20
+ setControlledState,
21
+ ) => {
22
+ const [uncontrolledState, setUncontrolledState] =
23
+ React.useState(initialValue);
24
+ const state =
25
+ controlledState !== undefined ? controlledState : uncontrolledState;
26
+ const setState = React.useCallback(
27
+ (value) => {
28
+ setUncontrolledState(value);
29
+ setControlledState?.(value);
30
+ },
31
+ [setControlledState, setUncontrolledState],
32
+ );
33
+ return [state, setState];
34
+ };
package/esm/styles.js CHANGED
@@ -33,8 +33,9 @@ const styles = {
33
33
  'iui-button-dropdown': '_iui3-button-dropdown',
34
34
  'iui-button-split': '_iui3-button-split',
35
35
  'iui-button-group': '_iui3-button-group',
36
- 'iui-input-container': '_iui3-input-container',
36
+ 'iui-input-flex-container': '_iui3-input-flex-container',
37
37
  'iui-input': '_iui3-input',
38
+ 'iui-input-grid': '_iui3-input-grid',
38
39
  'iui-disabled': '_iui3-disabled',
39
40
  'iui-button-group-vertical': '_iui3-button-group-vertical',
40
41
  'iui-button-group-overflow-x': '_iui3-button-group-overflow-x',
@@ -177,36 +178,18 @@ const styles = {
177
178
  'iui-information-body-content': '_iui3-information-body-content',
178
179
  'iui-input-label': '_iui3-input-label',
179
180
  'iui-inline': '_iui3-inline',
180
- 'iui-required': '_iui3-required',
181
181
  'iui-input-with-icon': '_iui3-input-with-icon',
182
182
  'iui-select-tag-container': '_iui3-select-tag-container',
183
183
  'iui-end-icon': '_iui3-end-icon',
184
- 'iui-actionable': '_iui3-actionable',
185
184
  'iui-open': '_iui3-open',
186
- 'iui-inline-icon': '_iui3-inline-icon',
187
- 'iui-with-message': '_iui3-with-message',
188
- 'iui-input-icon': '_iui3-input-icon',
185
+ 'iui-required': '_iui3-required',
189
186
  'iui-input-group': '_iui3-input-group',
187
+ 'iui-status-message': '_iui3-status-message',
188
+ 'iui-select-button': '_iui3-select-button',
189
+ 'iui-input-group-wrapper': '_iui3-input-group-wrapper',
190
190
  'iui-toggle-switch-wrapper': '_iui3-toggle-switch-wrapper',
191
191
  'iui-radio-wrapper': '_iui3-radio-wrapper',
192
- 'iui-inline-label': '_iui3-inline-label',
193
- 'iui-label': '_iui3-label',
194
- 'iui-message': '_iui3-message',
195
- 'iui-select-button': '_iui3-select-button',
196
- 'iui-input-flex-container': '_iui3-input-flex-container',
197
192
  'iui-keyboard': '_iui3-keyboard',
198
- 'iui-location-marker': '_iui3-location-marker',
199
- 'iui-location-marker-default': '_iui3-location-marker-default',
200
- 'iui-location-marker-default-pin': '_iui3-location-marker-default-pin',
201
- 'iui-location-marker-default-pin-dot':
202
- '_iui3-location-marker-default-pin-dot',
203
- 'iui-location-marker-data-rich': '_iui3-location-marker-data-rich',
204
- 'iui-location-marker-data-rich-body': '_iui3-location-marker-data-rich-body',
205
- 'iui-location-marker-data-rich-icon': '_iui3-location-marker-data-rich-icon',
206
- 'iui-location-marker-data-rich-icon-monochrome':
207
- '_iui3-location-marker-data-rich-icon-monochrome',
208
- 'iui-location-marker-me': '_iui3-location-marker-me',
209
- 'iui-location-marker-me-dot': '_iui3-location-marker-me-dot',
210
193
  'iui-list': '_iui3-list',
211
194
  'iui-menu': '_iui3-menu',
212
195
  'iui-header-menu-icon': '_iui3-header-menu-icon',
@@ -235,10 +218,10 @@ const styles = {
235
218
  'iui-overlay-exiting': '_iui3-overlay-exiting',
236
219
  closeAnimation,
237
220
  'iui-progress-indicator-radial': '_iui3-progress-indicator-radial',
238
- 'iui-u8bwhh6': '_iui3-u8bwhh6',
221
+ 'iui-ubn95wp': '_iui3-ubn95wp',
239
222
  'iui-progress-indicator-linear-label':
240
223
  '_iui3-progress-indicator-linear-label',
241
- 'iui-u8bwhhv': '_iui3-u8bwhhv',
224
+ 'iui-ubn95xj': '_iui3-ubn95xj',
242
225
  'iui-radio': '_iui3-radio',
243
226
  'iui-radio-tile': '_iui3-radio-tile',
244
227
  'iui-radio-tile-icon': '_iui3-radio-tile-icon',
@@ -305,6 +288,7 @@ const styles = {
305
288
  'iui-table-body': '_iui3-table-body',
306
289
  'iui-table-header-wrapper': '_iui3-table-header-wrapper',
307
290
  'iui-slot': '_iui3-slot',
291
+ 'iui-actionable': '_iui3-actionable',
308
292
  'iui-table-filter-button': '_iui3-table-filter-button',
309
293
  'iui-table-resizer': '_iui3-table-resizer',
310
294
  'iui-table-resizer-bar': '_iui3-table-resizer-bar',
@@ -401,6 +385,7 @@ const styles = {
401
385
  'iui-placement-bottom-start': '_iui3-placement-bottom-start',
402
386
  'iui-placement-bottom-end': '_iui3-placement-bottom-end',
403
387
  'iui-status-area': '_iui3-status-area',
388
+ 'iui-message': '_iui3-message',
404
389
  'iui-toast-anchor': '_iui3-toast-anchor',
405
390
  'iui-informational': '_iui3-informational',
406
391
  'iui-label-on-left': '_iui3-label-on-left',
@@ -408,11 +393,8 @@ const styles = {
408
393
  'iui-toggle-switch-icon': '_iui3-toggle-switch-icon',
409
394
  'iui-toggle-switch': '_iui3-toggle-switch',
410
395
  'iui-toggle-switch-label': '_iui3-toggle-switch-label',
411
- 'iui-tooltip-container': '_iui3-tooltip-container',
412
396
  'iui-tooltip': '_iui3-tooltip',
413
- 'iui-tooltip-visible': '_iui3-tooltip-visible',
414
397
  'iui-transfer-list-wrapper': '_iui3-transfer-list-wrapper',
415
- 'iui-transfer-list-listbox-label': '_iui3-transfer-list-listbox-label',
416
398
  'iui-transfer-list-listbox-wrapper': '_iui3-transfer-list-listbox-wrapper',
417
399
  'iui-transfer-list-listbox': '_iui3-transfer-list-listbox',
418
400
  'iui-transfer-list-toolbar': '_iui3-transfer-list-toolbar',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "3.0.0-dev.7",
3
+ "version": "3.0.0-dev.8",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -73,7 +73,7 @@
73
73
  "dev:styles": "yarn build:styles --watch"
74
74
  },
75
75
  "dependencies": {
76
- "@floating-ui/react": "^0.24.3",
76
+ "@floating-ui/react": "^0.25.2",
77
77
  "@tippyjs/react": "^4.2.6",
78
78
  "@types/react-table": "^7.0.18",
79
79
  "classnames": "^2.2.6",
@@ -83,7 +83,7 @@
83
83
  "tslib": "^2.6.0"
84
84
  },
85
85
  "devDependencies": {
86
- "@itwin/itwinui-css": "^2.0.0-dev.7",
86
+ "@itwin/itwinui-css": "^2.0.0-dev.8",
87
87
  "@itwin/itwinui-illustrations-react": "^2.1.0",
88
88
  "@itwin/itwinui-variables": "3.0.0-dev.1",
89
89
  "@swc/cli": "^0.1.62",