@trackunit/react-modal 1.8.109 → 1.8.112
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/index.cjs.js +9 -9
- package/index.esm.js +9 -9
- package/package.json +6 -6
- package/src/modal/Modal.d.ts +2 -2
- package/src/modal/Modal.stories.d.ts +1 -1
- package/src/modal/ModalBody/ModalBody.d.ts +1 -1
- package/src/modal/ModalBody/ModalBody.stories.d.ts +1 -1
- package/src/modal/ModalHeader/ModalHeader.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -236,11 +236,11 @@ const useModalFooterBorder = (rootRef, { footerClass = "border-t", enabled = tru
|
|
|
236
236
|
* };
|
|
237
237
|
* ```
|
|
238
238
|
*/
|
|
239
|
-
const Modal = ({ children, isOpen, role = "dialog", dataTestId, className, containerClassName, onBackdropClick, floatingUi, ref, }) => {
|
|
239
|
+
const Modal = ({ children, isOpen, role = "dialog", "data-testid": dataTestId, className, containerClassName, onBackdropClick, floatingUi, ref, }) => {
|
|
240
240
|
const { rootElement, refs, floatingStyles, context, getFloatingProps } = floatingUi;
|
|
241
241
|
const cardRef = react.useRef(null);
|
|
242
242
|
useModalFooterBorder(cardRef, { enabled: isOpen, footerClass: "border-t pt-4" });
|
|
243
|
-
return (jsxRuntime.jsx(reactComponents.Portal, { root: rootElement, children: isOpen ? (jsxRuntime.jsx(react$1.FloatingFocusManager, { context: context, children: jsxRuntime.jsx("div", { ref: refs.setFloating, style: { ...floatingStyles, zIndex: uiDesignTokens.zIndex.overlay }, ...getFloatingProps(), children: jsxRuntime.jsx(ModalBackdrop, { onClick: onBackdropClick, children: jsxRuntime.jsx("div", { "aria-modal": true, className: cvaModalContainer({ className: containerClassName }), ref: ref, role: role, children: jsxRuntime.jsx(reactComponents.Card, { className: cvaModalCard({ className }),
|
|
243
|
+
return (jsxRuntime.jsx(reactComponents.Portal, { root: rootElement, children: isOpen ? (jsxRuntime.jsx(react$1.FloatingFocusManager, { context: context, children: jsxRuntime.jsx("div", { ref: refs.setFloating, style: { ...floatingStyles, zIndex: uiDesignTokens.zIndex.overlay }, ...getFloatingProps(), children: jsxRuntime.jsx(ModalBackdrop, { onClick: onBackdropClick, children: jsxRuntime.jsx("div", { "aria-modal": true, className: cvaModalContainer({ className: containerClassName }), ref: ref, role: role, children: jsxRuntime.jsx(reactComponents.Card, { className: cvaModalCard({ className }), "data-testid": dataTestId, ref: cardRef, children: children }) }) }) }) })) : null }));
|
|
244
244
|
};
|
|
245
245
|
Modal.displayName = "Modal";
|
|
246
246
|
|
|
@@ -263,10 +263,10 @@ const cvaModalBodyContainer = cssClassVarianceUtilities.cvaMerge([
|
|
|
263
263
|
*
|
|
264
264
|
* @param {ModalBodyProps} props Component props.
|
|
265
265
|
* @param {ReactNode | null} props.children Content to render inside the modal body.
|
|
266
|
-
* @param {string} [props.
|
|
266
|
+
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
267
267
|
* @returns {ReactElement} Modal body wrapper element.
|
|
268
268
|
*/
|
|
269
|
-
const ModalBody = react.forwardRef(({ children, id, dataTestId, className }, ref) => {
|
|
269
|
+
const ModalBody = react.forwardRef(({ children, id, "data-testid": dataTestId, className }, ref) => {
|
|
270
270
|
return (jsxRuntime.jsx("div", { className: cvaModalBodyContainer({ className }), "data-modal-body": true, "data-testid": dataTestId, id: id, children: children }));
|
|
271
271
|
});
|
|
272
272
|
|
|
@@ -301,14 +301,14 @@ function isCustom(props) {
|
|
|
301
301
|
* @returns {ReactElement} Modal footer container element.
|
|
302
302
|
*/
|
|
303
303
|
const ModalFooter = react.forwardRef((props, ref) => {
|
|
304
|
-
const { dataTestId, className } = props;
|
|
304
|
+
const { "data-testid": dataTestId, className } = props;
|
|
305
305
|
if (isCustom(props)) {
|
|
306
306
|
// Branch with children: everything else is not required
|
|
307
307
|
return (jsxRuntime.jsx("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, ref: ref, children: props.children }));
|
|
308
308
|
}
|
|
309
309
|
// Branch with built-in buttons
|
|
310
310
|
const { onCancel, cancelLabel, primaryLabel, primaryAction, primaryVariant = "primary", primaryLoading = false, primaryDisabled = false, primaryFormId, secondaryLabel, secondaryAction, secondaryVariant = "secondary", secondaryLoading = false, secondaryDisabled = false, primaryName, secondaryName, cancelName, } = props;
|
|
311
|
-
return (jsxRuntime.jsxs("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, children: [jsxRuntime.jsx(reactComponents.Button, {
|
|
311
|
+
return (jsxRuntime.jsxs("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, children: [jsxRuntime.jsx(reactComponents.Button, { "data-testid": dataTestId ? `${dataTestId}-cancel` : undefined, disabled: secondaryLoading || primaryLoading, name: cancelName, onClick: onCancel, variant: "ghost-neutral", children: cancelLabel }), secondaryLabel && secondaryAction ? (jsxRuntime.jsx(reactComponents.Button, { "data-testid": dataTestId ? `${dataTestId}-secondary` : undefined, disabled: primaryLoading || secondaryDisabled, loading: secondaryLoading, name: secondaryName, onClick: secondaryAction, role: "button", variant: secondaryVariant, children: secondaryLabel })) : null, primaryLabel ? (jsxRuntime.jsx(reactComponents.Button, { "data-testid": dataTestId ? `${dataTestId}-primary` : undefined, disabled: secondaryLoading || primaryDisabled, form: primaryFormId, loading: primaryLoading, name: primaryName, onClick: primaryAction, role: "button", type: "submit", variant: primaryVariant, children: primaryLabel })) : null] }));
|
|
312
312
|
});
|
|
313
313
|
|
|
314
314
|
const cvaContainer = cssClassVarianceUtilities.cvaMerge(["flex", "justify-between", "border-b", "border-neutral-200", "p-4", "flex-none"]);
|
|
@@ -324,14 +324,14 @@ const cvaIconContainer = cssClassVarianceUtilities.cvaMerge(["flex", "place-item
|
|
|
324
324
|
* @param {string} [props.heading] Main heading text.
|
|
325
325
|
* @param {string} [props.subHeading] Optional subheading content.
|
|
326
326
|
* @param {() => void} props.onClose Close button click handler.
|
|
327
|
-
* @param {string} [props.
|
|
327
|
+
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
328
328
|
* @param {string} [props.className] Optional additional class name(s).
|
|
329
329
|
* @returns {ReactElement} The modal header element.
|
|
330
330
|
*/
|
|
331
|
-
const ModalHeader = react.forwardRef(({ heading, subHeading, onClose, dataTestId, className, id, children, accessories }, ref) => {
|
|
331
|
+
const ModalHeader = react.forwardRef(({ heading, subHeading, onClose, "data-testid": dataTestId, className, id, children, accessories }, ref) => {
|
|
332
332
|
return (jsxRuntime.jsxs("div", { className: cvaContainer({
|
|
333
333
|
className,
|
|
334
|
-
}), "data-testid": dataTestId, id: id, children: [jsxRuntime.jsxs("div", { className: cvaHeadingContainer(), children: [jsxRuntime.jsxs("div", { className: cvaTitleContainer(), children: [jsxRuntime.jsx(reactComponents.Heading, { variant: "tertiary", children: heading }), accessories] }), Boolean(subHeading) ? (jsxRuntime.jsx(reactComponents.Text, { size: "small", subtle: true, children: subHeading })) : null, children] }), jsxRuntime.jsx("div", { className: cvaIconContainer(), children: jsxRuntime.jsx(reactComponents.IconButton, { className: "!h-min",
|
|
334
|
+
}), "data-testid": dataTestId, id: id, children: [jsxRuntime.jsxs("div", { className: cvaHeadingContainer(), children: [jsxRuntime.jsxs("div", { className: cvaTitleContainer(), children: [jsxRuntime.jsx(reactComponents.Heading, { variant: "tertiary", children: heading }), accessories] }), Boolean(subHeading) ? (jsxRuntime.jsx(reactComponents.Text, { size: "small", subtle: true, children: subHeading })) : null, children] }), jsxRuntime.jsx("div", { className: cvaIconContainer(), children: jsxRuntime.jsx(reactComponents.IconButton, { className: "!h-min", "data-testid": dataTestId ? `${dataTestId}-close-button` : "modal-close-button", icon: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", variant: "ghost-neutral" }) })] }));
|
|
335
335
|
});
|
|
336
336
|
|
|
337
337
|
/**
|
package/index.esm.js
CHANGED
|
@@ -234,11 +234,11 @@ const useModalFooterBorder = (rootRef, { footerClass = "border-t", enabled = tru
|
|
|
234
234
|
* };
|
|
235
235
|
* ```
|
|
236
236
|
*/
|
|
237
|
-
const Modal = ({ children, isOpen, role = "dialog", dataTestId, className, containerClassName, onBackdropClick, floatingUi, ref, }) => {
|
|
237
|
+
const Modal = ({ children, isOpen, role = "dialog", "data-testid": dataTestId, className, containerClassName, onBackdropClick, floatingUi, ref, }) => {
|
|
238
238
|
const { rootElement, refs, floatingStyles, context, getFloatingProps } = floatingUi;
|
|
239
239
|
const cardRef = useRef(null);
|
|
240
240
|
useModalFooterBorder(cardRef, { enabled: isOpen, footerClass: "border-t pt-4" });
|
|
241
|
-
return (jsx(Portal, { root: rootElement, children: isOpen ? (jsx(FloatingFocusManager, { context: context, children: jsx("div", { ref: refs.setFloating, style: { ...floatingStyles, zIndex: zIndex.overlay }, ...getFloatingProps(), children: jsx(ModalBackdrop, { onClick: onBackdropClick, children: jsx("div", { "aria-modal": true, className: cvaModalContainer({ className: containerClassName }), ref: ref, role: role, children: jsx(Card, { className: cvaModalCard({ className }),
|
|
241
|
+
return (jsx(Portal, { root: rootElement, children: isOpen ? (jsx(FloatingFocusManager, { context: context, children: jsx("div", { ref: refs.setFloating, style: { ...floatingStyles, zIndex: zIndex.overlay }, ...getFloatingProps(), children: jsx(ModalBackdrop, { onClick: onBackdropClick, children: jsx("div", { "aria-modal": true, className: cvaModalContainer({ className: containerClassName }), ref: ref, role: role, children: jsx(Card, { className: cvaModalCard({ className }), "data-testid": dataTestId, ref: cardRef, children: children }) }) }) }) })) : null }));
|
|
242
242
|
};
|
|
243
243
|
Modal.displayName = "Modal";
|
|
244
244
|
|
|
@@ -261,10 +261,10 @@ const cvaModalBodyContainer = cvaMerge([
|
|
|
261
261
|
*
|
|
262
262
|
* @param {ModalBodyProps} props Component props.
|
|
263
263
|
* @param {ReactNode | null} props.children Content to render inside the modal body.
|
|
264
|
-
* @param {string} [props.
|
|
264
|
+
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
265
265
|
* @returns {ReactElement} Modal body wrapper element.
|
|
266
266
|
*/
|
|
267
|
-
const ModalBody = forwardRef(({ children, id, dataTestId, className }, ref) => {
|
|
267
|
+
const ModalBody = forwardRef(({ children, id, "data-testid": dataTestId, className }, ref) => {
|
|
268
268
|
return (jsx("div", { className: cvaModalBodyContainer({ className }), "data-modal-body": true, "data-testid": dataTestId, id: id, children: children }));
|
|
269
269
|
});
|
|
270
270
|
|
|
@@ -299,14 +299,14 @@ function isCustom(props) {
|
|
|
299
299
|
* @returns {ReactElement} Modal footer container element.
|
|
300
300
|
*/
|
|
301
301
|
const ModalFooter = forwardRef((props, ref) => {
|
|
302
|
-
const { dataTestId, className } = props;
|
|
302
|
+
const { "data-testid": dataTestId, className } = props;
|
|
303
303
|
if (isCustom(props)) {
|
|
304
304
|
// Branch with children: everything else is not required
|
|
305
305
|
return (jsx("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, ref: ref, children: props.children }));
|
|
306
306
|
}
|
|
307
307
|
// Branch with built-in buttons
|
|
308
308
|
const { onCancel, cancelLabel, primaryLabel, primaryAction, primaryVariant = "primary", primaryLoading = false, primaryDisabled = false, primaryFormId, secondaryLabel, secondaryAction, secondaryVariant = "secondary", secondaryLoading = false, secondaryDisabled = false, primaryName, secondaryName, cancelName, } = props;
|
|
309
|
-
return (jsxs("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, children: [jsx(Button, {
|
|
309
|
+
return (jsxs("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, children: [jsx(Button, { "data-testid": dataTestId ? `${dataTestId}-cancel` : undefined, disabled: secondaryLoading || primaryLoading, name: cancelName, onClick: onCancel, variant: "ghost-neutral", children: cancelLabel }), secondaryLabel && secondaryAction ? (jsx(Button, { "data-testid": dataTestId ? `${dataTestId}-secondary` : undefined, disabled: primaryLoading || secondaryDisabled, loading: secondaryLoading, name: secondaryName, onClick: secondaryAction, role: "button", variant: secondaryVariant, children: secondaryLabel })) : null, primaryLabel ? (jsx(Button, { "data-testid": dataTestId ? `${dataTestId}-primary` : undefined, disabled: secondaryLoading || primaryDisabled, form: primaryFormId, loading: primaryLoading, name: primaryName, onClick: primaryAction, role: "button", type: "submit", variant: primaryVariant, children: primaryLabel })) : null] }));
|
|
310
310
|
});
|
|
311
311
|
|
|
312
312
|
const cvaContainer = cvaMerge(["flex", "justify-between", "border-b", "border-neutral-200", "p-4", "flex-none"]);
|
|
@@ -322,14 +322,14 @@ const cvaIconContainer = cvaMerge(["flex", "place-items-center"]);
|
|
|
322
322
|
* @param {string} [props.heading] Main heading text.
|
|
323
323
|
* @param {string} [props.subHeading] Optional subheading content.
|
|
324
324
|
* @param {() => void} props.onClose Close button click handler.
|
|
325
|
-
* @param {string} [props.
|
|
325
|
+
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
326
326
|
* @param {string} [props.className] Optional additional class name(s).
|
|
327
327
|
* @returns {ReactElement} The modal header element.
|
|
328
328
|
*/
|
|
329
|
-
const ModalHeader = forwardRef(({ heading, subHeading, onClose, dataTestId, className, id, children, accessories }, ref) => {
|
|
329
|
+
const ModalHeader = forwardRef(({ heading, subHeading, onClose, "data-testid": dataTestId, className, id, children, accessories }, ref) => {
|
|
330
330
|
return (jsxs("div", { className: cvaContainer({
|
|
331
331
|
className,
|
|
332
|
-
}), "data-testid": dataTestId, id: id, children: [jsxs("div", { className: cvaHeadingContainer(), children: [jsxs("div", { className: cvaTitleContainer(), children: [jsx(Heading, { variant: "tertiary", children: heading }), accessories] }), Boolean(subHeading) ? (jsx(Text, { size: "small", subtle: true, children: subHeading })) : null, children] }), jsx("div", { className: cvaIconContainer(), children: jsx(IconButton, { className: "!h-min",
|
|
332
|
+
}), "data-testid": dataTestId, id: id, children: [jsxs("div", { className: cvaHeadingContainer(), children: [jsxs("div", { className: cvaTitleContainer(), children: [jsx(Heading, { variant: "tertiary", children: heading }), accessories] }), Boolean(subHeading) ? (jsx(Text, { size: "small", subtle: true, children: subHeading })) : null, children] }), jsx("div", { className: cvaIconContainer(), children: jsx(IconButton, { className: "!h-min", "data-testid": dataTestId ? `${dataTestId}-close-button` : "modal-close-button", icon: jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", variant: "ghost-neutral" }) })] }));
|
|
333
333
|
});
|
|
334
334
|
|
|
335
335
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-modal",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.112",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react": "19.0.0",
|
|
11
|
-
"@trackunit/react-components": "1.10.
|
|
12
|
-
"@trackunit/react-core-hooks": "1.7.
|
|
13
|
-
"@trackunit/css-class-variance-utilities": "1.7.
|
|
14
|
-
"@trackunit/i18n-library-translation": "1.7.
|
|
11
|
+
"@trackunit/react-components": "1.10.51",
|
|
12
|
+
"@trackunit/react-core-hooks": "1.7.90",
|
|
13
|
+
"@trackunit/css-class-variance-utilities": "1.7.77",
|
|
14
|
+
"@trackunit/i18n-library-translation": "1.7.94",
|
|
15
15
|
"@floating-ui/react": "^0.26.25",
|
|
16
16
|
"@floating-ui/react-dom": "2.1.2",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.7.
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.7.77"
|
|
18
18
|
},
|
|
19
19
|
"module": "./index.esm.js",
|
|
20
20
|
"main": "./index.cjs.js",
|
package/src/modal/Modal.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type ModalProps<TOnCloseFnArgs extends BaseUseModalActionArgs = [], TOnOp
|
|
|
16
16
|
/**
|
|
17
17
|
* The test ID applied to the modal.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
"data-testid"?: string;
|
|
20
20
|
} & PropsWithChildren<UseModalReturnValue<TOnCloseFnArgs, TOnOpenFnArgs>>;
|
|
21
21
|
/**
|
|
22
22
|
* - Modals are used to present critical information or request user input needed to complete a user's workflow.
|
|
@@ -46,6 +46,6 @@ export type ModalProps<TOnCloseFnArgs extends BaseUseModalActionArgs = [], TOnOp
|
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
48
|
export declare const Modal: {
|
|
49
|
-
<TOnCloseFnArgs extends BaseUseModalActionArgs = [], TOnOpenFnArgs extends BaseUseModalActionArgs = []>({ children, isOpen, role, dataTestId, className, containerClassName, onBackdropClick, floatingUi, ref, }: ModalProps<TOnCloseFnArgs, TOnOpenFnArgs>): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
<TOnCloseFnArgs extends BaseUseModalActionArgs = [], TOnOpenFnArgs extends BaseUseModalActionArgs = []>({ children, isOpen, role, "data-testid": dataTestId, className, containerClassName, onBackdropClick, floatingUi, ref, }: ModalProps<TOnCloseFnArgs, TOnOpenFnArgs>): import("react/jsx-runtime").JSX.Element;
|
|
50
50
|
displayName: string;
|
|
51
51
|
};
|
|
@@ -2,7 +2,7 @@ import { ReactElement } from "react";
|
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
4
|
component: {
|
|
5
|
-
<TOnCloseFnArgs extends import("./useModal").BaseUseModalActionArgs = [], TOnOpenFnArgs extends import("./useModal").BaseUseModalActionArgs = []>({ children, isOpen, role, dataTestId, className, containerClassName, onBackdropClick, floatingUi, ref, }: import("./Modal").ModalProps<TOnCloseFnArgs, TOnOpenFnArgs>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
<TOnCloseFnArgs extends import("./useModal").BaseUseModalActionArgs = [], TOnOpenFnArgs extends import("./useModal").BaseUseModalActionArgs = []>({ children, isOpen, role, "data-testid": dataTestId, className, containerClassName, onBackdropClick, floatingUi, ref, }: import("./Modal").ModalProps<TOnCloseFnArgs, TOnOpenFnArgs>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
8
|
tags: string[];
|
|
@@ -19,7 +19,7 @@ export interface ModalBodyProps extends CommonProps {
|
|
|
19
19
|
*
|
|
20
20
|
* @param {ModalBodyProps} props Component props.
|
|
21
21
|
* @param {ReactNode | null} props.children Content to render inside the modal body.
|
|
22
|
-
* @param {string} [props.
|
|
22
|
+
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
23
23
|
* @returns {ReactElement} Modal body wrapper element.
|
|
24
24
|
*/
|
|
25
25
|
export declare const ModalBody: import("react").ForwardRefExoticComponent<ModalBodyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -35,7 +35,7 @@ export interface ModalHeaderProps extends CommonProps {
|
|
|
35
35
|
* @param {string} [props.heading] Main heading text.
|
|
36
36
|
* @param {string} [props.subHeading] Optional subheading content.
|
|
37
37
|
* @param {() => void} props.onClose Close button click handler.
|
|
38
|
-
* @param {string} [props.
|
|
38
|
+
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
39
39
|
* @param {string} [props.className] Optional additional class name(s).
|
|
40
40
|
* @returns {ReactElement} The modal header element.
|
|
41
41
|
*/
|