@itwin/itwinui-react 3.0.0-dev.6 → 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 (283) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/cjs/core/Alert/Alert.d.ts +20 -9
  3. package/cjs/core/Alert/Alert.js +48 -10
  4. package/cjs/core/Avatar/Avatar.d.ts +3 -2
  5. package/cjs/core/Avatar/Avatar.js +21 -19
  6. package/cjs/core/AvatarGroup/AvatarGroup.js +3 -8
  7. package/cjs/core/ButtonGroup/ButtonGroup.js +41 -36
  8. package/cjs/core/Buttons/Button/Button.d.ts +15 -2
  9. package/cjs/core/Buttons/Button/Button.js +23 -9
  10. package/cjs/core/Buttons/DropdownButton/DropdownButton.js +1 -1
  11. package/cjs/core/Buttons/IconButton/IconButton.d.ts +5 -1
  12. package/cjs/core/Buttons/IconButton/IconButton.js +27 -38
  13. package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
  14. package/cjs/core/Buttons/SplitButton/SplitButton.js +25 -13
  15. package/cjs/core/Carousel/Carousel.d.ts +6 -4
  16. package/cjs/core/Carousel/Carousel.js +2 -2
  17. package/cjs/core/Carousel/CarouselDot.js +1 -3
  18. package/cjs/core/Carousel/CarouselNavigation.d.ts +6 -4
  19. package/cjs/core/ColorPicker/ColorBuilder.js +2 -1
  20. package/cjs/core/ColorPicker/ColorInputPanel.js +172 -231
  21. package/cjs/core/ComboBox/ComboBox.js +3 -3
  22. package/cjs/core/ComboBox/ComboBoxDropdown.js +4 -9
  23. package/cjs/core/ComboBox/ComboBoxEndIcon.js +3 -22
  24. package/cjs/core/ComboBox/ComboBoxInput.js +1 -1
  25. package/cjs/core/ComboBox/ComboBoxMenu.d.ts +2 -2
  26. package/cjs/core/ComboBox/ComboBoxMenu.js +5 -5
  27. package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
  28. package/cjs/core/ComboBox/ComboBoxMenuItem.js +8 -6
  29. package/cjs/core/ComboBox/helpers.d.ts +1 -2
  30. package/cjs/core/DatePicker/DatePicker.d.ts +30 -8
  31. package/cjs/core/DatePicker/DatePicker.js +47 -6
  32. package/cjs/core/Dialog/Dialog.js +10 -17
  33. package/cjs/core/Dialog/DialogContext.d.ts +3 -4
  34. package/cjs/core/Dialog/DialogMain.js +5 -5
  35. package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
  36. package/cjs/core/ExpandableBlock/ExpandableBlock.js +39 -18
  37. package/cjs/core/FileUpload/FileUpload.d.ts +4 -0
  38. package/cjs/core/FileUpload/FileUpload.js +24 -3
  39. package/cjs/core/Header/HeaderBasicButton.js +3 -16
  40. package/cjs/core/Header/HeaderDropdownButton.js +1 -1
  41. package/cjs/core/Header/HeaderSplitButton.js +3 -4
  42. package/cjs/core/Input/Input.d.ts +4 -0
  43. package/cjs/core/Input/Input.js +2 -1
  44. package/cjs/core/InputGrid/InputGrid.d.ts +25 -0
  45. package/cjs/core/InputGrid/InputGrid.js +39 -0
  46. package/cjs/core/InputGrid/index.d.ts +3 -0
  47. package/cjs/core/InputGrid/index.js +15 -0
  48. package/cjs/core/InputGroup/InputGroup.d.ts +13 -0
  49. package/cjs/core/InputGroup/InputGroup.js +35 -9
  50. package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
  51. package/cjs/core/InputWithDecorations/InputWithDecorations.js +81 -0
  52. package/cjs/core/InputWithDecorations/index.d.ts +3 -0
  53. package/cjs/core/InputWithDecorations/index.js +15 -0
  54. package/cjs/core/Label/Label.d.ts +5 -0
  55. package/cjs/core/Label/Label.js +2 -0
  56. package/cjs/core/LabeledInput/LabeledInput.d.ts +22 -16
  57. package/cjs/core/LabeledInput/LabeledInput.js +52 -29
  58. package/cjs/core/LabeledSelect/LabeledSelect.d.ts +17 -7
  59. package/cjs/core/LabeledSelect/LabeledSelect.js +36 -17
  60. package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
  61. package/cjs/core/LabeledTextarea/LabeledTextarea.js +12 -45
  62. package/cjs/core/Menu/Menu.d.ts +1 -1
  63. package/cjs/core/Menu/Menu.js +1 -1
  64. package/cjs/core/Menu/MenuDivider.d.ts +2 -1
  65. package/cjs/core/Menu/MenuDivider.js +1 -1
  66. package/cjs/core/Menu/MenuItem.d.ts +1 -1
  67. package/cjs/core/Menu/MenuItem.js +1 -0
  68. package/cjs/core/Menu/MenuItemSkeleton.d.ts +1 -1
  69. package/cjs/core/Menu/MenuItemSkeleton.js +0 -1
  70. package/cjs/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
  71. package/cjs/core/ProgressIndicators/ProgressLinear.js +9 -1
  72. package/cjs/core/SearchBox/SearchBox.js +1 -1
  73. package/cjs/core/Select/Select.d.ts +4 -0
  74. package/cjs/core/Select/Select.js +12 -11
  75. package/cjs/core/SideNavigation/SideNavigation.d.ts +16 -0
  76. package/cjs/core/SideNavigation/SideNavigation.js +42 -9
  77. package/cjs/core/Slider/Slider.d.ts +24 -0
  78. package/cjs/core/Slider/Slider.js +58 -10
  79. package/cjs/core/Slider/Thumb.js +3 -2
  80. package/cjs/core/Slider/Track.d.ts +1 -1
  81. package/cjs/core/Slider/Track.js +17 -6
  82. package/cjs/core/StatusMessage/StatusMessage.d.ts +12 -2
  83. package/cjs/core/StatusMessage/StatusMessage.js +23 -9
  84. package/cjs/core/Stepper/Stepper.d.ts +26 -1
  85. package/cjs/core/Stepper/Stepper.js +35 -6
  86. package/cjs/core/Stepper/StepperStep.d.ts +17 -0
  87. package/cjs/core/Stepper/StepperStep.js +33 -8
  88. package/cjs/core/Stepper/WorkflowDiagram.d.ts +11 -1
  89. package/cjs/core/Stepper/WorkflowDiagram.js +23 -10
  90. package/cjs/core/Stepper/WorkflowDiagramStep.d.ts +6 -1
  91. package/cjs/core/Stepper/WorkflowDiagramStep.js +9 -2
  92. package/cjs/core/Table/SubRowExpander.js +3 -1
  93. package/cjs/core/Table/Table.js +0 -1
  94. package/cjs/core/Table/TableCell.js +1 -1
  95. package/cjs/core/Table/TablePaginator.js +1 -3
  96. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
  97. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +46 -18
  98. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
  99. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
  100. package/cjs/core/Tabs/Tab.js +1 -2
  101. package/cjs/core/Textarea/Textarea.d.ts +7 -1
  102. package/cjs/core/Textarea/Textarea.js +6 -11
  103. package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
  104. package/cjs/core/ThemeProvider/ThemeProvider.d.ts +23 -3
  105. package/cjs/core/ThemeProvider/ThemeProvider.js +56 -23
  106. package/cjs/core/Tile/Tile.d.ts +142 -17
  107. package/cjs/core/Tile/Tile.js +107 -16
  108. package/cjs/core/Toast/Toast.d.ts +12 -4
  109. package/cjs/core/Toast/Toast.js +24 -13
  110. package/cjs/core/Tooltip/Tooltip.d.ts +35 -28
  111. package/cjs/core/Tooltip/Tooltip.js +116 -118
  112. package/cjs/core/TransferList/TransferList.js +4 -12
  113. package/cjs/core/Tree/TreeNode.js +1 -1
  114. package/cjs/core/index.d.ts +2 -0
  115. package/cjs/core/index.js +20 -4
  116. package/cjs/core/utils/components/ButtonBase.d.ts +14 -0
  117. package/cjs/core/utils/components/ButtonBase.js +46 -0
  118. package/cjs/core/utils/components/Icon.d.ts +5 -0
  119. package/cjs/core/utils/components/Icon.js +8 -1
  120. package/cjs/core/utils/components/InputContainer.d.ts +0 -1
  121. package/cjs/core/utils/components/InputContainer.js +14 -34
  122. package/cjs/core/utils/components/InputFlexContainer.d.ts +1 -0
  123. package/cjs/core/utils/components/InputFlexContainer.js +3 -1
  124. package/cjs/core/utils/components/Popover.js +5 -3
  125. package/cjs/core/utils/components/Portal.d.ts +27 -0
  126. package/cjs/core/utils/components/Portal.js +43 -0
  127. package/cjs/core/utils/components/VirtualScroll.js +4 -4
  128. package/cjs/core/utils/components/index.d.ts +2 -0
  129. package/cjs/core/utils/components/index.js +2 -0
  130. package/cjs/core/utils/functions/colors.d.ts +1 -1
  131. package/cjs/core/utils/functions/colors.js +1 -13
  132. package/cjs/core/utils/functions/index.d.ts +1 -0
  133. package/cjs/core/utils/functions/index.js +1 -0
  134. package/cjs/core/utils/functions/react.d.ts +8 -0
  135. package/cjs/core/utils/functions/react.js +40 -0
  136. package/cjs/core/utils/hooks/index.d.ts +1 -0
  137. package/cjs/core/utils/hooks/index.js +1 -0
  138. package/cjs/core/utils/hooks/useControlledState.d.ts +13 -0
  139. package/cjs/core/utils/hooks/useControlledState.js +39 -0
  140. package/cjs/core/utils/hooks/useGlobals.d.ts +1 -1
  141. package/cjs/styles.js +11 -35
  142. package/esm/core/Alert/Alert.d.ts +20 -9
  143. package/esm/core/Alert/Alert.js +49 -10
  144. package/esm/core/Avatar/Avatar.d.ts +3 -2
  145. package/esm/core/Avatar/Avatar.js +21 -17
  146. package/esm/core/AvatarGroup/AvatarGroup.js +3 -8
  147. package/esm/core/ButtonGroup/ButtonGroup.js +41 -36
  148. package/esm/core/Buttons/Button/Button.d.ts +15 -2
  149. package/esm/core/Buttons/Button/Button.js +18 -10
  150. package/esm/core/Buttons/DropdownButton/DropdownButton.js +1 -1
  151. package/esm/core/Buttons/IconButton/IconButton.d.ts +5 -1
  152. package/esm/core/Buttons/IconButton/IconButton.js +25 -37
  153. package/esm/core/Buttons/SplitButton/SplitButton.d.ts +9 -0
  154. package/esm/core/Buttons/SplitButton/SplitButton.js +31 -14
  155. package/esm/core/Carousel/Carousel.d.ts +6 -4
  156. package/esm/core/Carousel/Carousel.js +8 -3
  157. package/esm/core/Carousel/CarouselDot.js +2 -4
  158. package/esm/core/Carousel/CarouselNavigation.d.ts +6 -4
  159. package/esm/core/ColorPicker/ColorBuilder.js +2 -1
  160. package/esm/core/ColorPicker/ColorInputPanel.js +173 -232
  161. package/esm/core/ComboBox/ComboBox.js +3 -3
  162. package/esm/core/ComboBox/ComboBoxDropdown.js +4 -9
  163. package/esm/core/ComboBox/ComboBoxEndIcon.js +4 -25
  164. package/esm/core/ComboBox/ComboBoxInput.js +1 -1
  165. package/esm/core/ComboBox/ComboBoxMenu.d.ts +2 -2
  166. package/esm/core/ComboBox/ComboBoxMenu.js +5 -5
  167. package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
  168. package/esm/core/ComboBox/ComboBoxMenuItem.js +9 -7
  169. package/esm/core/ComboBox/helpers.d.ts +1 -2
  170. package/esm/core/DatePicker/DatePicker.d.ts +30 -8
  171. package/esm/core/DatePicker/DatePicker.js +33 -6
  172. package/esm/core/Dialog/Dialog.js +11 -23
  173. package/esm/core/Dialog/DialogContext.d.ts +3 -4
  174. package/esm/core/Dialog/DialogMain.js +5 -5
  175. package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
  176. package/esm/core/ExpandableBlock/ExpandableBlock.js +41 -20
  177. package/esm/core/FileUpload/FileUpload.d.ts +4 -0
  178. package/esm/core/FileUpload/FileUpload.js +26 -3
  179. package/esm/core/Header/HeaderBasicButton.js +4 -17
  180. package/esm/core/Header/HeaderDropdownButton.js +1 -1
  181. package/esm/core/Header/HeaderSplitButton.js +9 -5
  182. package/esm/core/Input/Input.d.ts +4 -0
  183. package/esm/core/Input/Input.js +2 -1
  184. package/esm/core/InputGrid/InputGrid.d.ts +25 -0
  185. package/esm/core/InputGrid/InputGrid.js +35 -0
  186. package/esm/core/InputGrid/index.d.ts +3 -0
  187. package/esm/core/InputGrid/index.js +6 -0
  188. package/esm/core/InputGroup/InputGroup.d.ts +13 -0
  189. package/esm/core/InputGroup/InputGroup.js +34 -10
  190. package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
  191. package/esm/core/InputWithDecorations/InputWithDecorations.js +80 -0
  192. package/esm/core/InputWithDecorations/index.d.ts +3 -0
  193. package/esm/core/InputWithDecorations/index.js +6 -0
  194. package/esm/core/Label/Label.d.ts +5 -0
  195. package/esm/core/Label/Label.js +2 -0
  196. package/esm/core/LabeledInput/LabeledInput.d.ts +22 -16
  197. package/esm/core/LabeledInput/LabeledInput.js +53 -29
  198. package/esm/core/LabeledSelect/LabeledSelect.d.ts +17 -7
  199. package/esm/core/LabeledSelect/LabeledSelect.js +37 -18
  200. package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
  201. package/esm/core/LabeledTextarea/LabeledTextarea.js +14 -45
  202. package/esm/core/Menu/Menu.d.ts +1 -1
  203. package/esm/core/Menu/Menu.js +1 -1
  204. package/esm/core/Menu/MenuDivider.d.ts +2 -1
  205. package/esm/core/Menu/MenuDivider.js +1 -1
  206. package/esm/core/Menu/MenuItem.d.ts +1 -1
  207. package/esm/core/Menu/MenuItem.js +1 -0
  208. package/esm/core/Menu/MenuItemSkeleton.d.ts +1 -1
  209. package/esm/core/Menu/MenuItemSkeleton.js +0 -1
  210. package/esm/core/ProgressIndicators/ProgressLinear.d.ts +4 -0
  211. package/esm/core/ProgressIndicators/ProgressLinear.js +9 -1
  212. package/esm/core/SearchBox/SearchBox.js +1 -1
  213. package/esm/core/Select/Select.d.ts +4 -0
  214. package/esm/core/Select/Select.js +12 -11
  215. package/esm/core/SideNavigation/SideNavigation.d.ts +16 -0
  216. package/esm/core/SideNavigation/SideNavigation.js +33 -9
  217. package/esm/core/Slider/Slider.d.ts +24 -0
  218. package/esm/core/Slider/Slider.js +43 -10
  219. package/esm/core/Slider/Thumb.js +3 -2
  220. package/esm/core/Slider/Track.d.ts +1 -1
  221. package/esm/core/Slider/Track.js +14 -6
  222. package/esm/core/StatusMessage/StatusMessage.d.ts +12 -2
  223. package/esm/core/StatusMessage/StatusMessage.js +23 -16
  224. package/esm/core/Stepper/Stepper.d.ts +26 -1
  225. package/esm/core/Stepper/Stepper.js +32 -6
  226. package/esm/core/Stepper/StepperStep.d.ts +17 -0
  227. package/esm/core/Stepper/StepperStep.js +27 -8
  228. package/esm/core/Stepper/WorkflowDiagram.d.ts +11 -1
  229. package/esm/core/Stepper/WorkflowDiagram.js +10 -7
  230. package/esm/core/Stepper/WorkflowDiagramStep.d.ts +6 -1
  231. package/esm/core/Stepper/WorkflowDiagramStep.js +6 -2
  232. package/esm/core/Table/SubRowExpander.js +3 -1
  233. package/esm/core/Table/Table.js +0 -1
  234. package/esm/core/Table/TableCell.js +1 -1
  235. package/esm/core/Table/TablePaginator.js +2 -3
  236. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
  237. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +45 -17
  238. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
  239. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
  240. package/esm/core/Tabs/Tab.js +2 -3
  241. package/esm/core/Textarea/Textarea.d.ts +7 -1
  242. package/esm/core/Textarea/Textarea.js +6 -11
  243. package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
  244. package/esm/core/ThemeProvider/ThemeProvider.d.ts +23 -3
  245. package/esm/core/ThemeProvider/ThemeProvider.js +65 -24
  246. package/esm/core/Tile/Tile.d.ts +142 -17
  247. package/esm/core/Tile/Tile.js +107 -16
  248. package/esm/core/Toast/Toast.d.ts +12 -4
  249. package/esm/core/Toast/Toast.js +26 -13
  250. package/esm/core/Tooltip/Tooltip.d.ts +35 -28
  251. package/esm/core/Tooltip/Tooltip.js +119 -116
  252. package/esm/core/TransferList/TransferList.js +4 -9
  253. package/esm/core/Tree/TreeNode.js +1 -1
  254. package/esm/core/index.d.ts +2 -0
  255. package/esm/core/index.js +2 -0
  256. package/esm/core/utils/components/ButtonBase.d.ts +14 -0
  257. package/esm/core/utils/components/ButtonBase.js +42 -0
  258. package/esm/core/utils/components/Icon.d.ts +5 -0
  259. package/esm/core/utils/components/Icon.js +8 -1
  260. package/esm/core/utils/components/InputContainer.d.ts +0 -1
  261. package/esm/core/utils/components/InputContainer.js +14 -30
  262. package/esm/core/utils/components/InputFlexContainer.d.ts +1 -0
  263. package/esm/core/utils/components/InputFlexContainer.js +3 -1
  264. package/esm/core/utils/components/Popover.js +5 -3
  265. package/esm/core/utils/components/Portal.d.ts +27 -0
  266. package/esm/core/utils/components/Portal.js +36 -0
  267. package/esm/core/utils/components/VirtualScroll.js +4 -4
  268. package/esm/core/utils/components/index.d.ts +2 -0
  269. package/esm/core/utils/components/index.js +2 -0
  270. package/esm/core/utils/functions/colors.d.ts +1 -1
  271. package/esm/core/utils/functions/colors.js +1 -13
  272. package/esm/core/utils/functions/index.d.ts +1 -0
  273. package/esm/core/utils/functions/index.js +1 -0
  274. package/esm/core/utils/functions/react.d.ts +8 -0
  275. package/esm/core/utils/functions/react.js +35 -0
  276. package/esm/core/utils/hooks/index.d.ts +1 -0
  277. package/esm/core/utils/hooks/index.js +1 -0
  278. package/esm/core/utils/hooks/useControlledState.d.ts +13 -0
  279. package/esm/core/utils/hooks/useControlledState.js +34 -0
  280. package/esm/core/utils/hooks/useGlobals.d.ts +1 -1
  281. package/esm/styles.js +11 -35
  282. package/package.json +3 -3
  283. package/styles.css +49 -46
