@carbon/react 1.25.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/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/TableToolbarContent.d.ts +4 -6
- package/es/components/DataTable/TableToolbarSearch.js +1 -0
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -0
- package/es/components/FileUploader/FileUploaderButton.js +2 -0
- package/es/components/InlineCheckbox/InlineCheckbox.js +7 -53
- package/es/components/MultiSelect/FilterableMultiSelect.js +15 -7
- package/es/components/MultiSelect/MultiSelect.js +0 -2
- package/es/components/NumberInput/NumberInput.js +9 -1
- 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 +84 -25
- 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/StructuredList/StructuredList.js +1 -1
- package/es/components/Tabs/Tabs.js +26 -5
- 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/UIShell/HeaderMenu.js +13 -4
- package/es/components/UIShell/HeaderMenuItem.js +17 -4
- package/es/tools/wrapComponent.js +9 -0
- package/lib/components/Button/Button.js +2 -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/TableToolbarContent.d.ts +4 -6
- package/lib/components/DataTable/TableToolbarSearch.js +1 -0
- package/lib/components/ExpandableSearch/ExpandableSearch.js +1 -0
- package/lib/components/FileUploader/FileUploaderButton.js +2 -0
- package/lib/components/InlineCheckbox/InlineCheckbox.js +7 -53
- package/lib/components/MultiSelect/FilterableMultiSelect.js +14 -6
- package/lib/components/MultiSelect/MultiSelect.js +0 -2
- package/lib/components/NumberInput/NumberInput.js +9 -1
- 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 +83 -24
- 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/StructuredList/StructuredList.js +1 -1
- package/lib/components/Tabs/Tabs.js +26 -5
- 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/UIShell/HeaderMenu.js +13 -4
- package/lib/components/UIShell/HeaderMenuItem.js +17 -4
- package/lib/tools/wrapComponent.js +9 -0
- package/package.json +3 -3
|
@@ -22,7 +22,7 @@ import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
|
22
22
|
var _CheckboxCheckedFille, _Checkbox, _ChevronDown, _ChevronDown2;
|
|
23
23
|
|
|
24
24
|
var _excluded = ["children", "className", "light"],
|
|
25
|
-
_excluded2 = ["children", "className", "clicked", "href", "light", "onClick", "onKeyDown"],
|
|
25
|
+
_excluded2 = ["children", "className", "clicked", "disabled", "href", "light", "onClick", "onKeyDown"],
|
|
26
26
|
_excluded3 = ["children", "className", "disabled", "id", "light", "name", "onClick", "onChange", "onKeyDown", "selected", "tabIndex", "title", "value"],
|
|
27
27
|
_excluded4 = ["tabIndex", "className", "children", "expanded", "tileMaxHeight", "tilePadding", "onClick", "onKeyUp", "tileCollapsedIconText", "tileExpandedIconText", "tileCollapsedLabel", "tileExpandedLabel", "light"];
|
|
28
28
|
var Tile = /*#__PURE__*/React__default.forwardRef(function Tile(_ref, ref) {
|
|
@@ -64,6 +64,7 @@ var ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableTil
|
|
|
64
64
|
className = _ref2.className,
|
|
65
65
|
_ref2$clicked = _ref2.clicked,
|
|
66
66
|
clicked = _ref2$clicked === void 0 ? false : _ref2$clicked,
|
|
67
|
+
disabled = _ref2.disabled,
|
|
67
68
|
href = _ref2.href,
|
|
68
69
|
light = _ref2.light,
|
|
69
70
|
_ref2$onClick = _ref2.onClick,
|
|
@@ -101,9 +102,10 @@ var ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableTil
|
|
|
101
102
|
return /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
102
103
|
className: classes,
|
|
103
104
|
href: href,
|
|
104
|
-
onClick: handleOnClick,
|
|
105
|
+
onClick: !disabled ? handleOnClick : null,
|
|
105
106
|
onKeyDown: handleOnKeyDown,
|
|
106
|
-
ref: ref
|
|
107
|
+
ref: ref,
|
|
108
|
+
disabled: disabled
|
|
107
109
|
}, rest), children);
|
|
108
110
|
});
|
|
109
111
|
ClickableTile.displayName = 'ClickableTile';
|
|
@@ -123,6 +125,11 @@ ClickableTile.propTypes = {
|
|
|
123
125
|
*/
|
|
124
126
|
clicked: PropTypes.bool,
|
|
125
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Specify whether the ClickableTile should be disabled
|
|
130
|
+
*/
|
|
131
|
+
disabled: PropTypes.bool,
|
|
132
|
+
|
|
126
133
|
/**
|
|
127
134
|
* The href for the link.
|
|
128
135
|
*/
|
|
@@ -359,7 +366,7 @@ function ExpandableTile(_ref4) {
|
|
|
359
366
|
isExpanded = _useState18[0],
|
|
360
367
|
setIsExpanded = _useState18[1];
|
|
361
368
|
|
|
362
|
-
var _useState19 = useState(
|
|
369
|
+
var _useState19 = useState(true),
|
|
363
370
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
364
371
|
interactive = _useState20[0],
|
|
365
372
|
setInteractive = _useState20[1];
|
|
@@ -429,11 +436,11 @@ function ExpandableTile(_ref4) {
|
|
|
429
436
|
setIsTilePadding(paddingTop + paddingBottom);
|
|
430
437
|
}, [isTileMaxHeight]);
|
|
431
438
|
useIsomorphicEffect(function () {
|
|
432
|
-
if (getInteractiveContent(belowTheFold.current)) {
|
|
433
|
-
setInteractive(
|
|
439
|
+
if (!getInteractiveContent(belowTheFold.current)) {
|
|
440
|
+
setInteractive(false);
|
|
434
441
|
return;
|
|
435
|
-
} else if (getInteractiveContent(aboveTheFold.current)) {
|
|
436
|
-
setInteractive(
|
|
442
|
+
} else if (!getInteractiveContent(aboveTheFold.current)) {
|
|
443
|
+
setInteractive(false);
|
|
437
444
|
}
|
|
438
445
|
}, []);
|
|
439
446
|
useIsomorphicEffect(function () {
|
|
@@ -12,10 +12,11 @@ import React__default from 'react';
|
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
13
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
14
14
|
import { PrefixContext } from '../../internal/usePrefix.js';
|
|
15
|
+
import deprecate from '../../prop-types/deprecate.js';
|
|
15
16
|
import { matches } from '../../internal/keyboard/match.js';
|
|
16
17
|
import { Enter, Space, Escape } from '../../internal/keyboard/keys.js';
|
|
17
18
|
|
|
18
|
-
var _excluded = ["isCurrentPage", "aria-label", "aria-labelledby", "className", "children", "renderMenuContent", "menuLinkName", "focusRef"];
|
|
19
|
+
var _excluded = ["isActive", "isCurrentPage", "aria-label", "aria-labelledby", "className", "children", "renderMenuContent", "menuLinkName", "focusRef"];
|
|
19
20
|
/**
|
|
20
21
|
* `HeaderMenu` is used to render submenu's in the `Header`. Most often children
|
|
21
22
|
* will be a `HeaderMenuItem`. It handles certain keyboard events to help
|
|
@@ -149,6 +150,7 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
149
150
|
var prefix = this.context;
|
|
150
151
|
|
|
151
152
|
var _this$props = this.props,
|
|
153
|
+
isActive = _this$props.isActive,
|
|
152
154
|
isCurrentPage = _this$props.isCurrentPage,
|
|
153
155
|
ariaLabel = _this$props['aria-label'],
|
|
154
156
|
ariaLabelledBy = _this$props['aria-labelledby'],
|
|
@@ -164,7 +166,8 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
164
166
|
'aria-labelledby': ariaLabelledBy
|
|
165
167
|
};
|
|
166
168
|
var itemClassName = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__submenu"), true), _defineProperty(_cx, customClassName, !!customClassName), _cx));
|
|
167
|
-
var
|
|
169
|
+
var isActivePage = isActive ? isActive : isCurrentPage;
|
|
170
|
+
var linkClassName = cx((_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--header__menu-item"), true), _defineProperty(_cx2, "".concat(prefix, "--header__menu-title"), true), _defineProperty(_cx2, "".concat(prefix, "--header__menu-item--current"), isActivePage), _cx2)); // Notes on eslint comments and based on the examples in:
|
|
168
171
|
// https://www.w3.org/TR/wai-aria-practices/examples/menubar/menubar-1/menubar-1.html#
|
|
169
172
|
// - The focus is handled by the <a> menuitem, onMouseOver is for mouse
|
|
170
173
|
// users
|
|
@@ -218,9 +221,15 @@ _defineProperty(HeaderMenu, "propTypes", _objectSpread2(_objectSpread2({}, AriaL
|
|
|
218
221
|
focusRef: PropTypes.func,
|
|
219
222
|
|
|
220
223
|
/**
|
|
221
|
-
* Applies selected styles to the item if a user sets this to true and aria-current !== 'page'
|
|
224
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
222
225
|
*/
|
|
223
|
-
|
|
226
|
+
isActive: PropTypes.bool,
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
230
|
+
* @deprecated Please use `isActive` instead. This will be removed in the next major release.
|
|
231
|
+
*/
|
|
232
|
+
isCurrentPage: deprecate(PropTypes.bool, 'The `isCurrentPage` prop for `HeaderMenu` has ' + 'been deprecated. Please use `isActive` instead. This will be removed in the next major release.'),
|
|
224
233
|
|
|
225
234
|
/**
|
|
226
235
|
* Provide a label for the link text
|
|
@@ -11,12 +11,14 @@ import React__default from 'react';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import Link, { LinkPropTypes } from './Link.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import deprecate from '../../prop-types/deprecate.js';
|
|
14
15
|
|
|
15
|
-
var _excluded = ["className", "isCurrentPage", "aria-current", "children", "role", "tabIndex"];
|
|
16
|
+
var _excluded = ["className", "isActive", "isCurrentPage", "aria-current", "children", "role", "tabIndex"];
|
|
16
17
|
var HeaderMenuItem = /*#__PURE__*/React__default.forwardRef(function HeaderMenuItem(_ref, ref) {
|
|
17
18
|
var _cx;
|
|
18
19
|
|
|
19
20
|
var className = _ref.className,
|
|
21
|
+
isActive = _ref.isActive,
|
|
20
22
|
isCurrentPage = _ref.isCurrentPage,
|
|
21
23
|
ariaCurrent = _ref['aria-current'],
|
|
22
24
|
children = _ref.children,
|
|
@@ -26,7 +28,12 @@ var HeaderMenuItem = /*#__PURE__*/React__default.forwardRef(function HeaderMenuI
|
|
|
26
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
29
|
|
|
28
30
|
var prefix = usePrefix();
|
|
29
|
-
|
|
31
|
+
|
|
32
|
+
if (isCurrentPage) {
|
|
33
|
+
isActive = isCurrentPage;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var linkClassName = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__menu-item"), true), _defineProperty(_cx, "".concat(prefix, "--header__menu-item--current"), isActive && ariaCurrent !== 'page'), _cx));
|
|
30
37
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
31
38
|
className: className,
|
|
32
39
|
role: role
|
|
@@ -53,9 +60,15 @@ HeaderMenuItem.propTypes = _objectSpread2(_objectSpread2({}, LinkPropTypes), {},
|
|
|
53
60
|
className: PropTypes.string,
|
|
54
61
|
|
|
55
62
|
/**
|
|
56
|
-
* Applies selected styles to the item if a user sets this to true and aria-current !== 'page'
|
|
63
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
64
|
+
*/
|
|
65
|
+
isActive: PropTypes.bool,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
69
|
+
* @deprecated Please use `isActive` instead. This will be removed in the next major release.
|
|
57
70
|
*/
|
|
58
|
-
isCurrentPage: PropTypes.bool,
|
|
71
|
+
isCurrentPage: deprecate(PropTypes.bool, 'The `isCurrentPage` prop for `HeaderMenuItem` has ' + 'been deprecated. Please use `isActive` instead. This will be removed in the next major release.'),
|
|
59
72
|
|
|
60
73
|
/**
|
|
61
74
|
* Optionally supply a role for the underlying `<li>` node. Useful for resetting
|
|
@@ -12,12 +12,21 @@ import cx from 'classnames';
|
|
|
12
12
|
import { usePrefix } from '../internal/usePrefix.js';
|
|
13
13
|
|
|
14
14
|
var _excluded = ["className"];
|
|
15
|
+
/**
|
|
16
|
+
* @param {{ name: string, type: string, className?: string | (prefix: string) => string }} props
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
15
19
|
|
|
16
20
|
var wrapComponent = function wrapComponent(_ref) {
|
|
17
21
|
var name = _ref.name,
|
|
18
22
|
getClassName = _ref.className,
|
|
19
23
|
type = _ref.type;
|
|
20
24
|
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {{ className?: string, [x: string]: any}} param0
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
21
30
|
function Component(_ref2) {
|
|
22
31
|
var baseClassName = _ref2.className,
|
|
23
32
|
other = _objectWithoutProperties(_ref2, _excluded);
|
|
@@ -27,7 +27,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
27
27
|
|
|
28
28
|
var _excluded = ["as", "children", "className", "dangerDescription", "disabled", "hasIconOnly", "href", "iconDescription", "isExpressive", "isSelected", "kind", "onBlur", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "renderIcon", "size", "tabIndex", "tooltipAlignment", "tooltipPosition", "type"];
|
|
29
29
|
var Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_ref, ref) {
|
|
30
|
-
var _classNames;
|
|
30
|
+
var _classNames, _rest$ariaPressed;
|
|
31
31
|
|
|
32
32
|
var as = _ref.as,
|
|
33
33
|
children = _ref.children,
|
|
@@ -92,7 +92,7 @@ var Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_
|
|
|
92
92
|
disabled: disabled,
|
|
93
93
|
type: type,
|
|
94
94
|
'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : null,
|
|
95
|
-
'aria-pressed': hasIconOnly && kind === 'ghost' ? isSelected : null
|
|
95
|
+
'aria-pressed': (_rest$ariaPressed = rest['aria-pressed']) !== null && _rest$ariaPressed !== void 0 ? _rest$ariaPressed : hasIconOnly && kind === 'ghost' ? isSelected : null
|
|
96
96
|
};
|
|
97
97
|
var anchorProps = {
|
|
98
98
|
href: href
|
|
@@ -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;
|
|
@@ -30,10 +30,12 @@ var Table = function Table(_ref) {
|
|
|
30
30
|
children = _ref.children,
|
|
31
31
|
useZebraStyles = _ref.useZebraStyles,
|
|
32
32
|
size = _ref.size,
|
|
33
|
-
isSortable = _ref.isSortable,
|
|
33
|
+
_ref$isSortable = _ref.isSortable,
|
|
34
|
+
isSortable = _ref$isSortable === void 0 ? false : _ref$isSortable,
|
|
34
35
|
useStaticWidth = _ref.useStaticWidth,
|
|
35
36
|
stickyHeader = _ref.stickyHeader,
|
|
36
|
-
|
|
37
|
+
_ref$overflowMenuOnHo = _ref.overflowMenuOnHover,
|
|
38
|
+
overflowMenuOnHover = _ref$overflowMenuOnHo === void 0 ? true : _ref$overflowMenuOnHo,
|
|
37
39
|
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
38
40
|
|
|
39
41
|
var _useContext = React.useContext(TableContext.TableContext),
|
|
@@ -0,0 +1,10 @@
|
|
|
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 { TdHTMLAttributes } from 'react';
|
|
8
|
+
export type TableCellProps = TdHTMLAttributes<HTMLTableCellElement>;
|
|
9
|
+
declare const TableCell: React.FC<TableCellProps>;
|
|
10
|
+
export default TableCell;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
8
|
+
interface TableContextType {
|
|
9
|
+
titleId?: string;
|
|
10
|
+
descriptionId?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const TableContext: import("react").Context<TableContextType>;
|
|
13
|
+
export {};
|
|
@@ -12,8 +12,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
12
|
var React = require('react');
|
|
13
13
|
|
|
14
14
|
var TableContext = /*#__PURE__*/React.createContext({
|
|
15
|
-
titleId:
|
|
16
|
-
descriptionId:
|
|
15
|
+
titleId: undefined,
|
|
16
|
+
descriptionId: undefined
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
exports.TableContext = TableContext;
|
|
@@ -0,0 +1,67 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
8
|
+
import { MouseEventHandler, PropsWithChildren } from 'react';
|
|
9
|
+
import { TableRowProps } from './TableRow';
|
|
10
|
+
interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
|
|
11
|
+
/**
|
|
12
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
13
|
+
* focused
|
|
14
|
+
*/
|
|
15
|
+
ariaLabel: string;
|
|
16
|
+
/**
|
|
17
|
+
* The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
|
|
18
|
+
*/
|
|
19
|
+
expandHeader?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The description of the chevron right icon, to be put in its SVG `<title>` element.
|
|
22
|
+
*/
|
|
23
|
+
expandIconDescription?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Specify whether this row is expanded or not. This helps coordinate data
|
|
26
|
+
* attributes so that `TableExpandRow` and `TableExpandedRow` work together
|
|
27
|
+
*/
|
|
28
|
+
isExpanded: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Hook for when a listener initiates a request to expand the given row
|
|
31
|
+
*/
|
|
32
|
+
onExpand: MouseEventHandler<HTMLButtonElement>;
|
|
33
|
+
}
|
|
34
|
+
declare const TableExpandRow: {
|
|
35
|
+
({ ariaLabel, className: rowClassName, children, isExpanded, onExpand, expandIconDescription, isSelected, expandHeader, ...rest }: TableExpandRowProps): JSX.Element;
|
|
36
|
+
propTypes: {
|
|
37
|
+
/**
|
|
38
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
39
|
+
* focused
|
|
40
|
+
*/
|
|
41
|
+
ariaLabel: PropTypes.Validator<string>;
|
|
42
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
43
|
+
className: PropTypes.Requireable<string>;
|
|
44
|
+
/**
|
|
45
|
+
* The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
|
|
46
|
+
*/
|
|
47
|
+
expandHeader: PropTypes.Requireable<string>;
|
|
48
|
+
/**
|
|
49
|
+
* The description of the chevron right icon, to be put in its SVG `<title>` element.
|
|
50
|
+
*/
|
|
51
|
+
expandIconDescription: PropTypes.Requireable<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Specify whether this row is expanded or not. This helps coordinate data
|
|
54
|
+
* attributes so that `TableExpandRow` and `TableExpandedRow` work together
|
|
55
|
+
*/
|
|
56
|
+
isExpanded: PropTypes.Validator<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Specify if the row is selected
|
|
59
|
+
*/
|
|
60
|
+
isSelected: PropTypes.Requireable<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Hook for when a listener initiates a request to expand the given row
|
|
63
|
+
*/
|
|
64
|
+
onExpand: PropTypes.Validator<(...args: any[]) => any>;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export default TableExpandRow;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
8
|
+
import { ReactAttr } from '../../types/common';
|
|
9
|
+
interface TableExpandedRowProps extends ReactAttr<HTMLTableRowElement> {
|
|
10
|
+
/**
|
|
11
|
+
* The width of the expanded row's internal cell
|
|
12
|
+
*/
|
|
13
|
+
colSpan: number;
|
|
14
|
+
}
|
|
15
|
+
declare const TableExpandedRow: {
|
|
16
|
+
({ className: customClassName, children, colSpan, ...rest }: TableExpandedRowProps): JSX.Element;
|
|
17
|
+
propTypes: {
|
|
18
|
+
/**
|
|
19
|
+
* Pass in the contents for your TableExpandedRow
|
|
20
|
+
*/
|
|
21
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
22
|
+
/**
|
|
23
|
+
* Specify an optional className to be applied to the container node
|
|
24
|
+
*/
|
|
25
|
+
className: PropTypes.Requireable<string>;
|
|
26
|
+
/**
|
|
27
|
+
* The width of the expanded row's internal cell
|
|
28
|
+
*/
|
|
29
|
+
colSpan: PropTypes.Validator<number>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default TableExpandedRow;
|
|
@@ -0,0 +1,10 @@
|
|
|
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, { ThHTMLAttributes } from 'react';
|
|
8
|
+
export type TableHeadProps = ThHTMLAttributes<HTMLTableSectionElement>;
|
|
9
|
+
declare const TableHead: React.FC<TableHeadProps>;
|
|
10
|
+
export default TableHead;
|
|
@@ -0,0 +1,64 @@
|
|
|
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, { MouseEventHandler } from 'react';
|
|
8
|
+
import { ReactAttr } from '../../types/common';
|
|
9
|
+
interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Pass in children that will be embedded in the table header label
|
|
12
|
+
*/
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Specify an optional className to be applied to the container node
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Specify `colSpan` as a non-negative integer value to indicate how
|
|
20
|
+
* many columns the TableHeader cell extends in a table
|
|
21
|
+
*/
|
|
22
|
+
colSpan?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Supply an id to the th element.
|
|
25
|
+
*/
|
|
26
|
+
id?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Specify whether this header is the header by which a table is being sorted
|
|
29
|
+
* by
|
|
30
|
+
*/
|
|
31
|
+
isSortHeader?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Specify whether this header is one through which a user can sort the table
|
|
34
|
+
*/
|
|
35
|
+
isSortable?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Hook that is invoked when the header is clicked
|
|
38
|
+
*/
|
|
39
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
40
|
+
/**
|
|
41
|
+
* Specify the scope of this table header. You can find more info about this
|
|
42
|
+
* attribute at the following URL:
|
|
43
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope
|
|
44
|
+
*/
|
|
45
|
+
scope: string;
|
|
46
|
+
/**
|
|
47
|
+
* Specify which direction we are currently sorting by, should be one of DESC,
|
|
48
|
+
* NONE, or ASC.
|
|
49
|
+
*/
|
|
50
|
+
sortDirection?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Supply a method to translate internal strings with your i18n tool of
|
|
53
|
+
* choice. Translation keys are available on the `translationKeys` field for
|
|
54
|
+
* this component.
|
|
55
|
+
*/
|
|
56
|
+
translateWithId?: (key: string, { header, sortDirection, isSortHeader, sortStates }: {
|
|
57
|
+
header: any;
|
|
58
|
+
sortDirection: any;
|
|
59
|
+
isSortHeader: any;
|
|
60
|
+
sortStates: any;
|
|
61
|
+
}) => string;
|
|
62
|
+
}
|
|
63
|
+
declare const TableHeader: React.ForwardRefExoticComponent<TableHeaderProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
64
|
+
export default TableHeader;
|
|
@@ -32,48 +32,43 @@ var translationKeys = {
|
|
|
32
32
|
buttonDescription: 'carbon.table.header.icon.description'
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
var translateWithId = function translateWithId(key,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
isSortHeader = _ref.isSortHeader,
|
|
39
|
-
sortStates = _ref.sortStates;
|
|
40
|
-
|
|
41
|
-
if (key === translationKeys.buttonDescription) {
|
|
42
|
-
if (isSortHeader) {
|
|
35
|
+
var translateWithId = function translateWithId(key, args) {
|
|
36
|
+
if (args && key === translationKeys.buttonDescription) {
|
|
37
|
+
if (args.isSortHeader && sortStates.sortStates) {
|
|
43
38
|
// When transitioning, we know that the sequence of states is as follows:
|
|
44
39
|
// NONE -> ASC -> DESC -> NONE
|
|
45
|
-
if (sortDirection === sortStates.NONE) {
|
|
46
|
-
return "Click to sort rows by ".concat(header, " header in ascending order");
|
|
40
|
+
if (args.sortDirection === sortStates.sortStates.NONE) {
|
|
41
|
+
return "Click to sort rows by ".concat(args.header, " header in ascending order");
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
if (sortDirection === sortStates.ASC) {
|
|
50
|
-
return "Click to sort rows by ".concat(header, " header in descending order");
|
|
44
|
+
if (args.sortDirection === sortStates.sortStates.ASC) {
|
|
45
|
+
return "Click to sort rows by ".concat(args.header, " header in descending order");
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
return "Click to unsort rows by ".concat(header, " header");
|
|
48
|
+
return "Click to unsort rows by ".concat(args.header, " header");
|
|
54
49
|
}
|
|
55
50
|
|
|
56
|
-
return "Click to sort rows by ".concat(header, " header in ascending order");
|
|
51
|
+
return "Click to sort rows by ".concat(args.header, " header in ascending order");
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
return '';
|
|
60
55
|
};
|
|
61
56
|
|
|
62
57
|
var sortDirections = (_sortDirections = {}, _rollupPluginBabelHelpers.defineProperty(_sortDirections, sortStates.sortStates.NONE, 'none'), _rollupPluginBabelHelpers.defineProperty(_sortDirections, sortStates.sortStates.ASC, 'ascending'), _rollupPluginBabelHelpers.defineProperty(_sortDirections, sortStates.sortStates.DESC, 'descending'), _sortDirections);
|
|
63
|
-
var TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function TableHeader(
|
|
58
|
+
var TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function TableHeader(_ref, ref) {
|
|
64
59
|
var _cx;
|
|
65
60
|
|
|
66
|
-
var headerClassName =
|
|
67
|
-
children =
|
|
68
|
-
colSpan =
|
|
69
|
-
isSortable =
|
|
70
|
-
isSortHeader =
|
|
71
|
-
onClick =
|
|
72
|
-
scope =
|
|
73
|
-
sortDirection =
|
|
74
|
-
t =
|
|
75
|
-
id =
|
|
76
|
-
rest = _rollupPluginBabelHelpers.objectWithoutProperties(
|
|
61
|
+
var headerClassName = _ref.className,
|
|
62
|
+
children = _ref.children,
|
|
63
|
+
colSpan = _ref.colSpan,
|
|
64
|
+
isSortable = _ref.isSortable,
|
|
65
|
+
isSortHeader = _ref.isSortHeader,
|
|
66
|
+
onClick = _ref.onClick,
|
|
67
|
+
scope = _ref.scope,
|
|
68
|
+
sortDirection = _ref.sortDirection,
|
|
69
|
+
t = _ref.translateWithId,
|
|
70
|
+
id = _ref.id,
|
|
71
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
77
72
|
|
|
78
73
|
var prefix = usePrefix.usePrefix();
|
|
79
74
|
var uniqueId = useId.useId('table-sort');
|
|
@@ -91,8 +86,8 @@ var TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function Tab
|
|
|
91
86
|
}
|
|
92
87
|
|
|
93
88
|
var className = cx__default["default"](headerClassName, (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--table-sort"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--table-sort--active"), isSortHeader && sortDirection !== sortStates.sortStates.NONE), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--table-sort--descending"), isSortHeader && sortDirection === sortStates.sortStates.DESC), _cx));
|
|
94
|
-
var ariaSort = !isSortHeader ? 'none' : sortDirections[sortDirection];
|
|
95
|
-
var sortDescription = t('carbon.table.header.icon.description', {
|
|
89
|
+
var ariaSort = !isSortHeader || !sortDirection ? 'none' : sortDirections[sortDirection];
|
|
90
|
+
var sortDescription = t && t('carbon.table.header.icon.description', {
|
|
96
91
|
header: children,
|
|
97
92
|
sortDirection: sortDirection,
|
|
98
93
|
isSortHeader: isSortHeader,
|
|
@@ -0,0 +1,32 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
8
|
+
import { ReactAttr } from '../../types/common';
|
|
9
|
+
export interface TableRowProps extends ReactAttr<HTMLTableRowElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Specify an optional className to be applied to the container node
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify if the row is selected
|
|
16
|
+
*/
|
|
17
|
+
isSelected?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const TableRow: {
|
|
20
|
+
(props: TableRowProps): JSX.Element;
|
|
21
|
+
propTypes: {
|
|
22
|
+
/**
|
|
23
|
+
* Specify an optional className to be applied to the container node
|
|
24
|
+
*/
|
|
25
|
+
className: PropTypes.Requireable<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Specify if the row is selected
|
|
28
|
+
*/
|
|
29
|
+
isSelected: PropTypes.Requireable<boolean>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default TableRow;
|
|
@@ -35,7 +35,7 @@ var TableSelectAll = function TableSelectAll(_ref) {
|
|
|
35
35
|
scope: "col",
|
|
36
36
|
className: cx__default["default"]("".concat(prefix, "--table-column-checkbox"), className)
|
|
37
37
|
}, /*#__PURE__*/React__default["default"].createElement(InlineCheckbox["default"], {
|
|
38
|
-
|
|
38
|
+
"aria-label": ariaLabel,
|
|
39
39
|
checked: checked,
|
|
40
40
|
id: id,
|
|
41
41
|
indeterminate: indeterminate,
|
|
@@ -49,9 +49,7 @@ var TableSelectRow = function TableSelectRow(_ref) {
|
|
|
49
49
|
}, /*#__PURE__*/React__default["default"].createElement(InlineInputComponent, _rollupPluginBabelHelpers["extends"]({}, selectionInputProps, radio && {
|
|
50
50
|
labelText: ariaLabel,
|
|
51
51
|
hideLabel: true
|
|
52
|
-
}, !radio && {
|
|
53
|
-
ariaLabel: ariaLabel
|
|
54
|
-
})));
|
|
52
|
+
}, !radio && _rollupPluginBabelHelpers.defineProperty({}, 'aria-label', ariaLabel))));
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
TableSelectRow.propTypes = {
|