admin-lib-cms 1.2.13 → 1.2.15

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 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 = "HH:mm";
1020
- var TIME_DISPLAY_FORMAT = "h:mm A";
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
- !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
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" : String(editing.estado).toLowerCase().includes("vencid") ? "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,
@@ -2776,7 +2788,8 @@ function CollectionEditor({ collection }) {
2776
2788
  { value: "Nueva", label: "Nueva" },
2777
2789
  { value: "Proceso", label: "Proceso" },
2778
2790
  { value: "Terminado", label: "Terminado" },
2779
- { value: "Cancelado", label: "Cancelado" }
2791
+ { value: "Cancelado", label: "Cancelado" },
2792
+ { value: "Vencido", label: "Vencido" }
2780
2793
  ],
2781
2794
  className: "w-32"
2782
2795
  }
@@ -2788,6 +2801,7 @@ function CollectionEditor({ collection }) {
2788
2801
  setEditing(null);
2789
2802
  setOriginalId(null);
2790
2803
  setIsCreatingManual(false);
2804
+ setIsViewingDetail(false);
2791
2805
  }
2792
2806
  },
2793
2807
  footer: null,
@@ -2825,12 +2839,55 @@ function CollectionEditor({ collection }) {
2825
2839
  }).map((f) => {
2826
2840
  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
2841
  const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
2842
+ if (isViewingDetail) {
2843
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
2844
+ /* @__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 }),
2845
+ f.customRender ? f.customRender({
2846
+ value: editing[f.id],
2847
+ record: editing,
2848
+ onChange: () => {
2849
+ },
2850
+ isCreatingEntry: false
2851
+ }) : 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)(
2852
+ "img",
2853
+ {
2854
+ src: String(editing[f.id]),
2855
+ alt: f.label,
2856
+ className: "h-28 w-auto max-w-full object-contain"
2857
+ }
2858
+ ) }) : /* @__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)(
2859
+ "span",
2860
+ {
2861
+ className: "rounded-full bg-slate-100 text-slate-700 px-3 py-1 text-xs font-medium border border-slate-200",
2862
+ children: String(item)
2863
+ },
2864
+ idx
2865
+ )) }) : /* @__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)(
2866
+ "a",
2867
+ {
2868
+ href: String(editing[f.id]),
2869
+ target: "_blank",
2870
+ rel: "noopener noreferrer",
2871
+ className: "inline-flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-800 underline font-medium py-1",
2872
+ children: [
2873
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5" }),
2874
+ String(editing[f.id]).includes("maps") ? "Ver en Google Maps" : String(editing[f.id])
2875
+ ]
2876
+ }
2877
+ ) : /* @__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") })
2878
+ ] }, f.id);
2879
+ }
2828
2880
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
2829
2881
  /* @__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
2882
  f.label,
2831
2883
  /* @__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
2884
  ] }),
2833
- f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2885
+ f.customRender ? f.customRender({
2886
+ value: editing[f.id],
2887
+ record: editing,
2888
+ onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2889
+ isCreatingEntry
2890
+ }) : f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2834
2891
  BranchSettingsEditor,
2835
2892
  {
2836
2893
  collectionId: f.collection || "",
@@ -3372,34 +3429,48 @@ function CollectionEditor({ collection }) {
3372
3429
  ] })
3373
3430
  ] }, f.id);
3374
3431
  }) }) }),
3375
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex shrink-0 justify-end gap-3 border-t border-slate-200 bg-white px-6 py-4", children: [
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)(
3432
+ /* @__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: [
3433
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: isViewingDetail && collection.onDownloadPdf && (!collection.canDownloadPdf || collection.canDownloadPdf(editing)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3392
3434
  import_antd.Button,
3393
3435
  {
3394
3436
  size: "large",
3395
3437
  type: "primary",
3396
- onClick: save,
3397
- loading: saving,
3398
- disabled: saving || Object.keys(duplicateErrors).length > 0,
3399
- className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700 disabled:opacity-50",
3400
- children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
3438
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileDown, { className: "w-4 h-4" }),
3439
+ onClick: () => collection.onDownloadPdf?.(editing),
3440
+ className: "rounded-xl font-semibold bg-emerald-600 hover:bg-emerald-500 border-emerald-600 shadow-sm",
3441
+ children: "Descargar PDF"
3401
3442
  }
3402
- )
3443
+ ) }),
3444
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
3445
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3446
+ import_antd.Button,
3447
+ {
3448
+ size: "large",
3449
+ onClick: () => {
3450
+ setEditing(null);
3451
+ setOriginalId(null);
3452
+ setDuplicateErrors({});
3453
+ setIsCreatingManual(false);
3454
+ setIsViewingDetail(false);
3455
+ },
3456
+ disabled: saving,
3457
+ className: "rounded-xl font-medium",
3458
+ children: isViewingDetail ? "Cerrar" : t.cancel
3459
+ }
3460
+ ),
3461
+ !isViewingDetail && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3462
+ import_antd.Button,
3463
+ {
3464
+ size: "large",
3465
+ type: "primary",
3466
+ onClick: save,
3467
+ loading: saving,
3468
+ disabled: saving || Object.keys(duplicateErrors).length > 0,
3469
+ className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700 disabled:opacity-50",
3470
+ children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
3471
+ }
3472
+ )
3473
+ ] })
3403
3474
  ] })
3404
3475
  ] }) })
3405
3476
  }
@@ -3457,7 +3528,7 @@ function CollectionEditor({ collection }) {
3457
3528
  onDragEnd,
3458
3529
  className: `hover:bg-slate-50/50 transition-colors group cursor-grab active:cursor-grabbing ${deletingId === e.id ? "opacity-50" : ""} ${dragOverIdx === idx ? "border-t-2 border-t-indigo-500" : ""}`,
3459
3530
  children: [
3460
- visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold ${String(e[f.id]) === "Terminado" || String(e[f.id]) === "Terminada" || String(e[f.id]).includes("Entregado") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(e[f.id]) === "Proceso" || String(e[f.id]).includes("Preparaci\xF3n") ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes("Cancelado") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-blue-50 text-blue-700 border border-blue-200"}`, children: String(e[f.id]) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? e.clienteNombre && f.id === "clienteId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.clienteNombre) }) : e.empleadoNombre && f.id === "empleadoId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.empleadoNombre) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Image, { src: String(e[f.id]), alt: "Firma", className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer", preview: { mask: "Ver" } }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
3531
+ visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold ${String(e[f.id]) === "Terminado" || String(e[f.id]) === "Terminada" || String(e[f.id]).includes("Entregado") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(e[f.id]) === "Proceso" || String(e[f.id]).includes("Preparaci\xF3n") ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes("Cancelado") ? "bg-slate-100 text-slate-700 border border-slate-200" : String(e[f.id]) === "Vencido" || String(e[f.id]).toLowerCase().includes("vencid") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-blue-50 text-blue-700 border border-blue-200"}`, children: String(e[f.id]) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? e.clienteNombre && f.id === "clienteId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.clienteNombre) }) : e.empleadoNombre && f.id === "empleadoId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.empleadoNombre) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Image, { src: String(e[f.id]), alt: "Firma", className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer", preview: { mask: "Ver" } }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
3461
3532
  "$ ",
3462
3533
  Number(e[f.id]).toLocaleString("es-CO")
3463
3534
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) : f.type === "link" || typeof e[f.id] === "string" && String(e[f.id]).startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
@@ -3472,14 +3543,38 @@ function CollectionEditor({ collection }) {
3472
3543
  String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
3473
3544
  ]
3474
3545
  }
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-2", children: [
3477
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "p-2 text-slate-300 cursor-grab active:cursor-grabbing", title: "Drag to reorder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "w-4 h-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M5.5 3C6.32843 3 7 3.67157 7 4.5C7 5.32843 6.32843 6 5.5 6C4.67157 6 4 5.32843 4 4.5C4 3.67157 4.67157 3 5.5 3ZM9.5 3C10.3284 3 11 3.67157 11 4.5C11 5.32843 10.3284 6 9.5 6C8.67157 6 8 5.32843 8 4.5C8 3.67157 8.67157 3 9.5 3ZM5.5 7.5C6.32843 7.5 7 8.17157 7 9C7 9.82843 6.32843 10.5 5.5 10.5C4.67157 10.5 4 9.82843 4 9C4 8.17157 4.67157 7.5 5.5 7.5ZM9.5 7.5C10.3284 7.5 11 8.17157 11 9C11 9.82843 10.3284 10.5 9.5 10.5C8.67157 10.5 8 9.82843 8 9C8 8.17157 8.67157 7.5 9.5 7.5ZM5.5 12C6.32843 12 7 12.6716 7 13.5C7 14.3284 6.32843 15 5.5 15C4.67157 15 4 14.3284 4 13.5C4 12.6716 4.67157 12 5.5 12ZM9.5 12C10.3284 12 11 12.6716 11 13.5C11 14.3284 10.3284 15 9.5 15C8.67157 15 8 14.3284 8 13.5C8 12.6716 8.67157 12 9.5 12Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) }),
3478
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3546
+ ) : 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)),
3547
+ /* @__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: [
3548
+ collection.enableDetailView && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3479
3549
  "button",
3480
3550
  {
3481
3551
  onClick: () => {
3482
3552
  setIsCreatingManual(false);
3553
+ setIsViewingDetail(true);
3554
+ setOriginalId(String(e.id || ""));
3555
+ setDuplicateErrors({});
3556
+ setEditing({ ...e });
3557
+ },
3558
+ className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
3559
+ title: "Ver detalle",
3560
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Eye, { className: "h-4 w-4" })
3561
+ }
3562
+ ),
3563
+ collection.onDownloadPdf && (!collection.canDownloadPdf || collection.canDownloadPdf(e)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3564
+ "button",
3565
+ {
3566
+ onClick: () => collection.onDownloadPdf?.(e),
3567
+ className: "p-2 rounded-lg text-slate-400 hover:text-emerald-600 hover:bg-emerald-50 transition-colors",
3568
+ title: "Descargar PDF",
3569
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileDown, { className: "h-4 w-4" })
3570
+ }
3571
+ ),
3572
+ !collection.disableEdit && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3573
+ "button",
3574
+ {
3575
+ onClick: () => {
3576
+ setIsCreatingManual(false);
3577
+ setIsViewingDetail(false);
3483
3578
  setOriginalId(String(e.id || ""));
3484
3579
  setDuplicateErrors({});
3485
3580
  setEditing({ ...e });
@@ -3489,7 +3584,7 @@ function CollectionEditor({ collection }) {
3489
3584
  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4" })
3490
3585
  }
3491
3586
  ),
3492
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3587
+ !collection.disableDelete && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3493
3588
  "button",
3494
3589
  {
3495
3590
  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 = "HH:mm";
258
- var TIME_DISPLAY_FORMAT = "h:mm A";
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
- !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
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" : String(editing.estado).toLowerCase().includes("vencid") ? "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,
@@ -2014,7 +2027,8 @@ function CollectionEditor({ collection }) {
2014
2027
  { value: "Nueva", label: "Nueva" },
2015
2028
  { value: "Proceso", label: "Proceso" },
2016
2029
  { value: "Terminado", label: "Terminado" },
2017
- { value: "Cancelado", label: "Cancelado" }
2030
+ { value: "Cancelado", label: "Cancelado" },
2031
+ { value: "Vencido", label: "Vencido" }
2018
2032
  ],
2019
2033
  className: "w-32"
2020
2034
  }
@@ -2026,6 +2040,7 @@ function CollectionEditor({ collection }) {
2026
2040
  setEditing(null);
2027
2041
  setOriginalId(null);
2028
2042
  setIsCreatingManual(false);
2043
+ setIsViewingDetail(false);
2029
2044
  }
2030
2045
  },
2031
2046
  footer: null,
@@ -2063,12 +2078,55 @@ function CollectionEditor({ collection }) {
2063
2078
  }).map((f) => {
2064
2079
  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
2080
  const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
2081
+ if (isViewingDetail) {
2082
+ return /* @__PURE__ */ jsxs("div", { className: `block ${colSpanClass}`, children: [
2083
+ /* @__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 }),
2084
+ f.customRender ? f.customRender({
2085
+ value: editing[f.id],
2086
+ record: editing,
2087
+ onChange: () => {
2088
+ },
2089
+ isCreatingEntry: false
2090
+ }) : 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(
2091
+ "img",
2092
+ {
2093
+ src: String(editing[f.id]),
2094
+ alt: f.label,
2095
+ className: "h-28 w-auto max-w-full object-contain"
2096
+ }
2097
+ ) }) : /* @__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(
2098
+ "span",
2099
+ {
2100
+ className: "rounded-full bg-slate-100 text-slate-700 px-3 py-1 text-xs font-medium border border-slate-200",
2101
+ children: String(item)
2102
+ },
2103
+ idx
2104
+ )) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 italic py-1", children: "Ninguno" }) : f.type === "link" ? Boolean(editing[f.id]) ? /* @__PURE__ */ jsxs(
2105
+ "a",
2106
+ {
2107
+ href: String(editing[f.id]),
2108
+ target: "_blank",
2109
+ rel: "noopener noreferrer",
2110
+ className: "inline-flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-800 underline font-medium py-1",
2111
+ children: [
2112
+ /* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5" }),
2113
+ String(editing[f.id]).includes("maps") ? "Ver en Google Maps" : String(editing[f.id])
2114
+ ]
2115
+ }
2116
+ ) : /* @__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") })
2117
+ ] }, f.id);
2118
+ }
2066
2119
  return /* @__PURE__ */ jsxs("div", { className: `block ${colSpanClass}`, children: [
2067
2120
  /* @__PURE__ */ jsxs("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
2068
2121
  f.label,
2069
2122
  /* @__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
2123
  ] }),
2071
- f.type === "branch-settings" ? /* @__PURE__ */ jsx(
2124
+ f.customRender ? f.customRender({
2125
+ value: editing[f.id],
2126
+ record: editing,
2127
+ onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2128
+ isCreatingEntry
2129
+ }) : f.type === "branch-settings" ? /* @__PURE__ */ jsx(
2072
2130
  BranchSettingsEditor,
2073
2131
  {
2074
2132
  collectionId: f.collection || "",
@@ -2610,34 +2668,48 @@ function CollectionEditor({ collection }) {
2610
2668
  ] })
2611
2669
  ] }, f.id);
2612
2670
  }) }) }),
2613
- /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 justify-end gap-3 border-t border-slate-200 bg-white px-6 py-4", children: [
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(
2671
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 justify-between items-center border-t border-slate-200 bg-white px-6 py-4", children: [
2672
+ /* @__PURE__ */ jsx("div", { children: isViewingDetail && collection.onDownloadPdf && (!collection.canDownloadPdf || collection.canDownloadPdf(editing)) && /* @__PURE__ */ jsx(
2630
2673
  Button,
2631
2674
  {
2632
2675
  size: "large",
2633
2676
  type: "primary",
2634
- onClick: save,
2635
- loading: saving,
2636
- disabled: saving || Object.keys(duplicateErrors).length > 0,
2637
- className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700 disabled:opacity-50",
2638
- children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
2677
+ icon: /* @__PURE__ */ jsx(FileDown, { className: "w-4 h-4" }),
2678
+ onClick: () => collection.onDownloadPdf?.(editing),
2679
+ className: "rounded-xl font-semibold bg-emerald-600 hover:bg-emerald-500 border-emerald-600 shadow-sm",
2680
+ children: "Descargar PDF"
2639
2681
  }
2640
- )
2682
+ ) }),
2683
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2684
+ /* @__PURE__ */ jsx(
2685
+ Button,
2686
+ {
2687
+ size: "large",
2688
+ onClick: () => {
2689
+ setEditing(null);
2690
+ setOriginalId(null);
2691
+ setDuplicateErrors({});
2692
+ setIsCreatingManual(false);
2693
+ setIsViewingDetail(false);
2694
+ },
2695
+ disabled: saving,
2696
+ className: "rounded-xl font-medium",
2697
+ children: isViewingDetail ? "Cerrar" : t.cancel
2698
+ }
2699
+ ),
2700
+ !isViewingDetail && /* @__PURE__ */ jsx(
2701
+ Button,
2702
+ {
2703
+ size: "large",
2704
+ type: "primary",
2705
+ onClick: save,
2706
+ loading: saving,
2707
+ disabled: saving || Object.keys(duplicateErrors).length > 0,
2708
+ className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700 disabled:opacity-50",
2709
+ children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
2710
+ }
2711
+ )
2712
+ ] })
2641
2713
  ] })
