@carbon/react 1.88.0 → 1.89.0-rc.1
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 +848 -848
- package/es/components/AILabel/index.d.ts +2 -5
- package/es/components/AILabel/index.js +2 -42
- package/es/components/ContainedList/ContainedList.d.ts +2 -2
- package/es/components/Copy/Copy.js +1 -0
- package/es/components/Link/Link.js +15 -1
- package/es/components/Menu/MenuContext.d.ts +1 -1
- package/es/components/Menu/MenuContext.js +11 -4
- package/es/components/Menu/MenuItem.js +2 -9
- package/es/components/Modal/Modal.js +15 -7
- package/es/components/MultiSelect/FilterableMultiSelect.js +1 -5
- package/es/components/MultiSelect/MultiSelect.js +3 -7
- package/es/components/Popover/index.d.ts +4 -0
- package/es/components/Popover/index.js +11 -22
- package/es/components/StructuredList/StructuredList.d.ts +16 -0
- package/es/components/StructuredList/StructuredList.js +19 -9
- package/es/components/TextArea/TextArea.js +21 -4
- package/es/components/Toggletip/index.d.ts +13 -36
- package/es/components/Toggletip/index.js +11 -51
- package/es/components/UIShell/Header.d.ts +3 -3
- package/es/components/UIShell/Header.js +7 -4
- package/es/internal/Selection.js +1 -1
- package/es/internal/useMergedRefs.js +4 -3
- package/lib/components/AILabel/index.d.ts +2 -5
- package/lib/components/AILabel/index.js +1 -41
- package/lib/components/ContainedList/ContainedList.d.ts +2 -2
- package/lib/components/Copy/Copy.js +1 -0
- package/lib/components/Link/Link.js +15 -1
- package/lib/components/Menu/MenuContext.d.ts +1 -1
- package/lib/components/Menu/MenuContext.js +11 -4
- package/lib/components/Menu/MenuItem.js +2 -9
- package/lib/components/Modal/Modal.js +15 -7
- package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -5
- package/lib/components/MultiSelect/MultiSelect.js +3 -7
- package/lib/components/Popover/index.d.ts +4 -0
- package/lib/components/Popover/index.js +10 -21
- package/lib/components/StructuredList/StructuredList.d.ts +16 -0
- package/lib/components/StructuredList/StructuredList.js +19 -9
- package/lib/components/TextArea/TextArea.js +21 -4
- package/lib/components/Toggletip/index.d.ts +13 -36
- package/lib/components/Toggletip/index.js +10 -50
- package/lib/components/UIShell/Header.d.ts +3 -3
- package/lib/components/UIShell/Header.js +7 -4
- package/lib/internal/Selection.js +1 -1
- package/lib/internal/useMergedRefs.js +3 -2
- package/package.json +12 -13
- package/telemetry.yml +3 -2
|
@@ -9,7 +9,7 @@ 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, { useContext, useRef, useState } from 'react';
|
|
12
|
-
import {
|
|
12
|
+
import { Popover, PopoverContent } from '../Popover/index.js';
|
|
13
13
|
import { Escape } from '../../internal/keyboard/keys.js';
|
|
14
14
|
import { match } from '../../internal/keyboard/match.js';
|
|
15
15
|
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
@@ -149,57 +149,17 @@ function Toggletip({
|
|
|
149
149
|
autoAlign: autoAlign
|
|
150
150
|
}, rest), children));
|
|
151
151
|
}
|
|
152
|
-
Toggletip.propTypes = {
|
|
153
|
-
/**
|
|
154
|
-
* Specify how the toggletip should align with the button
|
|
155
|
-
*/
|
|
156
|
-
align: PropTypes.oneOf(['top', 'top-left',
|
|
157
|
-
// deprecated use top-start instead
|
|
158
|
-
'top-right',
|
|
159
|
-
// deprecated use top-end instead
|
|
160
|
-
|
|
161
|
-
'bottom', 'bottom-left',
|
|
162
|
-
// deprecated use bottom-start instead
|
|
163
|
-
'bottom-right',
|
|
164
|
-
// deprecated use bottom-end instead
|
|
165
152
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
// new values to match floating-ui
|
|
177
|
-
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
|
|
178
|
-
/**
|
|
179
|
-
* **Experimental:** Provide an offset value for alignment axis. Only takes effect when `autoalign` is enabled.
|
|
180
|
-
*/
|
|
181
|
-
alignmentAxisOffset: PropTypes.number,
|
|
182
|
-
/**
|
|
183
|
-
* Provide a custom element or component to render the top-level node for the
|
|
184
|
-
* component.
|
|
185
|
-
*/
|
|
186
|
-
as: PropTypes.elementType,
|
|
187
|
-
/**
|
|
188
|
-
* Will auto-align the popover on first render if it is not visible. This prop
|
|
189
|
-
* is currently experimental and is subject to future changes. Requires
|
|
190
|
-
* React v17+
|
|
191
|
-
* @see https://github.com/carbon-design-system/carbon/issues/18714
|
|
192
|
-
*/
|
|
193
|
-
autoAlign: PropTypes.bool,
|
|
194
|
-
/**
|
|
195
|
-
* Custom children to be rendered as the content of the label
|
|
196
|
-
*/
|
|
197
|
-
children: PropTypes.node,
|
|
198
|
-
/**
|
|
199
|
-
* Provide a custom class name to be added to the outermost node in the
|
|
200
|
-
* component
|
|
201
|
-
*/
|
|
202
|
-
className: PropTypes.string,
|
|
153
|
+
// Get all the properties from Popover except for "open".
|
|
154
|
+
// The Typescript types for PropTypes are really messed up so we need lots of
|
|
155
|
+
// casting. It will be great when we can finally get rid of PropTypes altogether.
|
|
156
|
+
const {
|
|
157
|
+
open,
|
|
158
|
+
...popoverNonOpenPropTypes
|
|
159
|
+
} = Popover.propTypes ?? {};
|
|
160
|
+
Toggletip.propTypes = {
|
|
161
|
+
// Has all of Popover's PropTypes except for "open".
|
|
162
|
+
...popoverNonOpenPropTypes,
|
|
203
163
|
/**
|
|
204
164
|
* Specify if the toggletip should be open by default
|
|
205
165
|
*/
|
|
@@ -8,15 +8,15 @@ import React, { ReactNode } from 'react';
|
|
|
8
8
|
export interface HeaderProps {
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Optionally provide aria-label
|
|
12
12
|
*/
|
|
13
13
|
'aria-label'?: string;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Optionally provide aria-labelledby
|
|
16
16
|
*/
|
|
17
17
|
'aria-labelledby'?: string;
|
|
18
18
|
/**
|
|
19
|
-
* Optionally provide a custom class name that is applied to the underlying
|
|
19
|
+
* Optionally provide a custom class name that is applied to the underlying header
|
|
20
20
|
*/
|
|
21
21
|
className?: string;
|
|
22
22
|
}
|
|
@@ -9,7 +9,6 @@ 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 from 'react';
|
|
12
|
-
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
13
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
13
|
|
|
15
14
|
const Header = ({
|
|
@@ -25,11 +24,15 @@ const Header = ({
|
|
|
25
24
|
};
|
|
26
25
|
Header.propTypes = {
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
27
|
+
* Optionally provide aria-label
|
|
29
28
|
*/
|
|
30
|
-
|
|
29
|
+
'aria-label': PropTypes.string,
|
|
31
30
|
/**
|
|
32
|
-
* Optionally provide
|
|
31
|
+
* Optionally provide aria-labelledby
|
|
32
|
+
*/
|
|
33
|
+
'aria-labelledby': PropTypes.string,
|
|
34
|
+
/**
|
|
35
|
+
* Optionally provide a custom class name that is applied to the underlying header
|
|
33
36
|
*/
|
|
34
37
|
className: PropTypes.string
|
|
35
38
|
};
|
package/es/internal/Selection.js
CHANGED
|
@@ -48,7 +48,7 @@ const useSelection = ({
|
|
|
48
48
|
|
|
49
49
|
// Assert special properties (e.g., `disabled`, `isSelectAll`, etc.) are
|
|
50
50
|
// `any` since those properties aren’t part of the generic type.
|
|
51
|
-
const allSelectableItems = filteredItems.filter(item => !item?.disabled);
|
|
51
|
+
const allSelectableItems = filteredItems.filter(item => !item?.disabled && !item?.isSelectAll);
|
|
52
52
|
const disabledItemCount = filteredItems.filter(item => item?.disabled).length;
|
|
53
53
|
let newSelectedItems;
|
|
54
54
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { useCallback } from 'react';
|
|
8
|
+
import { useMemo, useCallback } from 'react';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Merges multiple refs into a single callback ref.
|
|
@@ -16,15 +16,16 @@ import { useCallback } from 'react';
|
|
|
16
16
|
* node, assigns that node to every ref in the array.
|
|
17
17
|
*/
|
|
18
18
|
const useMergedRefs = refs => {
|
|
19
|
+
const memoizedRefs = useMemo(() => refs, refs);
|
|
19
20
|
return useCallback(node => {
|
|
20
|
-
|
|
21
|
+
memoizedRefs.forEach(ref => {
|
|
21
22
|
if (typeof ref === 'function') {
|
|
22
23
|
ref(node);
|
|
23
24
|
} else if (ref) {
|
|
24
25
|
ref.current = node;
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
|
-
}, [
|
|
28
|
+
}, [memoizedRefs]);
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
export { useMergedRefs };
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { ToggletipBaseProps } from '../Toggletip';
|
|
8
9
|
import type { DeprecatedPopoverAlignment, NewPopoverAlignment, PopoverAlignment } from '../Popover';
|
|
9
10
|
export type AILabelContentProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
10
11
|
export declare const AILabelContent: React.ForwardRefExoticComponent<AILabelContentProps & React.RefAttributes<unknown>>;
|
|
@@ -17,15 +18,11 @@ export declare const AILabelActions: React.ForwardRefExoticComponent<AILabelActi
|
|
|
17
18
|
export type DeprecatedAlignment = DeprecatedPopoverAlignment;
|
|
18
19
|
export type NewAlignment = NewPopoverAlignment;
|
|
19
20
|
export type Alignment = PopoverAlignment;
|
|
20
|
-
export interface AILabelProps {
|
|
21
|
+
export interface AILabelProps extends ToggletipBaseProps {
|
|
21
22
|
AILabelContent?: React.ReactNode;
|
|
22
23
|
aiText?: string;
|
|
23
24
|
aiTextLabel?: string;
|
|
24
25
|
textLabel?: string;
|
|
25
|
-
align?: Alignment;
|
|
26
|
-
autoAlign?: boolean;
|
|
27
|
-
children?: React.ReactNode;
|
|
28
|
-
className?: string;
|
|
29
26
|
kind?: 'default' | 'inline';
|
|
30
27
|
onRevertClick?: (evt: React.MouseEvent<HTMLButtonElement>) => void;
|
|
31
28
|
revertActive?: boolean;
|
|
@@ -10,12 +10,10 @@
|
|
|
10
10
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
11
11
|
var cx = require('classnames');
|
|
12
12
|
var PropTypes = require('prop-types');
|
|
13
|
-
var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
|
|
14
13
|
var React = require('react');
|
|
15
14
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
16
15
|
var index = require('../Toggletip/index.js');
|
|
17
16
|
var index$1 = require('../IconButton/index.js');
|
|
18
|
-
var mapPopoverAlign = require('../../tools/mapPopoverAlign.js');
|
|
19
17
|
var iconsReact = require('@carbon/icons-react');
|
|
20
18
|
var useId = require('../../internal/useId.js');
|
|
21
19
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
@@ -145,6 +143,7 @@ const AILabel = /*#__PURE__*/React.forwardRef(function AILabel({
|
|
|
145
143
|
});
|
|
146
144
|
AILabel.displayName = 'AILabel';
|
|
147
145
|
AILabel.propTypes = {
|
|
146
|
+
...index.Toggletip.propTypes,
|
|
148
147
|
/**
|
|
149
148
|
* Specify the content you want rendered inside the `AILabel` ToggleTip
|
|
150
149
|
*/
|
|
@@ -158,49 +157,10 @@ AILabel.propTypes = {
|
|
|
158
157
|
* Specify additional text to be rendered next to the AI label in the inline variant
|
|
159
158
|
*/
|
|
160
159
|
aiTextLabel: deprecate.deprecate(PropTypes.string, '`aiTextLabel` on `AILabel` has been deprecated - Please use the `textLabel` prop instead'),
|
|
161
|
-
/**
|
|
162
|
-
* Specify how the popover should align with the button
|
|
163
|
-
*/
|
|
164
|
-
align: deprecateValuesWithin.default(PropTypes.oneOf(['top', 'top-left',
|
|
165
|
-
// deprecated use top-start instead
|
|
166
|
-
'top-right',
|
|
167
|
-
// deprecated use top-end instead
|
|
168
|
-
|
|
169
|
-
'bottom', 'bottom-left',
|
|
170
|
-
// deprecated use bottom-start instead
|
|
171
|
-
'bottom-right',
|
|
172
|
-
// deprecated use bottom-end instead
|
|
173
|
-
|
|
174
|
-
'left', 'left-bottom',
|
|
175
|
-
// deprecated use left-end instead
|
|
176
|
-
'left-top',
|
|
177
|
-
// deprecated use left-start instead
|
|
178
|
-
|
|
179
|
-
'right', 'right-bottom',
|
|
180
|
-
// deprecated use right-end instead
|
|
181
|
-
'right-top',
|
|
182
|
-
// deprecated use right-start instead
|
|
183
|
-
|
|
184
|
-
// new values to match floating-ui
|
|
185
|
-
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']), ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'], mapPopoverAlign.mapPopoverAlign),
|
|
186
160
|
/**
|
|
187
161
|
* Specify the text that will be provided to the aria-label of the `AILabel` button
|
|
188
162
|
*/
|
|
189
163
|
'aria-label': PropTypes.string,
|
|
190
|
-
/**
|
|
191
|
-
* Will auto-align the popover. This prop is currently experimental and is
|
|
192
|
-
* subject to future changes. Requires React v17+
|
|
193
|
-
* @see https://github.com/carbon-design-system/carbon/issues/18714
|
|
194
|
-
*/
|
|
195
|
-
autoAlign: PropTypes.bool,
|
|
196
|
-
/**
|
|
197
|
-
* Specify the content you want rendered inside the `AILabel` ToggleTip
|
|
198
|
-
*/
|
|
199
|
-
children: PropTypes.node,
|
|
200
|
-
/**
|
|
201
|
-
* Specify an optional className to be added to the `AILabel`
|
|
202
|
-
*/
|
|
203
|
-
className: PropTypes.string,
|
|
204
164
|
/**
|
|
205
165
|
* Specify the type of `AILabel`, from the following list of types:
|
|
206
166
|
*/
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
8
|
import ContainedListItem from './ContainedListItem';
|
|
9
9
|
declare const variants: readonly ["on-page", "disclosed"];
|
|
10
|
-
export
|
|
10
|
+
export type ContainedListType = React.FC<ContainedListProps> & {
|
|
11
11
|
ContainedListItem: typeof ContainedListItem;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
export type Variants = (typeof variants)[number];
|
|
14
14
|
export interface ContainedListProps {
|
|
15
15
|
/**
|
|
@@ -61,6 +61,7 @@ function Copy({
|
|
|
61
61
|
autoAlign: autoAlign,
|
|
62
62
|
className: classNames,
|
|
63
63
|
label: animation ? feedback : initialLabel,
|
|
64
|
+
leaveDelayMs: animation ? feedbackTimeout : undefined,
|
|
64
65
|
onClick: events.composeEventHandlers([onClick, handleClick]),
|
|
65
66
|
onAnimationEnd: events.composeEventHandlers([onAnimationEnd, handleAnimationEnd])
|
|
66
67
|
}, other, {
|
|
@@ -52,9 +52,23 @@ const LinkBase = /*#__PURE__*/React.forwardRef(({
|
|
|
52
52
|
linkProps['aria-disabled'] = true;
|
|
53
53
|
}
|
|
54
54
|
const BaseComponentAsAny = BaseComponent ?? 'a';
|
|
55
|
+
const handleOnClick = event => {
|
|
56
|
+
if (disabled) {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
} else {
|
|
60
|
+
// If the link is not disabled, we allow the onClick event to propagate
|
|
61
|
+
// so that any parent handlers can also respond to the click.
|
|
62
|
+
if (rest.onClick) {
|
|
63
|
+
rest.onClick(event);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
55
67
|
return /*#__PURE__*/React.createElement(BaseComponentAsAny, _rollupPluginBabelHelpers.extends({
|
|
56
68
|
ref: ref
|
|
57
|
-
}, linkProps, rest
|
|
69
|
+
}, linkProps, rest, {
|
|
70
|
+
onClick: handleOnClick
|
|
71
|
+
}), children, !inline && Icon && /*#__PURE__*/React.createElement("div", {
|
|
58
72
|
className: `${prefix}--link__icon`
|
|
59
73
|
}, /*#__PURE__*/React.createElement(Icon, null)));
|
|
60
74
|
});
|
|
@@ -30,10 +30,17 @@ function menuReducer(state, action) {
|
|
|
30
30
|
hasSelectableItems: true
|
|
31
31
|
};
|
|
32
32
|
case 'registerItem':
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
items
|
|
36
|
-
|
|
33
|
+
{
|
|
34
|
+
const newItem = action.payload;
|
|
35
|
+
const items = state.items.filter(item => item.ref.current);
|
|
36
|
+
const next = newItem.ref.current?.nextElementSibling;
|
|
37
|
+
const idx = items.findIndex(item => item.ref.current === next);
|
|
38
|
+
items.splice(idx < 0 ? items.length : idx, 0, newItem);
|
|
39
|
+
return {
|
|
40
|
+
...state,
|
|
41
|
+
items
|
|
42
|
+
};
|
|
43
|
+
}
|
|
37
44
|
}
|
|
38
45
|
}
|
|
39
46
|
const MenuContext = /*#__PURE__*/React.createContext({
|
|
@@ -130,18 +130,11 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem({
|
|
|
130
130
|
[`${prefix}--menu-item--disabled`]: isDisabled,
|
|
131
131
|
[`${prefix}--menu-item--danger`]: isDanger
|
|
132
132
|
});
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
// on first render, register this menuitem in the context's state
|
|
135
135
|
// (used for keyboard navigation)
|
|
136
136
|
React.useEffect(() => {
|
|
137
137
|
registerItem();
|
|
138
|
-
|
|
139
|
-
// Detects if this is the first focusable item
|
|
140
|
-
const currentItems = context.state.items;
|
|
141
|
-
if (!disabled && menuItem.current && currentItems.length === 0) {
|
|
142
|
-
setIsFocusable(true);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
138
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
146
139
|
}, []);
|
|
147
140
|
|
|
@@ -180,7 +173,7 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem({
|
|
|
180
173
|
}, rest, {
|
|
181
174
|
ref: ref,
|
|
182
175
|
className: classNames,
|
|
183
|
-
tabIndex:
|
|
176
|
+
tabIndex: !disabled ? 0 : -1,
|
|
184
177
|
"aria-disabled": isDisabled ?? undefined,
|
|
185
178
|
"aria-haspopup": hasChildren ?? undefined,
|
|
186
179
|
"aria-expanded": hasChildren ? submenuOpen : undefined,
|
|
@@ -85,6 +85,7 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal({
|
|
|
85
85
|
const innerModal = React.useRef(null);
|
|
86
86
|
const startTrap = React.useRef(null);
|
|
87
87
|
const endTrap = React.useRef(null);
|
|
88
|
+
const wrapFocusTimeout = React.useRef(null);
|
|
88
89
|
const [isScrollable, setIsScrollable] = React.useState(false);
|
|
89
90
|
const prevOpen = usePreviousValue.usePreviousValue(open);
|
|
90
91
|
const modalInstanceId = `modal-${useId.useId()}`;
|
|
@@ -146,13 +147,20 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal({
|
|
|
146
147
|
const {
|
|
147
148
|
current: endTrapNode
|
|
148
149
|
} = endTrap;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
// use setTimeout to ensure focus is set after all browser default focus behavior. Fixes issue of
|
|
151
|
+
// focus not wrapping in Firefox
|
|
152
|
+
wrapFocusTimeout.current = setTimeout(() => {
|
|
153
|
+
wrapFocus.wrapFocus({
|
|
154
|
+
bodyNode,
|
|
155
|
+
startTrapNode,
|
|
156
|
+
endTrapNode,
|
|
157
|
+
currentActiveNode,
|
|
158
|
+
oldActiveNode,
|
|
159
|
+
selectorsFloatingMenus
|
|
160
|
+
});
|
|
161
|
+
if (wrapFocusTimeout.current) {
|
|
162
|
+
clearTimeout(wrapFocusTimeout.current);
|
|
163
|
+
}
|
|
156
164
|
});
|
|
157
165
|
}
|
|
158
166
|
|
|
@@ -124,11 +124,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
124
124
|
inputValue
|
|
125
125
|
}), [items, inputValue, itemToString$1, filterItems]);
|
|
126
126
|
const nonSelectAllItems = React.useMemo(() => filteredItems.filter(item => !item.isSelectAll), [filteredItems]);
|
|
127
|
-
|
|
128
|
-
if ((selected ?? []).length > 0 && selectAll) {
|
|
129
|
-
console.warn('Warning: `selectAll` should not be used when `selectedItems` is provided. Please pass either `selectAll` or `selectedItems`, not both.');
|
|
130
|
-
selectAll = false;
|
|
131
|
-
}
|
|
127
|
+
const selectAll = filteredItems.some(item => item.isSelectAll);
|
|
132
128
|
const {
|
|
133
129
|
selectedItems: controlledSelectedItems,
|
|
134
130
|
onItemChange,
|
|
@@ -113,11 +113,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
113
113
|
return true; // Return true if item is not an object with undefined values
|
|
114
114
|
});
|
|
115
115
|
}, [items]);
|
|
116
|
-
|
|
117
|
-
if ((selected ?? []).length > 0 && selectAll) {
|
|
118
|
-
console.warn('Warning: `selectAll` should not be used when `selectedItems` is provided. Please pass either `selectAll` or `selectedItems`, not both.');
|
|
119
|
-
selectAll = false;
|
|
120
|
-
}
|
|
116
|
+
const selectAll = filteredItems.some(item => item.isSelectAll);
|
|
121
117
|
const prefix = usePrefix.usePrefix();
|
|
122
118
|
const {
|
|
123
119
|
isFluid
|
|
@@ -491,13 +487,13 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
491
487
|
})), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
492
488
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
493
489
|
}, normalizedDecorator) : ''), /*#__PURE__*/React.createElement(index$2.default.Menu, menuProps, isOpen && sortItems(filteredItems, sortOptions).map((item, index) => {
|
|
494
|
-
const isChecked = selectedItems.filter(selected => isEqual(selected, item)).length > 0;
|
|
495
490
|
const {
|
|
496
491
|
hasIndividualSelections,
|
|
497
492
|
nonSelectAllSelectedCount,
|
|
498
493
|
totalSelectableCount
|
|
499
494
|
} = getSelectionStats(selectedItems, filteredItems);
|
|
500
|
-
const
|
|
495
|
+
const isChecked = item.isSelectAll ? nonSelectAllSelectedCount === totalSelectableCount && totalSelectableCount > 0 : selectedItems.some(selected => isEqual(selected, item));
|
|
496
|
+
const isIndeterminate = item.isSelectAll && hasIndividualSelections && nonSelectAllSelectedCount < totalSelectableCount;
|
|
501
497
|
const itemProps = getItemProps({
|
|
502
498
|
item,
|
|
503
499
|
// we don't want Downshift to set aria-selected for us
|
|
@@ -25,6 +25,10 @@ export interface PopoverBaseProps {
|
|
|
25
25
|
* Specify how the popover should align with the trigger element.
|
|
26
26
|
*/
|
|
27
27
|
align?: PopoverAlignment;
|
|
28
|
+
/**
|
|
29
|
+
* **Experimental:** Provide an offset value for alignment axis. Only takes effect when `autoalign` is enabled.
|
|
30
|
+
*/
|
|
31
|
+
alignmentAxisOffset?: number;
|
|
28
32
|
/**
|
|
29
33
|
* Will auto-align the popover on first render if it is not visible. This prop
|
|
30
34
|
* is currently experimental and is subject to future changes. Requires
|
|
@@ -19,7 +19,6 @@ var useEvent = require('../../internal/useEvent.js');
|
|
|
19
19
|
var mapPopoverAlign = require('../../tools/mapPopoverAlign.js');
|
|
20
20
|
var react = require('@floating-ui/react');
|
|
21
21
|
var index = require('../FeatureFlags/index.js');
|
|
22
|
-
var index$1 = require('../Toggletip/index.js');
|
|
23
22
|
|
|
24
23
|
const PopoverContext = /*#__PURE__*/React.createContext({
|
|
25
24
|
setFloating: {
|
|
@@ -64,7 +63,10 @@ forwardRef) {
|
|
|
64
63
|
// The `Popover` should close whenever it and its children loses focus
|
|
65
64
|
useEvent.useEvent(popover, 'focusout', event => {
|
|
66
65
|
const relatedTarget = event.relatedTarget;
|
|
66
|
+
|
|
67
|
+
// No relatedTarget, focus moved to nowhere, so close the popover
|
|
67
68
|
if (!relatedTarget) {
|
|
69
|
+
onRequestClose?.();
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
70
72
|
const isOutsideMainContainer = !popover.current?.contains(relatedTarget);
|
|
@@ -237,7 +239,7 @@ forwardRef) {
|
|
|
237
239
|
// For a toggletip there is a specific trigger component, ToggletipButton.
|
|
238
240
|
// In either of these cases we want to set this as the reference node for floating-ui autoAlign
|
|
239
241
|
// positioning.
|
|
240
|
-
if (enableFloatingStyles && item?.type !== PopoverContent || enableFloatingStyles && item?.type ===
|
|
242
|
+
if (enableFloatingStyles && item?.type !== PopoverContent || enableFloatingStyles && item?.type['displayName'] === 'ToggletipButton') {
|
|
241
243
|
// Set the reference element for floating-ui
|
|
242
244
|
refs.setReference(node);
|
|
243
245
|
}
|
|
@@ -294,6 +296,10 @@ Popover.propTypes = {
|
|
|
294
296
|
|
|
295
297
|
// new values to match floating-ui
|
|
296
298
|
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']), ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'], mapPopoverAlign.mapPopoverAlign),
|
|
299
|
+
/**
|
|
300
|
+
* **Experimental:** Provide an offset value for alignment axis. Only takes effect when `autoalign` is enabled.
|
|
301
|
+
*/
|
|
302
|
+
alignmentAxisOffset: PropTypes.number,
|
|
297
303
|
/**
|
|
298
304
|
* Provide a custom element or component to render the top-level node for the
|
|
299
305
|
* component.
|
|
@@ -363,29 +369,12 @@ function PopoverContentRenderFunction(
|
|
|
363
369
|
caretRef,
|
|
364
370
|
autoAlign
|
|
365
371
|
} = React.useContext(PopoverContext);
|
|
366
|
-
const
|
|
367
|
-
const [isMultiLine, setIsMultiLine] = React.useState(false);
|
|
368
|
-
const ref = useMergedRefs.useMergedRefs([setFloating, textRef, forwardRef]);
|
|
372
|
+
const ref = useMergedRefs.useMergedRefs([setFloating, forwardRef]);
|
|
369
373
|
const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
370
|
-
React.useEffect(() => {
|
|
371
|
-
checkIfMultiLine();
|
|
372
|
-
}, [children]);
|
|
373
|
-
const checkIfMultiLine = () => {
|
|
374
|
-
const el = textRef.current;
|
|
375
|
-
if (el) {
|
|
376
|
-
const style = getComputedStyle(el);
|
|
377
|
-
const lineHeight = parseFloat(style.lineHeight);
|
|
378
|
-
const height = el.offsetHeight;
|
|
379
|
-
const lines = Math.floor(height / lineHeight);
|
|
380
|
-
setIsMultiLine(lines > 1);
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
374
|
return /*#__PURE__*/React.createElement("span", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
384
375
|
className: `${prefix}--popover`
|
|
385
376
|
}), /*#__PURE__*/React.createElement("span", {
|
|
386
|
-
className: cx(`${prefix}--popover-content`, className,
|
|
387
|
-
[`${prefix}--tooltip-content--multiline`]: isMultiLine
|
|
388
|
-
}),
|
|
377
|
+
className: cx(`${prefix}--popover-content`, className),
|
|
389
378
|
ref: ref
|
|
390
379
|
}, children, enableFloatingStyles && /*#__PURE__*/React.createElement("span", {
|
|
391
380
|
className: cx({
|
|
@@ -32,6 +32,10 @@ export interface StructuredListWrapperProps extends DivAttrs {
|
|
|
32
32
|
* Specify whether your StructuredListWrapper should have selections
|
|
33
33
|
*/
|
|
34
34
|
selection?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Specify which row will be selected initially
|
|
37
|
+
*/
|
|
38
|
+
selectedInitialRow?: string;
|
|
35
39
|
}
|
|
36
40
|
export declare function StructuredListWrapper(props: StructuredListWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
37
41
|
export declare namespace StructuredListWrapper {
|
|
@@ -65,6 +69,10 @@ export declare namespace StructuredListWrapper {
|
|
|
65
69
|
* Specify whether your StructuredListWrapper should have selections
|
|
66
70
|
*/
|
|
67
71
|
selection: PropTypes.Requireable<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Specify which row will be selected initially
|
|
74
|
+
*/
|
|
75
|
+
selectedInitialRow: PropTypes.Requireable<string>;
|
|
68
76
|
};
|
|
69
77
|
}
|
|
70
78
|
export interface StructuredListHeadProps extends DivAttrs {
|
|
@@ -148,6 +156,10 @@ export interface StructuredListRowProps extends DivAttrs {
|
|
|
148
156
|
* Mark if this row should be selectable
|
|
149
157
|
*/
|
|
150
158
|
selection?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Specify row id so that it can be used for initial selection
|
|
161
|
+
*/
|
|
162
|
+
id?: string;
|
|
151
163
|
}
|
|
152
164
|
export declare function StructuredListRow(props: StructuredListRowProps): import("react/jsx-runtime").JSX.Element;
|
|
153
165
|
export declare namespace StructuredListRow {
|
|
@@ -180,6 +192,10 @@ export declare namespace StructuredListRow {
|
|
|
180
192
|
* Mark if this row should be selectable
|
|
181
193
|
*/
|
|
182
194
|
selection: PropTypes.Requireable<boolean>;
|
|
195
|
+
/**
|
|
196
|
+
* Specify row id so that it can be used for initial selection
|
|
197
|
+
*/
|
|
198
|
+
id: PropTypes.Requireable<string>;
|
|
183
199
|
};
|
|
184
200
|
}
|
|
185
201
|
export interface StructuredListInputProps extends DivAttrs {
|
|
@@ -32,6 +32,7 @@ function StructuredListWrapper(props) {
|
|
|
32
32
|
ariaLabel: deprecatedAriaLabel,
|
|
33
33
|
isCondensed,
|
|
34
34
|
isFlush,
|
|
35
|
+
selectedInitialRow,
|
|
35
36
|
...other
|
|
36
37
|
} = props;
|
|
37
38
|
const prefix = usePrefix.usePrefix();
|
|
@@ -40,7 +41,7 @@ function StructuredListWrapper(props) {
|
|
|
40
41
|
[`${prefix}--structured-list--condensed`]: isCondensed,
|
|
41
42
|
[`${prefix}--structured-list--flush`]: isFlush && !selection
|
|
42
43
|
}, className);
|
|
43
|
-
const [selectedRow, setSelectedRow] = React.useState(null);
|
|
44
|
+
const [selectedRow, setSelectedRow] = React.useState(selectedInitialRow ?? null);
|
|
44
45
|
return /*#__PURE__*/React.createElement(GridSelectedRowStateContext.Provider, {
|
|
45
46
|
value: selectedRow
|
|
46
47
|
}, /*#__PURE__*/React.createElement(GridSelectedRowDispatchContext.Provider, {
|
|
@@ -81,7 +82,11 @@ StructuredListWrapper.propTypes = {
|
|
|
81
82
|
/**
|
|
82
83
|
* Specify whether your StructuredListWrapper should have selections
|
|
83
84
|
*/
|
|
84
|
-
selection: PropTypes.bool
|
|
85
|
+
selection: PropTypes.bool,
|
|
86
|
+
/**
|
|
87
|
+
* Specify which row will be selected initially
|
|
88
|
+
*/
|
|
89
|
+
selectedInitialRow: PropTypes.string
|
|
85
90
|
};
|
|
86
91
|
function StructuredListHead(props) {
|
|
87
92
|
const {
|
|
@@ -143,21 +148,22 @@ function StructuredListRow(props) {
|
|
|
143
148
|
head,
|
|
144
149
|
onClick,
|
|
145
150
|
selection,
|
|
151
|
+
id,
|
|
146
152
|
...other
|
|
147
153
|
} = props;
|
|
148
154
|
const [hasFocusWithin, setHasFocusWithin] = React.useState(false);
|
|
149
|
-
const
|
|
155
|
+
const rowId = id ?? useId.useId('grid-input');
|
|
150
156
|
const selectedRow = React.useContext(GridSelectedRowStateContext);
|
|
151
157
|
const setSelectedRow = React.useContext(GridSelectedRowDispatchContext);
|
|
152
158
|
const prefix = usePrefix.usePrefix();
|
|
153
159
|
const value = {
|
|
154
|
-
id
|
|
160
|
+
id: rowId
|
|
155
161
|
};
|
|
156
162
|
const classes = cx(`${prefix}--structured-list-row`, {
|
|
157
163
|
[`${prefix}--structured-list-row--header-row`]: head,
|
|
158
|
-
[`${prefix}--structured-list-row--focused-within`]: hasFocusWithin && !selection || hasFocusWithin && selection && (selectedRow ===
|
|
164
|
+
[`${prefix}--structured-list-row--focused-within`]: hasFocusWithin && !selection || hasFocusWithin && selection && (selectedRow === rowId || selectedRow === null),
|
|
159
165
|
// Ensure focus on the first item when navigating through Tab keys and no row is selected (selectedRow === null)
|
|
160
|
-
[`${prefix}--structured-list-row--selected`]: selectedRow ===
|
|
166
|
+
[`${prefix}--structured-list-row--selected`]: selectedRow === rowId
|
|
161
167
|
}, className);
|
|
162
168
|
const itemRef = React.useRef(null);
|
|
163
169
|
const handleClick = () => {
|
|
@@ -178,7 +184,7 @@ function StructuredListRow(props) {
|
|
|
178
184
|
className: classes,
|
|
179
185
|
ref: itemRef,
|
|
180
186
|
onClick: event => {
|
|
181
|
-
setSelectedRow?.(
|
|
187
|
+
setSelectedRow?.(rowId);
|
|
182
188
|
onClick && onClick(event);
|
|
183
189
|
if (selection) {
|
|
184
190
|
// focus items only when selection is enabled
|
|
@@ -194,7 +200,7 @@ function StructuredListRow(props) {
|
|
|
194
200
|
onKeyDown: onKeyDown
|
|
195
201
|
}), /*#__PURE__*/React.createElement(GridRowContext.Provider, {
|
|
196
202
|
value: value
|
|
197
|
-
}, selection && /*#__PURE__*/React.createElement(StructuredListCell, null, selectedRow ===
|
|
203
|
+
}, selection && /*#__PURE__*/React.createElement(StructuredListCell, null, selectedRow === rowId ? /*#__PURE__*/React.createElement(iconsReact.RadioButtonChecked, {
|
|
198
204
|
className: `${prefix}--structured-list__icon`
|
|
199
205
|
}) : /*#__PURE__*/React.createElement(iconsReact.RadioButton, {
|
|
200
206
|
className: `${prefix}--structured-list__icon`
|
|
@@ -228,7 +234,11 @@ StructuredListRow.propTypes = {
|
|
|
228
234
|
/**
|
|
229
235
|
* Mark if this row should be selectable
|
|
230
236
|
*/
|
|
231
|
-
selection: PropTypes.bool
|
|
237
|
+
selection: PropTypes.bool,
|
|
238
|
+
/**
|
|
239
|
+
* Specify row id so that it can be used for initial selection
|
|
240
|
+
*/
|
|
241
|
+
id: PropTypes.string
|
|
232
242
|
};
|
|
233
243
|
function StructuredListInput(props) {
|
|
234
244
|
const defaultId = useId.useId('structureListInput');
|