framepexls-ui-lib 0.1.4
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/dist/ActionIconButton.d.mts +11 -0
- package/dist/ActionIconButton.d.ts +11 -0
- package/dist/ActionIconButton.js +71 -0
- package/dist/ActionIconButton.mjs +41 -0
- package/dist/AppTopbar.d.mts +17 -0
- package/dist/AppTopbar.d.ts +17 -0
- package/dist/AppTopbar.js +51 -0
- package/dist/AppTopbar.mjs +31 -0
- package/dist/AvatarSquare.d.mts +16 -0
- package/dist/AvatarSquare.d.ts +16 -0
- package/dist/AvatarSquare.js +82 -0
- package/dist/AvatarSquare.mjs +52 -0
- package/dist/Badge.d.mts +13 -0
- package/dist/Badge.d.ts +13 -0
- package/dist/Badge.js +65 -0
- package/dist/Badge.mjs +45 -0
- package/dist/BadgeCluster.d.mts +17 -0
- package/dist/BadgeCluster.d.ts +17 -0
- package/dist/BadgeCluster.js +125 -0
- package/dist/BadgeCluster.mjs +95 -0
- package/dist/Breadcrumb.d.mts +11 -0
- package/dist/Breadcrumb.d.ts +11 -0
- package/dist/Breadcrumb.js +42 -0
- package/dist/Breadcrumb.mjs +12 -0
- package/dist/Button.d.mts +15 -0
- package/dist/Button.d.ts +15 -0
- package/dist/Button.js +72 -0
- package/dist/Button.mjs +52 -0
- package/dist/CalendarPanel.d.mts +13 -0
- package/dist/CalendarPanel.d.ts +13 -0
- package/dist/CalendarPanel.js +110 -0
- package/dist/CalendarPanel.mjs +90 -0
- package/dist/ChartCard.d.mts +15 -0
- package/dist/ChartCard.d.ts +15 -0
- package/dist/ChartCard.js +44 -0
- package/dist/ChartCard.mjs +24 -0
- package/dist/CheckboxPillsGroup.d.mts +28 -0
- package/dist/CheckboxPillsGroup.d.ts +28 -0
- package/dist/CheckboxPillsGroup.js +186 -0
- package/dist/CheckboxPillsGroup.mjs +156 -0
- package/dist/ColumnSelector.d.mts +17 -0
- package/dist/ColumnSelector.d.ts +17 -0
- package/dist/ColumnSelector.js +74 -0
- package/dist/ColumnSelector.mjs +54 -0
- package/dist/ComboSelect.d.mts +46 -0
- package/dist/ComboSelect.d.ts +46 -0
- package/dist/ComboSelect.js +442 -0
- package/dist/ComboSelect.mjs +412 -0
- package/dist/DateTimeField.d.mts +22 -0
- package/dist/DateTimeField.d.ts +22 -0
- package/dist/DateTimeField.js +409 -0
- package/dist/DateTimeField.mjs +379 -0
- package/dist/Dialog.d.mts +82 -0
- package/dist/Dialog.d.ts +82 -0
- package/dist/Dialog.js +408 -0
- package/dist/Dialog.mjs +368 -0
- package/dist/Dropdown.d.mts +52 -0
- package/dist/Dropdown.d.ts +52 -0
- package/dist/Dropdown.js +333 -0
- package/dist/Dropdown.mjs +313 -0
- package/dist/EmptyState.d.mts +8 -0
- package/dist/EmptyState.d.ts +8 -0
- package/dist/EmptyState.js +35 -0
- package/dist/EmptyState.mjs +15 -0
- package/dist/InfoGrid.d.mts +20 -0
- package/dist/InfoGrid.d.ts +20 -0
- package/dist/InfoGrid.js +67 -0
- package/dist/InfoGrid.mjs +47 -0
- package/dist/Input.d.mts +20 -0
- package/dist/Input.d.ts +20 -0
- package/dist/Input.js +85 -0
- package/dist/Input.mjs +55 -0
- package/dist/Money.d.mts +8 -0
- package/dist/Money.d.ts +8 -0
- package/dist/Money.js +30 -0
- package/dist/Money.mjs +10 -0
- package/dist/OrderButton.d.mts +11 -0
- package/dist/OrderButton.d.ts +11 -0
- package/dist/OrderButton.js +39 -0
- package/dist/OrderButton.mjs +19 -0
- package/dist/Pagination.d.mts +12 -0
- package/dist/Pagination.d.ts +12 -0
- package/dist/Pagination.js +71 -0
- package/dist/Pagination.mjs +51 -0
- package/dist/SearchInput.d.mts +17 -0
- package/dist/SearchInput.d.ts +17 -0
- package/dist/SearchInput.js +116 -0
- package/dist/SearchInput.mjs +86 -0
- package/dist/Select.d.mts +31 -0
- package/dist/Select.d.ts +31 -0
- package/dist/Select.js +293 -0
- package/dist/Select.mjs +263 -0
- package/dist/StatCard.d.mts +15 -0
- package/dist/StatCard.d.ts +15 -0
- package/dist/StatCard.js +47 -0
- package/dist/StatCard.mjs +27 -0
- package/dist/Steps.d.mts +31 -0
- package/dist/Steps.d.ts +31 -0
- package/dist/Steps.js +123 -0
- package/dist/Steps.mjs +99 -0
- package/dist/Table.d.mts +31 -0
- package/dist/Table.d.ts +31 -0
- package/dist/Table.js +153 -0
- package/dist/Table.mjs +117 -0
- package/dist/TimeAgo.d.mts +12 -0
- package/dist/TimeAgo.d.ts +12 -0
- package/dist/TimeAgo.js +104 -0
- package/dist/TimeAgo.mjs +74 -0
- package/dist/TimePanel.d.mts +14 -0
- package/dist/TimePanel.d.ts +14 -0
- package/dist/TimePanel.js +145 -0
- package/dist/TimePanel.mjs +125 -0
- package/dist/TimePopover.d.mts +33 -0
- package/dist/TimePopover.d.ts +33 -0
- package/dist/TimePopover.js +441 -0
- package/dist/TimePopover.mjs +406 -0
- package/dist/iconos/index.d.mts +60 -0
- package/dist/iconos/index.d.ts +60 -0
- package/dist/iconos/index.js +621 -0
- package/dist/iconos/index.mjs +548 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +141 -0
- package/dist/index.mjs +70 -0
- package/package.json +178 -0
package/dist/Dialog.js
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var Dialog_exports = {};
|
|
31
|
+
__export(Dialog_exports, {
|
|
32
|
+
ConfirmDialog: () => ConfirmDialog,
|
|
33
|
+
Dialog: () => Dialog,
|
|
34
|
+
DialogBody: () => DialogBody,
|
|
35
|
+
DialogField: () => DialogField,
|
|
36
|
+
DialogFooter: () => DialogFooter,
|
|
37
|
+
DialogHeader: () => DialogHeader,
|
|
38
|
+
FormDialog: () => FormDialog,
|
|
39
|
+
default: () => Dialog_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(Dialog_exports);
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
var import_react = __toESM(require("react"));
|
|
44
|
+
var import_framer_motion = require("framer-motion");
|
|
45
|
+
var import_ActionIconButton = __toESM(require("./ActionIconButton"));
|
|
46
|
+
const sizeToMaxW = {
|
|
47
|
+
sm: "max-w-sm",
|
|
48
|
+
md: "max-w-md",
|
|
49
|
+
lg: "max-w-lg",
|
|
50
|
+
xl: "max-w-xl",
|
|
51
|
+
"2xl": "max-w-2xl",
|
|
52
|
+
full: "max-w-[min(96vw,1200px)]"
|
|
53
|
+
};
|
|
54
|
+
function useLockBodyScroll(open) {
|
|
55
|
+
(0, import_react.useEffect)(() => {
|
|
56
|
+
if (!open) return;
|
|
57
|
+
const root = document.documentElement;
|
|
58
|
+
const body = document.body;
|
|
59
|
+
const prevOverflowRoot = root.style.overflow;
|
|
60
|
+
const prevOverflowBody = body.style.overflow;
|
|
61
|
+
const prevPadRightRoot = root.style.paddingRight;
|
|
62
|
+
const prevPadRightBody = body.style.paddingRight;
|
|
63
|
+
const scrollbarW = window.innerWidth - root.clientWidth;
|
|
64
|
+
root.style.overflow = "hidden";
|
|
65
|
+
body.style.overflow = body.style.overflow || "";
|
|
66
|
+
if (scrollbarW > 0) {
|
|
67
|
+
root.style.paddingRight = `${scrollbarW}px`;
|
|
68
|
+
body.style.paddingRight = `${scrollbarW}px`;
|
|
69
|
+
}
|
|
70
|
+
return () => {
|
|
71
|
+
root.style.overflow = prevOverflowRoot;
|
|
72
|
+
body.style.overflow = prevOverflowBody;
|
|
73
|
+
root.style.paddingRight = prevPadRightRoot;
|
|
74
|
+
body.style.paddingRight = prevPadRightBody;
|
|
75
|
+
};
|
|
76
|
+
}, [open]);
|
|
77
|
+
}
|
|
78
|
+
function useEscToClose(open, onClose, disabled) {
|
|
79
|
+
(0, import_react.useEffect)(() => {
|
|
80
|
+
if (!open || disabled) return;
|
|
81
|
+
const onKey = (e) => {
|
|
82
|
+
if (e.key === "Escape") onClose();
|
|
83
|
+
};
|
|
84
|
+
window.addEventListener("keydown", onKey);
|
|
85
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
86
|
+
}, [open, onClose, disabled]);
|
|
87
|
+
}
|
|
88
|
+
function cx(...a) {
|
|
89
|
+
return a.filter(Boolean).join(" ");
|
|
90
|
+
}
|
|
91
|
+
const CloseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", className: "h-4.5 w-4.5", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6L6 18M6 6l12 12" }) });
|
|
92
|
+
function DialogBase({
|
|
93
|
+
open,
|
|
94
|
+
onClose,
|
|
95
|
+
title,
|
|
96
|
+
description,
|
|
97
|
+
dismissibleBackdrop = true,
|
|
98
|
+
showClose = true,
|
|
99
|
+
size = "xl",
|
|
100
|
+
initialFocusRef,
|
|
101
|
+
className,
|
|
102
|
+
disableEscClose = false,
|
|
103
|
+
disableBackdropClose = false,
|
|
104
|
+
children
|
|
105
|
+
}) {
|
|
106
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
107
|
+
const closeBtnRef = (0, import_react.useRef)(null);
|
|
108
|
+
const lastFocusedRef = (0, import_react.useRef)(null);
|
|
109
|
+
useLockBodyScroll(open);
|
|
110
|
+
useEscToClose(open, onClose, disableEscClose);
|
|
111
|
+
(0, import_react.useEffect)(() => {
|
|
112
|
+
var _a, _b, _c;
|
|
113
|
+
if (open) {
|
|
114
|
+
lastFocusedRef.current = document.activeElement;
|
|
115
|
+
const target = (_a = initialFocusRef == null ? void 0 : initialFocusRef.current) != null ? _a : closeBtnRef.current;
|
|
116
|
+
setTimeout(() => target == null ? void 0 : target.focus(), 0);
|
|
117
|
+
} else {
|
|
118
|
+
(_c = (_b = lastFocusedRef.current) == null ? void 0 : _b.focus) == null ? void 0 : _c.call(_b);
|
|
119
|
+
}
|
|
120
|
+
}, [open, initialFocusRef]);
|
|
121
|
+
const handleBackdropMouseDown = (e) => {
|
|
122
|
+
if (disableBackdropClose) return;
|
|
123
|
+
if (!dismissibleBackdrop) return;
|
|
124
|
+
if (e.target === e.currentTarget) onClose();
|
|
125
|
+
};
|
|
126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { children: open && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
128
|
+
import_framer_motion.motion.div,
|
|
129
|
+
{
|
|
130
|
+
className: "fixed inset-0 z-[100] bg-black/45 backdrop-blur-sm",
|
|
131
|
+
initial: { opacity: 0 },
|
|
132
|
+
animate: { opacity: 1 },
|
|
133
|
+
exit: { opacity: 0 }
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
137
|
+
import_framer_motion.motion.div,
|
|
138
|
+
{
|
|
139
|
+
role: "dialog",
|
|
140
|
+
"aria-modal": "true",
|
|
141
|
+
"aria-labelledby": title ? "dialog-title" : void 0,
|
|
142
|
+
"aria-describedby": description ? "dialog-desc" : void 0,
|
|
143
|
+
className: "fixed inset-0 z-[101] grid place-items-center p-4",
|
|
144
|
+
initial: { opacity: 0, scale: 0.98, y: 8 },
|
|
145
|
+
animate: { opacity: 1, scale: 1, y: 0 },
|
|
146
|
+
exit: { opacity: 0, scale: 0.98, y: 8 },
|
|
147
|
+
onMouseDown: handleBackdropMouseDown,
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
ref: containerRef,
|
|
153
|
+
className: cx(
|
|
154
|
+
"w-full overflow-hidden rounded-3xl border border-slate-200 bg-white shadow-xl",
|
|
155
|
+
"dark:border-white/10 dark:bg-[#0e0d0e]",
|
|
156
|
+
"flex max-h-[88vh] flex-col",
|
|
157
|
+
sizeToMaxW[size],
|
|
158
|
+
className
|
|
159
|
+
),
|
|
160
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
161
|
+
children: children != null ? children : null
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
showClose && !children && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "absolute right-5 top-5", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
165
|
+
import_ActionIconButton.default,
|
|
166
|
+
{
|
|
167
|
+
title: "Cerrar",
|
|
168
|
+
size: "lg",
|
|
169
|
+
onClick: onClose,
|
|
170
|
+
ref: closeBtnRef,
|
|
171
|
+
className: "shadow-sm",
|
|
172
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CloseIcon, {})
|
|
173
|
+
}
|
|
174
|
+
) })
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
] }) });
|
|
179
|
+
}
|
|
180
|
+
function DialogHeader({
|
|
181
|
+
title,
|
|
182
|
+
description,
|
|
183
|
+
onClose,
|
|
184
|
+
showClose = true,
|
|
185
|
+
actions,
|
|
186
|
+
compact = false,
|
|
187
|
+
// 👈 nuevo
|
|
188
|
+
className
|
|
189
|
+
}) {
|
|
190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: cx("px-6", compact ? "pt-5 pb-2" : "pt-6 pb-3", className), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-start justify-between gap-3", children: [
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0", children: [
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
193
|
+
"h3",
|
|
194
|
+
{
|
|
195
|
+
id: "dialog-title",
|
|
196
|
+
className: cx("font-semibold tracking-tight", compact ? "text-lg leading-6" : "text-lg leading-6"),
|
|
197
|
+
children: title
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
201
|
+
"p",
|
|
202
|
+
{
|
|
203
|
+
id: "dialog-desc",
|
|
204
|
+
className: cx(compact ? "mt-1" : "mt-2", "text-sm text-slate-600 dark:text-slate-300"),
|
|
205
|
+
children: description
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
210
|
+
actions,
|
|
211
|
+
showClose && onClose && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ActionIconButton.default, { title: "Cerrar", size: "lg", onClick: onClose, className: "shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", className: "h-4.5 w-4.5", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6L6 18M6 6l12 12" }) }) })
|
|
212
|
+
] })
|
|
213
|
+
] }) });
|
|
214
|
+
}
|
|
215
|
+
function DialogBody({ children, padded = true }) {
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: cx("min-h-[60px] flex-1 overflow-auto", padded && "px-6 pb-6 pt-2"), children });
|
|
217
|
+
}
|
|
218
|
+
function DialogFooter({
|
|
219
|
+
children,
|
|
220
|
+
align = "end"
|
|
221
|
+
}) {
|
|
222
|
+
const map = {
|
|
223
|
+
start: "justify-start",
|
|
224
|
+
center: "justify-center",
|
|
225
|
+
end: "justify-end",
|
|
226
|
+
between: "justify-between"
|
|
227
|
+
};
|
|
228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
229
|
+
"div",
|
|
230
|
+
{
|
|
231
|
+
className: cx(
|
|
232
|
+
"sticky bottom-0 z-10 flex items-center gap-2 rounded-b-3xl border-t border-slate-200",
|
|
233
|
+
"bg-white px-6 py-4 text-sm",
|
|
234
|
+
"[box-shadow:inset_0_8px_10px_-8px_rgba(2,6,23,0.10)]",
|
|
235
|
+
"dark:border-white/10 dark:bg-[#0e0d0e] dark:[box-shadow:inset_0_8px_10px_-8px_rgba(255,255,255,0.08)]",
|
|
236
|
+
map[align]
|
|
237
|
+
),
|
|
238
|
+
children
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
function DialogField({
|
|
243
|
+
label,
|
|
244
|
+
hint,
|
|
245
|
+
required,
|
|
246
|
+
children,
|
|
247
|
+
className
|
|
248
|
+
}) {
|
|
249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: cx("grid gap-1 text-sm content-start", className), children: [
|
|
250
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "font-medium", children: [
|
|
251
|
+
label,
|
|
252
|
+
" ",
|
|
253
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-blue-600", children: "*" })
|
|
254
|
+
] }),
|
|
255
|
+
children,
|
|
256
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-slate-500 dark:text-slate-400", children: hint })
|
|
257
|
+
] });
|
|
258
|
+
}
|
|
259
|
+
function FormDialog({
|
|
260
|
+
open,
|
|
261
|
+
onClose,
|
|
262
|
+
title,
|
|
263
|
+
description,
|
|
264
|
+
children,
|
|
265
|
+
onSubmit,
|
|
266
|
+
submitLabel = "Aceptar",
|
|
267
|
+
cancelLabel = "Cerrar",
|
|
268
|
+
submitting = false,
|
|
269
|
+
submitDisabled = false,
|
|
270
|
+
error,
|
|
271
|
+
footerExtra,
|
|
272
|
+
footerAlign = "end",
|
|
273
|
+
...rest
|
|
274
|
+
}) {
|
|
275
|
+
const formId = import_react.default.useId();
|
|
276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogBase, { open, onClose, title, description, ...rest, children: [
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogHeader, { title, description, onClose }),
|
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogBody, { children: [
|
|
279
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-3 rounded-xl border border-blue-200/70 bg-blue-50 px-3 py-2 text-sm text-blue-700 dark:border-blue-500/30 dark:bg-blue-900/20 dark:text-blue-200", children: error }),
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("form", { id: formId, onSubmit, className: "space-y-3", children })
|
|
281
|
+
] }),
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogFooter, { align: footerAlign, children: [
|
|
283
|
+
footerExtra,
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ml-auto flex items-center gap-2", children: [
|
|
285
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
286
|
+
"button",
|
|
287
|
+
{
|
|
288
|
+
type: "button",
|
|
289
|
+
onClick: onClose,
|
|
290
|
+
className: "inline-flex h-10 items-center gap-2 rounded-xl border border-slate-300/80 bg-white px-4 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50 active:scale-95 dark:border-white/10 dark:bg-white/5 dark:text-slate-200 dark:hover:bg-white/10",
|
|
291
|
+
children: cancelLabel
|
|
292
|
+
}
|
|
293
|
+
),
|
|
294
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
295
|
+
"button",
|
|
296
|
+
{
|
|
297
|
+
type: "submit",
|
|
298
|
+
form: formId,
|
|
299
|
+
disabled: submitting || submitDisabled,
|
|
300
|
+
className: "inline-flex h-10 items-center gap-2 rounded-xl bg-slate-900 px-4 text-sm font-medium text-white shadow-sm hover:opacity-90 active:scale-95 disabled:opacity-60 dark:bg-white dark:text-slate-900",
|
|
301
|
+
children: submitting ? "Guardando\u2026" : submitLabel
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
] })
|
|
305
|
+
] })
|
|
306
|
+
] });
|
|
307
|
+
}
|
|
308
|
+
function ConfirmDialog({
|
|
309
|
+
open,
|
|
310
|
+
onClose,
|
|
311
|
+
title,
|
|
312
|
+
headerDescription,
|
|
313
|
+
// <— nuevo
|
|
314
|
+
description,
|
|
315
|
+
// body
|
|
316
|
+
confirmLabel = "Confirmar",
|
|
317
|
+
cancelLabel = "Cancelar",
|
|
318
|
+
danger,
|
|
319
|
+
loading,
|
|
320
|
+
onConfirm,
|
|
321
|
+
autoCloseOnConfirm = true,
|
|
322
|
+
disableEscClose,
|
|
323
|
+
disableBackdropClose
|
|
324
|
+
}) {
|
|
325
|
+
const [internalPending, setInternalPending] = import_react.default.useState(false);
|
|
326
|
+
const pending = loading != null ? loading : internalPending;
|
|
327
|
+
const confirmBtnRef = import_react.default.useRef(null);
|
|
328
|
+
const handleSubmit = async (e) => {
|
|
329
|
+
e == null ? void 0 : e.preventDefault();
|
|
330
|
+
try {
|
|
331
|
+
const result = onConfirm == null ? void 0 : onConfirm();
|
|
332
|
+
if (result && typeof result.then === "function") {
|
|
333
|
+
setInternalPending(true);
|
|
334
|
+
await result;
|
|
335
|
+
}
|
|
336
|
+
if (autoCloseOnConfirm) onClose();
|
|
337
|
+
} finally {
|
|
338
|
+
setInternalPending(false);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
342
|
+
DialogBase,
|
|
343
|
+
{
|
|
344
|
+
open,
|
|
345
|
+
onClose: pending ? () => {
|
|
346
|
+
} : onClose,
|
|
347
|
+
disableEscClose: disableEscClose || pending,
|
|
348
|
+
disableBackdropClose: disableBackdropClose || pending,
|
|
349
|
+
size: "md",
|
|
350
|
+
initialFocusRef: confirmBtnRef,
|
|
351
|
+
title,
|
|
352
|
+
description: headerDescription,
|
|
353
|
+
children: [
|
|
354
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogHeader, { title, onClose: pending ? void 0 : onClose, description: headerDescription }),
|
|
355
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogBody, { padded: true, children: typeof description === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-slate-600 dark:text-slate-300", children: description }) : description != null ? description : null }),
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogFooter, { align: "end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: handleSubmit, className: "ml-auto flex items-center gap-2", children: [
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
358
|
+
"button",
|
|
359
|
+
{
|
|
360
|
+
type: "button",
|
|
361
|
+
onClick: onClose,
|
|
362
|
+
disabled: pending,
|
|
363
|
+
className: "inline-flex h-10 items-center gap-2 rounded-xl border border-slate-300/80 bg-white px-4 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50 active:scale-95 disabled:opacity-60 dark:border-white/10 dark:bg-white/5 dark:text-slate-200 dark:hover:bg-white/10",
|
|
364
|
+
children: cancelLabel
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
368
|
+
"button",
|
|
369
|
+
{
|
|
370
|
+
ref: confirmBtnRef,
|
|
371
|
+
type: "submit",
|
|
372
|
+
disabled: pending,
|
|
373
|
+
className: [
|
|
374
|
+
"inline-flex h-10 items-center gap-2 rounded-xl px-4 text-sm font-semibold text-white shadow-sm active:scale-95 disabled:opacity-60",
|
|
375
|
+
danger ? "bg-blue-600 hover:bg-blue-700 focus-visible:ring-2 focus-visible:ring-blue-300" : "bg-slate-900 hover:opacity-90 focus-visible:ring-2 focus-visible:ring-slate-300 dark:bg-white dark:text-slate-900"
|
|
376
|
+
].join(" "),
|
|
377
|
+
children: [
|
|
378
|
+
pending && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { className: "h-4 w-4 animate-spin", viewBox: "0 0 24 24", fill: "none", children: [
|
|
379
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
380
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { className: "opacity-75", d: "M4 12a8 8 0 018-8", stroke: "currentColor", strokeWidth: "4", strokeLinecap: "round" })
|
|
381
|
+
] }),
|
|
382
|
+
confirmLabel
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
)
|
|
386
|
+
] }) })
|
|
387
|
+
]
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
const Dialog = Object.assign(DialogBase, {
|
|
392
|
+
Header: DialogHeader,
|
|
393
|
+
Body: DialogBody,
|
|
394
|
+
Footer: DialogFooter,
|
|
395
|
+
Field: DialogField,
|
|
396
|
+
Confirm: ConfirmDialog
|
|
397
|
+
});
|
|
398
|
+
var Dialog_default = Dialog;
|
|
399
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
400
|
+
0 && (module.exports = {
|
|
401
|
+
ConfirmDialog,
|
|
402
|
+
Dialog,
|
|
403
|
+
DialogBody,
|
|
404
|
+
DialogField,
|
|
405
|
+
DialogFooter,
|
|
406
|
+
DialogHeader,
|
|
407
|
+
FormDialog
|
|
408
|
+
});
|