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

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 (215) hide show
  1. package/CHANGELOG.md +68 -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/DropdownButton/DropdownButton.js +7 -19
  6. package/cjs/core/Buttons/IconButton/IconButton.js +27 -44
  7. package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +4 -4
  8. package/cjs/core/Buttons/SplitButton/SplitButton.js +54 -29
  9. package/cjs/core/ColorPicker/ColorInputPanel.js +172 -231
  10. package/cjs/core/ComboBox/ComboBox.d.ts +2 -2
  11. package/cjs/core/ComboBox/ComboBox.js +33 -25
  12. package/cjs/core/ComboBox/ComboBoxEndIcon.js +3 -22
  13. package/cjs/core/ComboBox/ComboBoxInput.js +29 -21
  14. package/cjs/core/ComboBox/ComboBoxMenu.d.ts +2 -2
  15. package/cjs/core/ComboBox/ComboBoxMenu.js +73 -93
  16. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
  17. package/cjs/core/ComboBox/ComboBoxMenuItem.js +8 -6
  18. package/cjs/core/ComboBox/helpers.d.ts +5 -3
  19. package/cjs/core/DatePicker/DatePicker.d.ts +30 -8
  20. package/cjs/core/DatePicker/DatePicker.js +40 -5
  21. package/cjs/core/Dialog/Dialog.js +10 -16
  22. package/cjs/core/Dialog/DialogContext.d.ts +3 -4
  23. package/cjs/core/DropdownMenu/DropdownMenu.d.ts +6 -5
  24. package/cjs/core/DropdownMenu/DropdownMenu.js +59 -55
  25. package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
  26. package/cjs/core/ExpandableBlock/ExpandableBlock.js +38 -15
  27. package/cjs/core/Header/HeaderDropdownButton.js +1 -2
  28. package/cjs/core/Header/HeaderSplitButton.js +2 -2
  29. package/cjs/core/Input/Input.d.ts +4 -0
  30. package/cjs/core/Input/Input.js +2 -1
  31. package/cjs/core/InputGrid/InputGrid.d.ts +25 -0
  32. package/cjs/core/InputGrid/InputGrid.js +39 -0
  33. package/cjs/core/InputGrid/index.d.ts +3 -0
  34. package/cjs/core/InputGrid/index.js +15 -0
  35. package/cjs/core/InputGroup/InputGroup.d.ts +13 -0
  36. package/cjs/core/InputGroup/InputGroup.js +35 -9
  37. package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
  38. package/cjs/core/InputWithDecorations/InputWithDecorations.js +81 -0
  39. package/cjs/core/InputWithDecorations/index.d.ts +3 -0
  40. package/cjs/core/InputWithDecorations/index.js +15 -0
  41. package/cjs/core/Label/Label.d.ts +5 -0
  42. package/cjs/core/Label/Label.js +2 -0
  43. package/cjs/core/LabeledInput/LabeledInput.d.ts +22 -16
  44. package/cjs/core/LabeledInput/LabeledInput.js +52 -29
  45. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +17 -7
  46. package/cjs/core/LabeledSelect/LabeledSelect.js +36 -17
  47. package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
  48. package/cjs/core/LabeledTextarea/LabeledTextarea.js +12 -45
  49. package/cjs/core/Menu/Menu.d.ts +1 -1
  50. package/cjs/core/Menu/Menu.js +2 -2
  51. package/cjs/core/Menu/MenuDivider.d.ts +2 -1
  52. package/cjs/core/Menu/MenuDivider.js +1 -1
  53. package/cjs/core/Menu/MenuItem.d.ts +1 -1
  54. package/cjs/core/Menu/MenuItem.js +78 -55
  55. package/cjs/core/Menu/MenuItemSkeleton.d.ts +1 -1
  56. package/cjs/core/Menu/MenuItemSkeleton.js +0 -1
  57. package/cjs/core/SearchBox/SearchBox.js +1 -1
  58. package/cjs/core/Select/Select.d.ts +9 -5
  59. package/cjs/core/Select/Select.js +81 -99
  60. package/cjs/core/SideNavigation/SideNavigation.js +2 -0
  61. package/cjs/core/Slider/Thumb.js +1 -0
  62. package/cjs/core/StatusMessage/StatusMessage.d.ts +12 -2
  63. package/cjs/core/StatusMessage/StatusMessage.js +23 -9
  64. package/cjs/core/Table/SubRowExpander.js +2 -0
  65. package/cjs/core/Table/columns/actionColumn.js +3 -7
  66. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
  67. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +56 -33
  68. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
  69. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
  70. package/cjs/core/Table/filters/FilterToggle.js +3 -2
  71. package/cjs/core/Textarea/Textarea.d.ts +7 -1
  72. package/cjs/core/Textarea/Textarea.js +6 -11
  73. package/cjs/core/ThemeProvider/ThemeProvider.js +1 -1
  74. package/cjs/core/Tile/Tile.d.ts +139 -15
  75. package/cjs/core/Tile/Tile.js +128 -38
  76. package/cjs/core/Toast/Toast.d.ts +12 -4
  77. package/cjs/core/Toast/Toast.js +20 -4
  78. package/cjs/core/Tooltip/Tooltip.d.ts +35 -28
  79. package/cjs/core/Tooltip/Tooltip.js +116 -117
  80. package/cjs/core/TransferList/TransferList.js +4 -12
  81. package/cjs/core/index.d.ts +3 -1
  82. package/cjs/core/index.js +28 -5
  83. package/cjs/core/utils/components/Icon.d.ts +5 -0
  84. package/cjs/core/utils/components/Icon.js +8 -1
  85. package/cjs/core/utils/components/InputContainer.d.ts +4 -5
  86. package/cjs/core/utils/components/InputContainer.js +21 -37
  87. package/cjs/core/utils/components/InputFlexContainer.d.ts +1 -0
  88. package/cjs/core/utils/components/InputFlexContainer.js +3 -1
  89. package/cjs/core/utils/components/Popover.d.ts +113 -27
  90. package/cjs/core/utils/components/Popover.js +156 -118
  91. package/cjs/core/utils/components/Portal.d.ts +27 -0
  92. package/cjs/core/utils/components/Portal.js +43 -0
  93. package/cjs/core/utils/components/index.d.ts +1 -0
  94. package/cjs/core/utils/components/index.js +1 -0
  95. package/cjs/core/utils/functions/index.d.ts +1 -0
  96. package/cjs/core/utils/functions/index.js +1 -0
  97. package/cjs/core/utils/functions/react.d.ts +8 -0
  98. package/cjs/core/utils/functions/react.js +40 -0
  99. package/cjs/core/utils/hooks/index.d.ts +1 -1
  100. package/cjs/core/utils/hooks/index.js +1 -1
  101. package/cjs/core/utils/hooks/useControlledState.d.ts +13 -0
  102. package/cjs/core/utils/hooks/useControlledState.js +39 -0
  103. package/cjs/styles.js +10 -31
  104. package/esm/core/Alert/Alert.d.ts +20 -9
  105. package/esm/core/Alert/Alert.js +49 -10
  106. package/esm/core/ButtonGroup/ButtonGroup.js +41 -36
  107. package/esm/core/Buttons/DropdownButton/DropdownButton.js +8 -24
  108. package/esm/core/Buttons/IconButton/IconButton.js +25 -40
  109. package/esm/core/Buttons/SplitButton/SplitButton.d.ts +4 -4
  110. package/esm/core/Buttons/SplitButton/SplitButton.js +61 -28
  111. package/esm/core/ColorPicker/ColorInputPanel.js +173 -232
  112. package/esm/core/ComboBox/ComboBox.d.ts +2 -2
  113. package/esm/core/ComboBox/ComboBox.js +34 -25
  114. package/esm/core/ComboBox/ComboBoxEndIcon.js +4 -25
  115. package/esm/core/ComboBox/ComboBoxInput.js +22 -21
  116. package/esm/core/ComboBox/ComboBoxMenu.d.ts +2 -2
  117. package/esm/core/ComboBox/ComboBoxMenu.js +67 -87
  118. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
  119. package/esm/core/ComboBox/ComboBoxMenuItem.js +9 -7
  120. package/esm/core/ComboBox/helpers.d.ts +5 -3
  121. package/esm/core/DatePicker/DatePicker.d.ts +30 -8
  122. package/esm/core/DatePicker/DatePicker.js +25 -5
  123. package/esm/core/Dialog/Dialog.js +11 -23
  124. package/esm/core/Dialog/DialogContext.d.ts +3 -4
  125. package/esm/core/DropdownMenu/DropdownMenu.d.ts +6 -5
  126. package/esm/core/DropdownMenu/DropdownMenu.js +64 -56
  127. package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
  128. package/esm/core/ExpandableBlock/ExpandableBlock.js +39 -17
  129. package/esm/core/Header/HeaderDropdownButton.js +1 -2
  130. package/esm/core/Header/HeaderSplitButton.js +2 -2
  131. package/esm/core/Input/Input.d.ts +4 -0
  132. package/esm/core/Input/Input.js +2 -1
  133. package/esm/core/InputGrid/InputGrid.d.ts +25 -0
  134. package/esm/core/InputGrid/InputGrid.js +35 -0
  135. package/esm/core/InputGrid/index.d.ts +3 -0
  136. package/esm/core/InputGrid/index.js +6 -0
  137. package/esm/core/InputGroup/InputGroup.d.ts +13 -0
  138. package/esm/core/InputGroup/InputGroup.js +34 -10
  139. package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
  140. package/esm/core/InputWithDecorations/InputWithDecorations.js +80 -0
  141. package/esm/core/InputWithDecorations/index.d.ts +3 -0
  142. package/esm/core/InputWithDecorations/index.js +6 -0
  143. package/esm/core/Label/Label.d.ts +5 -0
  144. package/esm/core/Label/Label.js +2 -0
  145. package/esm/core/LabeledInput/LabeledInput.d.ts +22 -16
  146. package/esm/core/LabeledInput/LabeledInput.js +53 -29
  147. package/esm/core/LabeledSelect/LabeledSelect.d.ts +17 -7
  148. package/esm/core/LabeledSelect/LabeledSelect.js +37 -18
  149. package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
  150. package/esm/core/LabeledTextarea/LabeledTextarea.js +14 -45
  151. package/esm/core/Menu/Menu.d.ts +1 -1
  152. package/esm/core/Menu/Menu.js +8 -3
  153. package/esm/core/Menu/MenuDivider.d.ts +2 -1
  154. package/esm/core/Menu/MenuDivider.js +1 -1
  155. package/esm/core/Menu/MenuItem.d.ts +1 -1
  156. package/esm/core/Menu/MenuItem.js +85 -52
  157. package/esm/core/Menu/MenuItemSkeleton.d.ts +1 -1
  158. package/esm/core/Menu/MenuItemSkeleton.js +0 -1
  159. package/esm/core/SearchBox/SearchBox.js +1 -1
  160. package/esm/core/Select/Select.d.ts +9 -5
  161. package/esm/core/Select/Select.js +81 -96
  162. package/esm/core/SideNavigation/SideNavigation.js +2 -0
  163. package/esm/core/Slider/Thumb.js +1 -0
  164. package/esm/core/StatusMessage/StatusMessage.d.ts +12 -2
  165. package/esm/core/StatusMessage/StatusMessage.js +23 -16
  166. package/esm/core/Table/SubRowExpander.js +2 -0
  167. package/esm/core/Table/columns/actionColumn.js +3 -7
  168. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
  169. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +56 -33
  170. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
  171. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
  172. package/esm/core/Table/filters/FilterToggle.js +3 -2
  173. package/esm/core/Textarea/Textarea.d.ts +7 -1
  174. package/esm/core/Textarea/Textarea.js +6 -11
  175. package/esm/core/ThemeProvider/ThemeProvider.js +4 -3
  176. package/esm/core/Tile/Tile.d.ts +139 -15
  177. package/esm/core/Tile/Tile.js +128 -38
  178. package/esm/core/Toast/Toast.d.ts +12 -4
  179. package/esm/core/Toast/Toast.js +21 -4
  180. package/esm/core/Tooltip/Tooltip.d.ts +35 -28
  181. package/esm/core/Tooltip/Tooltip.js +119 -116
  182. package/esm/core/TransferList/TransferList.js +4 -9
  183. package/esm/core/index.d.ts +3 -1
  184. package/esm/core/index.js +3 -0
  185. package/esm/core/utils/components/Icon.d.ts +5 -0
  186. package/esm/core/utils/components/Icon.js +8 -1
  187. package/esm/core/utils/components/InputContainer.d.ts +4 -5
  188. package/esm/core/utils/components/InputContainer.js +21 -32
  189. package/esm/core/utils/components/InputFlexContainer.d.ts +1 -0
  190. package/esm/core/utils/components/InputFlexContainer.js +3 -1
  191. package/esm/core/utils/components/Popover.d.ts +113 -27
  192. package/esm/core/utils/components/Popover.js +175 -118
  193. package/esm/core/utils/components/Portal.d.ts +27 -0
  194. package/esm/core/utils/components/Portal.js +36 -0
  195. package/esm/core/utils/components/index.d.ts +1 -0
  196. package/esm/core/utils/components/index.js +1 -0
  197. package/esm/core/utils/functions/index.d.ts +1 -0
  198. package/esm/core/utils/functions/index.js +1 -0
  199. package/esm/core/utils/functions/react.d.ts +8 -0
  200. package/esm/core/utils/functions/react.js +35 -0
  201. package/esm/core/utils/hooks/index.d.ts +1 -1
  202. package/esm/core/utils/hooks/index.js +1 -1
  203. package/esm/core/utils/hooks/useControlledState.d.ts +13 -0
  204. package/esm/core/utils/hooks/useControlledState.js +34 -0
  205. package/esm/styles.js +10 -31
  206. package/package.json +3 -5
  207. package/styles.css +23 -20
  208. package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +0 -7
  209. package/cjs/core/ComboBox/ComboBoxDropdown.js +0 -48
  210. package/cjs/core/utils/hooks/useUncontrolledState.d.ts +0 -6
  211. package/cjs/core/utils/hooks/useUncontrolledState.js +0 -18
  212. package/esm/core/ComboBox/ComboBoxDropdown.d.ts +0 -7
  213. package/esm/core/ComboBox/ComboBoxDropdown.js +0 -42
  214. package/esm/core/utils/hooks/useUncontrolledState.d.ts +0 -6
  215. package/esm/core/utils/hooks/useUncontrolledState.js +0 -13
