@carbon/react 1.107.0-rc.0 → 1.107.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 +918 -918
- package/es/components/Button/Button.d.ts +2 -2
- package/es/components/ComboButton/index.js +2 -2
- package/es/components/Modal/Modal.d.ts +1 -1
- package/es/components/Modal/Modal.js +17 -6
- package/es/components/NumberInput/NumberInput.js +4 -2
- package/es/components/OverflowMenu/OverflowMenu.js +12 -11
- package/es/components/Slider/Slider.js +12 -14
- package/lib/components/Button/Button.d.ts +2 -2
- package/lib/components/ComboButton/index.js +2 -2
- package/lib/components/Modal/Modal.d.ts +1 -1
- package/lib/components/Modal/Modal.js +16 -5
- package/lib/components/NumberInput/NumberInput.js +4 -2
- package/lib/components/OverflowMenu/OverflowMenu.js +11 -10
- package/lib/components/Slider/Slider.js +12 -14
- package/package.json +11 -11
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React from 'react';
|
|
7
|
+
import React, { type ReactNode } from 'react';
|
|
8
8
|
import { IconButtonKind } from '../IconButton';
|
|
9
9
|
import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
|
|
10
10
|
export declare const ButtonKinds: readonly ["primary", "secondary", "danger", "ghost", "danger--primary", "danger--ghost", "danger--tertiary", "tertiary"];
|
|
@@ -82,6 +82,6 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
82
82
|
tooltipPosition?: ButtonTooltipPosition;
|
|
83
83
|
}
|
|
84
84
|
export type ButtonProps<T extends React.ElementType> = PolymorphicComponentPropWithRef<T, ButtonBaseProps>;
|
|
85
|
-
export type ButtonComponent = <T extends React.ElementType = 'button'>(props: ButtonProps<T
|
|
85
|
+
export type ButtonComponent = <T extends React.ElementType = 'button'>(props: ButtonProps<T>) => ReactNode;
|
|
86
86
|
declare const _default: ButtonComponent;
|
|
87
87
|
export default _default;
|
|
@@ -38,8 +38,8 @@ const ComboButton = React.forwardRef(function ComboButton({ children, className,
|
|
|
38
38
|
const id = useId("combobutton");
|
|
39
39
|
const prefix = usePrefix();
|
|
40
40
|
const containerRef = useRef(null);
|
|
41
|
-
|
|
42
|
-
if (!enableOnlyFloatingStyles) middlewares
|
|
41
|
+
const middlewares = [];
|
|
42
|
+
if (!enableOnlyFloatingStyles) middlewares.push(flip({ crossAxis: false }), hide());
|
|
43
43
|
if (menuAlignment === "bottom" || menuAlignment === "top") middlewares.push(size({ apply({ rects, elements }) {
|
|
44
44
|
Object.assign(elements.floating.style, { width: `${rects.reference.width}px` });
|
|
45
45
|
} }));
|
|
@@ -57,7 +57,7 @@ export interface ModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
57
57
|
/**
|
|
58
58
|
* Provide a ref to return focus to once the modal is closed.
|
|
59
59
|
*/
|
|
60
|
-
launcherButtonRef?: RefObject<
|
|
60
|
+
launcherButtonRef?: RefObject<HTMLElement | null>;
|
|
61
61
|
/**
|
|
62
62
|
* Specify the description for the loading text
|
|
63
63
|
*/
|
|
@@ -9,6 +9,7 @@ import { usePrefix } from "../../internal/usePrefix.js";
|
|
|
9
9
|
import { Text } from "../Text/Text.js";
|
|
10
10
|
import { Enter, Escape, Tab } from "../../internal/keyboard/keys.js";
|
|
11
11
|
import { match } from "../../internal/keyboard/match.js";
|
|
12
|
+
import { selectorTabbable } from "../../internal/keyboard/navigation.js";
|
|
12
13
|
import { useId } from "../../internal/useId.js";
|
|
13
14
|
import { noopFn } from "../../internal/noopFn.js";
|
|
14
15
|
import { warning } from "../../internal/warning.js";
|
|
@@ -31,7 +32,7 @@ import { Dialog } from "../Dialog/Dialog.js";
|
|
|
31
32
|
import { usePreviousValue } from "../../internal/usePreviousValue.js";
|
|
32
33
|
import { ModalPresence, ModalPresenceContext, useExclusiveModalPresenceContext } from "./ModalPresence.js";
|
|
33
34
|
import classNames from "classnames";
|
|
34
|
-
import React, { cloneElement, useContext, useEffect, useRef } from "react";
|
|
35
|
+
import React, { cloneElement, useCallback, useContext, useEffect, useRef } from "react";
|
|
35
36
|
import PropTypes from "prop-types";
|
|
36
37
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
37
38
|
import { Close } from "@carbon/icons-react";
|
|
@@ -209,25 +210,35 @@ const ModalDialog = React.forwardRef(function ModalDialog({ "aria-label": ariaLa
|
|
|
209
210
|
prefix,
|
|
210
211
|
enableDialogElement
|
|
211
212
|
]);
|
|
213
|
+
const focusLauncherButton = useCallback(() => {
|
|
214
|
+
if (!launcherButtonRef || !launcherButtonRef.current) return;
|
|
215
|
+
const { current: launcherButton } = launcherButtonRef;
|
|
216
|
+
(launcherButton.matches(selectorTabbable) ? launcherButton : launcherButton.querySelector(selectorTabbable))?.focus();
|
|
217
|
+
}, [launcherButtonRef]);
|
|
212
218
|
useEffect(() => {
|
|
213
219
|
if (!enableDialogElement && !enablePresence && prevOpen && !open && launcherButtonRef) setTimeout(() => {
|
|
214
|
-
|
|
220
|
+
focusLauncherButton();
|
|
215
221
|
});
|
|
216
222
|
}, [
|
|
217
223
|
open,
|
|
218
224
|
prevOpen,
|
|
219
225
|
launcherButtonRef,
|
|
220
226
|
enableDialogElement,
|
|
221
|
-
enablePresence
|
|
227
|
+
enablePresence,
|
|
228
|
+
focusLauncherButton
|
|
222
229
|
]);
|
|
223
230
|
useEffect(() => {
|
|
224
231
|
const launcherButton = launcherButtonRef?.current;
|
|
225
232
|
return () => {
|
|
226
233
|
if (enablePresence && launcherButton) setTimeout(() => {
|
|
227
|
-
|
|
234
|
+
focusLauncherButton();
|
|
228
235
|
});
|
|
229
236
|
};
|
|
230
|
-
}, [
|
|
237
|
+
}, [
|
|
238
|
+
enablePresence,
|
|
239
|
+
launcherButtonRef,
|
|
240
|
+
focusLauncherButton
|
|
241
|
+
]);
|
|
231
242
|
useEffect(() => {
|
|
232
243
|
if (!enableDialogElement) {
|
|
233
244
|
const initialFocus = (focusContainerElement) => {
|
|
@@ -463,7 +474,7 @@ Modal.propTypes = {
|
|
|
463
474
|
hasScrollingContent: PropTypes.bool,
|
|
464
475
|
id: PropTypes.string,
|
|
465
476
|
isFullWidth: PropTypes.bool,
|
|
466
|
-
launcherButtonRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.oneOfType([typeof
|
|
477
|
+
launcherButtonRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.oneOfType([typeof HTMLElement !== "undefined" ? PropTypes.instanceOf(HTMLElement) : PropTypes.any, PropTypes.oneOf([null])]).isRequired })]),
|
|
467
478
|
loadingDescription: PropTypes.string,
|
|
468
479
|
loadingIconDescription: PropTypes.string,
|
|
469
480
|
loadingStatus: PropTypes.oneOf([
|
|
@@ -269,7 +269,7 @@ const NumberInput = React.forwardRef((props, forwardRef) => {
|
|
|
269
269
|
value: allowEmpty && event.target.value === "" ? "" : Number(event.target.value),
|
|
270
270
|
direction: value < event.target.value ? "up" : "down"
|
|
271
271
|
};
|
|
272
|
-
setValue(state.value);
|
|
272
|
+
if (controlledValue === void 0) setValue(state.value);
|
|
273
273
|
if (onChange) onChange(event, state);
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
@@ -312,7 +312,9 @@ const NumberInput = React.forwardRef((props, forwardRef) => {
|
|
|
312
312
|
value: newValue,
|
|
313
313
|
direction
|
|
314
314
|
};
|
|
315
|
-
if (type === "number")
|
|
315
|
+
if (type === "number") {
|
|
316
|
+
if (controlledValue === void 0) setValue(state.value);
|
|
317
|
+
}
|
|
316
318
|
if (type === "text") {
|
|
317
319
|
const formattedNewValue = format(newValue);
|
|
318
320
|
const parsedFormattedNewValue = numberParser.parse(formattedNewValue);
|
|
@@ -12,15 +12,13 @@ import { setupGetInstanceId } from "../../tools/setupGetInstanceId.js";
|
|
|
12
12
|
import { noopFn } from "../../internal/noopFn.js";
|
|
13
13
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
14
14
|
import { deprecateValuesWithin } from "../../prop-types/deprecateValuesWithin.js";
|
|
15
|
-
import { isComponentElement } from "../../internal/utils.js";
|
|
16
15
|
import { mapPopoverAlign } from "../../tools/mapPopoverAlign.js";
|
|
17
16
|
import { IconButton } from "../IconButton/index.js";
|
|
18
17
|
import { mergeRefs } from "../../tools/mergeRefs.js";
|
|
19
|
-
import OverflowMenuItem from "../OverflowMenuItem/OverflowMenuItem.js";
|
|
20
18
|
import { DIRECTION_BOTTOM, FloatingMenu } from "../../internal/FloatingMenu.js";
|
|
21
19
|
import { useOutsideClick } from "../../internal/useOutsideClick.js";
|
|
22
20
|
import classNames from "classnames";
|
|
23
|
-
import React, { Children, cloneElement, forwardRef, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
21
|
+
import React, { Children, cloneElement, forwardRef, isValidElement, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
24
22
|
import PropTypes from "prop-types";
|
|
25
23
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
26
24
|
import { OverflowMenuVertical } from "@carbon/icons-react";
|
|
@@ -224,14 +222,17 @@ const OverflowMenu = forwardRef(({ align, ["aria-label"]: ariaLabel = null, aria
|
|
|
224
222
|
});
|
|
225
223
|
const overflowMenuIconClasses = classNames(`${prefix}--overflow-menu__icon`, iconClass);
|
|
226
224
|
const childrenWithProps = Children.toArray(children).map((child, index) => {
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
225
|
+
if (isValidElement(child)) {
|
|
226
|
+
const childElement = child;
|
|
227
|
+
return cloneElement(childElement, {
|
|
228
|
+
closeMenu: childElement.props.closeMenu || closeMenuAndFocus,
|
|
229
|
+
handleOverflowMenuItemFocus,
|
|
230
|
+
ref: (el) => {
|
|
231
|
+
menuItemRefs.current[index] = el;
|
|
232
|
+
},
|
|
233
|
+
index
|
|
234
|
+
});
|
|
235
|
+
}
|
|
235
236
|
return null;
|
|
236
237
|
});
|
|
237
238
|
const wrappedMenuBody = /* @__PURE__ */ jsx(FloatingMenu, {
|
|
@@ -270,11 +270,11 @@ const Slider = (props) => {
|
|
|
270
270
|
DRAG_EVENT_TYPES.forEach((element) => {
|
|
271
271
|
elementRef.current?.ownerDocument.removeEventListener(element, handleDrag);
|
|
272
272
|
});
|
|
273
|
-
setState({
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
273
|
+
setState({ needsOnRelease: true });
|
|
274
|
+
};
|
|
275
|
+
const getValidityUpdateForHandle = (handle, validity) => {
|
|
276
|
+
if (typeof invalid !== "undefined") return {};
|
|
277
|
+
return handle === "upper" ? { isValidUpper: validity } : { isValid: validity };
|
|
278
278
|
};
|
|
279
279
|
/**
|
|
280
280
|
* Handles a "drag" event by recalculating the value/thumb and setting state
|
|
@@ -299,7 +299,7 @@ const Slider = (props) => {
|
|
|
299
299
|
else setState({
|
|
300
300
|
value: nearestStepValue(value),
|
|
301
301
|
left,
|
|
302
|
-
|
|
302
|
+
...getValidityUpdateForHandle("lower", true)
|
|
303
303
|
});
|
|
304
304
|
setState({
|
|
305
305
|
correctedValue: null,
|
|
@@ -338,7 +338,7 @@ const Slider = (props) => {
|
|
|
338
338
|
setState({
|
|
339
339
|
value: nearestStepValue(value),
|
|
340
340
|
left,
|
|
341
|
-
|
|
341
|
+
...getValidityUpdateForHandle("lower", true)
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
344
|
setState({
|
|
@@ -395,9 +395,7 @@ const Slider = (props) => {
|
|
|
395
395
|
const targetValue = Number.parseFloat(input.value);
|
|
396
396
|
const validity = !isNaN(targetValue);
|
|
397
397
|
const handlePosition = input.dataset.handlePosition;
|
|
398
|
-
|
|
399
|
-
else if (handlePosition === "upper") setState({ isValidUpper: validity });
|
|
400
|
-
setState({ isValid: validity });
|
|
398
|
+
setState(getValidityUpdateForHandle(handlePosition ?? "lower", validity));
|
|
401
399
|
if (validity) {
|
|
402
400
|
const adjustedValue = handlePosition ? getAdjustedValueForPosition({
|
|
403
401
|
handle: handlePosition,
|
|
@@ -507,22 +505,22 @@ const Slider = (props) => {
|
|
|
507
505
|
if (handle === "lower") setState({
|
|
508
506
|
value: valueUpper && newValue > valueUpper ? valueUpper : newValue,
|
|
509
507
|
left: valueUpper && newValue > valueUpper ? leftUpper : newLeft,
|
|
510
|
-
|
|
508
|
+
...getValidityUpdateForHandle(handle, true)
|
|
511
509
|
});
|
|
512
510
|
else setState({
|
|
513
511
|
valueUpper: value && newValue < value ? value : newValue,
|
|
514
512
|
leftUpper: value && newValue < value ? left : newLeft,
|
|
515
|
-
|
|
513
|
+
...getValidityUpdateForHandle(handle, true)
|
|
516
514
|
});
|
|
517
515
|
};
|
|
518
516
|
const setValueForHandle = (handle, value) => {
|
|
519
517
|
if (handle === "lower") setState({
|
|
520
518
|
value,
|
|
521
|
-
|
|
519
|
+
...getValidityUpdateForHandle(handle, true)
|
|
522
520
|
});
|
|
523
521
|
else setState({
|
|
524
522
|
valueUpper: value,
|
|
525
|
-
|
|
523
|
+
...getValidityUpdateForHandle(handle, true)
|
|
526
524
|
});
|
|
527
525
|
};
|
|
528
526
|
const isValidValueForPosition = ({ handle, value: newValue, min, max }) => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React from 'react';
|
|
7
|
+
import React, { type ReactNode } from 'react';
|
|
8
8
|
import { IconButtonKind } from '../IconButton';
|
|
9
9
|
import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
|
|
10
10
|
export declare const ButtonKinds: readonly ["primary", "secondary", "danger", "ghost", "danger--primary", "danger--ghost", "danger--tertiary", "tertiary"];
|
|
@@ -82,6 +82,6 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
82
82
|
tooltipPosition?: ButtonTooltipPosition;
|
|
83
83
|
}
|
|
84
84
|
export type ButtonProps<T extends React.ElementType> = PolymorphicComponentPropWithRef<T, ButtonBaseProps>;
|
|
85
|
-
export type ButtonComponent = <T extends React.ElementType = 'button'>(props: ButtonProps<T
|
|
85
|
+
export type ButtonComponent = <T extends React.ElementType = 'button'>(props: ButtonProps<T>) => ReactNode;
|
|
86
86
|
declare const _default: ButtonComponent;
|
|
87
87
|
export default _default;
|
|
@@ -42,8 +42,8 @@ const ComboButton = react.default.forwardRef(function ComboButton({ children, cl
|
|
|
42
42
|
const id = require_useId.useId("combobutton");
|
|
43
43
|
const prefix = require_usePrefix.usePrefix();
|
|
44
44
|
const containerRef = (0, react.useRef)(null);
|
|
45
|
-
|
|
46
|
-
if (!enableOnlyFloatingStyles) middlewares
|
|
45
|
+
const middlewares = [];
|
|
46
|
+
if (!enableOnlyFloatingStyles) middlewares.push((0, _floating_ui_react.flip)({ crossAxis: false }), (0, _floating_ui_react.hide)());
|
|
47
47
|
if (menuAlignment === "bottom" || menuAlignment === "top") middlewares.push((0, _floating_ui_react.size)({ apply({ rects, elements }) {
|
|
48
48
|
Object.assign(elements.floating.style, { width: `${rects.reference.width}px` });
|
|
49
49
|
} }));
|
|
@@ -57,7 +57,7 @@ export interface ModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
57
57
|
/**
|
|
58
58
|
* Provide a ref to return focus to once the modal is closed.
|
|
59
59
|
*/
|
|
60
|
-
launcherButtonRef?: RefObject<
|
|
60
|
+
launcherButtonRef?: RefObject<HTMLElement | null>;
|
|
61
61
|
/**
|
|
62
62
|
* Specify the description for the loading text
|
|
63
63
|
*/
|
|
@@ -10,6 +10,7 @@ const require_usePrefix = require("../../internal/usePrefix.js");
|
|
|
10
10
|
const require_Text = require("../Text/Text.js");
|
|
11
11
|
const require_keys = require("../../internal/keyboard/keys.js");
|
|
12
12
|
const require_match = require("../../internal/keyboard/match.js");
|
|
13
|
+
const require_navigation = require("../../internal/keyboard/navigation.js");
|
|
13
14
|
const require_useId = require("../../internal/useId.js");
|
|
14
15
|
const require_noopFn = require("../../internal/noopFn.js");
|
|
15
16
|
const require_warning = require("../../internal/warning.js");
|
|
@@ -213,25 +214,35 @@ const ModalDialog = react.default.forwardRef(function ModalDialog({ "aria-label"
|
|
|
213
214
|
prefix,
|
|
214
215
|
enableDialogElement
|
|
215
216
|
]);
|
|
217
|
+
const focusLauncherButton = (0, react.useCallback)(() => {
|
|
218
|
+
if (!launcherButtonRef || !launcherButtonRef.current) return;
|
|
219
|
+
const { current: launcherButton } = launcherButtonRef;
|
|
220
|
+
(launcherButton.matches(require_navigation.selectorTabbable) ? launcherButton : launcherButton.querySelector(require_navigation.selectorTabbable))?.focus();
|
|
221
|
+
}, [launcherButtonRef]);
|
|
216
222
|
(0, react.useEffect)(() => {
|
|
217
223
|
if (!enableDialogElement && !enablePresence && prevOpen && !open && launcherButtonRef) setTimeout(() => {
|
|
218
|
-
|
|
224
|
+
focusLauncherButton();
|
|
219
225
|
});
|
|
220
226
|
}, [
|
|
221
227
|
open,
|
|
222
228
|
prevOpen,
|
|
223
229
|
launcherButtonRef,
|
|
224
230
|
enableDialogElement,
|
|
225
|
-
enablePresence
|
|
231
|
+
enablePresence,
|
|
232
|
+
focusLauncherButton
|
|
226
233
|
]);
|
|
227
234
|
(0, react.useEffect)(() => {
|
|
228
235
|
const launcherButton = launcherButtonRef?.current;
|
|
229
236
|
return () => {
|
|
230
237
|
if (enablePresence && launcherButton) setTimeout(() => {
|
|
231
|
-
|
|
238
|
+
focusLauncherButton();
|
|
232
239
|
});
|
|
233
240
|
};
|
|
234
|
-
}, [
|
|
241
|
+
}, [
|
|
242
|
+
enablePresence,
|
|
243
|
+
launcherButtonRef,
|
|
244
|
+
focusLauncherButton
|
|
245
|
+
]);
|
|
235
246
|
(0, react.useEffect)(() => {
|
|
236
247
|
if (!enableDialogElement) {
|
|
237
248
|
const initialFocus = (focusContainerElement) => {
|
|
@@ -467,7 +478,7 @@ Modal.propTypes = {
|
|
|
467
478
|
hasScrollingContent: prop_types.default.bool,
|
|
468
479
|
id: prop_types.default.string,
|
|
469
480
|
isFullWidth: prop_types.default.bool,
|
|
470
|
-
launcherButtonRef: prop_types.default.oneOfType([prop_types.default.func, prop_types.default.shape({ current: prop_types.default.oneOfType([typeof
|
|
481
|
+
launcherButtonRef: prop_types.default.oneOfType([prop_types.default.func, prop_types.default.shape({ current: prop_types.default.oneOfType([typeof HTMLElement !== "undefined" ? prop_types.default.instanceOf(HTMLElement) : prop_types.default.any, prop_types.default.oneOf([null])]).isRequired })]),
|
|
471
482
|
loadingDescription: prop_types.default.string,
|
|
472
483
|
loadingIconDescription: prop_types.default.string,
|
|
473
484
|
loadingStatus: prop_types.default.oneOf([
|
|
@@ -273,7 +273,7 @@ const NumberInput = react.default.forwardRef((props, forwardRef) => {
|
|
|
273
273
|
value: allowEmpty && event.target.value === "" ? "" : Number(event.target.value),
|
|
274
274
|
direction: value < event.target.value ? "up" : "down"
|
|
275
275
|
};
|
|
276
|
-
setValue(state.value);
|
|
276
|
+
if (controlledValue === void 0) setValue(state.value);
|
|
277
277
|
if (onChange) onChange(event, state);
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
@@ -316,7 +316,9 @@ const NumberInput = react.default.forwardRef((props, forwardRef) => {
|
|
|
316
316
|
value: newValue,
|
|
317
317
|
direction
|
|
318
318
|
};
|
|
319
|
-
if (type === "number")
|
|
319
|
+
if (type === "number") {
|
|
320
|
+
if (controlledValue === void 0) setValue(state.value);
|
|
321
|
+
}
|
|
320
322
|
if (type === "text") {
|
|
321
323
|
const formattedNewValue = format(newValue);
|
|
322
324
|
const parsedFormattedNewValue = numberParser.parse(formattedNewValue);
|
|
@@ -13,11 +13,9 @@ const require_setupGetInstanceId = require("../../tools/setupGetInstanceId.js");
|
|
|
13
13
|
const require_noopFn = require("../../internal/noopFn.js");
|
|
14
14
|
const require_deprecate = require("../../prop-types/deprecate.js");
|
|
15
15
|
const require_deprecateValuesWithin = require("../../prop-types/deprecateValuesWithin.js");
|
|
16
|
-
const require_utils = require("../../internal/utils.js");
|
|
17
16
|
const require_mapPopoverAlign = require("../../tools/mapPopoverAlign.js");
|
|
18
17
|
const require_index = require("../IconButton/index.js");
|
|
19
18
|
const require_mergeRefs = require("../../tools/mergeRefs.js");
|
|
20
|
-
const require_OverflowMenuItem = require("../OverflowMenuItem/OverflowMenuItem.js");
|
|
21
19
|
const require_FloatingMenu = require("../../internal/FloatingMenu.js");
|
|
22
20
|
const require_useOutsideClick = require("../../internal/useOutsideClick.js");
|
|
23
21
|
let classnames = require("classnames");
|
|
@@ -229,14 +227,17 @@ const OverflowMenu = (0, react.forwardRef)(({ align, ["aria-label"]: ariaLabel =
|
|
|
229
227
|
});
|
|
230
228
|
const overflowMenuIconClasses = (0, classnames.default)(`${prefix}--overflow-menu__icon`, iconClass);
|
|
231
229
|
const childrenWithProps = react.Children.toArray(children).map((child, index) => {
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
230
|
+
if ((0, react.isValidElement)(child)) {
|
|
231
|
+
const childElement = child;
|
|
232
|
+
return (0, react.cloneElement)(childElement, {
|
|
233
|
+
closeMenu: childElement.props.closeMenu || closeMenuAndFocus,
|
|
234
|
+
handleOverflowMenuItemFocus,
|
|
235
|
+
ref: (el) => {
|
|
236
|
+
menuItemRefs.current[index] = el;
|
|
237
|
+
},
|
|
238
|
+
index
|
|
239
|
+
});
|
|
240
|
+
}
|
|
240
241
|
return null;
|
|
241
242
|
});
|
|
242
243
|
const wrappedMenuBody = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FloatingMenu.FloatingMenu, {
|
|
@@ -274,11 +274,11 @@ const Slider = (props) => {
|
|
|
274
274
|
DRAG_EVENT_TYPES.forEach((element) => {
|
|
275
275
|
elementRef.current?.ownerDocument.removeEventListener(element, handleDrag);
|
|
276
276
|
});
|
|
277
|
-
setState({
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
277
|
+
setState({ needsOnRelease: true });
|
|
278
|
+
};
|
|
279
|
+
const getValidityUpdateForHandle = (handle, validity) => {
|
|
280
|
+
if (typeof invalid !== "undefined") return {};
|
|
281
|
+
return handle === "upper" ? { isValidUpper: validity } : { isValid: validity };
|
|
282
282
|
};
|
|
283
283
|
/**
|
|
284
284
|
* Handles a "drag" event by recalculating the value/thumb and setting state
|
|
@@ -303,7 +303,7 @@ const Slider = (props) => {
|
|
|
303
303
|
else setState({
|
|
304
304
|
value: nearestStepValue(value),
|
|
305
305
|
left,
|
|
306
|
-
|
|
306
|
+
...getValidityUpdateForHandle("lower", true)
|
|
307
307
|
});
|
|
308
308
|
setState({
|
|
309
309
|
correctedValue: null,
|
|
@@ -342,7 +342,7 @@ const Slider = (props) => {
|
|
|
342
342
|
setState({
|
|
343
343
|
value: nearestStepValue(value),
|
|
344
344
|
left,
|
|
345
|
-
|
|
345
|
+
...getValidityUpdateForHandle("lower", true)
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
348
|
setState({
|
|
@@ -399,9 +399,7 @@ const Slider = (props) => {
|
|
|
399
399
|
const targetValue = Number.parseFloat(input.value);
|
|
400
400
|
const validity = !isNaN(targetValue);
|
|
401
401
|
const handlePosition = input.dataset.handlePosition;
|
|
402
|
-
|
|
403
|
-
else if (handlePosition === "upper") setState({ isValidUpper: validity });
|
|
404
|
-
setState({ isValid: validity });
|
|
402
|
+
setState(getValidityUpdateForHandle(handlePosition ?? "lower", validity));
|
|
405
403
|
if (validity) {
|
|
406
404
|
const adjustedValue = handlePosition ? getAdjustedValueForPosition({
|
|
407
405
|
handle: handlePosition,
|
|
@@ -511,22 +509,22 @@ const Slider = (props) => {
|
|
|
511
509
|
if (handle === "lower") setState({
|
|
512
510
|
value: valueUpper && newValue > valueUpper ? valueUpper : newValue,
|
|
513
511
|
left: valueUpper && newValue > valueUpper ? leftUpper : newLeft,
|
|
514
|
-
|
|
512
|
+
...getValidityUpdateForHandle(handle, true)
|
|
515
513
|
});
|
|
516
514
|
else setState({
|
|
517
515
|
valueUpper: value && newValue < value ? value : newValue,
|
|
518
516
|
leftUpper: value && newValue < value ? left : newLeft,
|
|
519
|
-
|
|
517
|
+
...getValidityUpdateForHandle(handle, true)
|
|
520
518
|
});
|
|
521
519
|
};
|
|
522
520
|
const setValueForHandle = (handle, value) => {
|
|
523
521
|
if (handle === "lower") setState({
|
|
524
522
|
value,
|
|
525
|
-
|
|
523
|
+
...getValidityUpdateForHandle(handle, true)
|
|
526
524
|
});
|
|
527
525
|
else setState({
|
|
528
526
|
valueUpper: value,
|
|
529
|
-
|
|
527
|
+
...getValidityUpdateForHandle(handle, true)
|
|
530
528
|
});
|
|
531
529
|
};
|
|
532
530
|
const isValidValueForPosition = ({ handle, value: newValue, min, max }) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.107.
|
|
4
|
+
"version": "1.107.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@babel/runtime": "^7.27.3",
|
|
55
55
|
"@carbon/feature-flags": "^1.3.0",
|
|
56
|
-
"@carbon/icons-react": "^11.80.0
|
|
56
|
+
"@carbon/icons-react": "^11.80.0",
|
|
57
57
|
"@carbon/layout": "^11.52.0",
|
|
58
|
-
"@carbon/styles": "^1.106.0
|
|
58
|
+
"@carbon/styles": "^1.106.0",
|
|
59
59
|
"@carbon/utilities": "^0.19.0",
|
|
60
60
|
"@floating-ui/react": "^0.27.4",
|
|
61
61
|
"@ibm/telemetry-js": "^1.5.0",
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"@babel/preset-react": "^7.27.1",
|
|
80
80
|
"@babel/preset-typescript": "^7.27.1",
|
|
81
81
|
"@carbon/test-utils": "^10.41.0",
|
|
82
|
-
"@carbon/themes": "^11.73.0
|
|
82
|
+
"@carbon/themes": "^11.73.0",
|
|
83
83
|
"@figma/code-connect": "^1.4.2",
|
|
84
84
|
"@stackblitz/sdk": "^1.11.0",
|
|
85
|
-
"@storybook/addon-a11y": "^
|
|
86
|
-
"@storybook/addon-docs": "^
|
|
87
|
-
"@storybook/addon-links": "^
|
|
88
|
-
"@storybook/builder-vite": "^
|
|
89
|
-
"@storybook/react-vite": "^
|
|
85
|
+
"@storybook/addon-a11y": "^10.3.5",
|
|
86
|
+
"@storybook/addon-docs": "^10.3.5",
|
|
87
|
+
"@storybook/addon-links": "^10.3.5",
|
|
88
|
+
"@storybook/builder-vite": "^10.3.5",
|
|
89
|
+
"@storybook/react-vite": "^10.3.5",
|
|
90
90
|
"@types/react-is": "^19.0.0",
|
|
91
91
|
"@types/use-sync-external-store": "^1",
|
|
92
92
|
"@vitejs/plugin-react": "^5.0.0",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"remark-gfm": "^4.0.0",
|
|
107
107
|
"rimraf": "^6.0.1",
|
|
108
108
|
"sass": "^1.93.2",
|
|
109
|
-
"storybook": "^
|
|
109
|
+
"storybook": "^10.3.5",
|
|
110
110
|
"storybook-addon-accessibility-checker": ">=9.2.0-rc.3",
|
|
111
111
|
"stream-browserify": "^3.0.0",
|
|
112
112
|
"tsdown": "^0.21.0",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"**/*.scss",
|
|
126
126
|
"**/*.css"
|
|
127
127
|
],
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "80f5039e553e19f4b540f914c35b8c3eaa8e41d3"
|
|
129
129
|
}
|