@carbon/react 1.40.0 → 1.41.0

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 (260) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1564 -872
  2. package/es/components/Accordion/Accordion.Skeleton.d.ts +0 -5
  3. package/es/components/Accordion/Accordion.Skeleton.js +0 -5
  4. package/es/components/Breadcrumb/BreadcrumbItem.js +3 -1
  5. package/es/components/Checkbox/Checkbox.js +3 -6
  6. package/es/components/CodeSnippet/CodeSnippet.js +5 -12
  7. package/es/components/ComboBox/ComboBox.d.ts +1 -5
  8. package/es/components/ComboBox/ComboBox.js +6 -20
  9. package/es/components/ComposedModal/ComposedModal.js +1 -5
  10. package/es/components/ComposedModal/ModalFooter.js +4 -9
  11. package/es/components/ComposedModal/ModalHeader.js +1 -4
  12. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +3 -8
  13. package/es/components/ContentSwitcher/ContentSwitcher.js +7 -11
  14. package/es/components/Copy/Copy.js +4 -8
  15. package/es/components/CopyButton/CopyButton.js +8 -7
  16. package/es/components/DataTable/DataTable.d.ts +3 -39
  17. package/es/components/DataTable/DataTable.js +10 -18
  18. package/es/components/DataTable/Table.d.ts +0 -4
  19. package/es/components/DataTable/Table.js +4 -7
  20. package/es/components/DataTable/TableBatchAction.js +12 -5
  21. package/es/components/DataTable/TableBatchActions.js +1 -6
  22. package/es/components/DataTable/TableBody.d.ts +0 -3
  23. package/es/components/DataTable/TableBody.js +1 -3
  24. package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
  25. package/es/components/DataTable/TableHeader.js +3 -8
  26. package/es/components/DataTable/TableSelectAll.d.ts +0 -3
  27. package/es/components/DataTable/TableSelectAll.js +1 -4
  28. package/es/components/DataTable/TableToolbar.d.ts +10 -0
  29. package/es/components/DataTable/TableToolbar.js +15 -7
  30. package/es/components/DataTable/TableToolbarMenu.js +2 -6
  31. package/es/components/DataTable/TableToolbarSearch.d.ts +2 -8
  32. package/es/components/DataTable/TableToolbarSearch.js +6 -11
  33. package/es/components/DataTable/tools/sorting.js +2 -2
  34. package/es/components/DatePicker/DatePicker.d.ts +4 -4
  35. package/es/components/DatePicker/DatePicker.js +9 -4
  36. package/es/components/DatePicker/plugins/fixEventsPlugin.js +6 -0
  37. package/es/components/DatePickerInput/DatePickerInput.d.ts +1 -1
  38. package/es/components/DatePickerInput/DatePickerInput.js +12 -6
  39. package/es/components/Dropdown/Dropdown.js +6 -15
  40. package/es/components/FileUploader/FileUploader.d.ts +2 -11
  41. package/es/components/FileUploader/FileUploader.js +15 -19
  42. package/es/components/FileUploader/FileUploaderButton.js +2 -2
  43. package/es/components/FileUploader/FileUploaderDropContainer.d.ts +0 -7
  44. package/es/components/FileUploader/FileUploaderDropContainer.js +2 -8
  45. package/es/components/FileUploader/FileUploaderItem.d.ts +0 -4
  46. package/es/components/FileUploader/FileUploaderItem.js +12 -9
  47. package/es/components/FileUploader/Filename.d.ts +6 -10
  48. package/es/components/FileUploader/Filename.js +7 -11
  49. package/es/components/FormGroup/FormGroup.d.ts +0 -5
  50. package/es/components/FormGroup/FormGroup.js +3 -8
  51. package/es/components/FormItem/FormItem.d.ts +32 -0
  52. package/es/components/FormItem/index.d.ts +9 -0
  53. package/es/components/FormLabel/FormLabel.js +4 -1
  54. package/es/components/ListBox/ListBox.js +4 -8
  55. package/es/components/ListBox/ListBoxMenuIcon.js +1 -4
  56. package/es/components/ListBox/ListBoxMenuItem.js +4 -8
  57. package/es/components/ListBox/ListBoxSelection.d.ts +5 -5
  58. package/es/components/ListBox/ListBoxSelection.js +12 -13
  59. package/es/components/ListBox/next/ListBoxSelection.js +12 -13
  60. package/es/components/ListBox/next/ListBoxTrigger.js +3 -5
  61. package/es/components/ListItem/ListItem.d.ts +1 -1
  62. package/es/components/ListItem/ListItem.js +6 -2
  63. package/es/components/Menu/MenuItem.js +4 -1
  64. package/es/components/Modal/Modal.d.ts +137 -0
  65. package/es/components/Modal/Modal.js +39 -45
  66. package/es/components/Modal/index.d.ts +9 -0
  67. package/es/components/ModalWrapper/ModalWrapper.js +13 -19
  68. package/es/components/MultiSelect/FilterableMultiSelect.js +14 -28
  69. package/es/components/MultiSelect/MultiSelect.js +17 -33
  70. package/es/components/MultiSelect/MultiSelectPropTypes.js +2 -2
  71. package/es/components/MultiSelect/tools/sorting.js +2 -2
  72. package/es/components/Notification/Notification.d.ts +11 -29
  73. package/es/components/Notification/Notification.js +38 -57
  74. package/es/components/NumberInput/NumberInput.js +6 -2
  75. package/es/components/OverflowMenu/OverflowMenu.js +27 -33
  76. package/es/components/OverflowMenuItem/OverflowMenuItem.js +4 -1
  77. package/es/components/Pagination/experimental/PageSelector.js +3 -8
  78. package/es/components/Pagination/experimental/Pagination.js +16 -34
  79. package/es/components/ProgressIndicator/ProgressIndicator.js +7 -6
  80. package/es/components/RadioTile/RadioTile.js +6 -7
  81. package/es/components/Search/Search.Skeleton.d.ts +0 -3
  82. package/es/components/Search/Search.Skeleton.js +1 -4
  83. package/es/components/Select/Select.d.ts +2 -2
  84. package/es/components/Select/Select.js +13 -16
  85. package/es/components/SelectItem/SelectItem.d.ts +0 -6
  86. package/es/components/SelectItem/SelectItem.js +4 -10
  87. package/es/components/SelectItemGroup/SelectItemGroup.d.ts +0 -3
  88. package/es/components/SelectItemGroup/SelectItemGroup.js +1 -4
  89. package/es/components/SkeletonIcon/SkeletonIcon.d.ts +13 -0
  90. package/es/components/SkeletonIcon/SkeletonIcon.js +2 -3
  91. package/es/components/SkeletonText/SkeletonText.d.ts +0 -6
  92. package/es/components/SkeletonText/SkeletonText.js +0 -6
  93. package/es/components/Slider/Slider.Skeleton.d.ts +9 -1
  94. package/es/components/Slider/Slider.Skeleton.js +20 -4
  95. package/es/components/Slider/Slider.d.ts +137 -25
  96. package/es/components/Slider/Slider.js +779 -186
  97. package/es/components/StructuredList/StructuredList.js +5 -2
  98. package/es/components/Switch/Switch.js +3 -7
  99. package/es/components/Tabs/Tabs.js +5 -2
  100. package/es/components/Tag/Tag.js +4 -2
  101. package/es/components/Text/Text.js +1 -1
  102. package/es/components/Text/TextDirection.d.ts +1 -1
  103. package/es/components/TextArea/TextArea.js +30 -34
  104. package/es/components/TextInput/ControlledPasswordInput.js +12 -19
  105. package/es/components/TextInput/TextInput.js +8 -3
  106. package/es/components/Tile/Tile.js +5 -3
  107. package/es/components/TileGroup/TileGroup.js +5 -4
  108. package/es/components/Toggle/Toggle.js +4 -2
  109. package/es/components/Toggletip/index.d.ts +6 -1
  110. package/es/components/Toggletip/index.js +7 -1
  111. package/es/components/UIShell/Content.js +1 -4
  112. package/es/components/UIShell/SideNav.d.ts +1 -1
  113. package/es/components/UIShell/SideNavDetails.d.ts +32 -0
  114. package/es/components/UIShell/SideNavDetails.js +1 -2
  115. package/es/components/UIShell/SideNavDivider.d.ts +15 -0
  116. package/es/components/UIShell/SideNavDivider.js +2 -2
  117. package/es/components/UIShell/SideNavFooter.js +2 -5
  118. package/es/components/UIShell/SideNavIcon.d.ts +25 -0
  119. package/es/components/UIShell/SideNavIcon.js +4 -7
  120. package/es/components/UIShell/SideNavSwitcher.d.ts +31 -0
  121. package/es/components/UIShell/SideNavSwitcher.js +6 -5
  122. package/es/index.js +2 -2
  123. package/es/internal/FloatingMenu.js +2 -7
  124. package/es/internal/Selection.js +0 -3
  125. package/es/internal/noopFn.d.ts +7 -0
  126. package/es/internal/noopFn.js +10 -0
  127. package/es/internal/useNormalizedInputProps.js +6 -2
  128. package/es/internal/wrapFocus.js +5 -5
  129. package/es/prop-types/requiredIfGivenPropIsTruthy.js +2 -2
  130. package/lib/components/Accordion/Accordion.Skeleton.d.ts +0 -5
  131. package/lib/components/Accordion/Accordion.Skeleton.js +0 -5
  132. package/lib/components/Breadcrumb/BreadcrumbItem.js +3 -1
  133. package/lib/components/Checkbox/Checkbox.js +3 -6
  134. package/lib/components/CodeSnippet/CodeSnippet.js +5 -12
  135. package/lib/components/ComboBox/ComboBox.d.ts +1 -5
  136. package/lib/components/ComboBox/ComboBox.js +5 -19
  137. package/lib/components/ComposedModal/ComposedModal.js +1 -5
  138. package/lib/components/ComposedModal/ModalFooter.js +4 -9
  139. package/lib/components/ComposedModal/ModalHeader.js +1 -4
  140. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +3 -8
  141. package/lib/components/ContentSwitcher/ContentSwitcher.js +7 -11
  142. package/lib/components/Copy/Copy.js +4 -8
  143. package/lib/components/CopyButton/CopyButton.js +8 -7
  144. package/lib/components/DataTable/DataTable.d.ts +3 -39
  145. package/lib/components/DataTable/DataTable.js +13 -21
  146. package/lib/components/DataTable/Table.d.ts +0 -4
  147. package/lib/components/DataTable/Table.js +3 -6
  148. package/lib/components/DataTable/TableBatchAction.js +12 -5
  149. package/lib/components/DataTable/TableBatchActions.js +1 -6
  150. package/lib/components/DataTable/TableBody.d.ts +0 -3
  151. package/lib/components/DataTable/TableBody.js +1 -3
  152. package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
  153. package/lib/components/DataTable/TableHeader.js +3 -8
  154. package/lib/components/DataTable/TableSelectAll.d.ts +0 -3
  155. package/lib/components/DataTable/TableSelectAll.js +1 -4
  156. package/lib/components/DataTable/TableToolbar.d.ts +10 -0
  157. package/lib/components/DataTable/TableToolbar.js +15 -7
  158. package/lib/components/DataTable/TableToolbarMenu.js +2 -6
  159. package/lib/components/DataTable/TableToolbarSearch.d.ts +2 -8
  160. package/lib/components/DataTable/TableToolbarSearch.js +6 -11
  161. package/lib/components/DataTable/tools/sorting.js +2 -2
  162. package/lib/components/DatePicker/DatePicker.d.ts +4 -4
  163. package/lib/components/DatePicker/DatePicker.js +9 -4
  164. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +6 -0
  165. package/lib/components/DatePickerInput/DatePickerInput.d.ts +1 -1
  166. package/lib/components/DatePickerInput/DatePickerInput.js +12 -6
  167. package/lib/components/Dropdown/Dropdown.js +6 -15
  168. package/lib/components/FileUploader/FileUploader.d.ts +2 -11
  169. package/lib/components/FileUploader/FileUploader.js +15 -19
  170. package/lib/components/FileUploader/FileUploaderButton.js +2 -2
  171. package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +0 -7
  172. package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -8
  173. package/lib/components/FileUploader/FileUploaderItem.d.ts +0 -4
  174. package/lib/components/FileUploader/FileUploaderItem.js +12 -9
  175. package/lib/components/FileUploader/Filename.d.ts +6 -10
  176. package/lib/components/FileUploader/Filename.js +7 -11
  177. package/lib/components/FormGroup/FormGroup.d.ts +0 -5
  178. package/lib/components/FormGroup/FormGroup.js +3 -8
  179. package/lib/components/FormItem/FormItem.d.ts +32 -0
  180. package/lib/components/FormItem/index.d.ts +9 -0
  181. package/lib/components/FormLabel/FormLabel.js +4 -1
  182. package/lib/components/ListBox/ListBox.js +4 -8
  183. package/lib/components/ListBox/ListBoxMenuIcon.js +1 -4
  184. package/lib/components/ListBox/ListBoxMenuItem.js +4 -8
  185. package/lib/components/ListBox/ListBoxSelection.d.ts +5 -5
  186. package/lib/components/ListBox/ListBoxSelection.js +12 -13
  187. package/lib/components/ListBox/next/ListBoxSelection.js +12 -13
  188. package/lib/components/ListBox/next/ListBoxTrigger.js +3 -5
  189. package/lib/components/ListItem/ListItem.d.ts +1 -1
  190. package/lib/components/ListItem/ListItem.js +6 -2
  191. package/lib/components/Menu/MenuItem.js +4 -1
  192. package/lib/components/Modal/Modal.d.ts +137 -0
  193. package/lib/components/Modal/Modal.js +40 -45
  194. package/lib/components/Modal/index.d.ts +9 -0
  195. package/lib/components/ModalWrapper/ModalWrapper.js +13 -19
  196. package/lib/components/MultiSelect/FilterableMultiSelect.js +18 -32
  197. package/lib/components/MultiSelect/MultiSelect.js +16 -32
  198. package/lib/components/MultiSelect/MultiSelectPropTypes.js +2 -2
  199. package/lib/components/MultiSelect/tools/sorting.js +2 -2
  200. package/lib/components/Notification/Notification.d.ts +11 -29
  201. package/lib/components/Notification/Notification.js +38 -57
  202. package/lib/components/NumberInput/NumberInput.js +6 -2
  203. package/lib/components/OverflowMenu/OverflowMenu.js +27 -33
  204. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +4 -1
  205. package/lib/components/Pagination/experimental/PageSelector.js +3 -8
  206. package/lib/components/Pagination/experimental/Pagination.js +16 -34
  207. package/lib/components/ProgressIndicator/ProgressIndicator.js +7 -6
  208. package/lib/components/RadioTile/RadioTile.js +6 -7
  209. package/lib/components/Search/Search.Skeleton.d.ts +0 -3
  210. package/lib/components/Search/Search.Skeleton.js +1 -4
  211. package/lib/components/Select/Select.d.ts +2 -2
  212. package/lib/components/Select/Select.js +13 -16
  213. package/lib/components/SelectItem/SelectItem.d.ts +0 -6
  214. package/lib/components/SelectItem/SelectItem.js +4 -10
  215. package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +0 -3
  216. package/lib/components/SelectItemGroup/SelectItemGroup.js +1 -4
  217. package/lib/components/SkeletonIcon/SkeletonIcon.d.ts +13 -0
  218. package/lib/components/SkeletonIcon/SkeletonIcon.js +2 -3
  219. package/lib/components/SkeletonText/SkeletonText.d.ts +0 -6
  220. package/lib/components/SkeletonText/SkeletonText.js +0 -6
  221. package/lib/components/Slider/Slider.Skeleton.d.ts +9 -1
  222. package/lib/components/Slider/Slider.Skeleton.js +20 -4
  223. package/lib/components/Slider/Slider.d.ts +137 -25
  224. package/lib/components/Slider/Slider.js +778 -185
  225. package/lib/components/StructuredList/StructuredList.js +5 -2
  226. package/lib/components/Switch/Switch.js +3 -7
  227. package/lib/components/Tabs/Tabs.js +5 -2
  228. package/lib/components/Tag/Tag.js +4 -2
  229. package/lib/components/Text/Text.js +1 -1
  230. package/lib/components/Text/TextDirection.d.ts +1 -1
  231. package/lib/components/TextArea/TextArea.js +30 -34
  232. package/lib/components/TextInput/ControlledPasswordInput.js +12 -19
  233. package/lib/components/TextInput/TextInput.js +8 -3
  234. package/lib/components/Tile/Tile.js +5 -3
  235. package/lib/components/TileGroup/TileGroup.js +5 -4
  236. package/lib/components/Toggle/Toggle.js +4 -2
  237. package/lib/components/Toggletip/index.d.ts +6 -1
  238. package/lib/components/Toggletip/index.js +7 -1
  239. package/lib/components/UIShell/Content.js +1 -4
  240. package/lib/components/UIShell/SideNav.d.ts +1 -1
  241. package/lib/components/UIShell/SideNavDetails.d.ts +32 -0
  242. package/lib/components/UIShell/SideNavDetails.js +1 -2
  243. package/lib/components/UIShell/SideNavDivider.d.ts +15 -0
  244. package/lib/components/UIShell/SideNavDivider.js +2 -2
  245. package/lib/components/UIShell/SideNavFooter.js +2 -5
  246. package/lib/components/UIShell/SideNavIcon.d.ts +25 -0
  247. package/lib/components/UIShell/SideNavIcon.js +4 -7
  248. package/lib/components/UIShell/SideNavSwitcher.d.ts +31 -0
  249. package/lib/components/UIShell/SideNavSwitcher.js +5 -4
  250. package/lib/index.js +4 -4
  251. package/lib/internal/FloatingMenu.js +2 -7
  252. package/lib/internal/Selection.js +0 -3
  253. package/lib/internal/noopFn.d.ts +7 -0
  254. package/lib/internal/noopFn.js +14 -0
  255. package/lib/internal/useNormalizedInputProps.js +6 -2
  256. package/lib/internal/wrapFocus.js +5 -5
  257. package/lib/prop-types/requiredIfGivenPropIsTruthy.js +2 -2
  258. package/package.json +9 -9
  259. package/scss/components/slug/_index.scss +9 -0
  260. package/scss/components/slug/_slug.scss +9 -0
