@vlrc-fe/components 3.0.5 → 3.0.6
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/CHANGELOG.md +7 -0
- package/dist/ConfirmModal.cjs +20 -14
- package/dist/ConfirmModal.d.ts +14 -2
- package/dist/ConfirmModal.d.ts.map +1 -1
- package/dist/ConfirmModal.js +20 -14
- package/dist/Modal.cjs +12 -9
- package/dist/Modal.d.ts +11 -1
- package/dist/Modal.d.ts.map +1 -1
- package/dist/Modal.js +12 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.0.6] - 2026-11-20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **ConfirmModal & Modal Prop Compatibility**:
|
|
8
|
+
- Restored backward-compatible prop aliases (`onClose`, `isOpen`, `onOk`, `variant`, `loading`, `message`) on `Modal` and `ConfirmModal` to ensure zero breaking changes across enterprise consumer applications.
|
|
9
|
+
|
|
3
10
|
## [3.0.5] - 2026-11-20
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/ConfirmModal.cjs
CHANGED
|
@@ -178,17 +178,23 @@ var TYPE_CONFIG = {
|
|
|
178
178
|
* Confirmation dialog for critical user actions (deletions, warnings, approvals).
|
|
179
179
|
* Built with Meta StyleX and Radix UI Dialog with native overscroll containment.
|
|
180
180
|
*/
|
|
181
|
-
function ConfirmModal({ open
|
|
181
|
+
function ConfirmModal({ open, isOpen, onClose, onCancel, onConfirm, onOk, title, message, description, children, confirmText = "Confirm", cancelText = "Cancel", closeLabel = "Close", processingText = "Processing...", loadingText, type, variant = "warning", isLoading, loading, size = "md", width, footer, sx, className }) {
|
|
182
|
+
const isModalOpen = open ?? isOpen ?? true;
|
|
183
|
+
const isPending = isLoading ?? loading ?? false;
|
|
184
|
+
const rawType = type ?? variant ?? "warning";
|
|
185
|
+
const resolvedType = rawType === "error" ? "danger" : rawType;
|
|
186
|
+
const resolvedMessage = message ?? description;
|
|
187
|
+
const resolvedLoadingText = loadingText ?? processingText ?? "Processing...";
|
|
182
188
|
const handleDismiss = () => {
|
|
183
|
-
if (!
|
|
189
|
+
if (!isPending) (onCancel ?? onClose)?.();
|
|
184
190
|
};
|
|
185
191
|
const handleConfirm = () => {
|
|
186
|
-
if (!
|
|
192
|
+
if (!isPending) (onConfirm ?? onOk)?.();
|
|
187
193
|
};
|
|
188
|
-
const { Icon, iconStyle, btnStyle } = TYPE_CONFIG[
|
|
194
|
+
const { Icon, iconStyle, btnStyle } = TYPE_CONFIG[resolvedType] ?? TYPE_CONFIG.warning;
|
|
189
195
|
const sizeStyle = sizeStyles[size] ?? styles.sizeMd;
|
|
190
196
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_dialog.Dialog, {
|
|
191
|
-
open,
|
|
197
|
+
open: isModalOpen,
|
|
192
198
|
onOpenChange: (val) => !val && handleDismiss(),
|
|
193
199
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_dialog.DialogContent, {
|
|
194
200
|
showCloseButton: false,
|
|
@@ -200,16 +206,16 @@ function ConfirmModal({ open = true, onCancel, onConfirm, title, message, childr
|
|
|
200
206
|
className,
|
|
201
207
|
style: width ? { maxWidth: width } : void 0,
|
|
202
208
|
onEscapeKeyDown: (e) => {
|
|
203
|
-
if (
|
|
209
|
+
if (isPending) e.preventDefault();
|
|
204
210
|
},
|
|
205
211
|
onPointerDownOutside: (e_0) => {
|
|
206
|
-
if (
|
|
212
|
+
if (isPending) e_0.preventDefault();
|
|
207
213
|
},
|
|
208
214
|
children: [
|
|
209
215
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
210
216
|
type: "button",
|
|
211
217
|
onClick: handleDismiss,
|
|
212
|
-
disabled:
|
|
218
|
+
disabled: isPending,
|
|
213
219
|
className: "x10l6tqk x1u62bzc x1nwpe0i x9psvww x78pyy4 xw3nh4a xc342km xjbqb8w x1ypdohk x78zum5 x6s0dn4 xl56j7k x1a2a7pz xfyfa0t x9p52ec x8aud5w xk2swo9 x13nj1q9 x1s07b3s xijokvz",
|
|
214
220
|
"aria-label": closeLabel,
|
|
215
221
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icons.Icons.X, { className: "xw4jnvo x1qx5ct2" })
|
|
@@ -231,12 +237,12 @@ function ConfirmModal({ open = true, onCancel, onConfirm, title, message, childr
|
|
|
231
237
|
children: title
|
|
232
238
|
})
|
|
233
239
|
}),
|
|
234
|
-
|
|
240
|
+
resolvedMessage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_dialog.DialogDescription, {
|
|
235
241
|
asChild: true,
|
|
236
242
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text.Text, {
|
|
237
243
|
type: "muted",
|
|
238
244
|
sx: styles.message,
|
|
239
|
-
children:
|
|
245
|
+
children: resolvedMessage
|
|
240
246
|
})
|
|
241
247
|
}) : null,
|
|
242
248
|
children
|
|
@@ -249,16 +255,16 @@ function ConfirmModal({ open = true, onCancel, onConfirm, title, message, childr
|
|
|
249
255
|
type: "button",
|
|
250
256
|
variant: "outline",
|
|
251
257
|
onClick: handleDismiss,
|
|
252
|
-
disabled:
|
|
258
|
+
disabled: isPending,
|
|
253
259
|
sx: styles.cancelBtn,
|
|
254
260
|
children: cancelText
|
|
255
261
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_button.Button, {
|
|
256
262
|
type: "button",
|
|
257
|
-
variant:
|
|
263
|
+
variant: resolvedType === "danger" ? "destructive" : "default",
|
|
258
264
|
onClick: handleConfirm,
|
|
259
|
-
isLoading,
|
|
265
|
+
isLoading: isPending,
|
|
260
266
|
sx: [styles.confirmBtn, btnStyle],
|
|
261
|
-
children:
|
|
267
|
+
children: isPending ? resolvedLoadingText : confirmText
|
|
262
268
|
})]
|
|
263
269
|
})
|
|
264
270
|
]
|
package/dist/ConfirmModal.d.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import * as stylex from '@stylexjs/stylex';
|
|
3
3
|
import type { ComponentSize } from './theme/types';
|
|
4
|
-
export type ConfirmModalType = 'warning' | 'info' | 'success' | 'danger';
|
|
4
|
+
export type ConfirmModalType = 'warning' | 'info' | 'success' | 'danger' | 'error';
|
|
5
5
|
export interface ConfirmModalProps {
|
|
6
6
|
/** Controls visibility of the confirmation modal dialog. */
|
|
7
7
|
open?: boolean;
|
|
8
|
+
/** Alias for `open` maintaining backward compatibility. */
|
|
9
|
+
isOpen?: boolean;
|
|
8
10
|
/** Callback fired when the dialog is dismissed or cancel button clicked. */
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
/** Alias for `onClose` (consistent with Modal `onCancel`). */
|
|
9
13
|
onCancel?: () => void;
|
|
10
14
|
/** Callback fired when the user confirms the action. */
|
|
11
15
|
onConfirm?: () => void;
|
|
16
|
+
/** Alias for `onConfirm`. */
|
|
17
|
+
onOk?: () => void;
|
|
12
18
|
/** Dialog heading title summarizing the intent. */
|
|
13
19
|
title: ReactNode;
|
|
14
20
|
/** Explanatory message describing the consequences of the action. */
|
|
15
21
|
message?: ReactNode;
|
|
22
|
+
/** Alias for `message` (consistent with Modal `description`). */
|
|
23
|
+
description?: ReactNode;
|
|
16
24
|
/** Optional body content rendered inside the dialog body. */
|
|
17
25
|
children?: ReactNode;
|
|
18
26
|
/** Text shown on the confirmation button (defaults to "Confirm"). */
|
|
@@ -27,8 +35,12 @@ export interface ConfirmModalProps {
|
|
|
27
35
|
loadingText?: string;
|
|
28
36
|
/** Semantic type determining the accent color and icon. */
|
|
29
37
|
type?: ConfirmModalType;
|
|
38
|
+
/** Alias for `type` to follow design system variant conventions. */
|
|
39
|
+
variant?: ConfirmModalType;
|
|
30
40
|
/** Whether the confirmation request is currently pending. */
|
|
31
41
|
isLoading?: boolean;
|
|
42
|
+
/** Alias for `isLoading`. */
|
|
43
|
+
loading?: boolean;
|
|
32
44
|
/** Sizing tier across the universal 7-level scale. Defaults to 'md'. */
|
|
33
45
|
size?: ComponentSize;
|
|
34
46
|
/** Maximum width in pixels or CSS unit (overrides size preset). */
|
|
@@ -44,5 +56,5 @@ export interface ConfirmModalProps {
|
|
|
44
56
|
* Confirmation dialog for critical user actions (deletions, warnings, approvals).
|
|
45
57
|
* Built with Meta StyleX and Radix UI Dialog with native overscroll containment.
|
|
46
58
|
*/
|
|
47
|
-
export declare function ConfirmModal({ open, onCancel, onConfirm, title, message, children, confirmText, cancelText, closeLabel, processingText, loadingText, type, isLoading, size, width, footer, sx, className, }: ConfirmModalProps): import("react").JSX.Element;
|
|
59
|
+
export declare function ConfirmModal({ open, isOpen, onClose, onCancel, onConfirm, onOk, title, message, description, children, confirmText, cancelText, closeLabel, processingText, loadingText, type, variant, isLoading, loading, size, width, footer, sx, className, }: ConfirmModalProps): import("react").JSX.Element;
|
|
48
60
|
//# sourceMappingURL=ConfirmModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal.d.ts","sourceRoot":"","sources":["../src/ConfirmModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA8LnD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmModal.d.ts","sourceRoot":"","sources":["../src/ConfirmModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CA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,CAAC;IACxB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,qEAAqE;IACrE,EAAE,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC;IACzB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,KAAK,EACL,OAAO,EACP,WAAW,EACX,QAAQ,EACR,WAAuB,EACvB,UAAqB,EACrB,UAAoB,EACpB,cAAgC,EAChC,WAAW,EACX,IAAI,EACJ,OAAmB,EACnB,SAAS,EACT,OAAO,EACP,IAAW,EACX,KAAK,EACL,MAAM,EACN,EAAE,EACF,SAAS,GACV,EAAE,iBAAiB,+BA0FnB"}
|
package/dist/ConfirmModal.js
CHANGED
|
@@ -176,17 +176,23 @@ var TYPE_CONFIG = {
|
|
|
176
176
|
* Confirmation dialog for critical user actions (deletions, warnings, approvals).
|
|
177
177
|
* Built with Meta StyleX and Radix UI Dialog with native overscroll containment.
|
|
178
178
|
*/
|
|
179
|
-
function ConfirmModal({ open
|
|
179
|
+
function ConfirmModal({ open, isOpen, onClose, onCancel, onConfirm, onOk, title, message, description, children, confirmText = "Confirm", cancelText = "Cancel", closeLabel = "Close", processingText = "Processing...", loadingText, type, variant = "warning", isLoading, loading, size = "md", width, footer, sx, className }) {
|
|
180
|
+
const isModalOpen = open ?? isOpen ?? true;
|
|
181
|
+
const isPending = isLoading ?? loading ?? false;
|
|
182
|
+
const rawType = type ?? variant ?? "warning";
|
|
183
|
+
const resolvedType = rawType === "error" ? "danger" : rawType;
|
|
184
|
+
const resolvedMessage = message ?? description;
|
|
185
|
+
const resolvedLoadingText = loadingText ?? processingText ?? "Processing...";
|
|
180
186
|
const handleDismiss = () => {
|
|
181
|
-
if (!
|
|
187
|
+
if (!isPending) (onCancel ?? onClose)?.();
|
|
182
188
|
};
|
|
183
189
|
const handleConfirm = () => {
|
|
184
|
-
if (!
|
|
190
|
+
if (!isPending) (onConfirm ?? onOk)?.();
|
|
185
191
|
};
|
|
186
|
-
const { Icon, iconStyle, btnStyle } = TYPE_CONFIG[
|
|
192
|
+
const { Icon, iconStyle, btnStyle } = TYPE_CONFIG[resolvedType] ?? TYPE_CONFIG.warning;
|
|
187
193
|
const sizeStyle = sizeStyles[size] ?? styles.sizeMd;
|
|
188
194
|
return /* @__PURE__ */ jsx(Dialog, {
|
|
189
|
-
open,
|
|
195
|
+
open: isModalOpen,
|
|
190
196
|
onOpenChange: (val) => !val && handleDismiss(),
|
|
191
197
|
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
192
198
|
showCloseButton: false,
|
|
@@ -198,16 +204,16 @@ function ConfirmModal({ open = true, onCancel, onConfirm, title, message, childr
|
|
|
198
204
|
className,
|
|
199
205
|
style: width ? { maxWidth: width } : void 0,
|
|
200
206
|
onEscapeKeyDown: (e) => {
|
|
201
|
-
if (
|
|
207
|
+
if (isPending) e.preventDefault();
|
|
202
208
|
},
|
|
203
209
|
onPointerDownOutside: (e_0) => {
|
|
204
|
-
if (
|
|
210
|
+
if (isPending) e_0.preventDefault();
|
|
205
211
|
},
|
|
206
212
|
children: [
|
|
207
213
|
/* @__PURE__ */ jsx("button", {
|
|
208
214
|
type: "button",
|
|
209
215
|
onClick: handleDismiss,
|
|
210
|
-
disabled:
|
|
216
|
+
disabled: isPending,
|
|
211
217
|
className: "x10l6tqk x1u62bzc x1nwpe0i x9psvww x78pyy4 xw3nh4a xc342km xjbqb8w x1ypdohk x78zum5 x6s0dn4 xl56j7k x1a2a7pz xfyfa0t x9p52ec x8aud5w xk2swo9 x13nj1q9 x1s07b3s xijokvz",
|
|
212
218
|
"aria-label": closeLabel,
|
|
213
219
|
children: /* @__PURE__ */ jsx(Icons.X, { className: "xw4jnvo x1qx5ct2" })
|
|
@@ -229,12 +235,12 @@ function ConfirmModal({ open = true, onCancel, onConfirm, title, message, childr
|
|
|
229
235
|
children: title
|
|
230
236
|
})
|
|
231
237
|
}),
|
|
232
|
-
|
|
238
|
+
resolvedMessage ? /* @__PURE__ */ jsx(DialogDescription, {
|
|
233
239
|
asChild: true,
|
|
234
240
|
children: /* @__PURE__ */ jsx(Text, {
|
|
235
241
|
type: "muted",
|
|
236
242
|
sx: styles.message,
|
|
237
|
-
children:
|
|
243
|
+
children: resolvedMessage
|
|
238
244
|
})
|
|
239
245
|
}) : null,
|
|
240
246
|
children
|
|
@@ -247,16 +253,16 @@ function ConfirmModal({ open = true, onCancel, onConfirm, title, message, childr
|
|
|
247
253
|
type: "button",
|
|
248
254
|
variant: "outline",
|
|
249
255
|
onClick: handleDismiss,
|
|
250
|
-
disabled:
|
|
256
|
+
disabled: isPending,
|
|
251
257
|
sx: styles.cancelBtn,
|
|
252
258
|
children: cancelText
|
|
253
259
|
}), /* @__PURE__ */ jsx(Button, {
|
|
254
260
|
type: "button",
|
|
255
|
-
variant:
|
|
261
|
+
variant: resolvedType === "danger" ? "destructive" : "default",
|
|
256
262
|
onClick: handleConfirm,
|
|
257
|
-
isLoading,
|
|
263
|
+
isLoading: isPending,
|
|
258
264
|
sx: [styles.confirmBtn, btnStyle],
|
|
259
|
-
children:
|
|
265
|
+
children: isPending ? resolvedLoadingText : confirmText
|
|
260
266
|
})]
|
|
261
267
|
})
|
|
262
268
|
]
|
package/dist/Modal.cjs
CHANGED
|
@@ -79,17 +79,20 @@ var sizeStyles = {
|
|
|
79
79
|
* Standard modal dialog component for VLRC applications.
|
|
80
80
|
* Built on top of Radix UI Dialog and styled with Meta StyleX with overscroll containment.
|
|
81
81
|
*/
|
|
82
|
-
function Modal({ open
|
|
82
|
+
function Modal({ open, isOpen, title, description, message, children, footer, size = "md", width, confirmText = "Confirm", cancelText = "Cancel", isLoading, loading, loadingText, onCancel, onClose, onConfirm, onOk, sx, className }) {
|
|
83
|
+
const isVisible = open ?? isOpen ?? true;
|
|
84
|
+
const isPending = isLoading ?? loading ?? false;
|
|
85
|
+
const resolvedDescription = description ?? message;
|
|
83
86
|
const handleDismiss = () => {
|
|
84
|
-
if (!
|
|
87
|
+
if (!isPending) (onCancel ?? onClose)?.();
|
|
85
88
|
};
|
|
86
89
|
const handleConfirm = () => {
|
|
87
|
-
if (!
|
|
90
|
+
if (!isPending) (onConfirm ?? onOk)?.();
|
|
88
91
|
};
|
|
89
|
-
const hasConfirmAction = Boolean(onConfirm);
|
|
92
|
+
const hasConfirmAction = Boolean(onConfirm || onOk);
|
|
90
93
|
const sizeStyle = sizeStyles[size] ?? styles.sizeMd;
|
|
91
94
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_dialog.Dialog, {
|
|
92
|
-
open,
|
|
95
|
+
open: isVisible,
|
|
93
96
|
onOpenChange: (val) => !val && handleDismiss(),
|
|
94
97
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_dialog.DialogContent, {
|
|
95
98
|
sx: [
|
|
@@ -102,7 +105,7 @@ function Modal({ open = true, title, description, children, footer, size = "md",
|
|
|
102
105
|
children: [
|
|
103
106
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_dialog.DialogHeader, {
|
|
104
107
|
sx: styles.header,
|
|
105
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_dialog.DialogTitle, { children: title }),
|
|
108
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_dialog.DialogTitle, { children: title }), resolvedDescription ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_dialog.DialogDescription, { children: resolvedDescription }) : null]
|
|
106
109
|
}),
|
|
107
110
|
children ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
108
111
|
className: "x12lumcd x1odjw0f x1qhpy6z xgepmj6",
|
|
@@ -115,12 +118,12 @@ function Modal({ open = true, title, description, children, footer, size = "md",
|
|
|
115
118
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_button.Button, {
|
|
116
119
|
variant: "outline",
|
|
117
120
|
onClick: handleDismiss,
|
|
118
|
-
disabled:
|
|
121
|
+
disabled: isPending,
|
|
119
122
|
children: cancelText
|
|
120
123
|
}), hasConfirmAction ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_button.Button, {
|
|
121
124
|
onClick: handleConfirm,
|
|
122
|
-
disabled:
|
|
123
|
-
children:
|
|
125
|
+
disabled: isPending,
|
|
126
|
+
children: isPending && loadingText ? loadingText : confirmText
|
|
124
127
|
}) : null]
|
|
125
128
|
})
|
|
126
129
|
})
|
package/dist/Modal.d.ts
CHANGED
|
@@ -4,12 +4,18 @@ import type { ComponentSize } from './theme/types';
|
|
|
4
4
|
export interface ModalProps {
|
|
5
5
|
/** Whether the modal dialog is currently visible and open. */
|
|
6
6
|
open?: boolean;
|
|
7
|
+
/** Alias for `open` for consistent prop usage across modal components. */
|
|
8
|
+
isOpen?: boolean;
|
|
7
9
|
/** Callback fired when the cancel button, close icon, or backdrop is clicked. */
|
|
8
10
|
onCancel?: () => void;
|
|
11
|
+
/** Alias for `onCancel` (consistent with ConfirmModal `onClose`). */
|
|
12
|
+
onClose?: () => void;
|
|
9
13
|
/** Primary title rendered in the modal header. */
|
|
10
14
|
title: ReactNode;
|
|
11
15
|
/** Optional secondary subtitle or description below the title. */
|
|
12
16
|
description?: ReactNode;
|
|
17
|
+
/** Alias for `description` (consistent with ConfirmModal `message`). */
|
|
18
|
+
message?: ReactNode;
|
|
13
19
|
/** Main body content rendered inside the scrollable dialog area. */
|
|
14
20
|
children?: ReactNode;
|
|
15
21
|
/** Custom footer node replacing the default cancel/confirm button row. */
|
|
@@ -24,8 +30,12 @@ export interface ModalProps {
|
|
|
24
30
|
cancelText?: string;
|
|
25
31
|
/** Callback fired when the primary confirmation button is clicked. */
|
|
26
32
|
onConfirm?: () => void;
|
|
33
|
+
/** Alias for `onConfirm`. */
|
|
34
|
+
onOk?: () => void;
|
|
27
35
|
/** If true, displays a loading state and disables modal action buttons. */
|
|
28
36
|
isLoading?: boolean;
|
|
37
|
+
/** Alias for `isLoading`. */
|
|
38
|
+
loading?: boolean;
|
|
29
39
|
/** Text displayed when confirmation action is loading. */
|
|
30
40
|
loadingText?: string;
|
|
31
41
|
/** Custom StyleX style overrides applied to the dialog container. */
|
|
@@ -37,5 +47,5 @@ export interface ModalProps {
|
|
|
37
47
|
* Standard modal dialog component for VLRC applications.
|
|
38
48
|
* Built on top of Radix UI Dialog and styled with Meta StyleX with overscroll containment.
|
|
39
49
|
*/
|
|
40
|
-
export declare function Modal({ open, title, description, children, footer, size, width, confirmText, cancelText, isLoading, loadingText, onCancel, onConfirm, sx, className, }: ModalProps): import("react").JSX.Element;
|
|
50
|
+
export declare function Modal({ open, isOpen, title, description, message, children, footer, size, width, confirmText, cancelText, isLoading, loading, loadingText, onCancel, onClose, onConfirm, onOk, sx, className, }: ModalProps): import("react").JSX.Element;
|
|
41
51
|
//# sourceMappingURL=Modal.d.ts.map
|
package/dist/Modal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAuEnD,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,kDAAkD;IAClD,KAAK,EAAE,SAAS,CAAC;IACjB,kEAAkE;IAClE,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,wEAAwE;IACxE,IAAI,CAAC,E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ACnB,wEAAwE;IACxE,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;IAClB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,EAAE,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC;IACzB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,EACpB,IAAI,EACJ,MAAM,EACN,KAAK,EACL,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,IAAW,EACX,KAAK,EACL,WAAuB,EACvB,UAAqB,EACrB,SAAS,EACT,OAAO,EACP,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,EAAE,EACF,SAAS,GACV,EAAE,UAAU,+BAiDZ"}
|
package/dist/Modal.js
CHANGED
|
@@ -77,17 +77,20 @@ var sizeStyles = {
|
|
|
77
77
|
* Standard modal dialog component for VLRC applications.
|
|
78
78
|
* Built on top of Radix UI Dialog and styled with Meta StyleX with overscroll containment.
|
|
79
79
|
*/
|
|
80
|
-
function Modal({ open
|
|
80
|
+
function Modal({ open, isOpen, title, description, message, children, footer, size = "md", width, confirmText = "Confirm", cancelText = "Cancel", isLoading, loading, loadingText, onCancel, onClose, onConfirm, onOk, sx, className }) {
|
|
81
|
+
const isVisible = open ?? isOpen ?? true;
|
|
82
|
+
const isPending = isLoading ?? loading ?? false;
|
|
83
|
+
const resolvedDescription = description ?? message;
|
|
81
84
|
const handleDismiss = () => {
|
|
82
|
-
if (!
|
|
85
|
+
if (!isPending) (onCancel ?? onClose)?.();
|
|
83
86
|
};
|
|
84
87
|
const handleConfirm = () => {
|
|
85
|
-
if (!
|
|
88
|
+
if (!isPending) (onConfirm ?? onOk)?.();
|
|
86
89
|
};
|
|
87
|
-
const hasConfirmAction = Boolean(onConfirm);
|
|
90
|
+
const hasConfirmAction = Boolean(onConfirm || onOk);
|
|
88
91
|
const sizeStyle = sizeStyles[size] ?? styles.sizeMd;
|
|
89
92
|
return /* @__PURE__ */ jsx(Dialog, {
|
|
90
|
-
open,
|
|
93
|
+
open: isVisible,
|
|
91
94
|
onOpenChange: (val) => !val && handleDismiss(),
|
|
92
95
|
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
93
96
|
sx: [
|
|
@@ -100,7 +103,7 @@ function Modal({ open = true, title, description, children, footer, size = "md",
|
|
|
100
103
|
children: [
|
|
101
104
|
/* @__PURE__ */ jsxs(DialogHeader, {
|
|
102
105
|
sx: styles.header,
|
|
103
|
-
children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }),
|
|
106
|
+
children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }), resolvedDescription ? /* @__PURE__ */ jsx(DialogDescription, { children: resolvedDescription }) : null]
|
|
104
107
|
}),
|
|
105
108
|
children ? /* @__PURE__ */ jsx("div", {
|
|
106
109
|
className: "x12lumcd x1odjw0f x1qhpy6z xgepmj6",
|
|
@@ -113,12 +116,12 @@ function Modal({ open = true, title, description, children, footer, size = "md",
|
|
|
113
116
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
114
117
|
variant: "outline",
|
|
115
118
|
onClick: handleDismiss,
|
|
116
|
-
disabled:
|
|
119
|
+
disabled: isPending,
|
|
117
120
|
children: cancelText
|
|
118
121
|
}), hasConfirmAction ? /* @__PURE__ */ jsx(Button, {
|
|
119
122
|
onClick: handleConfirm,
|
|
120
|
-
disabled:
|
|
121
|
-
children:
|
|
123
|
+
disabled: isPending,
|
|
124
|
+
children: isPending && loadingText ? loadingText : confirmText
|
|
122
125
|
}) : null]
|
|
123
126
|
})
|
|
124
127
|
})
|