@carbon/react 1.37.0 → 1.38.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 +924 -660
- package/es/components/DataTable/DataTable.js +1 -1
- package/es/components/DataTable/Table.js +21 -1
- package/es/components/Grid/CSSGrid.js +1 -1
- package/es/components/Grid/ColumnHang.js +1 -1
- package/es/components/Grid/GridContext.d.ts +2 -2
- package/es/components/Grid/GridContext.js +1 -1
- package/es/components/Heading/index.d.ts +5 -40
- package/es/components/Heading/index.js +11 -6
- package/es/components/Icon/Icon.Skeleton.d.ts +25 -0
- package/es/components/Icon/Icon.Skeleton.js +1 -4
- package/es/components/Icon/index.d.ts +7 -0
- package/es/components/IconButton/index.js +9 -1
- package/es/components/Layer/index.js +5 -3
- package/es/components/ListBox/ListBoxMenuItem.js +2 -1
- package/es/components/Menu/Menu.js +14 -2
- package/es/components/Menu/MenuItem.js +28 -7
- package/es/components/MenuButton/index.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +6 -6
- package/es/components/MultiSelect/MultiSelect.js +6 -0
- package/es/components/Notification/Notification.js +4 -2
- package/es/components/Slider/Slider.d.ts +1 -0
- package/es/components/Slider/Slider.js +16 -5
- package/es/components/Tabs/Tabs.js +6 -8
- package/es/components/Tag/Tag.Skeleton.js +6 -3
- package/es/components/Tag/Tag.js +2 -2
- package/es/components/Text/Text.js +1 -1
- package/es/components/TextInput/PasswordInput.js +3 -1
- package/es/components/Theme/index.d.ts +3 -15
- package/es/components/Theme/index.js +6 -3
- package/es/components/TreeView/TreeNode.js +2 -2
- package/es/components/UIShell/HeaderMenu.js +11 -11
- package/es/components/UIShell/HeaderMenuItem.d.ts +9 -5
- package/es/components/UIShell/HeaderMenuItem.js +2 -3
- package/lib/components/DataTable/DataTable.js +1 -1
- package/lib/components/DataTable/Table.js +20 -0
- package/lib/components/Grid/CSSGrid.js +1 -1
- package/lib/components/Grid/ColumnHang.js +1 -1
- package/lib/components/Grid/GridContext.d.ts +2 -2
- package/lib/components/Grid/GridContext.js +1 -1
- package/lib/components/Heading/index.d.ts +5 -40
- package/lib/components/Heading/index.js +11 -6
- package/lib/components/Icon/Icon.Skeleton.d.ts +25 -0
- package/lib/components/Icon/Icon.Skeleton.js +1 -4
- package/lib/components/Icon/index.d.ts +7 -0
- package/lib/components/IconButton/index.js +9 -1
- package/lib/components/Layer/index.js +5 -3
- package/lib/components/ListBox/ListBoxMenuItem.js +2 -1
- package/lib/components/Menu/Menu.js +14 -2
- package/lib/components/Menu/MenuItem.js +30 -9
- package/lib/components/MenuButton/index.js +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +5 -5
- package/lib/components/MultiSelect/MultiSelect.js +6 -0
- package/lib/components/Notification/Notification.js +4 -2
- package/lib/components/Slider/Slider.d.ts +1 -0
- package/lib/components/Slider/Slider.js +16 -5
- package/lib/components/Tabs/Tabs.js +6 -8
- package/lib/components/Tag/Tag.Skeleton.js +6 -3
- package/lib/components/Tag/Tag.js +2 -2
- package/lib/components/Text/Text.js +1 -1
- package/lib/components/TextInput/PasswordInput.js +3 -1
- package/lib/components/Theme/index.d.ts +3 -15
- package/lib/components/Theme/index.js +6 -3
- package/lib/components/TreeView/TreeNode.js +2 -2
- package/lib/components/UIShell/HeaderMenu.js +11 -11
- package/lib/components/UIShell/HeaderMenuItem.d.ts +9 -5
- package/lib/components/UIShell/HeaderMenuItem.js +2 -3
- package/package.json +5 -5
|
@@ -261,7 +261,7 @@ class DataTable extends React__default.Component {
|
|
|
261
261
|
checked: row.isSelected,
|
|
262
262
|
onSelect: composeEventHandlers([_this.handleOnSelectRow(row.id), onClick]),
|
|
263
263
|
id: `${_this.getTablePrefix()}__select-row-${row.id}`,
|
|
264
|
-
name: `select-row
|
|
264
|
+
name: `select-row`,
|
|
265
265
|
ariaLabel: t(translationKey),
|
|
266
266
|
disabled: row.disabled,
|
|
267
267
|
radio: _this.props.radio || null
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useContext, useRef, useCallback, useLayoutEffect } from 'react';
|
|
9
|
+
import React__default, { useContext, useState, useRef, useCallback, useLayoutEffect } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import debounce from 'lodash.debounce';
|
|
@@ -60,6 +60,7 @@ const Table = _ref => {
|
|
|
60
60
|
descriptionId
|
|
61
61
|
} = useContext(TableContext);
|
|
62
62
|
const prefix = usePrefix();
|
|
63
|
+
const [isScrollable, setIsScrollable] = useState(false);
|
|
63
64
|
const tableRef = useRef(null);
|
|
64
65
|
const componentClass = cx(`${prefix}--data-table`, className, {
|
|
65
66
|
[`${prefix}--data-table--${size}`]: size,
|
|
@@ -98,6 +99,22 @@ const Table = _ref => {
|
|
|
98
99
|
const debouncedSetTableAlignment = debounce(setTableAlignment, 100);
|
|
99
100
|
useWindowEvent('resize', debouncedSetTableAlignment);
|
|
100
101
|
|
|
102
|
+
// Used to set a tabIndex when the Table is horizontally scrollable
|
|
103
|
+
const setTabIndex = useCallback(() => {
|
|
104
|
+
const tableContainer = tableRef?.current?.parentNode;
|
|
105
|
+
const tableHeader = tableRef?.current?.firstChild;
|
|
106
|
+
if (tableHeader?.scrollWidth > tableContainer?.clientWidth) {
|
|
107
|
+
setIsScrollable(true);
|
|
108
|
+
} else {
|
|
109
|
+
setIsScrollable(false);
|
|
110
|
+
}
|
|
111
|
+
}, []);
|
|
112
|
+
const debouncedSetTabIndex = debounce(setTabIndex, 100);
|
|
113
|
+
useWindowEvent('resize', debouncedSetTabIndex);
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
setTabIndex();
|
|
116
|
+
}, [setTabIndex]);
|
|
117
|
+
|
|
101
118
|
// recalculate table alignment once fonts have loaded
|
|
102
119
|
if (typeof document !== 'undefined' && document?.fonts?.status && document.fonts.status !== 'loaded') {
|
|
103
120
|
document.fonts.ready.then(() => {
|
|
@@ -109,6 +126,9 @@ const Table = _ref => {
|
|
|
109
126
|
}, [setTableAlignment, size]);
|
|
110
127
|
const table = /*#__PURE__*/React__default.createElement("div", {
|
|
111
128
|
className: `${prefix}--data-table-content`
|
|
129
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
130
|
+
,
|
|
131
|
+
tabIndex: isScrollable ? 0 : undefined
|
|
112
132
|
}, /*#__PURE__*/React__default.createElement("table", _extends({
|
|
113
133
|
"aria-labelledby": titleId,
|
|
114
134
|
"aria-describedby": descriptionId
|
|
@@ -13,7 +13,7 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Helper component for rendering content that hangs on the column. Useful when
|
|
16
|
-
* trying to align content across different
|
|
16
|
+
* trying to align content across different gutter modes
|
|
17
17
|
*/
|
|
18
18
|
function ColumnHang(_ref) {
|
|
19
19
|
let {
|
|
@@ -8,7 +8,7 @@ import * as React from 'react';
|
|
|
8
8
|
export type GridMode = 'flexbox' | 'css-grid';
|
|
9
9
|
export interface GridSettingContext {
|
|
10
10
|
/**
|
|
11
|
-
* The
|
|
11
|
+
* The gutter mode for the GridContext
|
|
12
12
|
*/
|
|
13
13
|
mode: GridMode;
|
|
14
14
|
/**
|
|
@@ -23,7 +23,7 @@ export interface GridSettingsProps {
|
|
|
23
23
|
*/
|
|
24
24
|
children?: React.ReactNode;
|
|
25
25
|
/**
|
|
26
|
-
* Specify the
|
|
26
|
+
* Specify the gutter mode for the GridContext
|
|
27
27
|
*/
|
|
28
28
|
mode: GridMode;
|
|
29
29
|
/**
|
|
@@ -4,48 +4,13 @@
|
|
|
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
|
|
8
|
-
import { type ElementType } from 'react';
|
|
9
|
-
import type { PolymorphicProps } from '../../types/common';
|
|
7
|
+
import React from 'react';
|
|
10
8
|
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
9
|
type SectionBaseProps = {
|
|
12
10
|
level?: HeadingLevel;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Provide an alternative tag or component to use instead of the default
|
|
20
|
-
* <section> element
|
|
21
|
-
*/
|
|
22
|
-
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
23
|
-
/**
|
|
24
|
-
* Specify the content that will be placed in the component
|
|
25
|
-
*/
|
|
26
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
27
|
-
/**
|
|
28
|
-
* Specify a class name for the outermost node of the component
|
|
29
|
-
*/
|
|
30
|
-
className: PropTypes.Requireable<string>;
|
|
31
|
-
/**
|
|
32
|
-
* Overrides the level of the section
|
|
33
|
-
*/
|
|
34
|
-
level: PropTypes.Requireable<number>;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
type HeadingProps = JSX.IntrinsicElements[`h${HeadingLevel}`];
|
|
38
|
-
export declare function Heading(props: HeadingProps): JSX.Element;
|
|
39
|
-
export declare namespace Heading {
|
|
40
|
-
var propTypes: {
|
|
41
|
-
/**
|
|
42
|
-
* Specify the content that will be placed in the component
|
|
43
|
-
*/
|
|
44
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
45
|
-
/**
|
|
46
|
-
* Specify a class name for the outermost node of the component
|
|
47
|
-
*/
|
|
48
|
-
className: PropTypes.Requireable<string>;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
12
|
+
export declare const Section: React.ForwardRefExoticComponent<Pick<SectionBaseProps & Omit<any, "as"> & {
|
|
13
|
+
as?: React.ElementType<any> | undefined;
|
|
14
|
+
}, string | number | symbol> & React.RefAttributes<unknown>>;
|
|
15
|
+
export declare const Heading: React.ForwardRefExoticComponent<Pick<React.ClassAttributes<HTMLHeadingElement> & React.HTMLAttributes<HTMLHeadingElement>, "key" | keyof React.HTMLAttributes<HTMLHeadingElement>> & React.RefAttributes<HTMLHeadingElement>>;
|
|
51
16
|
export {};
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
8
9
|
import PropTypes from 'prop-types';
|
|
9
10
|
import React__default from 'react';
|
|
10
11
|
|
|
11
12
|
const HeadingContext = /*#__PURE__*/React__default.createContext(1);
|
|
12
|
-
function Section(_ref) {
|
|
13
|
+
const Section = /*#__PURE__*/React__default.forwardRef(function Section(_ref, ref) {
|
|
13
14
|
let {
|
|
14
15
|
as: BaseComponent = 'section',
|
|
15
16
|
level: levelOverride,
|
|
@@ -20,8 +21,10 @@ function Section(_ref) {
|
|
|
20
21
|
const BaseComponentAsAny = BaseComponent;
|
|
21
22
|
return /*#__PURE__*/React__default.createElement(HeadingContext.Provider, {
|
|
22
23
|
value: Math.min(level, 6)
|
|
23
|
-
}, /*#__PURE__*/React__default.createElement(BaseComponentAsAny,
|
|
24
|
-
|
|
24
|
+
}, /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({
|
|
25
|
+
ref: ref
|
|
26
|
+
}, rest)));
|
|
27
|
+
});
|
|
25
28
|
Section.propTypes = {
|
|
26
29
|
/**
|
|
27
30
|
* Provide an alternative tag or component to use instead of the default
|
|
@@ -41,10 +44,12 @@ Section.propTypes = {
|
|
|
41
44
|
*/
|
|
42
45
|
level: PropTypes.number
|
|
43
46
|
};
|
|
44
|
-
function Heading(props) {
|
|
47
|
+
const Heading = /*#__PURE__*/React__default.forwardRef(function Heading(props, ref) {
|
|
45
48
|
const HeadingIntrinsic = `h${React__default.useContext(HeadingContext)}`;
|
|
46
|
-
return /*#__PURE__*/React__default.createElement(HeadingIntrinsic,
|
|
47
|
-
|
|
49
|
+
return /*#__PURE__*/React__default.createElement(HeadingIntrinsic, _extends({
|
|
50
|
+
ref: ref
|
|
51
|
+
}, props));
|
|
52
|
+
});
|
|
48
53
|
Heading.propTypes = {
|
|
49
54
|
/**
|
|
50
55
|
* Specify the content that will be placed in the component
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { ComponentProps } from 'react';
|
|
9
|
+
export interface IconSkeletonProps extends ComponentProps<'div'> {
|
|
10
|
+
/**
|
|
11
|
+
* Specify an optional className to add.
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const IconSkeleton: {
|
|
16
|
+
({ className, ...rest }: IconSkeletonProps): JSX.Element;
|
|
17
|
+
propTypes: {
|
|
18
|
+
/**
|
|
19
|
+
* Specify an optional className to add.
|
|
20
|
+
*/
|
|
21
|
+
className: PropTypes.Requireable<string>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default IconSkeleton;
|
|
25
|
+
export { IconSkeleton };
|
|
@@ -17,12 +17,9 @@ const IconSkeleton = _ref => {
|
|
|
17
17
|
...rest
|
|
18
18
|
} = _ref;
|
|
19
19
|
const prefix = usePrefix();
|
|
20
|
-
const props = {
|
|
21
|
-
...rest
|
|
22
|
-
};
|
|
23
20
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
24
21
|
className: cx(`${prefix}--icon--skeleton`, className)
|
|
25
|
-
},
|
|
22
|
+
}, rest));
|
|
26
23
|
};
|
|
27
24
|
IconSkeleton.propTypes = {
|
|
28
25
|
/**
|
|
@@ -29,6 +29,7 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(pr
|
|
|
29
29
|
leaveDelayMs = 100,
|
|
30
30
|
wrapperClasses,
|
|
31
31
|
size,
|
|
32
|
+
isSelected,
|
|
32
33
|
...rest
|
|
33
34
|
} = props;
|
|
34
35
|
const prefix = usePrefix();
|
|
@@ -48,7 +49,9 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(pr
|
|
|
48
49
|
kind: kind,
|
|
49
50
|
ref: ref,
|
|
50
51
|
size: size,
|
|
51
|
-
className: cx(`${prefix}--btn--icon-only`,
|
|
52
|
+
className: cx(`${prefix}--btn--icon-only`, {
|
|
53
|
+
[`${prefix}--btn--selected`]: isSelected
|
|
54
|
+
}, className)
|
|
52
55
|
}), children));
|
|
53
56
|
});
|
|
54
57
|
IconButton.propTypes = {
|
|
@@ -80,6 +83,11 @@ IconButton.propTypes = {
|
|
|
80
83
|
* Specify the duration in milliseconds to delay before displaying the tooltip
|
|
81
84
|
*/
|
|
82
85
|
enterDelayMs: PropTypes.number,
|
|
86
|
+
/**
|
|
87
|
+
* Specify whether the IconButton is currently selected
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
isSelected: PropTypes.bool,
|
|
83
91
|
/**
|
|
84
92
|
* Specify the type of button to be used as the base for the IconButton
|
|
85
93
|
*/
|
|
@@ -26,7 +26,7 @@ function useLayer() {
|
|
|
26
26
|
level
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function Layer(_ref) {
|
|
29
|
+
const Layer = /*#__PURE__*/React__default.forwardRef(function Layer(_ref, ref) {
|
|
30
30
|
let {
|
|
31
31
|
as: BaseComponent = 'div',
|
|
32
32
|
className: customClassName,
|
|
@@ -42,10 +42,12 @@ function Layer(_ref) {
|
|
|
42
42
|
const value = Math.max(0, Math.min(level + 1, MAX_LEVEL));
|
|
43
43
|
return /*#__PURE__*/React__default.createElement(LayerContext.Provider, {
|
|
44
44
|
value: value
|
|
45
|
-
}, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({
|
|
45
|
+
}, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({
|
|
46
|
+
ref: ref
|
|
47
|
+
}, rest, {
|
|
46
48
|
className: className
|
|
47
49
|
}), children));
|
|
48
|
-
}
|
|
50
|
+
});
|
|
49
51
|
Layer.propTypes = {
|
|
50
52
|
/**
|
|
51
53
|
* Specify a custom component or element to be rendered as the top-level
|
|
@@ -14,10 +14,11 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
14
14
|
function useIsTruncated(ref) {
|
|
15
15
|
const [isTruncated, setIsTruncated] = useState(false);
|
|
16
16
|
useEffect(() => {
|
|
17
|
+
const element = ref.current;
|
|
17
18
|
const {
|
|
18
19
|
offsetWidth,
|
|
19
20
|
scrollWidth
|
|
20
|
-
} =
|
|
21
|
+
} = element.lastElementChild?.lastElementChild || element;
|
|
21
22
|
setIsTruncated(offsetWidth < scrollWidth);
|
|
22
23
|
}, [ref, setIsTruncated]);
|
|
23
24
|
return isTruncated;
|
|
@@ -13,6 +13,7 @@ import { createPortal } from 'react-dom';
|
|
|
13
13
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import { MenuContext, menuReducer } from './MenuContext.js';
|
|
16
|
+
import { useLayoutDirection } from '../LayoutDirection/useLayoutDirection.js';
|
|
16
17
|
import { match } from '../../internal/keyboard/match.js';
|
|
17
18
|
import { Escape, ArrowLeft, ArrowUp, ArrowDown } from '../../internal/keyboard/keys.js';
|
|
18
19
|
|
|
@@ -53,6 +54,11 @@ const Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardR
|
|
|
53
54
|
const ref = useMergedRefs([forwardRef, menu]);
|
|
54
55
|
const [position, setPosition] = useState([-1, -1]);
|
|
55
56
|
const focusableItems = childContext.state.items.filter(item => !item.disabled && item.ref.current);
|
|
57
|
+
|
|
58
|
+
// Set RTL based on document direction or `LayoutDirection`
|
|
59
|
+
const {
|
|
60
|
+
direction
|
|
61
|
+
} = useLayoutDirection();
|
|
56
62
|
function returnFocus() {
|
|
57
63
|
if (focusReturn.current) {
|
|
58
64
|
focusReturn.current.focus();
|
|
@@ -62,8 +68,14 @@ const Menu = /*#__PURE__*/React__default.forwardRef(function Menu(_ref, forwardR
|
|
|
62
68
|
if (menu.current) {
|
|
63
69
|
focusReturn.current = document.activeElement;
|
|
64
70
|
const pos = calculatePosition();
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
if ((document?.dir === 'rtl' || direction === 'rtl') && !rest?.id?.includes('MenuButton')) {
|
|
72
|
+
menu.current.style.insetInlineStart = `initial`;
|
|
73
|
+
menu.current.style.insetInlineEnd = `${pos[0]}px`;
|
|
74
|
+
} else {
|
|
75
|
+
menu.current.style.insetInlineStart = `${pos[0]}px`;
|
|
76
|
+
menu.current.style.insetInlineEnd = `initial`;
|
|
77
|
+
}
|
|
78
|
+
menu.current.style.insetBlockStart = `${pos[1]}px`;
|
|
67
79
|
setPosition(pos);
|
|
68
80
|
menu.current.focus();
|
|
69
81
|
if (onOpen) {
|
|
@@ -9,16 +9,17 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React__default, { useContext, useRef, useState, useEffect } from 'react';
|
|
12
|
-
import { CaretRight, Checkmark } from '@carbon/react
|
|
12
|
+
import { CaretLeft, CaretRight, Checkmark } from '@carbon/icons-react';
|
|
13
13
|
import { useControllableState } from '../../internal/useControllableState.js';
|
|
14
14
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
16
|
import { Menu } from './Menu.js';
|
|
17
17
|
import { MenuContext } from './MenuContext.js';
|
|
18
|
+
import { useLayoutDirection } from '../LayoutDirection/useLayoutDirection.js';
|
|
18
19
|
import { match } from '../../internal/keyboard/match.js';
|
|
19
20
|
import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
20
21
|
|
|
21
|
-
var _CaretRight;
|
|
22
|
+
var _CaretLeft, _CaretRight;
|
|
22
23
|
const hoverIntentDelay = 150; // in ms
|
|
23
24
|
|
|
24
25
|
const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref, forwardRef) {
|
|
@@ -41,6 +42,7 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
|
|
|
41
42
|
x: -1,
|
|
42
43
|
y: -1
|
|
43
44
|
});
|
|
45
|
+
const [isRtl, setRtl] = useState(false);
|
|
44
46
|
const hasChildren = Boolean(children);
|
|
45
47
|
const [submenuOpen, setSubmenuOpen] = useState(false);
|
|
46
48
|
const hoverIntentTimeout = useRef(null);
|
|
@@ -62,10 +64,17 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
|
|
|
62
64
|
width,
|
|
63
65
|
height
|
|
64
66
|
} = menuItem.current.getBoundingClientRect();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
if (isRtl) {
|
|
68
|
+
setBoundaries({
|
|
69
|
+
x: [-x, x - width],
|
|
70
|
+
y: [y, y + height]
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
setBoundaries({
|
|
74
|
+
x: [x, x + width],
|
|
75
|
+
y: [y, y + height]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
69
78
|
setSubmenuOpen(true);
|
|
70
79
|
}
|
|
71
80
|
function closeSubmenu() {
|
|
@@ -120,6 +129,18 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
|
|
|
120
129
|
registerItem();
|
|
121
130
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
122
131
|
}, []);
|
|
132
|
+
|
|
133
|
+
// Set RTL based on document direction or `LayoutDirection`
|
|
134
|
+
const {
|
|
135
|
+
direction
|
|
136
|
+
} = useLayoutDirection();
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (document?.dir === 'rtl' || direction === 'rtl') {
|
|
139
|
+
setRtl(true);
|
|
140
|
+
} else {
|
|
141
|
+
setRtl(false);
|
|
142
|
+
}
|
|
143
|
+
}, [direction]);
|
|
123
144
|
return /*#__PURE__*/React__default.createElement("li", _extends({
|
|
124
145
|
role: "menuitem"
|
|
125
146
|
}, rest, {
|
|
@@ -141,7 +162,7 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
|
|
|
141
162
|
className: `${prefix}--menu-item__shortcut`
|
|
142
163
|
}, shortcut), hasChildren && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
143
164
|
className: `${prefix}--menu-item__shortcut`
|
|
144
|
-
}, _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null))), /*#__PURE__*/React__default.createElement(Menu, {
|
|
165
|
+
}, isRtl ? _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default.createElement(CaretLeft, null)) : _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null))), /*#__PURE__*/React__default.createElement(Menu, {
|
|
145
166
|
label: label,
|
|
146
167
|
open: submenuOpen,
|
|
147
168
|
onClose: () => {
|
|
@@ -55,7 +55,7 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(_r
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
function handleOpen() {
|
|
58
|
-
menuRef.current.style.
|
|
58
|
+
menuRef.current.style.inlineSize = `${width}px`;
|
|
59
59
|
}
|
|
60
60
|
const triggerClasses = cx(`${prefix}--menu-button__trigger`, {
|
|
61
61
|
[`${prefix}--menu-button__trigger--open`]: open
|
|
@@ -28,7 +28,7 @@ import { match } from '../../internal/keyboard/match.js';
|
|
|
28
28
|
import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
|
|
29
29
|
import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
|
|
30
30
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
31
|
-
import { Space, Enter, Delete,
|
|
31
|
+
import { Escape, Space, Enter, Delete, Tab, Home, End } from '../../internal/keyboard/keys.js';
|
|
32
32
|
|
|
33
33
|
const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function FilterableMultiSelect(_ref, ref) {
|
|
34
34
|
let {
|
|
@@ -151,7 +151,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
151
151
|
case stateChangeTypes.keyDownArrowUp:
|
|
152
152
|
case stateChangeTypes.keyDownHome:
|
|
153
153
|
case stateChangeTypes.keyDownEnd:
|
|
154
|
-
setHighlightedIndex(changes.highlightedIndex !== undefined ? changes.highlightedIndex :
|
|
154
|
+
setHighlightedIndex(changes.highlightedIndex !== undefined ? changes.highlightedIndex : 0);
|
|
155
155
|
if (stateChangeTypes.keyDownArrowDown === type && !isOpen) {
|
|
156
156
|
handleOnMenuChange(true);
|
|
157
157
|
}
|
|
@@ -182,8 +182,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
182
182
|
handleOnMenuChange(false);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function clearInputValue() {
|
|
186
|
-
setInputValue('');
|
|
185
|
+
function clearInputValue(event) {
|
|
186
|
+
textInput.current.value.length === 1 || match(event, Escape) ? setInputValue('') : setInputValue(textInput.current.value);
|
|
187
187
|
if (textInput.current) {
|
|
188
188
|
textInput.current.focus();
|
|
189
189
|
}
|
|
@@ -285,10 +285,10 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
285
285
|
if (match(event, Delete) || match(event, Escape)) {
|
|
286
286
|
if (isOpen) {
|
|
287
287
|
handleOnMenuChange(true);
|
|
288
|
-
clearInputValue();
|
|
288
|
+
clearInputValue(event);
|
|
289
289
|
event.stopPropagation();
|
|
290
290
|
} else if (!isOpen) {
|
|
291
|
-
clearInputValue();
|
|
291
|
+
clearInputValue(event);
|
|
292
292
|
clearSelection();
|
|
293
293
|
event.stopPropagation();
|
|
294
294
|
}
|
|
@@ -255,6 +255,12 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
255
255
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
256
256
|
props.scrollIntoView(itemArray[highlightedIndex]);
|
|
257
257
|
}
|
|
258
|
+
if (highlightedIndex === -1) {
|
|
259
|
+
return {
|
|
260
|
+
...changes,
|
|
261
|
+
highlightedIndex: 0
|
|
262
|
+
};
|
|
263
|
+
}
|
|
258
264
|
return changes;
|
|
259
265
|
case ItemMouseMove:
|
|
260
266
|
return {
|
|
@@ -510,6 +510,7 @@ function ActionableNotification(_ref6) {
|
|
|
510
510
|
const [isOpen, setIsOpen] = useState(true);
|
|
511
511
|
const prefix = usePrefix();
|
|
512
512
|
const id = useId('actionable-notification');
|
|
513
|
+
const subtitleId = useId('actionable-notification-subtitle');
|
|
513
514
|
const containerClassName = cx(className, {
|
|
514
515
|
[`${prefix}--actionable-notification`]: true,
|
|
515
516
|
[`${prefix}--actionable-notification--toast`]: !inline,
|
|
@@ -540,7 +541,7 @@ function ActionableNotification(_ref6) {
|
|
|
540
541
|
ref: ref,
|
|
541
542
|
role: role,
|
|
542
543
|
className: containerClassName,
|
|
543
|
-
"aria-labelledby": title ? id :
|
|
544
|
+
"aria-labelledby": title ? id : subtitleId
|
|
544
545
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
545
546
|
className: `${prefix}--actionable-notification__details`
|
|
546
547
|
}, /*#__PURE__*/React__default.createElement(NotificationIcon, {
|
|
@@ -555,7 +556,8 @@ function ActionableNotification(_ref6) {
|
|
|
555
556
|
className: `${prefix}--actionable-notification__title`,
|
|
556
557
|
id: id
|
|
557
558
|
}, title), subtitle && /*#__PURE__*/React__default.createElement("div", {
|
|
558
|
-
className: `${prefix}--actionable-notification__subtitle
|
|
559
|
+
className: `${prefix}--actionable-notification__subtitle`,
|
|
560
|
+
id: subtitleId
|
|
559
561
|
}, subtitle), children))), actionButtonLabel && /*#__PURE__*/React__default.createElement(NotificationActionButton, {
|
|
560
562
|
onClick: onActionButtonClick,
|
|
561
563
|
inline: inline
|
|
@@ -270,6 +270,7 @@ export default class Slider extends PureComponent<SliderProps> {
|
|
|
270
270
|
left: number;
|
|
271
271
|
needsOnRelease: boolean;
|
|
272
272
|
isValid: boolean;
|
|
273
|
+
isRtl: boolean;
|
|
273
274
|
};
|
|
274
275
|
thumbRef: React.RefObject<HTMLDivElement>;
|
|
275
276
|
filledTrackRef: React.RefObject<HTMLDivElement>;
|
|
@@ -42,7 +42,8 @@ class Slider extends PureComponent {
|
|
|
42
42
|
value: this.props.value,
|
|
43
43
|
left: 0,
|
|
44
44
|
needsOnRelease: false,
|
|
45
|
-
isValid: true
|
|
45
|
+
isValid: true,
|
|
46
|
+
isRtl: false
|
|
46
47
|
});
|
|
47
48
|
_defineProperty(this, "thumbRef", void 0);
|
|
48
49
|
_defineProperty(this, "filledTrackRef", void 0);
|
|
@@ -284,7 +285,7 @@ class Slider extends PureComponent {
|
|
|
284
285
|
// use the provided value or state's value to calculate it instead.
|
|
285
286
|
let leftPercent;
|
|
286
287
|
if (clientX != null) {
|
|
287
|
-
const leftOffset = clientX - (boundingRect?.left ?? 0);
|
|
288
|
+
const leftOffset = this.state.isRtl ? (boundingRect?.right ?? 0) - clientX : clientX - (boundingRect?.left ?? 0);
|
|
288
289
|
leftPercent = leftOffset / width;
|
|
289
290
|
} else {
|
|
290
291
|
if (value == null) {
|
|
@@ -325,7 +326,8 @@ class Slider extends PureComponent {
|
|
|
325
326
|
});
|
|
326
327
|
this.setState({
|
|
327
328
|
value,
|
|
328
|
-
left
|
|
329
|
+
left,
|
|
330
|
+
isRtl: document?.dir === 'rtl'
|
|
329
331
|
});
|
|
330
332
|
}
|
|
331
333
|
}
|
|
@@ -342,11 +344,20 @@ class Slider extends PureComponent {
|
|
|
342
344
|
// Fire onChange event handler if present, if there's a usable value, and
|
|
343
345
|
// if the value is different from the last one
|
|
344
346
|
|
|
347
|
+
// Set alternative positioning if direction is 'rtl'
|
|
345
348
|
if (this.thumbRef.current) {
|
|
346
|
-
this.
|
|
349
|
+
if (this.state.isRtl) {
|
|
350
|
+
this.thumbRef.current.style.insetInlineStart = `calc(${this.state.left}% - 14px)`;
|
|
351
|
+
} else {
|
|
352
|
+
this.thumbRef.current.style.insetInlineStart = `${this.state.left}%`;
|
|
353
|
+
}
|
|
347
354
|
}
|
|
348
355
|
if (this.filledTrackRef.current) {
|
|
349
|
-
|
|
356
|
+
if (this.state.isRtl) {
|
|
357
|
+
this.filledTrackRef.current.style.transform = `translate(100%, -50%) scaleX(-${this.state.left / 100})`;
|
|
358
|
+
} else {
|
|
359
|
+
this.filledTrackRef.current.style.transform = `translate(0%, -50%) scaleX(${this.state.left / 100})`;
|
|
360
|
+
}
|
|
350
361
|
}
|
|
351
362
|
if (prevState.value !== this.state.value && typeof this.props.onChange === 'function') {
|
|
352
363
|
this.props.onChange({
|
|
@@ -29,7 +29,7 @@ import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
|
29
29
|
import { matches, match } from '../../internal/keyboard/match.js';
|
|
30
30
|
import { ArrowRight, ArrowLeft, Home, End, Delete } from '../../internal/keyboard/keys.js';
|
|
31
31
|
|
|
32
|
-
var _ChevronLeft, _ChevronRight
|
|
32
|
+
var _ChevronLeft, _ChevronRight;
|
|
33
33
|
|
|
34
34
|
// Used to manage the overall state of the Tabs
|
|
35
35
|
|
|
@@ -545,21 +545,19 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref5, forwardRef) {
|
|
|
545
545
|
}
|
|
546
546
|
onKeyDown?.(event);
|
|
547
547
|
};
|
|
548
|
-
const DismissIcon =
|
|
549
|
-
/*#__PURE__*/
|
|
550
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
551
|
-
React__default.createElement("div", {
|
|
552
|
-
role: "button",
|
|
548
|
+
const DismissIcon = /*#__PURE__*/React__default.createElement("div", {
|
|
553
549
|
tabIndex: -1,
|
|
554
550
|
"aria-hidden": true,
|
|
555
551
|
className: cx(`${prefix}--tabs__nav-item--close-icon`, {
|
|
556
552
|
[`${prefix}--visually-hidden`]: !dismissable
|
|
557
553
|
}),
|
|
558
554
|
onClick: handleClose,
|
|
559
|
-
"aria-label": "Close tab",
|
|
560
555
|
title: "Close tab",
|
|
561
556
|
ref: dismissIconRef
|
|
562
|
-
},
|
|
557
|
+
}, /*#__PURE__*/React__default.createElement(Close, {
|
|
558
|
+
"aria-hidden": dismissable ? 'false' : 'true',
|
|
559
|
+
"aria-label": "Press delete to close tab"
|
|
560
|
+
}));
|
|
563
561
|
const hasIcon = Icon ?? dismissable;
|
|
564
562
|
return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
565
563
|
"aria-controls": panelId,
|
|
@@ -18,10 +18,13 @@ function TagSkeleton(_ref) {
|
|
|
18
18
|
...rest
|
|
19
19
|
} = _ref;
|
|
20
20
|
const prefix = usePrefix();
|
|
21
|
+
const tagClasses = cx(`${prefix}--tag`, `${prefix}--skeleton`, className, {
|
|
22
|
+
[`${prefix}--tag--${size}`]: size,
|
|
23
|
+
// TODO: V12 - Remove this class
|
|
24
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
25
|
+
});
|
|
21
26
|
return /*#__PURE__*/React__default.createElement("span", _extends({
|
|
22
|
-
className:
|
|
23
|
-
[`${prefix}--tag--${size}`]: size
|
|
24
|
-
})
|
|
27
|
+
className: tagClasses
|
|
25
28
|
}, rest));
|
|
26
29
|
}
|
|
27
30
|
TagSkeleton.propTypes = {
|