@@ -14,6 +14,8 @@ var PropTypes = require('prop-types');
14
14
  var React = require('react');
15
15
  var cx = require('classnames');
16
16
  var usePrefix = require('../../internal/usePrefix.js');
17
+ require('../Text/index.js');
18
+ var Text = require('../Text/Text.js');
17
19
 
18
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
21
 
@@ -30,7 +32,8 @@ function FormLabel(_ref) {
30
32
  } = _ref;
31
33
  const prefix = usePrefix.usePrefix();
32
34
  const className = cx__default["default"](`${prefix}--label`, `${prefix}--label--no-margin`, customClassName);
33
- return /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
35
+ return /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
36
+ as: "label",
34
37
  htmlFor: id,
35
38
  className: className
36
39
  }, rest), children);
@@ -42,8 +42,8 @@ const ListBox = /*#__PURE__*/React__default["default"].forwardRef(function ListB
42
42
  let {
43
43
  children,
44
44
  className: containerClassName,
45
- disabled,
46
- type,
45
+ disabled = false,
46
+ type = 'default',
47
47
  size,
48
48
  invalid,
49
49
  invalidText,
@@ -98,7 +98,7 @@ ListBox.propTypes = {
98
98
  /**
99
99
  * Specify whether the ListBox is currently disabled
100
100
  */
101
- disabled: PropTypes__default["default"].bool.isRequired,
101
+ disabled: PropTypes__default["default"].bool,
102
102
  /**
103
103
  * Specify whether the control is currently invalid
104
104
  */
@@ -124,7 +124,7 @@ ListBox.propTypes = {
124
124
  * Specify the "type" of the ListBox. Currently supports either `default` or
125
125
  * `inline` as an option.
126
126
  */
127
- type: ListBoxPropTypes.ListBoxType.isRequired,
127
+ type: ListBoxPropTypes.ListBoxType,
128
128
  /**
129
129
  * Specify whether the control is currently in warning state
130
130
  */
@@ -134,9 +134,5 @@ ListBox.propTypes = {
134
134
  */
135
135
  warnText: PropTypes__default["default"].node
136
136
  };
137
- ListBox.defaultProps = {
138
- disabled: false,
139
- type: 'default'
140
- };
141
137
 
142
138
  exports["default"] = ListBox;
@@ -62,10 +62,7 @@ ListBoxMenuIcon.propTypes = {
62
62
  * icon. This function takes in an id defined in `translationIds` and should
63
63
  * return a string message for that given message id.
64
64
  */
65
- translateWithId: PropTypes__default["default"].func.isRequired
66
- };
67
- ListBoxMenuIcon.defaultProps = {
68
- translateWithId: defaultTranslateWithId
65
+ translateWithId: PropTypes__default["default"].func
69
66
  };
70
67
 
71
68
  exports["default"] = ListBoxMenuIcon;
@@ -41,8 +41,8 @@ function useIsTruncated(ref) {
41
41
  const ListBoxMenuItem = /*#__PURE__*/React__default["default"].forwardRef(function ListBoxMenuItem(_ref, forwardedRef) {
42
42
  let {
43
43
  children,
44
- isActive,
45
- isHighlighted,
44
+ isActive = false,
45
+ isHighlighted = false,
46
46
  title,
47
47
  ...rest
48
48
  } = _ref;
@@ -75,19 +75,15 @@ ListBoxMenuItem.propTypes = {
75
75
  /**
76
76
  * Specify whether the current menu item is "active".
77
77
  */
78
- isActive: PropTypes__default["default"].bool.isRequired,
78
+ isActive: PropTypes__default["default"].bool,
79
79
  /**
80
80
  * Specify whether the current menu item is "highlighted".
81
81
  */
82
- isHighlighted: PropTypes__default["default"].bool.isRequired,
82
+ isHighlighted: PropTypes__default["default"].bool,
83
83
  /**
84
84
  * Provide an optional tooltip for the ListBoxMenuItem
85
85
  */
86
86
  title: PropTypes__default["default"].string
87
87
  };
88
- ListBoxMenuItem.defaultProps = {
89
- isActive: false,
90
- isHighlighted: false
91
- };
92
88
 
93
89
  exports["default"] = ListBoxMenuItem;
@@ -35,17 +35,17 @@ export interface ListBoxSelectionProps {
35
35
  * icon. This function takes in an id defined in `translationIds` and should
36
36
  * return a string message for that given message id.
37
37
  */
38
- translateWithId(messageId: string, args?: Record<string, unknown>): string;
38
+ translateWithId?(messageId: string, args?: Record<string, unknown>): string;
39
39
  }
40
40
  export type ListBoxSelectionComponent = React.FC<ListBoxSelectionProps>;
41
+ export declare const translationIds: {
42
+ 'clear.all': string;
43
+ 'clear.selection': string;
44
+ };
41
45
  /**
42
46
  * `ListBoxSelection` is used to provide controls for clearing a selection, in
43
47
  * addition to conditionally rendering a badge if the control has more than one
44
48
  * selection.
45
49
  */
46
50
  declare const ListBoxSelection: ListBoxSelectionComponent;
47
- export declare const translationIds: {
48
- 'clear.all': string;
49
- 'clear.selection': string;
50
- };
51
51
  export default ListBoxSelection;
@@ -22,6 +22,16 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
22
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
23
23
 
24
24
  var _Close, _Close2;
25
+ const translationIds = {
26
+ 'clear.all': 'clear.all',
27
+ 'clear.selection': 'clear.selection'
28
+ };
29
+ const defaultTranslations = {
30
+ [translationIds['clear.all']]: 'Clear all selected items',
31
+ [translationIds['clear.selection']]: 'Clear selected item'
32
+ };
33
+ const defaultTranslateWithId = id => defaultTranslations[id];
34
+
25
35
  /**
26
36
  * `ListBoxSelection` is used to provide controls for clearing a selection, in
27
37
  * addition to conditionally rendering a badge if the control has more than one
@@ -31,7 +41,7 @@ const ListBoxSelection = _ref => {
31
41
  let {
32
42
  clearSelection,
33
43
  selectionCount,
34
- translateWithId: t,
44
+ translateWithId: t = defaultTranslateWithId,
35
45
  disabled,
36
46
  onClearSelection,
37
47
  readOnly
@@ -79,14 +89,6 @@ const ListBoxSelection = _ref => {
79
89
  title: description
80
90
  }, selectionCount, _Close2 || (_Close2 = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null)));
81
91
  };
82
- const translationIds = {
83
- 'clear.all': 'clear.all',
84
- 'clear.selection': 'clear.selection'
85
- };
86
- const defaultTranslations = {
87
- [translationIds['clear.all']]: 'Clear all selected items',
88
- [translationIds['clear.selection']]: 'Clear selected item'
89
- };
90
92
  ListBoxSelection.propTypes = {
91
93
  /**
92
94
  * Specify a function to be invoked when a user interacts with the clear
@@ -116,10 +118,7 @@ ListBoxSelection.propTypes = {
116
118
  * icon. This function takes in an id defined in `translationIds` and should
117
119
  * return a string message for that given message id.
118
120
  */
119
- translateWithId: PropTypes__default["default"].func.isRequired
120
- };
121
- ListBoxSelection.defaultProps = {
122
- translateWithId: id => defaultTranslations[id]
121
+ translateWithId: PropTypes__default["default"].func
123
122
  };
124
123
 
125
124
  exports["default"] = ListBoxSelection;
@@ -29,11 +29,21 @@ var _Close, _Close2;
29
29
  * addition to conditionally rendering a badge if the control has more than one
30
30
  * selection.
31
31
  */
32
+
33
+ const translationIds = {
34
+ 'clear.all': 'clear.all',
35
+ 'clear.selection': 'clear.selection'
36
+ };
37
+ const defaultTranslations = {
38
+ [translationIds['clear.all']]: 'Clear all selected items',
39
+ [translationIds['clear.selection']]: 'Clear selected item'
40
+ };
41
+ const defaultTranslateWithId = id => defaultTranslations[id];
32
42
  function ListBoxSelection(_ref) {
33
43
  let {
34
44
  clearSelection,
35
45
  selectionCount,
36
- translateWithId: t,
46
+ translateWithId: t = defaultTranslateWithId,
37
47
  disabled,
38
48
  onClearSelection,
39
49
  ...rest
@@ -83,14 +93,6 @@ function ListBoxSelection(_ref) {
83
93
  type: "button"
84
94
  }), _Close2 || (_Close2 = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null)));
85
95
  }
86
- const translationIds = {
87
- 'clear.all': 'clear.all',
88
- 'clear.selection': 'clear.selection'
89
- };
90
- const defaultTranslations = {
91
- [translationIds['clear.all']]: 'Clear all selected items',
92
- [translationIds['clear.selection']]: 'Clear selected item'
93
- };
94
96
  ListBoxSelection.propTypes = {
95
97
  /**
96
98
  * Specify a function to be invoked when a user interacts with the clear
@@ -126,10 +128,7 @@ ListBoxSelection.propTypes = {
126
128
  * icon. This function takes in an id defined in `translationIds` and should
127
129
  * return a string message for that given message id.
128
130
  */
129
- translateWithId: PropTypes__default["default"].func.isRequired
130
- };
131
- ListBoxSelection.defaultProps = {
132
- translateWithId: id => defaultTranslations[id]
131
+ translateWithId: PropTypes__default["default"].func
133
132
  };
134
133
 
135
134
  exports["default"] = ListBoxSelection;
@@ -31,6 +31,7 @@ const defaultTranslations = {
31
31
  [translationIds['close.menu']]: 'Close',
32
32
  [translationIds['open.menu']]: 'Open'
33
33
  };
34
+ const defaultTranslateWithId = id => defaultTranslations[id];
34
35
 
35
36
  /**
36
37
  * `ListBoxTrigger` is used to orient the icon up or down depending on the
@@ -39,7 +40,7 @@ const defaultTranslations = {
39
40
  const ListBoxTrigger = _ref => {
40
41
  let {
41
42
  isOpen,
42
- translateWithId: t,
43
+ translateWithId: t = defaultTranslateWithId,
43
44
  ...rest
44
45
  } = _ref;
45
46
  const prefix = usePrefix.usePrefix();
@@ -67,10 +68,7 @@ ListBoxTrigger.propTypes = {
67
68
  * icon. This function takes in an id defined in `translationIds` and should
68
69
  * return a string message for that given message id.
69
70
  */
70
- translateWithId: PropTypes__default["default"].func.isRequired
71
- };
72
- ListBoxTrigger.defaultProps = {
73
- translateWithId: id => defaultTranslations[id]
71
+ translateWithId: PropTypes__default["default"].func
74
72
  };
75
73
  var ListBoxTrigger$1 = ListBoxTrigger;
76
74
 
@@ -7,7 +7,7 @@
7
7
  import PropTypes from 'prop-types';
8
8
  import { type ComponentProps } from 'react';
9
9
  type ListItemProps = ComponentProps<'li'>;
10
- declare function ListItem({ className, ...other }: ListItemProps): JSX.Element;
10
+ declare function ListItem({ className, children, ...other }: ListItemProps): JSX.Element;
11
11
  declare namespace ListItem {
12
12
  var propTypes: {
13
13
  /**
@@ -14,6 +14,8 @@ var PropTypes = require('prop-types');
14
14
  var React = require('react');
15
15
  var cx = require('classnames');
16
16
  var usePrefix = require('../../internal/usePrefix.js');
17
+ require('../Text/index.js');
18
+ var Text = require('../Text/Text.js');
17
19
 
18
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
21
 
@@ -24,13 +26,15 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
24
26
  function ListItem(_ref) {
25
27
  let {
26
28
  className,
29
+ children,
27
30
  ...other
28
31
  } = _ref;
29
32
  const prefix = usePrefix.usePrefix();
30
33
  const classNames = cx__default["default"](`${prefix}--list__item`, className);
31
- return /*#__PURE__*/React__default["default"].createElement("li", _rollupPluginBabelHelpers["extends"]({
34
+ return /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
35
+ as: "li",
32
36
  className: classNames
33
- }, other));
37
+ }, other), children);
34
38
  }
35
39
  ListItem.propTypes = {
36
40
  /**
@@ -19,7 +19,9 @@ var useMergedRefs = require('../../internal/useMergedRefs.js');
19
19
  var usePrefix = require('../../internal/usePrefix.js');
20
20
  var Menu = require('./Menu.js');
21
21
  var MenuContext = require('./MenuContext.js');
22
+ require('../Text/index.js');
22
23
  var useLayoutDirection = require('../LayoutDirection/useLayoutDirection.js');
24
+ var Text = require('../Text/Text.js');
23
25
  var match = require('../../internal/keyboard/match.js');
24
26
  var keys = require('../../internal/keyboard/keys.js');
25
27
 
@@ -166,7 +168,8 @@ const MenuItem = /*#__PURE__*/React__default["default"].forwardRef(function Menu
166
168
  onKeyDown: handleKeyDown
167
169
  }), /*#__PURE__*/React__default["default"].createElement("div", {
168
170
  className: `${prefix}--menu-item__icon`
169
- }, IconElement && /*#__PURE__*/React__default["default"].createElement(IconElement, null)), /*#__PURE__*/React__default["default"].createElement("div", {
171
+ }, IconElement && /*#__PURE__*/React__default["default"].createElement(IconElement, null)), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
172
+ as: "div",
170
173
  className: `${prefix}--menu-item__label`
171
174
  }, label), shortcut && !hasChildren && /*#__PURE__*/React__default["default"].createElement("div", {
172
175
  className: `${prefix}--menu-item__shortcut`
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { ReactAttr } from '../../types/common';
9
+ export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
10
+ export type ModalSize = (typeof ModalSizes)[number];
11
+ export interface ModalSecondaryButton {
12
+ buttonText?: string;
13
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
14
+ }
15
+ export interface ModalProps extends ReactAttr<HTMLDivElement> {
16
+ /**
17
+ * Specify whether the Modal is displaying an alert, error or warning
18
+ * Should go hand in hand with the danger prop.
19
+ */
20
+ alert?: boolean;
21
+ /**
22
+ * Required props for the accessibility label of the header
23
+ */
24
+ 'aria-label'?: string;
25
+ /**
26
+ * Provide the contents of your Modal
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Specify an optional className to be applied to the modal root node
31
+ */
32
+ className?: string;
33
+ /**
34
+ * Specify an label for the close button of the modal; defaults to close
35
+ */
36
+ closeButtonLabel?: string;
37
+ /**
38
+ * Specify whether the Modal is for dangerous actions
39
+ */
40
+ danger?: boolean;
41
+ /**
42
+ * Specify whether the modal contains scrolling content
43
+ */
44
+ hasScrollingContent?: boolean;
45
+ /**
46
+ * Specify the DOM element ID of the top-level node.
47
+ */
48
+ id?: string;
49
+ /**
50
+ * Specify whether or not the Modal content should have any inner padding.
51
+ */
52
+ isFullWidth?: boolean;
53
+ /**
54
+ * Provide a ref to return focus to once the modal is closed.
55
+ */
56
+ launcherButtonRef?: any;
57
+ /**
58
+ * Specify a label to be read by screen readers on the modal root node
59
+ */
60
+ modalAriaLabel?: string;
61
+ /**
62
+ * Specify the content of the modal header title.
63
+ */
64
+ modalHeading?: React.ReactNode;
65
+ /**
66
+ * Specify the content of the modal header label.
67
+ */
68
+ modalLabel?: React.ReactNode;
69
+ /**
70
+ * Specify a handler for keypresses.
71
+ * @deprecated this property is unused
72
+ */
73
+ onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
74
+ /**
75
+ * Specify a handler for closing modal.
76
+ * The handler should care of closing modal, e.g. changing `open` prop.
77
+ */
78
+ onRequestClose?: React.ReactEventHandler<HTMLElement>;
79
+ /**
80
+ * Specify a handler for "submitting" modal.
81
+ * The handler should care of closing modal, e.g. changing `open` prop, if necessary.
82
+ */
83
+ onRequestSubmit?: React.ReactEventHandler<HTMLElement>;
84
+ /**
85
+ * Specify a handler for the secondary button.
86
+ * Useful if separate handler from `onRequestClose` is desirable
87
+ */
88
+ onSecondarySubmit?: React.ReactEventHandler<HTMLElement>;
89
+ /**
90
+ * Specify whether the Modal is currently open
91
+ */
92
+ open?: boolean;
93
+ /**
94
+ * Specify whether the modal should be button-less
95
+ */
96
+ passiveModal?: boolean;
97
+ /**
98
+ * Prevent closing on click outside of modal
99
+ */
100
+ preventCloseOnClickOutside?: boolean;
101
+ /**
102
+ * Specify whether the Button should be disabled, or not
103
+ */
104
+ primaryButtonDisabled?: boolean;
105
+ /**
106
+ * Specify the text for the primary button
107
+ */
108
+ primaryButtonText?: React.ReactNode;
109
+ /**
110
+ * Specify the text for the secondary button
111
+ */
112
+ secondaryButtonText?: React.ReactNode;
113
+ /**
114
+ * Specify an array of config objects for secondary buttons
115
+ */
116
+ secondaryButtons?: ModalSecondaryButton[];
117
+ /**
118
+ * Specify a CSS selector that matches the DOM element that should
119
+ * be focused when the Modal opens
120
+ */
121
+ selectorPrimaryFocus?: string;
122
+ /**
123
+ * Specify CSS selectors that match DOM elements working as floating menus.
124
+ * Focusing on those elements won't trigger "focus-wrap" behavior
125
+ */
126
+ selectorsFloatingMenus?: string[];
127
+ /**
128
+ * Specify if Enter key should be used as "submit" action
129
+ */
130
+ shouldSubmitOnEnter?: boolean;
131
+ /**
132
+ * Specify the size variant.
133
+ */
134
+ size?: ModalSize;
135
+ }
136
+ declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
137
+ export default Modal;
@@ -22,6 +22,9 @@ var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropI
22
22
  var wrapFocus = require('../../internal/wrapFocus.js');
23
23
  var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
24
24
  var usePrefix = require('../../internal/usePrefix.js');
25
+ var noopFn = require('../../internal/noopFn.js');
26
+ require('../Text/index.js');
27
+ var Text = require('../Text/Text.js');
25
28
  var match = require('../../internal/keyboard/match.js');
26
29
  var keys = require('../../internal/keyboard/keys.js');
27
30
 
@@ -32,46 +35,43 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
32
35
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
33
36
 
34
37
  const getInstanceId = setupGetInstanceId["default"]();
38
+ const ModalSizes = ['xs', 'sm', 'md', 'lg'];
35
39
  const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_ref, ref) {
36
40
  let {
37
41
  'aria-label': ariaLabelProp,
38
42
  children,
39
43
  className,
40
- modalHeading,
41
- modalLabel,
44
+ modalHeading = '',
45
+ modalLabel = '',
42
46
  modalAriaLabel,
43
- passiveModal,
47
+ passiveModal = false,
44
48
  secondaryButtonText,
45
49
  primaryButtonText,
46
50
  open,
47
- onRequestClose,
48
- onRequestSubmit,
51
+ onRequestClose = noopFn.noopFn,
52
+ onRequestSubmit = noopFn.noopFn,
49
53
  onSecondarySubmit,
50
- primaryButtonDisabled,
54
+ primaryButtonDisabled = false,
51
55
  danger,
52
56
  alert,
53
57
  secondaryButtons,
54
- selectorPrimaryFocus,
55
- // eslint-disable-line
58
+ selectorPrimaryFocus = '[data-modal-primary-focus]',
56
59
  selectorsFloatingMenus,
57
- // eslint-disable-line
58
60
  shouldSubmitOnEnter,
59
- // eslint-disable-line
60
61
  size,
61
- hasScrollingContent,
62
+ hasScrollingContent = false,
62
63
  closeButtonLabel,
63
- preventCloseOnClickOutside,
64
- // eslint-disable-line
64
+ preventCloseOnClickOutside = false,
65
65
  isFullWidth,
66
66
  launcherButtonRef,
67
67
  ...rest
68
68
  } = _ref;
69
69
  const prefix = usePrefix.usePrefix();
70
- const button = React.useRef();
70
+ const button = React.useRef(null);
71
71
  const secondaryButton = React.useRef();
72
- const innerModal = React.useRef();
73
- const startTrap = React.useRef();
74
- const endTrap = React.useRef();
72
+ const innerModal = React.useRef(null);
73
+ const startTrap = React.useRef(null);
74
+ const endTrap = React.useRef(null);
75
75
  const modalInstanceId = `modal-${getInstanceId()}`;
76
76
  const modalLabelId = `${prefix}--modal-header__label--${modalInstanceId}`;
77
77
  const modalHeadingId = `${prefix}--modal-header__heading--${modalInstanceId}`;
@@ -91,7 +91,8 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
91
91
  }
92
92
  }
