@carbon/react 1.109.0-rc.0 → 1.109.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 +1015 -1015
- package/es/components/ComposedModal/ComposedModal.d.ts +8 -0
- package/es/components/ComposedModal/ComposedModal.js +33 -18
- package/es/components/ComposedModal/ComposedModalContext.d.ts +12 -0
- package/es/components/ComposedModal/ComposedModalContext.js +18 -0
- package/es/components/ComposedModal/ModalHeader.js +29 -1
- package/es/components/Modal/Modal.js +1 -1
- package/es/components/Search/Search.js +1 -1
- package/lib/components/ComposedModal/ComposedModal.d.ts +8 -0
- package/lib/components/ComposedModal/ComposedModal.js +32 -17
- package/lib/components/ComposedModal/ComposedModalContext.d.ts +12 -0
- package/lib/components/ComposedModal/ComposedModalContext.js +18 -0
- package/lib/components/ComposedModal/ModalHeader.js +28 -0
- package/lib/components/Modal/Modal.js +1 -1
- package/lib/components/Search/Search.js +1 -1
- package/package.json +6 -6
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode, type RefObject } from 'react';
|
|
8
8
|
export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
/**
|
|
10
|
+
* Specify the aria-label for the modal body when it is scrollable
|
|
11
|
+
*/
|
|
12
|
+
'aria-label'?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Specify the aria-labelledby for the modal body when it is scrollable
|
|
15
|
+
*/
|
|
16
|
+
'aria-labelledby'?: string;
|
|
9
17
|
/** Specify the content to be placed in the ModalBody. */
|
|
10
18
|
children?: ReactNode;
|
|
11
19
|
/**
|
|
@@ -18,17 +18,17 @@ import { useResizeObserver } from "../../internal/useResizeObserver.js";
|
|
|
18
18
|
import { composeEventHandlers } from "../../tools/events.js";
|
|
19
19
|
import { mergeRefs } from "../../tools/mergeRefs.js";
|
|
20
20
|
import { Layer } from "../Layer/index.js";
|
|
21
|
+
import { ComposedModalContext } from "./ComposedModalContext.js";
|
|
21
22
|
import { ModalHeader } from "./ModalHeader.js";
|
|
22
23
|
import { ModalFooter } from "./ModalFooter.js";
|
|
23
24
|
import { toggleClass } from "../../tools/toggleClass.js";
|
|
24
|
-
import { requiredIfGivenPropIsTruthy } from "../../prop-types/requiredIfGivenPropIsTruthy.js";
|
|
25
25
|
import { elementOrParentIsFloatingMenu, wrapFocus, wrapFocusWithoutSentinels } from "../../internal/wrapFocus.js";
|
|
26
26
|
import { Dialog } from "../Dialog/Dialog.js";
|
|
27
27
|
import { useComposedModalState } from "./useComposedModalState.js";
|
|
28
28
|
import { ComposedModalPresence, ComposedModalPresenceContext, useExclusiveComposedModalPresenceContext } from "./ComposedModalPresence.js";
|
|
29
29
|
import { isTopmostVisibleModal } from "../Modal/isTopmostVisibleModal.js";
|
|
30
30
|
import classNames from "classnames";
|
|
31
|
-
import React, { Children, cloneElement, useContext, useEffect, useRef } from "react";
|
|
31
|
+
import React, { Children, cloneElement, useContext, useEffect, useRef, useState } from "react";
|
|
32
32
|
import PropTypes from "prop-types";
|
|
33
33
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
34
34
|
import { useMergeRefs } from "@floating-ui/react";
|
|
@@ -39,9 +39,10 @@ import { useMergeRefs } from "@floating-ui/react";
|
|
|
39
39
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
40
40
|
* LICENSE file in the root directory of this source tree.
|
|
41
41
|
*/
|
|
42
|
-
const ModalBody = React.forwardRef(function ModalBody({ className: customClassName, children, hasForm, hasScrollingContent, ...rest }, ref) {
|
|
42
|
+
const ModalBody = React.forwardRef(function ModalBody({ ["aria-label"]: ariaLabelProp, ["aria-labelledby"]: ariaLabelledByProp, className: customClassName, children, hasForm, hasScrollingContent, ...rest }, ref) {
|
|
43
43
|
const prefix = usePrefix();
|
|
44
44
|
const contentRef = useRef(null);
|
|
45
|
+
const { labelId, titleId } = useContext(ComposedModalContext);
|
|
45
46
|
const { height } = useResizeObserver({ ref: contentRef });
|
|
46
47
|
/**
|
|
47
48
|
* isScrollable is implicitly dependent on height, when height gets updated
|
|
@@ -57,7 +58,9 @@ const ModalBody = React.forwardRef(function ModalBody({ className: customClassNa
|
|
|
57
58
|
}, customClassName),
|
|
58
59
|
...hasScrollingContent || isScrollable ? {
|
|
59
60
|
tabIndex: 0,
|
|
60
|
-
role: "region"
|
|
61
|
+
role: "region",
|
|
62
|
+
"aria-label": ariaLabelProp,
|
|
63
|
+
"aria-labelledby": ariaLabelledByProp || labelId || titleId
|
|
61
64
|
} : {},
|
|
62
65
|
...rest,
|
|
63
66
|
ref: mergeRefs(contentRef, ref),
|
|
@@ -65,7 +68,8 @@ const ModalBody = React.forwardRef(function ModalBody({ className: customClassNa
|
|
|
65
68
|
});
|
|
66
69
|
});
|
|
67
70
|
ModalBody.propTypes = {
|
|
68
|
-
["aria-label"]:
|
|
71
|
+
["aria-label"]: PropTypes.string,
|
|
72
|
+
["aria-labelledby"]: PropTypes.string,
|
|
69
73
|
children: PropTypes.node,
|
|
70
74
|
className: PropTypes.string,
|
|
71
75
|
hasForm: PropTypes.bool,
|
|
@@ -95,6 +99,8 @@ const ComposedModal = React.forwardRef(function ComposedModal({ open, ...props }
|
|
|
95
99
|
});
|
|
96
100
|
const ComposedModalDialog = React.forwardRef(function ComposedModalDialog({ ["aria-labelledby"]: ariaLabelledBy, ["aria-label"]: ariaLabel, children, className: customClassName, containerClassName, danger, decorator, isFullWidth, onClose, onKeyDown, open: externalOpen, preventCloseOnClickOutside, selectorPrimaryFocus = "[data-modal-primary-focus]", selectorsFloatingMenus, size, launcherButtonRef, slug, ...rest }, ref) {
|
|
97
101
|
const prefix = usePrefix();
|
|
102
|
+
const [labelId, setLabelId] = useState(void 0);
|
|
103
|
+
const [titleId, setTitleId] = useState(void 0);
|
|
98
104
|
const innerModal = useRef(null);
|
|
99
105
|
const button = useRef(null);
|
|
100
106
|
const startSentinel = useRef(null);
|
|
@@ -286,19 +292,28 @@ const ComposedModalDialog = React.forwardRef(function ComposedModalDialog({ ["ar
|
|
|
286
292
|
})
|
|
287
293
|
]
|
|
288
294
|
});
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
295
|
+
const contextValue = {
|
|
296
|
+
labelId,
|
|
297
|
+
titleId,
|
|
298
|
+
setLabelId,
|
|
299
|
+
setTitleId
|
|
300
|
+
};
|
|
301
|
+
return /* @__PURE__ */ jsx(ComposedModalContext.Provider, {
|
|
302
|
+
value: contextValue,
|
|
303
|
+
children: /* @__PURE__ */ jsx(Layer, {
|
|
304
|
+
...rest,
|
|
305
|
+
level: 0,
|
|
306
|
+
role: "presentation",
|
|
307
|
+
ref: mergedRefs,
|
|
308
|
+
"aria-hidden": !open,
|
|
309
|
+
onBlur: handleBlur,
|
|
310
|
+
onClick: composeEventHandlers([rest?.onClick, handleOnClick]),
|
|
311
|
+
onMouseDown: composeEventHandlers([rest?.onMouseDown, handleOnMouseDown]),
|
|
312
|
+
onKeyDown: handleKeyDown,
|
|
313
|
+
className: modalClass,
|
|
314
|
+
"data-exiting": presenceContext?.isExiting || void 0,
|
|
315
|
+
children: modalBody
|
|
316
|
+
})
|
|
302
317
|
});
|
|
303
318
|
});
|
|
304
319
|
ComposedModal.propTypes = {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 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
|
+
export declare const ComposedModalContext: import("react").Context<{
|
|
8
|
+
labelId?: string;
|
|
9
|
+
titleId?: string;
|
|
10
|
+
setLabelId?: (id: string | undefined) => void;
|
|
11
|
+
setTitleId?: (id: string | undefined) => void;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
import { createContext } from "react";
|
|
9
|
+
//#region src/components/ComposedModal/ComposedModalContext.ts
|
|
10
|
+
/**
|
|
11
|
+
* Copyright IBM Corp. 2026
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
const ComposedModalContext = createContext({});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ComposedModalContext };
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
|
+
import { useId } from "../../internal/useId.js";
|
|
9
10
|
import { IconButton } from "../IconButton/index.js";
|
|
11
|
+
import { ComposedModalContext } from "./ComposedModalContext.js";
|
|
10
12
|
import classNames from "classnames";
|
|
11
|
-
import React from "react";
|
|
13
|
+
import React, { useContext, useEffect } from "react";
|
|
12
14
|
import PropTypes from "prop-types";
|
|
13
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
16
|
import { Close } from "@carbon/icons-react";
|
|
@@ -21,6 +23,30 @@ import { Close } from "@carbon/icons-react";
|
|
|
21
23
|
*/
|
|
22
24
|
const ModalHeader = React.forwardRef(function ModalHeader({ buttonOnClick, children, className: customClassName, closeClassName, closeIconClassName, closeModal, iconDescription = "Close", label, labelClassName, title, titleClassName, ...rest }, ref) {
|
|
23
25
|
const prefix = usePrefix();
|
|
26
|
+
const modalId = useId();
|
|
27
|
+
const { setLabelId, setTitleId } = useContext(ComposedModalContext);
|
|
28
|
+
const generatedLabelId = `${prefix}--modal-header__label--${modalId}`;
|
|
29
|
+
const generatedTitleId = `${prefix}--modal-header__heading--${modalId}`;
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (label && setLabelId) {
|
|
32
|
+
setLabelId(generatedLabelId);
|
|
33
|
+
return () => setLabelId(void 0);
|
|
34
|
+
}
|
|
35
|
+
}, [
|
|
36
|
+
label,
|
|
37
|
+
generatedLabelId,
|
|
38
|
+
setLabelId
|
|
39
|
+
]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (title && setTitleId) {
|
|
42
|
+
setTitleId(generatedTitleId);
|
|
43
|
+
return () => setTitleId(void 0);
|
|
44
|
+
}
|
|
45
|
+
}, [
|
|
46
|
+
title,
|
|
47
|
+
generatedTitleId,
|
|
48
|
+
setTitleId
|
|
49
|
+
]);
|
|
24
50
|
function handleCloseButtonClick(evt) {
|
|
25
51
|
closeModal?.(evt);
|
|
26
52
|
buttonOnClick?.(evt);
|
|
@@ -36,10 +62,12 @@ const ModalHeader = React.forwardRef(function ModalHeader({ buttonOnClick, child
|
|
|
36
62
|
ref,
|
|
37
63
|
children: [
|
|
38
64
|
label && /* @__PURE__ */ jsx("h2", {
|
|
65
|
+
id: generatedLabelId,
|
|
39
66
|
className: labelClass,
|
|
40
67
|
children: label
|
|
41
68
|
}),
|
|
42
69
|
title && /* @__PURE__ */ jsx("h2", {
|
|
70
|
+
id: generatedTitleId,
|
|
43
71
|
className: titleClass,
|
|
44
72
|
children: title
|
|
45
73
|
}),
|
|
@@ -26,10 +26,10 @@ import { composeEventHandlers } from "../../tools/events.js";
|
|
|
26
26
|
import { Layer } from "../Layer/index.js";
|
|
27
27
|
import InlineLoading_default from "../InlineLoading/index.js";
|
|
28
28
|
import { toggleClass } from "../../tools/toggleClass.js";
|
|
29
|
-
import { requiredIfGivenPropIsTruthy } from "../../prop-types/requiredIfGivenPropIsTruthy.js";
|
|
30
29
|
import { elementOrParentIsFloatingMenu, wrapFocus, wrapFocusWithoutSentinels } from "../../internal/wrapFocus.js";
|
|
31
30
|
import { Dialog } from "../Dialog/Dialog.js";
|
|
32
31
|
import { isTopmostVisibleModal } from "./isTopmostVisibleModal.js";
|
|
32
|
+
import { requiredIfGivenPropIsTruthy } from "../../prop-types/requiredIfGivenPropIsTruthy.js";
|
|
33
33
|
import { usePreviousValue } from "../../internal/usePreviousValue.js";
|
|
34
34
|
import { ModalPresence, ModalPresenceContext, useExclusiveModalPresenceContext } from "./ModalPresence.js";
|
|
35
35
|
import classNames from "classnames";
|
|
@@ -110,7 +110,7 @@ const Search$1 = React.forwardRef(({ autoComplete = "off", className, closeButto
|
|
|
110
110
|
});
|
|
111
111
|
return /* @__PURE__ */ jsxs("div", {
|
|
112
112
|
role: "search",
|
|
113
|
-
"aria-
|
|
113
|
+
"aria-labelledby": searchId,
|
|
114
114
|
className: searchClasses,
|
|
115
115
|
children: [
|
|
116
116
|
onExpand && !isExpanded ? /* @__PURE__ */ jsx(Tooltip, {
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode, type RefObject } from 'react';
|
|
8
8
|
export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
/**
|
|
10
|
+
* Specify the aria-label for the modal body when it is scrollable
|
|
11
|
+
*/
|
|
12
|
+
'aria-label'?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Specify the aria-labelledby for the modal body when it is scrollable
|
|
15
|
+
*/
|
|
16
|
+
'aria-labelledby'?: string;
|
|
9
17
|
/** Specify the content to be placed in the ModalBody. */
|
|
10
18
|
children?: ReactNode;
|
|
11
19
|
/**
|
|
@@ -19,10 +19,10 @@ const require_useResizeObserver = require("../../internal/useResizeObserver.js")
|
|
|
19
19
|
const require_events = require("../../tools/events.js");
|
|
20
20
|
const require_mergeRefs = require("../../tools/mergeRefs.js");
|
|
21
21
|
const require_index$2 = require("../Layer/index.js");
|
|
22
|
+
const require_ComposedModalContext = require("./ComposedModalContext.js");
|
|
22
23
|
const require_ModalHeader = require("./ModalHeader.js");
|
|
23
24
|
const require_ModalFooter = require("./ModalFooter.js");
|
|
24
25
|
const require_toggleClass = require("../../tools/toggleClass.js");
|
|
25
|
-
const require_requiredIfGivenPropIsTruthy = require("../../prop-types/requiredIfGivenPropIsTruthy.js");
|
|
26
26
|
const require_wrapFocus = require("../../internal/wrapFocus.js");
|
|
27
27
|
const require_Dialog = require("../Dialog/Dialog.js");
|
|
28
28
|
const require_useComposedModalState = require("./useComposedModalState.js");
|
|
@@ -43,9 +43,10 @@ let _floating_ui_react = require("@floating-ui/react");
|
|
|
43
43
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
44
44
|
* LICENSE file in the root directory of this source tree.
|
|
45
45
|
*/
|
|
46
|
-
const ModalBody = react.default.forwardRef(function ModalBody({ className: customClassName, children, hasForm, hasScrollingContent, ...rest }, ref) {
|
|
46
|
+
const ModalBody = react.default.forwardRef(function ModalBody({ ["aria-label"]: ariaLabelProp, ["aria-labelledby"]: ariaLabelledByProp, className: customClassName, children, hasForm, hasScrollingContent, ...rest }, ref) {
|
|
47
47
|
const prefix = require_usePrefix.usePrefix();
|
|
48
48
|
const contentRef = (0, react.useRef)(null);
|
|
49
|
+
const { labelId, titleId } = (0, react.useContext)(require_ComposedModalContext.ComposedModalContext);
|
|
49
50
|
const { height } = require_useResizeObserver.useResizeObserver({ ref: contentRef });
|
|
50
51
|
/**
|
|
51
52
|
* isScrollable is implicitly dependent on height, when height gets updated
|
|
@@ -61,7 +62,9 @@ const ModalBody = react.default.forwardRef(function ModalBody({ className: custo
|
|
|
61
62
|
}, customClassName),
|
|
62
63
|
...hasScrollingContent || isScrollable ? {
|
|
63
64
|
tabIndex: 0,
|
|
64
|
-
role: "region"
|
|
65
|
+
role: "region",
|
|
66
|
+
"aria-label": ariaLabelProp,
|
|
67
|
+
"aria-labelledby": ariaLabelledByProp || labelId || titleId
|
|
65
68
|
} : {},
|
|
66
69
|
...rest,
|
|
67
70
|
ref: require_mergeRefs.mergeRefs(contentRef, ref),
|
|
@@ -69,7 +72,8 @@ const ModalBody = react.default.forwardRef(function ModalBody({ className: custo
|
|
|
69
72
|
});
|
|
70
73
|
});
|
|
71
74
|
ModalBody.propTypes = {
|
|
72
|
-
["aria-label"]:
|
|
75
|
+
["aria-label"]: prop_types.default.string,
|
|
76
|
+
["aria-labelledby"]: prop_types.default.string,
|
|
73
77
|
children: prop_types.default.node,
|
|
74
78
|
className: prop_types.default.string,
|
|
75
79
|
hasForm: prop_types.default.bool,
|
|
@@ -99,6 +103,8 @@ const ComposedModal = react.default.forwardRef(function ComposedModal({ open, ..
|
|
|
99
103
|
});
|
|
100
104
|
const ComposedModalDialog = react.default.forwardRef(function ComposedModalDialog({ ["aria-labelledby"]: ariaLabelledBy, ["aria-label"]: ariaLabel, children, className: customClassName, containerClassName, danger, decorator, isFullWidth, onClose, onKeyDown, open: externalOpen, preventCloseOnClickOutside, selectorPrimaryFocus = "[data-modal-primary-focus]", selectorsFloatingMenus, size, launcherButtonRef, slug, ...rest }, ref) {
|
|
101
105
|
const prefix = require_usePrefix.usePrefix();
|
|
106
|
+
const [labelId, setLabelId] = (0, react.useState)(void 0);
|
|
107
|
+
const [titleId, setTitleId] = (0, react.useState)(void 0);
|
|
102
108
|
const innerModal = (0, react.useRef)(null);
|
|
103
109
|
const button = (0, react.useRef)(null);
|
|
104
110
|
const startSentinel = (0, react.useRef)(null);
|
|
@@ -290,19 +296,28 @@ const ComposedModalDialog = react.default.forwardRef(function ComposedModalDialo
|
|
|
290
296
|
})
|
|
291
297
|
]
|
|
292
298
|
});
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
299
|
+
const contextValue = {
|
|
300
|
+
labelId,
|
|
301
|
+
titleId,
|
|
302
|
+
setLabelId,
|
|
303
|
+
setTitleId
|
|
304
|
+
};
|
|
305
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ComposedModalContext.ComposedModalContext.Provider, {
|
|
306
|
+
value: contextValue,
|
|
307
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$2.Layer, {
|
|
308
|
+
...rest,
|
|
309
|
+
level: 0,
|
|
310
|
+
role: "presentation",
|
|
311
|
+
ref: mergedRefs,
|
|
312
|
+
"aria-hidden": !open,
|
|
313
|
+
onBlur: handleBlur,
|
|
314
|
+
onClick: require_events.composeEventHandlers([rest?.onClick, handleOnClick]),
|
|
315
|
+
onMouseDown: require_events.composeEventHandlers([rest?.onMouseDown, handleOnMouseDown]),
|
|
316
|
+
onKeyDown: handleKeyDown,
|
|
317
|
+
className: modalClass,
|
|
318
|
+
"data-exiting": presenceContext?.isExiting || void 0,
|
|
319
|
+
children: modalBody
|
|
320
|
+
})
|
|
306
321
|
});
|
|
307
322
|
});
|
|
308
323
|
ComposedModal.propTypes = {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 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
|
+
export declare const ComposedModalContext: import("react").Context<{
|
|
8
|
+
labelId?: string;
|
|
9
|
+
titleId?: string;
|
|
10
|
+
setLabelId?: (id: string | undefined) => void;
|
|
11
|
+
setTitleId?: (id: string | undefined) => void;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
require("../../_virtual/_rolldown/runtime.js");
|
|
9
|
+
//#region src/components/ComposedModal/ComposedModalContext.ts
|
|
10
|
+
/**
|
|
11
|
+
* Copyright IBM Corp. 2026
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
const ComposedModalContext = (0, require("react").createContext)({});
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.ComposedModalContext = ComposedModalContext;
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
9
9
|
const require_usePrefix = require("../../internal/usePrefix.js");
|
|
10
|
+
const require_useId = require("../../internal/useId.js");
|
|
10
11
|
const require_index = require("../IconButton/index.js");
|
|
12
|
+
const require_ComposedModalContext = require("./ComposedModalContext.js");
|
|
11
13
|
let classnames = require("classnames");
|
|
12
14
|
classnames = require_runtime.__toESM(classnames);
|
|
13
15
|
let react = require("react");
|
|
@@ -25,6 +27,30 @@ let _carbon_icons_react = require("@carbon/icons-react");
|
|
|
25
27
|
*/
|
|
26
28
|
const ModalHeader = react.default.forwardRef(function ModalHeader({ buttonOnClick, children, className: customClassName, closeClassName, closeIconClassName, closeModal, iconDescription = "Close", label, labelClassName, title, titleClassName, ...rest }, ref) {
|
|
27
29
|
const prefix = require_usePrefix.usePrefix();
|
|
30
|
+
const modalId = require_useId.useId();
|
|
31
|
+
const { setLabelId, setTitleId } = (0, react.useContext)(require_ComposedModalContext.ComposedModalContext);
|
|
32
|
+
const generatedLabelId = `${prefix}--modal-header__label--${modalId}`;
|
|
33
|
+
const generatedTitleId = `${prefix}--modal-header__heading--${modalId}`;
|
|
34
|
+
(0, react.useEffect)(() => {
|
|
35
|
+
if (label && setLabelId) {
|
|
36
|
+
setLabelId(generatedLabelId);
|
|
37
|
+
return () => setLabelId(void 0);
|
|
38
|
+
}
|
|
39
|
+
}, [
|
|
40
|
+
label,
|
|
41
|
+
generatedLabelId,
|
|
42
|
+
setLabelId
|
|
43
|
+
]);
|
|
44
|
+
(0, react.useEffect)(() => {
|
|
45
|
+
if (title && setTitleId) {
|
|
46
|
+
setTitleId(generatedTitleId);
|
|
47
|
+
return () => setTitleId(void 0);
|
|
48
|
+
}
|
|
49
|
+
}, [
|
|
50
|
+
title,
|
|
51
|
+
generatedTitleId,
|
|
52
|
+
setTitleId
|
|
53
|
+
]);
|
|
28
54
|
function handleCloseButtonClick(evt) {
|
|
29
55
|
closeModal?.(evt);
|
|
30
56
|
buttonOnClick?.(evt);
|
|
@@ -40,10 +66,12 @@ const ModalHeader = react.default.forwardRef(function ModalHeader({ buttonOnClic
|
|
|
40
66
|
ref,
|
|
41
67
|
children: [
|
|
42
68
|
label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
69
|
+
id: generatedLabelId,
|
|
43
70
|
className: labelClass,
|
|
44
71
|
children: label
|
|
45
72
|
}),
|
|
46
73
|
title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
74
|
+
id: generatedTitleId,
|
|
47
75
|
className: titleClass,
|
|
48
76
|
children: title
|
|
49
77
|
}),
|
|
@@ -27,10 +27,10 @@ const require_events = require("../../tools/events.js");
|
|
|
27
27
|
const require_index$5 = require("../Layer/index.js");
|
|
28
28
|
const require_index$6 = require("../InlineLoading/index.js");
|
|
29
29
|
const require_toggleClass = require("../../tools/toggleClass.js");
|
|
30
|
-
const require_requiredIfGivenPropIsTruthy = require("../../prop-types/requiredIfGivenPropIsTruthy.js");
|
|
31
30
|
const require_wrapFocus = require("../../internal/wrapFocus.js");
|
|
32
31
|
const require_Dialog = require("../Dialog/Dialog.js");
|
|
33
32
|
const require_isTopmostVisibleModal = require("./isTopmostVisibleModal.js");
|
|
33
|
+
const require_requiredIfGivenPropIsTruthy = require("../../prop-types/requiredIfGivenPropIsTruthy.js");
|
|
34
34
|
const require_usePreviousValue = require("../../internal/usePreviousValue.js");
|
|
35
35
|
const require_ModalPresence = require("./ModalPresence.js");
|
|
36
36
|
let classnames = require("classnames");
|
|
@@ -114,7 +114,7 @@ const Search = react.default.forwardRef(({ autoComplete = "off", className, clos
|
|
|
114
114
|
});
|
|
115
115
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
116
116
|
role: "search",
|
|
117
|
-
"aria-
|
|
117
|
+
"aria-labelledby": searchId,
|
|
118
118
|
className: searchClasses,
|
|
119
119
|
children: [
|
|
120
120
|
onExpand && !isExpanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tooltip.Tooltip, {
|
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.109.0
|
|
4
|
+
"version": "1.109.0",
|
|
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.82.0
|
|
56
|
+
"@carbon/icons-react": "^11.82.0",
|
|
57
57
|
"@carbon/layout": "^11.53.0",
|
|
58
|
-
"@carbon/styles": "^1.108.0
|
|
58
|
+
"@carbon/styles": "^1.108.0",
|
|
59
59
|
"@carbon/utilities": "^0.20.0",
|
|
60
60
|
"@floating-ui/react": "^0.27.4",
|
|
61
61
|
"@ibm/telemetry-js": "^1.5.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
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.75.0
|
|
82
|
+
"@carbon/themes": "^11.75.0",
|
|
83
83
|
"@figma/code-connect": "^1.4.5",
|
|
84
84
|
"@stackblitz/sdk": "^1.11.0",
|
|
85
85
|
"@storybook/addon-a11y": "^10.3.5",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"tsdown": "^0.21.0",
|
|
113
113
|
"typescript-config-carbon": "^0.10.0",
|
|
114
114
|
"use-sync-external-store": "^1.5.0",
|
|
115
|
-
"vite": "^
|
|
115
|
+
"vite": "^8.0.0"
|
|
116
116
|
},
|
|
117
117
|
"sideEffects": [
|
|
118
118
|
"es/index.js",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"**/*.scss",
|
|
126
126
|
"**/*.css"
|
|
127
127
|
],
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "5bb41d341768785b898851fde30731cb31b981c2"
|
|
129
129
|
}
|