@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
@@ -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';
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,
@@ -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,
@@ -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,43 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.Portal = 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 ReactDOM = tslib_1.__importStar(require('react-dom'));
11
+ const ThemeContext_js_1 = require('../../ThemeProvider/ThemeContext.js');
12
+ const dom_js_1 = require('../functions/dom.js');
13
+ const useIsClient_js_1 = require('../hooks/useIsClient.js');
14
+ // ----------------------------------------------------------------------------
15
+ /**
16
+ * Helper component that portals children according to the following conditions:
17
+ * - renders null on server
18
+ * - if `portal` is set to true, renders into nearest ThemeContext.portalContainer
19
+ * - if `portal` is set to false, renders as-is without portal
20
+ * - otherwise renders into `portal.to` (can be an element or a function)
21
+ *
22
+ * @private
23
+ */
24
+ const Portal = (props) => {
25
+ const { portal = true, children } = props;
26
+ const isClient = (0, useIsClient_js_1.useIsClient)();
27
+ const portalTo = usePortalTo(portal);
28
+ if (!isClient) {
29
+ return null;
30
+ }
31
+ return portalTo ? ReactDOM.createPortal(children, portalTo) : children;
32
+ };
33
+ exports.Portal = Portal;
34
+ // ----------------------------------------------------------------------------
35
+ const usePortalTo = (portal) => {
36
+ const themeInfo = React.useContext(ThemeContext_js_1.ThemeContext);
37
+ if (typeof portal === 'boolean') {
38
+ return portal
39
+ ? themeInfo?.portalContainer ?? (0, dom_js_1.getDocument)()?.body
40
+ : null;
41
+ }
42
+ return typeof portal.to === 'function' ? portal.to() : portal.to;
43
+ };
@@ -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';
@@ -21,3 +21,4 @@ tslib_1.__exportStar(require('./LinkAction.js'), exports);
21
21
  tslib_1.__exportStar(require('./AutoclearingHiddenLiveRegion.js'), exports);
22
22
  tslib_1.__exportStar(require('./Box.js'), exports);
23
23
  tslib_1.__exportStar(require('./ButtonBase.js'), exports);
24
+ tslib_1.__exportStar(require('./Portal.js'), exports);
@@ -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';
@@ -13,3 +13,4 @@ tslib_1.__exportStar(require('./focusable.js'), exports);
13
13
  tslib_1.__exportStar(require('./supports.js'), exports);
14
14
  tslib_1.__exportStar(require('./polymorphic.js'), exports);
15
15
  tslib_1.__exportStar(require('./import.js'), exports);
16
+ tslib_1.__exportStar(require('./react.js'), exports);
@@ -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,40 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.cloneElementWithRef = 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 useMergedRefs_js_1 = require('../hooks/useMergedRefs.js');
11
+ /**
12
+ * Wrapper over `cloneElement` that automatically checks for `isValidElement`
13
+ * and automatically merges `children.ref` with the ref passed in props.
14
+ *
15
+ * @private
16
+ */
17
+ const cloneElementWithRef = (children, getProps) => {
18
+ if (!children) {
19
+ return null;
20
+ }
21
+ if (!React.isValidElement(children)) {
22
+ return children;
23
+ }
24
+ const props = getProps(children);
25
+ const ref = (0, useMergedRefs_js_1.mergeRefs)(
26
+ ...[
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ 'ref' in children ? children.ref : null,
29
+ 'ref' in props ? props.ref : null,
30
+ ].filter(Boolean),
31
+ );
32
+ return React.cloneElement(children, {
33
+ ...props,
34
+ // we already checked ref above and handled null, so ts-ignore is ok
35
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
36
+ // @ts-ignore
37
+ ref,
38
+ });
39
+ };
40
+ exports.cloneElementWithRef = cloneElementWithRef;
@@ -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';
@@ -18,4 +18,4 @@ tslib_1.__exportStar(require('./useLatestRef.js'), exports);
18
18
  tslib_1.__exportStar(require('./useIsomorphicLayoutEffect.js'), exports);
19
19
  tslib_1.__exportStar(require('./useIsClient.js'), exports);
20
20
  tslib_1.__exportStar(require('./useId.js'), exports);
