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/Dropdown.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var Dropdown_exports = {};
|
|
21
|
+
__export(Dropdown_exports, {
|
|
22
|
+
Content: () => Content,
|
|
23
|
+
Dropdown: () => Dropdown,
|
|
24
|
+
Item: () => Item,
|
|
25
|
+
Label: () => Label,
|
|
26
|
+
Separator: () => Separator,
|
|
27
|
+
Trigger: () => Trigger,
|
|
28
|
+
default: () => Dropdown_default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(Dropdown_exports);
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_react_dom = require("react-dom");
|
|
34
|
+
var import_iconos = require("./iconos/index");
|
|
35
|
+
const DropdownCtx = (0, import_react.createContext)(null);
|
|
36
|
+
const useDropdown = () => {
|
|
37
|
+
const ctx = (0, import_react.useContext)(DropdownCtx);
|
|
38
|
+
if (!ctx) throw new Error("Dropdown.* debe usarse dentro de <Dropdown>");
|
|
39
|
+
return ctx;
|
|
40
|
+
};
|
|
41
|
+
function Dropdown({
|
|
42
|
+
children,
|
|
43
|
+
align = "end",
|
|
44
|
+
onOpenChange,
|
|
45
|
+
permissions,
|
|
46
|
+
hasPermission,
|
|
47
|
+
permStrategy = "all",
|
|
48
|
+
defaultHideUnauthorized = true,
|
|
49
|
+
defaultDisableUnauthorized = true
|
|
50
|
+
}) {
|
|
51
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
52
|
+
const triggerRef = (0, import_react.useRef)(null);
|
|
53
|
+
const menuRef = (0, import_react.useRef)(null);
|
|
54
|
+
const menuId = (0, import_react.useId)();
|
|
55
|
+
const labelId = (0, import_react.useId)();
|
|
56
|
+
(0, import_react.useEffect)(() => {
|
|
57
|
+
if (!open) return;
|
|
58
|
+
const onDown = (e) => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const t = e.target;
|
|
61
|
+
if ((_a = triggerRef.current) == null ? void 0 : _a.contains(t)) return;
|
|
62
|
+
if ((_b = menuRef.current) == null ? void 0 : _b.contains(t)) return;
|
|
63
|
+
setOpen(false);
|
|
64
|
+
};
|
|
65
|
+
const onScrollOrBlur = () => setOpen(false);
|
|
66
|
+
window.addEventListener("mousedown", onDown, true);
|
|
67
|
+
window.addEventListener("blur", onScrollOrBlur);
|
|
68
|
+
window.addEventListener("scroll", onScrollOrBlur, true);
|
|
69
|
+
return () => {
|
|
70
|
+
window.removeEventListener("mousedown", onDown, true);
|
|
71
|
+
window.removeEventListener("blur", onScrollOrBlur);
|
|
72
|
+
window.removeEventListener("scroll", onScrollOrBlur, true);
|
|
73
|
+
};
|
|
74
|
+
}, [open]);
|
|
75
|
+
(0, import_react.useEffect)(() => {
|
|
76
|
+
onOpenChange == null ? void 0 : onOpenChange(open);
|
|
77
|
+
}, [open, onOpenChange]);
|
|
78
|
+
const permSet = (0, import_react.useMemo)(() => {
|
|
79
|
+
if (!permissions) return void 0;
|
|
80
|
+
if (permissions instanceof Set) return permissions;
|
|
81
|
+
try {
|
|
82
|
+
return new Set(Array.from(permissions).map(String));
|
|
83
|
+
} catch {
|
|
84
|
+
return void 0;
|
|
85
|
+
}
|
|
86
|
+
}, [permissions]);
|
|
87
|
+
const isAllowed = (0, import_react.useCallback)((require2) => {
|
|
88
|
+
if (!require2) return true;
|
|
89
|
+
const needs = Array.isArray(require2) ? require2 : [require2];
|
|
90
|
+
if (hasPermission) {
|
|
91
|
+
return permStrategy === "all" ? needs.every((p) => hasPermission(p)) : needs.some((p) => hasPermission(p));
|
|
92
|
+
}
|
|
93
|
+
if (permSet) {
|
|
94
|
+
return permStrategy === "all" ? needs.every((p) => permSet.has(String(p))) : needs.some((p) => permSet.has(String(p)));
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}, [hasPermission, permSet, permStrategy]);
|
|
98
|
+
const value = (0, import_react.useMemo)(
|
|
99
|
+
() => ({
|
|
100
|
+
open,
|
|
101
|
+
setOpen,
|
|
102
|
+
triggerRef,
|
|
103
|
+
menuRef,
|
|
104
|
+
menuId,
|
|
105
|
+
labelId,
|
|
106
|
+
align,
|
|
107
|
+
isAllowed,
|
|
108
|
+
defaultHideUnauthorized,
|
|
109
|
+
defaultDisableUnauthorized
|
|
110
|
+
}),
|
|
111
|
+
[open, align, isAllowed, defaultHideUnauthorized, defaultDisableUnauthorized]
|
|
112
|
+
);
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownCtx.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative inline-block text-left", children }) });
|
|
114
|
+
}
|
|
115
|
+
function Trigger({
|
|
116
|
+
children,
|
|
117
|
+
className = "",
|
|
118
|
+
...btnProps
|
|
119
|
+
}) {
|
|
120
|
+
const { open, setOpen, triggerRef, menuId } = useDropdown();
|
|
121
|
+
const onClick = (0, import_react.useCallback)(() => setOpen(!open), [open, setOpen]);
|
|
122
|
+
const onKeyDown = (e) => {
|
|
123
|
+
if (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
setOpen(true);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
129
|
+
"button",
|
|
130
|
+
{
|
|
131
|
+
ref: triggerRef,
|
|
132
|
+
"aria-haspopup": "menu",
|
|
133
|
+
"aria-controls": menuId,
|
|
134
|
+
"aria-expanded": open,
|
|
135
|
+
onClick,
|
|
136
|
+
onKeyDown,
|
|
137
|
+
className: [
|
|
138
|
+
"inline-flex items-center gap-2 rounded-xl border border-slate-300/70 bg-white px-3 py-2",
|
|
139
|
+
"text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50 active:scale-[0.98]",
|
|
140
|
+
"dark:border-white/10 dark:bg-white/5 dark:text-slate-200 dark:hover:bg-white/10",
|
|
141
|
+
className
|
|
142
|
+
].join(" "),
|
|
143
|
+
...btnProps,
|
|
144
|
+
children
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
function Content({
|
|
149
|
+
children,
|
|
150
|
+
className = "",
|
|
151
|
+
maxHeight = 360
|
|
152
|
+
}) {
|
|
153
|
+
const { open, setOpen, triggerRef, menuRef, menuId, labelId, align } = useDropdown();
|
|
154
|
+
const [pos, setPos] = (0, import_react.useState)({ top: 0, left: 0, origin: "top-left", maxH: maxHeight });
|
|
155
|
+
const computePosition = (0, import_react.useCallback)(() => {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
const t = triggerRef.current;
|
|
158
|
+
if (!t) return;
|
|
159
|
+
const r = t.getBoundingClientRect();
|
|
160
|
+
const vw = window.innerWidth;
|
|
161
|
+
const vh = window.innerHeight;
|
|
162
|
+
const gap = 8;
|
|
163
|
+
const measuredW = (_b = (_a = menuRef.current) == null ? void 0 : _a.offsetWidth) != null ? _b : 0;
|
|
164
|
+
const estW = Math.max(220, r.width);
|
|
165
|
+
const w = measuredW || estW;
|
|
166
|
+
let left = align === "end" ? r.right - w : r.left;
|
|
167
|
+
left = Math.min(Math.max(left, 8), vw - w - 8);
|
|
168
|
+
const availableDown = vh - (r.bottom + gap) - 8;
|
|
169
|
+
const maxH = Math.max(160, Math.min(maxHeight, availableDown));
|
|
170
|
+
const origin = align === "end" ? "top-right" : "top-left";
|
|
171
|
+
setPos({ top: r.bottom + gap, left: Math.round(left), origin, maxH });
|
|
172
|
+
}, [align, triggerRef, menuRef, maxHeight]);
|
|
173
|
+
(0, import_react.useEffect)(() => {
|
|
174
|
+
if (!open) return;
|
|
175
|
+
computePosition();
|
|
176
|
+
const id = setTimeout(computePosition, 0);
|
|
177
|
+
const onScroll = () => computePosition();
|
|
178
|
+
const onResize = () => computePosition();
|
|
179
|
+
window.addEventListener("scroll", onScroll, true);
|
|
180
|
+
window.addEventListener("resize", onResize);
|
|
181
|
+
const ro = menuRef.current ? new ResizeObserver(() => computePosition()) : null;
|
|
182
|
+
if (menuRef.current && ro) ro.observe(menuRef.current);
|
|
183
|
+
return () => {
|
|
184
|
+
clearTimeout(id);
|
|
185
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
186
|
+
window.removeEventListener("resize", onResize);
|
|
187
|
+
ro == null ? void 0 : ro.disconnect();
|
|
188
|
+
};
|
|
189
|
+
}, [open, computePosition]);
|
|
190
|
+
const onKeyDown = (e) => {
|
|
191
|
+
var _a, _b, _c, _d, _e;
|
|
192
|
+
const items = Array.from(
|
|
193
|
+
(_b = (_a = menuRef.current) == null ? void 0 : _a.querySelectorAll('[role="menuitem"]')) != null ? _b : []
|
|
194
|
+
).filter((el) => el.getAttribute("data-disabled") !== "true");
|
|
195
|
+
const i = items.findIndex((el) => el === document.activeElement);
|
|
196
|
+
if (e.key === "Escape") {
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
setOpen(false);
|
|
199
|
+
(_c = triggerRef.current) == null ? void 0 : _c.focus();
|
|
200
|
+
} else if (e.key === "ArrowDown") {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
(_d = items[(i + 1 + items.length) % items.length]) == null ? void 0 : _d.focus();
|
|
203
|
+
} else if (e.key === "ArrowUp") {
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
(_e = items[(i - 1 + items.length) % items.length]) == null ? void 0 : _e.focus();
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
if (!open) return null;
|
|
209
|
+
return (0, import_react_dom.createPortal)(
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
role: "menu",
|
|
214
|
+
id: menuId,
|
|
215
|
+
"aria-labelledby": labelId,
|
|
216
|
+
ref: menuRef,
|
|
217
|
+
onKeyDown,
|
|
218
|
+
style: {
|
|
219
|
+
position: "fixed",
|
|
220
|
+
top: pos.top,
|
|
221
|
+
left: pos.left,
|
|
222
|
+
maxHeight: pos.maxH,
|
|
223
|
+
maxWidth: "calc(100vw - 16px)"
|
|
224
|
+
},
|
|
225
|
+
className: [
|
|
226
|
+
"z-[9999] overflow-auto rounded-2xl border border-slate-200/80 bg-white p-1.5 shadow-xl",
|
|
227
|
+
"data-[open=false]:pointer-events-none data-[open=false]:opacity-0 data-[open=false]:scale-95",
|
|
228
|
+
"data-[open=true]:opacity-100 data-[open=true]:scale-100 transition",
|
|
229
|
+
pos.origin === "top-right" ? "origin-top-right" : "origin-top-left",
|
|
230
|
+
"dark:border-white/10 dark:bg-[#0f0d0e]",
|
|
231
|
+
className
|
|
232
|
+
].join(" "),
|
|
233
|
+
"data-open": "true",
|
|
234
|
+
children
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
document.body
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
function Label({ children }) {
|
|
241
|
+
const { labelId } = useDropdown();
|
|
242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
243
|
+
"div",
|
|
244
|
+
{
|
|
245
|
+
id: labelId,
|
|
246
|
+
className: "px-2.5 py-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",
|
|
247
|
+
children
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
function Separator({ className = "" }) {
|
|
252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
253
|
+
"div",
|
|
254
|
+
{
|
|
255
|
+
role: "separator",
|
|
256
|
+
className: ["my-1 h-px bg-slate-200/80 dark:bg-white/10", className].join(" ")
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
function Item({
|
|
261
|
+
children,
|
|
262
|
+
icon,
|
|
263
|
+
kbd,
|
|
264
|
+
danger,
|
|
265
|
+
disabled,
|
|
266
|
+
require: require2,
|
|
267
|
+
hideIfUnauthorized,
|
|
268
|
+
disableIfUnauthorized,
|
|
269
|
+
onSelect,
|
|
270
|
+
className = "",
|
|
271
|
+
...rest
|
|
272
|
+
}) {
|
|
273
|
+
const { setOpen, isAllowed, defaultHideUnauthorized, defaultDisableUnauthorized } = useDropdown();
|
|
274
|
+
const allowed = isAllowed ? isAllowed(require2) : true;
|
|
275
|
+
const shouldHide = (hideIfUnauthorized != null ? hideIfUnauthorized : defaultHideUnauthorized) && !allowed;
|
|
276
|
+
const shouldDisable = !shouldHide && (disableIfUnauthorized != null ? disableIfUnauthorized : defaultDisableUnauthorized) && !allowed;
|
|
277
|
+
if (shouldHide) return null;
|
|
278
|
+
const onClick = (e) => {
|
|
279
|
+
e.preventDefault();
|
|
280
|
+
if (disabled || shouldDisable) return;
|
|
281
|
+
onSelect == null ? void 0 : onSelect();
|
|
282
|
+
setOpen(false);
|
|
283
|
+
};
|
|
284
|
+
const onKeyDown = (e) => {
|
|
285
|
+
if (disabled || shouldDisable) return;
|
|
286
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
287
|
+
e.preventDefault();
|
|
288
|
+
onSelect == null ? void 0 : onSelect();
|
|
289
|
+
setOpen(false);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
293
|
+
"button",
|
|
294
|
+
{
|
|
295
|
+
role: "menuitem",
|
|
296
|
+
"data-disabled": disabled || shouldDisable ? "true" : "false",
|
|
297
|
+
disabled: disabled || shouldDisable,
|
|
298
|
+
onClick,
|
|
299
|
+
onKeyDown,
|
|
300
|
+
className: [
|
|
301
|
+
"group flex w-full items-center justify-between gap-3 rounded-xl px-2.5 py-2 text-left text-sm",
|
|
302
|
+
disabled || shouldDisable ? "text-slate-400 dark:text-slate-500 cursor-not-allowed" : danger ? "text-blue-600 hover:bg-blue-50 dark:text-blue-400 dark:hover:bg-blue-500/10" : "text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-white/10",
|
|
303
|
+
className
|
|
304
|
+
].join(" "),
|
|
305
|
+
...rest,
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
308
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "shrink-0 flex items-center justify-center h-4 w-4 text-slate-500 dark:text-slate-400", children: icon }),
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "truncate leading-none", children })
|
|
310
|
+
] }),
|
|
311
|
+
kbd && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "shrink-0 rounded-md border border-slate-200/80 bg-white px-1.5 py-0.5 text-[11px] text-slate-500 dark:border-white/10 dark:bg-white/5 dark:text-slate-400", children: kbd })
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
const DropdownExport = Object.assign(Dropdown, {
|
|
317
|
+
Trigger,
|
|
318
|
+
Content,
|
|
319
|
+
Label,
|
|
320
|
+
Separator,
|
|
321
|
+
Item,
|
|
322
|
+
MenuPuntosVerticalIcon: import_iconos.MenuPuntosVerticalIcon
|
|
323
|
+
});
|
|
324
|
+
var Dropdown_default = DropdownExport;
|
|
325
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
326
|
+
0 && (module.exports = {
|
|
327
|
+
Content,
|
|
328
|
+
Dropdown,
|
|
329
|
+
Item,
|
|
330
|
+
Label,
|
|
331
|
+
Separator,
|
|
332
|
+
Trigger
|
|
333
|
+
});
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useId,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState
|
|
12
|
+
} from "react";
|
|
13
|
+
import { createPortal } from "react-dom";
|
|
14
|
+
import { MenuPuntosVerticalIcon } from "./iconos/index";
|
|
15
|
+
const DropdownCtx = createContext(null);
|
|
16
|
+
const useDropdown = () => {
|
|
17
|
+
const ctx = useContext(DropdownCtx);
|
|
18
|
+
if (!ctx) throw new Error("Dropdown.* debe usarse dentro de <Dropdown>");
|
|
19
|
+
return ctx;
|
|
20
|
+
};
|
|
21
|
+
function Dropdown({
|
|
22
|
+
children,
|
|
23
|
+
align = "end",
|
|
24
|
+
onOpenChange,
|
|
25
|
+
permissions,
|
|
26
|
+
hasPermission,
|
|
27
|
+
permStrategy = "all",
|
|
28
|
+
defaultHideUnauthorized = true,
|
|
29
|
+
defaultDisableUnauthorized = true
|
|
30
|
+
}) {
|
|
31
|
+
const [open, setOpen] = useState(false);
|
|
32
|
+
const triggerRef = useRef(null);
|
|
33
|
+
const menuRef = useRef(null);
|
|
34
|
+
const menuId = useId();
|
|
35
|
+
const labelId = useId();
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!open) return;
|
|
38
|
+
const onDown = (e) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const t = e.target;
|
|
41
|
+
if ((_a = triggerRef.current) == null ? void 0 : _a.contains(t)) return;
|
|
42
|
+
if ((_b = menuRef.current) == null ? void 0 : _b.contains(t)) return;
|
|
43
|
+
setOpen(false);
|
|
44
|
+
};
|
|
45
|
+
const onScrollOrBlur = () => setOpen(false);
|
|
46
|
+
window.addEventListener("mousedown", onDown, true);
|
|
47
|
+
window.addEventListener("blur", onScrollOrBlur);
|
|
48
|
+
window.addEventListener("scroll", onScrollOrBlur, true);
|
|
49
|
+
return () => {
|
|
50
|
+
window.removeEventListener("mousedown", onDown, true);
|
|
51
|
+
window.removeEventListener("blur", onScrollOrBlur);
|
|
52
|
+
window.removeEventListener("scroll", onScrollOrBlur, true);
|
|
53
|
+
};
|
|
54
|
+
}, [open]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
onOpenChange == null ? void 0 : onOpenChange(open);
|
|
57
|
+
}, [open, onOpenChange]);
|
|
58
|
+
const permSet = useMemo(() => {
|
|
59
|
+
if (!permissions) return void 0;
|
|
60
|
+
if (permissions instanceof Set) return permissions;
|
|
61
|
+
try {
|
|
62
|
+
return new Set(Array.from(permissions).map(String));
|
|
63
|
+
} catch {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
}, [permissions]);
|
|
67
|
+
const isAllowed = useCallback((require2) => {
|
|
68
|
+
if (!require2) return true;
|
|
69
|
+
const needs = Array.isArray(require2) ? require2 : [require2];
|
|
70
|
+
if (hasPermission) {
|
|
71
|
+
return permStrategy === "all" ? needs.every((p) => hasPermission(p)) : needs.some((p) => hasPermission(p));
|
|
72
|
+
}
|
|
73
|
+
if (permSet) {
|
|
74
|
+
return permStrategy === "all" ? needs.every((p) => permSet.has(String(p))) : needs.some((p) => permSet.has(String(p)));
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}, [hasPermission, permSet, permStrategy]);
|
|
78
|
+
const value = useMemo(
|
|
79
|
+
() => ({
|
|
80
|
+
open,
|
|
81
|
+
setOpen,
|
|
82
|
+
triggerRef,
|
|
83
|
+
menuRef,
|
|
84
|
+
menuId,
|
|
85
|
+
labelId,
|
|
86
|
+
align,
|
|
87
|
+
isAllowed,
|
|
88
|
+
defaultHideUnauthorized,
|
|
89
|
+
defaultDisableUnauthorized
|
|
90
|
+
}),
|
|
91
|
+
[open, align, isAllowed, defaultHideUnauthorized, defaultDisableUnauthorized]
|
|
92
|
+
);
|
|
93
|
+
return /* @__PURE__ */ jsx(DropdownCtx.Provider, { value, children: /* @__PURE__ */ jsx("div", { className: "relative inline-block text-left", children }) });
|
|
94
|
+
}
|
|
95
|
+
function Trigger({
|
|
96
|
+
children,
|
|
97
|
+
className = "",
|
|
98
|
+
...btnProps
|
|
99
|
+
}) {
|
|
100
|
+
const { open, setOpen, triggerRef, menuId } = useDropdown();
|
|
101
|
+
const onClick = useCallback(() => setOpen(!open), [open, setOpen]);
|
|
102
|
+
const onKeyDown = (e) => {
|
|
103
|
+
if (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
setOpen(true);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return /* @__PURE__ */ jsx(
|
|
109
|
+
"button",
|
|
110
|
+
{
|
|
111
|
+
ref: triggerRef,
|
|
112
|
+
"aria-haspopup": "menu",
|
|
113
|
+
"aria-controls": menuId,
|
|
114
|
+
"aria-expanded": open,
|
|
115
|
+
onClick,
|
|
116
|
+
onKeyDown,
|
|
117
|
+
className: [
|
|
118
|
+
"inline-flex items-center gap-2 rounded-xl border border-slate-300/70 bg-white px-3 py-2",
|
|
119
|
+
"text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50 active:scale-[0.98]",
|
|
120
|
+
"dark:border-white/10 dark:bg-white/5 dark:text-slate-200 dark:hover:bg-white/10",
|
|
121
|
+
className
|
|
122
|
+
].join(" "),
|
|
123
|
+
...btnProps,
|
|
124
|
+
children
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
function Content({
|
|
129
|
+
children,
|
|
130
|
+
className = "",
|
|
131
|
+
maxHeight = 360
|
|
132
|
+
}) {
|
|
133
|
+
const { open, setOpen, triggerRef, menuRef, menuId, labelId, align } = useDropdown();
|
|
134
|
+
const [pos, setPos] = useState({ top: 0, left: 0, origin: "top-left", maxH: maxHeight });
|
|
135
|
+
const computePosition = useCallback(() => {
|
|
136
|
+
var _a, _b;
|
|
137
|
+
const t = triggerRef.current;
|
|
138
|
+
if (!t) return;
|
|
139
|
+
const r = t.getBoundingClientRect();
|
|
140
|
+
const vw = window.innerWidth;
|
|
141
|
+
const vh = window.innerHeight;
|
|
142
|
+
const gap = 8;
|
|
143
|
+
const measuredW = (_b = (_a = menuRef.current) == null ? void 0 : _a.offsetWidth) != null ? _b : 0;
|
|
144
|
+
const estW = Math.max(220, r.width);
|
|
145
|
+
const w = measuredW || estW;
|
|
146
|
+
let left = align === "end" ? r.right - w : r.left;
|
|
147
|
+
left = Math.min(Math.max(left, 8), vw - w - 8);
|
|
148
|
+
const availableDown = vh - (r.bottom + gap) - 8;
|
|
149
|
+
const maxH = Math.max(160, Math.min(maxHeight, availableDown));
|
|
150
|
+
const origin = align === "end" ? "top-right" : "top-left";
|
|
151
|
+
setPos({ top: r.bottom + gap, left: Math.round(left), origin, maxH });
|
|
152
|
+
}, [align, triggerRef, menuRef, maxHeight]);
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
if (!open) return;
|
|
155
|
+
computePosition();
|
|
156
|
+
const id = setTimeout(computePosition, 0);
|
|
157
|
+
const onScroll = () => computePosition();
|
|
158
|
+
const onResize = () => computePosition();
|
|
159
|
+
window.addEventListener("scroll", onScroll, true);
|
|
160
|
+
window.addEventListener("resize", onResize);
|
|
161
|
+
const ro = menuRef.current ? new ResizeObserver(() => computePosition()) : null;
|
|
162
|
+
if (menuRef.current && ro) ro.observe(menuRef.current);
|
|
163
|
+
return () => {
|
|
164
|
+
clearTimeout(id);
|
|
165
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
166
|
+
window.removeEventListener("resize", onResize);
|
|
167
|
+
ro == null ? void 0 : ro.disconnect();
|
|
168
|
+
};
|
|
169
|
+
}, [open, computePosition]);
|
|
170
|
+
const onKeyDown = (e) => {
|
|
171
|
+
var _a, _b, _c, _d, _e;
|
|
172
|
+
const items = Array.from(
|
|
173
|
+
(_b = (_a = menuRef.current) == null ? void 0 : _a.querySelectorAll('[role="menuitem"]')) != null ? _b : []
|
|
174
|
+
).filter((el) => el.getAttribute("data-disabled") !== "true");
|
|
175
|
+
const i = items.findIndex((el) => el === document.activeElement);
|
|
176
|
+
if (e.key === "Escape") {
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
setOpen(false);
|
|
179
|
+
(_c = triggerRef.current) == null ? void 0 : _c.focus();
|
|
180
|
+
} else if (e.key === "ArrowDown") {
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
(_d = items[(i + 1 + items.length) % items.length]) == null ? void 0 : _d.focus();
|
|
183
|
+
} else if (e.key === "ArrowUp") {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
(_e = items[(i - 1 + items.length) % items.length]) == null ? void 0 : _e.focus();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
if (!open) return null;
|
|
189
|
+
return createPortal(
|
|
190
|
+
/* @__PURE__ */ jsx(
|
|
191
|
+
"div",
|
|
192
|
+
{
|
|
193
|
+
role: "menu",
|
|
194
|
+
id: menuId,
|
|
195
|
+
"aria-labelledby": labelId,
|
|
196
|
+
ref: menuRef,
|
|
197
|
+
onKeyDown,
|
|
198
|
+
style: {
|
|
199
|
+
position: "fixed",
|
|
200
|
+
top: pos.top,
|
|
201
|
+
left: pos.left,
|
|
202
|
+
maxHeight: pos.maxH,
|
|
203
|
+
maxWidth: "calc(100vw - 16px)"
|
|
204
|
+
},
|
|
205
|
+
className: [
|
|
206
|
+
"z-[9999] overflow-auto rounded-2xl border border-slate-200/80 bg-white p-1.5 shadow-xl",
|
|
207
|
+
"data-[open=false]:pointer-events-none data-[open=false]:opacity-0 data-[open=false]:scale-95",
|
|
208
|
+
"data-[open=true]:opacity-100 data-[open=true]:scale-100 transition",
|
|
209
|
+
pos.origin === "top-right" ? "origin-top-right" : "origin-top-left",
|
|
210
|
+
"dark:border-white/10 dark:bg-[#0f0d0e]",
|
|
211
|
+
className
|
|
212
|
+
].join(" "),
|
|
213
|
+
"data-open": "true",
|
|
214
|
+
children
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
document.body
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
function Label({ children }) {
|
|
221
|
+
const { labelId } = useDropdown();
|
|
222
|
+
return /* @__PURE__ */ jsx(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
id: labelId,
|
|
226
|
+
className: "px-2.5 py-2 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400",
|
|
227
|
+
children
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
function Separator({ className = "" }) {
|
|
232
|
+
return /* @__PURE__ */ jsx(
|
|
233
|
+
"div",
|
|
234
|
+
{
|
|
235
|
+
role: "separator",
|
|
236
|
+
className: ["my-1 h-px bg-slate-200/80 dark:bg-white/10", className].join(" ")
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
function Item({
|
|
241
|
+
children,
|
|
242
|
+
icon,
|
|
243
|
+
kbd,
|
|
244
|
+
danger,
|
|
245
|
+
disabled,
|
|
246
|
+
require: require2,
|
|
247
|
+
hideIfUnauthorized,
|
|
248
|
+
disableIfUnauthorized,
|
|
249
|
+
onSelect,
|
|
250
|
+
className = "",
|
|
251
|
+
...rest
|
|
252
|
+
}) {
|
|
253
|
+
const { setOpen, isAllowed, defaultHideUnauthorized, defaultDisableUnauthorized } = useDropdown();
|
|
254
|
+
const allowed = isAllowed ? isAllowed(require2) : true;
|
|
255
|
+
const shouldHide = (hideIfUnauthorized != null ? hideIfUnauthorized : defaultHideUnauthorized) && !allowed;
|
|
256
|
+
const shouldDisable = !shouldHide && (disableIfUnauthorized != null ? disableIfUnauthorized : defaultDisableUnauthorized) && !allowed;
|
|
257
|
+
if (shouldHide) return null;
|
|
258
|
+
const onClick = (e) => {
|
|
259
|
+
e.preventDefault();
|
|
260
|
+
if (disabled || shouldDisable) return;
|
|
261
|
+
onSelect == null ? void 0 : onSelect();
|
|
262
|
+
setOpen(false);
|
|
263
|
+
};
|
|
264
|
+
const onKeyDown = (e) => {
|
|
265
|
+
if (disabled || shouldDisable) return;
|
|
266
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
onSelect == null ? void 0 : onSelect();
|
|
269
|
+
setOpen(false);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
return /* @__PURE__ */ jsxs(
|
|
273
|
+
"button",
|
|
274
|
+
{
|
|
275
|
+
role: "menuitem",
|
|
276
|
+
"data-disabled": disabled || shouldDisable ? "true" : "false",
|
|
277
|
+
disabled: disabled || shouldDisable,
|
|
278
|
+
onClick,
|
|
279
|
+
onKeyDown,
|
|
280
|
+
className: [
|
|
281
|
+
"group flex w-full items-center justify-between gap-3 rounded-xl px-2.5 py-2 text-left text-sm",
|
|
282
|
+
disabled || shouldDisable ? "text-slate-400 dark:text-slate-500 cursor-not-allowed" : danger ? "text-blue-600 hover:bg-blue-50 dark:text-blue-400 dark:hover:bg-blue-500/10" : "text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-white/10",
|
|
283
|
+
className
|
|
284
|
+
].join(" "),
|
|
285
|
+
...rest,
|
|
286
|
+
children: [
|
|
287
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
288
|
+
icon && /* @__PURE__ */ jsx("span", { className: "shrink-0 flex items-center justify-center h-4 w-4 text-slate-500 dark:text-slate-400", children: icon }),
|
|
289
|
+
/* @__PURE__ */ jsx("span", { className: "truncate leading-none", children })
|
|
290
|
+
] }),
|
|
291
|
+
kbd && /* @__PURE__ */ jsx("span", { className: "shrink-0 rounded-md border border-slate-200/80 bg-white px-1.5 py-0.5 text-[11px] text-slate-500 dark:border-white/10 dark:bg-white/5 dark:text-slate-400", children: kbd })
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
const DropdownExport = Object.assign(Dropdown, {
|
|
297
|
+
Trigger,
|
|
298
|
+
Content,
|
|
299
|
+
Label,
|
|
300
|
+
Separator,
|
|
301
|
+
Item,
|
|
302
|
+
MenuPuntosVerticalIcon
|
|
303
|
+
});
|
|
304
|
+
var Dropdown_default = DropdownExport;
|
|
305
|
+
export {
|
|
306
|
+
Content,
|
|
307
|
+
Dropdown,
|
|
308
|
+
Item,
|
|
309
|
+
Label,
|
|
310
|
+
Separator,
|
|
311
|
+
Trigger,
|
|
312
|
+
Dropdown_default as default
|
|
313
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var EmptyState_exports = {};
|
|
21
|
+
__export(EmptyState_exports, {
|
|
22
|
+
default: () => EmptyState
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(EmptyState_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
function EmptyState({
|
|
27
|
+
title = "Sin resultados",
|
|
28
|
+
subtitle = "Intenta cambiar el t\xE9rmino de b\xFAsqueda o los filtros."
|
|
29
|
+
}) {
|
|
30
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mx-auto w-full max-w-sm", children: [
|
|
31
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-auto mb-4 h-14 w-14 rounded-2xl bg-slate-100 ring-1 ring-slate-200 dark:bg-white/5" }),
|
|
32
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-lg font-medium", children: title }),
|
|
33
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm text-slate-500", children: subtitle })
|
|
34
|
+
] });
|
|
35
|
+
}
|