@carbon/react 1.111.1 → 1.112.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 +935 -935
- package/es/components/ComboBox/ComboBox.js +7 -7
- package/es/components/DatePicker/DatePicker.js +1 -2
- package/es/components/DatePicker/plugins/fixEventsPlugin.d.ts +2 -5
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +5 -12
- package/es/components/Dropdown/Dropdown.js +1 -4
- package/es/components/FeatureFlags/index.d.ts +3 -1
- package/es/components/FeatureFlags/index.js +36 -14
- package/es/components/IconIndicator/index.d.ts +33 -1
- package/es/components/IconIndicator/index.js +55 -26
- package/es/components/ListBox/next/ListBoxSelection.d.ts +12 -2
- package/es/components/ListBox/next/ListBoxSelection.js +7 -2
- package/es/components/Modal/Modal.js +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +19 -10
- package/es/components/MultiSelect/MultiSelect.js +3 -4
- package/es/components/OverflowMenu/OverflowMenu.js +31 -6
- package/es/components/OverflowMenu/next/index.d.ts +1 -1
- package/es/components/OverflowMenu/next/index.js +2 -2
- package/es/components/ShapeIndicator/index.d.ts +18 -0
- package/es/components/ShapeIndicator/index.js +49 -7
- package/es/components/Tabs/Tabs.js +1 -1
- package/es/components/Tooltip/DefinitionTooltip.js +5 -2
- package/es/feature-flags.js +1 -0
- package/es/internal/index.d.ts +2 -1
- package/es/internal/isItemDisabled.d.ts +7 -0
- package/es/internal/isItemDisabled.js +17 -0
- package/lib/components/ComboBox/ComboBox.js +7 -7
- package/lib/components/DatePicker/DatePicker.js +1 -2
- package/lib/components/DatePicker/plugins/fixEventsPlugin.d.ts +2 -5
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +5 -12
- package/lib/components/Dropdown/Dropdown.js +2 -5
- package/lib/components/FeatureFlags/index.d.ts +3 -1
- package/lib/components/FeatureFlags/index.js +36 -14
- package/lib/components/IconIndicator/index.d.ts +33 -1
- package/lib/components/IconIndicator/index.js +54 -25
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +12 -2
- package/lib/components/ListBox/next/ListBoxSelection.js +7 -2
- package/lib/components/Modal/Modal.js +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +19 -10
- package/lib/components/MultiSelect/MultiSelect.js +3 -4
- package/lib/components/OverflowMenu/OverflowMenu.js +30 -5
- package/lib/components/OverflowMenu/next/index.d.ts +1 -1
- package/lib/components/OverflowMenu/next/index.js +2 -2
- package/lib/components/ShapeIndicator/index.d.ts +18 -0
- package/lib/components/ShapeIndicator/index.js +48 -6
- package/lib/components/Tabs/Tabs.js +1 -1
- package/lib/components/Tooltip/DefinitionTooltip.js +4 -1
- package/lib/feature-flags.js +1 -0
- package/lib/internal/index.d.ts +2 -1
- package/lib/internal/isItemDisabled.d.ts +7 -0
- package/lib/internal/isItemDisabled.js +17 -0
- package/package.json +15 -11
- package/telemetry.yml +4 -1
|
@@ -18,7 +18,7 @@ import { mergeRefs } from "../../tools/mergeRefs.js";
|
|
|
18
18
|
import { DIRECTION_BOTTOM, FloatingMenu } from "../../internal/FloatingMenu.js";
|
|
19
19
|
import { useOutsideClick } from "../../internal/useOutsideClick.js";
|
|
20
20
|
import classNames from "classnames";
|
|
21
|
-
import React, { Children, cloneElement, forwardRef, isValidElement, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
21
|
+
import React, { Children, cloneElement, forwardRef, isValidElement, useCallback, useContext, useEffect, useReducer, useRef, useState } from "react";
|
|
22
22
|
import PropTypes from "prop-types";
|
|
23
23
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { OverflowMenuVertical } from "@carbon/icons-react";
|
|
@@ -81,7 +81,7 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
const OverflowMenu = forwardRef(({ align, ["aria-label"]: ariaLabel = null, ariaLabel: deprecatedAriaLabel, children, className, direction = DIRECTION_BOTTOM, flipped = false, focusTrap = false, iconClass, iconDescription = "Options", id, light, menuOffset = getMenuOffset, menuOffsetFlip = getMenuOffset, menuOptionsClass, onClick = noopFn, onClose = noopFn, onOpen = noopFn, open: openProp, renderIcon: IconElement = OverflowMenuVertical, selectorPrimaryFocus = "[data-floating-menu-primary-focus]", size
|
|
84
|
+
const OverflowMenu = forwardRef(({ align, ["aria-label"]: ariaLabel = null, ariaLabel: deprecatedAriaLabel, children, className, direction = DIRECTION_BOTTOM, flipped = false, focusTrap = false, iconClass, iconDescription = "Options", id, light, menuOffset = getMenuOffset, menuOffsetFlip = getMenuOffset, menuOptionsClass, onClick = noopFn, onClose = noopFn, onOpen = noopFn, open: openProp, renderIcon: IconElement = OverflowMenuVertical, selectorPrimaryFocus = "[data-floating-menu-primary-focus]", size, innerRef, ...other }, ref) => {
|
|
85
85
|
const prefix = useContext(PrefixContext);
|
|
86
86
|
const [open, setOpen] = useState(openProp ?? false);
|
|
87
87
|
const [click, setClick] = useState(false);
|
|
@@ -96,6 +96,8 @@ const OverflowMenu = forwardRef(({ align, ["aria-label"]: ariaLabel = null, aria
|
|
|
96
96
|
/** The element ref of the tooltip's trigger button. */
|
|
97
97
|
const triggerRef = useRef(null);
|
|
98
98
|
const wrapperRef = useRef(null);
|
|
99
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
100
|
+
const resizeObserverRef = useRef(null);
|
|
99
101
|
useEffect(() => {
|
|
100
102
|
if (prevOpenProp.current !== openProp) {
|
|
101
103
|
setOpen(!!openProp);
|
|
@@ -105,6 +107,26 @@ const OverflowMenu = forwardRef(({ align, ["aria-label"]: ariaLabel = null, aria
|
|
|
105
107
|
useEffect(() => {
|
|
106
108
|
if (triggerRef.current) setHasMountedTrigger(true);
|
|
107
109
|
}, []);
|
|
110
|
+
/**
|
|
111
|
+
* When `size` is brought in from a contextual layout token, FloatingMenu can't detect size changes
|
|
112
|
+
* while the menu is open since there is no state/prop update. This ResizeObserver watches
|
|
113
|
+
* the trigger button when the menu is open and calls `forceUpdate()` on resize to force a re-render if its
|
|
114
|
+
* size changes while the menu is open
|
|
115
|
+
*/
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
resizeObserverRef.current = new ResizeObserver(() => {
|
|
118
|
+
forceUpdate();
|
|
119
|
+
});
|
|
120
|
+
return () => {
|
|
121
|
+
resizeObserverRef.current?.disconnect();
|
|
122
|
+
resizeObserverRef.current = null;
|
|
123
|
+
};
|
|
124
|
+
}, []);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!triggerRef.current || !resizeObserverRef.current) return;
|
|
127
|
+
if (open) resizeObserverRef.current.observe(triggerRef.current);
|
|
128
|
+
else resizeObserverRef.current.disconnect();
|
|
129
|
+
}, [open]);
|
|
108
130
|
useEffect(() => {
|
|
109
131
|
if (open && !prevOpenState.current) onOpen();
|
|
110
132
|
else if (!open && prevOpenState.current) onClose();
|
|
@@ -205,22 +227,25 @@ const OverflowMenu = forwardRef(({ align, ["aria-label"]: ariaLabel = null, aria
|
|
|
205
227
|
};
|
|
206
228
|
const getTarget = () => {
|
|
207
229
|
const triggerEl = triggerRef.current;
|
|
208
|
-
if (triggerEl instanceof Element) return triggerEl.closest("[data-floating-menu-container]") || document.body;
|
|
230
|
+
if (triggerEl instanceof Element) return triggerEl.closest("[data-floating-menu-container]") || triggerEl.closest(`.${prefix}--layout`) || document.body;
|
|
209
231
|
return document.body;
|
|
210
232
|
};
|
|
211
233
|
const menuBodyId = `overflow-menu-${instanceId.current}__menu-body`;
|
|
212
234
|
const overflowMenuClasses = classNames(className, `${prefix}--overflow-menu`, {
|
|
213
235
|
[`${prefix}--overflow-menu--open`]: open,
|
|
214
236
|
[`${prefix}--overflow-menu--light`]: light,
|
|
215
|
-
[`${prefix}--overflow-menu--${size}`]: size
|
|
237
|
+
[`${prefix}--overflow-menu--${size}`]: size,
|
|
238
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
216
239
|
});
|
|
217
240
|
const overflowMenuOptionsClasses = classNames(menuOptionsClass, `${prefix}--overflow-menu-options`, {
|
|
218
241
|
[`${prefix}--overflow-menu--flip`]: flipped,
|
|
219
242
|
[`${prefix}--overflow-menu-options--open`]: open,
|
|
220
243
|
[`${prefix}--overflow-menu-options--light`]: light,
|
|
221
|
-
[`${prefix}--overflow-menu-options--${size}`]: size
|
|
244
|
+
[`${prefix}--overflow-menu-options--${size}`]: size,
|
|
245
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
222
246
|
});
|
|
223
247
|
const overflowMenuIconClasses = classNames(`${prefix}--overflow-menu__icon`, iconClass);
|
|
248
|
+
const overflowMenuWrapperClasses = classNames(`${prefix}--overflow-menu__wrapper`);
|
|
224
249
|
const childrenWithProps = Children.toArray(children).map((child, index) => {
|
|
225
250
|
if (isValidElement(child)) {
|
|
226
251
|
const childElement = child;
|
|
@@ -257,7 +282,7 @@ const OverflowMenu = forwardRef(({ align, ["aria-label"]: ariaLabel = null, aria
|
|
|
257
282
|
});
|
|
258
283
|
const combinedRef = innerRef ? mergeRefs(triggerRef, innerRef, ref) : mergeRefs(triggerRef, ref);
|
|
259
284
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("span", {
|
|
260
|
-
className:
|
|
285
|
+
className: overflowMenuWrapperClasses,
|
|
261
286
|
"aria-owns": open ? menuBodyId : void 0,
|
|
262
287
|
ref: wrapperRef,
|
|
263
288
|
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
@@ -22,7 +22,7 @@ import { OverflowMenuVertical } from "@carbon/icons-react";
|
|
|
22
22
|
import { autoUpdate, flip, useFloating } from "@floating-ui/react";
|
|
23
23
|
//#region src/components/OverflowMenu/next/index.tsx
|
|
24
24
|
/**
|
|
25
|
-
* Copyright IBM Corp. 2020,
|
|
25
|
+
* Copyright IBM Corp. 2020, 2026
|
|
26
26
|
*
|
|
27
27
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
28
28
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -67,7 +67,7 @@ const OverflowMenu = React.forwardRef(({ autoAlign = false, children, className,
|
|
|
67
67
|
}
|
|
68
68
|
const containerClasses = classNames(className, `${prefix}--overflow-menu__container`, { [`${prefix}--autoalign`]: enableFloatingStyles });
|
|
69
69
|
const menuClasses = classNames(`${prefix}--overflow-menu__${menuAlignment}`);
|
|
70
|
-
const triggerClasses = classNames(`${prefix}--overflow-menu`, { [`${prefix}--overflow-menu--open`]: open }, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
|
|
70
|
+
const triggerClasses = classNames(`${prefix}--overflow-menu`, { [`${prefix}--overflow-menu--open`]: open }, size !== defaultSize && `${prefix}--overflow-menu--${size}`, size !== defaultSize && `${prefix}--layout--size-${size}`);
|
|
71
71
|
const floatingRef = mergeRefs(triggerRef, refs.setReference);
|
|
72
72
|
return /* @__PURE__ */ jsxs("div", {
|
|
73
73
|
...rest,
|
|
@@ -5,13 +5,26 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { PopoverAlignment } from '../Popover';
|
|
8
9
|
export declare const ShapeIndicatorKinds: string[];
|
|
9
10
|
export type ShapeIndicatorKind = (typeof ShapeIndicatorKinds)[number];
|
|
10
11
|
export interface ShapeIndicatorProps {
|
|
12
|
+
/**
|
|
13
|
+
* Specify how the tooltip should align with the shape in compact mode
|
|
14
|
+
*/
|
|
15
|
+
align?: PopoverAlignment;
|
|
16
|
+
/**
|
|
17
|
+
* Will auto-align the tooltip in compact mode.
|
|
18
|
+
*/
|
|
19
|
+
autoAlign?: boolean;
|
|
11
20
|
/**
|
|
12
21
|
* Specify an optional className to add.
|
|
13
22
|
*/
|
|
14
23
|
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* When true, displays only the shape with the label in a tooltip
|
|
26
|
+
*/
|
|
27
|
+
compact?: boolean;
|
|
15
28
|
/**
|
|
16
29
|
* Specify the kind of shape to be used
|
|
17
30
|
*/
|
|
@@ -20,6 +33,11 @@ export interface ShapeIndicatorProps {
|
|
|
20
33
|
* Label next to the shape
|
|
21
34
|
*/
|
|
22
35
|
label: string;
|
|
36
|
+
/**
|
|
37
|
+
* Description for the shape announced to screen readers in compact mode.
|
|
38
|
+
* Defaults to `label` when not provided.
|
|
39
|
+
*/
|
|
40
|
+
shapeDescription?: string;
|
|
23
41
|
/**
|
|
24
42
|
* Specify the text size of the Shape Indicator. Defaults to 12.
|
|
25
43
|
*/
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
|
+
import { DefinitionTooltip } from "../Tooltip/DefinitionTooltip.js";
|
|
9
10
|
import classNames from "classnames";
|
|
10
11
|
import React from "react";
|
|
11
12
|
import PropTypes from "prop-types";
|
|
12
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
import { Caution, CircleFill, CircleStroke, Critical, CriticalSeverity, DiamondFill, LowSeverity } from "@carbon/icons-react";
|
|
14
15
|
//#region src/components/ShapeIndicator/index.tsx
|
|
15
16
|
/**
|
|
@@ -61,26 +62,62 @@ const shapeTypes = {
|
|
|
61
62
|
incomplete: incompleteIcon,
|
|
62
63
|
draft: CircleStroke
|
|
63
64
|
};
|
|
64
|
-
const ShapeIndicator = React.forwardRef(({ className: customClassName, kind, label, textSize = 12 }, ref) => {
|
|
65
|
+
const ShapeIndicator = React.forwardRef(({ align = "right", autoAlign = false, className: customClassName, compact = false, kind, label, shapeDescription, textSize = 12 }, ref) => {
|
|
65
66
|
const prefix = usePrefix();
|
|
66
67
|
const classNames$1 = classNames(`${prefix}--shape-indicator`, customClassName, { [`${prefix}--shape-indicator--14`]: textSize == 14 });
|
|
67
68
|
const ShapeForKind = shapeTypes[kind];
|
|
68
69
|
if (!ShapeForKind) return null;
|
|
69
|
-
|
|
70
|
+
const shapeElement = /* @__PURE__ */ jsx(ShapeForKind, {
|
|
71
|
+
size: 16,
|
|
72
|
+
className: `${prefix}--shape-indicator--${kind}`
|
|
73
|
+
});
|
|
74
|
+
return /* @__PURE__ */ jsx("div", {
|
|
70
75
|
className: classNames$1,
|
|
71
76
|
ref,
|
|
72
|
-
children:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
children: compact ? /* @__PURE__ */ jsxs(DefinitionTooltip, {
|
|
78
|
+
align,
|
|
79
|
+
autoAlign,
|
|
80
|
+
openOnHover: true,
|
|
81
|
+
definition: label,
|
|
82
|
+
triggerClassName: `${prefix}--shape-indicator__button`,
|
|
83
|
+
children: [shapeElement, /* @__PURE__ */ jsx("span", {
|
|
84
|
+
className: `${prefix}--visually-hidden`,
|
|
85
|
+
children: shapeDescription ?? label
|
|
86
|
+
})]
|
|
87
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [shapeElement, label] })
|
|
76
88
|
});
|
|
77
89
|
});
|
|
78
90
|
ShapeIndicator.propTypes = {
|
|
91
|
+
/**
|
|
92
|
+
* Specify how the tooltip should align with the shape in compact mode
|
|
93
|
+
*/
|
|
94
|
+
align: PropTypes.oneOf([
|
|
95
|
+
"top",
|
|
96
|
+
"top-start",
|
|
97
|
+
"top-end",
|
|
98
|
+
"bottom",
|
|
99
|
+
"bottom-start",
|
|
100
|
+
"bottom-end",
|
|
101
|
+
"left",
|
|
102
|
+
"left-start",
|
|
103
|
+
"left-end",
|
|
104
|
+
"right",
|
|
105
|
+
"right-start",
|
|
106
|
+
"right-end"
|
|
107
|
+
]),
|
|
108
|
+
/**
|
|
109
|
+
* Will auto-align the tooltip in compact mode
|
|
110
|
+
*/
|
|
111
|
+
autoAlign: PropTypes.bool,
|
|
79
112
|
/**
|
|
80
113
|
* Specify an optional className to add.
|
|
81
114
|
*/
|
|
82
115
|
className: PropTypes.string,
|
|
83
116
|
/**
|
|
117
|
+
* When true, displays only the shape with the label in a tooltip
|
|
118
|
+
*/
|
|
119
|
+
compact: PropTypes.bool,
|
|
120
|
+
/**
|
|
84
121
|
* Specify the kind of the Shape Indicator
|
|
85
122
|
*/
|
|
86
123
|
kind: PropTypes.oneOf(ShapeIndicatorKinds).isRequired,
|
|
@@ -89,6 +126,11 @@ ShapeIndicator.propTypes = {
|
|
|
89
126
|
*/
|
|
90
127
|
label: PropTypes.string.isRequired,
|
|
91
128
|
/**
|
|
129
|
+
* Description for the shape announced to screen readers in compact mode.
|
|
130
|
+
* Defaults to `label` when not provided.
|
|
131
|
+
*/
|
|
132
|
+
shapeDescription: PropTypes.string,
|
|
133
|
+
/**
|
|
92
134
|
* Specify the text size of the Shape Indicator. Defaults to 12.
|
|
93
135
|
*/
|
|
94
136
|
textSize: PropTypes.oneOf([12, 14])
|
|
@@ -930,7 +930,7 @@ function TabPanels({ children }) {
|
|
|
930
930
|
const isVertical = tabContainer?.classList.contains(`${prefix}--tabs--vertical`);
|
|
931
931
|
const parentHasHeight = tabContainer?.parentElement?.style.height;
|
|
932
932
|
if (isVertical && !parentHasHeight) {
|
|
933
|
-
hiddenStates.current = refs.current.map((ref) => ref?.hidden || false);
|
|
933
|
+
hiddenStates.current = refs.current.map((ref) => ref?.hasAttribute("hidden") || false);
|
|
934
934
|
refs.current.forEach((ref) => {
|
|
935
935
|
if (ref) ref.hidden = false;
|
|
936
936
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
|
-
import { Escape } from "../../internal/keyboard/keys.js";
|
|
9
|
+
import { Enter, Escape, Space } from "../../internal/keyboard/keys.js";
|
|
10
10
|
import { match } from "../../internal/keyboard/match.js";
|
|
11
11
|
import { useFallbackId } from "../../internal/useId.js";
|
|
12
12
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
@@ -27,7 +27,10 @@ const DefinitionTooltip = ({ align = "bottom", autoAlign, className, children, d
|
|
|
27
27
|
const prefix = usePrefix();
|
|
28
28
|
const tooltipId = useFallbackId(id);
|
|
29
29
|
function onKeyDown(event) {
|
|
30
|
-
if (
|
|
30
|
+
if (match(event, Enter) || match(event, Space)) {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
setOpen(!isOpen);
|
|
33
|
+
} else if (isOpen && match(event, Escape)) {
|
|
31
34
|
event.stopPropagation();
|
|
32
35
|
setOpen(false);
|
|
33
36
|
}
|
package/es/feature-flags.js
CHANGED
package/es/internal/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
2
|
+
* Copyright IBM Corp. 2025, 2026
|
|
3
3
|
*
|
|
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
7
|
export * from './defaultItemToString';
|
|
8
|
+
export * from './isItemDisabled';
|
|
8
9
|
export * from './utils';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
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
|
+
|
|
8
|
+
//#region src/internal/isItemDisabled.ts
|
|
9
|
+
/**
|
|
10
|
+
* Copyright IBM Corp. 2026
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/
|
|
15
|
+
const isItemDisabled = (item) => item !== null && typeof item === "object" && "disabled" in item && item.disabled === true;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { isItemDisabled };
|
|
@@ -13,6 +13,7 @@ const require_match = require("../../internal/keyboard/match.js");
|
|
|
13
13
|
const require_useId = require("../../internal/useId.js");
|
|
14
14
|
const require_deprecate = require("../../prop-types/deprecate.js");
|
|
15
15
|
const require_defaultItemToString = require("../../internal/defaultItemToString.js");
|
|
16
|
+
const require_isItemDisabled = require("../../internal/isItemDisabled.js");
|
|
16
17
|
const require_utils = require("../../internal/utils.js");
|
|
17
18
|
const require_index = require("../FeatureFlags/index.js");
|
|
18
19
|
const require_useNormalizedInputProps = require("../../internal/useNormalizedInputProps.js");
|
|
@@ -44,7 +45,6 @@ react_fast_compare = require_runtime.__toESM(react_fast_compare);
|
|
|
44
45
|
*/
|
|
45
46
|
const { InputBlur, InputKeyDownEnter, FunctionToggleMenu, ToggleButtonClick, ItemMouseMove, InputKeyDownArrowUp, InputKeyDownArrowDown, MenuMouseLeave, ItemClick, FunctionSelectItem } = downshift.useCombobox.stateChangeTypes;
|
|
46
47
|
const defaultShouldFilterItem = () => true;
|
|
47
|
-
const isDisabledItem = (item) => item !== null && typeof item === "object" && "disabled" in item && Boolean(item.disabled);
|
|
48
48
|
const autocompleteCustomFilter = ({ item, inputValue }) => {
|
|
49
49
|
if (inputValue === null || inputValue === "") return true;
|
|
50
50
|
const lowercaseItem = item.toLowerCase();
|
|
@@ -61,7 +61,7 @@ const findHighlightedIndex = ({ items, itemToString = require_defaultItemToStrin
|
|
|
61
61
|
const searchValue = inputValue.toLowerCase();
|
|
62
62
|
for (let i = 0; i < items.length; i++) {
|
|
63
63
|
const item = itemToString(items[i]).toLowerCase();
|
|
64
|
-
if (!
|
|
64
|
+
if (!require_isItemDisabled.isItemDisabled(items[i]) && item.indexOf(searchValue) !== -1) return i;
|
|
65
65
|
}
|
|
66
66
|
return -1;
|
|
67
67
|
};
|
|
@@ -104,7 +104,7 @@ const ComboBox = (0, react.forwardRef)((props, ref) => {
|
|
|
104
104
|
(0, react.useEffect)(() => {
|
|
105
105
|
if (typeahead) {
|
|
106
106
|
if (inputValue.length >= prevInputLengthRef.current) if (inputValue) {
|
|
107
|
-
const filteredItems = items.filter((item) => !
|
|
107
|
+
const filteredItems = items.filter((item) => !require_isItemDisabled.isItemDisabled(item) && autocompleteCustomFilter({
|
|
108
108
|
item: itemToString(item),
|
|
109
109
|
inputValue
|
|
110
110
|
}));
|
|
@@ -226,7 +226,7 @@ const ComboBox = (0, react.forwardRef)((props, ref) => {
|
|
|
226
226
|
case InputKeyDownEnter:
|
|
227
227
|
if (!allowCustomValue) if (state.highlightedIndex !== -1) {
|
|
228
228
|
const highlightedItem = filterItems(items, itemToString, inputValue)[state.highlightedIndex];
|
|
229
|
-
if (highlightedItem && !
|
|
229
|
+
if (highlightedItem && !require_isItemDisabled.isItemDisabled(highlightedItem)) return {
|
|
230
230
|
...changes,
|
|
231
231
|
selectedItem: highlightedItem,
|
|
232
232
|
inputValue: itemToString(highlightedItem)
|
|
@@ -235,7 +235,7 @@ const ComboBox = (0, react.forwardRef)((props, ref) => {
|
|
|
235
235
|
const autoIndex = indexToHighlight(inputValue);
|
|
236
236
|
if (autoIndex !== -1) {
|
|
237
237
|
const matchingItem = items[autoIndex];
|
|
238
|
-
if (matchingItem && !
|
|
238
|
+
if (matchingItem && !require_isItemDisabled.isItemDisabled(matchingItem)) return {
|
|
239
239
|
...changes,
|
|
240
240
|
selectedItem: matchingItem,
|
|
241
241
|
inputValue: itemToString(matchingItem)
|
|
@@ -357,7 +357,7 @@ const ComboBox = (0, react.forwardRef)((props, ref) => {
|
|
|
357
357
|
initialSelectedItem,
|
|
358
358
|
inputId: id,
|
|
359
359
|
stateReducer,
|
|
360
|
-
isItemDisabled:
|
|
360
|
+
isItemDisabled: require_isItemDisabled.isItemDisabled,
|
|
361
361
|
...downshiftProps,
|
|
362
362
|
onStateChange: ({ type, selectedItem: newSelectedItem }) => {
|
|
363
363
|
if (isManualClearingRef.current || isSyncingControlledSelectionRef.current) {
|
|
@@ -544,7 +544,7 @@ const ComboBox = (0, react.forwardRef)((props, ref) => {
|
|
|
544
544
|
}
|
|
545
545
|
if (typeahead && event.key === "Tab") {
|
|
546
546
|
if (!isOpen) return;
|
|
547
|
-
const matchingItem = items.find((item) => !
|
|
547
|
+
const matchingItem = items.find((item) => !require_isItemDisabled.isItemDisabled(item) && itemToString(item).toLowerCase().startsWith(inputValue.toLowerCase()));
|
|
548
548
|
if (matchingItem) {
|
|
549
549
|
downshiftSetInputValue(itemToString(matchingItem));
|
|
550
550
|
selectItem(matchingItem);
|
|
@@ -286,10 +286,9 @@ const DatePicker = (0, react.forwardRef)((props, ref) => {
|
|
|
286
286
|
classFlatpickrCurrentMonth: "cur-month",
|
|
287
287
|
locale
|
|
288
288
|
}),
|
|
289
|
-
require_fixEventsPlugin.
|
|
289
|
+
require_fixEventsPlugin.fixEventsPlugin({
|
|
290
290
|
inputFrom: startInputField.current,
|
|
291
291
|
inputTo: endInputField.current,
|
|
292
|
-
lastStartValue,
|
|
293
292
|
container: wrapperRef.current
|
|
294
293
|
})
|
|
295
294
|
],
|
|
@@ -8,11 +8,8 @@ import type { Plugin } from 'flatpickr/dist/types/options';
|
|
|
8
8
|
interface FixEventsPluginConfig {
|
|
9
9
|
inputFrom: HTMLInputElement;
|
|
10
10
|
inputTo?: HTMLInputElement | null;
|
|
11
|
-
lastStartValue: {
|
|
12
|
-
current: string;
|
|
13
|
-
};
|
|
14
11
|
container?: HTMLElement | null;
|
|
15
12
|
}
|
|
16
13
|
type FixEventsPlugin = (config: FixEventsPluginConfig) => Plugin;
|
|
17
|
-
declare const fixEventsPlugin: FixEventsPlugin;
|
|
18
|
-
export
|
|
14
|
+
export declare const fixEventsPlugin: FixEventsPlugin;
|
|
15
|
+
export {};
|
|
@@ -9,14 +9,13 @@ const require_keys = require("../../../internal/keyboard/keys.js");
|
|
|
9
9
|
const require_match = require("../../../internal/keyboard/match.js");
|
|
10
10
|
//#region src/components/DatePicker/plugins/fixEventsPlugin.ts
|
|
11
11
|
const fixEventsPlugin = (config) => (fp) => {
|
|
12
|
-
const { inputFrom, inputTo,
|
|
12
|
+
const { inputFrom, inputTo, container } = config;
|
|
13
13
|
let mouseDownInside = false;
|
|
14
|
-
const getEventPath = (event) => typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
15
14
|
const isEventInside = (event) => {
|
|
16
|
-
const path =
|
|
15
|
+
const path = event.composedPath();
|
|
17
16
|
const { target } = event;
|
|
18
17
|
if (!(target instanceof Node)) return false;
|
|
19
|
-
return Boolean(container && (path.includes(container) || container.contains(target)) ||
|
|
18
|
+
return Boolean(container && (path.includes(container) || container.contains(target)) || path.includes(fp.calendarContainer) || fp.calendarContainer.contains(target) || inputFrom && (path.includes(inputFrom) || inputFrom.contains(target)) || inputTo && (path.includes(inputTo) || inputTo.contains(target)));
|
|
20
19
|
};
|
|
21
20
|
/**
|
|
22
21
|
* Handles `click` outside to close calendar
|
|
@@ -62,6 +61,7 @@ const fixEventsPlugin = (config) => (fp) => {
|
|
|
62
61
|
}
|
|
63
62
|
};
|
|
64
63
|
const parseDateWithFormat = (dateStr) => fp.parseDate(dateStr, fp.config.dateFormat);
|
|
64
|
+
const isValidDate = (date) => date?.toString() !== "Invalid Date";
|
|
65
65
|
/**
|
|
66
66
|
* Handles `blur` event.
|
|
67
67
|
*
|
|
@@ -78,16 +78,9 @@ const fixEventsPlugin = (config) => (fp) => {
|
|
|
78
78
|
const currentValueToDate = withoutTime(parseDateWithFormat(inputTo.value));
|
|
79
79
|
if (selectedToDate && currentValueToDate && selectedToDate !== currentValueToDate) fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
|
|
80
80
|
}
|
|
81
|
-
const isValidDate = (date) => date?.toString() !== "Invalid Date";
|
|
82
81
|
if (inputTo === target && fp.selectedDates.length === 1 && inputTo.value) {
|
|
83
82
|
if (isValidDate(parseDateWithFormat(inputTo.value))) fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
|
|
84
83
|
}
|
|
85
|
-
if (inputTo === target && !inputFrom.value && lastStartValue.current) {
|
|
86
|
-
if (isValidDate(parseDateWithFormat(lastStartValue.current))) {
|
|
87
|
-
inputFrom.value = lastStartValue.current;
|
|
88
|
-
if (inputTo.value) fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
84
|
};
|
|
92
85
|
/**
|
|
93
86
|
* Releases event listeners used in this Flatpickr plugin.
|
|
@@ -128,4 +121,4 @@ const fixEventsPlugin = (config) => (fp) => {
|
|
|
128
121
|
};
|
|
129
122
|
};
|
|
130
123
|
//#endregion
|
|
131
|
-
exports.
|
|
124
|
+
exports.fixEventsPlugin = fixEventsPlugin;
|
|
@@ -9,6 +9,7 @@ const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
|
9
9
|
const require_usePrefix = require("../../internal/usePrefix.js");
|
|
10
10
|
const require_deprecate = require("../../prop-types/deprecate.js");
|
|
11
11
|
const require_defaultItemToString = require("../../internal/defaultItemToString.js");
|
|
12
|
+
const require_isItemDisabled = require("../../internal/isItemDisabled.js");
|
|
12
13
|
const require_utils = require("../../internal/utils.js");
|
|
13
14
|
const require_index = require("../FeatureFlags/index.js");
|
|
14
15
|
const require_useNormalizedInputProps = require("../../internal/useNormalizedInputProps.js");
|
|
@@ -103,9 +104,6 @@ const Dropdown = react.default.forwardRef(({ autoAlign = false, className: conta
|
|
|
103
104
|
const onSelectedItemChange = (0, react.useCallback)(({ selectedItem }) => {
|
|
104
105
|
if (onChange) onChange({ selectedItem: selectedItem ?? null });
|
|
105
106
|
}, [onChange]);
|
|
106
|
-
const isItemDisabled = (0, react.useCallback)((item) => {
|
|
107
|
-
return item !== null && typeof item === "object" && "disabled" in item && item.disabled === true;
|
|
108
|
-
}, []);
|
|
109
107
|
const onHighlightedIndexChange = (0, react.useCallback)((changes) => {
|
|
110
108
|
const { highlightedIndex } = changes;
|
|
111
109
|
if (highlightedIndex !== void 0 && highlightedIndex > -1) {
|
|
@@ -123,7 +121,7 @@ const Dropdown = react.default.forwardRef(({ autoAlign = false, className: conta
|
|
|
123
121
|
initialSelectedItem,
|
|
124
122
|
onSelectedItemChange,
|
|
125
123
|
stateReducer,
|
|
126
|
-
isItemDisabled,
|
|
124
|
+
isItemDisabled: require_isItemDisabled.isItemDisabled,
|
|
127
125
|
onHighlightedIndexChange,
|
|
128
126
|
...downshiftProps
|
|
129
127
|
}), [
|
|
@@ -132,7 +130,6 @@ const Dropdown = react.default.forwardRef(({ autoAlign = false, className: conta
|
|
|
132
130
|
initialSelectedItem,
|
|
133
131
|
onSelectedItemChange,
|
|
134
132
|
stateReducer,
|
|
135
|
-
isItemDisabled,
|
|
136
133
|
onHighlightedIndexChange,
|
|
137
134
|
downshiftProps
|
|
138
135
|
]);
|
|
@@ -9,6 +9,7 @@ import { type ReactNode } from 'react';
|
|
|
9
9
|
export interface FeatureFlagsProps {
|
|
10
10
|
children?: ReactNode;
|
|
11
11
|
flags?: Record<string, boolean>;
|
|
12
|
+
enableV12Release?: boolean;
|
|
12
13
|
enableV12TileDefaultIcons?: boolean;
|
|
13
14
|
enableV12TileRadioIcons?: boolean;
|
|
14
15
|
enableV12Overflowmenu?: boolean;
|
|
@@ -26,13 +27,14 @@ export interface FeatureFlagsProps {
|
|
|
26
27
|
* a feature flag is enabled or disabled in a given React tree
|
|
27
28
|
*/
|
|
28
29
|
export declare const FeatureFlags: {
|
|
29
|
-
({ children, flags, enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, enableFocusWrapWithoutSentinels, enableDialogElement, enableV12DynamicFloatingStyles, enableEnhancedFileUploader, enablePresence, }: FeatureFlagsProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
({ children, flags, enableV12Release, enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, enableFocusWrapWithoutSentinels, enableDialogElement, enableV12DynamicFloatingStyles, enableEnhancedFileUploader, enablePresence, }: FeatureFlagsProps): import("react/jsx-runtime").JSX.Element;
|
|
30
31
|
propTypes: {
|
|
31
32
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
32
33
|
/**
|
|
33
34
|
* Provide the feature flags to enabled or disabled in the current Rea,ct tree
|
|
34
35
|
*/
|
|
35
36
|
flags: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
|
|
37
|
+
enableV12Release: PropTypes.Requireable<boolean>;
|
|
36
38
|
enableV12TileDefaultIcons: PropTypes.Requireable<boolean>;
|
|
37
39
|
enableV12TileRadioIcons: PropTypes.Requireable<boolean>;
|
|
38
40
|
enableV12Overflowmenu: PropTypes.Requireable<boolean>;
|
|
@@ -25,30 +25,51 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
25
25
|
* or disable feature flags in a given React tree
|
|
26
26
|
*/
|
|
27
27
|
const FeatureFlagContext = (0, react.createContext)(_carbon_feature_flags.FeatureFlags);
|
|
28
|
+
const PROP_TO_FLAG = {
|
|
29
|
+
enableV12Release: "enable-v12-release",
|
|
30
|
+
enableV12TileDefaultIcons: "enable-v12-tile-default-icons",
|
|
31
|
+
enableV12TileRadioIcons: "enable-v12-tile-radio-icons",
|
|
32
|
+
enableV12Overflowmenu: "enable-v12-overflowmenu",
|
|
33
|
+
enableTreeviewControllable: "enable-treeview-controllable",
|
|
34
|
+
enableExperimentalFocusWrapWithoutSentinels: "enable-experimental-focus-wrap-without-sentinels",
|
|
35
|
+
enableFocusWrapWithoutSentinels: "enable-focus-wrap-without-sentinels",
|
|
36
|
+
enableDialogElement: "enable-dialog-element",
|
|
37
|
+
enableV12DynamicFloatingStyles: "enable-v12-dynamic-floating-styles",
|
|
38
|
+
enableEnhancedFileUploader: "enable-enhanced-file-uploader",
|
|
39
|
+
enablePresence: "enable-presence"
|
|
40
|
+
};
|
|
28
41
|
/**
|
|
29
42
|
* Supports an object of feature flag values with the `flags` prop, merging them
|
|
30
43
|
* along with the current `FeatureFlagContext` to provide consumers to check if
|
|
31
44
|
* a feature flag is enabled or disabled in a given React tree
|
|
32
45
|
*/
|
|
33
|
-
const FeatureFlags = ({ children, flags
|
|
46
|
+
const FeatureFlags = ({ children, flags, enableV12Release, enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, enableFocusWrapWithoutSentinels, enableDialogElement, enableV12DynamicFloatingStyles, enableEnhancedFileUploader, enablePresence }) => {
|
|
34
47
|
const parentScope = (0, react.useContext)(FeatureFlagContext);
|
|
35
48
|
const scope = (0, react.useMemo)(() => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
+
const flagProps = {
|
|
50
|
+
enableV12Release,
|
|
51
|
+
enableV12TileDefaultIcons,
|
|
52
|
+
enableV12TileRadioIcons,
|
|
53
|
+
enableV12Overflowmenu,
|
|
54
|
+
enableTreeviewControllable,
|
|
55
|
+
enableExperimentalFocusWrapWithoutSentinels,
|
|
56
|
+
enableFocusWrapWithoutSentinels,
|
|
57
|
+
enableDialogElement,
|
|
58
|
+
enableV12DynamicFloatingStyles,
|
|
59
|
+
enableEnhancedFileUploader,
|
|
60
|
+
enablePresence
|
|
61
|
+
};
|
|
62
|
+
const explicitFlags = {};
|
|
63
|
+
for (const [prop, flagKey] of Object.entries(PROP_TO_FLAG)) {
|
|
64
|
+
const value = flagProps[prop];
|
|
65
|
+
if (value !== void 0) explicitFlags[flagKey] = value;
|
|
66
|
+
}
|
|
67
|
+
if (flags) Object.assign(explicitFlags, flags);
|
|
68
|
+
const scope = (0, _carbon_feature_flags.createScope)(explicitFlags);
|
|
49
69
|
scope.mergeWithScope(parentScope);
|
|
50
70
|
return scope;
|
|
51
71
|
}, [
|
|
72
|
+
enableV12Release,
|
|
52
73
|
enableV12TileDefaultIcons,
|
|
53
74
|
enableV12TileRadioIcons,
|
|
54
75
|
enableV12Overflowmenu,
|
|
@@ -73,6 +94,7 @@ FeatureFlags.propTypes = {
|
|
|
73
94
|
* Provide the feature flags to enabled or disabled in the current Rea,ct tree
|
|
74
95
|
*/
|
|
75
96
|
flags: require_deprecate.deprecate(prop_types.default.objectOf(prop_types.default.bool), "The `flags` prop for `FeatureFlag` has been deprecated. Please run the `featureflag-deprecate-flags-prop` codemod to migrate to individual boolean props.npx @carbon/upgrade migrate featureflag-deprecate-flags-prop --write"),
|
|
97
|
+
enableV12Release: prop_types.default.bool,
|
|
76
98
|
enableV12TileDefaultIcons: prop_types.default.bool,
|
|
77
99
|
enableV12TileRadioIcons: prop_types.default.bool,
|
|
78
100
|
enableV12Overflowmenu: prop_types.default.bool,
|