@carbon/react 1.61.0-rc.1 → 1.61.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1175 -992
- package/es/components/Dialog/index.d.ts +3 -4
- package/es/components/Search/Search.js +3 -3
- package/es/components/Tabs/Tabs.d.ts +111 -1
- package/es/components/Tabs/Tabs.js +163 -16
- package/es/components/TextArea/TextArea.js +2 -1
- package/lib/components/Dialog/index.d.ts +3 -4
- package/lib/components/Search/Search.js +3 -3
- package/lib/components/Tabs/Tabs.d.ts +111 -1
- package/lib/components/Tabs/Tabs.js +162 -15
- package/lib/components/TextArea/TextArea.js +2 -1
- package/package.json +4 -5
|
@@ -4,7 +4,6 @@
|
|
|
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 'wicg-inert';
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import { ReactAttr } from '../../types/common';
|
|
10
9
|
export interface DialogProps extends ReactAttr<HTMLDialogElement> {
|
|
@@ -26,6 +25,6 @@ export interface DialogProps extends ReactAttr<HTMLDialogElement> {
|
|
|
26
25
|
*/
|
|
27
26
|
open?: boolean;
|
|
28
27
|
}
|
|
29
|
-
declare const
|
|
30
|
-
export {
|
|
31
|
-
export default
|
|
28
|
+
declare const unstable__Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<unknown>>;
|
|
29
|
+
export { unstable__Dialog };
|
|
30
|
+
export default unstable__Dialog;
|
|
@@ -120,15 +120,15 @@ const Search = /*#__PURE__*/React__default.forwardRef(function Search(_ref, forw
|
|
|
120
120
|
"aria-label": placeholder,
|
|
121
121
|
className: searchClasses
|
|
122
122
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
123
|
-
"aria-label":
|
|
123
|
+
"aria-label": onExpand ? 'button' : undefined,
|
|
124
124
|
"aria-labelledby": onExpand ? uniqueId : undefined,
|
|
125
|
-
role:
|
|
125
|
+
role: onExpand ? 'button' : undefined,
|
|
126
126
|
className: `${prefix}--search-magnifier`,
|
|
127
127
|
onClick: onExpand,
|
|
128
128
|
onKeyDown: handleExpandButtonKeyDown,
|
|
129
129
|
tabIndex: onExpand && !isExpanded ? 0 : -1,
|
|
130
130
|
ref: expandButtonRef,
|
|
131
|
-
"aria-expanded": onExpand && isExpanded ? true : false,
|
|
131
|
+
"aria-expanded": onExpand && isExpanded ? true : onExpand && !isExpanded ? false : undefined,
|
|
132
132
|
"aria-controls": onExpand ? uniqueId : undefined
|
|
133
133
|
}, /*#__PURE__*/React__default.createElement(CustomSearchIcon, {
|
|
134
134
|
icon: renderIcon
|
|
@@ -77,6 +77,63 @@ declare namespace Tabs {
|
|
|
77
77
|
selectedIndex: PropTypes.Requireable<number>;
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
+
export interface TabsVerticalProps {
|
|
81
|
+
/**
|
|
82
|
+
* Provide child elements to be rendered inside the `TabsVertical`.
|
|
83
|
+
* These elements should render either `TabsListVertical` or `TabsPanels`
|
|
84
|
+
*/
|
|
85
|
+
children?: ReactNode;
|
|
86
|
+
/**
|
|
87
|
+
* Specify which content tab should be initially selected when the component
|
|
88
|
+
* is first rendered
|
|
89
|
+
*/
|
|
90
|
+
defaultSelectedIndex?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Option to set a height style only if using vertical variation
|
|
93
|
+
*/
|
|
94
|
+
height?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Provide an optional function which is called
|
|
97
|
+
* whenever the state of the `Tabs` changes
|
|
98
|
+
*/
|
|
99
|
+
onChange?(state: {
|
|
100
|
+
selectedIndex: number;
|
|
101
|
+
}): void;
|
|
102
|
+
/**
|
|
103
|
+
* Control which content panel is currently selected. This puts the component
|
|
104
|
+
* in a controlled mode and should be used along with `onChange`
|
|
105
|
+
*/
|
|
106
|
+
selectedIndex?: number;
|
|
107
|
+
}
|
|
108
|
+
declare function TabsVertical({ children, height, defaultSelectedIndex, onChange, selectedIndex: controlledSelectedIndex, ...rest }: TabsVerticalProps): import("react/jsx-runtime").JSX.Element;
|
|
109
|
+
declare namespace TabsVertical {
|
|
110
|
+
var propTypes: {
|
|
111
|
+
/**
|
|
112
|
+
* Provide child elements to be rendered inside the `TabsVertical`.
|
|
113
|
+
* These elements should render either `TabsListVertical` or `TabsPanels`
|
|
114
|
+
*/
|
|
115
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
116
|
+
/**
|
|
117
|
+
* Specify which content tab should be initially selected when the component
|
|
118
|
+
* is first rendered
|
|
119
|
+
*/
|
|
120
|
+
defaultSelectedIndex: PropTypes.Requireable<number>;
|
|
121
|
+
/**
|
|
122
|
+
* Option to set a height style only if using vertical variation
|
|
123
|
+
*/
|
|
124
|
+
height: PropTypes.Requireable<string>;
|
|
125
|
+
/**
|
|
126
|
+
* Provide an optional function which is called whenever the state of the
|
|
127
|
+
* `Tabs` changes
|
|
128
|
+
*/
|
|
129
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
130
|
+
/**
|
|
131
|
+
* Control which content panel is currently selected. This puts the component
|
|
132
|
+
* in a controlled mode and should be used along with `onChange`
|
|
133
|
+
*/
|
|
134
|
+
selectedIndex: PropTypes.Requireable<number>;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
80
137
|
/**
|
|
81
138
|
* TabList
|
|
82
139
|
*/
|
|
@@ -195,6 +252,59 @@ declare namespace TabList {
|
|
|
195
252
|
scrollIntoView: PropTypes.Requireable<boolean>;
|
|
196
253
|
};
|
|
197
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* TabListVertical
|
|
257
|
+
*/
|
|
258
|
+
export interface TabListVerticalProps extends DivAttributes {
|
|
259
|
+
/**
|
|
260
|
+
* Specify whether the content tab should be activated automatically or
|
|
261
|
+
* manually
|
|
262
|
+
*/
|
|
263
|
+
activation?: 'automatic' | 'manual';
|
|
264
|
+
/**
|
|
265
|
+
* Provide an accessible label to be read when a user interacts with this
|
|
266
|
+
* component
|
|
267
|
+
*/
|
|
268
|
+
'aria-label': string;
|
|
269
|
+
/**
|
|
270
|
+
* Provide child elements to be rendered inside `ContentTabs`.
|
|
271
|
+
* These elements should render a `ContentTab`
|
|
272
|
+
*/
|
|
273
|
+
children?: ReactNode;
|
|
274
|
+
/**
|
|
275
|
+
* Specify an optional className to be added to the container node
|
|
276
|
+
*/
|
|
277
|
+
className?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Choose whether to automatically scroll to newly selected tabs
|
|
280
|
+
* on component rerender
|
|
281
|
+
*/
|
|
282
|
+
scrollIntoView?: boolean;
|
|
283
|
+
}
|
|
284
|
+
declare function TabListVertical({ activation, 'aria-label': label, children, className: customClassName, scrollIntoView, ...rest }: TabListVerticalProps): import("react/jsx-runtime").JSX.Element;
|
|
285
|
+
declare namespace TabListVertical {
|
|
286
|
+
var propTypes: {
|
|
287
|
+
/**
|
|
288
|
+
* Specify whether the content tab should be activated automatically or
|
|
289
|
+
* manually
|
|
290
|
+
*/
|
|
291
|
+
activation: PropTypes.Requireable<string>;
|
|
292
|
+
/**
|
|
293
|
+
* Provide an accessible label to be read when a user interacts with this
|
|
294
|
+
* component
|
|
295
|
+
*/
|
|
296
|
+
'aria-label': PropTypes.Validator<string>;
|
|
297
|
+
/**
|
|
298
|
+
* Provide child elements to be rendered inside `ContentTabs`.
|
|
299
|
+
* These elements should render a `ContentTab`
|
|
300
|
+
*/
|
|
301
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
302
|
+
/**
|
|
303
|
+
* Specify an optional className to be added to the container node
|
|
304
|
+
*/
|
|
305
|
+
className: PropTypes.Requireable<string>;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
198
308
|
/**
|
|
199
309
|
* Tab
|
|
200
310
|
*/
|
|
@@ -308,4 +418,4 @@ declare namespace TabPanels {
|
|
|
308
418
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
309
419
|
};
|
|
310
420
|
}
|
|
311
|
-
export { Tabs, Tab, IconTab, TabPanel, TabPanels, TabList };
|
|
421
|
+
export { Tabs, TabsVertical, Tab, IconTab, TabPanel, TabPanels, TabList, TabListVertical, };
|
|
@@ -11,7 +11,13 @@ import { breakpoints } from '@carbon/layout';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import debounce from 'lodash.debounce';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import React__default, { useState, useRef, useCallback, useEffect, forwardRef } from 'react';
|
|
14
|
+
import React__default, { useState, useRef, useCallback, useEffect, forwardRef, useLayoutEffect } from 'react';
|
|
15
|
+
import '../Grid/FlexGrid.js';
|
|
16
|
+
import '../Grid/Grid.js';
|
|
17
|
+
import '../Grid/Row.js';
|
|
18
|
+
import '../Grid/Column.js';
|
|
19
|
+
import '../Grid/ColumnHang.js';
|
|
20
|
+
import '../Grid/GridContext.js';
|
|
15
21
|
import { isElement } from 'react-is';
|
|
16
22
|
import '../Tooltip/DefinitionTooltip.js';
|
|
17
23
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
@@ -52,6 +58,7 @@ const TabContext = /*#__PURE__*/React__default.createContext({
|
|
|
52
58
|
hasSecondaryLabel: false
|
|
53
59
|
});
|
|
54
60
|
const lgMediaQuery = `(min-width: ${breakpoints.lg.width})`;
|
|
61
|
+
`(max-width: ${breakpoints.md.width})`;
|
|
55
62
|
|
|
56
63
|
// Used to keep track of position in a list of tab panels
|
|
57
64
|
const TabPanelContext = /*#__PURE__*/React__default.createContext(0);
|
|
@@ -130,6 +137,32 @@ Tabs.propTypes = {
|
|
|
130
137
|
*/
|
|
131
138
|
selectedIndex: PropTypes.number
|
|
132
139
|
};
|
|
140
|
+
({
|
|
141
|
+
/**
|
|
142
|
+
* Provide child elements to be rendered inside the `TabsVertical`.
|
|
143
|
+
* These elements should render either `TabsListVertical` or `TabsPanels`
|
|
144
|
+
*/
|
|
145
|
+
children: PropTypes.node,
|
|
146
|
+
/**
|
|
147
|
+
* Specify which content tab should be initially selected when the component
|
|
148
|
+
* is first rendered
|
|
149
|
+
*/
|
|
150
|
+
defaultSelectedIndex: PropTypes.number,
|
|
151
|
+
/**
|
|
152
|
+
* Option to set a height style only if using vertical variation
|
|
153
|
+
*/
|
|
154
|
+
height: PropTypes.string,
|
|
155
|
+
/**
|
|
156
|
+
* Provide an optional function which is called whenever the state of the
|
|
157
|
+
* `Tabs` changes
|
|
158
|
+
*/
|
|
159
|
+
onChange: PropTypes.func,
|
|
160
|
+
/**
|
|
161
|
+
* Control which content panel is currently selected. This puts the component
|
|
162
|
+
* in a controlled mode and should be used along with `onChange`
|
|
163
|
+
*/
|
|
164
|
+
selectedIndex: PropTypes.number
|
|
165
|
+
});
|
|
133
166
|
|
|
134
167
|
/**
|
|
135
168
|
* Get the next index for a given keyboard event
|
|
@@ -154,7 +187,7 @@ function getNextIndex(event, total, index) {
|
|
|
154
187
|
* TabList
|
|
155
188
|
*/
|
|
156
189
|
|
|
157
|
-
function TabList(
|
|
190
|
+
function TabList(_ref4) {
|
|
158
191
|
let {
|
|
159
192
|
activation = 'automatic',
|
|
160
193
|
'aria-label': label,
|
|
@@ -169,7 +202,7 @@ function TabList(_ref2) {
|
|
|
169
202
|
scrollDebounceWait = 200,
|
|
170
203
|
scrollIntoView,
|
|
171
204
|
...rest
|
|
172
|
-
} =
|
|
205
|
+
} = _ref4;
|
|
173
206
|
const {
|
|
174
207
|
activeIndex,
|
|
175
208
|
selectedIndex,
|
|
@@ -326,10 +359,10 @@ function TabList(_ref2) {
|
|
|
326
359
|
}
|
|
327
360
|
}, [activation, activeIndex, selectedIndex, isScrollable, children]);
|
|
328
361
|
usePressable(previousButton, {
|
|
329
|
-
onPress(
|
|
362
|
+
onPress(_ref5) {
|
|
330
363
|
let {
|
|
331
364
|
longPress
|
|
332
|
-
} =
|
|
365
|
+
} = _ref5;
|
|
333
366
|
if (!longPress && ref.current) {
|
|
334
367
|
setScrollLeft(Math.max(scrollLeft - ref.current.scrollWidth / tabs.current.length * 1.5, 0));
|
|
335
368
|
}
|
|
@@ -339,10 +372,10 @@ function TabList(_ref2) {
|
|
|
339
372
|
}
|
|
340
373
|
});
|
|
341
374
|
usePressable(nextButton, {
|
|
342
|
-
onPress(
|
|
375
|
+
onPress(_ref6) {
|
|
343
376
|
let {
|
|
344
377
|
longPress
|
|
345
|
-
} =
|
|
378
|
+
} = _ref6;
|
|
346
379
|
if (!longPress && ref.current) {
|
|
347
380
|
setScrollLeft(Math.min(scrollLeft + ref.current.scrollWidth / tabs.current.length * 1.5, ref.current.scrollWidth - ref.current.clientWidth));
|
|
348
381
|
}
|
|
@@ -444,6 +477,27 @@ TabList.propTypes = {
|
|
|
444
477
|
*/
|
|
445
478
|
scrollIntoView: PropTypes.bool
|
|
446
479
|
};
|
|
480
|
+
({
|
|
481
|
+
/**
|
|
482
|
+
* Specify whether the content tab should be activated automatically or
|
|
483
|
+
* manually
|
|
484
|
+
*/
|
|
485
|
+
activation: PropTypes.oneOf(['automatic', 'manual']),
|
|
486
|
+
/**
|
|
487
|
+
* Provide an accessible label to be read when a user interacts with this
|
|
488
|
+
* component
|
|
489
|
+
*/
|
|
490
|
+
'aria-label': PropTypes.string.isRequired,
|
|
491
|
+
/**
|
|
492
|
+
* Provide child elements to be rendered inside `ContentTabs`.
|
|
493
|
+
* These elements should render a `ContentTab`
|
|
494
|
+
*/
|
|
495
|
+
children: PropTypes.node,
|
|
496
|
+
/**
|
|
497
|
+
* Specify an optional className to be added to the container node
|
|
498
|
+
*/
|
|
499
|
+
className: PropTypes.string
|
|
500
|
+
});
|
|
447
501
|
|
|
448
502
|
/**
|
|
449
503
|
* Helper function to set up the behavior when a button is "long pressed".
|
|
@@ -490,7 +544,7 @@ function createLongPressBehavior(ref, direction, setScrollLeft) {
|
|
|
490
544
|
* Tab
|
|
491
545
|
*/
|
|
492
546
|
|
|
493
|
-
const Tab = /*#__PURE__*/forwardRef(function Tab(
|
|
547
|
+
const Tab = /*#__PURE__*/forwardRef(function Tab(_ref8, forwardRef) {
|
|
494
548
|
let {
|
|
495
549
|
as = 'button',
|
|
496
550
|
children,
|
|
@@ -501,7 +555,7 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref5, forwardRef) {
|
|
|
501
555
|
secondaryLabel,
|
|
502
556
|
renderIcon: Icon,
|
|
503
557
|
...rest
|
|
504
|
-
} =
|
|
558
|
+
} = _ref8;
|
|
505
559
|
const prefix = usePrefix();
|
|
506
560
|
const {
|
|
507
561
|
selectedIndex,
|
|
@@ -521,6 +575,11 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref5, forwardRef) {
|
|
|
521
575
|
const [ignoreHover, setIgnoreHover] = useState(false);
|
|
522
576
|
const id = `${baseId}-tab-${index}`;
|
|
523
577
|
const panelId = `${baseId}-tabpanel-${index}`;
|
|
578
|
+
const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
|
|
579
|
+
const isEllipsisActive = element => {
|
|
580
|
+
setIsEllipsisApplied(element.offsetHeight < element.scrollHeight);
|
|
581
|
+
return element.offsetHeight < element.scrollHeight;
|
|
582
|
+
};
|
|
524
583
|
const className = cx(`${prefix}--tabs__nav-item`, `${prefix}--tabs__nav-link`, {
|
|
525
584
|
[`${prefix}--tabs__nav-item--selected`]: selectedIndex === index,
|
|
526
585
|
[`${prefix}--tabs__nav-item--disabled`]: disabled,
|
|
@@ -542,6 +601,18 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref5, forwardRef) {
|
|
|
542
601
|
};
|
|
543
602
|
useEvent(dismissIconRef, 'mouseover', onDismissIconMouseEnter);
|
|
544
603
|
useEvent(dismissIconRef, 'mouseleave', onDismissIconMouseLeave);
|
|
604
|
+
useLayoutEffect(() => {
|
|
605
|
+
function handler() {
|
|
606
|
+
const elementTabId = document.getElementById(`${id}`);
|
|
607
|
+
const newElement = elementTabId?.getElementsByClassName(`${prefix}--tabs__nav-item-label`)[0];
|
|
608
|
+
isEllipsisActive(newElement);
|
|
609
|
+
}
|
|
610
|
+
handler();
|
|
611
|
+
window.addEventListener('resize', handler);
|
|
612
|
+
return () => {
|
|
613
|
+
window.removeEventListener('resize', handler);
|
|
614
|
+
};
|
|
615
|
+
}, [prefix, id]);
|
|
545
616
|
const handleClose = evt => {
|
|
546
617
|
evt.stopPropagation();
|
|
547
618
|
onTabCloseRequest?.(index);
|
|
@@ -596,6 +667,46 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref5, forwardRef) {
|
|
|
596
667
|
"aria-label": `Press delete to remove ${typeof children === 'string' ? children : ''} tab`
|
|
597
668
|
})));
|
|
598
669
|
const hasIcon = Icon ?? dismissable;
|
|
670
|
+
|
|
671
|
+
// should only happen for vertical variation, so no dissimisamble icon is needed here
|
|
672
|
+
if (isEllipsisApplied) {
|
|
673
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
674
|
+
label: children,
|
|
675
|
+
align: "top",
|
|
676
|
+
leaveDelayMs: 0,
|
|
677
|
+
autoAlign: true,
|
|
678
|
+
onMouseEnter: () => false,
|
|
679
|
+
closeOnActivation: true
|
|
680
|
+
}, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
681
|
+
"aria-controls": panelId,
|
|
682
|
+
"aria-disabled": disabled,
|
|
683
|
+
"aria-selected": selectedIndex === index,
|
|
684
|
+
ref: ref,
|
|
685
|
+
id: id,
|
|
686
|
+
role: "tab",
|
|
687
|
+
className: className,
|
|
688
|
+
disabled: disabled,
|
|
689
|
+
title: children,
|
|
690
|
+
onClick: evt => {
|
|
691
|
+
if (disabled) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
setSelectedIndex(index);
|
|
695
|
+
onClick?.(evt);
|
|
696
|
+
},
|
|
697
|
+
onKeyDown: handleKeyDown,
|
|
698
|
+
tabIndex: selectedIndex === index ? '0' : '-1',
|
|
699
|
+
type: "button"
|
|
700
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
701
|
+
className: `${prefix}--tabs__nav-item-label-wrapper`
|
|
702
|
+
}, /*#__PURE__*/React__default.createElement(Text, {
|
|
703
|
+
className: `${prefix}--tabs__nav-item-label`
|
|
704
|
+
}, children)), hasSecondaryLabel && secondaryLabel && /*#__PURE__*/React__default.createElement(Text, {
|
|
705
|
+
as: "div",
|
|
706
|
+
className: `${prefix}--tabs__nav-item-secondary-label`,
|
|
707
|
+
title: secondaryLabel
|
|
708
|
+
}, secondaryLabel)));
|
|
709
|
+
}
|
|
599
710
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
600
711
|
"aria-controls": panelId,
|
|
601
712
|
"aria-disabled": disabled,
|
|
@@ -684,7 +795,7 @@ Tab.propTypes = {
|
|
|
684
795
|
* IconTab
|
|
685
796
|
*/
|
|
686
797
|
|
|
687
|
-
const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(
|
|
798
|
+
const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref9, ref) {
|
|
688
799
|
let {
|
|
689
800
|
children,
|
|
690
801
|
className: customClassName,
|
|
@@ -693,7 +804,7 @@ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref6, r
|
|
|
693
804
|
leaveDelayMs,
|
|
694
805
|
label,
|
|
695
806
|
...rest
|
|
696
|
-
} =
|
|
807
|
+
} = _ref9;
|
|
697
808
|
const prefix = usePrefix();
|
|
698
809
|
const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName);
|
|
699
810
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
@@ -742,12 +853,12 @@ IconTab.propTypes = {
|
|
|
742
853
|
* TabPanel
|
|
743
854
|
*/
|
|
744
855
|
|
|
745
|
-
const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(
|
|
856
|
+
const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref10, forwardRef) {
|
|
746
857
|
let {
|
|
747
858
|
children,
|
|
748
859
|
className: customClassName,
|
|
749
860
|
...rest
|
|
750
|
-
} =
|
|
861
|
+
} = _ref10;
|
|
751
862
|
const prefix = usePrefix();
|
|
752
863
|
const panel = useRef(null);
|
|
753
864
|
const ref = useMergedRefs([forwardRef, panel]);
|
|
@@ -822,14 +933,50 @@ TabPanel.propTypes = {
|
|
|
822
933
|
* TabPanels
|
|
823
934
|
*/
|
|
824
935
|
|
|
825
|
-
function TabPanels(
|
|
936
|
+
function TabPanels(_ref11) {
|
|
826
937
|
let {
|
|
827
938
|
children
|
|
828
|
-
} =
|
|
939
|
+
} = _ref11;
|
|
940
|
+
const prefix = usePrefix();
|
|
941
|
+
const refs = useRef([]);
|
|
942
|
+
const hiddenStates = useRef([]);
|
|
943
|
+
useLayoutEffect(() => {
|
|
944
|
+
const tabContainer = refs.current[0]?.previousElementSibling;
|
|
945
|
+
const isVertical = tabContainer?.classList.contains(`${prefix}--tabs--vertical`);
|
|
946
|
+
const parentHasHeight = tabContainer?.parentElement?.style.height;
|
|
947
|
+
|
|
948
|
+
// Should only apply same height to vertical Tab Panels without a given height
|
|
949
|
+
if (isVertical && !parentHasHeight) {
|
|
950
|
+
hiddenStates.current = refs.current.map(ref => ref?.hidden || false);
|
|
951
|
+
|
|
952
|
+
// un-hide hidden Tab Panels to get heights
|
|
953
|
+
refs.current.forEach(ref => {
|
|
954
|
+
if (ref) {
|
|
955
|
+
ref.hidden = false;
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
// set max height to TabList
|
|
960
|
+
const heights = refs.current.map(ref => ref?.offsetHeight || 0);
|
|
961
|
+
const max = Math.max(...heights);
|
|
962
|
+
tabContainer.style.height = max + 'px';
|
|
963
|
+
|
|
964
|
+
// re-hide hidden Tab Panels
|
|
965
|
+
refs.current.forEach((ref, index) => {
|
|
966
|
+
if (ref) {
|
|
967
|
+
ref.hidden = hiddenStates.current[index];
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
});
|
|
829
972
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, React__default.Children.map(children, (child, index) => {
|
|
830
973
|
return /*#__PURE__*/React__default.createElement(TabPanelContext.Provider, {
|
|
831
974
|
value: index
|
|
832
|
-
}, child
|
|
975
|
+
}, /*#__PURE__*/React__default.cloneElement(child, {
|
|
976
|
+
ref: element => {
|
|
977
|
+
refs.current[index] = element;
|
|
978
|
+
}
|
|
979
|
+
}));
|
|
833
980
|
}));
|
|
834
981
|
}
|
|
835
982
|
TabPanels.propTypes = {
|
|
@@ -87,7 +87,7 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
|
|
|
87
87
|
onKeyDown: evt => {
|
|
88
88
|
if (!disabled && enableCounter && counterMode === 'word') {
|
|
89
89
|
const key = evt.which;
|
|
90
|
-
if (maxCount && textCount >= maxCount && key === 32) {
|
|
90
|
+
if (maxCount && textCount >= maxCount && key === 32 || maxCount && textCount >= maxCount && key === 13) {
|
|
91
91
|
evt.preventDefault();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -220,6 +220,7 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
|
|
|
220
220
|
const ariaAnnouncement = useAnnouncer(textCount, maxCount, counterMode === 'word' ? 'words' : undefined);
|
|
221
221
|
const input = /*#__PURE__*/React__default.createElement("textarea", _extends({}, other, textareaProps, {
|
|
222
222
|
placeholder: placeholder,
|
|
223
|
+
"aria-readonly": other.readOnly ? true : false,
|
|
223
224
|
className: textareaClasses,
|
|
224
225
|
"aria-invalid": invalid,
|
|
225
226
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -4,7 +4,6 @@
|
|
|
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 'wicg-inert';
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import { ReactAttr } from '../../types/common';
|
|
10
9
|
export interface DialogProps extends ReactAttr<HTMLDialogElement> {
|
|
@@ -26,6 +25,6 @@ export interface DialogProps extends ReactAttr<HTMLDialogElement> {
|
|
|
26
25
|
*/
|
|
27
26
|
open?: boolean;
|
|
28
27
|
}
|
|
29
|
-
declare const
|
|
30
|
-
export {
|
|
31
|
-
export default
|
|
28
|
+
declare const unstable__Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<unknown>>;
|
|
29
|
+
export { unstable__Dialog };
|
|
30
|
+
export default unstable__Dialog;
|
|
@@ -130,15 +130,15 @@ const Search = /*#__PURE__*/React__default["default"].forwardRef(function Search
|
|
|
130
130
|
"aria-label": placeholder,
|
|
131
131
|
className: searchClasses
|
|
132
132
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
133
|
-
"aria-label":
|
|
133
|
+
"aria-label": onExpand ? 'button' : undefined,
|
|
134
134
|
"aria-labelledby": onExpand ? uniqueId : undefined,
|
|
135
|
-
role:
|
|
135
|
+
role: onExpand ? 'button' : undefined,
|
|
136
136
|
className: `${prefix}--search-magnifier`,
|
|
137
137
|
onClick: onExpand,
|
|
138
138
|
onKeyDown: handleExpandButtonKeyDown,
|
|
139
139
|
tabIndex: onExpand && !isExpanded ? 0 : -1,
|
|
140
140
|
ref: expandButtonRef,
|
|
141
|
-
"aria-expanded": onExpand && isExpanded ? true : false,
|
|
141
|
+
"aria-expanded": onExpand && isExpanded ? true : onExpand && !isExpanded ? false : undefined,
|
|
142
142
|
"aria-controls": onExpand ? uniqueId : undefined
|
|
143
143
|
}, /*#__PURE__*/React__default["default"].createElement(CustomSearchIcon, {
|
|
144
144
|
icon: renderIcon
|
|
@@ -77,6 +77,63 @@ declare namespace Tabs {
|
|
|
77
77
|
selectedIndex: PropTypes.Requireable<number>;
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
+
export interface TabsVerticalProps {
|
|
81
|
+
/**
|
|
82
|
+
* Provide child elements to be rendered inside the `TabsVertical`.
|
|
83
|
+
* These elements should render either `TabsListVertical` or `TabsPanels`
|
|
84
|
+
*/
|
|
85
|
+
children?: ReactNode;
|
|
86
|
+
/**
|
|
87
|
+
* Specify which content tab should be initially selected when the component
|
|
88
|
+
* is first rendered
|
|
89
|
+
*/
|
|
90
|
+
defaultSelectedIndex?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Option to set a height style only if using vertical variation
|
|
93
|
+
*/
|
|
94
|
+
height?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Provide an optional function which is called
|
|
97
|
+
* whenever the state of the `Tabs` changes
|
|
98
|
+
*/
|
|
99
|
+
onChange?(state: {
|
|
100
|
+
selectedIndex: number;
|
|
101
|
+
}): void;
|
|
102
|
+
/**
|
|
103
|
+
* Control which content panel is currently selected. This puts the component
|
|
104
|
+
* in a controlled mode and should be used along with `onChange`
|
|
105
|
+
*/
|
|
106
|
+
selectedIndex?: number;
|
|
107
|
+
}
|
|
108
|
+
declare function TabsVertical({ children, height, defaultSelectedIndex, onChange, selectedIndex: controlledSelectedIndex, ...rest }: TabsVerticalProps): import("react/jsx-runtime").JSX.Element;
|
|
109
|
+
declare namespace TabsVertical {
|
|
110
|
+
var propTypes: {
|
|
111
|
+
/**
|
|
112
|
+
* Provide child elements to be rendered inside the `TabsVertical`.
|
|
113
|
+
* These elements should render either `TabsListVertical` or `TabsPanels`
|
|
114
|
+
*/
|
|
115
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
116
|
+
/**
|
|
117
|
+
* Specify which content tab should be initially selected when the component
|
|
118
|
+
* is first rendered
|
|
119
|
+
*/
|
|
120
|
+
defaultSelectedIndex: PropTypes.Requireable<number>;
|
|
121
|
+
/**
|
|
122
|
+
* Option to set a height style only if using vertical variation
|
|
123
|
+
*/
|
|
124
|
+
height: PropTypes.Requireable<string>;
|
|
125
|
+
/**
|
|
126
|
+
* Provide an optional function which is called whenever the state of the
|
|
127
|
+
* `Tabs` changes
|
|
128
|
+
*/
|
|
129
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
130
|
+
/**
|
|
131
|
+
* Control which content panel is currently selected. This puts the component
|
|
132
|
+
* in a controlled mode and should be used along with `onChange`
|
|
133
|
+
*/
|
|
134
|
+
selectedIndex: PropTypes.Requireable<number>;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
80
137
|
/**
|
|
81
138
|
* TabList
|
|
82
139
|
*/
|
|
@@ -195,6 +252,59 @@ declare namespace TabList {
|
|
|
195
252
|
scrollIntoView: PropTypes.Requireable<boolean>;
|
|
196
253
|
};
|
|
197
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* TabListVertical
|
|
257
|
+
*/
|
|
258
|
+
export interface TabListVerticalProps extends DivAttributes {
|
|
259
|
+
/**
|
|
260
|
+
* Specify whether the content tab should be activated automatically or
|
|
261
|
+
* manually
|
|
262
|
+
*/
|
|
263
|
+
activation?: 'automatic' | 'manual';
|
|
264
|
+
/**
|
|
265
|
+
* Provide an accessible label to be read when a user interacts with this
|
|
266
|
+
* component
|
|
267
|
+
*/
|
|
268
|
+
'aria-label': string;
|
|
269
|
+
/**
|
|
270
|
+
* Provide child elements to be rendered inside `ContentTabs`.
|
|
271
|
+
* These elements should render a `ContentTab`
|
|
272
|
+
*/
|
|
273
|
+
children?: ReactNode;
|
|
274
|
+
/**
|
|
275
|
+
* Specify an optional className to be added to the container node
|
|
276
|
+
*/
|
|
277
|
+
className?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Choose whether to automatically scroll to newly selected tabs
|
|
280
|
+
* on component rerender
|
|
281
|
+
*/
|
|
282
|
+
scrollIntoView?: boolean;
|
|
283
|
+
}
|
|
284
|
+
declare function TabListVertical({ activation, 'aria-label': label, children, className: customClassName, scrollIntoView, ...rest }: TabListVerticalProps): import("react/jsx-runtime").JSX.Element;
|
|
285
|
+
declare namespace TabListVertical {
|
|
286
|
+
var propTypes: {
|
|
287
|
+
/**
|
|
288
|
+
* Specify whether the content tab should be activated automatically or
|
|
289
|
+
* manually
|
|
290
|
+
*/
|
|
291
|
+
activation: PropTypes.Requireable<string>;
|
|
292
|
+
/**
|
|
293
|
+
* Provide an accessible label to be read when a user interacts with this
|
|
294
|
+
* component
|
|
295
|
+
*/
|
|
296
|
+
'aria-label': PropTypes.Validator<string>;
|
|
297
|
+
/**
|
|
298
|
+
* Provide child elements to be rendered inside `ContentTabs`.
|
|
299
|
+
* These elements should render a `ContentTab`
|
|
300
|
+
*/
|
|
301
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
302
|
+
/**
|
|
303
|
+
* Specify an optional className to be added to the container node
|
|
304
|
+
*/
|
|
305
|
+
className: PropTypes.Requireable<string>;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
198
308
|
/**
|
|
199
309
|
* Tab
|
|
200
310
|
*/
|
|
@@ -308,4 +418,4 @@ declare namespace TabPanels {
|
|
|
308
418
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
309
419
|
};
|
|
310
420
|
}
|
|
311
|
-
export { Tabs, Tab, IconTab, TabPanel, TabPanels, TabList };
|
|
421
|
+
export { Tabs, TabsVertical, Tab, IconTab, TabPanel, TabPanels, TabList, TabListVertical, };
|