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
|
@@ -0,0 +1,441 @@
|
|
|
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 TimePopover_exports = {};
|
|
31
|
+
__export(TimePopover_exports, {
|
|
32
|
+
MonthPopover: () => MonthPopover,
|
|
33
|
+
WeekPopover: () => WeekPopover,
|
|
34
|
+
default: () => TimePopover
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(TimePopover_exports);
|
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
var React = __toESM(require("react"));
|
|
39
|
+
var import_react_dom = require("react-dom");
|
|
40
|
+
const pad2 = (n) => n < 10 ? `0${n}` : String(n);
|
|
41
|
+
function TimePopover({
|
|
42
|
+
anchorEl,
|
|
43
|
+
hh,
|
|
44
|
+
mm,
|
|
45
|
+
onChange,
|
|
46
|
+
onClose,
|
|
47
|
+
step = 5
|
|
48
|
+
}) {
|
|
49
|
+
const popRef = React.useRef(null);
|
|
50
|
+
const [pos, setPos] = React.useState({ top: -9999, left: -9999 });
|
|
51
|
+
const [H, setH] = React.useState(hh);
|
|
52
|
+
const [M, setM] = React.useState(mm);
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
setH(hh);
|
|
55
|
+
}, [hh]);
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
setM(mm);
|
|
58
|
+
}, [mm]);
|
|
59
|
+
const commit = (h, m) => {
|
|
60
|
+
setH(h);
|
|
61
|
+
setM(m);
|
|
62
|
+
onChange(h, m);
|
|
63
|
+
};
|
|
64
|
+
const place = React.useCallback(() => {
|
|
65
|
+
const a = anchorEl == null ? void 0 : anchorEl.getBoundingClientRect();
|
|
66
|
+
if (!a) return;
|
|
67
|
+
const W = 220, Hh = 128, GAP = 8, MARGIN = 8;
|
|
68
|
+
let left = Math.min(a.left, window.innerWidth - W - MARGIN);
|
|
69
|
+
left = Math.max(MARGIN, left);
|
|
70
|
+
let top = a.bottom + GAP;
|
|
71
|
+
if (top + Hh > window.innerHeight) top = Math.max(MARGIN, a.top - GAP - Hh);
|
|
72
|
+
setPos({ top, left });
|
|
73
|
+
}, [anchorEl]);
|
|
74
|
+
React.useEffect(() => {
|
|
75
|
+
place();
|
|
76
|
+
const onDown = (e) => {
|
|
77
|
+
var _a;
|
|
78
|
+
const t = e.target;
|
|
79
|
+
if ((_a = popRef.current) == null ? void 0 : _a.contains(t)) return;
|
|
80
|
+
if (anchorEl && t instanceof Node && anchorEl.contains(t)) return;
|
|
81
|
+
onClose();
|
|
82
|
+
};
|
|
83
|
+
const onKey = (e) => {
|
|
84
|
+
if (e.key === "Escape") onClose();
|
|
85
|
+
};
|
|
86
|
+
const onScroll = () => place();
|
|
87
|
+
window.addEventListener("pointerdown", onDown, true);
|
|
88
|
+
window.addEventListener("keydown", onKey);
|
|
89
|
+
window.addEventListener("scroll", onScroll, true);
|
|
90
|
+
window.addEventListener("resize", onScroll);
|
|
91
|
+
return () => {
|
|
92
|
+
window.removeEventListener("pointerdown", onDown, true);
|
|
93
|
+
window.removeEventListener("keydown", onKey);
|
|
94
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
95
|
+
window.removeEventListener("resize", onScroll);
|
|
96
|
+
};
|
|
97
|
+
}, [place, onClose, anchorEl]);
|
|
98
|
+
const incH = (d) => commit((H + d + 24) % 24, M);
|
|
99
|
+
const incM = (d) => {
|
|
100
|
+
const t = (H * 60 + M + d + 24 * 60) % (24 * 60);
|
|
101
|
+
commit(Math.floor(t / 60), t % 60);
|
|
102
|
+
};
|
|
103
|
+
const onKeyDown = (e) => {
|
|
104
|
+
if (e.key === "ArrowUp") {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
incH(1);
|
|
107
|
+
} else if (e.key === "ArrowDown") {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
incH(-1);
|
|
110
|
+
} else if (e.key === "ArrowRight") {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
incM(+step);
|
|
113
|
+
} else if (e.key === "ArrowLeft") {
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
incM(-step);
|
|
116
|
+
} else if (e.key === "Enter") onClose();
|
|
117
|
+
};
|
|
118
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
ref: popRef,
|
|
122
|
+
role: "dialog",
|
|
123
|
+
"aria-label": "Selector de hora",
|
|
124
|
+
tabIndex: 0,
|
|
125
|
+
"data-dtf-pop": true,
|
|
126
|
+
onPointerDownCapture: (e) => e.stopPropagation(),
|
|
127
|
+
onKeyDown,
|
|
128
|
+
style: { position: "fixed", top: pos.top, left: pos.left, zIndex: 1e5 },
|
|
129
|
+
className: "w-64 rounded-2xl border border-slate-200 bg-white p-3 shadow-xl dark:border-white/10 dark:bg-[#0e0d0e]",
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-2 text-sm font-medium text-slate-700 dark:text-slate-200", children: "Selecciona hora" }),
|
|
132
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
133
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-stretch gap-2", children: [
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
|
+
"button",
|
|
136
|
+
{
|
|
137
|
+
type: "button",
|
|
138
|
+
className: "h-8 rounded-lg ring-1 ring-slate-200 hover:bg-slate-50 active:scale-95 dark:ring-white/10 dark:hover:bg-white/10",
|
|
139
|
+
onClick: () => incH(1),
|
|
140
|
+
"aria-label": "Aumentar hora",
|
|
141
|
+
children: "+"
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
145
|
+
"input",
|
|
146
|
+
{
|
|
147
|
+
inputMode: "numeric",
|
|
148
|
+
"aria-label": "Hora",
|
|
149
|
+
value: pad2(H),
|
|
150
|
+
onChange: (e) => {
|
|
151
|
+
const v = e.target.value.replace(/\D/g, "").slice(-2);
|
|
152
|
+
if (!v) return;
|
|
153
|
+
let n = parseInt(v, 10);
|
|
154
|
+
if (Number.isNaN(n)) return;
|
|
155
|
+
if (n > 23) n = 23;
|
|
156
|
+
commit(n, M);
|
|
157
|
+
},
|
|
158
|
+
className: "h-10 rounded-lg text-center text-lg ring-1 ring-slate-200 outline-none focus:ring-2 focus:ring-slate-300 dark:ring-white/10 dark:bg-white/5"
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
162
|
+
"button",
|
|
163
|
+
{
|
|
164
|
+
type: "button",
|
|
165
|
+
className: "h-8 rounded-lg ring-1 ring-slate-200 hover:bg-slate-50 active:scale-95 dark:ring-white/10 dark:hover:bg-white/10",
|
|
166
|
+
onClick: () => incH(-1),
|
|
167
|
+
"aria-label": "Disminuir hora",
|
|
168
|
+
children: "\u2212"
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
] }),
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-stretch gap-2", children: [
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
174
|
+
"button",
|
|
175
|
+
{
|
|
176
|
+
type: "button",
|
|
177
|
+
className: "h-8 rounded-lg ring-1 ring-slate-200 hover:bg-slate-50 active:scale-95 dark:ring-white/10 dark:hover:bg-white/10",
|
|
178
|
+
onClick: () => incM(+step),
|
|
179
|
+
"aria-label": "Aumentar minutos",
|
|
180
|
+
children: "+"
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
184
|
+
"input",
|
|
185
|
+
{
|
|
186
|
+
inputMode: "numeric",
|
|
187
|
+
"aria-label": "Minutos",
|
|
188
|
+
value: pad2(M),
|
|
189
|
+
onChange: (e) => {
|
|
190
|
+
const v = e.target.value.replace(/\D/g, "").slice(-2);
|
|
191
|
+
if (!v) return;
|
|
192
|
+
let n = parseInt(v, 10);
|
|
193
|
+
if (Number.isNaN(n)) return;
|
|
194
|
+
if (n > 59) n = 59;
|
|
195
|
+
commit(H, n);
|
|
196
|
+
},
|
|
197
|
+
className: "h-10 rounded-lg text-center text-lg ring-1 ring-slate-200 outline-none focus:ring-2 focus:ring-slate-300 dark:ring-white/10 dark:bg-white/5"
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
type: "button",
|
|
204
|
+
className: "h-8 rounded-lg ring-1 ring-slate-200 hover:bg-slate-50 active:scale-95 dark:ring-white/10 dark:hover:bg-white/10",
|
|
205
|
+
onClick: () => incM(-step),
|
|
206
|
+
"aria-label": "Disminuir minutos",
|
|
207
|
+
children: "\u2212"
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
] })
|
|
211
|
+
] }),
|
|
212
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mt-3 flex items-center justify-between", children: [
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
214
|
+
"button",
|
|
215
|
+
{
|
|
216
|
+
type: "button",
|
|
217
|
+
className: "rounded-xl px-2.5 py-1.5 text-sm ring-1 ring-slate-200 hover:bg-slate-50 active:scale-[0.98] dark:ring-white/10 dark:hover:bg-white/10",
|
|
218
|
+
onClick: () => {
|
|
219
|
+
const t = /* @__PURE__ */ new Date();
|
|
220
|
+
const rounded = Math.round(t.getMinutes() / step) * step % 60;
|
|
221
|
+
commit(t.getHours(), rounded);
|
|
222
|
+
},
|
|
223
|
+
children: "Ahora"
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
227
|
+
"button",
|
|
228
|
+
{
|
|
229
|
+
type: "button",
|
|
230
|
+
className: "rounded-xl bg-slate-900 px-3 py-1.5 text-sm text-white hover:opacity-95 active:scale-[0.98] dark:bg-white dark:text-slate-900",
|
|
231
|
+
onClick: onClose,
|
|
232
|
+
children: "Listo"
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
] })
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
return (0, import_react_dom.createPortal)(body, document.body);
|
|
240
|
+
}
|
|
241
|
+
function WeekPopover({ anchorEl, cursor, value, onCursorChange, onPick, onClose }) {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
const popRef = React.useRef(null);
|
|
244
|
+
const [pos, setPos] = React.useState({ top: -9999, left: -9999 });
|
|
245
|
+
const place = React.useCallback(() => {
|
|
246
|
+
const a = anchorEl == null ? void 0 : anchorEl.getBoundingClientRect();
|
|
247
|
+
if (!a) return;
|
|
248
|
+
const W = 360, H = 320, GAP = 8, M = 8;
|
|
249
|
+
let left = Math.min(a.left, window.innerWidth - W - M);
|
|
250
|
+
left = Math.max(M, left);
|
|
251
|
+
let top = a.bottom + GAP;
|
|
252
|
+
if (top + H > window.innerHeight) top = Math.max(M, a.top - GAP - H);
|
|
253
|
+
setPos({ top, left });
|
|
254
|
+
}, [anchorEl]);
|
|
255
|
+
React.useEffect(() => {
|
|
256
|
+
place();
|
|
257
|
+
const onDown = (e) => {
|
|
258
|
+
var _a2;
|
|
259
|
+
const t = e.target;
|
|
260
|
+
if ((_a2 = popRef.current) == null ? void 0 : _a2.contains(t)) return;
|
|
261
|
+
if (anchorEl && anchorEl.contains(t)) return;
|
|
262
|
+
onClose();
|
|
263
|
+
};
|
|
264
|
+
const onScroll = () => place();
|
|
265
|
+
const onKey = (e) => {
|
|
266
|
+
if (e.key === "Escape") onClose();
|
|
267
|
+
};
|
|
268
|
+
window.addEventListener("pointerdown", onDown, true);
|
|
269
|
+
window.addEventListener("scroll", onScroll, true);
|
|
270
|
+
window.addEventListener("resize", onScroll);
|
|
271
|
+
window.addEventListener("keydown", onKey);
|
|
272
|
+
return () => {
|
|
273
|
+
window.removeEventListener("pointerdown", onDown, true);
|
|
274
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
275
|
+
window.removeEventListener("resize", onScroll);
|
|
276
|
+
window.removeEventListener("keydown", onKey);
|
|
277
|
+
};
|
|
278
|
+
}, [place, onClose, anchorEl]);
|
|
279
|
+
const year = cursor.getFullYear();
|
|
280
|
+
const month = cursor.getMonth();
|
|
281
|
+
const firstOfMonth = new Date(year, month, 1);
|
|
282
|
+
const start = new Date(firstOfMonth);
|
|
283
|
+
start.setDate(firstOfMonth.getDate() - firstOfMonth.getDay());
|
|
284
|
+
const lastOfMonth = new Date(year, month + 1, 0);
|
|
285
|
+
const end = new Date(lastOfMonth);
|
|
286
|
+
end.setDate(lastOfMonth.getDate() + (6 - lastOfMonth.getDay()));
|
|
287
|
+
const weeks = [];
|
|
288
|
+
for (let d = new Date(start); d <= end; d.setDate(d.getDate() + 7)) {
|
|
289
|
+
const from = new Date(d);
|
|
290
|
+
const to = new Date(d);
|
|
291
|
+
to.setDate(to.getDate() + 6);
|
|
292
|
+
weeks.push({ from, to });
|
|
293
|
+
}
|
|
294
|
+
const selFrom = (_a = value == null ? void 0 : value.from) != null ? _a : null;
|
|
295
|
+
const selTo = (_b = value == null ? void 0 : value.to) != null ? _b : null;
|
|
296
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: popRef, style: { position: "fixed", top: pos.top, left: pos.left, zIndex: 1e5 }, className: "w-[340px] rounded-2xl border border-slate-200 bg-white p-3 shadow-xl dark:border-white/10 dark:bg-[#0e0d0e]", children: [
|
|
297
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
|
|
298
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
299
|
+
"button",
|
|
300
|
+
{
|
|
301
|
+
className: "rounded-lg border border-slate-200 px-2 py-1 text-sm hover:bg-slate-50 dark:border-white/10 dark:hover:bg-white/10",
|
|
302
|
+
onClick: () => onCursorChange(new Date(year, month - 1, 1)),
|
|
303
|
+
children: "\u25C0"
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm font-semibold", children: cursor.toLocaleDateString("es-MX", { month: "long", year: "numeric" }) }),
|
|
307
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
308
|
+
"button",
|
|
309
|
+
{
|
|
310
|
+
className: "rounded-lg border border-slate-200 px-2 py-1 text-sm hover:bg-slate-50 dark:border-white/10 dark:hover:bg-white/10",
|
|
311
|
+
onClick: () => onCursorChange(new Date(year, month + 1, 1)),
|
|
312
|
+
children: "\u25B6"
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
] }),
|
|
316
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid gap-2", children: weeks.map((w, idx) => {
|
|
317
|
+
const isSel = selFrom && selTo && sameDay(selFrom, w.from) && sameDay(selTo, w.to);
|
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
319
|
+
"button",
|
|
320
|
+
{
|
|
321
|
+
className: `flex items-center justify-between rounded-xl border px-3 py-2 text-sm ${isSel ? "bg-slate-900 text-white border-slate-900 dark:bg-white dark:text-slate-900 dark:border-white" : "border-slate-200 hover:bg-slate-100 dark:border-white/10 dark:hover:bg-white/10"}`,
|
|
322
|
+
onClick: () => onPick(w.from, w.to),
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
325
|
+
"Semana ",
|
|
326
|
+
idx + 1
|
|
327
|
+
] }),
|
|
328
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs opacity-80", children: formatWeekLabel(w.from, w.to) })
|
|
329
|
+
]
|
|
330
|
+
},
|
|
331
|
+
`${w.from.toISOString()}-${w.to.toISOString()}`
|
|
332
|
+
);
|
|
333
|
+
}) })
|
|
334
|
+
] });
|
|
335
|
+
return (0, import_react_dom.createPortal)(body, document.body);
|
|
336
|
+
}
|
|
337
|
+
function sameDay(a, b) {
|
|
338
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
339
|
+
}
|
|
340
|
+
function formatWeekLabel(from, to) {
|
|
341
|
+
const opts = { day: "2-digit", month: "short" };
|
|
342
|
+
try {
|
|
343
|
+
const f = from.toLocaleDateString("es-MX", opts);
|
|
344
|
+
const t = to.toLocaleDateString("es-MX", opts);
|
|
345
|
+
return `${f} \u2013 ${t}`;
|
|
346
|
+
} catch {
|
|
347
|
+
return `${from.getDate()}/${from.getMonth() + 1} \u2013 ${to.getDate()}/${to.getMonth() + 1}`;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function MonthPopover({ anchorEl, cursor, value, onCursorChange, onPick, onClose }) {
|
|
351
|
+
var _a;
|
|
352
|
+
const popRef = React.useRef(null);
|
|
353
|
+
const [pos, setPos] = React.useState({ top: -9999, left: -9999 });
|
|
354
|
+
const place = React.useCallback(() => {
|
|
355
|
+
const a = anchorEl == null ? void 0 : anchorEl.getBoundingClientRect();
|
|
356
|
+
if (!a) return;
|
|
357
|
+
const W = 320, H = 360, GAP = 8, M = 8;
|
|
358
|
+
let left = Math.min(a.left, window.innerWidth - W - M);
|
|
359
|
+
left = Math.max(M, left);
|
|
360
|
+
let top = a.bottom + GAP;
|
|
361
|
+
if (top + H > window.innerHeight) top = Math.max(M, a.top - GAP - H);
|
|
362
|
+
setPos({ top, left });
|
|
363
|
+
}, [anchorEl]);
|
|
364
|
+
React.useEffect(() => {
|
|
365
|
+
place();
|
|
366
|
+
const onDown = (e) => {
|
|
367
|
+
var _a2;
|
|
368
|
+
const t = e.target;
|
|
369
|
+
if ((_a2 = popRef.current) == null ? void 0 : _a2.contains(t)) return;
|
|
370
|
+
if (anchorEl && anchorEl.contains(t)) return;
|
|
371
|
+
onClose();
|
|
372
|
+
};
|
|
373
|
+
const onScroll = () => place();
|
|
374
|
+
const onKey = (e) => {
|
|
375
|
+
if (e.key === "Escape") onClose();
|
|
376
|
+
};
|
|
377
|
+
window.addEventListener("pointerdown", onDown, true);
|
|
378
|
+
window.addEventListener("scroll", onScroll, true);
|
|
379
|
+
window.addEventListener("resize", onScroll);
|
|
380
|
+
window.addEventListener("keydown", onKey);
|
|
381
|
+
return () => {
|
|
382
|
+
window.removeEventListener("pointerdown", onDown, true);
|
|
383
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
384
|
+
window.removeEventListener("resize", onScroll);
|
|
385
|
+
window.removeEventListener("keydown", onKey);
|
|
386
|
+
};
|
|
387
|
+
}, [place, onClose, anchorEl]);
|
|
388
|
+
const year = cursor.getFullYear();
|
|
389
|
+
const months = ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"];
|
|
390
|
+
let selYear = null;
|
|
391
|
+
let selMonthIdx = null;
|
|
392
|
+
if (value) {
|
|
393
|
+
const parts = value.split("-").map(Number);
|
|
394
|
+
if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
|
|
395
|
+
selYear = parts[0];
|
|
396
|
+
selMonthIdx = ((_a = parts[1]) != null ? _a : 1) - 1;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const body = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: popRef, style: { position: "fixed", top: pos.top, left: pos.left, zIndex: 1e5 }, className: "w-[300px] rounded-2xl border border-slate-200 bg-white p-3 shadow-xl dark:border-white/10 dark:bg-[#0e0d0e]", children: [
|
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
|
|
401
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
402
|
+
"button",
|
|
403
|
+
{
|
|
404
|
+
className: "rounded-lg border border-slate-200 px-2 py-1 text-sm hover:bg-slate-50 dark:border-white/10 dark:hover:bg-white/10",
|
|
405
|
+
onClick: () => onCursorChange(new Date(year - 1, 0, 1)),
|
|
406
|
+
children: "\u25C0"
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm font-semibold", children: year }),
|
|
410
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
411
|
+
"button",
|
|
412
|
+
{
|
|
413
|
+
className: "rounded-lg border border-slate-200 px-2 py-1 text-sm hover:bg-slate-50 dark:border-white/10 dark:hover:bg-white/10",
|
|
414
|
+
onClick: () => onCursorChange(new Date(year + 1, 0, 1)),
|
|
415
|
+
children: "\u25B6"
|
|
416
|
+
}
|
|
417
|
+
)
|
|
418
|
+
] }),
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid grid-cols-3 gap-2", children: months.map((m, idx) => {
|
|
420
|
+
const isSel = selYear === year && selMonthIdx === idx;
|
|
421
|
+
const base = "rounded-xl border px-2 py-2 text-sm ";
|
|
422
|
+
const light = isSel ? "bg-slate-900 text-white border-slate-900" : "border-slate-200 hover:bg-slate-100";
|
|
423
|
+
const dark = isSel ? "dark:bg-white dark:text-slate-900 dark:border-white" : "dark:border-white/10 dark:hover:bg-white/10";
|
|
424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
425
|
+
"button",
|
|
426
|
+
{
|
|
427
|
+
className: `${base} ${light} ${dark}`,
|
|
428
|
+
onClick: () => onPick(new Date(year, idx, 1)),
|
|
429
|
+
children: m
|
|
430
|
+
},
|
|
431
|
+
idx
|
|
432
|
+
);
|
|
433
|
+
}) })
|
|
434
|
+
] });
|
|
435
|
+
return (0, import_react_dom.createPortal)(body, document.body);
|
|
436
|
+
}
|
|
437
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
438
|
+
0 && (module.exports = {
|
|
439
|
+
MonthPopover,
|
|
440
|
+
WeekPopover
|
|
441
|
+
});
|