93
93
  function handleMousedown(evt) {
94
- if (innerModal.current && !innerModal.current.contains(evt.target) && !wrapFocus.elementOrParentIsFloatingMenu(evt.target, selectorsFloatingMenus) && !preventCloseOnClickOutside) {
94
+ const target = evt.target;
95
+ if (innerModal.current && !innerModal.current.contains(target) && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && !preventCloseOnClickOutside) {
95
96
  onRequestClose(evt);
96
97
  }
97
98
  }
@@ -124,9 +125,8 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
124
125
  const modalClasses = cx__default["default"](`${prefix}--modal`, {
125
126
  [`${prefix}--modal-tall`]: !passiveModal,
126
127
  'is-visible': open,
127
- [`${prefix}--modal--danger`]: danger,
128
- [className]: className
129
- });
128
+ [`${prefix}--modal--danger`]: danger
129
+ }, className);
130
130
  const containerClasses = cx__default["default"](`${prefix}--modal-container`, {
131
131
  [`${prefix}--modal-container--${size}`]: size,
132
132
  [`${prefix}--modal-container--full-width`]: isFullWidth
@@ -137,7 +137,12 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
137
137
  const footerClasses = cx__default["default"](`${prefix}--modal-footer`, {
138
138
  [`${prefix}--modal-footer--three-button`]: Array.isArray(secondaryButtons) && secondaryButtons.length === 2
139
139
  });
140
- const ariaLabel = modalLabel || ariaLabelProp || modalAriaLabel || modalHeading;
140
+ const asStringOrUndefined = node => {
141
+ return typeof node === 'string' ? node : undefined;
142
+ };
143
+ const modalLabelStr = asStringOrUndefined(modalLabel);
144
+ const modalHeadingStr = asStringOrUndefined(modalHeading);
145
+ const ariaLabel = modalLabelStr || ariaLabelProp || modalAriaLabel || modalHeadingStr;
141
146
  const getAriaLabelledBy = modalLabel ? modalLabelId : modalHeadingId;
142
147
  const hasScrollingContentProps = hasScrollingContent ? {
143
148
  tabIndex: 0,
@@ -159,7 +164,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
159
164
  };
160
165
  }, [prefix]);
