@trackunit/react-modal 2.10.17 → 2.11.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/index.cjs.js
CHANGED
|
@@ -439,9 +439,9 @@ const cvaModalBodyContainer = cssClassVarianceUtilities.cva({
|
|
|
439
439
|
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
440
440
|
* @returns {ReactElement} Modal body wrapper element.
|
|
441
441
|
*/
|
|
442
|
-
const ModalBody =
|
|
442
|
+
const ModalBody = ({ children, id, "data-testid": dataTestId, className, style, ref, }) => {
|
|
443
443
|
return (jsxRuntime.jsx("div", { className: cvaModalBodyContainer({ className }), "data-modal-body": true, "data-testid": dataTestId, id: id, ref: ref, style: style, children: children }));
|
|
444
|
-
}
|
|
444
|
+
};
|
|
445
445
|
|
|
446
446
|
const cvaModalFooterContainer = cssClassVarianceUtilities.cva({
|
|
447
447
|
base: [
|
|
@@ -525,20 +525,20 @@ function isCustom(props) {
|
|
|
525
525
|
* @param props.primaryLoading Optional loading state for the Primary button.
|
|
526
526
|
* @returns {ReactElement} Modal footer container element.
|
|
527
527
|
*/
|
|
528
|
-
const ModalFooter =
|
|
529
|
-
const { "data-testid": dataTestId, className, style } = props;
|
|
528
|
+
const ModalFooter = (props) => {
|
|
529
|
+
const { "data-testid": dataTestId, className, style, ref } = props;
|
|
530
530
|
if (isCustom(props)) {
|
|
531
531
|
// Branch with children: everything else is not required
|
|
532
532
|
return (jsxRuntime.jsx("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, ref: ref, style: style, children: props.children }));
|
|
533
533
|
}
|
|
534
534
|
// Branch with built-in buttons
|
|
535
535
|
const { onCancel: onClickCancel, cancelLabel, primaryLabel, primaryAction, primaryVariant = "primary", primaryLoading = false, primaryDisabled = false, primaryFormId, secondaryLabel, secondaryAction, secondaryVariant = "secondary", secondaryLoading = false, secondaryDisabled = false, primaryName, secondaryName, cancelName, } = props;
|
|
536
|
-
return (jsxRuntime.jsxs("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, style: style, children: [jsxRuntime.jsx(reactComponents.Button, { "data-testid": dataTestId ? `${dataTestId}-cancel` : undefined, disabled: secondaryLoading || primaryLoading, name: cancelName, onClick: onClickCancel, variant: "ghost-neutral", children: cancelLabel }), secondaryLabel && secondaryAction ? (jsxRuntime.jsx(reactComponents.Button, { "data-testid": dataTestId ? `${dataTestId}-secondary` : undefined, disabled: primaryLoading || secondaryDisabled, loading: secondaryLoading, name: secondaryName,
|
|
536
|
+
return (jsxRuntime.jsxs("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, ref: ref, style: style, children: [jsxRuntime.jsx(reactComponents.Button, { "data-testid": dataTestId ? `${dataTestId}-cancel` : undefined, disabled: secondaryLoading || primaryLoading, name: cancelName, onClick: onClickCancel, variant: "ghost-neutral", children: cancelLabel }), secondaryLabel && secondaryAction ? (jsxRuntime.jsx(reactComponents.Button, { "data-testid": dataTestId ? `${dataTestId}-secondary` : undefined, disabled: primaryLoading || secondaryDisabled, loading: secondaryLoading, name: secondaryName,
|
|
537
537
|
// eslint-disable-next-line @trackunit/prefer-event-specific-callback-naming
|
|
538
538
|
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,
|
|
539
539
|
// eslint-disable-next-line @trackunit/prefer-event-specific-callback-naming
|
|
540
540
|
onClick: primaryAction, role: "button", type: "submit", variant: primaryVariant, children: primaryLabel })) : null] }));
|
|
541
|
-
}
|
|
541
|
+
};
|
|
542
542
|
|
|
543
543
|
const cvaContainer = cssClassVarianceUtilities.cva({
|
|
544
544
|
base: ["flex", "justify-between", "border-b", "border-neutral-200", "p-4", "flex-none"],
|
|
@@ -597,14 +597,14 @@ const cvaIconContainer = cssClassVarianceUtilities.cva({ base: ["flex", "place-i
|
|
|
597
597
|
* @param {() => void} props.onClickClose Close button click handler.
|
|
598
598
|
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
599
599
|
* @param {string} [props.className] Optional additional class name(s).
|
|
600
|
-
* @returns The modal header element.
|
|
600
|
+
* @returns {ReactElement} The modal header element.
|
|
601
601
|
*/
|
|
602
|
-
const ModalHeader =
|
|
602
|
+
const ModalHeader = ({ heading, subHeading, onClickClose, "data-testid": dataTestId, className, style, id, children, accessories, ref, }) => {
|
|
603
603
|
const [t] = useTranslation();
|
|
604
604
|
return (jsxRuntime.jsxs("div", { className: cvaContainer({
|
|
605
605
|
className,
|
|
606
606
|
}), "data-testid": dataTestId, id: id, ref: ref, style: style, 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: onClickClose, size: "small", title: t("modalHeader.close"), variant: "ghost-neutral" }) })] }));
|
|
607
|
-
}
|
|
607
|
+
};
|
|
608
608
|
|
|
609
609
|
/**
|
|
610
610
|
* Trust anchor for the modal registry's outbound (iframe → host) postMessage.
|
package/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
3
|
import { useMergeRefs, FloatingFocusManager, FloatingOverlay, useFloating, autoUpdate, shift, useDismiss, useInteractions } from '@floating-ui/react';
|
|
4
4
|
import { useOverflowBorder, useSheetSnap, useWatch, Card, Portal, Sheet, Button, Heading, Text, IconButton, Icon, useContainerBreakpoints, useViewportBreakpoints, useTimeout, SHEET_TRANSITION_DURATION_MS } from '@trackunit/react-components';
|
|
5
|
-
import { useRef, useEffect, useCallback, useState, useReducer, useMemo,
|
|
5
|
+
import { useRef, useEffect, useCallback, useState, useReducer, useMemo, useId, useSyncExternalStore, useLayoutEffect, useContext } from 'react';
|
|
6
6
|
import { cva } from '@trackunit/css-class-variance-utilities';
|
|
7
7
|
import { ModalDialogContext, ErrorHandlingContext } from '@trackunit/react-core-contexts-api';
|
|
8
8
|
|
|
@@ -437,9 +437,9 @@ const cvaModalBodyContainer = cva({
|
|
|
437
437
|
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
438
438
|
* @returns {ReactElement} Modal body wrapper element.
|
|
439
439
|
*/
|
|
440
|
-
const ModalBody =
|
|
440
|
+
const ModalBody = ({ children, id, "data-testid": dataTestId, className, style, ref, }) => {
|
|
441
441
|
return (jsx("div", { className: cvaModalBodyContainer({ className }), "data-modal-body": true, "data-testid": dataTestId, id: id, ref: ref, style: style, children: children }));
|
|
442
|
-
}
|
|
442
|
+
};
|
|
443
443
|
|
|
444
444
|
const cvaModalFooterContainer = cva({
|
|
445
445
|
base: [
|
|
@@ -523,20 +523,20 @@ function isCustom(props) {
|
|
|
523
523
|
* @param props.primaryLoading Optional loading state for the Primary button.
|
|
524
524
|
* @returns {ReactElement} Modal footer container element.
|
|
525
525
|
*/
|
|
526
|
-
const ModalFooter =
|
|
527
|
-
const { "data-testid": dataTestId, className, style } = props;
|
|
526
|
+
const ModalFooter = (props) => {
|
|
527
|
+
const { "data-testid": dataTestId, className, style, ref } = props;
|
|
528
528
|
if (isCustom(props)) {
|
|
529
529
|
// Branch with children: everything else is not required
|
|
530
530
|
return (jsx("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, ref: ref, style: style, children: props.children }));
|
|
531
531
|
}
|
|
532
532
|
// Branch with built-in buttons
|
|
533
533
|
const { onCancel: onClickCancel, cancelLabel, primaryLabel, primaryAction, primaryVariant = "primary", primaryLoading = false, primaryDisabled = false, primaryFormId, secondaryLabel, secondaryAction, secondaryVariant = "secondary", secondaryLoading = false, secondaryDisabled = false, primaryName, secondaryName, cancelName, } = props;
|
|
534
|
-
return (jsxs("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, style: style, children: [jsx(Button, { "data-testid": dataTestId ? `${dataTestId}-cancel` : undefined, disabled: secondaryLoading || primaryLoading, name: cancelName, onClick: onClickCancel, variant: "ghost-neutral", children: cancelLabel }), secondaryLabel && secondaryAction ? (jsx(Button, { "data-testid": dataTestId ? `${dataTestId}-secondary` : undefined, disabled: primaryLoading || secondaryDisabled, loading: secondaryLoading, name: secondaryName,
|
|
534
|
+
return (jsxs("div", { className: cvaModalFooterContainer({ className }), "data-modal-footer": true, "data-testid": dataTestId, ref: ref, style: style, children: [jsx(Button, { "data-testid": dataTestId ? `${dataTestId}-cancel` : undefined, disabled: secondaryLoading || primaryLoading, name: cancelName, onClick: onClickCancel, variant: "ghost-neutral", children: cancelLabel }), secondaryLabel && secondaryAction ? (jsx(Button, { "data-testid": dataTestId ? `${dataTestId}-secondary` : undefined, disabled: primaryLoading || secondaryDisabled, loading: secondaryLoading, name: secondaryName,
|
|
535
535
|
// eslint-disable-next-line @trackunit/prefer-event-specific-callback-naming
|
|
536
536
|
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,
|
|
537
537
|
// eslint-disable-next-line @trackunit/prefer-event-specific-callback-naming
|
|
538
538
|
onClick: primaryAction, role: "button", type: "submit", variant: primaryVariant, children: primaryLabel })) : null] }));
|
|
539
|
-
}
|
|
539
|
+
};
|
|
540
540
|
|
|
541
541
|
const cvaContainer = cva({
|
|
542
542
|
base: ["flex", "justify-between", "border-b", "border-neutral-200", "p-4", "flex-none"],
|
|
@@ -595,14 +595,14 @@ const cvaIconContainer = cva({ base: ["flex", "place-items-center"] });
|
|
|
595
595
|
* @param {() => void} props.onClickClose Close button click handler.
|
|
596
596
|
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
597
597
|
* @param {string} [props.className] Optional additional class name(s).
|
|
598
|
-
* @returns The modal header element.
|
|
598
|
+
* @returns {ReactElement} The modal header element.
|
|
599
599
|
*/
|
|
600
|
-
const ModalHeader =
|
|
600
|
+
const ModalHeader = ({ heading, subHeading, onClickClose, "data-testid": dataTestId, className, style, id, children, accessories, ref, }) => {
|
|
601
601
|
const [t] = useTranslation();
|
|
602
602
|
return (jsxs("div", { className: cvaContainer({
|
|
603
603
|
className,
|
|
604
604
|
}), "data-testid": dataTestId, id: id, ref: ref, style: style, 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: onClickClose, size: "small", title: t("modalHeader.close"), variant: "ghost-neutral" }) })] }));
|
|
605
|
-
}
|
|
605
|
+
};
|
|
606
606
|
|
|
607
607
|
/**
|
|
608
608
|
* Trust anchor for the modal registry's outbound (iframe → host) postMessage.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-modal",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@floating-ui/react": "^0.26.25",
|
|
11
|
-
"@trackunit/react-components": "3.
|
|
12
|
-
"@trackunit/css-class-variance-utilities": "2.
|
|
13
|
-
"@trackunit/shared-utils": "1.
|
|
11
|
+
"@trackunit/react-components": "3.9.0",
|
|
12
|
+
"@trackunit/css-class-variance-utilities": "2.4.0",
|
|
13
|
+
"@trackunit/shared-utils": "1.20.0",
|
|
14
14
|
"@floating-ui/react-dom": "2.1.2",
|
|
15
|
-
"@trackunit/react-core-contexts-api": "1.
|
|
16
|
-
"@trackunit/i18n-library-translation": "2.
|
|
15
|
+
"@trackunit/react-core-contexts-api": "1.23.0",
|
|
16
|
+
"@trackunit/i18n-library-translation": "2.9.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@tanstack/react-router": "^1.114.29",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonProps, type Styleable } from "@trackunit/react-components";
|
|
2
|
-
import { ReactNode } from "react";
|
|
3
|
-
export interface ModalBodyProps extends CommonProps, Styleable {
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
|
+
import { ReactElement, ReactNode } from "react";
|
|
3
|
+
export interface ModalBodyProps extends CommonProps, Styleable, Refable<HTMLDivElement> {
|
|
4
4
|
/**
|
|
5
5
|
* Content to render inside the modal body. Accepts any React nodes.
|
|
6
6
|
* Typically text, lists, forms or other components.
|
|
@@ -50,4 +50,4 @@ export interface ModalBodyProps extends CommonProps, Styleable {
|
|
|
50
50
|
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
51
51
|
* @returns {ReactElement} Modal body wrapper element.
|
|
52
52
|
*/
|
|
53
|
-
export declare const ModalBody:
|
|
53
|
+
export declare const ModalBody: ({ children, id, "data-testid": dataTestId, className, style, ref, }: ModalBodyProps) => ReactElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonProps, type Styleable } from "@trackunit/react-components";
|
|
2
|
-
import { MouseEventHandler, ReactNode } from "react";
|
|
3
|
-
interface ModalFooterBuiltInProps extends CommonProps, Styleable {
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
|
+
import { MouseEventHandler, ReactElement, ReactNode } from "react";
|
|
3
|
+
interface ModalFooterBuiltInProps extends CommonProps, Styleable, Refable<HTMLDivElement> {
|
|
4
4
|
children?: null | undefined;
|
|
5
5
|
/**
|
|
6
6
|
* Click handler for the Cancel button.
|
|
@@ -66,7 +66,7 @@ interface ModalFooterBuiltInProps extends CommonProps, Styleable {
|
|
|
66
66
|
secondaryName?: string;
|
|
67
67
|
cancelName?: string;
|
|
68
68
|
}
|
|
69
|
-
interface ModalFooterCustomProps extends CommonProps, Styleable {
|
|
69
|
+
interface ModalFooterCustomProps extends CommonProps, Styleable, Refable<HTMLDivElement> {
|
|
70
70
|
children: ReactNode;
|
|
71
71
|
onCancel?: never;
|
|
72
72
|
cancelLabel?: never;
|
|
@@ -149,5 +149,5 @@ export type ModalFooterProps = ModalFooterBuiltInProps | ModalFooterCustomProps;
|
|
|
149
149
|
* @param props.primaryLoading Optional loading state for the Primary button.
|
|
150
150
|
* @returns {ReactElement} Modal footer container element.
|
|
151
151
|
*/
|
|
152
|
-
export declare const ModalFooter:
|
|
152
|
+
export declare const ModalFooter: (props: ModalFooterProps) => ReactElement;
|
|
153
153
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonProps, type Styleable } from "@trackunit/react-components";
|
|
2
|
-
import { MouseEventHandler, ReactNode } from "react";
|
|
3
|
-
export interface ModalHeaderProps extends CommonProps, Styleable {
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
|
+
import { MouseEventHandler, ReactElement, ReactNode } from "react";
|
|
3
|
+
export interface ModalHeaderProps extends CommonProps, Styleable, Refable<HTMLDivElement> {
|
|
4
4
|
/**
|
|
5
5
|
* Main title displayed in the modal header.
|
|
6
6
|
*/
|
|
@@ -77,6 +77,6 @@ export interface ModalHeaderProps extends CommonProps, Styleable {
|
|
|
77
77
|
* @param {() => void} props.onClickClose Close button click handler.
|
|
78
78
|
* @param {string} [props."data-testid"] Optional test id for the container.
|
|
79
79
|
* @param {string} [props.className] Optional additional class name(s).
|
|
80
|
-
* @returns The modal header element.
|
|
80
|
+
* @returns {ReactElement} The modal header element.
|
|
81
81
|
*/
|
|
82
|
-
export declare const ModalHeader:
|
|
82
|
+
export declare const ModalHeader: ({ heading, subHeading, onClickClose, "data-testid": dataTestId, className, style, id, children, accessories, ref, }: ModalHeaderProps) => ReactElement;
|