@@ -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,79 +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?.portalContainerRef?.current ??
128
- (0, index_js_1.getDocument)()?.body
129
- : null;
130
- const contentBox = React.createElement(
131
- index_js_1.Box,
132
- {
133
- className: (0, classnames_1.default)('iui-tooltip', className),
134
- ref: (0, index_js_1.useMergedRefs)(tooltip.refs.setFloating, forwardRef),
135
- style: { ...tooltip.floatingStyles, ...style },
136
- ...tooltip.getFloatingProps(),
137
- ...rest,
138
- },
139
- content,
140
- );
141
- const childrenRef =
142
- React.isValidElement(children) &&
143
- (0, index_js_1.mergeRefs)(
144
- tooltip.refs.setReference,
145
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
- children.ref,
147
- );
136
+ exports.Tooltip = React.forwardRef((props, forwardedRef) => {
137
+ const { content, children, portal = true, className, style, ...rest } = props;
138
+ const tooltip = useTooltip(rest);
148
139
  return React.createElement(
149
140
  React.Fragment,
150
141
  null,
151
- React.isValidElement(children)
152
- ? React.cloneElement(
153
- children,
154
- tooltip.getReferenceProps({
155
- ref: childrenRef,
156
- ...children.props,
157
- }),
158
- )
159
- : null,
160
- tooltip.open
161
- ? portalTo
162
- ? react_dom_1.default.createPortal(contentBox, portalTo)
163
- : contentBox
164
- : 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
+ ),
165
163
  );
166
164
  });