2642
2714
  ] }) })
2643
2715
  }
@@ -2695,7 +2767,7 @@ function CollectionEditor({ collection }) {
2695
2767
  onDragEnd,
2696
2768
  className: `hover:bg-slate-50/50 transition-colors group cursor-grab active:cursor-grabbing ${deletingId === e.id ? "opacity-50" : ""} ${dragOverIdx === idx ? "border-t-2 border-t-indigo-500" : ""}`,
2697
2769
  children: [
2698
- visibleFields.map((f) => /* @__PURE__ */ jsx("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ jsx(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ jsx("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ jsx("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ jsx("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ jsx("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ jsx("span", { className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold ${String(e[f.id]) === "Terminado" || String(e[f.id]) === "Terminada" || String(e[f.id]).includes("Entregado") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(e[f.id]) === "Proceso" || String(e[f.id]).includes("Preparaci\xF3n") ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes("Cancelado") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-blue-50 text-blue-700 border border-blue-200"}`, children: String(e[f.id]) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? e.clienteNombre && f.id === "clienteId" ? /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-800", children: String(e.clienteNombre) }) : e.empleadoNombre && f.id === "empleadoId" ? /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-800", children: String(e.empleadoNombre) }) : /* @__PURE__ */ jsx(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ jsx(Image, { src: String(e[f.id]), alt: "Firma", className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer", preview: { mask: "Ver" } }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ jsxs("span", { className: "font-semibold text-slate-800", children: [
2770
+ visibleFields.map((f) => /* @__PURE__ */ jsx("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ jsx(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ jsx("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ jsx("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ jsx("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ jsx("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ jsx("span", { className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold ${String(e[f.id]) === "Terminado" || String(e[f.id]) === "Terminada" || String(e[f.id]).includes("Entregado") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(e[f.id]) === "Proceso" || String(e[f.id]).includes("Preparaci\xF3n") ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes("Cancelado") ? "bg-slate-100 text-slate-700 border border-slate-200" : String(e[f.id]) === "Vencido" || String(e[f.id]).toLowerCase().includes("vencid") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-blue-50 text-blue-700 border border-blue-200"}`, children: String(e[f.id]) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? e.clienteNombre && f.id === "clienteId" ? /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-800", children: String(e.clienteNombre) }) : e.empleadoNombre && f.id === "empleadoId" ? /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-800", children: String(e.empleadoNombre) }) : /* @__PURE__ */ jsx(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ jsx(Image, { src: String(e[f.id]), alt: "Firma", className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer", preview: { mask: "Ver" } }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ jsxs("span", { className: "font-semibold text-slate-800", children: [
2699
2771
  "$ ",
2700
2772
  Number(e[f.id]).toLocaleString("es-CO")
2701
2773
  ] }) : /* @__PURE__ */ jsx("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) : f.type === "link" || typeof e[f.id] === "string" && String(e[f.id]).startsWith("http") ? /* @__PURE__ */ jsxs(
@@ -2710,14 +2782,38 @@ function CollectionEditor({ collection }) {
2710
2782
  String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
2711
2783
  ]
2712
2784
  }
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-2", children: [
2715
- /* @__PURE__ */ jsx("div", { className: "p-2 text-slate-300 cursor-grab active:cursor-grabbing", title: "Drag to reorder", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "w-4 h-4", children: /* @__PURE__ */ jsx("path", { d: "M5.5 3C6.32843 3 7 3.67157 7 4.5C7 5.32843 6.32843 6 5.5 6C4.67157 6 4 5.32843 4 4.5C4 3.67157 4.67157 3 5.5 3ZM9.5 3C10.3284 3 11 3.67157 11 4.5C11 5.32843 10.3284 6 9.5 6C8.67157 6 8 5.32843 8 4.5C8 3.67157 8.67157 3 9.5 3ZM5.5 7.5C6.32843 7.5 7 8.17157 7 9C7 9.82843 6.32843 10.5 5.5 10.5C4.67157 10.5 4 9.82843 4 9C4 8.17157 4.67157 7.5 5.5 7.5ZM9.5 7.5C10.3284 7.5 11 8.17157 11 9C11 9.82843 10.3284 10.5 9.5 10.5C8.67157 10.5 8 9.82843 8 9C8 8.17157 8.67157 7.5 9.5 7.5ZM5.5 12C6.32843 12 7 12.6716 7 13.5C7 14.3284 6.32843 15 5.5 15C4.67157 15 4 14.3284 4 13.5C4 12.6716 4.67157 12 5.5 12ZM9.5 12C10.3284 12 11 12.6716 11 13.5C11 14.3284 10.3284 15 9.5 15C8.67157 15 8 14.3284 8 13.5C8 12.6716 8.67157 12 9.5 12Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) }),
2716
- /* @__PURE__ */ jsx(
2785
+ ) : 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)),
2786
+ /* @__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: [
2787
+ collection.enableDetailView && /* @__PURE__ */ jsx(
2717
2788
  "button",
2718
2789
  {
2719
2790
  onClick: () => {
2720
2791
  setIsCreatingManual(false);
2792
+ setIsViewingDetail(true);
2793
+ setOriginalId(String(e.id || ""));
2794
+ setDuplicateErrors({});
2795
+ setEditing({ ...e });
2796
+ },
2797
+ className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
2798
+ title: "Ver detalle",
2799
+ children: /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" })
2800
+ }
2801
+ ),
2802
+ collection.onDownloadPdf && (!collection.canDownloadPdf || collection.canDownloadPdf(e)) && /* @__PURE__ */ jsx(
2803
+ "button",
2804
+ {
2805
+ onClick: () => collection.onDownloadPdf?.(e),
2806
+ className: "p-2 rounded-lg text-slate-400 hover:text-emerald-600 hover:bg-emerald-50 transition-colors",
2807
+ title: "Descargar PDF",
2808
+ children: /* @__PURE__ */ jsx(FileDown, { className: "h-4 w-4" })
2809
+ }
2810
+ ),
2811
+ !collection.disableEdit && /* @__PURE__ */ jsx(
2812
+ "button",
2813
+ {
2814
+ onClick: () => {
2815
+ setIsCreatingManual(false);
2816
+ setIsViewingDetail(false);
2721
2817
  setOriginalId(String(e.id || ""));
2722
2818
  setDuplicateErrors({});
2723
2819
  setEditing({ ...e });
@@ -2727,7 +2823,7 @@ function CollectionEditor({ collection }) {
2727
2823
  children: /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4" })
2728
2824
  }
2729
2825
  ),
2730
- /* @__PURE__ */ jsx(
2826
+ !collection.disableDelete && /* @__PURE__ */ jsx(
2731
2827
  "button",
2732
2828
  {
2733
2829
  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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admin-lib-cms",
3
- "version": "1.2.13",
3
+ "version": "1.2.15",
4
4
  "description": "Agnostic Admin CMS Library",
5
5
  "keywords": [
6
6
  "cms",