@carbon/react 1.30.0 → 1.31.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/Accordion/Accordion.js +3 -1
- package/es/components/AspectRatio/AspectRatio.d.ts +67 -0
- package/es/components/AspectRatio/AspectRatio.js +2 -2
- package/es/components/AspectRatio/index.d.ts +7 -0
- package/es/components/Button/Button.js +6 -1
- package/es/components/Checkbox/Checkbox.js +2 -2
- package/es/components/CodeSnippet/CodeSnippet.js +1 -0
- package/es/components/ComboButton/index.js +6 -5
- package/es/components/ContainedList/ContainedList.js +12 -4
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +6 -1
- package/es/components/ContentSwitcher/ContentSwitcher.js +10 -1
- package/es/components/CopyButton/CopyButton.js +8 -2
- package/es/components/DataTable/DataTable.js +8 -2
- package/es/components/DataTable/Table.d.ts +6 -1
- package/es/components/DataTable/Table.js +78 -3
- package/es/components/DataTable/TableHeader.js +2 -1
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +1 -2
- package/es/components/DataTableSkeleton/index.d.ts +9 -0
- package/es/components/ExpandableSearch/ExpandableSearch.d.ts +1 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +6 -2
- package/es/components/FileUploader/FileUploaderButton.js +2 -1
- package/es/components/IconButton/index.js +10 -2
- package/es/components/Layout/index.js +118 -0
- package/es/components/Link/Link.d.ts +53 -0
- package/es/components/Link/Link.js +4 -3
- package/es/components/Link/index.d.ts +9 -0
- package/es/components/ListBox/ListBoxPropTypes.d.ts +1 -1
- package/es/components/Menu/MenuItem.js +2 -1
- package/es/components/MenuButton/index.js +7 -4
- package/es/components/OverflowMenu/index.js +9 -1
- package/es/components/OverflowMenu/next/index.js +98 -0
- package/es/components/OverflowMenuV2/index.js +15 -73
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +0 -1
- package/es/components/Search/Search.d.ts +4 -0
- package/es/components/Search/Search.js +8 -2
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Tabs/Tabs.js +5 -1
- package/es/components/Tag/Tag.js +2 -0
- package/es/components/TextArea/TextArea.Skeleton.js +1 -2
- package/es/components/TextArea/TextArea.js +1 -2
- package/es/components/TextArea/index.d.ts +10 -0
- package/es/components/TextInput/PasswordInput.js +1 -2
- package/es/components/TextInput/TextInput.Skeleton.js +1 -2
- package/es/components/TextInput/TextInput.js +5 -4
- package/es/components/TextInput/index.d.ts +4 -0
- package/es/components/TimePicker/TimePicker.d.ts +8 -0
- package/es/components/TimePicker/TimePicker.js +26 -6
- package/es/components/Tooltip/Tooltip.js +4 -2
- package/es/components/UIShell/HeaderMenuItem.d.ts +22 -0
- package/es/components/UIShell/HeaderMenuItem.js +4 -3
- package/es/components/UIShell/HeaderPanel.js +3 -11
- package/es/components/UIShell/Link.d.ts +48 -0
- package/es/components/UIShell/Link.js +30 -19
- package/es/components/UIShell/SideNav.d.ts +2 -1
- package/es/components/UIShell/SideNav.js +25 -7
- package/es/index.d.ts +21 -20
- package/es/index.js +30 -28
- package/lib/components/Accordion/Accordion.js +3 -1
- package/lib/components/AspectRatio/AspectRatio.d.ts +67 -0
- package/lib/components/AspectRatio/AspectRatio.js +2 -2
- package/lib/components/AspectRatio/index.d.ts +7 -0
- package/lib/components/Button/Button.js +6 -1
- package/lib/components/Checkbox/Checkbox.js +2 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
- package/lib/components/ComboButton/index.js +6 -5
- package/lib/components/ContainedList/ContainedList.js +12 -4
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +6 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.js +10 -1
- package/lib/components/CopyButton/CopyButton.js +8 -2
- package/lib/components/DataTable/DataTable.js +8 -2
- package/lib/components/DataTable/Table.d.ts +6 -1
- package/lib/components/DataTable/Table.js +78 -2
- package/lib/components/DataTable/TableHeader.js +2 -1
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +1 -2
- package/lib/components/DataTableSkeleton/index.d.ts +9 -0
- package/lib/components/ExpandableSearch/ExpandableSearch.d.ts +1 -1
- package/lib/components/ExpandableSearch/ExpandableSearch.js +6 -2
- package/lib/components/FileUploader/FileUploaderButton.js +2 -1
- package/lib/components/IconButton/index.js +10 -2
- package/lib/components/Layout/index.js +129 -0
- package/lib/components/Link/Link.d.ts +53 -0
- package/lib/components/Link/Link.js +4 -3
- package/lib/components/Link/index.d.ts +9 -0
- package/lib/components/ListBox/ListBoxPropTypes.d.ts +1 -1
- package/lib/components/Menu/MenuItem.js +2 -1
- package/lib/components/MenuButton/index.js +7 -4
- package/lib/components/OverflowMenu/index.js +13 -1
- package/lib/components/OverflowMenu/next/index.js +108 -0
- package/lib/components/OverflowMenuV2/index.js +14 -74
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +0 -1
- package/lib/components/Search/Search.d.ts +4 -0
- package/lib/components/Search/Search.js +8 -2
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Tabs/Tabs.js +5 -1
- package/lib/components/Tag/Tag.js +2 -0
- package/lib/components/TextArea/TextArea.Skeleton.js +1 -2
- package/lib/components/TextArea/TextArea.js +1 -2
- package/lib/components/TextArea/index.d.ts +10 -0
- package/lib/components/TextInput/PasswordInput.js +1 -2
- package/lib/components/TextInput/TextInput.Skeleton.js +1 -2
- package/lib/components/TextInput/TextInput.js +5 -4
- package/lib/components/TextInput/index.d.ts +4 -0
- package/lib/components/TimePicker/TimePicker.d.ts +8 -0
- package/lib/components/TimePicker/TimePicker.js +26 -6
- package/lib/components/Tooltip/Tooltip.js +4 -2
- package/lib/components/UIShell/HeaderMenuItem.d.ts +22 -0
- package/lib/components/UIShell/HeaderMenuItem.js +3 -2
- package/lib/components/UIShell/HeaderPanel.js +3 -11
- package/lib/components/UIShell/Link.d.ts +48 -0
- package/lib/components/UIShell/Link.js +29 -18
- package/lib/components/UIShell/SideNav.d.ts +2 -1
- package/lib/components/UIShell/SideNav.js +24 -6
- package/lib/index.d.ts +21 -20
- package/lib/index.js +92 -89
- package/package.json +10 -9
- /package/es/components/{Layout → LayoutDirection}/LayoutDirection.js +0 -0
- /package/es/components/{Layout → LayoutDirection}/LayoutDirectionContext.js +0 -0
- /package/es/components/{Layout → LayoutDirection}/useLayoutDirection.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/LayoutDirection.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/LayoutDirectionContext.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/useLayoutDirection.js +0 -0
|
@@ -13,25 +13,57 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var React = require('react');
|
|
14
14
|
var PropTypes = require('prop-types');
|
|
15
15
|
var cx = require('classnames');
|
|
16
|
+
var debounce = require('lodash.debounce');
|
|
16
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
18
|
var TableContext = require('./TableContext.js');
|
|
19
|
+
var useEvent = require('../../internal/useEvent.js');
|
|
18
20
|
|
|
19
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
22
|
|
|
21
23
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
24
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
23
25
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
|
+
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
24
27
|
|
|
28
|
+
const isElementWrappingContent = (element, context) => {
|
|
29
|
+
if (element.children.length > 0) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const computedStyles = window.getComputedStyle(element);
|
|
33
|
+
context.font = computedStyles.font ? computedStyles.font : `${computedStyles.fontSize}" "${computedStyles.fontFamily}`;
|
|
34
|
+
const measuredText = context?.measureText(element.textContent ?? '');
|
|
35
|
+
let textWidth = measuredText.width ?? 0;
|
|
36
|
+
// account for letter spacing
|
|
37
|
+
const letterSpacing = computedStyles.letterSpacing?.split('px');
|
|
38
|
+
if (letterSpacing && letterSpacing.length && !isNaN(Number(letterSpacing[0]))) {
|
|
39
|
+
textWidth += Number(letterSpacing[0]) * (element.textContent?.length ?? 0);
|
|
40
|
+
}
|
|
41
|
+
// account for padding
|
|
42
|
+
const paddingLeft = computedStyles.paddingLeft?.split('px');
|
|
43
|
+
if (paddingLeft && paddingLeft.length && !isNaN(Number(paddingLeft[0]))) {
|
|
44
|
+
textWidth += Number(paddingLeft[0]);
|
|
45
|
+
}
|
|
46
|
+
const paddingRight = computedStyles.paddingLeft?.split('px');
|
|
47
|
+
if (paddingRight && paddingRight.length && !isNaN(Number(paddingRight[0]))) {
|
|
48
|
+
textWidth += Number(paddingRight[0]);
|
|
49
|
+
}
|
|
50
|
+
// if measured textWidth is larger than the cell's width, then the content is being wrapped
|
|
51
|
+
if (textWidth > element.getBoundingClientRect().width) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
};
|
|
25
56
|
const Table = _ref => {
|
|
26
57
|
let {
|
|
27
58
|
className,
|
|
28
59
|
children,
|
|
29
60
|
useZebraStyles,
|
|
30
|
-
size,
|
|
61
|
+
size = 'lg',
|
|
31
62
|
isSortable = false,
|
|
32
63
|
useStaticWidth,
|
|
33
64
|
stickyHeader,
|
|
34
65
|
overflowMenuOnHover = true,
|
|
66
|
+
experimentalAutoAlign = false,
|
|
35
67
|
...other
|
|
36
68
|
} = _ref;
|
|
37
69
|
const {
|
|
@@ -39,6 +71,7 @@ const Table = _ref => {
|
|
|
39
71
|
descriptionId
|
|
40
72
|
} = React.useContext(TableContext.TableContext);
|
|
41
73
|
const prefix = usePrefix.usePrefix();
|
|
74
|
+
const tableRef = React.useRef(null);
|
|
42
75
|
const componentClass = cx__default["default"](`${prefix}--data-table`, className, {
|
|
43
76
|
[`${prefix}--data-table--${size}`]: size,
|
|
44
77
|
[`${prefix}--data-table--sort`]: isSortable,
|
|
@@ -47,13 +80,52 @@ const Table = _ref => {
|
|
|
47
80
|
[`${prefix}--data-table--sticky-header`]: stickyHeader,
|
|
48
81
|
[`${prefix}--data-table--visible-overflow-menu`]: !overflowMenuOnHover
|
|
49
82
|
});
|
|
83
|
+
const toggleTableBodyAlignmentClass = React.useCallback(function () {
|
|
84
|
+
let alignTop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
85
|
+
alignTop ? tableRef.current?.classList.add(`${prefix}--data-table--top-aligned-body`) : tableRef.current?.classList.remove(`${prefix}--data-table--top-aligned-body`);
|
|
86
|
+
}, [prefix]);
|
|
87
|
+
const toggleTableHeaderAlignmentClass = React.useCallback(function () {
|
|
88
|
+
let alignTop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
89
|
+
alignTop ? tableRef.current?.classList.add(`${prefix}--data-table--top-aligned-header`) : tableRef.current?.classList.remove(`${prefix}--data-table--top-aligned-header`);
|
|
90
|
+
}, [prefix]);
|
|
91
|
+
const setTableAlignment = React.useCallback(() => {
|
|
92
|
+
if (experimentalAutoAlign) {
|
|
93
|
+
const canvas = document.createElement('canvas');
|
|
94
|
+
const context = canvas.getContext('2d');
|
|
95
|
+
if (tableRef.current && context) {
|
|
96
|
+
const isBodyMultiline = Array.from(tableRef.current.querySelectorAll('td')).some(td => isElementWrappingContent(td, context));
|
|
97
|
+
const isHeaderMultiline = Array.from(tableRef.current.querySelectorAll('th')).some(th => {
|
|
98
|
+
const label = th.querySelector(`.${prefix}--table-header-label`);
|
|
99
|
+
return label && isElementWrappingContent(label, context);
|
|
100
|
+
});
|
|
101
|
+
toggleTableBodyAlignmentClass(isBodyMultiline);
|
|
102
|
+
toggleTableHeaderAlignmentClass(isHeaderMultiline);
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
toggleTableBodyAlignmentClass(false);
|
|
106
|
+
toggleTableHeaderAlignmentClass(false);
|
|
107
|
+
}
|
|
108
|
+
}, [experimentalAutoAlign, toggleTableBodyAlignmentClass, toggleTableHeaderAlignmentClass, prefix]);
|
|
109
|
+
const debouncedSetTableAlignment = debounce__default["default"](setTableAlignment, 100);
|
|
110
|
+
useEvent.useWindowEvent('resize', debouncedSetTableAlignment);
|
|
111
|
+
|
|
112
|
+
// recalculate table alignment once fonts have loaded
|
|
113
|
+
if (document?.fonts?.status && document.fonts.status !== 'loaded') {
|
|
114
|
+
document.fonts.ready.then(() => {
|
|
115
|
+
setTableAlignment();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
React.useLayoutEffect(() => {
|
|
119
|
+
setTableAlignment();
|
|
120
|
+
}, [setTableAlignment, size]);
|
|
50
121
|
const table = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
51
122
|
className: `${prefix}--data-table-content`
|
|
52
123
|
}, /*#__PURE__*/React__default["default"].createElement("table", _rollupPluginBabelHelpers["extends"]({
|
|
53
124
|
"aria-labelledby": titleId,
|
|
54
125
|
"aria-describedby": descriptionId
|
|
55
126
|
}, other, {
|
|
56
|
-
className: componentClass
|
|
127
|
+
className: componentClass,
|
|
128
|
+
ref: tableRef
|
|
57
129
|
}), children));
|
|
58
130
|
return stickyHeader ? /*#__PURE__*/React__default["default"].createElement("section", {
|
|
59
131
|
className: `${prefix}--data-table_inner-container`
|
|
@@ -65,6 +137,10 @@ Table.propTypes = {
|
|
|
65
137
|
*/
|
|
66
138
|
children: PropTypes__default["default"].node,
|
|
67
139
|
className: PropTypes__default["default"].string,
|
|
140
|
+
/**
|
|
141
|
+
* Experimental property. Allows table to align cell contents to the top if there is text wrapping in the content. Might have performance issues, intended for smaller tables
|
|
142
|
+
*/
|
|
143
|
+
experimentalAutoAlign: PropTypes__default["default"].bool,
|
|
68
144
|
/**
|
|
69
145
|
* `false` If true, will apply sorting styles
|
|
70
146
|
*/
|
|
@@ -90,10 +90,11 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
|
|
|
90
90
|
isSortHeader,
|
|
91
91
|
sortStates: sortStates.sortStates
|
|
92
92
|
});
|
|
93
|
+
const headerClasses = cx__default["default"](headerClassName, `${prefix}--table-sort__header`);
|
|
93
94
|
return /*#__PURE__*/React__default["default"].createElement("th", {
|
|
94
95
|
id: id,
|
|
95
96
|
"aria-sort": ariaSort,
|
|
96
|
-
className:
|
|
97
|
+
className: headerClasses,
|
|
97
98
|
colSpan: colSpan,
|
|
98
99
|
ref: ref,
|
|
99
100
|
scope: scope
|
|
@@ -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 DataTableSkeleton from './DataTableSkeleton';
|
|
8
|
+
export default DataTableSkeleton;
|
|
9
|
+
export { DataTableSkeleton };
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { type SearchProps } from '../Search';
|
|
9
|
-
declare function ExpandableSearch({ onBlur, onChange, onExpand, onFocus, ...props }: SearchProps): JSX.Element;
|
|
9
|
+
declare function ExpandableSearch({ onBlur, onChange, onExpand, onFocus, defaultValue, isExpanded, ...props }: SearchProps): JSX.Element;
|
|
10
10
|
declare namespace ExpandableSearch {
|
|
11
11
|
var propTypes: React.WeakValidationMap<SearchProps & React.RefAttributes<HTMLInputElement>> | undefined;
|
|
12
12
|
var displayName: string;
|
|
@@ -28,10 +28,12 @@ function ExpandableSearch(_ref) {
|
|
|
28
28
|
onChange,
|
|
29
29
|
onExpand,
|
|
30
30
|
onFocus,
|
|
31
|
+
defaultValue,
|
|
32
|
+
isExpanded,
|
|
31
33
|
...props
|
|
32
34
|
} = _ref;
|
|
33
|
-
const [expanded, setExpanded] = React.useState(false);
|
|
34
|
-
const [hasContent, setHasContent] = React.useState(false);
|
|
35
|
+
const [expanded, setExpanded] = React.useState(isExpanded || false);
|
|
36
|
+
const [hasContent, setHasContent] = React.useState(defaultValue ? true : false);
|
|
35
37
|
const searchRef = React.useRef(null);
|
|
36
38
|
const prefix = usePrefix.usePrefix();
|
|
37
39
|
function handleFocus() {
|
|
@@ -55,6 +57,8 @@ function ExpandableSearch(_ref) {
|
|
|
55
57
|
[`${prefix}--search--expanded`]: expanded
|
|
56
58
|
}, props.className);
|
|
57
59
|
return /*#__PURE__*/React__default["default"].createElement(Search["default"], _rollupPluginBabelHelpers["extends"]({}, props, {
|
|
60
|
+
defaultValue: defaultValue,
|
|
61
|
+
isExpanded: expanded,
|
|
58
62
|
ref: searchRef,
|
|
59
63
|
className: classes,
|
|
60
64
|
onFocus: events.composeEventHandlers([onFocus, handleFocus]),
|
|
@@ -56,7 +56,8 @@ function FileUploaderButton(_ref) {
|
|
|
56
56
|
[`${prefix}--btn--disabled`]: disabled,
|
|
57
57
|
// V11: remove field, small
|
|
58
58
|
[`${prefix}--btn--md`]: size === 'field' || size === 'md',
|
|
59
|
-
[`${prefix}--btn--sm`]: size === 'small' || size === 'sm'
|
|
59
|
+
[`${prefix}--btn--sm`]: size === 'small' || size === 'sm',
|
|
60
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
60
61
|
});
|
|
61
62
|
|
|
62
63
|
// Adjust label text state based on changes to the labelText prop
|
|
@@ -31,16 +31,19 @@ const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Ic
|
|
|
31
31
|
className,
|
|
32
32
|
closeOnActivation = true,
|
|
33
33
|
defaultOpen = false,
|
|
34
|
+
disabled,
|
|
34
35
|
enterDelayMs,
|
|
35
36
|
kind,
|
|
36
37
|
label,
|
|
37
38
|
leaveDelayMs,
|
|
38
39
|
wrapperClasses,
|
|
39
|
-
size
|
|
40
|
+
size,
|
|
40
41
|
...rest
|
|
41
42
|
} = props;
|
|
42
43
|
const prefix = usePrefix.usePrefix();
|
|
43
|
-
const tooltipClasses = cx__default["default"](wrapperClasses, `${prefix}--icon-tooltip
|
|
44
|
+
const tooltipClasses = cx__default["default"](wrapperClasses, `${prefix}--icon-tooltip`, {
|
|
45
|
+
[`${prefix}--icon-tooltip--disabled`]: disabled
|
|
46
|
+
});
|
|
44
47
|
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
45
48
|
align: align,
|
|
46
49
|
closeOnActivation: closeOnActivation,
|
|
@@ -50,6 +53,7 @@ const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Ic
|
|
|
50
53
|
label: label,
|
|
51
54
|
leaveDelayMs: leaveDelayMs
|
|
52
55
|
}, /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
56
|
+
disabled: disabled,
|
|
53
57
|
kind: kind,
|
|
54
58
|
ref: ref,
|
|
55
59
|
size: size,
|
|
@@ -77,6 +81,10 @@ IconButton.propTypes = {
|
|
|
77
81
|
* Specify whether the tooltip should be open when it first renders
|
|
78
82
|
*/
|
|
79
83
|
defaultOpen: PropTypes__default["default"].bool,
|
|
84
|
+
/**
|
|
85
|
+
* Specify whether the Button should be disabled, or not
|
|
86
|
+
*/
|
|
87
|
+
disabled: PropTypes__default["default"].bool,
|
|
80
88
|
/**
|
|
81
89
|
* Specify the duration in milliseconds to delay before displaying the tooltip
|
|
82
90
|
*/
|
|
@@ -0,0 +1,129 @@
|
|
|
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 cx = require('classnames');
|
|
14
|
+
var PropTypes = require('prop-types');
|
|
15
|
+
var React = require('react');
|
|
16
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
21
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
22
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
|
+
|
|
24
|
+
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl'];
|
|
25
|
+
const densities = ['condensed', 'normal'];
|
|
26
|
+
const Layout = /*#__PURE__*/React__default["default"].forwardRef(function Layout(_ref, forwardRef) {
|
|
27
|
+
let {
|
|
28
|
+
as: BaseComponent = 'div',
|
|
29
|
+
children,
|
|
30
|
+
className,
|
|
31
|
+
density,
|
|
32
|
+
size,
|
|
33
|
+
...rest
|
|
34
|
+
} = _ref;
|
|
35
|
+
const prefix = usePrefix.usePrefix();
|
|
36
|
+
const classes = cx__default["default"](className, `${prefix}--layout`, {
|
|
37
|
+
[`${prefix}--layout--size-${size}`]: sizes.includes(size),
|
|
38
|
+
[`${prefix}--layout--density-${density}`]: densities.includes(density)
|
|
39
|
+
});
|
|
40
|
+
return /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
41
|
+
ref: forwardRef,
|
|
42
|
+
className: classes
|
|
43
|
+
}), children);
|
|
44
|
+
});
|
|
45
|
+
Layout.propTypes = {
|
|
46
|
+
/**
|
|
47
|
+
* Specify a custom component or element to be rendered as the top-level
|
|
48
|
+
* element in the component
|
|
49
|
+
*/
|
|
50
|
+
as: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].string, PropTypes__default["default"].elementType]),
|
|
51
|
+
/**
|
|
52
|
+
* Provide child elements to be rendered inside of `Layout`
|
|
53
|
+
*/
|
|
54
|
+
children: PropTypes__default["default"].node,
|
|
55
|
+
/**
|
|
56
|
+
* Provide a custom class name to be used on the outermost element rendered by
|
|
57
|
+
* the component
|
|
58
|
+
*/
|
|
59
|
+
className: PropTypes__default["default"].string,
|
|
60
|
+
/**
|
|
61
|
+
* Specify the desired density of components within this layout
|
|
62
|
+
*/
|
|
63
|
+
density: PropTypes__default["default"].oneOf(densities),
|
|
64
|
+
/**
|
|
65
|
+
* Specify the desired size of components within this layout
|
|
66
|
+
*/
|
|
67
|
+
size: PropTypes__default["default"].oneOf(sizes)
|
|
68
|
+
};
|
|
69
|
+
const LayoutConstraint = /*#__PURE__*/React__default["default"].forwardRef(function Layout(_ref2, forwardRef) {
|
|
70
|
+
let {
|
|
71
|
+
as: BaseComponent = 'div',
|
|
72
|
+
children,
|
|
73
|
+
className,
|
|
74
|
+
density,
|
|
75
|
+
size,
|
|
76
|
+
...rest
|
|
77
|
+
} = _ref2;
|
|
78
|
+
const prefix = usePrefix.usePrefix();
|
|
79
|
+
const classes = cx__default["default"](className, Object.entries({
|
|
80
|
+
size,
|
|
81
|
+
density
|
|
82
|
+
}).map(_ref3 => {
|
|
83
|
+
let [group, constraints] = _ref3;
|
|
84
|
+
return {
|
|
85
|
+
[`${prefix}--layout-constraint--${group}:default-${constraints?.default}`]: constraints?.default,
|
|
86
|
+
[`${prefix}--layout-constraint--${group}:min-${constraints?.min}`]: constraints?.min,
|
|
87
|
+
[`${prefix}--layout-constraint--${group}:max-${constraints?.max}`]: constraints?.max
|
|
88
|
+
};
|
|
89
|
+
}));
|
|
90
|
+
return /*#__PURE__*/React__default["default"].createElement(BaseComponent, _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
91
|
+
ref: forwardRef,
|
|
92
|
+
className: classes
|
|
93
|
+
}), children);
|
|
94
|
+
});
|
|
95
|
+
LayoutConstraint.propTypes = {
|
|
96
|
+
/**
|
|
97
|
+
* Specify a custom component or element to be rendered as the top-level
|
|
98
|
+
* element in the component
|
|
99
|
+
*/
|
|
100
|
+
as: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].string, PropTypes__default["default"].elementType]),
|
|
101
|
+
/**
|
|
102
|
+
* Provide child elements to be rendered inside of `LayoutConstraint`
|
|
103
|
+
*/
|
|
104
|
+
children: PropTypes__default["default"].node,
|
|
105
|
+
/**
|
|
106
|
+
* Provide a custom class name to be used on the outermost element rendered by
|
|
107
|
+
* the component
|
|
108
|
+
*/
|
|
109
|
+
className: PropTypes__default["default"].string,
|
|
110
|
+
/**
|
|
111
|
+
* Specify the desired layout density constraints of this element's children
|
|
112
|
+
*/
|
|
113
|
+
density: PropTypes__default["default"].shape({
|
|
114
|
+
min: PropTypes__default["default"].oneOf(densities),
|
|
115
|
+
default: PropTypes__default["default"].oneOf(densities),
|
|
116
|
+
max: PropTypes__default["default"].oneOf(densities)
|
|
117
|
+
}),
|
|
118
|
+
/**
|
|
119
|
+
* Specify the desired layout size constraints of this element's children
|
|
120
|
+
*/
|
|
121
|
+
size: PropTypes__default["default"].shape({
|
|
122
|
+
min: PropTypes__default["default"].oneOf(sizes),
|
|
123
|
+
default: PropTypes__default["default"].oneOf(sizes),
|
|
124
|
+
max: PropTypes__default["default"].oneOf(sizes)
|
|
125
|
+
})
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
exports.Layout = Layout;
|
|
129
|
+
exports.LayoutConstraint = LayoutConstraint;
|
|
@@ -0,0 +1,53 @@
|
|
|
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, { AriaAttributes, ComponentType, HTMLAttributeAnchorTarget } from 'react';
|
|
8
|
+
interface LinkProps {
|
|
9
|
+
/**
|
|
10
|
+
* @description Indicates the element that represents the
|
|
11
|
+
* current item within a container or set of related
|
|
12
|
+
* elements.
|
|
13
|
+
*/
|
|
14
|
+
'aria-current'?: AriaAttributes['aria-current'];
|
|
15
|
+
/**
|
|
16
|
+
* @description Provide a custom className to be applied to
|
|
17
|
+
* the containing `<a>` node.
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @description Specify if the control should be disabled, or not.
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @description Provide the `href` attribute for the `<a>` node.
|
|
26
|
+
*/
|
|
27
|
+
href?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description Specify whether you want the inline version of this control.
|
|
30
|
+
*/
|
|
31
|
+
inline?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @description Optional prop to render an icon next to the link.
|
|
34
|
+
* Can be a React component class
|
|
35
|
+
*/
|
|
36
|
+
renderIcon?: ComponentType;
|
|
37
|
+
/**
|
|
38
|
+
* Specify the size of the Link. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
|
|
39
|
+
*/
|
|
40
|
+
size?: 'sm' | 'md' | 'lg';
|
|
41
|
+
/**
|
|
42
|
+
* @description Specify the target attribute for the `<a>` node.
|
|
43
|
+
*/
|
|
44
|
+
target?: HTMLAttributeAnchorTarget;
|
|
45
|
+
/**
|
|
46
|
+
* Specify whether you want the link to receive visited styles after the link has been clicked
|
|
47
|
+
*/
|
|
48
|
+
visited?: boolean;
|
|
49
|
+
}
|
|
50
|
+
declare const Link: React.ForwardRefExoticComponent<LinkProps & {
|
|
51
|
+
children?: React.ReactNode;
|
|
52
|
+
} & React.RefAttributes<HTMLAnchorElement>>;
|
|
53
|
+
export default Link;
|
|
@@ -31,6 +31,7 @@ const Link = /*#__PURE__*/React__default["default"].forwardRef(function Link(_re
|
|
|
31
31
|
visited = false,
|
|
32
32
|
renderIcon: Icon,
|
|
33
33
|
size,
|
|
34
|
+
target,
|
|
34
35
|
...rest
|
|
35
36
|
} = _ref;
|
|
36
37
|
const prefix = usePrefix.usePrefix();
|
|
@@ -40,7 +41,7 @@ const Link = /*#__PURE__*/React__default["default"].forwardRef(function Link(_re
|
|
|
40
41
|
[`${prefix}--link--visited`]: visited,
|
|
41
42
|
[`${prefix}--link--${size}`]: size
|
|
42
43
|
});
|
|
43
|
-
const rel =
|
|
44
|
+
const rel = target === '_blank' ? 'noopener' : undefined;
|
|
44
45
|
const linkProps = {
|
|
45
46
|
className,
|
|
46
47
|
rel
|
|
@@ -86,6 +87,7 @@ Link.propTypes = {
|
|
|
86
87
|
* Optional prop to render an icon next to the link.
|
|
87
88
|
* Can be a React component class
|
|
88
89
|
*/
|
|
90
|
+
// @ts-expect-error - PropTypes are unable to cover this case.
|
|
89
91
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
90
92
|
/**
|
|
91
93
|
* Specify the size of the Link. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
|
|
@@ -96,6 +98,5 @@ Link.propTypes = {
|
|
|
96
98
|
*/
|
|
97
99
|
visited: PropTypes__default["default"].bool
|
|
98
100
|
};
|
|
99
|
-
var Link$1 = Link;
|
|
100
101
|
|
|
101
|
-
exports["default"] = Link
|
|
102
|
+
exports["default"] = Link;
|
|
@@ -10,5 +10,5 @@ declare const listBoxSizes: readonly ["sm", "md", "lg"];
|
|
|
10
10
|
export type ListBoxType = (typeof listBoxTypes)[number];
|
|
11
11
|
export type ListBoxSize = (typeof listBoxSizes)[number];
|
|
12
12
|
export declare const ListBoxType: PropTypes.Requireable<"default" | "inline">;
|
|
13
|
-
export declare const ListBoxSize: PropTypes.Requireable<"
|
|
13
|
+
export declare const ListBoxSize: PropTypes.Requireable<"sm" | "md" | "lg">;
|
|
14
14
|
export {};
|
|
@@ -290,12 +290,13 @@ MenuItemGroup.propTypes = {
|
|
|
290
290
|
*/
|
|
291
291
|
label: PropTypes__default["default"].string.isRequired
|
|
292
292
|
};
|
|
293
|
+
const defaultItemToString = item => item.toString();
|
|
293
294
|
const MenuItemRadioGroup = /*#__PURE__*/React__default["default"].forwardRef(function MenuItemRadioGroup(_ref4, forwardRef) {
|
|
294
295
|
let {
|
|
295
296
|
className,
|
|
296
297
|
defaultSelectedItem,
|
|
297
298
|
items,
|
|
298
|
-
itemToString =
|
|
299
|
+
itemToString = defaultItemToString,
|
|
299
300
|
label,
|
|
300
301
|
onChange,
|
|
301
302
|
selectedItem,
|
|
@@ -68,10 +68,13 @@ const MenuButton = /*#__PURE__*/React__default["default"].forwardRef(function Me
|
|
|
68
68
|
}
|
|
69
69
|
const triggerClasses = cx__default["default"](`${prefix}--menu-button__trigger`, {
|
|
70
70
|
[`${prefix}--menu-button__trigger--open`]: open
|
|
71
|
-
}
|
|
71
|
+
});
|
|
72
72
|
const buttonKind = validButtonKinds.includes(kind) ? kind : defaultButtonKind;
|
|
73
|
-
return /*#__PURE__*/React__default["default"].createElement(
|
|
73
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
74
74
|
ref: ref,
|
|
75
|
+
"aria-owns": open ? id : null,
|
|
76
|
+
className: className
|
|
77
|
+
}), /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
75
78
|
className: triggerClasses,
|
|
76
79
|
size: size,
|
|
77
80
|
kind: buttonKind,
|
|
@@ -81,8 +84,8 @@ const MenuButton = /*#__PURE__*/React__default["default"].forwardRef(function Me
|
|
|
81
84
|
"aria-expanded": open,
|
|
82
85
|
onClick: handleClick,
|
|
83
86
|
onMouseDown: handleMousedown,
|
|
84
|
-
"aria-
|
|
85
|
-
}
|
|
87
|
+
"aria-controls": open ? id : null
|
|
88
|
+
}, label), /*#__PURE__*/React__default["default"].createElement(Menu.Menu, {
|
|
86
89
|
ref: menuRef,
|
|
87
90
|
id: id,
|
|
88
91
|
label: label,
|
|
@@ -9,10 +9,22 @@
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var index = require('../FeatureFlags/index.js');
|
|
14
|
+
var index$1 = require('./next/index.js');
|
|
12
15
|
var OverflowMenu$1 = require('./OverflowMenu.js');
|
|
13
16
|
var createClassWrapper = require('../../internal/createClassWrapper.js');
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
+
|
|
22
|
+
const OverflowMenuV11 = createClassWrapper.createClassWrapper(OverflowMenu$1.OverflowMenu);
|
|
23
|
+
function OverflowMenu(props) {
|
|
24
|
+
const enableV12OverflowMenu = index.useFeatureFlag('enable-v12-overflowmenu');
|
|
25
|
+
return enableV12OverflowMenu ? /*#__PURE__*/React__default["default"].createElement(index$1.OverflowMenu, props) : /*#__PURE__*/React__default["default"].createElement(OverflowMenuV11, props);
|
|
26
|
+
}
|
|
27
|
+
OverflowMenu.displayName = 'OverflowMenu';
|
|
16
28
|
|
|
17
29
|
exports.OverflowMenu = OverflowMenu;
|
|
18
30
|
exports["default"] = OverflowMenu;
|
|
@@ -0,0 +1,108 @@
|
|
|
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 index = require('../../IconButton/index.js');
|
|
18
|
+
var Menu = require('../../Menu/Menu.js');
|
|
19
|
+
var useId = require('../../../internal/useId.js');
|
|
20
|
+
var usePrefix = require('../../../internal/usePrefix.js');
|
|
21
|
+
var useAttachedMenu = require('../../../internal/useAttachedMenu.js');
|
|
22
|
+
|
|
23
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
+
|
|
25
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
26
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
27
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
28
|
+
|
|
29
|
+
const defaultSize = 'md';
|
|
30
|
+
const OverflowMenu = /*#__PURE__*/React__default["default"].forwardRef(function OverflowMenu(_ref, forwardRef) {
|
|
31
|
+
let {
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
label = 'Options',
|
|
35
|
+
renderIcon: IconElement = iconsReact.OverflowMenuVertical,
|
|
36
|
+
size = defaultSize,
|
|
37
|
+
tooltipAlignment,
|
|
38
|
+
...rest
|
|
39
|
+
} = _ref;
|
|
40
|
+
const id = useId.useId('overflowmenu');
|
|
41
|
+
const prefix = usePrefix.usePrefix();
|
|
42
|
+
const triggerRef = React.useRef(null);
|
|
43
|
+
const {
|
|
44
|
+
open,
|
|
45
|
+
x,
|
|
46
|
+
y,
|
|
47
|
+
handleClick,
|
|
48
|
+
handleMousedown,
|
|
49
|
+
handleClose
|
|
50
|
+
} = useAttachedMenu.useAttachedMenu(triggerRef);
|
|
51
|
+
const containerClasses = cx__default["default"](className, `${prefix}--overflow-menu__container`);
|
|
52
|
+
const triggerClasses = cx__default["default"](`${prefix}--overflow-menu`, {
|
|
53
|
+
[`${prefix}--overflow-menu--open`]: open
|
|
54
|
+
}, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
|
|
55
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
56
|
+
className: containerClasses,
|
|
57
|
+
"aria-owns": open ? id : null,
|
|
58
|
+
ref: forwardRef
|
|
59
|
+
}), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
|
|
60
|
+
"aria-controls": open ? id : null,
|
|
61
|
+
"aria-haspopup": true,
|
|
62
|
+
"aria-expanded": open,
|
|
63
|
+
className: triggerClasses,
|
|
64
|
+
onClick: handleClick,
|
|
65
|
+
onMouseDown: handleMousedown,
|
|
66
|
+
ref: triggerRef,
|
|
67
|
+
label: label,
|
|
68
|
+
align: tooltipAlignment
|
|
69
|
+
}, /*#__PURE__*/React__default["default"].createElement(IconElement, {
|
|
70
|
+
className: `${prefix}--overflow-menu__icon`
|
|
71
|
+
})), /*#__PURE__*/React__default["default"].createElement(Menu.Menu, {
|
|
72
|
+
id: id,
|
|
73
|
+
size: size,
|
|
74
|
+
open: open,
|
|
75
|
+
onClose: handleClose,
|
|
76
|
+
x: x,
|
|
77
|
+
y: y,
|
|
78
|
+
label: label
|
|
79
|
+
}, children));
|
|
80
|
+
});
|
|
81
|
+
OverflowMenu.propTypes = {
|
|
82
|
+
/**
|
|
83
|
+
* A collection of MenuItems to be rendered within this OverflowMenu.
|
|
84
|
+
*/
|
|
85
|
+
children: PropTypes__default["default"].node,
|
|
86
|
+
/**
|
|
87
|
+
* Additional CSS class names for the trigger button.
|
|
88
|
+
*/
|
|
89
|
+
className: PropTypes__default["default"].string,
|
|
90
|
+
/**
|
|
91
|
+
* A label describing the options available. Is used in the trigger tooltip and as the menu's accessible label.
|
|
92
|
+
*/
|
|
93
|
+
label: PropTypes__default["default"].string,
|
|
94
|
+
/**
|
|
95
|
+
* Otionally provide a custom icon to be rendered on the trigger button.
|
|
96
|
+
*/
|
|
97
|
+
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
98
|
+
/**
|
|
99
|
+
* Specify the size of the menu, from a list of available sizes.
|
|
100
|
+
*/
|
|
101
|
+
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
|
|
102
|
+
/**
|
|
103
|
+
* Specify how the trigger tooltip should be aligned.
|
|
104
|
+
*/
|
|
105
|
+
tooltipAlignment: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right'])
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
exports.OverflowMenu = OverflowMenu;
|