21
- tslib_1.__exportStar(require('./useUncontrolledState.js'), exports);
21
+ tslib_1.__exportStar(require('./useControlledState.js'), exports);
@@ -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,39 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.useControlledState = 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
+ /**
11
+ * Wrapper over `useState` that always gives preference to the
12
+ * controlled state (which often comes from a prop).
13
+ *
14
+ * This is helpful when a component needs to support both uncontrolled
15
+ * and controlled states. If controlled value/setter is not passed,
16
+ * then it will work just like a regular `useState`.
17
+ *
18
+ * @example
19
+ * const [state, setState] = useControlledState(null, props.value, props.onChange);
20
+ */
21
+ const useControlledState = (
22
+ initialValue,
23
+ controlledState,
24
+ setControlledState,
25
+ ) => {
26
+ const [uncontrolledState, setUncontrolledState] =
27
+ React.useState(initialValue);
28
+ const state =
29
+ controlledState !== undefined ? controlledState : uncontrolledState;
30
+ const setState = React.useCallback(
31
+ (value) => {
32
+ setUncontrolledState(value);
33
+ setControlledState?.(value);
34
+ },
35
+ [setControlledState, setUncontrolledState],
36
+ );
37
+ return [state, setState];
38
+ };
39
+ exports.useControlledState = useControlledState;
package/cjs/styles.js CHANGED
@@ -34,8 +34,9 @@ const styles = {
34
34
  'iui-button-dropdown': '_iui3-button-dropdown',
35
35
  'iui-button-split': '_iui3-button-split',
36
36
  'iui-button-group': '_iui3-button-group',
37
- 'iui-input-container': '_iui3-input-container',
37
+ 'iui-input-flex-container': '_iui3-input-flex-container',
38
38
  'iui-input': '_iui3-input',
39
+ 'iui-input-grid': '_iui3-input-grid',
39
40
  'iui-disabled': '_iui3-disabled',
40
41
  'iui-button-group-vertical': '_iui3-button-group-vertical',
41
42
  'iui-button-group-overflow-x': '_iui3-button-group-overflow-x',
@@ -178,36 +179,18 @@ const styles = {
178
179
  'iui-information-body-content': '_iui3-information-body-content',
179
180
  'iui-input-label': '_iui3-input-label',
180
181
  'iui-inline': '_iui3-inline',
181
- 'iui-required': '_iui3-required',
182
182
  'iui-input-with-icon': '_iui3-input-with-icon',
183
183
  'iui-select-tag-container': '_iui3-select-tag-container',
184
184
  'iui-end-icon': '_iui3-end-icon',
185
- 'iui-actionable': '_iui3-actionable',
186
185
  'iui-open': '_iui3-open',
187
- 'iui-inline-icon': '_iui3-inline-icon',
188
- 'iui-with-message': '_iui3-with-message',
189
- 'iui-input-icon': '_iui3-input-icon',
186
+ 'iui-required': '_iui3-required',
190
187
  'iui-input-group': '_iui3-input-group',
188
+ 'iui-status-message': '_iui3-status-message',
189
+ 'iui-select-button': '_iui3-select-button',
190
+ 'iui-input-group-wrapper': '_iui3-input-group-wrapper',
191
191
  'iui-toggle-switch-wrapper': '_iui3-toggle-switch-wrapper',
192
192
  'iui-radio-wrapper': '_iui3-radio-wrapper',
193
- 'iui-inline-label': '_iui3-inline-label',
194
- 'iui-label': '_iui3-label',
195
- 'iui-message': '_iui3-message',
196
- 'iui-select-button': '_iui3-select-button',
197
- 'iui-input-flex-container': '_iui3-input-flex-container',
198
193
  'iui-keyboard': '_iui3-keyboard',
199
- 'iui-location-marker': '_iui3-location-marker',
200
- 'iui-location-marker-default': '_iui3-location-marker-default',
201
- 'iui-location-marker-default-pin': '_iui3-location-marker-default-pin',
202
- 'iui-location-marker-default-pin-dot':
203
- '_iui3-location-marker-default-pin-dot',
204
- 'iui-location-marker-data-rich': '_iui3-location-marker-data-rich',
205
- 'iui-location-marker-data-rich-body': '_iui3-location-marker-data-rich-body',
206
- 'iui-location-marker-data-rich-icon': '_iui3-location-marker-data-rich-icon',
207
- 'iui-location-marker-data-rich-icon-monochrome':
208
- '_iui3-location-marker-data-rich-icon-monochrome',
209
- 'iui-location-marker-me': '_iui3-location-marker-me',
210
- 'iui-location-marker-me-dot': '_iui3-location-marker-me-dot',
211
194
  'iui-list': '_iui3-list',
212
195
  'iui-menu': '_iui3-menu',
213
196
  'iui-header-menu-icon': '_iui3-header-menu-icon',
@@ -236,10 +219,10 @@ const styles = {
236
219
  'iui-overlay-exiting': '_iui3-overlay-exiting',
237
220
  closeAnimation,
238
221
  'iui-progress-indicator-radial': '_iui3-progress-indicator-radial',
239
- 'iui-u8bwhh6': '_iui3-u8bwhh6',
222
+ 'iui-ubn95wp': '_iui3-ubn95wp',
240
223
  'iui-progress-indicator-linear-label':
241
224
  '_iui3-progress-indicator-linear-label',
242
- 'iui-u8bwhhv': '_iui3-u8bwhhv',
225
+ 'iui-ubn95xj': '_iui3-ubn95xj',
243
226
  'iui-radio': '_iui3-radio',
244
227
  'iui-radio-tile': '_iui3-radio-tile',
245
228
  'iui-radio-tile-icon': '_iui3-radio-tile-icon',
@@ -306,6 +289,7 @@ const styles = {
306
289
  'iui-table-body': '_iui3-table-body',
307
290
  'iui-table-header-wrapper': '_iui3-table-header-wrapper',
308
291
  'iui-slot': '_iui3-slot',
292
+ 'iui-actionable': '_iui3-actionable',
309
293
  'iui-table-filter-button': '_iui3-table-filter-button',
310
294
  'iui-table-resizer': '_iui3-table-resizer',
311
295
  'iui-table-resizer-bar': '_iui3-table-resizer-bar',
@@ -402,6 +386,7 @@ const styles = {
402
386
  'iui-placement-bottom-start': '_iui3-placement-bottom-start',
403
387
  'iui-placement-bottom-end': '_iui3-placement-bottom-end',
404
388
  'iui-status-area': '_iui3-status-area',
389
+ 'iui-message': '_iui3-message',
405
390
  'iui-toast-anchor': '_iui3-toast-anchor',
406
391
  'iui-informational': '_iui3-informational',
407
392
  'iui-label-on-left': '_iui3-label-on-left',
@@ -409,11 +394,8 @@ const styles = {
409
394
  'iui-toggle-switch-icon': '_iui3-toggle-switch-icon',
410
395
  'iui-toggle-switch': '_iui3-toggle-switch',
411
396
  'iui-toggle-switch-label': '_iui3-toggle-switch-label',
412
- 'iui-tooltip-container': '_iui3-tooltip-container',
413
397
  'iui-tooltip': '_iui3-tooltip',
414
- 'iui-tooltip-visible': '_iui3-tooltip-visible',
415
398
  'iui-transfer-list-wrapper': '_iui3-transfer-list-wrapper',
416
- 'iui-transfer-list-listbox-label': '_iui3-transfer-list-listbox-label',
417
399
  'iui-transfer-list-listbox-wrapper': '_iui3-transfer-list-listbox-wrapper',
418
400
  'iui-transfer-list-listbox': '_iui3-transfer-list-listbox',
419
401
  'iui-transfer-list-toolbar': '_iui3-transfer-list-toolbar',
@@ -12,20 +12,26 @@ type AlertOwnProps = {
12
12
  */
13
13
  isSticky?: boolean;
14
14
  };
15
+ type AlertLegacyProps = {
16
+ /** @deprecated Use `Alert.Action` subcomponent. */
17
+ clickableText?: React.ReactNode;
18
+ /** @deprecated Use `Alert.Action` subcomponent. */
19
+ clickableTextProps?: React.ComponentPropsWithoutRef<'a'>;
20
+ /** @deprecated Use `Alert.CloseButton` subcomponent. */
21
+ onClose?: () => void;
22
+ };
15
23
  /**
16
24
  * A small box to quickly grab user attention and communicate a brief message
17
25
  * @example
18
- * <Alert>
19
- * <Alert.Message>This is an alert.</Alert.Message>
20
- * </Alert>
26
+ * <Alert>This is an alert.</Alert>
21
27
  * @example
22
- * <Alert type='informational'>
28
+ * <Alert.Wrapper type='informational'>
23
29
  * <Alert.Icon />
24
30
  * <Alert.Message>This is an informational alert.</Alert.Message>
25
31
  * <Alert.CloseButton onClick={() => {}} />
26
- * </Alert>
32
+ * </Alert.Wrapper>
27
33
  * @example
28
- * <Alert type='positive'>
34
+ * <Alert.Wrapper type='positive'>
29
35
  * <Alert.Icon>
30
36
  * <SvgSmileyHappy />
31
37
  * </Alert.Icon>
@@ -36,17 +42,22 @@ type AlertOwnProps = {
36
42
  * <Alert.CloseButton onClick={() => {}}>
37
43
  * <SvgCollapse />
38
44
  * </Alert.CloseButton>
39
- * </Alert>
45
+ * </Alert.Wrapper>
40
46
  */
41
- export declare const Alert: PolymorphicForwardRefComponent<"div", AlertOwnProps> & {
47
+ export declare const Alert: PolymorphicForwardRefComponent<"div", AlertOwnProps & AlertLegacyProps> & {
48
+ /**
49
+ * Alert wrapper subcomponent
50
+ */
51
+ Wrapper: PolymorphicForwardRefComponent<"div", AlertOwnProps>;
42
52
  /**
43
53
  * Alert icon subcomponent
44
54
  */
45
55
  Icon: PolymorphicForwardRefComponent<"span", Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
46
56
  ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
47
- }, "fill" | "as" | "key" | "size" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
57
+ }, "fill" | "as" | "key" | "size" | keyof React.HTMLAttributes<HTMLSpanElement> | "padded"> & {
48
58
  size?: "small" | "large" | "auto" | "medium" | import("../utils/types.js").AnyString | undefined;
49
59
  fill?: "default" | "informational" | "negative" | "positive" | "warning" | import("../utils/types.js").AnyString | undefined;
60
+ padded?: boolean | undefined;
50
61
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
51
62
  as?: "span" | undefined;
52
63
  }>;