167
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
  });
@@ -229,7 +229,7 @@ const TreeNode = (props) => {
229
229
  as: 'ul',
230
230
  className: 'iui-sub-tree',
231
231
  role: 'group',
232
- 'aria-owns': subNodeIds.join(','),
232
+ 'aria-owns': subNodeIds.join(' '),
233
233
  }),
234
234
  );
235
235
  };
@@ -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/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,6 +99,8 @@ 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
105
  exports.Divider =
106
106
  exports.VisuallyHidden =
@@ -120,6 +120,8 @@ exports.Divider =
120
120
  exports.Code =
121
121
  exports.Blockquote =
122
122
  exports.Anchor =
123
+ exports.TreeNodeExpander =
124
+ exports.TreeNode =
123
125
  void 0;
124
126
  /*---------------------------------------------------------------------------------------------
125
127
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
@@ -445,6 +447,20 @@ Object.defineProperty(exports, 'Input', {
445
447
  return index_js_26.Input;
446
448
  },
447
449
  });
450
+ var InputWithDecorations_js_1 = require('./InputWithDecorations/InputWithDecorations.js');
451
+ Object.defineProperty(exports, 'InputWithDecorations', {
452
+ enumerable: true,
453
+ get: function () {
454
+ return InputWithDecorations_js_1.InputWithDecorations;
455
+ },
456
+ });
457
+ var InputGrid_js_1 = require('./InputGrid/InputGrid.js');
458
+ Object.defineProperty(exports, 'InputGrid', {
459
+ enumerable: true,
460
+ get: function () {
461
+ return InputGrid_js_1.InputGrid;
462
+ },
463
+ });
448
464
  var index_js_27 = require('./Label/index.js');
449
465
  Object.defineProperty(exports, 'Label', {
450
466
  enumerable: true,
@@ -0,0 +1,14 @@
1
+ import type { PolymorphicForwardRefComponent } from '../props.js';
2
+ export declare const ButtonBase: PolymorphicForwardRefComponent<"button", ButtonBaseProps>;
3
+ type ButtonBaseProps = {
4
+ /**
5
+ * Custom `disabled` prop that keeps the button focusable, prevents
6
+ * clicks, applied disabled styling, and adds `aria-disabled`.
7
+ */
8
+ disabled?: boolean;
9
+ /**
10
+ * Built-in html `disabled` attribute
11
+ */
12
+ htmlDisabled?: boolean;
13
+ };
14
+ export {};
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.ButtonBase = void 0;
4
+ const tslib_1 = require('tslib');
5
+ /*---------------------------------------------------------------------------------------------
6
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
7
+ * See LICENSE.md in the project root for license terms and full copyright notice.
8
+ *--------------------------------------------------------------------------------------------*/
9
+ const React = tslib_1.__importStar(require('react'));
10
+ const classnames_1 = tslib_1.__importDefault(require('classnames'));
11
+ const Box_js_1 = require('./Box.js');
12
+ const useIsClient_js_1 = require('../hooks/useIsClient.js');
13
+ exports.ButtonBase = React.forwardRef((props, forwardedRef) => {
14
+ const {
15
+ as: asProp = 'button',
16
+ disabled: disabledProp,
17
+ htmlDisabled,
18
+ ...rest
19
+ } = props;
20
+ const isClient = (0, useIsClient_js_1.useIsClient)();
21
+ const ariaDisabled =
22
+ disabledProp &&
23
+ !htmlDisabled && // htmlDisabled prop takes preference
24
+ isClient && // progressively enhance after first render
25
+ asProp === 'button'; // ignore if not button, e.g. links
26
+ const handleIfEnabled = (handler) => (e) => {
27
+ if (disabledProp) {
28
+ return;
29
+ }
30
+ handler?.(e);
31
+ };
32
+ return React.createElement(Box_js_1.Box, {
33
+ as: asProp,
34
+ type: asProp === 'button' ? 'button' : undefined,
35
+ ref: forwardedRef,
36
+ 'aria-disabled': ariaDisabled ? 'true' : undefined,
37
+ 'data-iui-disabled': disabledProp ? 'true' : undefined,
38
+ disabled: htmlDisabled ?? (!isClient && disabledProp) ? true : undefined,
39
+ ...rest,
40
+ className: (0, classnames_1.default)('iui-button-base', props.className),
41
+ onClick: handleIfEnabled(props.onClick),
42
+ onPointerDown: handleIfEnabled(props.onPointerDown),
43
+ onPointerUp: handleIfEnabled(props.onPointerUp),
44
+ });
45
+ });
46
+ exports.ButtonBase.displayName = 'ButtonBase';
@@ -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
  });
