@carbon/react 1.33.1 → 1.34.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.d.ts +1 -1
- package/es/components/ComposedModal/ComposedModal.js +13 -14
- package/es/components/DataTable/DataTable.d.ts +541 -0
- package/es/components/DataTable/DataTable.js +35 -14
- package/es/components/DataTable/index.d.ts +2 -2
- package/es/components/DataTable/state/sortStates.d.ts +13 -0
- package/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +17 -16
- package/es/components/ExpandableSearch/ExpandableSearch.d.ts +1 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +16 -8
- package/es/components/InlineCheckbox/InlineCheckbox.js +3 -2
- package/es/components/OverflowMenu/OverflowMenu.js +2 -2
- package/es/components/Search/Search.d.ts +2 -2
- package/es/components/Search/Search.js +25 -4
- package/es/components/Tabs/Tabs.js +2 -0
- package/es/components/Tag/Tag.js +9 -2
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/Toggle/Toggle.d.ts +8 -8
- package/es/components/UIShell/HeaderMenuButton.d.ts +57 -0
- package/es/components/UIShell/HeaderMenuButton.js +4 -0
- package/es/components/UIShell/HeaderNavigation.d.ts +56 -0
- package/es/components/UIShell/HeaderPanel.js +1 -1
- package/es/components/UIShell/Switcher.js +17 -6
- package/es/prop-types/isRequiredOneOf.js +2 -2
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +13 -14
- package/lib/components/DataTable/DataTable.d.ts +541 -0
- package/lib/components/DataTable/DataTable.js +39 -18
- package/lib/components/DataTable/index.d.ts +2 -2
- package/lib/components/DataTable/state/sortStates.d.ts +13 -0
- package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +17 -16
- package/lib/components/ExpandableSearch/ExpandableSearch.d.ts +1 -1
- package/lib/components/ExpandableSearch/ExpandableSearch.js +16 -8
- package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -2
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -2
- package/lib/components/Search/Search.d.ts +2 -2
- package/lib/components/Search/Search.js +24 -3
- package/lib/components/Tabs/Tabs.js +2 -0
- package/lib/components/Tag/Tag.js +9 -2
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/Toggle/Toggle.d.ts +8 -8
- package/lib/components/UIShell/HeaderMenuButton.d.ts +57 -0
- package/lib/components/UIShell/HeaderMenuButton.js +4 -0
- package/lib/components/UIShell/HeaderNavigation.d.ts +56 -0
- package/lib/components/UIShell/HeaderPanel.js +1 -1
- package/lib/components/UIShell/Switcher.js +17 -6
- package/lib/prop-types/isRequiredOneOf.js +2 -2
- package/package.json +6 -6
|
@@ -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
|
+
export type DataTableSortState = 'NONE' | 'DESC' | 'ASC';
|
|
8
|
+
/**
|
|
9
|
+
* We currently support the following sorting states for DataTable headers,
|
|
10
|
+
* namely: `NONE` for no sorting being applied, and then `DESC` and `ASC` for
|
|
11
|
+
* the corresponding direction of the sorting order.
|
|
12
|
+
*/
|
|
13
|
+
export declare const sortStates: Record<DataTableSortState, DataTableSortState>;
|
|
@@ -5,46 +5,47 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
|
|
8
|
+
import { TableHTMLAttributes } from 'react';
|
|
9
|
+
export interface DataTableSkeletonHeader {
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Optionally specify header label
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
header?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optionally specify header key
|
|
16
|
+
*/
|
|
17
|
+
key?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DataTableSkeletonProps extends TableHTMLAttributes<HTMLTableElement> {
|
|
13
20
|
/**
|
|
14
21
|
* Specify the number of columns that you want to render in the skeleton state
|
|
15
22
|
*/
|
|
16
|
-
columnCount
|
|
23
|
+
columnCount?: number;
|
|
17
24
|
/**
|
|
18
25
|
* Optionally specify whether you want the Skeleton to be rendered as a
|
|
19
26
|
* compact DataTable
|
|
20
27
|
*/
|
|
21
|
-
compact
|
|
28
|
+
compact?: boolean;
|
|
22
29
|
/**
|
|
23
30
|
* Optionally specify the displayed headers
|
|
24
31
|
*/
|
|
25
|
-
headers?: [
|
|
26
|
-
header: string;
|
|
27
|
-
key: string;
|
|
28
|
-
}] | {
|
|
29
|
-
header: string;
|
|
30
|
-
key: string;
|
|
31
|
-
};
|
|
32
|
+
headers?: DataTableSkeletonHeader[];
|
|
32
33
|
/**
|
|
33
34
|
* Specify the number of rows that you want to render in the skeleton state
|
|
34
35
|
*/
|
|
35
|
-
rowCount
|
|
36
|
+
rowCount?: number;
|
|
36
37
|
/**
|
|
37
38
|
* Specify if the table header should be rendered as part of the skeleton.
|
|
38
39
|
*/
|
|
39
|
-
showHeader
|
|
40
|
+
showHeader?: boolean;
|
|
40
41
|
/**
|
|
41
42
|
* Specify if the table toolbar should be rendered as part of the skeleton.
|
|
42
43
|
*/
|
|
43
|
-
showToolbar
|
|
44
|
+
showToolbar?: boolean;
|
|
44
45
|
/**
|
|
45
46
|
* Optionally specify whether you want the DataTable to be zebra striped
|
|
46
47
|
*/
|
|
47
|
-
zebra
|
|
48
|
+
zebra?: boolean;
|
|
48
49
|
}
|
|
49
50
|
declare const DataTableSkeleton: {
|
|
50
51
|
({ headers, rowCount, columnCount, zebra, compact, className, showHeader, showToolbar, ...rest }: {
|
|
@@ -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,
|
|
9
|
+
declare function ExpandableSearch({ onBlur, onChange, onExpand, onKeyDown, 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;
|
|
@@ -16,6 +16,8 @@ var Search = require('../Search/Search.js');
|
|
|
16
16
|
require('../Search/Search.Skeleton.js');
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
18
|
var events = require('../../tools/events.js');
|
|
19
|
+
var match = require('../../internal/keyboard/match.js');
|
|
20
|
+
var keys = require('../../internal/keyboard/keys.js');
|
|
19
21
|
|
|
20
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
23
|
|
|
@@ -27,7 +29,7 @@ function ExpandableSearch(_ref) {
|
|
|
27
29
|
onBlur,
|
|
28
30
|
onChange,
|
|
29
31
|
onExpand,
|
|
30
|
-
|
|
32
|
+
onKeyDown,
|
|
31
33
|
defaultValue,
|
|
32
34
|
isExpanded,
|
|
33
35
|
...props
|
|
@@ -36,11 +38,6 @@ function ExpandableSearch(_ref) {
|
|
|
36
38
|
const [hasContent, setHasContent] = React.useState(defaultValue ? true : false);
|
|
37
39
|
const searchRef = React.useRef(null);
|
|
38
40
|
const prefix = usePrefix.usePrefix();
|
|
39
|
-
function handleFocus() {
|
|
40
|
-
if (!expanded) {
|
|
41
|
-
setExpanded(true);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
41
|
function handleBlur(evt) {
|
|
45
42
|
const relatedTargetIsAllowed = evt.relatedTarget && evt.relatedTarget.classList.contains(`${prefix}--search-close`);
|
|
46
43
|
if (expanded && !relatedTargetIsAllowed && !hasContent) {
|
|
@@ -51,8 +48,19 @@ function ExpandableSearch(_ref) {
|
|
|
51
48
|
setHasContent(evt.target.value !== '');
|
|
52
49
|
}
|
|
53
50
|
function handleExpand() {
|
|
51
|
+
setExpanded(true);
|
|
54
52
|
searchRef.current?.focus?.();
|
|
55
53
|
}
|
|
54
|
+
function handleKeyDown(evt) {
|
|
55
|
+
if (expanded && match.match(evt, keys.Escape)) {
|
|
56
|
+
evt.stopPropagation();
|
|
57
|
+
|
|
58
|
+
// escape key only clears if the input is empty, otherwise it clears the input
|
|
59
|
+
if (!evt.target?.value) {
|
|
60
|
+
setExpanded(false);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
56
64
|
const classes = cx__default["default"](`${prefix}--search--expandable`, {
|
|
57
65
|
[`${prefix}--search--expanded`]: expanded
|
|
58
66
|
}, props.className);
|
|
@@ -61,10 +69,10 @@ function ExpandableSearch(_ref) {
|
|
|
61
69
|
isExpanded: expanded,
|
|
62
70
|
ref: searchRef,
|
|
63
71
|
className: classes,
|
|
64
|
-
onFocus: events.composeEventHandlers([onFocus, handleFocus]),
|
|
65
72
|
onBlur: events.composeEventHandlers([onBlur, handleBlur]),
|
|
66
73
|
onChange: events.composeEventHandlers([onChange, handleChange]),
|
|
67
|
-
onExpand: events.composeEventHandlers([onExpand, handleExpand])
|
|
74
|
+
onExpand: events.composeEventHandlers([onExpand, handleExpand]),
|
|
75
|
+
onKeyDown: events.composeEventHandlers([onKeyDown, handleKeyDown])
|
|
68
76
|
}));
|
|
69
77
|
}
|
|
70
78
|
ExpandableSearch.propTypes = Search["default"].propTypes;
|
|
@@ -68,12 +68,13 @@ const InlineCheckbox = /*#__PURE__*/React__default["default"].forwardRef(functio
|
|
|
68
68
|
React__default["default"].createElement("label", {
|
|
69
69
|
htmlFor: id,
|
|
70
70
|
className: `${prefix}--checkbox-label`,
|
|
71
|
-
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
72
71
|
title: title,
|
|
73
72
|
onClick: evt => {
|
|
74
73
|
evt.stopPropagation();
|
|
75
74
|
}
|
|
76
|
-
}
|
|
75
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
76
|
+
className: `${prefix}--visually-hidden`
|
|
77
|
+
}, deprecatedAriaLabel || ariaLabel)));
|
|
77
78
|
});
|
|
78
79
|
InlineCheckbox.propTypes = {
|
|
79
80
|
/**
|
|
@@ -48,7 +48,7 @@ const on = function (element) {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* The CSS property names of the arrow keyed by the floating menu direction.
|
|
51
|
-
* @type {
|
|
51
|
+
* @type {[key: string]: string}
|
|
52
52
|
*/
|
|
53
53
|
const triggerButtonPositionProps = {
|
|
54
54
|
[FloatingMenu.DIRECTION_TOP]: 'bottom',
|
|
@@ -57,7 +57,7 @@ const triggerButtonPositionProps = {
|
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Determines how the position of arrow should affect the floating menu position.
|
|
60
|
-
* @type {
|
|
60
|
+
* @type {[key: string]: number}
|
|
61
61
|
*/
|
|
62
62
|
const triggerButtonPositionFactors = {
|
|
63
63
|
[FloatingMenu.DIRECTION_TOP]: -2,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { type HTMLAttributes, type ReactNode, type ComponentType, type FunctionComponent } from 'react';
|
|
7
|
+
import React, { type HTMLAttributes, type ReactNode, type KeyboardEvent, type ComponentType, type FunctionComponent, type MouseEvent } from 'react';
|
|
8
8
|
type InputPropsBase = Omit<HTMLAttributes<HTMLInputElement>, 'onChange'>;
|
|
9
9
|
export interface SearchProps extends InputPropsBase {
|
|
10
10
|
/**
|
|
@@ -54,7 +54,7 @@ export interface SearchProps extends InputPropsBase {
|
|
|
54
54
|
/**
|
|
55
55
|
* Optional callback called when the magnifier icon is clicked in ExpandableSearch.
|
|
56
56
|
*/
|
|
57
|
-
onExpand?(): void;
|
|
57
|
+
onExpand?(e: MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>): void;
|
|
58
58
|
/**
|
|
59
59
|
* Provide an optional placeholder text for the Search.
|
|
60
60
|
* Note: if the label and placeholder differ,
|
|
@@ -63,6 +63,7 @@ const Search = /*#__PURE__*/React__default["default"].forwardRef(function Search
|
|
|
63
63
|
} = React.useContext(FormContext.FormContext);
|
|
64
64
|
const inputRef = React.useRef(null);
|
|
65
65
|
const ref = useMergedRefs.useMergedRefs([forwardRef, inputRef]);
|
|
66
|
+
const expandButtonRef = React.useRef(null);
|
|
66
67
|
const inputId = useId.useId('search-input');
|
|
67
68
|
const uniqueId = id || inputId;
|
|
68
69
|
const searchId = `${uniqueId}-search`;
|
|
@@ -107,7 +108,21 @@ const Search = /*#__PURE__*/React__default["default"].forwardRef(function Search
|
|
|
107
108
|
function handleKeyDown(event) {
|
|
108
109
|
if (match.match(event, keys.Escape)) {
|
|
109
110
|
event.stopPropagation();
|
|
110
|
-
|
|
111
|
+
if (inputRef.current?.value) {
|
|
112
|
+
clearInput();
|
|
113
|
+
}
|
|
114
|
+
// ExpandableSearch closes on escape when isExpanded, focus search activation button
|
|
115
|
+
else if (onExpand && isExpanded) {
|
|
116
|
+
expandButtonRef.current?.focus();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function handleExpandButtonKeyDown(event) {
|
|
121
|
+
if (match.match(event, keys.Enter) || match.match(event, keys.Space)) {
|
|
122
|
+
event.stopPropagation();
|
|
123
|
+
if (onExpand) {
|
|
124
|
+
onExpand(event);
|
|
125
|
+
}
|
|
111
126
|
}
|
|
112
127
|
}
|
|
113
128
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -118,7 +133,12 @@ const Search = /*#__PURE__*/React__default["default"].forwardRef(function Search
|
|
|
118
133
|
"aria-labelledby": onExpand ? uniqueId : undefined,
|
|
119
134
|
role: onExpand ? 'button' : undefined,
|
|
120
135
|
className: `${prefix}--search-magnifier`,
|
|
121
|
-
onClick: onExpand
|
|
136
|
+
onClick: onExpand,
|
|
137
|
+
onKeyDown: handleExpandButtonKeyDown,
|
|
138
|
+
tabIndex: onExpand && !isExpanded ? 1 : -1,
|
|
139
|
+
ref: expandButtonRef,
|
|
140
|
+
"aria-expanded": onExpand && isExpanded ? true : undefined,
|
|
141
|
+
"aria-controls": onExpand ? uniqueId : undefined
|
|
122
142
|
}, /*#__PURE__*/React__default["default"].createElement(CustomSearchIcon, {
|
|
123
143
|
icon: renderIcon
|
|
124
144
|
})), /*#__PURE__*/React__default["default"].createElement("label", {
|
|
@@ -137,7 +157,8 @@ const Search = /*#__PURE__*/React__default["default"].forwardRef(function Search
|
|
|
137
157
|
onKeyDown: events.composeEventHandlers([onKeyDown, handleKeyDown]),
|
|
138
158
|
placeholder: placeholder,
|
|
139
159
|
type: type,
|
|
140
|
-
value: value
|
|
160
|
+
value: value,
|
|
161
|
+
tabIndex: onExpand && !isExpanded ? -1 : undefined
|
|
141
162
|
})), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
142
163
|
"aria-label": closeButtonLabelText,
|
|
143
164
|
className: clearClasses,
|
|
@@ -205,6 +205,8 @@ function TabList(_ref2) {
|
|
|
205
205
|
[`${prefix}--tabs--light`]: light,
|
|
206
206
|
[`${prefix}--tabs__icon--default`]: iconSize === 'default',
|
|
207
207
|
[`${prefix}--tabs__icon--lg`]: iconSize === 'lg',
|
|
208
|
+
// TODO: V12 - Remove this class
|
|
209
|
+
[`${prefix}--layout--size-lg`]: iconSize === 'lg',
|
|
208
210
|
[`${prefix}--tabs--tall`]: hasSecondaryLabelTabs,
|
|
209
211
|
[`${prefix}--tabs--full-width`]: distributeWidth
|
|
210
212
|
}, customClassName);
|
|
@@ -51,6 +51,7 @@ const Tag = _ref => {
|
|
|
51
51
|
disabled,
|
|
52
52
|
onClose,
|
|
53
53
|
size,
|
|
54
|
+
as: BaseComponent,
|
|
54
55
|
...other
|
|
55
56
|
} = _ref;
|
|
56
57
|
const prefix = usePrefix.usePrefix();
|
|
@@ -71,7 +72,8 @@ const Tag = _ref => {
|
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
74
|
if (filter) {
|
|
74
|
-
|
|
75
|
+
const ComponentTag = BaseComponent ?? 'div';
|
|
76
|
+
return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
|
|
75
77
|
className: tagClasses,
|
|
76
78
|
id: tagId
|
|
77
79
|
}, other), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -86,7 +88,7 @@ const Tag = _ref => {
|
|
|
86
88
|
title: title
|
|
87
89
|
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))));
|
|
88
90
|
}
|
|
89
|
-
const ComponentTag = other.onClick ? 'button' : 'div';
|
|
91
|
+
const ComponentTag = BaseComponent ?? (other.onClick ? 'button' : 'div');
|
|
90
92
|
return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
|
|
91
93
|
disabled: ComponentTag === 'button' ? disabled : null,
|
|
92
94
|
className: tagClasses,
|
|
@@ -98,6 +100,11 @@ const Tag = _ref => {
|
|
|
98
100
|
}, children !== null && children !== undefined ? children : TYPES[type]));
|
|
99
101
|
};
|
|
100
102
|
Tag.propTypes = {
|
|
103
|
+
/**
|
|
104
|
+
* Provide an alternative tag or component to use instead of the default
|
|
105
|
+
* wrapping element
|
|
106
|
+
*/
|
|
107
|
+
as: PropTypes__default["default"].elementType,
|
|
101
108
|
/**
|
|
102
109
|
* Provide content to be rendered inside of a <Tag>
|
|
103
110
|
*/
|
|
@@ -71,7 +71,7 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
71
71
|
if (!other.disabled && onChange) {
|
|
72
72
|
// delay textCount assignation to give the textarea element value time to catch up if is a controlled input
|
|
73
73
|
setTimeout(() => {
|
|
74
|
-
setTextCount(evt.target
|
|
74
|
+
setTextCount(evt.target?.value?.length);
|
|
75
75
|
}, 0);
|
|
76
76
|
onChange(evt);
|
|
77
77
|
}
|
|
@@ -19,18 +19,18 @@ export interface ToggleProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonE
|
|
|
19
19
|
/**
|
|
20
20
|
* Specify the label for the "off" position
|
|
21
21
|
*/
|
|
22
|
-
labelA?: string
|
|
22
|
+
labelA?: string;
|
|
23
23
|
/**
|
|
24
24
|
* Specify the label for the "on" position
|
|
25
25
|
*/
|
|
26
|
-
labelB?: string
|
|
26
|
+
labelB?: string;
|
|
27
27
|
/**
|
|
28
28
|
* Provide the text that will be read by a screen reader when visiting this
|
|
29
29
|
* control. This should be provided unless 'aria-labelledby' is set instead
|
|
30
30
|
* or you use an external <label> element with its "for" attribute set to the
|
|
31
31
|
* toggle's id.
|
|
32
32
|
*/
|
|
33
|
-
labelText?: string
|
|
33
|
+
labelText?: string;
|
|
34
34
|
/**
|
|
35
35
|
* If true, the side labels (props.labelA and props.labelB) will be replaced by
|
|
36
36
|
* props.labelText (if passed), so that the toggle doesn't render a top label.
|
|
@@ -39,7 +39,7 @@ export interface ToggleProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonE
|
|
|
39
39
|
/**
|
|
40
40
|
* Provide an event listener that is called when the control is toggled
|
|
41
41
|
*/
|
|
42
|
-
onClick
|
|
42
|
+
onClick?: MouseEventHandler<HTMLDivElement> | KeyboardEventHandler<HTMLDivElement>;
|
|
43
43
|
/**
|
|
44
44
|
* Provide an event listener that is called when the control is toggled
|
|
45
45
|
*/
|
|
@@ -47,19 +47,19 @@ export interface ToggleProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonE
|
|
|
47
47
|
/**
|
|
48
48
|
* Specify the size of the Toggle. Currently only supports 'sm' or 'md' (default)
|
|
49
49
|
*/
|
|
50
|
-
size?: 'sm' | 'md'
|
|
50
|
+
size?: 'sm' | 'md';
|
|
51
51
|
/**
|
|
52
52
|
* Whether the toggle should be read-only
|
|
53
53
|
*/
|
|
54
|
-
readOnly?: boolean
|
|
54
|
+
readOnly?: boolean;
|
|
55
55
|
/**
|
|
56
56
|
* Specify whether the toggle should be on by default
|
|
57
57
|
*/
|
|
58
|
-
defaultToggled?: boolean
|
|
58
|
+
defaultToggled?: boolean;
|
|
59
59
|
/**
|
|
60
60
|
* Specify whether the control is toggled
|
|
61
61
|
*/
|
|
62
|
-
toggled?: boolean
|
|
62
|
+
toggled?: boolean;
|
|
63
63
|
}
|
|
64
64
|
export declare function Toggle({ 'aria-labelledby': ariaLabelledby, className, defaultToggled, disabled, hideLabel, id, labelA, labelB, labelText, onClick, onToggle, readOnly, size, toggled, ...other }: ToggleProps): JSX.Element;
|
|
65
65
|
export declare namespace Toggle {
|
|
@@ -28,11 +28,68 @@ declare namespace HeaderMenuButton {
|
|
|
28
28
|
* Specify whether the menu button is "active".
|
|
29
29
|
*/
|
|
30
30
|
isActive: PropTypes.Requireable<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Specify whether the menu button is collapsible.
|
|
33
|
+
*/
|
|
34
|
+
isCollapsible: PropTypes.Requireable<boolean>;
|
|
31
35
|
/**
|
|
32
36
|
* Optionally provide an onClick handler that is called when the underlying
|
|
33
37
|
* button fires it's onclick event
|
|
34
38
|
*/
|
|
35
39
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
|
+
0: string;
|
|
41
|
+
length: 1;
|
|
42
|
+
toString(): string;
|
|
43
|
+
toLocaleString(): string;
|
|
44
|
+
pop(): string | undefined;
|
|
45
|
+
push(...items: string[]): number;
|
|
46
|
+
concat(...items: ConcatArray<string>[]): string[];
|
|
47
|
+
concat(...items: (string | ConcatArray<string>)[]): string[];
|
|
48
|
+
join(separator?: string | undefined): string;
|
|
49
|
+
reverse(): string[];
|
|
50
|
+
shift(): string | undefined;
|
|
51
|
+
slice(start?: number | undefined, end?: number | undefined): string[];
|
|
52
|
+
sort(compareFn?: ((a: string, b: string) => number) | undefined): [key: string];
|
|
53
|
+
splice(start: number, deleteCount?: number | undefined): string[];
|
|
54
|
+
splice(start: number, deleteCount: number, ...items: string[]): string[];
|
|
55
|
+
unshift(...items: string[]): number;
|
|
56
|
+
indexOf(searchElement: string, fromIndex?: number | undefined): number;
|
|
57
|
+
lastIndexOf(searchElement: string, fromIndex?: number | undefined): number;
|
|
58
|
+
every<S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): this is S[];
|
|
59
|
+
every(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean;
|
|
60
|
+
some(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean;
|
|
61
|
+
forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
|
|
62
|
+
map<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];
|
|
63
|
+
filter<S_1 extends string>(predicate: (value: string, index: number, array: string[]) => value is S_1, thisArg?: any): S_1[];
|
|
64
|
+
filter(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[];
|
|
65
|
+
reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
|
|
66
|
+
reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
|
|
67
|
+
reduce<U_1>(callbackfn: (previousValue: U_1, currentValue: string, currentIndex: number, array: string[]) => U_1, initialValue: U_1): U_1;
|
|
68
|
+
reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
|
|
69
|
+
reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
|
|
70
|
+
reduceRight<U_2>(callbackfn: (previousValue: U_2, currentValue: string, currentIndex: number, array: string[]) => U_2, initialValue: U_2): U_2;
|
|
71
|
+
find<S_2 extends string>(predicate: (this: void, value: string, index: number, obj: string[]) => value is S_2, thisArg?: any): S_2 | undefined;
|
|
72
|
+
find(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): string | undefined;
|
|
73
|
+
findIndex(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): number;
|
|
74
|
+
fill(value: string, start?: number | undefined, end?: number | undefined): [key: string];
|
|
75
|
+
copyWithin(target: number, start: number, end?: number | undefined): [key: string];
|
|
76
|
+
entries(): IterableIterator<[number, string]>;
|
|
77
|
+
keys(): IterableIterator<number>;
|
|
78
|
+
values(): IterableIterator<string>;
|
|
79
|
+
includes(searchElement: string, fromIndex?: number | undefined): boolean;
|
|
80
|
+
flatMap<U_3, This = undefined>(callback: (this: This, value: string, index: number, array: string[]) => U_3 | readonly U_3[], thisArg?: This | undefined): U_3[];
|
|
81
|
+
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
|
82
|
+
at(index: number): string | undefined;
|
|
83
|
+
[Symbol.iterator](): IterableIterator<string>;
|
|
84
|
+
[Symbol.unscopables](): {
|
|
85
|
+
copyWithin: boolean;
|
|
86
|
+
entries: boolean;
|
|
87
|
+
fill: boolean;
|
|
88
|
+
find: boolean;
|
|
89
|
+
findIndex: boolean;
|
|
90
|
+
keys: boolean;
|
|
91
|
+
values: boolean;
|
|
92
|
+
};
|
|
36
93
|
};
|
|
37
94
|
}
|
|
38
95
|
export default HeaderMenuButton;
|
|
@@ -74,6 +74,10 @@ HeaderMenuButton.propTypes = {
|
|
|
74
74
|
* Specify whether the menu button is "active".
|
|
75
75
|
*/
|
|
76
76
|
isActive: PropTypes__default["default"].bool,
|
|
77
|
+
/**
|
|
78
|
+
* Specify whether the menu button is collapsible.
|
|
79
|
+
*/
|
|
80
|
+
isCollapsible: PropTypes__default["default"].bool,
|
|
77
81
|
/**
|
|
78
82
|
* Optionally provide an onClick handler that is called when the underlying
|
|
79
83
|
* button fires it's onclick event
|
|
@@ -19,6 +19,62 @@ declare namespace HeaderNavigation {
|
|
|
19
19
|
* Optionally provide a custom class to apply to the underlying <nav> node
|
|
20
20
|
*/
|
|
21
21
|
className: PropTypes.Requireable<string>;
|
|
22
|
+
0: string;
|
|
23
|
+
length: 1;
|
|
24
|
+
toString(): string;
|
|
25
|
+
toLocaleString(): string;
|
|
26
|
+
pop(): string | undefined;
|
|
27
|
+
push(...items: string[]): number;
|
|
28
|
+
concat(...items: ConcatArray<string>[]): string[];
|
|
29
|
+
concat(...items: (string | ConcatArray<string>)[]): string[];
|
|
30
|
+
join(separator?: string | undefined): string;
|
|
31
|
+
reverse(): string[];
|
|
32
|
+
shift(): string | undefined;
|
|
33
|
+
slice(start?: number | undefined, end?: number | undefined): string[];
|
|
34
|
+
sort(compareFn?: ((a: string, b: string) => number) | undefined): [key: string];
|
|
35
|
+
splice(start: number, deleteCount?: number | undefined): string[];
|
|
36
|
+
splice(start: number, deleteCount: number, ...items: string[]): string[];
|
|
37
|
+
unshift(...items: string[]): number;
|
|
38
|
+
indexOf(searchElement: string, fromIndex?: number | undefined): number;
|
|
39
|
+
lastIndexOf(searchElement: string, fromIndex?: number | undefined): number;
|
|
40
|
+
every<S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): this is S[];
|
|
41
|
+
every(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean;
|
|
42
|
+
some(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean;
|
|
43
|
+
forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
|
|
44
|
+
map<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];
|
|
45
|
+
filter<S_1 extends string>(predicate: (value: string, index: number, array: string[]) => value is S_1, thisArg?: any): S_1[];
|
|
46
|
+
filter(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[];
|
|
47
|
+
reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
|
|
48
|
+
reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
|
|
49
|
+
reduce<U_1>(callbackfn: (previousValue: U_1, currentValue: string, currentIndex: number, array: string[]) => U_1, initialValue: U_1): U_1;
|
|
50
|
+
reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
|
|
51
|
+
reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
|
|
52
|
+
reduceRight<U_2>(callbackfn: (previousValue: U_2, currentValue: string, currentIndex: number, array: string[]) => U_2, initialValue: U_2): U_2;
|
|
53
|
+
find<S_2 extends string>(predicate: (this: void, value: string, index: number, obj: string[]) => value is S_2, thisArg?: any): S_2 | undefined;
|
|
54
|
+
find(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): string | undefined;
|
|
55
|
+
findIndex(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): number;
|
|
56
|
+
fill(value: string, start?: number | undefined, end?: number | undefined): [key: string];
|
|
57
|
+
copyWithin(target: number, start: number, end?: number | undefined): [key: string];
|
|
58
|
+
entries(): IterableIterator<[number, string]>;
|
|
59
|
+
keys(): IterableIterator<number>;
|
|
60
|
+
values(): IterableIterator<string>;
|
|
61
|
+
includes(searchElement: string, fromIndex?: number | undefined): boolean;
|
|
62
|
+
flatMap<U_3, This = undefined>(callback: (this: This, value: string, index: number, array: string[]) => U_3 | readonly U_3[], thisArg?: This | undefined): U_3[];
|
|
63
|
+
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
|
64
|
+
at(index: number): string | undefined; /**
|
|
65
|
+
* Provide valid children of HeaderNavigation, for example `HeaderMenuItem`
|
|
66
|
+
* or `HeaderMenu`
|
|
67
|
+
*/
|
|
68
|
+
[Symbol.iterator](): IterableIterator<string>;
|
|
69
|
+
[Symbol.unscopables](): {
|
|
70
|
+
copyWithin: boolean;
|
|
71
|
+
entries: boolean;
|
|
72
|
+
fill: boolean;
|
|
73
|
+
find: boolean;
|
|
74
|
+
findIndex: boolean;
|
|
75
|
+
keys: boolean;
|
|
76
|
+
values: boolean;
|
|
77
|
+
};
|
|
22
78
|
};
|
|
23
79
|
}
|
|
24
80
|
export default HeaderNavigation;
|
|
@@ -49,7 +49,7 @@ const HeaderPanel = /*#__PURE__*/React__default["default"].forwardRef(function H
|
|
|
49
49
|
const eventHandlers = {};
|
|
50
50
|
if (addFocusListeners) {
|
|
51
51
|
eventHandlers.onBlur = event => {
|
|
52
|
-
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement
|
|
52
|
+
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement?.classList?.contains('cds--switcher__item-link')) {
|
|
53
53
|
setExpandedState(false);
|
|
54
54
|
setLastClickedElement(null);
|
|
55
55
|
if (expanded) {
|
|
@@ -67,12 +67,23 @@ const Switcher = /*#__PURE__*/React__default["default"].forwardRef(function Swit
|
|
|
67
67
|
const switcherItem = switcherRef.current.children[nextValidIndex].children[0];
|
|
68
68
|
switcherItem?.focus();
|
|
69
69
|
};
|
|
70
|
-
const childrenWithProps = React__default["default"].Children.toArray(children).map((child, index) =>
|
|
71
|
-
handleSwitcherItemFocus
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
const childrenWithProps = React__default["default"].Children.toArray(children).map((child, index) => {
|
|
71
|
+
// handleSwitcherItemFocus should only be passed down if the child is a SwitcherItem
|
|
72
|
+
// SwitcherDivider, for example, does not accept a handleSwitcherItemFocus prop
|
|
73
|
+
if (child.type?.displayName === 'SwitcherItem') {
|
|
74
|
+
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
75
|
+
handleSwitcherItemFocus,
|
|
76
|
+
index,
|
|
77
|
+
key: index,
|
|
78
|
+
expanded
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
82
|
+
index,
|
|
83
|
+
key: index,
|
|
84
|
+
expanded
|
|
85
|
+
});
|
|
86
|
+
});
|
|
76
87
|
return /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
|
|
77
88
|
ref: ref,
|
|
78
89
|
className: className
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @param {
|
|
14
|
-
* @returns {
|
|
13
|
+
* @param {[key: string]: Function)} propTypes The list of type checkers, keyed by prop names.
|
|
14
|
+
* @returns {[key: string]: Function}
|
|
15
15
|
* The new prop type checkers that checks if one of the given props exist,
|
|
16
16
|
* in addition to the original type checkings.
|
|
17
17
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.34.0-rc.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.18.3",
|
|
47
47
|
"@carbon/feature-flags": "^0.15.0",
|
|
48
|
-
"@carbon/icons-react": "^11.
|
|
49
|
-
"@carbon/layout": "^11.
|
|
50
|
-
"@carbon/styles": "^1.
|
|
48
|
+
"@carbon/icons-react": "^11.23.0-rc.0",
|
|
49
|
+
"@carbon/layout": "^11.17.0-rc.0",
|
|
50
|
+
"@carbon/styles": "^1.34.0-rc.0",
|
|
51
51
|
"@carbon/telemetry": "0.1.0",
|
|
52
52
|
"classnames": "2.3.2",
|
|
53
53
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@babel/preset-react": "^7.22.3",
|
|
76
76
|
"@babel/preset-typescript": "^7.21.5",
|
|
77
77
|
"@carbon/test-utils": "^10.30.0",
|
|
78
|
-
"@carbon/themes": "^11.
|
|
78
|
+
"@carbon/themes": "^11.22.0-rc.0",
|
|
79
79
|
"@rollup/plugin-babel": "^6.0.0",
|
|
80
80
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
81
81
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
"**/*.scss",
|
|
138
138
|
"**/*.css"
|
|
139
139
|
],
|
|
140
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "52fd3db75951b341e4abb3af2e7441da6639bfa4"
|
|
141
141
|
}
|