161
166
  React.useEffect(() => {
162
- toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, open);
167
+ toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, open ?? false);
163
168
  }, [open, prefix]);
164
169
  React.useEffect(() => {
165
170
  if (!open && launcherButtonRef) {
@@ -179,7 +184,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
179
184
  };
180
185
  const focusButton = focusContainerElement => {
181
186
  const target = initialFocus(focusContainerElement);
182
- if (target) {
187
+ if (target !== null) {
183
188
  target.focus();
184
189
  }
185
190
  };
@@ -207,13 +212,15 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
207
212
  className: containerClasses,
208
213
  "aria-label": ariaLabel,
209
214
  "aria-modal": "true",
210
- tabIndex: "-1"
215
+ tabIndex: -1
211
216
  }), /*#__PURE__*/React__default["default"].createElement("div", {
212
217
  className: `${prefix}--modal-header`
213
- }, passiveModal && modalButton, modalLabel && /*#__PURE__*/React__default["default"].createElement("h2", {
218
+ }, passiveModal && modalButton, modalLabel && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
219
+ as: "h2",
214
220
  id: modalLabelId,
215
221
  className: `${prefix}--modal-header__label`
216
- }, modalLabel), /*#__PURE__*/React__default["default"].createElement("h3", {
222
+ }, modalLabel), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
223
+ as: "h3",
217
224
  id: modalHeadingId,
218
225
  className: `${prefix}--modal-header__heading`
219
226
  }, modalHeading), !passiveModal && modalButton), /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