@@ -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;
@@ -9,6 +9,8 @@ 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
@@ -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,19 @@ 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,
50
42
  ...rest,
51
43
  },
52
44
  label &&
53
45
  React.createElement(
54
- Box_js_1.Box,
46
+ index_js_1.Label,
55
47
  {
56
48
  as: inputId && props.as !== 'label' ? 'label' : 'div',
57
- className: (0, classnames_1.default)('iui-label', {
58
- 'iui-required': required,
59
- }),
49
+ required: required,
50
+ disabled: disabled,
60
51
  htmlFor: inputId,
61
52
  id: labelId,
62
53
  },
@@ -65,23 +56,12 @@ const InputContainer = (props) => {
65
56
  children,
66
57
  statusMessage
67
58
  ? 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
- ),
59
+ : message &&
60
+ React.createElement(
61
+ index_js_2.StatusMessage,
62
+ { startIcon: icon, status: status },
63
+ message,
64
+ ),
85
65
  );
86
66
  };
87
67
  exports.InputContainer = InputContainer;
@@ -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,
@@ -40,8 +40,7 @@ exports.Popover = React.forwardRef((props, ref) => {
40
40
  const computedProps = {
41
41
  allowHTML: true,
42
42
  animation: false,
43
- appendTo: (el) =>
44
- themeInfo?.portalContainerRef?.current || el.ownerDocument.body,
43
+ appendTo: (el) => themeInfo?.portalContainer || el.ownerDocument.body,
45
44
  arrow: false,
46
45
  duration: 0,
47
46
  interactive: true,
@@ -66,7 +65,10 @@ exports.Popover = React.forwardRef((props, ref) => {
66
65
  ...props.popperOptions,
67
66
  modifiers: [
68
67
  { name: 'flip' },
69
- { name: 'preventOverflow', options: { padding: 0 } },
68
+ {
69
+ name: 'preventOverflow',
70
+ options: { padding: 0 },
71
+ },
70
72
  ...(props.popperOptions?.modifiers || []),
71
73
  ],
72
74
  },
@@ -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;