@@ -10,31 +10,30 @@ const React = tslib_1.__importStar(require('react'));
10
10
  const classnames_1 = tslib_1.__importDefault(require('classnames'));
11
11
  const react_1 = require('@floating-ui/react');
12
12
  const index_js_1 = require('../utils/index.js');
13
- const react_dom_1 = tslib_1.__importDefault(require('react-dom'));
14
13
  const useTooltip = (options = {}) => {
14
+ const uniqueId = (0, index_js_1.useId)();
15
15
  const {
16
- placement,
17
- visible: controlledOpen,
18
- middleware = {
19
- flip: true,
20
- shift: true,
21
- },
16
+ placement = 'top',
17
+ visible,
18
+ onVisibleChange,
19
+ middleware = { flip: true, shift: true },
22
20
  autoUpdateOptions = {},
21
+ reference,
22
+ ariaStrategy = 'description',
23
+ id = uniqueId,
24
+ ...props
23
25
  } = options;
24
- const [uncontrolledOpen, setUncontrolledOpen] = React.useState(false);
25
- const open = controlledOpen ?? uncontrolledOpen;
26
- const data = (0, react_1.useFloating)({
26
+ const [open, onOpenChange] = (0, index_js_1.useControlledState)(
27
+ false,
28
+ visible,
29
+ onVisibleChange,
30
+ );
31
+ const floating = (0, react_1.useFloating)({
27
32
  placement,
28
33
  open,
29
- onOpenChange: setUncontrolledOpen,
30
- whileElementsMounted: (referenceEl, floatingEl, update) =>
31
- (0, react_1.autoUpdate)(referenceEl, floatingEl, update, {
32
- animationFrame: autoUpdateOptions.animationFrame,
33
- ancestorScroll: autoUpdateOptions.ancestorScroll,
34
- ancestorResize: autoUpdateOptions.ancestorResize,
35
- elementResize: autoUpdateOptions.elementResize,
36
- layoutShift: autoUpdateOptions.layoutShift,
37
- }),
34
+ onOpenChange,
35
+ whileElementsMounted: (...args) =>
36
+ (0, react_1.autoUpdate)(...args, autoUpdateOptions),
38
37
  middleware: [
39
38
  middleware.offset !== undefined
40
39
  ? (0, react_1.offset)(middleware.offset)
@@ -46,41 +45,81 @@ const useTooltip = (options = {}) => {
46
45
  middleware.inline && (0, react_1.inline)(),
47
46
  middleware.hide && (0, react_1.hide)(),
48
47
  ].filter(Boolean),
48
+ ...(reference && { elements: { reference } }),
49
49
  });
50
- const context = data.context;
51
- const hover = (0, react_1.useHover)(context, {
52
- enabled: controlledOpen == null,
53
- delay: {
54
- open: 50,
55
- close: 250,
56
- },
57
- handleClose: (0, react_1.safePolygon)({ buffer: -Infinity }),
58
- });
59
- const focus = (0, react_1.useFocus)(context, {
60
- enabled: controlledOpen == null,
61
- });
62
- const click = (0, react_1.useClick)(context, {
63
- enabled: controlledOpen == null,
64
- });
65
- const dismiss = (0, react_1.useDismiss)(context, {
66
- enabled: controlledOpen == null,
67
- });
68
- const role = (0, react_1.useRole)(context, { role: 'tooltip' });
50
+ const ariaProps = React.useMemo(
51
+ () =>
52
+ ariaStrategy === 'description'
53
+ ? { 'aria-describedby': id }
54
+ : ariaStrategy === 'label'
55
+ ? { 'aria-labelledby': id }
56
+ : {},
57
+ [ariaStrategy, id],
58
+ );
59
+ const { delay } = (0, react_1.useDelayGroupContext)();
60
+ (0, react_1.useDelayGroup)(floating.context, { id: (0, index_js_1.useId)() });
69
61
  const interactions = (0, react_1.useInteractions)([
70
- click,
71
- hover,
72
- focus,
73
- dismiss,
74
- role,
62
+ (0, react_1.useHover)(floating.context, {
63
+ delay: delay ?? { open: 50, close: 250 },
64
+ handleClose: (0, react_1.safePolygon)({ buffer: -Infinity }),
65
+ }),
66
+ (0, react_1.useFocus)(floating.context),
67
+ (0, react_1.useClick)(floating.context),
68
+ (0, react_1.useDismiss)(floating.context),
75
69
  ]);
70
+ // Manually add attributes and event handlers to external reference element,
71
+ // because we cannot spread getReferenceProps onto it.
72
+ React.useEffect(() => {
73
+ if (!reference) {
74
+ return;
75
+ }
76
+ /** e.g. onPointerDown --> pointerdown */
77
+ const domEventName = (e) => e.toLowerCase().substring(2);
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ const cleanupValues = {};
80
+ Object.entries({
81
+ ...ariaProps,
82
+ ...interactions.getReferenceProps(),
83
+ }).forEach(([key, value]) => {
84
+ if (typeof value === 'function') {
85
+ reference.addEventListener(domEventName(key), value);
86
+ cleanupValues[key] = value;
87
+ } else if (value) {
88
+ cleanupValues[key] = reference.getAttribute(key);
89
+ reference.setAttribute(key, value);
90
+ }
91
+ });
92
+ return () => {
93
+ Object.entries(cleanupValues).forEach(([key, value]) => {
94
+ if (typeof value === 'function') {
95
+ reference.removeEventListener(domEventName(key), value);
96
+ } else if (value) {
97
+ reference.setAttribute(key, value);
98
+ } else {
99
+ reference.removeAttribute(key);
100
+ }
101
+ });
102
+ };
103
+ }, [ariaProps, reference, interactions]);
104
+ const getReferenceProps = React.useCallback(
105
+ (userProps) => {
106
+ return interactions.getReferenceProps({ ...userProps, ...ariaProps });
107
+ },
108
+ [interactions, ariaProps],
109
+ );
110
+ const floatingProps = React.useMemo(
111
+ () =>
112
+ interactions.getFloatingProps({
113
+ hidden: !open,
114
+ 'aria-hidden': 'true',
115
+ ...props,
116
+ id,
117
+ }),
118
+ [interactions, props, id, open],
119
+ );
76
120
  return React.useMemo(
77
- () => ({
78
- open,
79
- setUncontrolledOpen,
80
- ...interactions,
81
- ...data,
82
- }),
83
- [open, interactions, data],
121
+ () => ({ getReferenceProps, floatingProps, ...floating }),
122
+ [getReferenceProps, floatingProps, floating],
84
123
  );
85
124
  };
86
125
  /**
@@ -89,78 +128,38 @@ const useTooltip = (options = {}) => {
89
128
  * @example
90
129
  * <Tooltip content='tooltip text' placement='top'>Hover here</Tooltip>
91
130
  * @example
92
- * const buttonRef = React.useRef();
131
+ * const [trigger, setTrigger] = React.useState(null);
93
132
  * ...
94
- * <Button ref={buttonRef} />
95
- * <Tooltip content='tooltip text' reference={buttonRef} />
133
+ * <Button ref={setTrigger} />
134
+ * <Tooltip content='tooltip text' reference={trigger} />
96
135
  */
97
- exports.Tooltip = React.forwardRef((props, forwardRef) => {
98
- const {
99
- content,
100
- children,
101
- portal = true,
102
- placement = 'top',
103
- autoUpdateOptions,
104
- middleware,
105
- style,
106
- className,
107
- visible,
108
- reference,
109
- ...rest
110
- } = props;
111
- const tooltip = useTooltip({
112
- placement,
113
- visible,
114
- autoUpdateOptions,
115
- middleware,
116
- });
117
- const context = (0, index_js_1.useGlobals)();
118
- React.useEffect(() => {
119
- if (reference) {
120
- tooltip.refs.setReference(reference.current);
121
- }
122
- }, [reference, tooltip.refs]);
123
- const portalTo =
124
- typeof portal !== 'boolean'
125
- ? portal.to
126
- : portal
127
- ? context?.portalContainer || (0, index_js_1.getDocument)()?.body
128
- : null;
129
- const contentBox = React.createElement(
130
- index_js_1.Box,
131
- {
132
- className: (0, classnames_1.default)('iui-tooltip', className),
133
- ref: (0, index_js_1.useMergedRefs)(tooltip.refs.setFloating, forwardRef),
134
- style: { ...tooltip.floatingStyles, ...style },
135
- ...tooltip.getFloatingProps(),
136
- ...rest,
137
- },
138
- content,
139
- );
140
- const childrenRef =
141
- React.isValidElement(children) &&
142
- (0, index_js_1.mergeRefs)(
143
- tooltip.refs.setReference,
144
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
- children.ref,
146
- );
136
+ exports.Tooltip = React.forwardRef((props, forwardedRef) => {
137
+ const { content, children, portal = true, className, style, ...rest } = props;
138
+ const tooltip = useTooltip(rest);
147
139
  return React.createElement(
148
140
  React.Fragment,
149
141
  null,
150
- React.isValidElement(children)
151
- ? React.cloneElement(
152
- children,
153
- tooltip.getReferenceProps({
154
- ref: childrenRef,
155
- ...children.props,
156
- }),
157
- )
158
- : null,
159
- tooltip.open
160
- ? portalTo
161
- ? react_dom_1.default.createPortal(contentBox, portalTo)
162
- : contentBox
163
- : null,
142
+ (0, index_js_1.cloneElementWithRef)(children, (children) => ({
143
+ ...tooltip.getReferenceProps(children.props),
144
+ ref: tooltip.refs.setReference,
145
+ })),
146
+ React.createElement(
147
+ index_js_1.Portal,
148
+ { portal: portal },
149
+ React.createElement(
150
+ index_js_1.Box,
151
+ {
152
+ className: (0, classnames_1.default)('iui-tooltip', className),
153
+ ref: (0, index_js_1.useMergedRefs)(
154
+ tooltip.refs.setFloating,
155
+ forwardedRef,
156
+ ),
157
+ style: { ...tooltip.floatingStyles, ...style },
158
+ ...tooltip.floatingProps,
159
+ },
160
+ content,
161
+ ),
162
+ ),
164
163
  );
165
164
  });
166
165
  exports.default = exports.Tooltip;
@@ -10,6 +10,7 @@ const react_1 = tslib_1.__importDefault(require('react'));
10
10
  const classnames_1 = tslib_1.__importDefault(require('classnames'));
11
11
  const index_js_1 = require('../utils/index.js');
12
12
  const index_js_2 = require('../List/index.js');
13
+ const index_js_3 = require('../Label/index.js');
13
14
  // ----------------------------------------------------------------------------
14
15
  // TransferListComponent
15
16
  const TransferListComponent = (0, index_js_1.polymorphic)(
@@ -152,7 +153,7 @@ const TransferListItem = react_1.default.forwardRef((props, ref) => {
152
153
  });
153
154
  TransferListItem.displayName = 'TransferList.Item';
154
155
  const TransferListListboxLabel = react_1.default.forwardRef((props, ref) => {
155
- const { children, className, id, ...rest } = props;
156
+ const { children, id, ...rest } = props;
156
157
  const { labelId, setLabelId } = (0, index_js_1.useSafeContext)(
157
158
  exports.TransferListContext,
158
159
  );
@@ -162,17 +163,8 @@ const TransferListListboxLabel = react_1.default.forwardRef((props, ref) => {
162
163
  }
163
164
  }, [id, labelId, setLabelId]);
164
165
  return react_1.default.createElement(
165
- index_js_1.Box,
166
- {
167
- as: 'div',
168
- className: (0, classnames_1.default)(
169
- 'iui-transfer-list-listbox-label',
170
- className,
171
- ),
172
- id: labelId,
173
- ref: ref,
174
- ...rest,
175
- },
166
+ index_js_3.Label,
167
+ { as: 'div', id: labelId, ref: ref, ...rest },
176
168
  children,
177
169
  );
178
170
  });
@@ -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';
@@ -63,4 +65,4 @@ export { Anchor, Blockquote, Code, Kbd, KbdKeys, Text, } from './Typography/inde
63
65
  export { Stepper, WorkflowDiagram } from './Stepper/index.js';
64
66
  export type { StepProperties, StepperLocalization } from './Stepper/index.js';
65
67
  export { SearchBox } from './SearchBox/index.js';
66
- export { getUserColor, ColorValue, MiddleTextTruncation, LinkBox, LinkAction, Icon, Flex, VisuallyHidden, Divider, } from './utils/index.js';
68
+ export { getUserColor, ColorValue, MiddleTextTruncation, LinkBox, LinkAction, Icon, Flex, VisuallyHidden, Divider, Popover, } from './utils/index.js';
package/cjs/core/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.Label =
3
+ exports.InputWithDecorations =
4
4
  exports.Input =
5
5
  exports.InformationPanelContent =
6
6
  exports.InformationPanelBody =
@@ -51,9 +51,7 @@ exports.Label =
51
51
  exports.Avatar =
52
52
  exports.Alert =
53
53
  void 0;
54
- exports.TreeNodeExpander =
55
- exports.TreeNode =
56
- exports.Tree =
54
+ exports.Tree =
57
55
  exports.Tooltip =
58
56
  exports.ToggleSwitch =
59
57
  exports.ThemeProvider =
@@ -101,8 +99,11 @@ exports.TreeNodeExpander =
101
99
  exports.LabeledSelect =
102
100
  exports.InputGroup =
103
101
  exports.LabeledInput =
102
+ exports.Label =
103
+ exports.InputGrid =
104
104
  void 0;
105
- exports.Divider =
105
+ exports.Popover =
106
+ exports.Divider =
106
107
  exports.VisuallyHidden =
107
108
  exports.Flex =
108
109
  exports.Icon =
@@ -120,6 +121,8 @@ exports.Divider =
120
121
  exports.Code =
121
122
  exports.Blockquote =
122
123
  exports.Anchor =
124
+ exports.TreeNodeExpander =
125
+ exports.TreeNode =
123
126
  void 0;
124
127
  /*---------------------------------------------------------------------------------------------
125
128
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
@@ -445,6 +448,20 @@ Object.defineProperty(exports, 'Input', {
445
448
  return index_js_26.Input;
446
449
  },
447
450
  });
451
+ var InputWithDecorations_js_1 = require('./InputWithDecorations/InputWithDecorations.js');
452
+ Object.defineProperty(exports, 'InputWithDecorations', {
453
+ enumerable: true,
454
+ get: function () {
455
+ return InputWithDecorations_js_1.InputWithDecorations;
456
+ },
457
+ });
458
+ var InputGrid_js_1 = require('./InputGrid/InputGrid.js');
459
+ Object.defineProperty(exports, 'InputGrid', {
460
+ enumerable: true,
461
+ get: function () {
462
+ return InputGrid_js_1.InputGrid;
463
+ },
464
+ });
448
465
  var index_js_27 = require('./Label/index.js');
449
466
  Object.defineProperty(exports, 'Label', {
450
467
  enumerable: true,
@@ -891,3 +908,9 @@ Object.defineProperty(exports, 'Divider', {
891
908
  return index_js_58.Divider;
892
909
  },
893
910
  });
911
+ Object.defineProperty(exports, 'Popover', {
912
+ enumerable: true,
913
+ get: function () {
914
+ return index_js_58.Popover;
915
+ },
916
+ });
@@ -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.
@@ -36,12 +36,19 @@ const getSizeValue = (size) => {
36
36
  * </Icon>
37
37
  */
38
38
  exports.Icon = React.forwardRef((props, ref) => {
39
- const { size = 'medium', fill = 'default', className, ...rest } = props;
39
+ const {
40
+ size = 'medium',
41
+ fill = 'default',
42
+ className,
43
+ padded = false,
44
+ ...rest
45
+ } = props;
40
46
  return React.createElement(Box_js_1.Box, {
41
47
  as: 'span',
42
48
  className: (0, classnames_1.default)('iui-svg-icon', className),
43
49
  'data-iui-icon-size': getSizeValue(size),
44
50
  'data-iui-icon-color': fill,
51
+ 'data-iui-padded': padded ? 'true' : undefined,
45
52
  ref: ref,
46
53
  ...rest,
47
54
  });
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- export type InputContainerProps<T extends React.ElementType = 'div'> = {
3
- as?: T;
2
+ import type { PolymorphicForwardRefComponent } from '../props.js';
3
+ export type InputContainerProps = {
4
4
  label?: React.ReactNode;
5
5
  disabled?: boolean;
6
6
  required?: boolean;
@@ -8,13 +8,12 @@ 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;
15
- } & React.ComponentPropsWithoutRef<T>;
14
+ };
16
15
  /**
17
16
  * Input container to wrap inputs with label, and add optional message and icon.
18
17
  * @private
19
18
  */
20
- export declare const InputContainer: <T extends React.ElementType<any> = "div">(props: InputContainerProps<T>) => React.JSX.Element;
19
+ export declare const InputContainer: PolymorphicForwardRefComponent<"div", InputContainerProps>;
@@ -9,11 +9,13 @@ const tslib_1 = require('tslib');
9
9
  const React = tslib_1.__importStar(require('react'));
10
10
  const classnames_1 = tslib_1.__importDefault(require('classnames'));
11
11
  const Box_js_1 = require('./Box.js');
12
+ const index_js_1 = require('../../Label/index.js');
13
+ const index_js_2 = require('../../StatusMessage/index.js');
12
14
  /**
13
15
  * Input container to wrap inputs with label, and add optional message and icon.
14
16
  * @private
15
17
  */
16
- const InputContainer = (props) => {
18
+ exports.InputContainer = React.forwardRef((props, forwardedRef) => {
17
19
  const {
18
20
  label,
19
21
  disabled,
@@ -22,7 +24,6 @@ const InputContainer = (props) => {
22
24
  message,
23
25
  icon,
24
26
  isLabelInline,
25
- isIconInline,
26
27
  children,
27
28
  className,
28
29
  style,
@@ -34,29 +35,24 @@ const InputContainer = (props) => {
34
35
  return React.createElement(
35
36
  Box_js_1.Box,
36
37
  {
37
- className: (0, classnames_1.default)(
38
- 'iui-input-container',
39
- {
40
- 'iui-disabled': disabled,
41
- [`iui-${status}`]: !!status,
42
- 'iui-inline-label': isLabelInline,
43
- 'iui-inline-icon': isIconInline,
44
- 'iui-with-message':
45
- (!!message || !!icon || !!statusMessage) && !isLabelInline,
46
- },
47
- className,
48
- ),
38
+ className: (0, classnames_1.default)('iui-input-grid', className),
39
+ 'data-iui-status': status,
40
+ 'data-iui-label-placement': isLabelInline ? 'inline' : undefined,
49
41
  style: style,
42
+ ref: forwardedRef,
50
43
  ...rest,
51
44
  },
52
45
  label &&
53
46
  React.createElement(
54
- Box_js_1.Box,
47
+ index_js_1.Label,
48
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
+ // @ts-ignore
55
50
  {
51
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
52
+ // @ts-ignore
56
53
  as: inputId && props.as !== 'label' ? 'label' : 'div',
57
- className: (0, classnames_1.default)('iui-label', {
58
- 'iui-required': required,
59
- }),
54
+ required: required,
55
+ disabled: disabled,
60
56
  htmlFor: inputId,
61
57
  id: labelId,
62
58
  },
@@ -65,23 +61,11 @@ const InputContainer = (props) => {
65
61
  children,
66
62
  statusMessage
67
63
  ? statusMessage
68
- : React.createElement(
69
- React.Fragment,
70
- null,
71
- icon &&
72
- React.createElement(
73
- Box_js_1.Box,
74
- { as: 'span', className: 'iui-input-icon', 'aria-hidden': true },
75
- icon,
76
- ),
77
- message &&
78
- !isLabelInline &&
79
- React.createElement(
80
- Box_js_1.Box,
81
- { className: 'iui-message' },
82
- message,
83
- ),
84
- ),
64
+ : message &&
65
+ React.createElement(
66
+ index_js_2.StatusMessage,
67
+ { startIcon: icon, status: status },
68
+ message,
69
+ ),
85
70
  );
86
- };
87
- exports.InputContainer = InputContainer;
71
+ });
@@ -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.
@@ -14,7 +14,8 @@ const Box_js_1 = require('./Box.js');
14
14
  * @private
15
15
  */
16
16
  exports.InputFlexContainer = react_1.default.forwardRef((props, ref) => {
17
- const { isDisabled, status, children, className, style, ...rest } = props;
17
+ const { isDisabled, status, children, className, size, style, ...rest } =
18
+ props;
18
19
  return react_1.default.createElement(
19
20
  Box_js_1.Box,
20
21
  {
@@ -23,6 +24,7 @@ exports.InputFlexContainer = react_1.default.forwardRef((props, ref) => {
23
24
  className,
24
25
  ),
25
26
  'data-iui-status': status,
27
+ 'data-iui-size': size,
26
28
  'data-iui-disabled': isDisabled ? 'true' : undefined,
27
29
  ref: ref,
28
30
  style: style,