framepexls-ui-lib 0.1.30 → 0.1.31
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/Checkbox.d.mts +1 -1
- package/dist/Checkbox.d.ts +1 -1
- package/dist/Dialog.js +96 -56
- package/dist/Dialog.mjs +97 -57
- package/package.json +1 -1
package/dist/Checkbox.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ type CheckboxProps = Omit<React__default.InputHTMLAttributes<HTMLInputElement>,
|
|
|
11
11
|
className?: string;
|
|
12
12
|
inputClassName?: string;
|
|
13
13
|
};
|
|
14
|
-
declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "
|
|
14
|
+
declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
|
|
15
15
|
label?: React__default.ReactNode;
|
|
16
16
|
description?: React__default.ReactNode;
|
|
17
17
|
error?: boolean;
|
package/dist/Checkbox.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ type CheckboxProps = Omit<React__default.InputHTMLAttributes<HTMLInputElement>,
|
|
|
11
11
|
className?: string;
|
|
12
12
|
inputClassName?: string;
|
|
13
13
|
};
|
|
14
|
-
declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "
|
|
14
|
+
declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<React__default.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
|
|
15
15
|
label?: React__default.ReactNode;
|
|
16
16
|
description?: React__default.ReactNode;
|
|
17
17
|
error?: boolean;
|
package/dist/Dialog.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(Dialog_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(Dialog_exports);
|
|
42
42
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
43
|
var import_react = __toESM(require("react"));
|
|
44
|
+
var import_react_dom = require("react-dom");
|
|
44
45
|
var import_framer_motion = require("framer-motion");
|
|
45
46
|
var import_ActionIconButton = __toESM(require("./ActionIconButton"));
|
|
46
47
|
var import_Button = __toESM(require("./Button"));
|
|
@@ -55,6 +56,26 @@ const sizeToMaxW = {
|
|
|
55
56
|
"5xl": "max-w-5xl",
|
|
56
57
|
full: "max-w-[min(96vw,1200px)]"
|
|
57
58
|
};
|
|
59
|
+
const zManager = /* @__PURE__ */ (() => {
|
|
60
|
+
const stack = [];
|
|
61
|
+
const BASE = 1e3;
|
|
62
|
+
const STEP = 10;
|
|
63
|
+
return {
|
|
64
|
+
acquire() {
|
|
65
|
+
const z = BASE + stack.length * STEP;
|
|
66
|
+
stack.push(z);
|
|
67
|
+
return z;
|
|
68
|
+
},
|
|
69
|
+
release(z) {
|
|
70
|
+
const i = stack.indexOf(z);
|
|
71
|
+
if (i !== -1) stack.splice(i, 1);
|
|
72
|
+
},
|
|
73
|
+
isTop(z) {
|
|
74
|
+
if (z == null) return false;
|
|
75
|
+
return stack.length > 0 && stack[stack.length - 1] === z;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
})();
|
|
58
79
|
function useLockBodyScroll(open) {
|
|
59
80
|
(0, import_react.useEffect)(() => {
|
|
60
81
|
if (!open) return;
|
|
@@ -79,15 +100,16 @@ function useLockBodyScroll(open) {
|
|
|
79
100
|
};
|
|
80
101
|
}, [open]);
|
|
81
102
|
}
|
|
82
|
-
function useEscToClose(open, onClose, disabled) {
|
|
103
|
+
function useEscToClose(open, onClose, disabled, onlyIfTop) {
|
|
83
104
|
(0, import_react.useEffect)(() => {
|
|
84
105
|
if (!open || disabled) return;
|
|
106
|
+
if (onlyIfTop && !onlyIfTop()) return;
|
|
85
107
|
const onKey = (e) => {
|
|
86
108
|
if (e.key === "Escape") onClose();
|
|
87
109
|
};
|
|
88
110
|
window.addEventListener("keydown", onKey);
|
|
89
111
|
return () => window.removeEventListener("keydown", onKey);
|
|
90
|
-
}, [open, onClose, disabled]);
|
|
112
|
+
}, [open, onClose, disabled, onlyIfTop == null ? void 0 : onlyIfTop()]);
|
|
91
113
|
}
|
|
92
114
|
function cx(...a) {
|
|
93
115
|
return a.filter(Boolean).join(" ");
|
|
@@ -110,8 +132,21 @@ function DialogBase({
|
|
|
110
132
|
const containerRef = (0, import_react.useRef)(null);
|
|
111
133
|
const closeBtnRef = (0, import_react.useRef)(null);
|
|
112
134
|
const lastFocusedRef = (0, import_react.useRef)(null);
|
|
135
|
+
const [zIndexBase, setZIndexBase] = (0, import_react.useState)(null);
|
|
113
136
|
useLockBodyScroll(open);
|
|
114
|
-
useEscToClose(open, onClose, disableEscClose);
|
|
137
|
+
useEscToClose(open, onClose, disableEscClose, () => zManager.isTop(zIndexBase));
|
|
138
|
+
(0, import_react.useEffect)(() => {
|
|
139
|
+
if (open) {
|
|
140
|
+
const z = zManager.acquire();
|
|
141
|
+
setZIndexBase(z);
|
|
142
|
+
return () => {
|
|
143
|
+
zManager.release(z);
|
|
144
|
+
setZIndexBase(null);
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
setZIndexBase(null);
|
|
148
|
+
}
|
|
149
|
+
}, [open]);
|
|
115
150
|
(0, import_react.useEffect)(() => {
|
|
116
151
|
var _a, _b, _c;
|
|
117
152
|
if (open) {
|
|
@@ -127,59 +162,64 @@ function DialogBase({
|
|
|
127
162
|
if (!dismissibleBackdrop) return;
|
|
128
163
|
if (e.target === e.currentTarget) onClose();
|
|
129
164
|
};
|
|
130
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { children: open &&
|
|
131
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { children: open && typeof document !== "undefined" && zIndexBase !== null && (0, import_react_dom.createPortal)(
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
|
+
import_framer_motion.motion.div,
|
|
169
|
+
{
|
|
170
|
+
className: "fixed inset-0 bg-black/45 backdrop-blur-sm",
|
|
171
|
+
style: { zIndex: zIndexBase },
|
|
172
|
+
initial: { opacity: 0 },
|
|
173
|
+
animate: { opacity: 1 },
|
|
174
|
+
exit: { opacity: 0 }
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
178
|
+
import_framer_motion.motion.div,
|
|
179
|
+
{
|
|
180
|
+
role: "dialog",
|
|
181
|
+
"aria-modal": "true",
|
|
182
|
+
"aria-labelledby": title ? "dialog-title" : void 0,
|
|
183
|
+
"aria-describedby": description ? "dialog-desc" : void 0,
|
|
184
|
+
className: "fixed inset-0 grid place-items-center p-4",
|
|
185
|
+
style: { zIndex: zIndexBase + 1 },
|
|
186
|
+
initial: { opacity: 0, scale: 0.98, y: 8 },
|
|
187
|
+
animate: { opacity: 1, scale: 1, y: 0 },
|
|
188
|
+
exit: { opacity: 0, scale: 0.98, y: 8 },
|
|
189
|
+
onMouseDown: handleBackdropMouseDown,
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
ref: containerRef,
|
|
195
|
+
className: cx(
|
|
196
|
+
"w-full overflow-hidden rounded-3xl border border-slate-200 bg-white shadow-xl",
|
|
197
|
+
"dark:border-white/10 dark:bg-[#0b0a0a]",
|
|
198
|
+
"flex max-h-[88vh] flex-col",
|
|
199
|
+
sizeToMaxW[size],
|
|
200
|
+
className
|
|
201
|
+
),
|
|
202
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
203
|
+
children: children != null ? children : null
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
showClose && !children && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "absolute right-5 top-5", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
207
|
+
import_ActionIconButton.default,
|
|
208
|
+
{
|
|
209
|
+
title: "Cerrar",
|
|
210
|
+
size: "lg",
|
|
211
|
+
onClick: onClose,
|
|
212
|
+
ref: closeBtnRef,
|
|
213
|
+
className: "shadow-sm",
|
|
214
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CloseIcon, {})
|
|
215
|
+
}
|
|
216
|
+
) })
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
] }),
|
|
221
|
+
document.body
|
|
222
|
+
) });
|
|
183
223
|
}
|
|
184
224
|
function DialogHeader({
|
|
185
225
|
title,
|
package/dist/Dialog.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import React, { useEffect, useRef } from "react";
|
|
3
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
4
5
|
import { motion, AnimatePresence } from "framer-motion";
|
|
5
6
|
import ActionIconButton from "./ActionIconButton";
|
|
6
7
|
import Button from "./Button";
|
|
@@ -15,6 +16,26 @@ const sizeToMaxW = {
|
|
|
15
16
|
"5xl": "max-w-5xl",
|
|
16
17
|
full: "max-w-[min(96vw,1200px)]"
|
|
17
18
|
};
|
|
19
|
+
const zManager = /* @__PURE__ */ (() => {
|
|
20
|
+
const stack = [];
|
|
21
|
+
const BASE = 1e3;
|
|
22
|
+
const STEP = 10;
|
|
23
|
+
return {
|
|
24
|
+
acquire() {
|
|
25
|
+
const z = BASE + stack.length * STEP;
|
|
26
|
+
stack.push(z);
|
|
27
|
+
return z;
|
|
28
|
+
},
|
|
29
|
+
release(z) {
|
|
30
|
+
const i = stack.indexOf(z);
|
|
31
|
+
if (i !== -1) stack.splice(i, 1);
|
|
32
|
+
},
|
|
33
|
+
isTop(z) {
|
|
34
|
+
if (z == null) return false;
|
|
35
|
+
return stack.length > 0 && stack[stack.length - 1] === z;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
18
39
|
function useLockBodyScroll(open) {
|
|
19
40
|
useEffect(() => {
|
|
20
41
|
if (!open) return;
|
|
@@ -39,15 +60,16 @@ function useLockBodyScroll(open) {
|
|
|
39
60
|
};
|
|
40
61
|
}, [open]);
|
|
41
62
|
}
|
|
42
|
-
function useEscToClose(open, onClose, disabled) {
|
|
63
|
+
function useEscToClose(open, onClose, disabled, onlyIfTop) {
|
|
43
64
|
useEffect(() => {
|
|
44
65
|
if (!open || disabled) return;
|
|
66
|
+
if (onlyIfTop && !onlyIfTop()) return;
|
|
45
67
|
const onKey = (e) => {
|
|
46
68
|
if (e.key === "Escape") onClose();
|
|
47
69
|
};
|
|
48
70
|
window.addEventListener("keydown", onKey);
|
|
49
71
|
return () => window.removeEventListener("keydown", onKey);
|
|
50
|
-
}, [open, onClose, disabled]);
|
|
72
|
+
}, [open, onClose, disabled, onlyIfTop == null ? void 0 : onlyIfTop()]);
|
|
51
73
|
}
|
|
52
74
|
function cx(...a) {
|
|
53
75
|
return a.filter(Boolean).join(" ");
|
|
@@ -70,8 +92,21 @@ function DialogBase({
|
|
|
70
92
|
const containerRef = useRef(null);
|
|
71
93
|
const closeBtnRef = useRef(null);
|
|
72
94
|
const lastFocusedRef = useRef(null);
|
|
95
|
+
const [zIndexBase, setZIndexBase] = useState(null);
|
|
73
96
|
useLockBodyScroll(open);
|
|
74
|
-
useEscToClose(open, onClose, disableEscClose);
|
|
97
|
+
useEscToClose(open, onClose, disableEscClose, () => zManager.isTop(zIndexBase));
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (open) {
|
|
100
|
+
const z = zManager.acquire();
|
|
101
|
+
setZIndexBase(z);
|
|
102
|
+
return () => {
|
|
103
|
+
zManager.release(z);
|
|
104
|
+
setZIndexBase(null);
|
|
105
|
+
};
|
|
106
|
+
} else {
|
|
107
|
+
setZIndexBase(null);
|
|
108
|
+
}
|
|
109
|
+
}, [open]);
|
|
75
110
|
useEffect(() => {
|
|
76
111
|
var _a, _b, _c;
|
|
77
112
|
if (open) {
|
|
@@ -87,59 +122,64 @@ function DialogBase({
|
|
|
87
122
|
if (!dismissibleBackdrop) return;
|
|
88
123
|
if (e.target === e.currentTarget) onClose();
|
|
89
124
|
};
|
|
90
|
-
return /* @__PURE__ */ jsx(AnimatePresence, { children: open &&
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: open && typeof document !== "undefined" && zIndexBase !== null && createPortal(
|
|
126
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
127
|
+
/* @__PURE__ */ jsx(
|
|
128
|
+
motion.div,
|
|
129
|
+
{
|
|
130
|
+
className: "fixed inset-0 bg-black/45 backdrop-blur-sm",
|
|
131
|
+
style: { zIndex: zIndexBase },
|
|
132
|
+
initial: { opacity: 0 },
|
|
133
|
+
animate: { opacity: 1 },
|
|
134
|
+
exit: { opacity: 0 }
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ jsxs(
|
|
138
|
+
motion.div,
|
|
139
|
+
{
|
|
140
|
+
role: "dialog",
|
|
141
|
+
"aria-modal": "true",
|
|
142
|
+
"aria-labelledby": title ? "dialog-title" : void 0,
|
|
143
|
+
"aria-describedby": description ? "dialog-desc" : void 0,
|
|
144
|
+
className: "fixed inset-0 grid place-items-center p-4",
|
|
145
|
+
style: { zIndex: zIndexBase + 1 },
|
|
146
|
+
initial: { opacity: 0, scale: 0.98, y: 8 },
|
|
147
|
+
animate: { opacity: 1, scale: 1, y: 0 },
|
|
148
|
+
exit: { opacity: 0, scale: 0.98, y: 8 },
|
|
149
|
+
onMouseDown: handleBackdropMouseDown,
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ jsx(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
ref: containerRef,
|
|
155
|
+
className: cx(
|
|
156
|
+
"w-full overflow-hidden rounded-3xl border border-slate-200 bg-white shadow-xl",
|
|
157
|
+
"dark:border-white/10 dark:bg-[#0b0a0a]",
|
|
158
|
+
"flex max-h-[88vh] flex-col",
|
|
159
|
+
sizeToMaxW[size],
|
|
160
|
+
className
|
|
161
|
+
),
|
|
162
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
163
|
+
children: children != null ? children : null
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
showClose && !children && /* @__PURE__ */ jsx("div", { className: "absolute right-5 top-5", children: /* @__PURE__ */ jsx(
|
|
167
|
+
ActionIconButton,
|
|
168
|
+
{
|
|
169
|
+
title: "Cerrar",
|
|
170
|
+
size: "lg",
|
|
171
|
+
onClick: onClose,
|
|
172
|
+
ref: closeBtnRef,
|
|
173
|
+
className: "shadow-sm",
|
|
174
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
175
|
+
}
|
|
176
|
+
) })
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }),
|
|
181
|
+
document.body
|
|
182
|
+
) });
|
|
143
183
|
}
|
|
144
184
|
function DialogHeader({
|
|
145
185
|
title,
|