@carbon/react 1.24.0 → 1.26.0-rc.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.
- package/es/components/Button/Button.js +2 -2
- package/es/components/CodeSnippet/CodeSnippet.js +13 -115
- package/es/components/ComboBox/ComboBox.d.ts +6 -0
- package/es/components/ComboBox/ComboBox.js +19 -172
- package/es/components/ComboButton/index.js +164 -0
- package/es/components/ComposedModal/ComposedModal.js +1 -2
- package/es/components/DataTable/Table.d.ts +74 -0
- package/es/components/DataTable/Table.js +4 -2
- package/es/components/DataTable/TableCell.d.ts +10 -0
- package/es/components/DataTable/TableContext.d.ts +13 -0
- package/es/components/DataTable/TableContext.js +2 -2
- package/es/components/DataTable/TableExpandRow.d.ts +67 -0
- package/es/components/DataTable/TableExpandedRow.d.ts +32 -0
- package/es/components/DataTable/TableHead.d.ts +10 -0
- package/es/components/DataTable/TableHeader.d.ts +64 -0
- package/es/components/DataTable/TableHeader.js +23 -28
- package/es/components/DataTable/TableRow.d.ts +32 -0
- package/es/components/DataTable/TableSelectAll.js +1 -1
- package/es/components/DataTable/TableSelectRow.js +1 -3
- package/es/components/DataTable/TableToolbar.d.ts +19 -0
- package/es/components/DataTable/TableToolbar.js +1 -1
- package/es/components/DataTable/TableToolbarAction.d.ts +21 -0
- package/es/components/DataTable/TableToolbarContent.d.ts +19 -0
- package/es/components/DataTable/TableToolbarMenu.d.ts +24 -0
- package/es/components/DataTable/TableToolbarMenu.js +3 -3
- package/es/components/DataTable/TableToolbarSearch.js +1 -0
- package/es/components/DataTable/tools/sorting.js +2 -1
- package/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
- package/es/components/Dropdown/Dropdown.d.ts +6 -0
- package/es/components/Dropdown/Dropdown.js +8 -145
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -0
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +2 -0
- package/es/components/FileUploader/FileUploaderDropContainer.js +30 -18
- package/es/components/FileUploader/FileUploaderItem.js +2 -1
- package/es/components/FileUploader/Filename.js +8 -2
- package/es/components/FluidTextArea/FluidTextArea.js +12 -1
- package/es/components/IconButton/index.js +1 -0
- package/es/components/InlineCheckbox/InlineCheckbox.js +7 -53
- package/es/components/ListBox/ListBoxSelection.js +4 -23
- package/es/components/ListBox/next/ListBoxSelection.js +2 -23
- package/es/components/Menu/Menu.js +50 -29
- package/es/components/Menu/MenuItem.js +1 -0
- package/es/components/MenuButton/index.js +127 -0
- package/es/components/Modal/Modal.js +4 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +46 -144
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/MultiSelect.js +48 -28
- package/es/components/Notification/Notification.js +27 -264
- package/es/components/NumberInput/NumberInput.js +9 -1
- package/es/components/OverflowMenu/OverflowMenu.js +13 -139
- package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
- package/es/components/OverflowMenuV2/index.js +15 -51
- package/es/components/Popover/index.d.ts +5 -1
- package/es/components/Popover/index.js +37 -9
- package/es/components/RadioButton/RadioButton.Skeleton.d.ts +25 -0
- package/es/components/RadioButton/RadioButton.Skeleton.js +3 -3
- package/es/components/RadioButton/RadioButton.d.ts +64 -0
- package/es/components/RadioButton/RadioButton.js +19 -17
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +80 -0
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +88 -26
- package/es/components/RadioTile/RadioTile.js +6 -6
- package/es/components/Search/Search.Skeleton.d.ts +36 -0
- package/es/components/Search/Search.js +3 -2
- package/es/components/Search/index.js +1 -0
- package/es/components/Select/Select.d.ts +89 -0
- package/es/components/SelectItem/SelectItem.d.ts +62 -0
- package/es/components/SelectItem/SelectItem.js +2 -4
- package/es/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
- package/es/components/SkeletonText/SkeletonText.js +1 -1
- package/es/components/StructuredList/StructuredList.js +11 -39
- package/es/components/Tabs/Tabs.js +29 -6
- package/es/components/TextArea/TextArea.Skeleton.d.ts +33 -0
- package/es/components/TextArea/TextArea.Skeleton.js +5 -5
- package/es/components/TextArea/TextArea.d.ts +9 -2
- package/es/components/TextArea/TextArea.js +31 -8
- package/es/components/TextArea/index.js +1 -0
- package/es/components/TextInput/TextInput.Skeleton.d.ts +33 -0
- package/es/components/TextInput/index.js +1 -0
- package/es/components/Tile/Tile.js +15 -8
- package/es/components/Toggle/Toggle.js +8 -19
- package/es/components/Tooltip/DefinitionTooltip.d.ts +52 -0
- package/es/components/Tooltip/DefinitionTooltip.js +2 -2
- package/es/components/Tooltip/Tooltip.d.ts +117 -0
- package/es/components/Tooltip/Tooltip.js +6 -4
- package/es/components/Tooltip/index.d.ts +9 -0
- package/es/components/UIShell/HeaderMenu.js +13 -4
- package/es/components/UIShell/HeaderMenuItem.js +17 -4
- package/es/index.d.ts +2 -0
- package/es/index.js +5 -3
- package/es/internal/ClickListener.js +1 -2
- package/es/internal/keyboard/match.js +1 -1
- package/es/internal/useAttachedMenu.js +85 -0
- package/es/internal/useDelayedState.d.ts +19 -0
- package/es/internal/useDelayedState.js +7 -3
- package/es/internal/useId.js +1 -1
- package/es/tools/wrapComponent.js +9 -0
- package/lib/components/Button/Button.js +2 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +13 -115
- package/lib/components/ComboBox/ComboBox.d.ts +6 -0
- package/lib/components/ComboBox/ComboBox.js +18 -171
- package/lib/components/ComboButton/index.js +174 -0
- package/lib/components/ComposedModal/ComposedModal.js +1 -2
- package/lib/components/DataTable/Table.d.ts +74 -0
- package/lib/components/DataTable/Table.js +4 -2
- package/lib/components/DataTable/TableCell.d.ts +10 -0
- package/lib/components/DataTable/TableContext.d.ts +13 -0
- package/lib/components/DataTable/TableContext.js +2 -2
- package/lib/components/DataTable/TableExpandRow.d.ts +67 -0
- package/lib/components/DataTable/TableExpandedRow.d.ts +32 -0
- package/lib/components/DataTable/TableHead.d.ts +10 -0
- package/lib/components/DataTable/TableHeader.d.ts +64 -0
- package/lib/components/DataTable/TableHeader.js +23 -28
- package/lib/components/DataTable/TableRow.d.ts +32 -0
- package/lib/components/DataTable/TableSelectAll.js +1 -1
- package/lib/components/DataTable/TableSelectRow.js +1 -3
- package/lib/components/DataTable/TableToolbar.d.ts +19 -0
- package/lib/components/DataTable/TableToolbar.js +1 -1
- package/lib/components/DataTable/TableToolbarAction.d.ts +21 -0
- package/lib/components/DataTable/TableToolbarContent.d.ts +19 -0
- package/lib/components/DataTable/TableToolbarMenu.d.ts +24 -0
- package/lib/components/DataTable/TableToolbarMenu.js +3 -3
- package/lib/components/DataTable/TableToolbarSearch.js +1 -0
- package/lib/components/DataTable/tools/sorting.js +2 -1
- package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
- package/lib/components/Dropdown/Dropdown.d.ts +6 -0
- package/lib/components/Dropdown/Dropdown.js +7 -144
- package/lib/components/ExpandableSearch/ExpandableSearch.js +1 -0
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +2 -0
- package/lib/components/FileUploader/FileUploaderDropContainer.js +30 -18
- package/lib/components/FileUploader/FileUploaderItem.js +2 -1
- package/lib/components/FileUploader/Filename.js +8 -2
- package/lib/components/FluidTextArea/FluidTextArea.js +12 -1
- package/lib/components/IconButton/index.js +1 -0
- package/lib/components/InlineCheckbox/InlineCheckbox.js +7 -53
- package/lib/components/ListBox/ListBoxSelection.js +4 -23
- package/lib/components/ListBox/next/ListBoxSelection.js +2 -23
- package/lib/components/Menu/Menu.js +50 -29
- package/lib/components/Menu/MenuItem.js +1 -0
- package/lib/components/MenuButton/index.js +137 -0
- package/lib/components/Modal/Modal.js +4 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +43 -141
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.js +47 -27
- package/lib/components/Notification/Notification.js +27 -264
- package/lib/components/NumberInput/NumberInput.js +9 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +13 -139
- package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
- package/lib/components/OverflowMenuV2/index.js +13 -49
- package/lib/components/Popover/index.d.ts +5 -1
- package/lib/components/Popover/index.js +37 -9
- package/lib/components/RadioButton/RadioButton.Skeleton.d.ts +25 -0
- package/lib/components/RadioButton/RadioButton.Skeleton.js +3 -3
- package/lib/components/RadioButton/RadioButton.d.ts +64 -0
- package/lib/components/RadioButton/RadioButton.js +18 -16
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +80 -0
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +86 -24
- package/lib/components/RadioTile/RadioTile.js +6 -6
- package/lib/components/Search/Search.Skeleton.d.ts +36 -0
- package/lib/components/Search/Search.js +3 -2
- package/lib/components/Search/index.js +2 -0
- package/lib/components/Select/Select.d.ts +89 -0
- package/lib/components/SelectItem/SelectItem.d.ts +62 -0
- package/lib/components/SelectItem/SelectItem.js +1 -3
- package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
- package/lib/components/SkeletonText/SkeletonText.js +1 -1
- package/lib/components/StructuredList/StructuredList.js +11 -39
- package/lib/components/Tabs/Tabs.js +29 -6
- package/lib/components/TextArea/TextArea.Skeleton.d.ts +33 -0
- package/lib/components/TextArea/TextArea.Skeleton.js +5 -5
- package/lib/components/TextArea/TextArea.d.ts +9 -2
- package/lib/components/TextArea/TextArea.js +30 -7
- package/lib/components/TextArea/index.js +2 -0
- package/lib/components/TextInput/TextInput.Skeleton.d.ts +33 -0
- package/lib/components/TextInput/index.js +2 -0
- package/lib/components/Tile/Tile.js +15 -8
- package/lib/components/Toggle/Toggle.js +8 -19
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +52 -0
- package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
- package/lib/components/Tooltip/Tooltip.d.ts +117 -0
- package/lib/components/Tooltip/Tooltip.js +6 -4
- package/lib/components/Tooltip/index.d.ts +9 -0
- package/lib/components/UIShell/HeaderMenu.js +13 -4
- package/lib/components/UIShell/HeaderMenuItem.js +17 -4
- package/lib/index.d.ts +2 -0
- package/lib/index.js +50 -46
- package/lib/internal/ClickListener.js +1 -2
- package/lib/internal/keyboard/match.js +1 -1
- package/lib/internal/useAttachedMenu.js +89 -0
- package/lib/internal/useDelayedState.d.ts +19 -0
- package/lib/internal/useDelayedState.js +7 -3
- package/lib/internal/useId.js +1 -1
- package/lib/tools/wrapComponent.js +9 -0
- package/package.json +3 -3
|
@@ -31,7 +31,9 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
31
31
|
var useResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(useResizeObserver);
|
|
32
32
|
var copy__default = /*#__PURE__*/_interopDefaultLegacy(copy);
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _CodeSnippet$propType, _CodeSnippet$defaultP;
|
|
35
|
+
|
|
36
|
+
var _excluded = ["className", "type", "children", "disabled", "feedback", "feedbackTimeout", "onClick", "aria-label", "ariaLabel", "copyText", "copyButtonDescription", "light", "showMoreText", "showLessText", "hideCopyButton", "wrapText", "maxCollapsedNumberOfRows", "maxExpandedNumberOfRows", "minCollapsedNumberOfRows", "minExpandedNumberOfRows"];
|
|
35
37
|
var rowHeightInPixels = 16;
|
|
36
38
|
var defaultMaxCollapsedNumberOfRows = 15;
|
|
37
39
|
var defaultMaxExpandedNumberOfRows = 0;
|
|
@@ -48,7 +50,8 @@ function CodeSnippet(_ref) {
|
|
|
48
50
|
feedback = _ref.feedback,
|
|
49
51
|
feedbackTimeout = _ref.feedbackTimeout,
|
|
50
52
|
onClick = _ref.onClick,
|
|
51
|
-
ariaLabel = _ref
|
|
53
|
+
ariaLabel = _ref['aria-label'],
|
|
54
|
+
deprecatedAriaLabel = _ref.ariaLabel,
|
|
52
55
|
copyText = _ref.copyText,
|
|
53
56
|
copyButtonDescription = _ref.copyButtonDescription,
|
|
54
57
|
light = _ref.light,
|
|
@@ -183,7 +186,7 @@ function CodeSnippet(_ref) {
|
|
|
183
186
|
|
|
184
187
|
return /*#__PURE__*/React__default["default"].createElement(Copy["default"], _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
185
188
|
onClick: handleCopyClick,
|
|
186
|
-
"aria-label": ariaLabel,
|
|
189
|
+
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
187
190
|
"aria-describedby": uid,
|
|
188
191
|
className: codeSnippetClasses,
|
|
189
192
|
feedback: feedback,
|
|
@@ -226,10 +229,12 @@ function CodeSnippet(_ref) {
|
|
|
226
229
|
className: codeSnippetClasses
|
|
227
230
|
}), /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
228
231
|
ref: codeContainerRef,
|
|
229
|
-
role: type === 'single' ? 'textbox' : null,
|
|
230
|
-
tabIndex: type === 'single' && !disabled ? 0 : null,
|
|
232
|
+
role: type === 'single' || type === 'multi' ? 'textbox' : null,
|
|
233
|
+
tabIndex: (type === 'single' || type === 'multi') && !disabled ? 0 : null,
|
|
231
234
|
className: "".concat(prefix, "--snippet-container"),
|
|
232
|
-
"aria-label": ariaLabel || 'code-snippet',
|
|
235
|
+
"aria-label": deprecatedAriaLabel || ariaLabel || 'code-snippet',
|
|
236
|
+
"aria-readonly": type === 'single' || type === 'multi' ? true : null,
|
|
237
|
+
"aria-multiline": type === 'multi' ? true : null,
|
|
233
238
|
onScroll: type === 'single' && handleScroll || null
|
|
234
239
|
}, containerStyle), /*#__PURE__*/React__default["default"].createElement("pre", {
|
|
235
240
|
ref: codeContentRef,
|
|
@@ -263,114 +268,7 @@ function CodeSnippet(_ref) {
|
|
|
263
268
|
})));
|
|
264
269
|
}
|
|
265
270
|
|
|
266
|
-
CodeSnippet.propTypes = {
|
|
267
|
-
|
|
268
|
-
* Specify a label to be read by screen readers on the containing <textbox>
|
|
269
|
-
* node
|
|
270
|
-
*/
|
|
271
|
-
ariaLabel: PropTypes__default["default"].string,
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Provide the content of your CodeSnippet as a node or string
|
|
275
|
-
*/
|
|
276
|
-
children: PropTypes__default["default"].node,
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Specify an optional className to be applied to the container node
|
|
280
|
-
*/
|
|
281
|
-
className: PropTypes__default["default"].string,
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Specify the description for the Copy Button
|
|
285
|
-
*/
|
|
286
|
-
copyButtonDescription: PropTypes__default["default"].string,
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Optional text to copy. If not specified, the `children` node's `innerText`
|
|
290
|
-
* will be used as the copy value.
|
|
291
|
-
*/
|
|
292
|
-
copyText: PropTypes__default["default"].string,
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Specify whether or not the CodeSnippet should be disabled
|
|
296
|
-
*/
|
|
297
|
-
disabled: PropTypes__default["default"].bool,
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Specify the string displayed when the snippet is copied
|
|
301
|
-
*/
|
|
302
|
-
feedback: PropTypes__default["default"].string,
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Specify the time it takes for the feedback message to timeout
|
|
306
|
-
*/
|
|
307
|
-
feedbackTimeout: PropTypes__default["default"].number,
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Specify whether or not a copy button should be used/rendered.
|
|
311
|
-
*/
|
|
312
|
-
hideCopyButton: PropTypes__default["default"].bool,
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Specify whether you are using the light variant of the Code Snippet,
|
|
316
|
-
* typically used for inline snippet to display an alternate color
|
|
317
|
-
*/
|
|
318
|
-
light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `CodeSnippet` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Specify the maximum number of rows to be shown when in collapsed view
|
|
322
|
-
*/
|
|
323
|
-
maxCollapsedNumberOfRows: PropTypes__default["default"].number,
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Specify the maximum number of rows to be shown when in expanded view
|
|
327
|
-
*/
|
|
328
|
-
maxExpandedNumberOfRows: PropTypes__default["default"].number,
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Specify the minimum number of rows to be shown when in collapsed view
|
|
332
|
-
*/
|
|
333
|
-
minCollapsedNumberOfRows: PropTypes__default["default"].number,
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Specify the minimum number of rows to be shown when in expanded view
|
|
337
|
-
*/
|
|
338
|
-
minExpandedNumberOfRows: PropTypes__default["default"].number,
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* An optional handler to listen to the `onClick` even fired by the Copy
|
|
342
|
-
* Button
|
|
343
|
-
*/
|
|
344
|
-
onClick: PropTypes__default["default"].func,
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Specify a string that is displayed when the Code Snippet has been
|
|
348
|
-
* interacted with to show more lines
|
|
349
|
-
*/
|
|
350
|
-
showLessText: PropTypes__default["default"].string,
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Specify a string that is displayed when the Code Snippet text is more
|
|
354
|
-
* than 15 lines
|
|
355
|
-
*/
|
|
356
|
-
showMoreText: PropTypes__default["default"].string,
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Provide the type of Code Snippet
|
|
360
|
-
*/
|
|
361
|
-
type: PropTypes__default["default"].oneOf(['single', 'inline', 'multi']),
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Specify whether or not to wrap the text.
|
|
365
|
-
*/
|
|
366
|
-
wrapText: PropTypes__default["default"].bool
|
|
367
|
-
};
|
|
368
|
-
CodeSnippet.defaultProps = {
|
|
369
|
-
ariaLabel: 'Copy to clipboard',
|
|
370
|
-
type: 'single',
|
|
371
|
-
showMoreText: 'Show more',
|
|
372
|
-
showLessText: 'Show less',
|
|
373
|
-
wrapText: false
|
|
374
|
-
};
|
|
271
|
+
CodeSnippet.propTypes = (_CodeSnippet$propType = {}, _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, 'aria-label', PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "ariaLabel", deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.')), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "children", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "className", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "copyButtonDescription", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "copyText", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "disabled", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "feedback", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "feedbackTimeout", PropTypes__default["default"].number), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "hideCopyButton", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "light", deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `CodeSnippet` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.')), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "maxCollapsedNumberOfRows", PropTypes__default["default"].number), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "maxExpandedNumberOfRows", PropTypes__default["default"].number), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "minCollapsedNumberOfRows", PropTypes__default["default"].number), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "minExpandedNumberOfRows", PropTypes__default["default"].number), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "onClick", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "showLessText", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "showMoreText", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "type", PropTypes__default["default"].oneOf(['single', 'inline', 'multi'])), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$propType, "wrapText", PropTypes__default["default"].bool), _CodeSnippet$propType);
|
|
272
|
+
CodeSnippet.defaultProps = (_CodeSnippet$defaultP = {}, _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$defaultP, 'aria-label', 'Copy to clipboard'), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$defaultP, "type", 'single'), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$defaultP, "showMoreText", 'Show more'), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$defaultP, "showLessText", 'Show less'), _rollupPluginBabelHelpers.defineProperty(_CodeSnippet$defaultP, "wrapText", false), _CodeSnippet$defaultP);
|
|
375
273
|
|
|
376
274
|
exports["default"] = CodeSnippet;
|
|
@@ -11,6 +11,12 @@ import { ListBoxType, ListBoxSize } from '../ListBox';
|
|
|
11
11
|
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
|
|
12
12
|
export interface ComboBoxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
13
13
|
/**
|
|
14
|
+
* Specify a label to be read by screen readers on the container node
|
|
15
|
+
* 'aria-label' of the ListBox component.
|
|
16
|
+
*/
|
|
17
|
+
['aria-label']?: string;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated please use `aria-label` instead.
|
|
14
20
|
* 'aria-label' of the ListBox component.
|
|
15
21
|
*/
|
|
16
22
|
ariaLabel?: string;
|
|
@@ -38,7 +38,9 @@ var Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
|
|
|
38
38
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
39
39
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
40
40
|
|
|
41
|
-
var
|
|
41
|
+
var _ComboBox$propTypes, _ComboBox$defaultProp;
|
|
42
|
+
|
|
43
|
+
var _excluded = ["aria-label", "ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "readOnly", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
42
44
|
|
|
43
45
|
var defaultItemToString = function defaultItemToString(item) {
|
|
44
46
|
if (typeof item === 'string') {
|
|
@@ -95,7 +97,8 @@ var getInstanceId = setupGetInstanceId["default"]();
|
|
|
95
97
|
var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props, ref) {
|
|
96
98
|
var _cx, _ref4, _cx4, _Text;
|
|
97
99
|
|
|
98
|
-
var ariaLabel = props
|
|
100
|
+
var ariaLabel = props['aria-label'],
|
|
101
|
+
deprecatedAriaLabel = props.ariaLabel,
|
|
99
102
|
containerClassName = props.className,
|
|
100
103
|
direction = props.direction,
|
|
101
104
|
disabled = props.disabled,
|
|
@@ -315,6 +318,14 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
315
318
|
if (match.match(event, keys.Enter) && !inputValue) {
|
|
316
319
|
toggleMenu();
|
|
317
320
|
}
|
|
321
|
+
|
|
322
|
+
if (match.match(event, keys.Escape) && inputValue) {
|
|
323
|
+
if (event.target === textInput.current && isOpen) {
|
|
324
|
+
toggleMenu();
|
|
325
|
+
event.preventDownshiftDefault = true;
|
|
326
|
+
event.persist();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
318
329
|
}
|
|
319
330
|
});
|
|
320
331
|
|
|
@@ -377,7 +388,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
377
388
|
isOpen: isOpen,
|
|
378
389
|
translateWithId: translateWithId
|
|
379
390
|
}))), /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, getMenuProps({
|
|
380
|
-
'aria-label': ariaLabel
|
|
391
|
+
'aria-label': deprecatedAriaLabel || ariaLabel
|
|
381
392
|
}), isOpen ? filterItems(items, itemToString, inputValue).map(function (item, index) {
|
|
382
393
|
var _getItemProps;
|
|
383
394
|
|
|
@@ -406,178 +417,14 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
406
417
|
});
|
|
407
418
|
});
|
|
408
419
|
ComboBox.displayName = 'ComboBox';
|
|
409
|
-
ComboBox.propTypes = {
|
|
410
|
-
|
|
411
|
-
* 'aria-label' of the ListBox component.
|
|
412
|
-
*/
|
|
413
|
-
ariaLabel: PropTypes__default["default"].string,
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* An optional className to add to the container node
|
|
417
|
-
*/
|
|
418
|
-
className: PropTypes__default["default"].string,
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Specify the direction of the combobox dropdown. Can be either top or bottom.
|
|
422
|
-
*/
|
|
423
|
-
direction: PropTypes__default["default"].oneOf(['top', 'bottom']),
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Specify if the control should be disabled, or not
|
|
427
|
-
*/
|
|
428
|
-
disabled: PropTypes__default["default"].bool,
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Additional props passed to Downshift
|
|
432
|
-
*/
|
|
433
|
-
// @ts-ignore
|
|
434
|
-
downshiftProps: PropTypes__default["default"].shape(Downshift__default["default"].propTypes),
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Provide helper text that is used alongside the control label for
|
|
438
|
-
* additional help
|
|
439
|
-
*/
|
|
440
|
-
helperText: PropTypes__default["default"].string,
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* Specify a custom `id` for the input
|
|
444
|
-
*/
|
|
445
|
-
id: PropTypes__default["default"].string.isRequired,
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* Allow users to pass in an arbitrary item or a string (in case their items are an array of strings)
|
|
449
|
-
* from their collection that are pre-selected
|
|
450
|
-
*/
|
|
451
|
-
initialSelectedItem: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].string, PropTypes__default["default"].number]),
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Specify if the currently selected value is invalid.
|
|
455
|
-
*/
|
|
456
|
-
invalid: PropTypes__default["default"].bool,
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Message which is displayed if the value is invalid.
|
|
460
|
-
*/
|
|
461
|
-
invalidText: PropTypes__default["default"].node,
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* Optional function to render items as custom components instead of strings.
|
|
465
|
-
* Defaults to null and is overridden by a getter
|
|
466
|
-
*/
|
|
467
|
-
itemToElement: PropTypes__default["default"].func,
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Helper function passed to downshift that allows the library to render a
|
|
471
|
-
* given item to a string label. By default, it extracts the `label` field
|
|
472
|
-
* from a given item to serve as the item label in the list
|
|
473
|
-
*/
|
|
474
|
-
itemToString: PropTypes__default["default"].func,
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* We try to stay as generic as possible here to allow individuals to pass
|
|
478
|
-
* in a collection of whatever kind of data structure they prefer
|
|
479
|
-
*/
|
|
480
|
-
items: PropTypes__default["default"].array.isRequired,
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* should use "light theme" (white background)?
|
|
484
|
-
*/
|
|
485
|
-
light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `Combobox` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* `onChange` is a utility for this controlled component to communicate to a
|
|
489
|
-
* consuming component when a specific dropdown item is selected.
|
|
490
|
-
* `({ selectedItem }) => void`
|
|
491
|
-
* @param {{ selectedItem }}
|
|
492
|
-
*/
|
|
493
|
-
onChange: PropTypes__default["default"].func.isRequired,
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Callback function to notify consumer when the text input changes.
|
|
497
|
-
* This provides support to change available items based on the text.
|
|
498
|
-
* `(inputText) => void`
|
|
499
|
-
* @param {string} inputText
|
|
500
|
-
*/
|
|
501
|
-
onInputChange: PropTypes__default["default"].func,
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Helper function passed to Downshift that allows the user to observe internal
|
|
505
|
-
* state changes
|
|
506
|
-
* `(changes, stateAndHelpers) => void`
|
|
507
|
-
*/
|
|
508
|
-
onStateChange: PropTypes__default["default"].func,
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Callback function that fires when the combobox menu toggle is clicked
|
|
512
|
-
* `(evt) => void`
|
|
513
|
-
* @param {MouseEvent} event
|
|
514
|
-
*/
|
|
515
|
-
onToggleClick: PropTypes__default["default"].func,
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Used to provide a placeholder text node before a user enters any input.
|
|
519
|
-
* This is only present if the control has no items selected
|
|
520
|
-
*/
|
|
521
|
-
placeholder: PropTypes__default["default"].string,
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Is the ComboBox readonly?
|
|
525
|
-
*/
|
|
526
|
-
readOnly: PropTypes__default["default"].bool,
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* For full control of the selection
|
|
530
|
-
*/
|
|
531
|
-
selectedItem: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].string, PropTypes__default["default"].number]),
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Specify your own filtering logic by passing in a `shouldFilterItem`
|
|
535
|
-
* function that takes in the current input and an item and passes back
|
|
536
|
-
* whether or not the item should be filtered.
|
|
537
|
-
*/
|
|
538
|
-
shouldFilterItem: PropTypes__default["default"].func,
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
542
|
-
*/
|
|
543
|
-
size: ListBoxPropTypes.ListBoxSize,
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Provide text to be used in a `<label>` element that is tied to the
|
|
547
|
-
* combobox via ARIA attributes.
|
|
548
|
-
*/
|
|
549
|
-
titleText: PropTypes__default["default"].node,
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Specify a custom translation function that takes in a message identifier
|
|
553
|
-
* and returns the localized string for the message
|
|
554
|
-
*/
|
|
555
|
-
translateWithId: PropTypes__default["default"].func,
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Currently supports either the default type, or an inline variant
|
|
559
|
-
*/
|
|
560
|
-
type: ListBoxPropTypes.ListBoxType,
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Specify whether the control is currently in warning state
|
|
564
|
-
*/
|
|
565
|
-
warn: PropTypes__default["default"].bool,
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Provide the text that is displayed when the control is in warning state
|
|
569
|
-
*/
|
|
570
|
-
warnText: PropTypes__default["default"].node
|
|
571
|
-
};
|
|
572
|
-
ComboBox.defaultProps = {
|
|
420
|
+
ComboBox.propTypes = (_ComboBox$propTypes = {}, _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, 'aria-label', PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "ariaLabel", deprecate["default"](PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.')), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "className", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "direction", PropTypes__default["default"].oneOf(['top', 'bottom'])), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "disabled", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "downshiftProps", PropTypes__default["default"].shape(Downshift__default["default"].propTypes)), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "helperText", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "id", PropTypes__default["default"].string.isRequired), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "initialSelectedItem", PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].string, PropTypes__default["default"].number])), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "invalid", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "invalidText", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "itemToElement", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "itemToString", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "items", PropTypes__default["default"].array.isRequired), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "light", deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `Combobox` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.')), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "onChange", PropTypes__default["default"].func.isRequired), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "onInputChange", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "onStateChange", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "onToggleClick", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "placeholder", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "readOnly", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "selectedItem", PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].string, PropTypes__default["default"].number])), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "shouldFilterItem", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "size", ListBoxPropTypes.ListBoxSize), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "titleText", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "translateWithId", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "type", ListBoxPropTypes.ListBoxType), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "warn", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_ComboBox$propTypes, "warnText", PropTypes__default["default"].node), _ComboBox$propTypes);
|
|
421
|
+
ComboBox.defaultProps = (_ComboBox$defaultProp = {
|
|
573
422
|
disabled: false,
|
|
574
423
|
itemToString: defaultItemToString,
|
|
575
424
|
itemToElement: null,
|
|
576
425
|
shouldFilterItem: defaultShouldFilterItem,
|
|
577
|
-
type: 'default'
|
|
578
|
-
|
|
579
|
-
direction: 'bottom'
|
|
580
|
-
};
|
|
426
|
+
type: 'default'
|
|
427
|
+
}, _rollupPluginBabelHelpers.defineProperty(_ComboBox$defaultProp, 'aria-label', 'Choose an item'), _rollupPluginBabelHelpers.defineProperty(_ComboBox$defaultProp, "direction", 'bottom'), _ComboBox$defaultProp);
|
|
581
428
|
var ComboBox$1 = ComboBox;
|
|
582
429
|
|
|
583
430
|
exports["default"] = ComboBox$1;
|
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var React = require('react');
|
|
14
|
+
var PropTypes = require('prop-types');
|
|
15
|
+
var cx = require('classnames');
|
|
16
|
+
var iconsReact = require('@carbon/icons-react');
|
|
17
|
+
var Button = require('../Button/Button.js');
|
|
18
|
+
var index = require('../IconButton/index.js');
|
|
19
|
+
var Menu = require('../Menu/Menu.js');
|
|
20
|
+
var useAttachedMenu = require('../../internal/useAttachedMenu.js');
|
|
21
|
+
var useId = require('../../internal/useId.js');
|
|
22
|
+
var useMergedRefs = require('../../internal/useMergedRefs.js');
|
|
23
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
24
|
+
|
|
25
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
|
+
|
|
27
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
28
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
29
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
30
|
+
|
|
31
|
+
var _ChevronDown;
|
|
32
|
+
|
|
33
|
+
var _excluded = ["children", "className", "disabled", "label", "onClick", "size", "tooltipAlign", "translateWithId"];
|
|
34
|
+
var spacing = 4; // top and bottom spacing between the button and the menu. in px
|
|
35
|
+
|
|
36
|
+
var defaultTranslations = {
|
|
37
|
+
'carbon.combo-button.additional-actions': 'Additional actions'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function defaultTranslateWithId(messageId) {
|
|
41
|
+
return defaultTranslations[messageId];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function ComboButton(_ref, forwardRef) {
|
|
45
|
+
var children = _ref.children,
|
|
46
|
+
className = _ref.className,
|
|
47
|
+
disabled = _ref.disabled,
|
|
48
|
+
label = _ref.label,
|
|
49
|
+
onClick = _ref.onClick,
|
|
50
|
+
_ref$size = _ref.size,
|
|
51
|
+
size = _ref$size === void 0 ? 'lg' : _ref$size,
|
|
52
|
+
tooltipAlign = _ref.tooltipAlign,
|
|
53
|
+
_ref$translateWithId = _ref.translateWithId,
|
|
54
|
+
t = _ref$translateWithId === void 0 ? defaultTranslateWithId : _ref$translateWithId,
|
|
55
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
56
|
+
|
|
57
|
+
var id = useId.useId('combobutton');
|
|
58
|
+
var prefix = usePrefix.usePrefix();
|
|
59
|
+
var containerRef = React.useRef(null);
|
|
60
|
+
var menuRef = React.useRef(null);
|
|
61
|
+
var ref = useMergedRefs.useMergedRefs([forwardRef, containerRef]);
|
|
62
|
+
|
|
63
|
+
var _useState = React.useState(0),
|
|
64
|
+
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
|
65
|
+
width = _useState2[0],
|
|
66
|
+
setWidth = _useState2[1];
|
|
67
|
+
|
|
68
|
+
var _useAttachedMenu = useAttachedMenu.useAttachedMenu(containerRef),
|
|
69
|
+
open = _useAttachedMenu.open,
|
|
70
|
+
x = _useAttachedMenu.x,
|
|
71
|
+
y = _useAttachedMenu.y,
|
|
72
|
+
hookOnClick = _useAttachedMenu.handleClick,
|
|
73
|
+
handleTriggerMousedown = _useAttachedMenu.handleMousedown,
|
|
74
|
+
handleClose = _useAttachedMenu.handleClose;
|
|
75
|
+
|
|
76
|
+
function handleTriggerClick() {
|
|
77
|
+
if (containerRef.current) {
|
|
78
|
+
var _containerRef$current = containerRef.current.getBoundingClientRect(),
|
|
79
|
+
w = _containerRef$current.width;
|
|
80
|
+
|
|
81
|
+
setWidth(w);
|
|
82
|
+
hookOnClick();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function handlePrimaryActionClick(e) {
|
|
87
|
+
if (onClick) {
|
|
88
|
+
onClick(e);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function handleOpen() {
|
|
93
|
+
menuRef.current.style.width = "".concat(width, "px");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var containerClasses = cx__default["default"]("".concat(prefix, "--combo-button__container"), "".concat(prefix, "--combo-button__container--").concat(size), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--combo-button__container--open"), open), className);
|
|
97
|
+
var primaryActionClasses = cx__default["default"]("".concat(prefix, "--combo-button__primary-action"));
|
|
98
|
+
var triggerClasses = cx__default["default"]("".concat(prefix, "--combo-button__trigger"));
|
|
99
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
100
|
+
className: containerClasses,
|
|
101
|
+
ref: ref
|
|
102
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
103
|
+
className: primaryActionClasses
|
|
104
|
+
}, /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
105
|
+
size: size,
|
|
106
|
+
disabled: disabled,
|
|
107
|
+
onClick: handlePrimaryActionClick
|
|
108
|
+
}, label)), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
|
|
109
|
+
className: triggerClasses,
|
|
110
|
+
label: t('carbon.combo-button.additional-actions'),
|
|
111
|
+
size: size,
|
|
112
|
+
disabled: disabled,
|
|
113
|
+
align: tooltipAlign,
|
|
114
|
+
"aria-haspopup": true,
|
|
115
|
+
"aria-expanded": open,
|
|
116
|
+
onClick: handleTriggerClick,
|
|
117
|
+
onMouseDown: handleTriggerMousedown,
|
|
118
|
+
"aria-owns": open ? id : null
|
|
119
|
+
}, _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronDown, null))), /*#__PURE__*/React__default["default"].createElement(Menu.Menu, {
|
|
120
|
+
ref: menuRef,
|
|
121
|
+
id: id,
|
|
122
|
+
label: t('carbon.combo-button.additional-actions'),
|
|
123
|
+
size: size,
|
|
124
|
+
open: open,
|
|
125
|
+
onClose: handleClose,
|
|
126
|
+
onOpen: handleOpen,
|
|
127
|
+
x: x,
|
|
128
|
+
y: [y[0] - spacing, y[1] + spacing]
|
|
129
|
+
}, children));
|
|
130
|
+
});
|
|
131
|
+
ComboButton.propTypes = {
|
|
132
|
+
/**
|
|
133
|
+
* A collection of MenuItems to be rendered as additional actions for this ComboButton.
|
|
134
|
+
*/
|
|
135
|
+
children: PropTypes__default["default"].node.isRequired,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Additional CSS class names.
|
|
139
|
+
*/
|
|
140
|
+
className: PropTypes__default["default"].string,
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Specify whether the ComboButton should be disabled, or not.
|
|
144
|
+
*/
|
|
145
|
+
disabled: PropTypes__default["default"].bool,
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Provide the label to be renderd on the primary action button.
|
|
149
|
+
*/
|
|
150
|
+
label: PropTypes__default["default"].string.isRequired,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Provide an optional function to be called when the primary action element is clicked.
|
|
154
|
+
*/
|
|
155
|
+
onClick: PropTypes__default["default"].func,
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Specify the size of the buttons and menu.
|
|
159
|
+
*/
|
|
160
|
+
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Specify how the trigger tooltip should be aligned.
|
|
164
|
+
*/
|
|
165
|
+
tooltipAlign: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Optional method that takes in a message id and returns an
|
|
169
|
+
* internationalized string.
|
|
170
|
+
*/
|
|
171
|
+
translateWithId: PropTypes__default["default"].func
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
exports.ComboButton = ComboButton;
|
|
@@ -206,8 +206,7 @@ var ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
206
206
|
onBlur: handleBlur,
|
|
207
207
|
onMouseDown: handleMousedown,
|
|
208
208
|
onKeyDown: handleKeyDown,
|
|
209
|
-
className: modalClass
|
|
210
|
-
tabIndex: "-1"
|
|
209
|
+
className: modalClass
|
|
211
210
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
212
211
|
className: containerClass,
|
|
213
212
|
role: "dialog",
|
|
@@ -0,0 +1,74 @@
|
|
|
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 { PropsWithChildren } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
interface TableProps {
|
|
10
|
+
className?: string;
|
|
11
|
+
/**
|
|
12
|
+
* `false` If true, will apply sorting styles
|
|
13
|
+
*/
|
|
14
|
+
isSortable?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Specify whether the overflow menu (if it exists) should be shown always, or only on hover
|
|
17
|
+
*/
|
|
18
|
+
overflowMenuOnHover?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Change the row height of table. Currently supports `xs`, `sm`, `md`, `lg`, and `xl`.
|
|
21
|
+
*/
|
|
22
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
23
|
+
/**
|
|
24
|
+
* `false` If true, will keep the header sticky (only data rows will scroll)
|
|
25
|
+
*/
|
|
26
|
+
stickyHeader?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* `false` If true, will use a width of 'auto' instead of 100%
|
|
29
|
+
*/
|
|
30
|
+
useStaticWidth?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* `true` to add useZebraStyles striping.
|
|
33
|
+
*/
|
|
34
|
+
useZebraStyles?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare const Table: {
|
|
37
|
+
({ className, children, useZebraStyles, size, isSortable, useStaticWidth, stickyHeader, overflowMenuOnHover, ...other }: PropsWithChildren<TableProps>): JSX.Element;
|
|
38
|
+
propTypes: {
|
|
39
|
+
/**
|
|
40
|
+
* Pass in the children that will be rendered within the Table
|
|
41
|
+
*/
|
|
42
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
43
|
+
className: PropTypes.Requireable<string>;
|
|
44
|
+
/**
|
|
45
|
+
* `false` If true, will apply sorting styles
|
|
46
|
+
*/
|
|
47
|
+
isSortable: PropTypes.Requireable<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Specify whether the overflow menu (if it exists) should be shown always, or only on hover
|
|
50
|
+
*/
|
|
51
|
+
overflowMenuOnHover: PropTypes.Requireable<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Change the row height of table. Currently supports `xs`, `sm`, `md`, `lg`, and `xl`.
|
|
54
|
+
*/
|
|
55
|
+
size: PropTypes.Requireable<string>;
|
|
56
|
+
/**
|
|
57
|
+
* `false` If true, will keep the header sticky (only data rows will scroll)
|
|
58
|
+
*/
|
|
59
|
+
stickyHeader: PropTypes.Requireable<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* `false` If true, will use a width of 'auto' instead of 100%
|
|
62
|
+
*/
|
|
63
|
+
useStaticWidth: PropTypes.Requireable<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* `true` to add useZebraStyles striping.
|
|
66
|
+
*/
|
|
67
|
+
useZebraStyles: PropTypes.Requireable<boolean>;
|
|
68
|
+
};
|
|
69
|
+
defaultProps: {
|
|
70
|
+
isSortable: boolean;
|
|
71
|
+
overflowMenuOnHover: boolean;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export default Table;
|