@@ -252,12 +259,12 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
252
259
  ref: ref
253
260
  }), /*#__PURE__*/React__default["default"].createElement("span", {
254
261
  ref: startTrap,
255
- tabIndex: "0",
262
+ tabIndex: 0,
256
263
  role: "link",
257
264
  className: `${prefix}--visually-hidden`
258
265
  }, "Focus sentinel"), modalBody, /*#__PURE__*/React__default["default"].createElement("span", {
259
266
  ref: endTrap,
260
- tabIndex: "0",
267
+ tabIndex: 0,
261
268
  role: "link",
262
269
  className: `${prefix}--visually-hidden`
263
270
  }, "Focus sentinel"));
@@ -392,7 +399,7 @@ Modal.propTypes = {
392
399
  * Specify CSS selectors that match DOM elements working as floating menus.
393
400
  * Focusing on those elements won't trigger "focus-wrap" behavior
394
401
  */
395
- selectorsFloatingMenus: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string),
402
+ selectorsFloatingMenus: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string.isRequired),
396
403
  /**
397
404
  * Specify if Enter key should be used as "submit" action
398
405
  */
@@ -400,20 +407,8 @@ Modal.propTypes = {
400
407
  /**
401
408
  * Specify the size variant.
402
409
  */
403
- size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg'])
404
- };
405
- Modal.defaultProps = {
406
- onRequestClose: () => {},
407
- onRequestSubmit: () => {},
408
- primaryButtonDisabled: false,
409
- onKeyDown: () => {},
410
- passiveModal: false,
411
- modalHeading: '',
412
- modalLabel: '',
413
- preventCloseOnClickOutside: false,
414
- selectorPrimaryFocus: '[data-modal-primary-focus]',
415
- hasScrollingContent: false
410
+ size: PropTypes__default["default"].oneOf(ModalSizes)
416
411
  };
417
- var Modal$1 = Modal;
418
412
 
419
- exports["default"] = Modal$1;
413
+ exports.ModalSizes = ModalSizes;
414
+ exports["default"] = Modal;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import Modal from './Modal';
8
+ export default Modal;
9
+ export { Modal };