@trackunit/react-modal 1.3.20 → 1.3.21
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 +22 -6
- package/index.esm.js +22 -6
- package/package.json +1 -1
- package/src/modal/Modal.d.ts +4 -0
- package/src/modal/Modal.variants.d.ts +1 -0
- package/src/modal/ModalBackdrop.d.ts +3 -2
package/index.cjs.js
CHANGED
|
@@ -105,25 +105,41 @@ const cvaModalBackdrop = cssClassVarianceUtilities.cvaMerge([
|
|
|
105
105
|
], {
|
|
106
106
|
variants: {
|
|
107
107
|
show: {
|
|
108
|
-
true: "
|
|
108
|
+
true: "",
|
|
109
109
|
false: "",
|
|
110
110
|
},
|
|
111
111
|
noShadow: {
|
|
112
112
|
true: "",
|
|
113
113
|
false: "bg-black/50",
|
|
114
114
|
},
|
|
115
|
+
isFastOpen: {
|
|
116
|
+
true: "",
|
|
117
|
+
false: "",
|
|
118
|
+
},
|
|
115
119
|
},
|
|
120
|
+
compoundVariants: [
|
|
121
|
+
{
|
|
122
|
+
show: true,
|
|
123
|
+
isFastOpen: true,
|
|
124
|
+
class: "animate-modal-fade-fast",
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
show: true,
|
|
128
|
+
isFastOpen: false,
|
|
129
|
+
class: "animate-modal-fade",
|
|
130
|
+
},
|
|
131
|
+
],
|
|
116
132
|
});
|
|
117
133
|
|
|
118
134
|
/**
|
|
119
135
|
* The Backdrop for the modal.
|
|
120
|
-
|
|
136
|
+
|
|
121
137
|
* @param {ModalBackdropProps} props - The props for the ModalBackdrop component
|
|
122
138
|
* @returns {JSX.Element} ModalBackdrop component
|
|
123
139
|
*/
|
|
124
|
-
const ModalBackdrop = ({ children, isVisible, onClick, noShadow }) => {
|
|
140
|
+
const ModalBackdrop = ({ children, isVisible, onClick, noShadow, isFastOpen }) => {
|
|
125
141
|
const ref = React__namespace.useRef(null);
|
|
126
|
-
return (jsxRuntime.jsx("div", { className: cvaModalBackdrop({ show: isVisible, noShadow }), onMouseDown: e => {
|
|
142
|
+
return (jsxRuntime.jsx("div", { className: cvaModalBackdrop({ show: isVisible, noShadow, isFastOpen }), onMouseDown: e => {
|
|
127
143
|
// only react on click on backdrop - accessing first child to get around styled element element
|
|
128
144
|
if (ref.current !== null && e.target === ref.current.children[0]) {
|
|
129
145
|
onClick();
|
|
@@ -137,7 +153,7 @@ const ModalBackdrop = ({ children, isVisible, onClick, noShadow }) => {
|
|
|
137
153
|
* - The modal component provides a foundation for creating dialogs, lightboxes, etc.
|
|
138
154
|
|
|
139
155
|
*/
|
|
140
|
-
const Modal = React__namespace.forwardRef(({ isOpen, children, dataTestId, className, containerClassName, role = "", noBackdropShadow = false, onDismissClick = () => {
|
|
156
|
+
const Modal = React__namespace.forwardRef(({ isOpen, children, dataTestId, className, containerClassName, role = "", noBackdropShadow = false, isFastOpen = false, onDismissClick = () => {
|
|
141
157
|
return;
|
|
142
158
|
}, }, ref) => {
|
|
143
159
|
const { openModal, closeModal } = reactCoreHooks.useModalDialogContext();
|
|
@@ -157,7 +173,7 @@ const Modal = React__namespace.forwardRef(({ isOpen, children, dataTestId, class
|
|
|
157
173
|
};
|
|
158
174
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
159
175
|
}, []); // Empty dependency array means this effect runs only on mount and unmount
|
|
160
|
-
return (jsxRuntime.jsx(ModalBackdrop, { isVisible: isOpen, noShadow: noBackdropShadow, onClick: onDismissClick, children: isOpen ? (jsxRuntime.jsx("div", { className: cvaModalContainer({ className: containerClassName }), ref: ref, role: role, children: jsxRuntime.jsx(reactComponents.Card, { className: cvaModalCard({ className }), dataTestId: dataTestId, children: children }) })) : null }));
|
|
176
|
+
return (jsxRuntime.jsx(ModalBackdrop, { isFastOpen: isFastOpen, isVisible: isOpen, noShadow: noBackdropShadow, onClick: onDismissClick, children: isOpen ? (jsxRuntime.jsx("div", { className: cvaModalContainer({ className: containerClassName }), ref: ref, role: role, children: jsxRuntime.jsx(reactComponents.Card, { className: cvaModalCard({ className }), dataTestId: dataTestId, children: children }) })) : null }));
|
|
161
177
|
});
|
|
162
178
|
Modal.displayName = "Modal";
|
|
163
179
|
|
package/index.esm.js
CHANGED
|
@@ -85,25 +85,41 @@ const cvaModalBackdrop = cvaMerge([
|
|
|
85
85
|
], {
|
|
86
86
|
variants: {
|
|
87
87
|
show: {
|
|
88
|
-
true: "
|
|
88
|
+
true: "",
|
|
89
89
|
false: "",
|
|
90
90
|
},
|
|
91
91
|
noShadow: {
|
|
92
92
|
true: "",
|
|
93
93
|
false: "bg-black/50",
|
|
94
94
|
},
|
|
95
|
+
isFastOpen: {
|
|
96
|
+
true: "",
|
|
97
|
+
false: "",
|
|
98
|
+
},
|
|
95
99
|
},
|
|
100
|
+
compoundVariants: [
|
|
101
|
+
{
|
|
102
|
+
show: true,
|
|
103
|
+
isFastOpen: true,
|
|
104
|
+
class: "animate-modal-fade-fast",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
show: true,
|
|
108
|
+
isFastOpen: false,
|
|
109
|
+
class: "animate-modal-fade",
|
|
110
|
+
},
|
|
111
|
+
],
|
|
96
112
|
});
|
|
97
113
|
|
|
98
114
|
/**
|
|
99
115
|
* The Backdrop for the modal.
|
|
100
|
-
|
|
116
|
+
|
|
101
117
|
* @param {ModalBackdropProps} props - The props for the ModalBackdrop component
|
|
102
118
|
* @returns {JSX.Element} ModalBackdrop component
|
|
103
119
|
*/
|
|
104
|
-
const ModalBackdrop = ({ children, isVisible, onClick, noShadow }) => {
|
|
120
|
+
const ModalBackdrop = ({ children, isVisible, onClick, noShadow, isFastOpen }) => {
|
|
105
121
|
const ref = React.useRef(null);
|
|
106
|
-
return (jsx("div", { className: cvaModalBackdrop({ show: isVisible, noShadow }), onMouseDown: e => {
|
|
122
|
+
return (jsx("div", { className: cvaModalBackdrop({ show: isVisible, noShadow, isFastOpen }), onMouseDown: e => {
|
|
107
123
|
// only react on click on backdrop - accessing first child to get around styled element element
|
|
108
124
|
if (ref.current !== null && e.target === ref.current.children[0]) {
|
|
109
125
|
onClick();
|
|
@@ -117,7 +133,7 @@ const ModalBackdrop = ({ children, isVisible, onClick, noShadow }) => {
|
|
|
117
133
|
* - The modal component provides a foundation for creating dialogs, lightboxes, etc.
|
|
118
134
|
|
|
119
135
|
*/
|
|
120
|
-
const Modal = React.forwardRef(({ isOpen, children, dataTestId, className, containerClassName, role = "", noBackdropShadow = false, onDismissClick = () => {
|
|
136
|
+
const Modal = React.forwardRef(({ isOpen, children, dataTestId, className, containerClassName, role = "", noBackdropShadow = false, isFastOpen = false, onDismissClick = () => {
|
|
121
137
|
return;
|
|
122
138
|
}, }, ref) => {
|
|
123
139
|
const { openModal, closeModal } = useModalDialogContext();
|
|
@@ -137,7 +153,7 @@ const Modal = React.forwardRef(({ isOpen, children, dataTestId, className, conta
|
|
|
137
153
|
};
|
|
138
154
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
139
155
|
}, []); // Empty dependency array means this effect runs only on mount and unmount
|
|
140
|
-
return (jsx(ModalBackdrop, { isVisible: isOpen, noShadow: noBackdropShadow, onClick: onDismissClick, children: isOpen ? (jsx("div", { className: cvaModalContainer({ className: containerClassName }), ref: ref, role: role, children: jsx(Card, { className: cvaModalCard({ className }), dataTestId: dataTestId, children: children }) })) : null }));
|
|
156
|
+
return (jsx(ModalBackdrop, { isFastOpen: isFastOpen, isVisible: isOpen, noShadow: noBackdropShadow, onClick: onDismissClick, children: isOpen ? (jsx("div", { className: cvaModalContainer({ className: containerClassName }), ref: ref, role: role, children: jsx(Card, { className: cvaModalCard({ className }), dataTestId: dataTestId, children: children }) })) : null }));
|
|
141
157
|
});
|
|
142
158
|
Modal.displayName = "Modal";
|
|
143
159
|
|
package/package.json
CHANGED
package/src/modal/Modal.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ export interface ModalProps extends CommonProps {
|
|
|
29
29
|
* A custom class name to be attached to modal container
|
|
30
30
|
*/
|
|
31
31
|
containerClassName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether modal should open with a fast animation or not.
|
|
34
|
+
*/
|
|
35
|
+
isFastOpen?: boolean;
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* - Modals are used to present critical information or request user input needed to complete a user's workflow.
|
|
@@ -3,4 +3,5 @@ export declare const cvaModalCard: (props?: import("class-variance-authority/dis
|
|
|
3
3
|
export declare const cvaModalBackdrop: (props?: ({
|
|
4
4
|
show?: boolean | null | undefined;
|
|
5
5
|
noShadow?: boolean | null | undefined;
|
|
6
|
+
isFastOpen?: boolean | null | undefined;
|
|
6
7
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -4,11 +4,12 @@ export interface ModalBackdropProps {
|
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
isVisible?: boolean;
|
|
6
6
|
noShadow?: boolean;
|
|
7
|
+
isFastOpen?: boolean;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* The Backdrop for the modal.
|
|
10
|
-
|
|
11
|
+
|
|
11
12
|
* @param {ModalBackdropProps} props - The props for the ModalBackdrop component
|
|
12
13
|
* @returns {JSX.Element} ModalBackdrop component
|
|
13
14
|
*/
|
|
14
|
-
export declare const ModalBackdrop: ({ children, isVisible, onClick, noShadow }: ModalBackdropProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const ModalBackdrop: ({ children, isVisible, onClick, noShadow, isFastOpen }: ModalBackdropProps) => import("react/jsx-runtime").JSX.Element;
|