admin-lib-cms 1.2.13 → 1.2.14
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/index.js +128 -34
- package/dist/index.mjs +130 -35
- package/dist/types.d.mts +16 -0
- package/dist/types.d.ts +16 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1016,8 +1016,8 @@ var AdminI18nContext = import_react5.default.createContext(getAdminTranslations(
|
|
|
1016
1016
|
function useAdminI18n() {
|
|
1017
1017
|
return import_react5.default.useContext(AdminI18nContext);
|
|
1018
1018
|
}
|
|
1019
|
-
var TIME_STORAGE_FORMAT = "
|
|
1020
|
-
var TIME_DISPLAY_FORMAT = "h:mm
|
|
1019
|
+
var TIME_STORAGE_FORMAT = "h:mm a";
|
|
1020
|
+
var TIME_DISPLAY_FORMAT = "h:mm a";
|
|
1021
1021
|
var TIME_PICKER_THEME = {
|
|
1022
1022
|
token: {
|
|
1023
1023
|
borderRadius: 12,
|
|
@@ -1078,6 +1078,16 @@ function toDayjsTime(value) {
|
|
|
1078
1078
|
function toStoredTime(value) {
|
|
1079
1079
|
return value?.format(TIME_STORAGE_FORMAT) ?? "";
|
|
1080
1080
|
}
|
|
1081
|
+
function formatTo12Hour(value) {
|
|
1082
|
+
const str = String(value ?? "").trim();
|
|
1083
|
+
if (!str || str === "\u2014" || str === "undefined") return "";
|
|
1084
|
+
if (/\b(am|pm)\b/i.test(str)) return str.toLowerCase();
|
|
1085
|
+
const d = toDayjsTime(str);
|
|
1086
|
+
if (d && d.isValid()) {
|
|
1087
|
+
return d.format("h:mm a");
|
|
1088
|
+
}
|
|
1089
|
+
return str;
|
|
1090
|
+
}
|
|
1081
1091
|
async function handleImageFile(file, onUrl, uploadImage) {
|
|
1082
1092
|
if (uploadImage) {
|
|
1083
1093
|
try {
|
|
@@ -2501,6 +2511,7 @@ function CollectionEditor({ collection }) {
|
|
|
2501
2511
|
const [originalId, setOriginalId] = (0, import_react5.useState)(null);
|
|
2502
2512
|
const [duplicateErrors, setDuplicateErrors] = (0, import_react5.useState)({});
|
|
2503
2513
|
const [isCreatingManual, setIsCreatingManual] = (0, import_react5.useState)(false);
|
|
2514
|
+
const [isViewingDetail, setIsViewingDetail] = (0, import_react5.useState)(false);
|
|
2504
2515
|
const [saving, setSaving] = (0, import_react5.useState)(false);
|
|
2505
2516
|
const [deletingId, setDeletingId] = (0, import_react5.useState)(null);
|
|
2506
2517
|
const [loadingEntries, setLoadingEntries] = (0, import_react5.useState)(true);
|
|
@@ -2761,10 +2772,11 @@ function CollectionEditor({ collection }) {
|
|
|
2761
2772
|
open: Boolean(editing),
|
|
2762
2773
|
title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between pr-8", children: [
|
|
2763
2774
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2 text-slate-900 font-bold", children: [
|
|
2764
|
-
isCreatingEntry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4 text-indigo-600" }),
|
|
2765
|
-
isCreatingEntry ? collection.createTitle || `Nueva ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}` : `Editar ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}`
|
|
2775
|
+
isViewingDetail ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Eye, { className: "h-4 w-4 text-indigo-600" }) : isCreatingEntry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4 text-indigo-600" }),
|
|
2776
|
+
isViewingDetail ? `Detalle de ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}${editing?.numero ? ` #${editing.numero}` : ""}` : isCreatingEntry ? collection.createTitle || `Nueva ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}` : `Editar ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}`
|
|
2766
2777
|
] }),
|
|
2767
|
-
|
|
2778
|
+
isViewingDetail && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `px-2.5 py-1 text-xs font-semibold rounded-full ${String(editing.estado).toLowerCase().includes("terminad") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(editing.estado).toLowerCase().includes("proceso") ? "bg-sky-50 text-sky-700 border border-sky-200" : String(editing.estado).toLowerCase().includes("cancelad") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-amber-50 text-amber-700 border border-amber-200"}`, children: String(editing.estado) }),
|
|
2779
|
+
!isViewingDetail && !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2768
2780
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
|
|
2769
2781
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2770
2782
|
import_antd.Select,
|
|
@@ -2788,6 +2800,7 @@ function CollectionEditor({ collection }) {
|
|
|
2788
2800
|
setEditing(null);
|
|
2789
2801
|
setOriginalId(null);
|
|
2790
2802
|
setIsCreatingManual(false);
|
|
2803
|
+
setIsViewingDetail(false);
|
|
2791
2804
|
}
|
|
2792
2805
|
},
|
|
2793
2806
|
footer: null,
|
|
@@ -2825,12 +2838,55 @@ function CollectionEditor({ collection }) {
|
|
|
2825
2838
|
}).map((f) => {
|
|
2826
2839
|
const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.type === "signature" || f.type === "date" || f.type === "datetime" || f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "branch-settings" || f.type === "time-range";
|
|
2827
2840
|
const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
|
|
2841
|
+
if (isViewingDetail) {
|
|
2842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
|
|
2843
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: f.label }),
|
|
2844
|
+
f.customRender ? f.customRender({
|
|
2845
|
+
value: editing[f.id],
|
|
2846
|
+
record: editing,
|
|
2847
|
+
onChange: () => {
|
|
2848
|
+
},
|
|
2849
|
+
isCreatingEntry: false
|
|
2850
|
+
}) : f.type === "signature" ? editing[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl border border-slate-200 bg-white p-3 flex items-center justify-center shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2851
|
+
"img",
|
|
2852
|
+
{
|
|
2853
|
+
src: String(editing[f.id]),
|
|
2854
|
+
alt: f.label,
|
|
2855
|
+
className: "h-28 w-auto max-w-full object-contain"
|
|
2856
|
+
}
|
|
2857
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-400 italic py-1", children: "Sin firma registrada" }) : f.type === "list" ? Array.isArray(editing[f.id]) && editing[f.id].length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-1.5 pt-0.5", children: editing[f.id].map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2858
|
+
"span",
|
|
2859
|
+
{
|
|
2860
|
+
className: "rounded-full bg-slate-100 text-slate-700 px-3 py-1 text-xs font-medium border border-slate-200",
|
|
2861
|
+
children: String(item)
|
|
2862
|
+
},
|
|
2863
|
+
idx
|
|
2864
|
+
)) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-400 italic py-1", children: "Ninguno" }) : f.type === "link" ? Boolean(editing[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2865
|
+
"a",
|
|
2866
|
+
{
|
|
2867
|
+
href: String(editing[f.id]),
|
|
2868
|
+
target: "_blank",
|
|
2869
|
+
rel: "noopener noreferrer",
|
|
2870
|
+
className: "inline-flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-800 underline font-medium py-1",
|
|
2871
|
+
children: [
|
|
2872
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5" }),
|
|
2873
|
+
String(editing[f.id]).includes("maps") ? "Ver en Google Maps" : String(editing[f.id])
|
|
2874
|
+
]
|
|
2875
|
+
}
|
|
2876
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 py-1 block", children: "\u2014" }) : f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2.5 text-sm text-slate-800 whitespace-pre-line leading-relaxed", children: String(editing[f.id] || "\u2014") }) : f.type === "time" || f.id.toLowerCase().includes("hora") || f.id === "inicioServicio" || f.id === "finServicio" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2 text-sm text-slate-800 font-medium", children: formatTo12Hour(editing[f.id]) || String(editing[f.id] ?? "\u2014") }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2 text-sm text-slate-800 font-medium", children: String(editing[f.id] ?? "\u2014") })
|
|
2877
|
+
] }, f.id);
|
|
2878
|
+
}
|
|
2828
2879
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
|
|
2829
2880
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
|
|
2830
2881
|
f.label,
|
|
2831
2882
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
|
|
2832
2883
|
] }),
|
|
2833
|
-
f.
|
|
2884
|
+
f.customRender ? f.customRender({
|
|
2885
|
+
value: editing[f.id],
|
|
2886
|
+
record: editing,
|
|
2887
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
2888
|
+
isCreatingEntry
|
|
2889
|
+
}) : f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2834
2890
|
BranchSettingsEditor,
|
|
2835
2891
|
{
|
|
2836
2892
|
collectionId: f.collection || "",
|
|
@@ -3372,34 +3428,48 @@ function CollectionEditor({ collection }) {
|
|
|
3372
3428
|
] })
|
|
3373
3429
|
] }, f.id);
|
|
3374
3430
|
}) }) }),
|
|
3375
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex shrink-0 justify-
|
|
3376
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3377
|
-
import_antd.Button,
|
|
3378
|
-
{
|
|
3379
|
-
size: "large",
|
|
3380
|
-
onClick: () => {
|
|
3381
|
-
setEditing(null);
|
|
3382
|
-
setOriginalId(null);
|
|
3383
|
-
setDuplicateErrors({});
|
|
3384
|
-
setIsCreatingManual(false);
|
|
3385
|
-
},
|
|
3386
|
-
disabled: saving,
|
|
3387
|
-
className: "rounded-xl font-medium",
|
|
3388
|
-
children: t.cancel
|
|
3389
|
-
}
|
|
3390
|
-
),
|
|
3391
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3431
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex shrink-0 justify-between items-center border-t border-slate-200 bg-white px-6 py-4", children: [
|
|
3432
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: isViewingDetail && collection.onDownloadPdf && (!collection.canDownloadPdf || collection.canDownloadPdf(editing)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3392
3433
|
import_antd.Button,
|
|
3393
3434
|
{
|
|
3394
3435
|
size: "large",
|
|
3395
3436
|
type: "primary",
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
|
|
3437
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileDown, { className: "w-4 h-4" }),
|
|
3438
|
+
onClick: () => collection.onDownloadPdf?.(editing),
|
|
3439
|
+
className: "rounded-xl font-semibold bg-emerald-600 hover:bg-emerald-500 border-emerald-600 shadow-sm",
|
|
3440
|
+
children: "Descargar PDF"
|
|
3401
3441
|
}
|
|
3402
|
-
)
|
|
3442
|
+
) }),
|
|
3443
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
3444
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3445
|
+
import_antd.Button,
|
|
3446
|
+
{
|
|
3447
|
+
size: "large",
|
|
3448
|
+
onClick: () => {
|
|
3449
|
+
setEditing(null);
|
|
3450
|
+
setOriginalId(null);
|
|
3451
|
+
setDuplicateErrors({});
|
|
3452
|
+
setIsCreatingManual(false);
|
|
3453
|
+
setIsViewingDetail(false);
|
|
3454
|
+
},
|
|
3455
|
+
disabled: saving,
|
|
3456
|
+
className: "rounded-xl font-medium",
|
|
3457
|
+
children: isViewingDetail ? "Cerrar" : t.cancel
|
|
3458
|
+
}
|
|
3459
|
+
),
|
|
3460
|
+
!isViewingDetail && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3461
|
+
import_antd.Button,
|
|
3462
|
+
{
|
|
3463
|
+
size: "large",
|
|
3464
|
+
type: "primary",
|
|
3465
|
+
onClick: save,
|
|
3466
|
+
loading: saving,
|
|
3467
|
+
disabled: saving || Object.keys(duplicateErrors).length > 0,
|
|
3468
|
+
className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700 disabled:opacity-50",
|
|
3469
|
+
children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
|
|
3470
|
+
}
|
|
3471
|
+
)
|
|
3472
|
+
] })
|
|
3403
3473
|
] })
|
|
3404
3474
|
] }) })
|
|
3405
3475
|
}
|
|
@@ -3472,14 +3542,38 @@ function CollectionEditor({ collection }) {
|
|
|
3472
3542
|
String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
|
|
3473
3543
|
]
|
|
3474
3544
|
}
|
|
3475
|
-
) : String(e[f.id] ?? "") }, f.id)),
|
|
3476
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-end gap-
|
|
3477
|
-
|
|
3478
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3545
|
+
) : f.type === "time" || f.id.toLowerCase().includes("hora") || f.id === "inicioServicio" || f.id === "finServicio" ? formatTo12Hour(e[f.id]) || String(e[f.id] ?? "") : String(e[f.id] ?? "") }, f.id)),
|
|
3546
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-end gap-1.5", children: [
|
|
3547
|
+
collection.enableDetailView && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3479
3548
|
"button",
|
|
3480
3549
|
{
|
|
3481
3550
|
onClick: () => {
|
|
3482
3551
|
setIsCreatingManual(false);
|
|
3552
|
+
setIsViewingDetail(true);
|
|
3553
|
+
setOriginalId(String(e.id || ""));
|
|
3554
|
+
setDuplicateErrors({});
|
|
3555
|
+
setEditing({ ...e });
|
|
3556
|
+
},
|
|
3557
|
+
className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
|
|
3558
|
+
title: "Ver detalle",
|
|
3559
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Eye, { className: "h-4 w-4" })
|
|
3560
|
+
}
|
|
3561
|
+
),
|
|
3562
|
+
collection.onDownloadPdf && (!collection.canDownloadPdf || collection.canDownloadPdf(e)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3563
|
+
"button",
|
|
3564
|
+
{
|
|
3565
|
+
onClick: () => collection.onDownloadPdf?.(e),
|
|
3566
|
+
className: "p-2 rounded-lg text-slate-400 hover:text-emerald-600 hover:bg-emerald-50 transition-colors",
|
|
3567
|
+
title: "Descargar PDF",
|
|
3568
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileDown, { className: "h-4 w-4" })
|
|
3569
|
+
}
|
|
3570
|
+
),
|
|
3571
|
+
!collection.disableEdit && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3572
|
+
"button",
|
|
3573
|
+
{
|
|
3574
|
+
onClick: () => {
|
|
3575
|
+
setIsCreatingManual(false);
|
|
3576
|
+
setIsViewingDetail(false);
|
|
3483
3577
|
setOriginalId(String(e.id || ""));
|
|
3484
3578
|
setDuplicateErrors({});
|
|
3485
3579
|
setEditing({ ...e });
|
|
@@ -3489,7 +3583,7 @@ function CollectionEditor({ collection }) {
|
|
|
3489
3583
|
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4" })
|
|
3490
3584
|
}
|
|
3491
3585
|
),
|
|
3492
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3586
|
+
!collection.disableDelete && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3493
3587
|
"button",
|
|
3494
3588
|
{
|
|
3495
3589
|
onClick: () => remove(e.id),
|
package/dist/index.mjs
CHANGED
|
@@ -67,7 +67,8 @@ import {
|
|
|
67
67
|
ExternalLink,
|
|
68
68
|
Check,
|
|
69
69
|
GripVertical,
|
|
70
|
-
AlertTriangle
|
|
70
|
+
AlertTriangle,
|
|
71
|
+
FileDown
|
|
71
72
|
} from "lucide-react";
|
|
72
73
|
|
|
73
74
|
// src/admin/i18n.ts
|
|
@@ -254,8 +255,8 @@ var AdminI18nContext = React.createContext(getAdminTranslations("en"));
|
|
|
254
255
|
function useAdminI18n() {
|
|
255
256
|
return React.useContext(AdminI18nContext);
|
|
256
257
|
}
|
|
257
|
-
var TIME_STORAGE_FORMAT = "
|
|
258
|
-
var TIME_DISPLAY_FORMAT = "h:mm
|
|
258
|
+
var TIME_STORAGE_FORMAT = "h:mm a";
|
|
259
|
+
var TIME_DISPLAY_FORMAT = "h:mm a";
|
|
259
260
|
var TIME_PICKER_THEME = {
|
|
260
261
|
token: {
|
|
261
262
|
borderRadius: 12,
|
|
@@ -316,6 +317,16 @@ function toDayjsTime(value) {
|
|
|
316
317
|
function toStoredTime(value) {
|
|
317
318
|
return value?.format(TIME_STORAGE_FORMAT) ?? "";
|
|
318
319
|
}
|
|
320
|
+
function formatTo12Hour(value) {
|
|
321
|
+
const str = String(value ?? "").trim();
|
|
322
|
+
if (!str || str === "\u2014" || str === "undefined") return "";
|
|
323
|
+
if (/\b(am|pm)\b/i.test(str)) return str.toLowerCase();
|
|
324
|
+
const d = toDayjsTime(str);
|
|
325
|
+
if (d && d.isValid()) {
|
|
326
|
+
return d.format("h:mm a");
|
|
327
|
+
}
|
|
328
|
+
return str;
|
|
329
|
+
}
|
|
319
330
|
async function handleImageFile(file, onUrl, uploadImage) {
|
|
320
331
|
if (uploadImage) {
|
|
321
332
|
try {
|
|
@@ -1739,6 +1750,7 @@ function CollectionEditor({ collection }) {
|
|
|
1739
1750
|
const [originalId, setOriginalId] = useState(null);
|
|
1740
1751
|
const [duplicateErrors, setDuplicateErrors] = useState({});
|
|
1741
1752
|
const [isCreatingManual, setIsCreatingManual] = useState(false);
|
|
1753
|
+
const [isViewingDetail, setIsViewingDetail] = useState(false);
|
|
1742
1754
|
const [saving, setSaving] = useState(false);
|
|
1743
1755
|
const [deletingId, setDeletingId] = useState(null);
|
|
1744
1756
|
const [loadingEntries, setLoadingEntries] = useState(true);
|
|
@@ -1999,10 +2011,11 @@ function CollectionEditor({ collection }) {
|
|
|
1999
2011
|
open: Boolean(editing),
|
|
2000
2012
|
title: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pr-8", children: [
|
|
2001
2013
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-slate-900 font-bold", children: [
|
|
2002
|
-
isCreatingEntry ? /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4 text-indigo-600" }),
|
|
2003
|
-
isCreatingEntry ? collection.createTitle || `Nueva ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}` : `Editar ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}`
|
|
2014
|
+
isViewingDetail ? /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4 text-indigo-600" }) : isCreatingEntry ? /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4 text-indigo-600" }),
|
|
2015
|
+
isViewingDetail ? `Detalle de ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}${editing?.numero ? ` #${editing.numero}` : ""}` : isCreatingEntry ? collection.createTitle || `Nueva ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}` : `Editar ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}`
|
|
2004
2016
|
] }),
|
|
2005
|
-
|
|
2017
|
+
isViewingDetail && editing && editing.estado !== void 0 && /* @__PURE__ */ jsx("span", { className: `px-2.5 py-1 text-xs font-semibold rounded-full ${String(editing.estado).toLowerCase().includes("terminad") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(editing.estado).toLowerCase().includes("proceso") ? "bg-sky-50 text-sky-700 border border-sky-200" : String(editing.estado).toLowerCase().includes("cancelad") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-amber-50 text-amber-700 border border-amber-200"}`, children: String(editing.estado) }),
|
|
2018
|
+
!isViewingDetail && !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2006
2019
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
|
|
2007
2020
|
/* @__PURE__ */ jsx(
|
|
2008
2021
|
Select,
|
|
@@ -2026,6 +2039,7 @@ function CollectionEditor({ collection }) {
|
|
|
2026
2039
|
setEditing(null);
|
|
2027
2040
|
setOriginalId(null);
|
|
2028
2041
|
setIsCreatingManual(false);
|
|
2042
|
+
setIsViewingDetail(false);
|
|
2029
2043
|
}
|
|
2030
2044
|
},
|
|
2031
2045
|
footer: null,
|
|
@@ -2063,12 +2077,55 @@ function CollectionEditor({ collection }) {
|
|
|
2063
2077
|
}).map((f) => {
|
|
2064
2078
|
const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.type === "signature" || f.type === "date" || f.type === "datetime" || f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "branch-settings" || f.type === "time-range";
|
|
2065
2079
|
const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
|
|
2080
|
+
if (isViewingDetail) {
|
|
2081
|
+
return /* @__PURE__ */ jsxs("div", { className: `block ${colSpanClass}`, children: [
|
|
2082
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: f.label }),
|
|
2083
|
+
f.customRender ? f.customRender({
|
|
2084
|
+
value: editing[f.id],
|
|
2085
|
+
record: editing,
|
|
2086
|
+
onChange: () => {
|
|
2087
|
+
},
|
|
2088
|
+
isCreatingEntry: false
|
|
2089
|
+
}) : f.type === "signature" ? editing[f.id] ? /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-slate-200 bg-white p-3 flex items-center justify-center shadow-sm", children: /* @__PURE__ */ jsx(
|
|
2090
|
+
"img",
|
|
2091
|
+
{
|
|
2092
|
+
src: String(editing[f.id]),
|
|
2093
|
+
alt: f.label,
|
|
2094
|
+
className: "h-28 w-auto max-w-full object-contain"
|
|
2095
|
+
}
|
|
2096
|
+
) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 italic py-1", children: "Sin firma registrada" }) : f.type === "list" ? Array.isArray(editing[f.id]) && editing[f.id].length > 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5 pt-0.5", children: editing[f.id].map((item, idx) => /* @__PURE__ */ jsx(
|
|
2097
|
+
"span",
|
|
2098
|
+
{
|
|
2099
|
+
className: "rounded-full bg-slate-100 text-slate-700 px-3 py-1 text-xs font-medium border border-slate-200",
|
|
2100
|
+
children: String(item)
|
|
2101
|
+
},
|
|
2102
|
+
idx
|
|
2103
|
+
)) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 italic py-1", children: "Ninguno" }) : f.type === "link" ? Boolean(editing[f.id]) ? /* @__PURE__ */ jsxs(
|
|
2104
|
+
"a",
|
|
2105
|
+
{
|
|
2106
|
+
href: String(editing[f.id]),
|
|
2107
|
+
target: "_blank",
|
|
2108
|
+
rel: "noopener noreferrer",
|
|
2109
|
+
className: "inline-flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-800 underline font-medium py-1",
|
|
2110
|
+
children: [
|
|
2111
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5" }),
|
|
2112
|
+
String(editing[f.id]).includes("maps") ? "Ver en Google Maps" : String(editing[f.id])
|
|
2113
|
+
]
|
|
2114
|
+
}
|
|
2115
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-xs text-slate-400 py-1 block", children: "\u2014" }) : f.type === "textarea" ? /* @__PURE__ */ jsx("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2.5 text-sm text-slate-800 whitespace-pre-line leading-relaxed", children: String(editing[f.id] || "\u2014") }) : f.type === "time" || f.id.toLowerCase().includes("hora") || f.id === "inicioServicio" || f.id === "finServicio" ? /* @__PURE__ */ jsx("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2 text-sm text-slate-800 font-medium", children: formatTo12Hour(editing[f.id]) || String(editing[f.id] ?? "\u2014") }) : /* @__PURE__ */ jsx("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2 text-sm text-slate-800 font-medium", children: String(editing[f.id] ?? "\u2014") })
|
|
2116
|
+
] }, f.id);
|
|
2117
|
+
}
|
|
2066
2118
|
return /* @__PURE__ */ jsxs("div", { className: `block ${colSpanClass}`, children: [
|
|
2067
2119
|
/* @__PURE__ */ jsxs("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
|
|
2068
2120
|
f.label,
|
|
2069
2121
|
/* @__PURE__ */ jsx("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
|
|
2070
2122
|
] }),
|
|
2071
|
-
f.
|
|
2123
|
+
f.customRender ? f.customRender({
|
|
2124
|
+
value: editing[f.id],
|
|
2125
|
+
record: editing,
|
|
2126
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
2127
|
+
isCreatingEntry
|
|
2128
|
+
}) : f.type === "branch-settings" ? /* @__PURE__ */ jsx(
|
|
2072
2129
|
BranchSettingsEditor,
|
|
2073
2130
|
{
|
|
2074
2131
|
collectionId: f.collection || "",
|
|
@@ -2610,34 +2667,48 @@ function CollectionEditor({ collection }) {
|
|
|
2610
2667
|
] })
|
|
2611
2668
|
] }, f.id);
|
|
2612
2669
|
}) }) }),
|
|
2613
|
-
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 justify-
|
|
2614
|
-
/* @__PURE__ */ jsx(
|
|
2615
|
-
Button,
|
|
2616
|
-
{
|
|
2617
|
-
size: "large",
|
|
2618
|
-
onClick: () => {
|
|
2619
|
-
setEditing(null);
|
|
2620
|
-
setOriginalId(null);
|
|
2621
|
-
setDuplicateErrors({});
|
|
2622
|
-
setIsCreatingManual(false);
|
|
2623
|
-
},
|
|
2624
|
-
disabled: saving,
|
|
2625
|
-
className: "rounded-xl font-medium",
|
|
2626
|
-
children: t.cancel
|
|
2627
|
-
}
|
|
2628
|
-
),
|
|
2629
|
-
/* @__PURE__ */ jsx(
|
|
2670
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 justify-between items-center border-t border-slate-200 bg-white px-6 py-4", children: [
|
|
2671
|
+
/* @__PURE__ */ jsx("div", { children: isViewingDetail && collection.onDownloadPdf && (!collection.canDownloadPdf || collection.canDownloadPdf(editing)) && /* @__PURE__ */ jsx(
|
|
2630
2672
|
Button,
|
|
2631
2673
|
{
|
|
2632
2674
|
size: "large",
|
|
2633
2675
|
type: "primary",
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
|
|
2676
|
+
icon: /* @__PURE__ */ jsx(FileDown, { className: "w-4 h-4" }),
|
|
2677
|
+
onClick: () => collection.onDownloadPdf?.(editing),
|
|
2678
|
+
className: "rounded-xl font-semibold bg-emerald-600 hover:bg-emerald-500 border-emerald-600 shadow-sm",
|
|
2679
|
+
children: "Descargar PDF"
|
|
2639
2680
|
}
|
|
2640
|
-
)
|
|
2681
|
+
) }),
|
|
2682
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
2683
|
+
/* @__PURE__ */ jsx(
|
|
2684
|
+
Button,
|
|
2685
|
+
{
|
|
2686
|
+
size: "large",
|
|
2687
|
+
onClick: () => {
|
|
2688
|
+
setEditing(null);
|
|
2689
|
+
setOriginalId(null);
|
|
2690
|
+
setDuplicateErrors({});
|
|
2691
|
+
setIsCreatingManual(false);
|
|
2692
|
+
setIsViewingDetail(false);
|
|
2693
|
+
},
|
|
2694
|
+
disabled: saving,
|
|
2695
|
+
className: "rounded-xl font-medium",
|
|
2696
|
+
children: isViewingDetail ? "Cerrar" : t.cancel
|
|
2697
|
+
}
|
|
2698
|
+
),
|
|
2699
|
+
!isViewingDetail && /* @__PURE__ */ jsx(
|
|
2700
|
+
Button,
|
|
2701
|
+
{
|
|
2702
|
+
size: "large",
|
|
2703
|
+
type: "primary",
|
|
2704
|
+
onClick: save,
|
|
2705
|
+
loading: saving,
|
|
2706
|
+
disabled: saving || Object.keys(duplicateErrors).length > 0,
|
|
2707
|
+
className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700 disabled:opacity-50",
|
|
2708
|
+
children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
|
|
2709
|
+
}
|
|
2710
|
+
)
|
|
2711
|
+
] })
|
|
2641
2712
|
] })
|
|
2642
2713
|
] }) })
|
|
2643
2714
|
}
|
|
@@ -2710,14 +2781,38 @@ function CollectionEditor({ collection }) {
|
|
|
2710
2781
|
String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
|
|
2711
2782
|
]
|
|
2712
2783
|
}
|
|
2713
|
-
) : String(e[f.id] ?? "") }, f.id)),
|
|
2714
|
-
/* @__PURE__ */ jsx("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-
|
|
2715
|
-
|
|
2716
|
-
/* @__PURE__ */ jsx(
|
|
2784
|
+
) : f.type === "time" || f.id.toLowerCase().includes("hora") || f.id === "inicioServicio" || f.id === "finServicio" ? formatTo12Hour(e[f.id]) || String(e[f.id] ?? "") : String(e[f.id] ?? "") }, f.id)),
|
|
2785
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-1.5", children: [
|
|
2786
|
+
collection.enableDetailView && /* @__PURE__ */ jsx(
|
|
2717
2787
|
"button",
|
|
2718
2788
|
{
|
|
2719
2789
|
onClick: () => {
|
|
2720
2790
|
setIsCreatingManual(false);
|
|
2791
|
+
setIsViewingDetail(true);
|
|
2792
|
+
setOriginalId(String(e.id || ""));
|
|
2793
|
+
setDuplicateErrors({});
|
|
2794
|
+
setEditing({ ...e });
|
|
2795
|
+
},
|
|
2796
|
+
className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
|
|
2797
|
+
title: "Ver detalle",
|
|
2798
|
+
children: /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" })
|
|
2799
|
+
}
|
|
2800
|
+
),
|
|
2801
|
+
collection.onDownloadPdf && (!collection.canDownloadPdf || collection.canDownloadPdf(e)) && /* @__PURE__ */ jsx(
|
|
2802
|
+
"button",
|
|
2803
|
+
{
|
|
2804
|
+
onClick: () => collection.onDownloadPdf?.(e),
|
|
2805
|
+
className: "p-2 rounded-lg text-slate-400 hover:text-emerald-600 hover:bg-emerald-50 transition-colors",
|
|
2806
|
+
title: "Descargar PDF",
|
|
2807
|
+
children: /* @__PURE__ */ jsx(FileDown, { className: "h-4 w-4" })
|
|
2808
|
+
}
|
|
2809
|
+
),
|
|
2810
|
+
!collection.disableEdit && /* @__PURE__ */ jsx(
|
|
2811
|
+
"button",
|
|
2812
|
+
{
|
|
2813
|
+
onClick: () => {
|
|
2814
|
+
setIsCreatingManual(false);
|
|
2815
|
+
setIsViewingDetail(false);
|
|
2721
2816
|
setOriginalId(String(e.id || ""));
|
|
2722
2817
|
setDuplicateErrors({});
|
|
2723
2818
|
setEditing({ ...e });
|
|
@@ -2727,7 +2822,7 @@ function CollectionEditor({ collection }) {
|
|
|
2727
2822
|
children: /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4" })
|
|
2728
2823
|
}
|
|
2729
2824
|
),
|
|
2730
|
-
/* @__PURE__ */ jsx(
|
|
2825
|
+
!collection.disableDelete && /* @__PURE__ */ jsx(
|
|
2731
2826
|
"button",
|
|
2732
2827
|
{
|
|
2733
2828
|
onClick: () => remove(e.id),
|
package/dist/types.d.mts
CHANGED
|
@@ -62,6 +62,12 @@ interface CollectionField {
|
|
|
62
62
|
colSpan?: 1 | 2 | 6 | 12;
|
|
63
63
|
readOnly?: boolean;
|
|
64
64
|
unique?: boolean;
|
|
65
|
+
customRender?: (props: {
|
|
66
|
+
value: any;
|
|
67
|
+
record: any;
|
|
68
|
+
onChange?: (val: any) => void;
|
|
69
|
+
isCreatingEntry?: boolean;
|
|
70
|
+
}) => React.ReactNode;
|
|
65
71
|
}
|
|
66
72
|
interface CollectionDef {
|
|
67
73
|
id: string;
|
|
@@ -76,6 +82,16 @@ interface CollectionDef {
|
|
|
76
82
|
submitLabel?: string;
|
|
77
83
|
saveLabel?: string;
|
|
78
84
|
isSeparator?: boolean;
|
|
85
|
+
enableDetailView?: boolean;
|
|
86
|
+
disableEdit?: boolean;
|
|
87
|
+
disableDelete?: boolean;
|
|
88
|
+
onDownloadPdf?: (record: any) => void;
|
|
89
|
+
canDownloadPdf?: (record: any) => boolean;
|
|
90
|
+
customRowActions?: (props: {
|
|
91
|
+
record: any;
|
|
92
|
+
openDetail: () => void;
|
|
93
|
+
openEdit: () => void;
|
|
94
|
+
}) => React.ReactNode;
|
|
79
95
|
}
|
|
80
96
|
interface GlobalGroup {
|
|
81
97
|
id: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -62,6 +62,12 @@ interface CollectionField {
|
|
|
62
62
|
colSpan?: 1 | 2 | 6 | 12;
|
|
63
63
|
readOnly?: boolean;
|
|
64
64
|
unique?: boolean;
|
|
65
|
+
customRender?: (props: {
|
|
66
|
+
value: any;
|
|
67
|
+
record: any;
|
|
68
|
+
onChange?: (val: any) => void;
|
|
69
|
+
isCreatingEntry?: boolean;
|
|
70
|
+
}) => React.ReactNode;
|
|
65
71
|
}
|
|
66
72
|
interface CollectionDef {
|
|
67
73
|
id: string;
|
|
@@ -76,6 +82,16 @@ interface CollectionDef {
|
|
|
76
82
|
submitLabel?: string;
|
|
77
83
|
saveLabel?: string;
|
|
78
84
|
isSeparator?: boolean;
|
|
85
|
+
enableDetailView?: boolean;
|
|
86
|
+
disableEdit?: boolean;
|
|
87
|
+
disableDelete?: boolean;
|
|
88
|
+
onDownloadPdf?: (record: any) => void;
|
|
89
|
+
canDownloadPdf?: (record: any) => boolean;
|
|
90
|
+
customRowActions?: (props: {
|
|
91
|
+
record: any;
|
|
92
|
+
openDetail: () => void;
|
|
93
|
+
openEdit: () => void;
|
|
94
|
+
}) => React.ReactNode;
|
|
79
95
|
}
|
|
80
96
|
interface GlobalGroup {
|
|
81
97
|
id: string;
|