@carbon/react 1.69.0-rc.0 → 1.69.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 +789 -789
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/Grid/CSSGrid.js +8 -1
- package/es/components/Grid/Grid.js +4 -0
- package/es/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/es/components/ListBox/next/ListBoxSelection.js +12 -5
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/es/components/Tabs/Tabs.js +46 -20
- package/es/components/Tag/SelectableTag.d.ts +17 -1
- package/es/components/Tag/SelectableTag.js +21 -13
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/Grid/CSSGrid.js +8 -1
- package/lib/components/Grid/Grid.js +4 -0
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/lib/components/ListBox/next/ListBoxSelection.js +12 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/lib/components/Tabs/Tabs.js +46 -20
- package/lib/components/Tag/SelectableTag.d.ts +17 -1
- package/lib/components/Tag/SelectableTag.js +21 -13
- package/package.json +10 -9
|
@@ -14,6 +14,7 @@ import { useGridSettings, GridSettings } from './GridContext.js';
|
|
|
14
14
|
|
|
15
15
|
function CSSGrid(_ref) {
|
|
16
16
|
let {
|
|
17
|
+
align,
|
|
17
18
|
as: BaseComponent = 'div',
|
|
18
19
|
children,
|
|
19
20
|
className: customClassName,
|
|
@@ -46,7 +47,9 @@ function CSSGrid(_ref) {
|
|
|
46
47
|
[`${prefix}--css-grid`]: true,
|
|
47
48
|
[`${prefix}--css-grid--condensed`]: mode === 'condensed',
|
|
48
49
|
[`${prefix}--css-grid--narrow`]: mode === 'narrow',
|
|
49
|
-
[`${prefix}--css-grid--full-width`]: fullWidth
|
|
50
|
+
[`${prefix}--css-grid--full-width`]: fullWidth,
|
|
51
|
+
[`${prefix}--css-grid--start`]: align === 'start',
|
|
52
|
+
[`${prefix}--css-grid--end`]: align === 'end'
|
|
50
53
|
});
|
|
51
54
|
|
|
52
55
|
// cast as any to let TypeScript allow passing in attributes to base component
|
|
@@ -59,6 +62,10 @@ function CSSGrid(_ref) {
|
|
|
59
62
|
}, rest), children));
|
|
60
63
|
}
|
|
61
64
|
CSSGrid.propTypes = {
|
|
65
|
+
/**
|
|
66
|
+
* Specify grid aligment. Default is center
|
|
67
|
+
*/
|
|
68
|
+
align: PropTypes.oneOf(['start', 'center', 'end']),
|
|
62
69
|
/**
|
|
63
70
|
* Provide a custom element to render instead of the default <div>
|
|
64
71
|
*/
|
|
@@ -19,6 +19,10 @@ function Grid(props) {
|
|
|
19
19
|
return /*#__PURE__*/React__default.createElement(FlexGridComponent, props);
|
|
20
20
|
}
|
|
21
21
|
Grid.propTypes = {
|
|
22
|
+
/**
|
|
23
|
+
* Specify grid aligment. Default is center
|
|
24
|
+
*/
|
|
25
|
+
align: PropTypes.oneOf(['start', 'center', 'end']),
|
|
22
26
|
/**
|
|
23
27
|
* Provide a custom element to render instead of the default <div>
|
|
24
28
|
*/
|
|
@@ -37,6 +37,10 @@ export interface ListBoxSelectionProps {
|
|
|
37
37
|
* Specify whether or not the clear selection element should be disabled
|
|
38
38
|
*/
|
|
39
39
|
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether or not the listbox is readonly
|
|
42
|
+
*/
|
|
43
|
+
readOnly?: boolean;
|
|
40
44
|
/**
|
|
41
45
|
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
42
46
|
* element is cleared
|
|
@@ -58,7 +62,7 @@ export interface ListBoxSelectionProps {
|
|
|
58
62
|
*/
|
|
59
63
|
onMouseUp?: React.MouseEventHandler<HTMLButtonElement>;
|
|
60
64
|
}
|
|
61
|
-
declare function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t, disabled, onClearSelection, ...rest }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
declare function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t, disabled, readOnly, onClearSelection, ...rest }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element;
|
|
62
66
|
declare namespace ListBoxSelection {
|
|
63
67
|
var propTypes: {
|
|
64
68
|
/**
|
|
@@ -70,6 +74,10 @@ declare namespace ListBoxSelection {
|
|
|
70
74
|
* Specify whether or not the clear selection element should be disabled
|
|
71
75
|
*/
|
|
72
76
|
disabled: PropTypes.Requireable<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Whether or not the listbox is readonly
|
|
79
|
+
*/
|
|
80
|
+
readOnly: PropTypes.Requireable<boolean>;
|
|
73
81
|
/**
|
|
74
82
|
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
75
83
|
* element is cleared
|
|
@@ -26,6 +26,7 @@ function ListBoxSelection(_ref) {
|
|
|
26
26
|
selectionCount,
|
|
27
27
|
translateWithId: t = defaultTranslateWithId,
|
|
28
28
|
disabled,
|
|
29
|
+
readOnly,
|
|
29
30
|
onClearSelection,
|
|
30
31
|
...rest
|
|
31
32
|
} = _ref;
|
|
@@ -40,7 +41,7 @@ function ListBoxSelection(_ref) {
|
|
|
40
41
|
});
|
|
41
42
|
function onClick(event) {
|
|
42
43
|
event.stopPropagation();
|
|
43
|
-
if (disabled) {
|
|
44
|
+
if (disabled || readOnly) {
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
clearSelection(event);
|
|
@@ -57,21 +58,23 @@ function ListBoxSelection(_ref) {
|
|
|
57
58
|
}, selectionCount), /*#__PURE__*/React__default.createElement("button", {
|
|
58
59
|
"aria-label": description,
|
|
59
60
|
className: `${prefix}--tag__close-icon`,
|
|
60
|
-
disabled: disabled,
|
|
61
|
+
disabled: disabled || readOnly,
|
|
61
62
|
onClick: onClick,
|
|
62
63
|
tabIndex: -1,
|
|
63
64
|
title: description,
|
|
64
|
-
type: "button"
|
|
65
|
+
type: "button",
|
|
66
|
+
"aria-disabled": readOnly ? true : undefined
|
|
65
67
|
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null))));
|
|
66
68
|
}
|
|
67
69
|
return /*#__PURE__*/React__default.createElement("button", _extends({}, rest, {
|
|
68
70
|
"aria-label": description,
|
|
69
71
|
className: className,
|
|
70
|
-
disabled: disabled,
|
|
72
|
+
disabled: disabled || readOnly,
|
|
71
73
|
onClick: onClick,
|
|
72
74
|
tabIndex: -1,
|
|
73
75
|
title: description,
|
|
74
|
-
type: "button"
|
|
76
|
+
type: "button",
|
|
77
|
+
"aria-disabled": readOnly ? true : undefined
|
|
75
78
|
}), _Close2 || (_Close2 = /*#__PURE__*/React__default.createElement(Close, null)));
|
|
76
79
|
}
|
|
77
80
|
ListBoxSelection.propTypes = {
|
|
@@ -84,6 +87,10 @@ ListBoxSelection.propTypes = {
|
|
|
84
87
|
* Specify whether or not the clear selection element should be disabled
|
|
85
88
|
*/
|
|
86
89
|
disabled: PropTypes.bool,
|
|
90
|
+
/**
|
|
91
|
+
* Whether or not the listbox is readonly
|
|
92
|
+
*/
|
|
93
|
+
readOnly: PropTypes.bool,
|
|
87
94
|
/**
|
|
88
95
|
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
89
96
|
* element is cleared
|
|
@@ -143,6 +143,10 @@ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSorting
|
|
|
143
143
|
* what this field is for
|
|
144
144
|
*/
|
|
145
145
|
placeholder?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Whether or not the filterable multiselect is readonly
|
|
148
|
+
*/
|
|
149
|
+
readOnly?: boolean;
|
|
146
150
|
/**
|
|
147
151
|
* Specify feedback (mode) of the selection.
|
|
148
152
|
* `top`: selected item jumps to top
|
|
@@ -90,6 +90,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
90
90
|
onChange,
|
|
91
91
|
onMenuChange,
|
|
92
92
|
placeholder,
|
|
93
|
+
readOnly,
|
|
93
94
|
titleText,
|
|
94
95
|
type,
|
|
95
96
|
selectionFeedback = 'top-after-reopen',
|
|
@@ -232,9 +233,11 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
232
233
|
}
|
|
233
234
|
};
|
|
234
235
|
function handleMenuChange(forceIsOpen) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
if (!readOnly) {
|
|
237
|
+
const nextIsOpen = forceIsOpen ?? !isOpen;
|
|
238
|
+
setIsOpen(nextIsOpen);
|
|
239
|
+
validateHighlightFocus();
|
|
240
|
+
}
|
|
238
241
|
}
|
|
239
242
|
useEffect(() => {
|
|
240
243
|
onMenuChange?.(isOpen);
|
|
@@ -423,7 +426,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
423
426
|
[`${prefix}--multi-select--open`]: isOpen,
|
|
424
427
|
[`${prefix}--multi-select--inline`]: inline,
|
|
425
428
|
[`${prefix}--multi-select--selected`]: controlledSelectedItems?.length > 0,
|
|
426
|
-
[`${prefix}--multi-select--filterable--input-focused`]: inputFocused
|
|
429
|
+
[`${prefix}--multi-select--filterable--input-focused`]: inputFocused,
|
|
430
|
+
[`${prefix}--multi-select--readonly`]: readOnly
|
|
427
431
|
});
|
|
428
432
|
const labelProps = getLabelProps();
|
|
429
433
|
const buttonProps = getToggleButtonProps({
|
|
@@ -510,6 +514,24 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
510
514
|
setIsFocused(evt?.type === 'focus' ? true : false);
|
|
511
515
|
}
|
|
512
516
|
};
|
|
517
|
+
const mergedRef = mergeRefs(textInput, inputProps.ref);
|
|
518
|
+
const readOnlyEventHandlers = readOnly ? {
|
|
519
|
+
onClick: evt => {
|
|
520
|
+
// NOTE: does not prevent click
|
|
521
|
+
evt.preventDefault();
|
|
522
|
+
// focus on the element as per readonly input behavior
|
|
523
|
+
if (mergedRef.current !== undefined) {
|
|
524
|
+
mergedRef.current.focus();
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
onKeyDown: evt => {
|
|
528
|
+
const selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter'];
|
|
529
|
+
// This prevents the select from opening for the above keys
|
|
530
|
+
if (selectAccessKeys.includes(evt.key)) {
|
|
531
|
+
evt.preventDefault();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
} : {};
|
|
513
535
|
const clearSelectionContent = controlledSelectedItems.length > 0 ? /*#__PURE__*/React__default.createElement("span", {
|
|
514
536
|
className: `${prefix}--visually-hidden`
|
|
515
537
|
}, clearSelectionDescription, " ", controlledSelectedItems.length, ",", clearSelectionText) : /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -533,12 +555,13 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
533
555
|
invalidText: invalidText,
|
|
534
556
|
warn: warn,
|
|
535
557
|
warnText: warnText,
|
|
536
|
-
isOpen: isOpen,
|
|
558
|
+
isOpen: !readOnly && isOpen,
|
|
537
559
|
size: size$1
|
|
538
560
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
539
561
|
className: `${prefix}--list-box__field`,
|
|
540
562
|
ref: autoAlign ? refs.setReference : null
|
|
541
563
|
}, controlledSelectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBoxSelection, {
|
|
564
|
+
readOnly: readOnly,
|
|
542
565
|
clearSelection: () => {
|
|
543
566
|
clearSelection();
|
|
544
567
|
if (textInput.current) {
|
|
@@ -551,7 +574,9 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
551
574
|
}), /*#__PURE__*/React__default.createElement("input", _extends({
|
|
552
575
|
className: inputClasses
|
|
553
576
|
}, inputProps, {
|
|
554
|
-
ref:
|
|
577
|
+
ref: mergedRef
|
|
578
|
+
}, readOnlyEventHandlers, {
|
|
579
|
+
readOnly: readOnly
|
|
555
580
|
})), invalid && /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
556
581
|
className: `${prefix}--list-box__invalid-icon`
|
|
557
582
|
}), showWarning && /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
@@ -560,6 +585,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
560
585
|
clearSelection: clearInputValue,
|
|
561
586
|
disabled: disabled,
|
|
562
587
|
translateWithId: translateWithId,
|
|
588
|
+
readOnly: readOnly,
|
|
563
589
|
onMouseUp: event => {
|
|
564
590
|
// If we do not stop this event from propagating,
|
|
565
591
|
// it seems like Downshift takes our event and
|
|
@@ -322,8 +322,8 @@ function TabList(_ref4) {
|
|
|
322
322
|
function onKeyDown(event) {
|
|
323
323
|
if (matches(event, [ArrowRight, ArrowLeft, Home, End])) {
|
|
324
324
|
event.preventDefault();
|
|
325
|
-
const
|
|
326
|
-
const activeTabs =
|
|
325
|
+
const filteredTabs = tabs.current.filter(tab => tab !== null);
|
|
326
|
+
const activeTabs = filteredTabs.filter(tab => !tab.disabled);
|
|
327
327
|
const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
|
|
328
328
|
const nextIndex = tabs.current.indexOf(activeTabs[getNextIndex(event, activeTabs.length, currentIndex)]);
|
|
329
329
|
if (activation === 'automatic') {
|
|
@@ -334,6 +334,18 @@ function TabList(_ref4) {
|
|
|
334
334
|
tabs.current[nextIndex]?.focus();
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
+
function handleBlur(_ref5) {
|
|
338
|
+
let {
|
|
339
|
+
relatedTarget: currentActiveNode
|
|
340
|
+
} = _ref5;
|
|
341
|
+
if (ref.current?.contains(currentActiveNode)) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
// reset active index to selected tab index for manual activation
|
|
345
|
+
if (activation === 'manual') {
|
|
346
|
+
setActiveIndex(selectedIndex);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
337
349
|
useEffectOnce(() => {
|
|
338
350
|
const tab = tabs.current[selectedIndex];
|
|
339
351
|
if (scrollIntoView && tab) {
|
|
@@ -419,10 +431,10 @@ function TabList(_ref4) {
|
|
|
419
431
|
}
|
|
420
432
|
}, [activation, activeIndex, selectedIndex, isScrollable, children]);
|
|
421
433
|
usePressable(previousButton, {
|
|
422
|
-
onPress(
|
|
434
|
+
onPress(_ref6) {
|
|
423
435
|
let {
|
|
424
436
|
longPress
|
|
425
|
-
} =
|
|
437
|
+
} = _ref6;
|
|
426
438
|
if (!longPress && ref.current) {
|
|
427
439
|
setScrollLeft(Math.max(scrollLeft - ref.current.scrollWidth / tabs.current.length * 1.5, 0));
|
|
428
440
|
}
|
|
@@ -432,10 +444,10 @@ function TabList(_ref4) {
|
|
|
432
444
|
}
|
|
433
445
|
});
|
|
434
446
|
usePressable(nextButton, {
|
|
435
|
-
onPress(
|
|
447
|
+
onPress(_ref7) {
|
|
436
448
|
let {
|
|
437
449
|
longPress
|
|
438
|
-
} =
|
|
450
|
+
} = _ref7;
|
|
439
451
|
if (!longPress && ref.current) {
|
|
440
452
|
setScrollLeft(Math.min(scrollLeft + ref.current.scrollWidth / tabs.current.length * 1.5, ref.current.scrollWidth - ref.current.clientWidth));
|
|
441
453
|
}
|
|
@@ -459,7 +471,8 @@ function TabList(_ref4) {
|
|
|
459
471
|
role: "tablist",
|
|
460
472
|
className: `${prefix}--tab--list`,
|
|
461
473
|
onScroll: debouncedOnScroll,
|
|
462
|
-
onKeyDown: onKeyDown
|
|
474
|
+
onKeyDown: onKeyDown,
|
|
475
|
+
onBlur: handleBlur
|
|
463
476
|
}), React__default.Children.map(children, (child, index) => {
|
|
464
477
|
return !isElement(child) ? null : /*#__PURE__*/React__default.createElement(TabContext.Provider, {
|
|
465
478
|
value: {
|
|
@@ -544,7 +557,7 @@ TabList.propTypes = {
|
|
|
544
557
|
|
|
545
558
|
// type TabElement = HTMLElement & { disabled?: boolean };
|
|
546
559
|
|
|
547
|
-
function TabListVertical(
|
|
560
|
+
function TabListVertical(_ref8) {
|
|
548
561
|
let {
|
|
549
562
|
activation = 'automatic',
|
|
550
563
|
'aria-label': label,
|
|
@@ -552,7 +565,7 @@ function TabListVertical(_ref7) {
|
|
|
552
565
|
className: customClassName,
|
|
553
566
|
scrollIntoView,
|
|
554
567
|
...rest
|
|
555
|
-
} =
|
|
568
|
+
} = _ref8;
|
|
556
569
|
const {
|
|
557
570
|
activeIndex,
|
|
558
571
|
selectedIndex,
|
|
@@ -569,8 +582,8 @@ function TabListVertical(_ref7) {
|
|
|
569
582
|
function onKeyDown(event) {
|
|
570
583
|
if (matches(event, [ArrowDown, ArrowUp, Home, End])) {
|
|
571
584
|
event.preventDefault();
|
|
572
|
-
const
|
|
573
|
-
const activeTabs =
|
|
585
|
+
const filteredTabs = tabs.current.filter(tab => tab !== null);
|
|
586
|
+
const activeTabs = filteredTabs.filter(tab => !tab.disabled);
|
|
574
587
|
const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
|
|
575
588
|
const nextIndex = tabs.current.indexOf(activeTabs[getNextIndexVertical(event, activeTabs.length, currentIndex)]);
|
|
576
589
|
if (activation === 'automatic') {
|
|
@@ -581,6 +594,18 @@ function TabListVertical(_ref7) {
|
|
|
581
594
|
tabs.current[nextIndex]?.focus();
|
|
582
595
|
}
|
|
583
596
|
}
|
|
597
|
+
function handleBlur(_ref9) {
|
|
598
|
+
let {
|
|
599
|
+
relatedTarget: currentActiveNode
|
|
600
|
+
} = _ref9;
|
|
601
|
+
if (ref.current?.contains(currentActiveNode)) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
// reset active index to selected tab index for manual activation
|
|
605
|
+
if (activation === 'manual') {
|
|
606
|
+
setActiveIndex(selectedIndex);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
584
609
|
useEffectOnce(() => {
|
|
585
610
|
if (tabs.current[selectedIndex]?.disabled) {
|
|
586
611
|
const activeTabs = tabs.current.filter(tab => {
|
|
@@ -647,7 +672,8 @@ function TabListVertical(_ref7) {
|
|
|
647
672
|
ref: ref,
|
|
648
673
|
role: "tablist",
|
|
649
674
|
className: `${prefix}--tab--list`,
|
|
650
|
-
onKeyDown: onKeyDown
|
|
675
|
+
onKeyDown: onKeyDown,
|
|
676
|
+
onBlur: handleBlur
|
|
651
677
|
}), React__default.Children.map(children, (child, index) => {
|
|
652
678
|
return !isElement(child) ? null : /*#__PURE__*/React__default.createElement(TabContext.Provider, {
|
|
653
679
|
value: {
|
|
@@ -730,7 +756,7 @@ function createLongPressBehavior(ref, direction, setScrollLeft) {
|
|
|
730
756
|
* Tab
|
|
731
757
|
*/
|
|
732
758
|
|
|
733
|
-
const Tab = /*#__PURE__*/forwardRef(function Tab(
|
|
759
|
+
const Tab = /*#__PURE__*/forwardRef(function Tab(_ref10, forwardRef) {
|
|
734
760
|
let {
|
|
735
761
|
as = 'button',
|
|
736
762
|
children,
|
|
@@ -741,7 +767,7 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref8, forwardRef) {
|
|
|
741
767
|
secondaryLabel,
|
|
742
768
|
renderIcon: Icon,
|
|
743
769
|
...rest
|
|
744
|
-
} =
|
|
770
|
+
} = _ref10;
|
|
745
771
|
const prefix = usePrefix();
|
|
746
772
|
const {
|
|
747
773
|
selectedIndex,
|
|
@@ -983,7 +1009,7 @@ Tab.propTypes = {
|
|
|
983
1009
|
* IconTab
|
|
984
1010
|
*/
|
|
985
1011
|
|
|
986
|
-
const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(
|
|
1012
|
+
const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref11, ref) {
|
|
987
1013
|
let {
|
|
988
1014
|
children,
|
|
989
1015
|
className: customClassName,
|
|
@@ -992,7 +1018,7 @@ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref9, r
|
|
|
992
1018
|
leaveDelayMs,
|
|
993
1019
|
label,
|
|
994
1020
|
...rest
|
|
995
|
-
} =
|
|
1021
|
+
} = _ref11;
|
|
996
1022
|
const prefix = usePrefix();
|
|
997
1023
|
const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName);
|
|
998
1024
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
@@ -1041,12 +1067,12 @@ IconTab.propTypes = {
|
|
|
1041
1067
|
* TabPanel
|
|
1042
1068
|
*/
|
|
1043
1069
|
|
|
1044
|
-
const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(
|
|
1070
|
+
const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref12, forwardRef) {
|
|
1045
1071
|
let {
|
|
1046
1072
|
children,
|
|
1047
1073
|
className: customClassName,
|
|
1048
1074
|
...rest
|
|
1049
|
-
} =
|
|
1075
|
+
} = _ref12;
|
|
1050
1076
|
const prefix = usePrefix();
|
|
1051
1077
|
const panel = useRef(null);
|
|
1052
1078
|
const ref = useMergedRefs([forwardRef, panel]);
|
|
@@ -1121,10 +1147,10 @@ TabPanel.propTypes = {
|
|
|
1121
1147
|
* TabPanels
|
|
1122
1148
|
*/
|
|
1123
1149
|
|
|
1124
|
-
function TabPanels(
|
|
1150
|
+
function TabPanels(_ref13) {
|
|
1125
1151
|
let {
|
|
1126
1152
|
children
|
|
1127
|
-
} =
|
|
1153
|
+
} = _ref13;
|
|
1128
1154
|
const prefix = usePrefix();
|
|
1129
1155
|
const refs = useRef([]);
|
|
1130
1156
|
const hiddenStates = useRef([]);
|
|
@@ -26,6 +26,14 @@ export interface SelectableTagBaseProps {
|
|
|
26
26
|
* Can be a React component class
|
|
27
27
|
*/
|
|
28
28
|
renderIcon?: React.ElementType;
|
|
29
|
+
/**
|
|
30
|
+
* Provide an optional hook that is called when selected is changed
|
|
31
|
+
*/
|
|
32
|
+
onChange?: (selected: boolean) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Provide an optional function to be called when the tag is clicked.
|
|
35
|
+
*/
|
|
36
|
+
onClick?: (e: Event) => void;
|
|
29
37
|
/**
|
|
30
38
|
* Specify the state of the selectable tag.
|
|
31
39
|
*/
|
|
@@ -42,7 +50,7 @@ export interface SelectableTagBaseProps {
|
|
|
42
50
|
}
|
|
43
51
|
export type SelectableTagProps<T extends React.ElementType> = PolymorphicProps<T, SelectableTagBaseProps>;
|
|
44
52
|
declare const SelectableTag: {
|
|
45
|
-
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, selected, size, text, ...other }: SelectableTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, onChange, onClick, selected, size, text, ...other }: SelectableTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
46
54
|
propTypes: {
|
|
47
55
|
/**
|
|
48
56
|
* Provide a custom className that is applied to the containing <span>
|
|
@@ -61,6 +69,14 @@ declare const SelectableTag: {
|
|
|
61
69
|
* Can be a React component class
|
|
62
70
|
*/
|
|
63
71
|
renderIcon: PropTypes.Requireable<object>;
|
|
72
|
+
/**
|
|
73
|
+
* Provide an optional hook that is called when selected is changed
|
|
74
|
+
*/
|
|
75
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
76
|
+
/**
|
|
77
|
+
* Provide an optional function to be called when the tag is clicked.
|
|
78
|
+
*/
|
|
79
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
64
80
|
/**
|
|
65
81
|
* Specify the state of the selectable tag.
|
|
66
82
|
*/
|
|
@@ -24,6 +24,8 @@ const SelectableTag = _ref => {
|
|
|
24
24
|
disabled,
|
|
25
25
|
id,
|
|
26
26
|
renderIcon,
|
|
27
|
+
onChange,
|
|
28
|
+
onClick,
|
|
27
29
|
selected = false,
|
|
28
30
|
size,
|
|
29
31
|
text,
|
|
@@ -42,13 +44,11 @@ const SelectableTag = _ref => {
|
|
|
42
44
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
43
45
|
}, [prefix, tagRef]);
|
|
44
46
|
const tooltipClasses = cx(`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
...otherProps
|
|
51
|
-
} = other;
|
|
47
|
+
const handleClick = e => {
|
|
48
|
+
setSelectedTag(!selectedTag);
|
|
49
|
+
onChange?.(!selectedTag);
|
|
50
|
+
onClick?.(e);
|
|
51
|
+
};
|
|
52
52
|
if (isEllipsisApplied) {
|
|
53
53
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
54
54
|
label: text,
|
|
@@ -57,29 +57,29 @@ const SelectableTag = _ref => {
|
|
|
57
57
|
leaveDelayMs: 0,
|
|
58
58
|
onMouseEnter: () => false
|
|
59
59
|
}, /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
60
|
-
"aria-pressed": selectedTag,
|
|
60
|
+
"aria-pressed": selectedTag !== false,
|
|
61
61
|
ref: tagRef,
|
|
62
62
|
size: size,
|
|
63
63
|
renderIcon: renderIcon,
|
|
64
64
|
disabled: disabled,
|
|
65
65
|
className: tagClasses,
|
|
66
66
|
id: tagId,
|
|
67
|
-
onClick:
|
|
68
|
-
},
|
|
67
|
+
onClick: handleClick
|
|
68
|
+
}, other), /*#__PURE__*/React__default.createElement(Text, {
|
|
69
69
|
title: text,
|
|
70
70
|
className: `${prefix}--tag__label`
|
|
71
71
|
}, text)));
|
|
72
72
|
}
|
|
73
73
|
return /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
74
|
-
"aria-pressed": selectedTag,
|
|
74
|
+
"aria-pressed": selectedTag !== false,
|
|
75
75
|
ref: tagRef,
|
|
76
76
|
size: size,
|
|
77
77
|
renderIcon: renderIcon,
|
|
78
78
|
disabled: disabled,
|
|
79
79
|
className: tagClasses,
|
|
80
80
|
id: tagId,
|
|
81
|
-
onClick:
|
|
82
|
-
},
|
|
81
|
+
onClick: handleClick
|
|
82
|
+
}, other), /*#__PURE__*/React__default.createElement(Text, {
|
|
83
83
|
title: text,
|
|
84
84
|
className: `${prefix}--tag__label`
|
|
85
85
|
}, text));
|
|
@@ -102,6 +102,14 @@ SelectableTag.propTypes = {
|
|
|
102
102
|
* Can be a React component class
|
|
103
103
|
*/
|
|
104
104
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
105
|
+
/**
|
|
106
|
+
* Provide an optional hook that is called when selected is changed
|
|
107
|
+
*/
|
|
108
|
+
onChange: PropTypes.func,
|
|
109
|
+
/**
|
|
110
|
+
* Provide an optional function to be called when the tag is clicked.
|
|
111
|
+
*/
|
|
112
|
+
onClick: PropTypes.func,
|
|
105
113
|
/**
|
|
106
114
|
* Specify the state of the selectable tag.
|
|
107
115
|
*/
|
|
@@ -24,6 +24,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
24
24
|
|
|
25
25
|
function CSSGrid(_ref) {
|
|
26
26
|
let {
|
|
27
|
+
align,
|
|
27
28
|
as: BaseComponent = 'div',
|
|
28
29
|
children,
|
|
29
30
|
className: customClassName,
|
|
@@ -56,7 +57,9 @@ function CSSGrid(_ref) {
|
|
|
56
57
|
[`${prefix}--css-grid`]: true,
|
|
57
58
|
[`${prefix}--css-grid--condensed`]: mode === 'condensed',
|
|
58
59
|
[`${prefix}--css-grid--narrow`]: mode === 'narrow',
|
|
59
|
-
[`${prefix}--css-grid--full-width`]: fullWidth
|
|
60
|
+
[`${prefix}--css-grid--full-width`]: fullWidth,
|
|
61
|
+
[`${prefix}--css-grid--start`]: align === 'start',
|
|
62
|
+
[`${prefix}--css-grid--end`]: align === 'end'
|
|
60
63
|
});
|
|
61
64
|
|
|
62
65
|
// cast as any to let TypeScript allow passing in attributes to base component
|
|
@@ -69,6 +72,10 @@ function CSSGrid(_ref) {
|
|
|
69
72
|
}, rest), children));
|
|
70
73
|
}
|
|
71
74
|
CSSGrid.propTypes = {
|
|
75
|
+
/**
|
|
76
|
+
* Specify grid aligment. Default is center
|
|
77
|
+
*/
|
|
78
|
+
align: PropTypes__default["default"].oneOf(['start', 'center', 'end']),
|
|
72
79
|
/**
|
|
73
80
|
* Provide a custom element to render instead of the default <div>
|
|
74
81
|
*/
|
|
@@ -28,6 +28,10 @@ function Grid(props) {
|
|
|
28
28
|
return /*#__PURE__*/React__default["default"].createElement(FlexGrid.FlexGrid, props);
|
|
29
29
|
}
|
|
30
30
|
Grid.propTypes = {
|
|
31
|
+
/**
|
|
32
|
+
* Specify grid aligment. Default is center
|
|
33
|
+
*/
|
|
34
|
+
align: PropTypes__default["default"].oneOf(['start', 'center', 'end']),
|
|
31
35
|
/**
|
|
32
36
|
* Provide a custom element to render instead of the default <div>
|
|
33
37
|
*/
|
|
@@ -37,6 +37,10 @@ export interface ListBoxSelectionProps {
|
|
|
37
37
|
* Specify whether or not the clear selection element should be disabled
|
|
38
38
|
*/
|
|
39
39
|
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether or not the listbox is readonly
|
|
42
|
+
*/
|
|
43
|
+
readOnly?: boolean;
|
|
40
44
|
/**
|
|
41
45
|
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
42
46
|
* element is cleared
|
|
@@ -58,7 +62,7 @@ export interface ListBoxSelectionProps {
|
|
|
58
62
|
*/
|
|
59
63
|
onMouseUp?: React.MouseEventHandler<HTMLButtonElement>;
|
|
60
64
|
}
|
|
61
|
-
declare function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t, disabled, onClearSelection, ...rest }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
declare function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t, disabled, readOnly, onClearSelection, ...rest }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element;
|
|
62
66
|
declare namespace ListBoxSelection {
|
|
63
67
|
var propTypes: {
|
|
64
68
|
/**
|
|
@@ -70,6 +74,10 @@ declare namespace ListBoxSelection {
|
|
|
70
74
|
* Specify whether or not the clear selection element should be disabled
|
|
71
75
|
*/
|
|
72
76
|
disabled: PropTypes.Requireable<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Whether or not the listbox is readonly
|
|
79
|
+
*/
|
|
80
|
+
readOnly: PropTypes.Requireable<boolean>;
|
|
73
81
|
/**
|
|
74
82
|
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
75
83
|
* element is cleared
|
|
@@ -36,6 +36,7 @@ function ListBoxSelection(_ref) {
|
|
|
36
36
|
selectionCount,
|
|
37
37
|
translateWithId: t = defaultTranslateWithId,
|
|
38
38
|
disabled,
|
|
39
|
+
readOnly,
|
|
39
40
|
onClearSelection,
|
|
40
41
|
...rest
|
|
41
42
|
} = _ref;
|
|
@@ -50,7 +51,7 @@ function ListBoxSelection(_ref) {
|
|
|
50
51
|
});
|
|
51
52
|
function onClick(event) {
|
|
52
53
|
event.stopPropagation();
|
|
53
|
-
if (disabled) {
|
|
54
|
+
if (disabled || readOnly) {
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
clearSelection(event);
|
|
@@ -67,21 +68,23 @@ function ListBoxSelection(_ref) {
|
|
|
67
68
|
}, selectionCount), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
68
69
|
"aria-label": description,
|
|
69
70
|
className: `${prefix}--tag__close-icon`,
|
|
70
|
-
disabled: disabled,
|
|
71
|
+
disabled: disabled || readOnly,
|
|
71
72
|
onClick: onClick,
|
|
72
73
|
tabIndex: -1,
|
|
73
74
|
title: description,
|
|
74
|
-
type: "button"
|
|
75
|
+
type: "button",
|
|
76
|
+
"aria-disabled": readOnly ? true : undefined
|
|
75
77
|
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))));
|
|
76
78
|
}
|
|
77
79
|
return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
78
80
|
"aria-label": description,
|
|
79
81
|
className: className,
|
|
80
|
-
disabled: disabled,
|
|
82
|
+
disabled: disabled || readOnly,
|
|
81
83
|
onClick: onClick,
|
|
82
84
|
tabIndex: -1,
|
|
83
85
|
title: description,
|
|
84
|
-
type: "button"
|
|
86
|
+
type: "button",
|
|
87
|
+
"aria-disabled": readOnly ? true : undefined
|
|
85
88
|
}), _Close2 || (_Close2 = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null)));
|
|
86
89
|
}
|
|
87
90
|
ListBoxSelection.propTypes = {
|
|
@@ -94,6 +97,10 @@ ListBoxSelection.propTypes = {
|
|
|
94
97
|
* Specify whether or not the clear selection element should be disabled
|
|
95
98
|
*/
|
|
96
99
|
disabled: PropTypes__default["default"].bool,
|
|
100
|
+
/**
|
|
101
|
+
* Whether or not the listbox is readonly
|
|
102
|
+
*/
|
|
103
|
+
readOnly: PropTypes__default["default"].bool,
|
|
97
104
|
/**
|
|
98
105
|
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
99
106
|
* element is cleared
|