@carbon/react 1.68.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 +871 -871
- package/README.md +3 -3
- package/es/components/Accordion/AccordionItem.js +0 -1
- package/es/components/Button/Button.js +6 -0
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/es/components/CheckboxGroup/index.d.ts +10 -0
- package/es/components/ComboBox/ComboBox.js +13 -18
- package/es/components/ComboButton/index.js +10 -3
- package/es/components/DataTable/TableCell.d.ts +1 -4
- package/es/components/DataTable/TableCell.js +3 -2
- package/es/components/Disclosure/index.d.ts +18 -0
- package/es/components/Dropdown/Dropdown.js +11 -9
- package/es/components/FileUploader/FileUploader.d.ts +8 -92
- package/es/components/FileUploader/FileUploader.js +116 -137
- package/es/components/Grid/CSSGrid.js +8 -1
- package/es/components/Grid/Grid.js +4 -0
- package/es/components/IdPrefix/index.d.ts +26 -0
- package/es/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/es/components/ListBox/next/ListBoxSelection.js +12 -5
- package/es/components/Menu/MenuItem.js +1 -4
- package/es/components/MenuButton/index.d.ts +4 -0
- package/es/components/MenuButton/index.js +19 -5
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/es/components/MultiSelect/MultiSelect.js +11 -9
- package/es/components/OverflowMenu/next/index.d.ts +4 -0
- package/es/components/OverflowMenu/next/index.js +19 -9
- package/es/components/PaginationNav/PaginationNav.js +1 -1
- package/es/components/Popover/index.js +18 -14
- package/es/components/Portal/index.d.ts +25 -0
- package/es/components/Slider/Slider.js +2 -2
- package/es/components/Tabs/Tabs.js +46 -20
- package/es/components/Tag/DismissibleTag.js +2 -2
- package/es/components/Tag/OperationalTag.d.ts +2 -10
- package/es/components/Tag/OperationalTag.js +2 -14
- package/es/components/Tag/SelectableTag.d.ts +18 -10
- package/es/components/Tag/SelectableTag.js +22 -28
- package/es/components/Toggle/Toggle.js +2 -0
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/es/components/ToggleSmall/index.d.ts +7 -0
- package/es/components/TreeView/TreeNode.js +4 -2
- package/es/components/TreeView/TreeView.js +4 -4
- package/es/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/es/components/UIShell/SideNavMenuItem.js +1 -4
- package/es/index.js +1 -1
- package/es/internal/useIdPrefix.d.ts +9 -0
- package/lib/components/Accordion/AccordionItem.js +0 -1
- package/lib/components/Button/Button.js +6 -0
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/lib/components/CheckboxGroup/index.d.ts +10 -0
- package/lib/components/ComboBox/ComboBox.js +18 -23
- package/lib/components/ComboButton/index.js +12 -5
- package/lib/components/DataTable/TableCell.d.ts +1 -4
- package/lib/components/DataTable/TableCell.js +3 -2
- package/lib/components/Disclosure/index.d.ts +18 -0
- package/lib/components/Dropdown/Dropdown.js +18 -16
- package/lib/components/FileUploader/FileUploader.d.ts +8 -92
- package/lib/components/FileUploader/FileUploader.js +113 -134
- package/lib/components/Grid/CSSGrid.js +8 -1
- package/lib/components/Grid/Grid.js +4 -0
- package/lib/components/IdPrefix/index.d.ts +26 -0
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/lib/components/ListBox/next/ListBoxSelection.js +12 -5
- package/lib/components/Menu/MenuItem.js +1 -4
- package/lib/components/MenuButton/index.d.ts +4 -0
- package/lib/components/MenuButton/index.js +19 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/lib/components/MultiSelect/MultiSelect.js +18 -16
- package/lib/components/OverflowMenu/next/index.d.ts +4 -0
- package/lib/components/OverflowMenu/next/index.js +21 -11
- package/lib/components/PaginationNav/PaginationNav.js +1 -1
- package/lib/components/Popover/index.js +18 -14
- package/lib/components/Portal/index.d.ts +25 -0
- package/lib/components/Slider/Slider.js +2 -2
- package/lib/components/Tabs/Tabs.js +46 -20
- package/lib/components/Tag/DismissibleTag.js +2 -2
- package/lib/components/Tag/OperationalTag.d.ts +2 -10
- package/lib/components/Tag/OperationalTag.js +2 -14
- package/lib/components/Tag/SelectableTag.d.ts +18 -10
- package/lib/components/Tag/SelectableTag.js +22 -28
- package/lib/components/Toggle/Toggle.js +2 -0
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/lib/components/ToggleSmall/index.d.ts +7 -0
- package/lib/components/TreeView/TreeNode.js +4 -2
- package/lib/components/TreeView/TreeView.js +4 -4
- package/lib/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/lib/components/UIShell/SideNavMenuItem.js +1 -4
- package/lib/index.js +2 -2
- package/lib/internal/useIdPrefix.d.ts +9 -0
- package/package.json +10 -9
- package/telemetry.yml +809 -809
|
@@ -1114,7 +1114,7 @@ class Slider extends React.PureComponent {
|
|
|
1114
1114
|
className: lowerThumbClasses,
|
|
1115
1115
|
role: "slider",
|
|
1116
1116
|
id: twoHandles ? undefined : id,
|
|
1117
|
-
tabIndex:
|
|
1117
|
+
tabIndex: readOnly || disabled ? undefined : 0,
|
|
1118
1118
|
"aria-valuetext": `${formatLabel(value, '')}`,
|
|
1119
1119
|
"aria-valuemax": twoHandles ? valueUpper : max,
|
|
1120
1120
|
"aria-valuemin": min,
|
|
@@ -1133,7 +1133,7 @@ class Slider extends React.PureComponent {
|
|
|
1133
1133
|
}, upperThumbWrapperProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1134
1134
|
className: upperThumbClasses,
|
|
1135
1135
|
role: "slider",
|
|
1136
|
-
tabIndex:
|
|
1136
|
+
tabIndex: readOnly || disabled ? undefined : 0,
|
|
1137
1137
|
"aria-valuemax": max,
|
|
1138
1138
|
"aria-valuemin": value,
|
|
1139
1139
|
"aria-valuenow": valueUpper,
|
|
@@ -333,8 +333,8 @@ function TabList(_ref4) {
|
|
|
333
333
|
function onKeyDown(event) {
|
|
334
334
|
if (match.matches(event, [keys.ArrowRight, keys.ArrowLeft, keys.Home, keys.End])) {
|
|
335
335
|
event.preventDefault();
|
|
336
|
-
const
|
|
337
|
-
const activeTabs =
|
|
336
|
+
const filteredTabs = tabs.current.filter(tab => tab !== null);
|
|
337
|
+
const activeTabs = filteredTabs.filter(tab => !tab.disabled);
|
|
338
338
|
const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
|
|
339
339
|
const nextIndex = tabs.current.indexOf(activeTabs[getNextIndex(event, activeTabs.length, currentIndex)]);
|
|
340
340
|
if (activation === 'automatic') {
|
|
@@ -345,6 +345,18 @@ function TabList(_ref4) {
|
|
|
345
345
|
tabs.current[nextIndex]?.focus();
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
+
function handleBlur(_ref5) {
|
|
349
|
+
let {
|
|
350
|
+
relatedTarget: currentActiveNode
|
|
351
|
+
} = _ref5;
|
|
352
|
+
if (ref.current?.contains(currentActiveNode)) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
// reset active index to selected tab index for manual activation
|
|
356
|
+
if (activation === 'manual') {
|
|
357
|
+
setActiveIndex(selectedIndex);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
348
360
|
useEffectOnce.useEffectOnce(() => {
|
|
349
361
|
const tab = tabs.current[selectedIndex];
|
|
350
362
|
if (scrollIntoView && tab) {
|
|
@@ -430,10 +442,10 @@ function TabList(_ref4) {
|
|
|
430
442
|
}
|
|
431
443
|
}, [activation, activeIndex, selectedIndex, isScrollable, children]);
|
|
432
444
|
usePressable.usePressable(previousButton, {
|
|
433
|
-
onPress(
|
|
445
|
+
onPress(_ref6) {
|
|
434
446
|
let {
|
|
435
447
|
longPress
|
|
436
|
-
} =
|
|
448
|
+
} = _ref6;
|
|
437
449
|
if (!longPress && ref.current) {
|
|
438
450
|
setScrollLeft(Math.max(scrollLeft - ref.current.scrollWidth / tabs.current.length * 1.5, 0));
|
|
439
451
|
}
|
|
@@ -443,10 +455,10 @@ function TabList(_ref4) {
|
|
|
443
455
|
}
|
|
444
456
|
});
|
|
445
457
|
usePressable.usePressable(nextButton, {
|
|
446
|
-
onPress(
|
|
458
|
+
onPress(_ref7) {
|
|
447
459
|
let {
|
|
448
460
|
longPress
|
|
449
|
-
} =
|
|
461
|
+
} = _ref7;
|
|
450
462
|
if (!longPress && ref.current) {
|
|
451
463
|
setScrollLeft(Math.min(scrollLeft + ref.current.scrollWidth / tabs.current.length * 1.5, ref.current.scrollWidth - ref.current.clientWidth));
|
|
452
464
|
}
|
|
@@ -470,7 +482,8 @@ function TabList(_ref4) {
|
|
|
470
482
|
role: "tablist",
|
|
471
483
|
className: `${prefix}--tab--list`,
|
|
472
484
|
onScroll: debouncedOnScroll,
|
|
473
|
-
onKeyDown: onKeyDown
|
|
485
|
+
onKeyDown: onKeyDown,
|
|
486
|
+
onBlur: handleBlur
|
|
474
487
|
}), React__default["default"].Children.map(children, (child, index) => {
|
|
475
488
|
return !reactIs.isElement(child) ? null : /*#__PURE__*/React__default["default"].createElement(TabContext.Provider, {
|
|
476
489
|
value: {
|
|
@@ -555,7 +568,7 @@ TabList.propTypes = {
|
|
|
555
568
|
|
|
556
569
|
// type TabElement = HTMLElement & { disabled?: boolean };
|
|
557
570
|
|
|
558
|
-
function TabListVertical(
|
|
571
|
+
function TabListVertical(_ref8) {
|
|
559
572
|
let {
|
|
560
573
|
activation = 'automatic',
|
|
561
574
|
'aria-label': label,
|
|
@@ -563,7 +576,7 @@ function TabListVertical(_ref7) {
|
|
|
563
576
|
className: customClassName,
|
|
564
577
|
scrollIntoView,
|
|
565
578
|
...rest
|
|
566
|
-
} =
|
|
579
|
+
} = _ref8;
|
|
567
580
|
const {
|
|
568
581
|
activeIndex,
|
|
569
582
|
selectedIndex,
|
|
@@ -580,8 +593,8 @@ function TabListVertical(_ref7) {
|
|
|
580
593
|
function onKeyDown(event) {
|
|
581
594
|
if (match.matches(event, [keys.ArrowDown, keys.ArrowUp, keys.Home, keys.End])) {
|
|
582
595
|
event.preventDefault();
|
|
583
|
-
const
|
|
584
|
-
const activeTabs =
|
|
596
|
+
const filteredTabs = tabs.current.filter(tab => tab !== null);
|
|
597
|
+
const activeTabs = filteredTabs.filter(tab => !tab.disabled);
|
|
585
598
|
const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
|
|
586
599
|
const nextIndex = tabs.current.indexOf(activeTabs[getNextIndexVertical(event, activeTabs.length, currentIndex)]);
|
|
587
600
|
if (activation === 'automatic') {
|
|
@@ -592,6 +605,18 @@ function TabListVertical(_ref7) {
|
|
|
592
605
|
tabs.current[nextIndex]?.focus();
|
|
593
606
|
}
|
|
594
607
|
}
|
|
608
|
+
function handleBlur(_ref9) {
|
|
609
|
+
let {
|
|
610
|
+
relatedTarget: currentActiveNode
|
|
611
|
+
} = _ref9;
|
|
612
|
+
if (ref.current?.contains(currentActiveNode)) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
// reset active index to selected tab index for manual activation
|
|
616
|
+
if (activation === 'manual') {
|
|
617
|
+
setActiveIndex(selectedIndex);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
595
620
|
useEffectOnce.useEffectOnce(() => {
|
|
596
621
|
if (tabs.current[selectedIndex]?.disabled) {
|
|
597
622
|
const activeTabs = tabs.current.filter(tab => {
|
|
@@ -658,7 +683,8 @@ function TabListVertical(_ref7) {
|
|
|
658
683
|
ref: ref,
|
|
659
684
|
role: "tablist",
|
|
660
685
|
className: `${prefix}--tab--list`,
|
|
661
|
-
onKeyDown: onKeyDown
|
|
686
|
+
onKeyDown: onKeyDown,
|
|
687
|
+
onBlur: handleBlur
|
|
662
688
|
}), React__default["default"].Children.map(children, (child, index) => {
|
|
663
689
|
return !reactIs.isElement(child) ? null : /*#__PURE__*/React__default["default"].createElement(TabContext.Provider, {
|
|
664
690
|
value: {
|
|
@@ -741,7 +767,7 @@ function createLongPressBehavior(ref, direction, setScrollLeft) {
|
|
|
741
767
|
* Tab
|
|
742
768
|
*/
|
|
743
769
|
|
|
744
|
-
const Tab = /*#__PURE__*/React.forwardRef(function Tab(
|
|
770
|
+
const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref10, forwardRef) {
|
|
745
771
|
let {
|
|
746
772
|
as = 'button',
|
|
747
773
|
children,
|
|
@@ -752,7 +778,7 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(_ref8, forwardRef) {
|
|
|
752
778
|
secondaryLabel,
|
|
753
779
|
renderIcon: Icon,
|
|
754
780
|
...rest
|
|
755
|
-
} =
|
|
781
|
+
} = _ref10;
|
|
756
782
|
const prefix = usePrefix.usePrefix();
|
|
757
783
|
const {
|
|
758
784
|
selectedIndex,
|
|
@@ -994,7 +1020,7 @@ Tab.propTypes = {
|
|
|
994
1020
|
* IconTab
|
|
995
1021
|
*/
|
|
996
1022
|
|
|
997
|
-
const IconTab = /*#__PURE__*/React__default["default"].forwardRef(function IconTab(
|
|
1023
|
+
const IconTab = /*#__PURE__*/React__default["default"].forwardRef(function IconTab(_ref11, ref) {
|
|
998
1024
|
let {
|
|
999
1025
|
children,
|
|
1000
1026
|
className: customClassName,
|
|
@@ -1003,7 +1029,7 @@ const IconTab = /*#__PURE__*/React__default["default"].forwardRef(function IconT
|
|
|
1003
1029
|
leaveDelayMs,
|
|
1004
1030
|
label,
|
|
1005
1031
|
...rest
|
|
1006
|
-
} =
|
|
1032
|
+
} = _ref11;
|
|
1007
1033
|
const prefix = usePrefix.usePrefix();
|
|
1008
1034
|
const classNames = cx__default["default"](`${prefix}--tabs__nav-item--icon-only`, customClassName);
|
|
1009
1035
|
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
@@ -1052,12 +1078,12 @@ IconTab.propTypes = {
|
|
|
1052
1078
|
* TabPanel
|
|
1053
1079
|
*/
|
|
1054
1080
|
|
|
1055
|
-
const TabPanel = /*#__PURE__*/React__default["default"].forwardRef(function TabPanel(
|
|
1081
|
+
const TabPanel = /*#__PURE__*/React__default["default"].forwardRef(function TabPanel(_ref12, forwardRef) {
|
|
1056
1082
|
let {
|
|
1057
1083
|
children,
|
|
1058
1084
|
className: customClassName,
|
|
1059
1085
|
...rest
|
|
1060
|
-
} =
|
|
1086
|
+
} = _ref12;
|
|
1061
1087
|
const prefix = usePrefix.usePrefix();
|
|
1062
1088
|
const panel = React.useRef(null);
|
|
1063
1089
|
const ref = useMergedRefs.useMergedRefs([forwardRef, panel]);
|
|
@@ -1132,10 +1158,10 @@ TabPanel.propTypes = {
|
|
|
1132
1158
|
* TabPanels
|
|
1133
1159
|
*/
|
|
1134
1160
|
|
|
1135
|
-
function TabPanels(
|
|
1161
|
+
function TabPanels(_ref13) {
|
|
1136
1162
|
let {
|
|
1137
1163
|
children
|
|
1138
|
-
} =
|
|
1164
|
+
} = _ref13;
|
|
1139
1165
|
const prefix = usePrefix.usePrefix();
|
|
1140
1166
|
const refs = React.useRef([]);
|
|
1141
1167
|
const hiddenStates = React.useRef([]);
|
|
@@ -89,7 +89,7 @@ const DismissibleTag = _ref => {
|
|
|
89
89
|
}, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
90
90
|
title: tagTitle ? tagTitle : text,
|
|
91
91
|
className: `${prefix}--tag__label`
|
|
92
|
-
}, text), /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
92
|
+
}, text), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
93
93
|
label: isEllipsisApplied ? dismissLabel : title,
|
|
94
94
|
align: "bottom",
|
|
95
95
|
className: tooltipClasses,
|
|
@@ -101,7 +101,7 @@ const DismissibleTag = _ref => {
|
|
|
101
101
|
onClick: handleClose,
|
|
102
102
|
disabled: disabled,
|
|
103
103
|
"aria-label": title
|
|
104
|
-
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))))
|
|
104
|
+
}, _Close || (_Close = /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, null))))));
|
|
105
105
|
};
|
|
106
106
|
DismissibleTag.propTypes = {
|
|
107
107
|
/**
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React, { MouseEventHandler
|
|
8
|
+
import React, { MouseEventHandler } from 'react';
|
|
9
9
|
import { PolymorphicProps } from '../../types/common';
|
|
10
10
|
import { SIZES } from './Tag';
|
|
11
11
|
declare const TYPES: {
|
|
@@ -44,10 +44,6 @@ export interface OperationalTagBaseProps {
|
|
|
44
44
|
* `md` (default) or `lg` sizes.
|
|
45
45
|
*/
|
|
46
46
|
size?: keyof typeof SIZES;
|
|
47
|
-
/**
|
|
48
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
49
|
-
*/
|
|
50
|
-
slug?: ReactNode;
|
|
51
47
|
/**
|
|
52
48
|
* Provide text to be rendered inside of a the tag.
|
|
53
49
|
*/
|
|
@@ -59,7 +55,7 @@ export interface OperationalTagBaseProps {
|
|
|
59
55
|
}
|
|
60
56
|
export type OperationalTagProps<T extends React.ElementType> = PolymorphicProps<T, OperationalTagBaseProps>;
|
|
61
57
|
declare const OperationalTag: {
|
|
62
|
-
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon,
|
|
58
|
+
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, size, text, type, ...other }: OperationalTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
63
59
|
propTypes: {
|
|
64
60
|
/**
|
|
65
61
|
* Provide a custom className that is applied to the containing <span>
|
|
@@ -83,10 +79,6 @@ declare const OperationalTag: {
|
|
|
83
79
|
* `md` (default) or `lg` sizes.
|
|
84
80
|
*/
|
|
85
81
|
size: PropTypes.Requireable<string>;
|
|
86
|
-
/**
|
|
87
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
88
|
-
*/
|
|
89
|
-
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
90
82
|
/**
|
|
91
83
|
* Provide text to be rendered inside of a the tag.
|
|
92
84
|
*/
|
|
@@ -46,7 +46,6 @@ const OperationalTag = _ref => {
|
|
|
46
46
|
disabled,
|
|
47
47
|
id,
|
|
48
48
|
renderIcon,
|
|
49
|
-
slug,
|
|
50
49
|
size,
|
|
51
50
|
text,
|
|
52
51
|
type = 'gray',
|
|
@@ -61,13 +60,6 @@ const OperationalTag = _ref => {
|
|
|
61
60
|
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
62
61
|
setIsEllipsisApplied(isEllipsisActive.isEllipsisActive(newElement));
|
|
63
62
|
}, [prefix, tagRef]);
|
|
64
|
-
let normalizedSlug;
|
|
65
|
-
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
66
|
-
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
67
|
-
size: 'sm',
|
|
68
|
-
kind: 'inline'
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
63
|
const tooltipClasses = cx__default["default"](`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
|
|
72
64
|
if (isEllipsisApplied) {
|
|
73
65
|
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
@@ -88,7 +80,7 @@ const OperationalTag = _ref => {
|
|
|
88
80
|
}, other), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
89
81
|
title: text,
|
|
90
82
|
className: `${prefix}--tag__label`
|
|
91
|
-
}, text)
|
|
83
|
+
}, text)));
|
|
92
84
|
}
|
|
93
85
|
return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
94
86
|
ref: tagRef,
|
|
@@ -98,7 +90,7 @@ const OperationalTag = _ref => {
|
|
|
98
90
|
disabled: disabled,
|
|
99
91
|
className: tagClasses,
|
|
100
92
|
id: tagId
|
|
101
|
-
}, other),
|
|
93
|
+
}, other), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
102
94
|
title: text,
|
|
103
95
|
className: `${prefix}--tag__label`
|
|
104
96
|
}, text));
|
|
@@ -126,10 +118,6 @@ OperationalTag.propTypes = {
|
|
|
126
118
|
* `md` (default) or `lg` sizes.
|
|
127
119
|
*/
|
|
128
120
|
size: PropTypes__default["default"].oneOf(Object.keys(Tag.SIZES)),
|
|
129
|
-
/**
|
|
130
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
131
|
-
*/
|
|
132
|
-
slug: PropTypes__default["default"].node,
|
|
133
121
|
/**
|
|
134
122
|
* Provide text to be rendered inside of a the tag.
|
|
135
123
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React
|
|
8
|
+
import React from 'react';
|
|
9
9
|
import { PolymorphicProps } from '../../types/common';
|
|
10
10
|
import { SIZES } from './Tag';
|
|
11
11
|
export interface SelectableTagBaseProps {
|
|
@@ -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
|
*/
|
|
@@ -35,10 +43,6 @@ export interface SelectableTagBaseProps {
|
|
|
35
43
|
* `md` (default) or `lg` sizes.
|
|
36
44
|
*/
|
|
37
45
|
size?: keyof typeof SIZES;
|
|
38
|
-
/**
|
|
39
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
40
|
-
*/
|
|
41
|
-
slug?: ReactNode;
|
|
42
46
|
/**
|
|
43
47
|
* Provide text to be rendered inside of a the tag.
|
|
44
48
|
*/
|
|
@@ -46,7 +50,7 @@ export interface SelectableTagBaseProps {
|
|
|
46
50
|
}
|
|
47
51
|
export type SelectableTagProps<T extends React.ElementType> = PolymorphicProps<T, SelectableTagBaseProps>;
|
|
48
52
|
declare const SelectableTag: {
|
|
49
|
-
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon,
|
|
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;
|
|
50
54
|
propTypes: {
|
|
51
55
|
/**
|
|
52
56
|
* Provide a custom className that is applied to the containing <span>
|
|
@@ -65,6 +69,14 @@ declare const SelectableTag: {
|
|
|
65
69
|
* Can be a React component class
|
|
66
70
|
*/
|
|
67
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>;
|
|
68
80
|
/**
|
|
69
81
|
* Specify the state of the selectable tag.
|
|
70
82
|
*/
|
|
@@ -74,10 +86,6 @@ declare const SelectableTag: {
|
|
|
74
86
|
* `md` (default) or `lg` sizes.
|
|
75
87
|
*/
|
|
76
88
|
size: PropTypes.Requireable<string>;
|
|
77
|
-
/**
|
|
78
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
79
|
-
*/
|
|
80
|
-
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
81
89
|
/**
|
|
82
90
|
* Provide text to be rendered inside of a the tag.
|
|
83
91
|
*/
|
|
@@ -34,8 +34,9 @@ const SelectableTag = _ref => {
|
|
|
34
34
|
disabled,
|
|
35
35
|
id,
|
|
36
36
|
renderIcon,
|
|
37
|
+
onChange,
|
|
38
|
+
onClick,
|
|
37
39
|
selected = false,
|
|
38
|
-
slug,
|
|
39
40
|
size,
|
|
40
41
|
text,
|
|
41
42
|
...other
|
|
@@ -52,21 +53,12 @@ const SelectableTag = _ref => {
|
|
|
52
53
|
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
53
54
|
setIsEllipsisApplied(isEllipsisActive.isEllipsisActive(newElement));
|
|
54
55
|
}, [prefix, tagRef]);
|
|
55
|
-
let normalizedSlug;
|
|
56
|
-
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
57
|
-
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
58
|
-
size: 'sm',
|
|
59
|
-
kind: 'inline'
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
56
|
const tooltipClasses = cx__default["default"](`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
...otherProps
|
|
69
|
-
} = other;
|
|
57
|
+
const handleClick = e => {
|
|
58
|
+
setSelectedTag(!selectedTag);
|
|
59
|
+
onChange?.(!selectedTag);
|
|
60
|
+
onClick?.(e);
|
|
61
|
+
};
|
|
70
62
|
if (isEllipsisApplied) {
|
|
71
63
|
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
72
64
|
label: text,
|
|
@@ -75,31 +67,29 @@ const SelectableTag = _ref => {
|
|
|
75
67
|
leaveDelayMs: 0,
|
|
76
68
|
onMouseEnter: () => false
|
|
77
69
|
}, /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
78
|
-
"aria-pressed": selectedTag,
|
|
70
|
+
"aria-pressed": selectedTag !== false,
|
|
79
71
|
ref: tagRef,
|
|
80
|
-
slug: slug,
|
|
81
72
|
size: size,
|
|
82
73
|
renderIcon: renderIcon,
|
|
83
74
|
disabled: disabled,
|
|
84
75
|
className: tagClasses,
|
|
85
76
|
id: tagId,
|
|
86
|
-
onClick:
|
|
87
|
-
},
|
|
77
|
+
onClick: handleClick
|
|
78
|
+
}, other), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
88
79
|
title: text,
|
|
89
80
|
className: `${prefix}--tag__label`
|
|
90
|
-
}, text)
|
|
81
|
+
}, text)));
|
|
91
82
|
}
|
|
92
83
|
return /*#__PURE__*/React__default["default"].createElement(Tag["default"], _rollupPluginBabelHelpers["extends"]({
|
|
93
|
-
"aria-pressed": selectedTag,
|
|
84
|
+
"aria-pressed": selectedTag !== false,
|
|
94
85
|
ref: tagRef,
|
|
95
|
-
slug: slug,
|
|
96
86
|
size: size,
|
|
97
87
|
renderIcon: renderIcon,
|
|
98
88
|
disabled: disabled,
|
|
99
89
|
className: tagClasses,
|
|
100
90
|
id: tagId,
|
|
101
|
-
onClick:
|
|
102
|
-
},
|
|
91
|
+
onClick: handleClick
|
|
92
|
+
}, other), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
103
93
|
title: text,
|
|
104
94
|
className: `${prefix}--tag__label`
|
|
105
95
|
}, text));
|
|
@@ -122,6 +112,14 @@ SelectableTag.propTypes = {
|
|
|
122
112
|
* Can be a React component class
|
|
123
113
|
*/
|
|
124
114
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
115
|
+
/**
|
|
116
|
+
* Provide an optional hook that is called when selected is changed
|
|
117
|
+
*/
|
|
118
|
+
onChange: PropTypes__default["default"].func,
|
|
119
|
+
/**
|
|
120
|
+
* Provide an optional function to be called when the tag is clicked.
|
|
121
|
+
*/
|
|
122
|
+
onClick: PropTypes__default["default"].func,
|
|
125
123
|
/**
|
|
126
124
|
* Specify the state of the selectable tag.
|
|
127
125
|
*/
|
|
@@ -131,10 +129,6 @@ SelectableTag.propTypes = {
|
|
|
131
129
|
* `md` (default) or `lg` sizes.
|
|
132
130
|
*/
|
|
133
131
|
size: PropTypes__default["default"].oneOf(Object.keys(Tag.SIZES)),
|
|
134
|
-
/**
|
|
135
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
136
|
-
*/
|
|
137
|
-
slug: PropTypes__default["default"].node,
|
|
138
132
|
/**
|
|
139
133
|
* Provide text to be rendered inside of a the tag.
|
|
140
134
|
*/
|
|
@@ -113,6 +113,8 @@ function Toggle(_ref) {
|
|
|
113
113
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
114
114
|
className: switchClasses
|
|
115
115
|
}, isSm && /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
116
|
+
"aria-hidden": "true",
|
|
117
|
+
focusable: "false",
|
|
116
118
|
className: `${prefix}--toggle__check`,
|
|
117
119
|
width: "6px",
|
|
118
120
|
height: "5px",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
interface ToggleSmallSkeletonProps {
|
|
10
|
+
['aria-label']: string;
|
|
11
|
+
/**
|
|
12
|
+
* Specify an optional className to add to the form item wrapper.
|
|
13
|
+
*/
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Provide an id that unique represents the underlying `<input>`
|
|
17
|
+
*/
|
|
18
|
+
id?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Provide the text that will be read by a screen reader when visiting this
|
|
21
|
+
* control
|
|
22
|
+
* `aria-label` is always required but will be null if `labelText` is also
|
|
23
|
+
* provided
|
|
24
|
+
*/
|
|
25
|
+
labelText?: string;
|
|
26
|
+
}
|
|
27
|
+
declare class ToggleSmallSkeleton extends React.Component<ToggleSmallSkeletonProps> {
|
|
28
|
+
static propTypes: {
|
|
29
|
+
"aria-label": PropTypes.Validator<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Specify an optional className to add to the form item wrapper.
|
|
32
|
+
*/
|
|
33
|
+
className: PropTypes.Requireable<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Provide an id that unique represents the underlying `<input>`
|
|
36
|
+
*/
|
|
37
|
+
id: PropTypes.Requireable<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Provide the text that will be read by a screen reader when visiting this
|
|
40
|
+
* control
|
|
41
|
+
* `aria-label` is always required but will be null if `labelText` is also
|
|
42
|
+
* provided
|
|
43
|
+
*/
|
|
44
|
+
labelText: PropTypes.Requireable<string>;
|
|
45
|
+
};
|
|
46
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
}
|
|
48
|
+
export default ToggleSmallSkeleton;
|
|
49
|
+
export { ToggleSmallSkeleton };
|
|
@@ -281,9 +281,11 @@ const TreeNode = /*#__PURE__*/React__default["default"].forwardRef((_ref, forwar
|
|
|
281
281
|
className: `${prefix}--tree-node__label__details`
|
|
282
282
|
}, Icon && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
283
283
|
className: `${prefix}--tree-node__icon`
|
|
284
|
-
}), label)),
|
|
284
|
+
}), label)), /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
285
285
|
role: "group",
|
|
286
|
-
className: `${prefix}--tree-node__children
|
|
286
|
+
className: cx__default["default"](`${prefix}--tree-node__children`, {
|
|
287
|
+
[`${prefix}--tree-node--hidden`]: !expanded
|
|
288
|
+
})
|
|
287
289
|
}, nodesWithProps));
|
|
288
290
|
});
|
|
289
291
|
TreeNode.propTypes = {
|
|
@@ -161,12 +161,12 @@ const TreeView = _ref => {
|
|
|
161
161
|
}])) {
|
|
162
162
|
const nodeIds = [];
|
|
163
163
|
if (match.matches(event, [keys.Home, keys.End])) {
|
|
164
|
-
if (multiselect && event.shiftKey && event.ctrlKey && treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled')) {
|
|
164
|
+
if (multiselect && event.shiftKey && event.ctrlKey && treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled') && !treeWalker.current.currentNode.classList.contains(`${prefix}--tree-node--hidden`)) {
|
|
165
165
|
nodeIds.push(treeWalker.current.currentNode?.id);
|
|
166
166
|
}
|
|
167
167
|
while (match.match(event, keys.Home) ? treeWalker.current.previousNode() : treeWalker.current.nextNode()) {
|
|
168
168
|
nextFocusNode = treeWalker.current.currentNode;
|
|
169
|
-
if (multiselect && event.shiftKey && event.ctrlKey && nextFocusNode instanceof Element && !nextFocusNode.getAttribute('aria-disabled')) {
|
|
169
|
+
if (multiselect && event.shiftKey && event.ctrlKey && nextFocusNode instanceof Element && !nextFocusNode.getAttribute('aria-disabled') && !nextFocusNode.classList.contains(`${prefix}--tree-node--hidden`)) {
|
|
170
170
|
nodeIds.push(nextFocusNode?.id);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -177,7 +177,7 @@ const TreeView = _ref => {
|
|
|
177
177
|
}) && event.ctrlKey) {
|
|
178
178
|
treeWalker.current.currentNode = treeWalker.current.root;
|
|
179
179
|
while (treeWalker.current.nextNode()) {
|
|
180
|
-
if (treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled')) {
|
|
180
|
+
if (treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled') && !treeWalker.current.currentNode.classList.contains(`${prefix}--tree-node--hidden`)) {
|
|
181
181
|
nodeIds.push(treeWalker.current.currentNode?.id);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
@@ -199,7 +199,7 @@ const TreeView = _ref => {
|
|
|
199
199
|
if (!(node instanceof Element)) {
|
|
200
200
|
return NodeFilter.FILTER_SKIP;
|
|
201
201
|
}
|
|
202
|
-
if (node.classList.contains(`${prefix}--tree-node--disabled`)) {
|
|
202
|
+
if (node.classList.contains(`${prefix}--tree-node--disabled`) || node.classList.contains(`${prefix}--tree-node--hidden`)) {
|
|
203
203
|
return NodeFilter.FILTER_REJECT;
|
|
204
204
|
}
|
|
205
205
|
if (node.matches(`li.${prefix}--tree-node`)) {
|
|
@@ -4,8 +4,9 @@
|
|
|
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, {
|
|
8
|
-
|
|
7
|
+
import React, { ComponentProps } from 'react';
|
|
8
|
+
import Link from './Link';
|
|
9
|
+
interface SideNavMenuItemProps extends ComponentProps<typeof Link> {
|
|
9
10
|
/**
|
|
10
11
|
* Specify the children to be rendered inside of the `SideNavMenuItem`
|
|
11
12
|
*/
|
|
@@ -25,5 +26,5 @@ interface SideNavMenuItemProps extends HTMLAttributes<HTMLElement> {
|
|
|
25
26
|
*/
|
|
26
27
|
href?: string;
|
|
27
28
|
}
|
|
28
|
-
declare const SideNavMenuItem: React.ForwardRefExoticComponent<SideNavMenuItemProps & React.RefAttributes<HTMLElement>>;
|
|
29
|
+
declare const SideNavMenuItem: React.ForwardRefExoticComponent<Omit<SideNavMenuItemProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
29
30
|
export default SideNavMenuItem;
|
|
@@ -29,7 +29,6 @@ const SideNavMenuItem = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
29
29
|
children,
|
|
30
30
|
className: customClassName,
|
|
31
31
|
isActive,
|
|
32
|
-
href,
|
|
33
32
|
...rest
|
|
34
33
|
} = props;
|
|
35
34
|
const className = cx__default["default"](`${prefix}--side-nav__menu-item`, customClassName);
|
|
@@ -39,9 +38,7 @@ const SideNavMenuItem = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
39
38
|
});
|
|
40
39
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
41
40
|
className: className
|
|
42
|
-
}, /*#__PURE__*/React__default["default"].createElement(Link["default"], _rollupPluginBabelHelpers["extends"]({
|
|
43
|
-
href: href
|
|
44
|
-
}, rest, {
|
|
41
|
+
}, /*#__PURE__*/React__default["default"].createElement(Link["default"], _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
45
42
|
className: linkClassName,
|
|
46
43
|
ref: ref
|
|
47
44
|
}), /*#__PURE__*/React__default["default"].createElement(SideNavLinkText["default"], null, children)));
|