admin-lib-cms 1.2.18 → 1.2.19

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.mjs CHANGED
@@ -22,7 +22,14 @@ import {
22
22
  } from "./chunk-4KJKAYIC.mjs";
23
23
 
24
24
  // src/admin/AdminApp.tsx
25
- import React, { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
25
+ import React, {
26
+ createElement,
27
+ useCallback,
28
+ useEffect,
29
+ useMemo,
30
+ useRef,
31
+ useState
32
+ } from "react";
26
33
  import { createPortal } from "react-dom";
27
34
  import {
28
35
  ConfigProvider,
@@ -126,7 +133,15 @@ function findExistingEntry(item, existingEntries, collection) {
126
133
  }
127
134
  return null;
128
135
  }
129
- function formatValueForExport(val, field) {
136
+ function formatValueForExport(val, field, entry) {
137
+ if (field?.formatExport && typeof field.formatExport === "function") {
138
+ try {
139
+ const res = field.formatExport(val, entry);
140
+ if (res !== void 0 && res !== null) return res;
141
+ } catch (e) {
142
+ console.error("Error en formatExport:", e);
143
+ }
144
+ }
130
145
  if (val === void 0 || val === null) return "";
131
146
  if (typeof val === "number" || typeof val === "boolean") return val;
132
147
  if (Array.isArray(val)) {
@@ -156,7 +171,7 @@ function exportCollectionToExcel(collection, entries, fileNamePrefix) {
156
171
  const rowObj = {};
157
172
  columns.forEach((col) => {
158
173
  const rawVal = entry[col.key];
159
- rowObj[col.label] = formatValueForExport(rawVal, col.field);
174
+ rowObj[col.label] = formatValueForExport(rawVal, col.field, entry);
160
175
  });
161
176
  return rowObj;
162
177
  });
@@ -524,12 +539,13 @@ function getAdminTranslations(locale) {
524
539
  // src/admin/AdminApp.tsx
525
540
  import { CreditCard, BarChart3 } from "lucide-react";
526
541
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
527
- var AdminI18nContext = React.createContext(getAdminTranslations("en"));
542
+ var AdminI18nContext = React.createContext(
543
+ getAdminTranslations("en")
544
+ );
528
545
  function useAdminI18n() {
529
546
  return React.useContext(AdminI18nContext);
530
547
  }
531
548
  var TIME_STORAGE_FORMAT = "h:mm a";
532
- var TIME_DISPLAY_FORMAT = "h:mm a";
533
549
  var TIME_PICKER_THEME = {
534
550
  token: {
535
551
  borderRadius: 12,
@@ -555,6 +571,21 @@ var TIME_PICKER_THEME = {
555
571
  }
556
572
  }
557
573
  };
574
+ function parseCurrencyInput(value, locale) {
575
+ if (!value) return 0;
576
+ const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
577
+ const groupSeparator = parts.find((part) => part.type === "group")?.value;
578
+ const decimalSeparator = parts.find((part) => part.type === "decimal")?.value;
579
+ let normalized = value;
580
+ if (groupSeparator) {
581
+ normalized = normalized.split(groupSeparator).join("");
582
+ }
583
+ if (decimalSeparator && decimalSeparator !== ".") {
584
+ normalized = normalized.split(decimalSeparator).join(".");
585
+ }
586
+ const parsed = Number(normalized.replace(/[^\d.-]/g, ""));
587
+ return Number.isFinite(parsed) ? parsed : 0;
588
+ }
558
589
  function AdminTimeRangePicker(props) {
559
590
  return /* @__PURE__ */ jsx(ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ jsx(
560
591
  TimePicker.RangePicker,
@@ -584,7 +615,13 @@ function toDayjsTime(value) {
584
615
  if (match24) {
585
616
  return dayjs2().hour(Number(match24[1])).minute(Number(match24[2])).second(0).millisecond(0);
586
617
  }
587
- const parsed = dayjs2(str, ["h:mm a", "h:mm A", "hh:mm a", "hh:mm A", "HH:mm"]);
618
+ const parsed = dayjs2(str, [
619
+ "h:mm a",
620
+ "h:mm A",
621
+ "hh:mm a",
622
+ "hh:mm A",
623
+ "HH:mm"
624
+ ]);
588
625
  return parsed.isValid() ? parsed : null;
589
626
  }
590
627
  function toStoredTime(value) {
@@ -651,7 +688,15 @@ function FilePickerButton({
651
688
  function AdminApp(props) {
652
689
  const content = /* @__PURE__ */ jsx(App, { className: "min-h-screen", children: /* @__PURE__ */ jsx(AdminAppContent, { ...props }) });
653
690
  if (props.projectId) {
654
- return /* @__PURE__ */ jsx(SubscriptionProvider, { apiUrl: props.apiUrl, projectId: props.projectId, email: props.email, children: content });
691
+ return /* @__PURE__ */ jsx(
692
+ SubscriptionProvider,
693
+ {
694
+ apiUrl: props.apiUrl,
695
+ projectId: props.projectId,
696
+ email: props.email,
697
+ children: content
698
+ }
699
+ );
655
700
  }
656
701
  return content;
657
702
  }
@@ -660,7 +705,9 @@ function AdminAppContent(props) {
660
705
  const rawLocale = props.locale ?? props.lang ?? ctx.config.locale ?? ctx.config.lang ?? "en";
661
706
  const t = useMemo(() => getAdminTranslations(rawLocale), [rawLocale]);
662
707
  const hasDashboard = Boolean(props.dashboard);
663
- const [section, setSection] = useState(hasDashboard ? "dashboard" : "pages");
708
+ const [section, setSection] = useState(
709
+ hasDashboard ? "dashboard" : "pages"
710
+ );
664
711
  const [authChecking, setAuthChecking] = useState(true);
665
712
  const [authenticated, setAuthenticated] = useState(false);
666
713
  const hideSettings = props.hideSettings ?? ctx.config.hideSettings ?? false;
@@ -715,13 +762,27 @@ function AdminAppContent(props) {
715
762
  daysOverdue > 15 && daysOverdue < 30 && /* @__PURE__ */ jsx("div", { className: "bg-rose-600 text-white px-4 py-2.5 text-center text-sm font-bold shadow-sm z-50", children: "Attention: If you do not settle your balance, your account will be suspended soon." }),
716
763
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
717
764
  /* @__PURE__ */ jsx("div", { className: "lg:hidden flex items-center justify-between bg-white/80 backdrop-blur-xl border-b border-slate-200 px-4 py-3 shrink-0 z-20 relative", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
718
- ctx.overrides?.["global-logo"] ? /* @__PURE__ */ jsx("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
765
+ ctx.overrides?.["global-logo"] ? /* @__PURE__ */ jsx(
766
+ "img",
767
+ {
768
+ src: String(ctx.overrides["global-logo"]),
769
+ alt: "Logo",
770
+ className: "h-5 w-auto object-contain"
771
+ }
772
+ ) : /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
719
773
  /* @__PURE__ */ jsx("div", { className: "font-bold text-slate-900 tracking-tight", children: "Admin CMS" })
720
774
  ] }) }),
721
775
  /* @__PURE__ */ jsxs("aside", { className: "flex w-full lg:w-64 shrink-0 flex-col border-b lg:border-b-0 lg:border-r border-slate-200 bg-white/80 backdrop-blur-xl shadow-sm z-10 overflow-hidden", children: [
722
776
  /* @__PURE__ */ jsxs("div", { className: "hidden lg:block border-b border-slate-200 px-6 py-5 bg-white/50", children: [
723
777
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-1", children: [
724
- ctx.overrides?.["global-logo"] ? /* @__PURE__ */ jsx("img", { src: String(ctx.overrides["global-logo"]), alt: "Logo", className: "h-5 w-auto object-contain" }) : /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
778
+ ctx.overrides?.["global-logo"] ? /* @__PURE__ */ jsx(
779
+ "img",
780
+ {
781
+ src: String(ctx.overrides["global-logo"]),
782
+ alt: "Logo",
783
+ className: "h-5 w-auto object-contain"
784
+ }
785
+ ) : /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
725
786
  /* @__PURE__ */ jsx("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: "Admin CMS" })
726
787
  ] }),
727
788
  /* @__PURE__ */ jsx("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
@@ -858,7 +919,9 @@ function AdminAppContent(props) {
858
919
  });
859
920
  } else {
860
921
  const topCustom = (props.customSections || []).filter((cs) => cs.position === "top").map((cs) => cs.id);
861
- const bottomCustom = (props.customSections || []).filter((cs) => cs.position === "bottom" || cs.position === "after-collections").map((cs) => cs.id);
922
+ const bottomCustom = (props.customSections || []).filter(
923
+ (cs) => cs.position === "bottom" || cs.position === "after-collections"
924
+ ).map((cs) => cs.id);
862
925
  const otherCustom = (props.customSections || []).filter(
863
926
  (cs) => cs.position !== "top" && cs.position !== "bottom" && cs.position !== "after-collections"
864
927
  ).map((cs) => cs.id);
@@ -879,7 +942,9 @@ function AdminAppContent(props) {
879
942
  "button",
880
943
  {
881
944
  onClick: async () => {
882
- await fetch("/api/admin/auth?action=logout", { method: "POST" });
945
+ await fetch("/api/admin/auth?action=logout", {
946
+ method: "POST"
947
+ });
883
948
  window.location.href = "/admin/login";
884
949
  },
885
950
  className: "flex items-center justify-center gap-2 w-full px-3 py-2 text-sm font-medium text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",
@@ -966,16 +1031,22 @@ function PageListItem({
966
1031
  ] })
967
1032
  }
968
1033
  ) }),
969
- hasChildren && expanded && /* @__PURE__ */ jsx("ul", { className: `mt-1 space-y-1 ${depth === 0 ? "ml-4 border-l-2 border-slate-100 pl-1" : "ml-2"}`, children: p.children.map((child) => /* @__PURE__ */ jsx(
970
- PageListItem,
1034
+ hasChildren && expanded && /* @__PURE__ */ jsx(
1035
+ "ul",
971
1036
  {
972
- p: child,
973
- selected,
974
- onSelect,
975
- depth: depth + 1
976
- },
977
- child.id
978
- )) })
1037
+ className: `mt-1 space-y-1 ${depth === 0 ? "ml-4 border-l-2 border-slate-100 pl-1" : "ml-2"}`,
1038
+ children: p.children.map((child) => /* @__PURE__ */ jsx(
1039
+ PageListItem,
1040
+ {
1041
+ p: child,
1042
+ selected,
1043
+ onSelect,
1044
+ depth: depth + 1
1045
+ },
1046
+ child.id
1047
+ ))
1048
+ }
1049
+ )
979
1050
  ] });
980
1051
  }
981
1052
  function PagesSection() {
@@ -1010,14 +1081,20 @@ function PagesSection() {
1010
1081
  ) : /* @__PURE__ */ jsx("div", { className: "grid h-full place-items-center text-sm text-slate-500", children: "Select a page to edit its content." }) })
1011
1082
  ] });
1012
1083
  }
1013
- function PageEditor({ page, showList, onToggleList }) {
1084
+ function PageEditor({
1085
+ page,
1086
+ showList,
1087
+ onToggleList
1088
+ }) {
1014
1089
  const ctx = useCmsContext();
1015
1090
  const t = useAdminI18n();
1016
1091
  const iframeRef = useRef(null);
1017
1092
  const [registered, setRegistered] = useState([]);
1018
1093
  const [selectedId, setSelectedId] = useState(null);
1019
1094
  const [preview, setPreview] = useState(false);
1020
- const [drawerState, setDrawerState] = useState("half");
1095
+ const [drawerState, setDrawerState] = useState(
1096
+ "half"
1097
+ );
1021
1098
  const src = useMemo(
1022
1099
  () => `${page.path}${preview ? "" : "?__cms=edit"}`,
1023
1100
  [page.path, preview]
@@ -1036,7 +1113,11 @@ function PageEditor({ page, showList, onToggleList }) {
1036
1113
  }
1037
1114
  } else if (d.type === "cms:ready") {
1038
1115
  iframeRef.current?.contentWindow?.postMessage(
1039
- { __cms: true, type: "cms:set-all-overrides", overrides: ctx.overrides },
1116
+ {
1117
+ __cms: true,
1118
+ type: "cms:set-all-overrides",
1119
+ overrides: ctx.overrides
1120
+ },
1040
1121
  "*"
1041
1122
  );
1042
1123
  }
@@ -1059,20 +1140,54 @@ function PageEditor({ page, showList, onToggleList }) {
1059
1140
  [ctx]
1060
1141
  );
1061
1142
  const selectedMeta = registered.find((r) => r.id === selectedId) ?? null;
1062
- const [viewMode, setViewMode] = useState("desktop");
1143
+ const [viewMode, setViewMode] = useState(
1144
+ "desktop"
1145
+ );
1063
1146
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col", children: [
1064
1147
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 border-b border-slate-200 bg-white/80 backdrop-blur px-4 py-3 shadow-sm z-10 shrink-0", children: [
1065
1148
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm shrink-0", children: [
1066
- /* @__PURE__ */ jsx("button", { onClick: onToggleList, className: "text-slate-400 hover:text-slate-700 p-1 hidden lg:block", title: "Toggle Pages Menu", children: showList ? /* @__PURE__ */ jsx(PanelLeftClose, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(PanelLeftOpen, { className: "w-5 h-5" }) }),
1149
+ /* @__PURE__ */ jsx(
1150
+ "button",
1151
+ {
1152
+ onClick: onToggleList,
1153
+ className: "text-slate-400 hover:text-slate-700 p-1 hidden lg:block",
1154
+ title: "Toggle Pages Menu",
1155
+ children: showList ? /* @__PURE__ */ jsx(PanelLeftClose, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(PanelLeftOpen, { className: "w-5 h-5" })
1156
+ }
1157
+ ),
1067
1158
  /* @__PURE__ */ jsx("span", { className: "font-bold text-slate-800 text-sm md:text-base", children: page.name }),
1068
1159
  /* @__PURE__ */ jsx("span", { className: "text-slate-300 hidden sm:inline", children: "|" }),
1069
1160
  /* @__PURE__ */ jsx("span", { className: "text-slate-500 font-mono text-[10px] md:text-xs bg-slate-100 px-2 py-1 rounded hidden sm:inline-block", children: page.path })
1070
1161
  ] }),
1071
1162
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 overflow-x-auto w-full sm:w-auto pb-1 sm:pb-0 hide-scrollbar shrink-0", children: [
1072
1163
  /* @__PURE__ */ jsxs("div", { className: "flex bg-slate-100/80 p-0.5 rounded-lg mr-2 shrink-0", children: [
1073
- /* @__PURE__ */ jsx("button", { onClick: () => setViewMode("desktop"), className: `p-1.5 rounded-md transition-all ${viewMode === "desktop" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`, title: "Desktop View", children: /* @__PURE__ */ jsx(Monitor, { className: "w-4 h-4" }) }),
1074
- /* @__PURE__ */ jsx("button", { onClick: () => setViewMode("tablet"), className: `p-1.5 rounded-md transition-all ${viewMode === "tablet" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`, title: "Tablet View", children: /* @__PURE__ */ jsx(Tablet, { className: "w-4 h-4" }) }),
1075
- /* @__PURE__ */ jsx("button", { onClick: () => setViewMode("mobile"), className: `p-1.5 rounded-md transition-all ${viewMode === "mobile" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`, title: "Mobile View", children: /* @__PURE__ */ jsx(Smartphone, { className: "w-4 h-4" }) })
1164
+ /* @__PURE__ */ jsx(
1165
+ "button",
1166
+ {
1167
+ onClick: () => setViewMode("desktop"),
1168
+ className: `p-1.5 rounded-md transition-all ${viewMode === "desktop" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`,
1169
+ title: "Desktop View",
1170
+ children: /* @__PURE__ */ jsx(Monitor, { className: "w-4 h-4" })
1171
+ }
1172
+ ),
1173
+ /* @__PURE__ */ jsx(
1174
+ "button",
1175
+ {
1176
+ onClick: () => setViewMode("tablet"),
1177
+ className: `p-1.5 rounded-md transition-all ${viewMode === "tablet" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`,
1178
+ title: "Tablet View",
1179
+ children: /* @__PURE__ */ jsx(Tablet, { className: "w-4 h-4" })
1180
+ }
1181
+ ),
1182
+ /* @__PURE__ */ jsx(
1183
+ "button",
1184
+ {
1185
+ onClick: () => setViewMode("mobile"),
1186
+ className: `p-1.5 rounded-md transition-all ${viewMode === "mobile" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`,
1187
+ title: "Mobile View",
1188
+ children: /* @__PURE__ */ jsx(Smartphone, { className: "w-4 h-4" })
1189
+ }
1190
+ )
1076
1191
  ] }),
1077
1192
  /* @__PURE__ */ jsxs(
1078
1193
  "button",
@@ -1125,100 +1240,133 @@ function PageEditor({ page, showList, onToggleList }) {
1125
1240
  ] })
1126
1241
  ] }),
1127
1242
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col sm:flex-row flex-1 overflow-hidden", children: [
1128
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 sm:p-4 flex flex-col items-center", children: /* @__PURE__ */ jsx("div", { className: `flex-1 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-lg ring-1 ring-slate-900/5 min-h-[300px] transition-all duration-300 w-full ${viewMode === "mobile" ? "max-w-[375px]" : viewMode === "tablet" ? "max-w-[768px]" : "w-full"}`, children: /* @__PURE__ */ jsx(
1129
- "iframe",
1243
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 sm:p-4 flex flex-col items-center", children: /* @__PURE__ */ jsx(
1244
+ "div",
1130
1245
  {
1131
- ref: iframeRef,
1132
- src,
1133
- title: page.name,
1134
- className: "h-full w-full bg-white",
1135
- allow: "autoplay; encrypted-media; fullscreen"
1136
- },
1137
- src
1138
- ) }) }),
1139
- /* @__PURE__ */ jsxs("aside", { className: `w-full sm:w-[320px] lg:w-[360px] shrink-0 overflow-y-auto border-t sm:border-t-0 sm:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 hide-scrollbar transition-all duration-300 ${drawerState === "min" ? "max-h-[52px] sm:max-h-none" : drawerState === "full" ? "max-h-[85vh] sm:max-h-none" : "max-h-[50vh] sm:max-h-none"}`, children: [
1140
- /* @__PURE__ */ jsxs("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10 flex items-center justify-between", children: [
1141
- /* @__PURE__ */ jsx("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
1142
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1143
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 sm:hidden", children: [
1144
- /* @__PURE__ */ jsx(
1145
- "button",
1146
- {
1147
- onClick: () => setDrawerState((prev) => prev === "full" ? "half" : prev === "half" ? "min" : "half"),
1148
- className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
1149
- title: "Shrink",
1150
- children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-4 h-4" })
1151
- }
1152
- ),
1153
- /* @__PURE__ */ jsx(
1154
- "button",
1155
- {
1156
- onClick: () => setDrawerState((prev) => prev === "min" ? "half" : prev === "half" ? "full" : "half"),
1157
- className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
1158
- title: "Expand",
1159
- children: /* @__PURE__ */ jsx(ChevronUp, { className: "w-4 h-4" })
1160
- }
1161
- )
1162
- ] }),
1163
- selectedMeta && /* @__PURE__ */ jsx("button", { onClick: () => setSelectedId(null), className: "sm:hidden text-slate-400 hover:text-slate-700 text-xs font-bold uppercase tracking-widest", children: "Close" })
1164
- ] })
1165
- ] }),
1166
- /* @__PURE__ */ jsxs("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
1167
- !selectedMeta && /* @__PURE__ */ jsx("div", { className: "px-5 mt-1 mb-2", children: /* @__PURE__ */ jsx("p", { className: "text-[10px] md:text-xs text-slate-400", children: "Select an element on the left to edit it." }) }),
1168
- selectedMeta ? /* @__PURE__ */ jsx(
1169
- FieldEditor,
1246
+ className: `flex-1 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-lg ring-1 ring-slate-900/5 min-h-[300px] transition-all duration-300 w-full ${viewMode === "mobile" ? "max-w-[375px]" : viewMode === "tablet" ? "max-w-[768px]" : "w-full"}`,
1247
+ children: /* @__PURE__ */ jsx(
1248
+ "iframe",
1170
1249
  {
1171
- meta: selectedMeta,
1172
- value: ctx.overrides[selectedMeta.id] ?? selectedMeta.defaultValue,
1173
- onChange: (v) => updateOverride(selectedMeta.id, v),
1174
- onReset: () => {
1175
- ctx.reset(selectedMeta.id);
1176
- iframeRef.current?.contentWindow?.postMessage(
1250
+ ref: iframeRef,
1251
+ src,
1252
+ title: page.name,
1253
+ className: "h-full w-full bg-white",
1254
+ allow: "autoplay; encrypted-media; fullscreen"
1255
+ },
1256
+ src
1257
+ )
1258
+ }
1259
+ ) }),
1260
+ /* @__PURE__ */ jsxs(
1261
+ "aside",
1262
+ {
1263
+ className: `w-full sm:w-[320px] lg:w-[360px] shrink-0 overflow-y-auto border-t sm:border-t-0 sm:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 hide-scrollbar transition-all duration-300 ${drawerState === "min" ? "max-h-[52px] sm:max-h-none" : drawerState === "full" ? "max-h-[85vh] sm:max-h-none" : "max-h-[50vh] sm:max-h-none"}`,
1264
+ children: [
1265
+ /* @__PURE__ */ jsxs("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10 flex items-center justify-between", children: [
1266
+ /* @__PURE__ */ jsx("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
1267
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1268
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 sm:hidden", children: [
1269
+ /* @__PURE__ */ jsx(
1270
+ "button",
1271
+ {
1272
+ onClick: () => setDrawerState(
1273
+ (prev) => prev === "full" ? "half" : prev === "half" ? "min" : "half"
1274
+ ),
1275
+ className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
1276
+ title: "Shrink",
1277
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-4 h-4" })
1278
+ }
1279
+ ),
1280
+ /* @__PURE__ */ jsx(
1281
+ "button",
1282
+ {
1283
+ onClick: () => setDrawerState(
1284
+ (prev) => prev === "min" ? "half" : prev === "half" ? "full" : "half"
1285
+ ),
1286
+ className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
1287
+ title: "Expand",
1288
+ children: /* @__PURE__ */ jsx(ChevronUp, { className: "w-4 h-4" })
1289
+ }
1290
+ )
1291
+ ] }),
1292
+ selectedMeta && /* @__PURE__ */ jsx(
1293
+ "button",
1177
1294
  {
1178
- __cms: true,
1179
- type: "cms:set-override",
1180
- id: selectedMeta.id,
1181
- value: selectedMeta.defaultValue
1295
+ onClick: () => setSelectedId(null),
1296
+ className: "sm:hidden text-slate-400 hover:text-slate-700 text-xs font-bold uppercase tracking-widest",
1297
+ children: "Close"
1298
+ }
1299
+ )
1300
+ ] })
1301
+ ] }),
1302
+ /* @__PURE__ */ jsxs("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
1303
+ !selectedMeta && /* @__PURE__ */ jsx("div", { className: "px-5 mt-1 mb-2", children: /* @__PURE__ */ jsx("p", { className: "text-[10px] md:text-xs text-slate-400", children: "Select an element on the left to edit it." }) }),
1304
+ selectedMeta ? /* @__PURE__ */ jsx(
1305
+ FieldEditor,
1306
+ {
1307
+ meta: selectedMeta,
1308
+ value: ctx.overrides[selectedMeta.id] ?? selectedMeta.defaultValue,
1309
+ onChange: (v) => updateOverride(selectedMeta.id, v),
1310
+ onReset: () => {
1311
+ ctx.reset(selectedMeta.id);
1312
+ iframeRef.current?.contentWindow?.postMessage(
1313
+ {
1314
+ __cms: true,
1315
+ type: "cms:set-override",
1316
+ id: selectedMeta.id,
1317
+ value: selectedMeta.defaultValue
1318
+ },
1319
+ "*"
1320
+ );
1182
1321
  },
1183
- "*"
1184
- );
1185
- },
1186
- onClose: () => setSelectedId(null)
1187
- }
1188
- ) : /* @__PURE__ */ jsxs(Fragment, { children: [
1189
- page.hideable && /* @__PURE__ */ jsxs("div", { className: "px-5 py-4 border-b border-slate-100 bg-slate-50/50", children: [
1190
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-3", children: [
1322
+ onClose: () => setSelectedId(null)
1323
+ }
1324
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
1325
+ page.hideable && /* @__PURE__ */ jsxs("div", { className: "px-5 py-4 border-b border-slate-100 bg-slate-50/50", children: [
1326
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-3", children: [
1327
+ /* @__PURE__ */ jsx(
1328
+ "input",
1329
+ {
1330
+ type: "checkbox",
1331
+ id: `page-visible-toggle-${page.id}`,
1332
+ checked: ctx.overrides[`page-${page.id}-visible`] !== false,
1333
+ onChange: (e) => updateOverride(
1334
+ `page-${page.id}-visible`,
1335
+ e.target.checked
1336
+ ),
1337
+ className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-600 focus:ring-offset-0"
1338
+ }
1339
+ ),
1340
+ /* @__PURE__ */ jsx(
1341
+ "label",
1342
+ {
1343
+ htmlFor: `page-visible-toggle-${page.id}`,
1344
+ className: "text-sm font-medium text-slate-800 cursor-pointer flex-1",
1345
+ children: "Page is Visible"
1346
+ }
1347
+ )
1348
+ ] }),
1349
+ /* @__PURE__ */ jsx("p", { className: "text-[11px] text-slate-500 mt-1.5 pl-8", children: "If unchecked, this page will be hidden from navigation and URL access." })
1350
+ ] }),
1191
1351
  /* @__PURE__ */ jsx(
1192
- "input",
1352
+ SectionAccordion,
1193
1353
  {
1194
- type: "checkbox",
1195
- id: `page-visible-toggle-${page.id}`,
1196
- checked: ctx.overrides[`page-${page.id}-visible`] !== false,
1197
- onChange: (e) => updateOverride(`page-${page.id}-visible`, e.target.checked),
1198
- className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-600 focus:ring-offset-0"
1354
+ registered,
1355
+ onSelect: (id) => {
1356
+ setSelectedId(id);
1357
+ setDrawerState((prev) => prev === "min" ? "half" : prev);
1358
+ iframeRef.current?.contentWindow?.postMessage(
1359
+ { __cms: true, type: "cms:select", id },
1360
+ "*"
1361
+ );
1362
+ }
1199
1363
  }
1200
- ),
1201
- /* @__PURE__ */ jsx("label", { htmlFor: `page-visible-toggle-${page.id}`, className: "text-sm font-medium text-slate-800 cursor-pointer flex-1", children: "Page is Visible" })
1202
- ] }),
1203
- /* @__PURE__ */ jsx("p", { className: "text-[11px] text-slate-500 mt-1.5 pl-8", children: "If unchecked, this page will be hidden from navigation and URL access." })
1204
- ] }),
1205
- /* @__PURE__ */ jsx(
1206
- SectionAccordion,
1207
- {
1208
- registered,
1209
- onSelect: (id) => {
1210
- setSelectedId(id);
1211
- setDrawerState((prev) => prev === "min" ? "half" : prev);
1212
- iframeRef.current?.contentWindow?.postMessage(
1213
- { __cms: true, type: "cms:select", id },
1214
- "*"
1215
- );
1216
- }
1217
- }
1218
- )
1219
- ] })
1220
- ] })
1221
- ] })
1364
+ )
1365
+ ] })
1366
+ ] })
1367
+ ]
1368
+ }
1369
+ )
1222
1370
  ] })
1223
1371
  ] });
1224
1372
  }
@@ -1247,37 +1395,54 @@ function SectionAccordion({
1247
1395
  sectionNames.map((sectionName) => {
1248
1396
  const isOpen = expanded[sectionName] ?? false;
1249
1397
  const fields = groups[sectionName];
1250
- return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-slate-200 overflow-hidden", children: [
1251
- /* @__PURE__ */ jsxs(
1252
- "button",
1253
- {
1254
- onClick: () => toggle(sectionName),
1255
- className: "flex w-full items-center justify-between px-3 py-2.5 bg-slate-50/80 hover:bg-slate-100 transition-colors text-left",
1256
- children: [
1257
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
1258
- /* @__PURE__ */ jsx("span", { className: "font-semibold text-sm text-slate-800", children: sectionName }),
1259
- /* @__PURE__ */ jsx("span", { className: "text-[10px] font-mono text-slate-400 bg-slate-200/70 px-1.5 py-0.5 rounded-full", children: fields.length })
1260
- ] }),
1261
- /* @__PURE__ */ jsx(
1262
- "svg",
1263
- {
1264
- className: `h-4 w-4 text-slate-400 transition-transform duration-200 ${isOpen ? "rotate-180" : ""}`,
1265
- fill: "none",
1266
- viewBox: "0 0 24 24",
1267
- stroke: "currentColor",
1268
- strokeWidth: 2,
1269
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
1270
- }
1271
- )
1272
- ]
1273
- }
1274
- ),
1275
- isOpen && /* @__PURE__ */ jsx("ul", { className: "divide-y divide-slate-100 bg-white", children: fields.map((m) => /* @__PURE__ */ jsx(FieldListItem, { meta: m, onSelect }, m.id)) })
1276
- ] }, sectionName);
1398
+ return /* @__PURE__ */ jsxs(
1399
+ "div",
1400
+ {
1401
+ className: "rounded-lg border border-slate-200 overflow-hidden",
1402
+ children: [
1403
+ /* @__PURE__ */ jsxs(
1404
+ "button",
1405
+ {
1406
+ onClick: () => toggle(sectionName),
1407
+ className: "flex w-full items-center justify-between px-3 py-2.5 bg-slate-50/80 hover:bg-slate-100 transition-colors text-left",
1408
+ children: [
1409
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
1410
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-sm text-slate-800", children: sectionName }),
1411
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] font-mono text-slate-400 bg-slate-200/70 px-1.5 py-0.5 rounded-full", children: fields.length })
1412
+ ] }),
1413
+ /* @__PURE__ */ jsx(
1414
+ "svg",
1415
+ {
1416
+ className: `h-4 w-4 text-slate-400 transition-transform duration-200 ${isOpen ? "rotate-180" : ""}`,
1417
+ fill: "none",
1418
+ viewBox: "0 0 24 24",
1419
+ stroke: "currentColor",
1420
+ strokeWidth: 2,
1421
+ children: /* @__PURE__ */ jsx(
1422
+ "path",
1423
+ {
1424
+ strokeLinecap: "round",
1425
+ strokeLinejoin: "round",
1426
+ d: "M19 9l-7 7-7-7"
1427
+ }
1428
+ )
1429
+ }
1430
+ )
1431
+ ]
1432
+ }
1433
+ ),
1434
+ isOpen && /* @__PURE__ */ jsx("ul", { className: "divide-y divide-slate-100 bg-white", children: fields.map((m) => /* @__PURE__ */ jsx(FieldListItem, { meta: m, onSelect }, m.id)) })
1435
+ ]
1436
+ },
1437
+ sectionName
1438
+ );
1277
1439
  })
1278
1440
  ] });
1279
1441
  }
1280
- function FieldListItem({ meta, onSelect }) {
1442
+ function FieldListItem({
1443
+ meta,
1444
+ onSelect
1445
+ }) {
1281
1446
  return /* @__PURE__ */ jsx("li", { className: "p-1 list-none", children: /* @__PURE__ */ jsxs(
1282
1447
  "button",
1283
1448
  {
@@ -1299,9 +1464,15 @@ function FieldListItem({ meta, onSelect }) {
1299
1464
  }
1300
1465
  ) });
1301
1466
  }
1302
- function SidebarReferenceSelect({ meta, value, onChange }) {
1467
+ function SidebarReferenceSelect({
1468
+ meta,
1469
+ value,
1470
+ onChange
1471
+ }) {
1303
1472
  const ctx = useCmsContext();
1304
- const collection = ctx.config.collections?.find((c) => c.id === meta.collection);
1473
+ const collection = ctx.config.collections?.find(
1474
+ (c) => c.id === meta.collection
1475
+ );
1305
1476
  const [items, setItems] = useState([]);
1306
1477
  const [search, setSearch] = useState("");
1307
1478
  const [loading, setLoading] = useState(true);
@@ -1327,7 +1498,9 @@ function SidebarReferenceSelect({ meta, value, onChange }) {
1327
1498
  }
1328
1499
  };
1329
1500
  const imgField = collection?.fields.find((f) => f.type === "image");
1330
- const txtField = collection?.fields.find((f) => f.type === "text" || f.type === "textarea" || f.type === "richtext");
1501
+ const txtField = collection?.fields.find(
1502
+ (f) => f.type === "text" || f.type === "textarea" || f.type === "richtext"
1503
+ );
1331
1504
  const filtered = items.filter((it) => {
1332
1505
  if (!search) return true;
1333
1506
  const q = search.toLowerCase();
@@ -1355,8 +1528,21 @@ function SidebarReferenceSelect({ meta, value, onChange }) {
1355
1528
  onClick: () => toggle(it.id),
1356
1529
  className: `flex items-center gap-3 p-2 rounded-xl cursor-pointer border ${isSelected ? "border-indigo-500 bg-indigo-50" : "border-slate-100 bg-slate-50 hover:border-slate-300"}`,
1357
1530
  children: [
1358
- !!imgSrc && /* @__PURE__ */ jsx("img", { src: Array.isArray(imgSrc) ? String(imgSrc[0]) : String(imgSrc), alt: "", className: "w-10 h-10 rounded-lg object-cover bg-white border border-slate-200" }),
1359
- /* @__PURE__ */ jsx("span", { className: `text-sm ${isSelected ? "font-semibold text-indigo-900" : "text-slate-700"}`, children: String(label) }),
1531
+ !!imgSrc && /* @__PURE__ */ jsx(
1532
+ "img",
1533
+ {
1534
+ src: Array.isArray(imgSrc) ? String(imgSrc[0]) : String(imgSrc),
1535
+ alt: "",
1536
+ className: "w-10 h-10 rounded-lg object-cover bg-white border border-slate-200"
1537
+ }
1538
+ ),
1539
+ /* @__PURE__ */ jsx(
1540
+ "span",
1541
+ {
1542
+ className: `text-sm ${isSelected ? "font-semibold text-indigo-900" : "text-slate-700"}`,
1543
+ children: String(label)
1544
+ }
1545
+ ),
1360
1546
  isSelected && /* @__PURE__ */ jsx(Check, { className: "w-4 h-4 text-indigo-600 ml-auto" })
1361
1547
  ]
1362
1548
  },
@@ -1375,7 +1561,9 @@ function FieldEditor({
1375
1561
  onClose
1376
1562
  }) {
1377
1563
  const ctx = useCmsContext();
1378
- const [expandedItems, setExpandedItems] = useState({});
1564
+ const [expandedItems, setExpandedItems] = useState(
1565
+ {}
1566
+ );
1379
1567
  const [searchQuery, setSearchQuery] = useState("");
1380
1568
  const [listDragIdx, setListDragIdx] = useState(null);
1381
1569
  const [listDragOverIdx, setListDragOverIdx] = useState(null);
@@ -1397,7 +1585,14 @@ function FieldEditor({
1397
1585
  className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-600 focus:ring-offset-0"
1398
1586
  }
1399
1587
  ),
1400
- /* @__PURE__ */ jsx("label", { htmlFor: meta.id, className: "text-sm font-medium text-slate-700 cursor-pointer", children: meta.label || "Enabled" })
1588
+ /* @__PURE__ */ jsx(
1589
+ "label",
1590
+ {
1591
+ htmlFor: meta.id,
1592
+ className: "text-sm font-medium text-slate-700 cursor-pointer",
1593
+ children: meta.label || "Enabled"
1594
+ }
1595
+ )
1401
1596
  ] }),
1402
1597
  meta.type === "text" && /* @__PURE__ */ jsx(
1403
1598
  "input",
@@ -1619,7 +1814,9 @@ function FieldEditor({
1619
1814
  ] }),
1620
1815
  (Array.isArray(value) ? value : []).map((item, idx) => {
1621
1816
  if (meta.search && searchQuery) {
1622
- const title = String(item?.title || item?.name || "").toLowerCase();
1817
+ const title = String(
1818
+ item?.title || item?.name || ""
1819
+ ).toLowerCase();
1623
1820
  if (!title.includes(searchQuery.toLowerCase())) return null;
1624
1821
  }
1625
1822
  const isExpanded = expandedItems[idx] ?? false;
@@ -1661,7 +1858,10 @@ function FieldEditor({
1661
1858
  "div",
1662
1859
  {
1663
1860
  className: "flex items-center justify-between cursor-pointer py-1 select-none gap-2",
1664
- onClick: () => setExpandedItems((prev) => ({ ...prev, [idx]: !isExpanded })),
1861
+ onClick: () => setExpandedItems((prev) => ({
1862
+ ...prev,
1863
+ [idx]: !isExpanded
1864
+ })),
1665
1865
  children: [
1666
1866
  isReorderable && /* @__PURE__ */ jsxs(
1667
1867
  "div",
@@ -1722,13 +1922,18 @@ function FieldEditor({
1722
1922
  schemaField.type === "icon" ? /* @__PURE__ */ jsx(
1723
1923
  SearchableSelect,
1724
1924
  {
1725
- value: String(item?.[schemaField.key] ?? (Array.isArray(meta.defaultValue) ? meta.defaultValue[idx]?.[schemaField.key] : "") ?? ""),
1925
+ value: String(
1926
+ item?.[schemaField.key] ?? (Array.isArray(meta.defaultValue) ? meta.defaultValue[idx]?.[schemaField.key] : "") ?? ""
1927
+ ),
1726
1928
  options: schemaField.options ?? [],
1727
1929
  placeholder: "Search icon...",
1728
1930
  iconMap: ctx.iconMap,
1729
1931
  onChange: (val) => {
1730
1932
  const arr = Array.isArray(value) ? [...value] : [];
1731
- arr[idx] = { ...arr[idx] || {}, [schemaField.key]: val };
1933
+ arr[idx] = {
1934
+ ...arr[idx] || {},
1935
+ [schemaField.key]: val
1936
+ };
1732
1937
  onChange(arr);
1733
1938
  }
1734
1939
  }
@@ -1736,10 +1941,15 @@ function FieldEditor({
1736
1941
  "textarea",
1737
1942
  {
1738
1943
  rows: 3,
1739
- value: String(item?.[schemaField.key] ?? ""),
1944
+ value: String(
1945
+ item?.[schemaField.key] ?? ""
1946
+ ),
1740
1947
  onChange: (e) => {
1741
1948
  const arr = Array.isArray(value) ? [...value] : [];
1742
- arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
1949
+ arr[idx] = {
1950
+ ...arr[idx] || {},
1951
+ [schemaField.key]: e.target.value
1952
+ };
1743
1953
  onChange(arr);
1744
1954
  },
1745
1955
  className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
@@ -1752,7 +1962,10 @@ function FieldEditor({
1752
1962
  checked: !!item?.[schemaField.key],
1753
1963
  onChange: (e) => {
1754
1964
  const arr = Array.isArray(value) ? [...value] : [];
1755
- arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.checked };
1965
+ arr[idx] = {
1966
+ ...arr[idx] || {},
1967
+ [schemaField.key]: e.target.checked
1968
+ };
1756
1969
  onChange(arr);
1757
1970
  },
1758
1971
  className: "w-4 h-4 text-indigo-600 border-slate-300 rounded focus:ring-indigo-500"
@@ -1765,10 +1978,15 @@ function FieldEditor({
1765
1978
  "input",
1766
1979
  {
1767
1980
  type: "url",
1768
- value: String(item?.[schemaField.key] ?? ""),
1981
+ value: String(
1982
+ item?.[schemaField.key] ?? ""
1983
+ ),
1769
1984
  onChange: (e) => {
1770
1985
  const arr = Array.isArray(value) ? [...value] : [];
1771
- arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
1986
+ arr[idx] = {
1987
+ ...arr[idx] || {},
1988
+ [schemaField.key]: e.target.value
1989
+ };
1772
1990
  onChange(arr);
1773
1991
  },
1774
1992
  placeholder: "https://... or upload",
@@ -1790,7 +2008,10 @@ function FieldEditor({
1790
2008
  file,
1791
2009
  (url) => {
1792
2010
  const arr = Array.isArray(value) ? [...value] : [];
1793
- arr[idx] = { ...arr[idx] || {}, [schemaField.key]: url };
2011
+ arr[idx] = {
2012
+ ...arr[idx] || {},
2013
+ [schemaField.key]: url
2014
+ };
1794
2015
  onChange(arr);
1795
2016
  },
1796
2017
  ctx.uploadImage
@@ -1801,17 +2022,25 @@ function FieldEditor({
1801
2022
  )
1802
2023
  ] })
1803
2024
  ] }),
1804
- item?.[schemaField.key] ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(item?.[schemaField.key]).match(/\.(mp4|webm|ogg|mov)(\?.*)?$/i) || schemaField.type === "video" ? /* @__PURE__ */ jsx(
2025
+ item?.[schemaField.key] ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(
2026
+ item?.[schemaField.key]
2027
+ ).match(
2028
+ /\.(mp4|webm|ogg|mov)(\?.*)?$/i
2029
+ ) || schemaField.type === "video" ? /* @__PURE__ */ jsx(
1805
2030
  "video",
1806
2031
  {
1807
- src: String(item?.[schemaField.key]),
2032
+ src: String(
2033
+ item?.[schemaField.key]
2034
+ ),
1808
2035
  controls: true,
1809
2036
  className: "w-full h-auto max-h-32 object-contain rounded-md"
1810
2037
  }
1811
2038
  ) : /* @__PURE__ */ jsx(
1812
2039
  "img",
1813
2040
  {
1814
- src: String(item?.[schemaField.key]),
2041
+ src: String(
2042
+ item?.[schemaField.key]
2043
+ ),
1815
2044
  alt: "",
1816
2045
  className: "w-full h-auto max-h-32 object-contain rounded-md"
1817
2046
  }
@@ -1819,10 +2048,15 @@ function FieldEditor({
1819
2048
  ] }) : schemaField.type === "select" ? /* @__PURE__ */ jsx(
1820
2049
  "select",
1821
2050
  {
1822
- value: String(item?.[schemaField.key] ?? ""),
2051
+ value: String(
2052
+ item?.[schemaField.key] ?? ""
2053
+ ),
1823
2054
  onChange: (e) => {
1824
2055
  const arr = Array.isArray(value) ? [...value] : [];
1825
- arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
2056
+ arr[idx] = {
2057
+ ...arr[idx] || {},
2058
+ [schemaField.key]: e.target.value
2059
+ };
1826
2060
  onChange(arr);
1827
2061
  },
1828
2062
  className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 bg-white",
@@ -1834,7 +2068,10 @@ function FieldEditor({
1834
2068
  value: item?.[schemaField.key],
1835
2069
  onChange: (val) => {
1836
2070
  const arr = Array.isArray(value) ? [...value] : [];
1837
- arr[idx] = { ...arr[idx] || {}, [schemaField.key]: val };
2071
+ arr[idx] = {
2072
+ ...arr[idx] || {},
2073
+ [schemaField.key]: val
2074
+ };
1838
2075
  onChange(arr);
1839
2076
  },
1840
2077
  isPrice: schemaField.key.toLowerCase().includes("price") || schemaField.key.toLowerCase().includes("precio"),
@@ -1844,10 +2081,15 @@ function FieldEditor({
1844
2081
  "input",
1845
2082
  {
1846
2083
  type: "text",
1847
- value: String(item?.[schemaField.key] ?? ""),
2084
+ value: String(
2085
+ item?.[schemaField.key] ?? ""
2086
+ ),
1848
2087
  onChange: (e) => {
1849
2088
  const arr = Array.isArray(value) ? [...value] : [];
1850
- arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
2089
+ arr[idx] = {
2090
+ ...arr[idx] || {},
2091
+ [schemaField.key]: e.target.value
2092
+ };
1851
2093
  onChange(arr);
1852
2094
  },
1853
2095
  className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
@@ -1919,7 +2161,14 @@ function FieldEditor({
1919
2161
  }
1920
2162
  )
1921
2163
  ] }),
1922
- meta.type === "reference" && /* @__PURE__ */ jsx(SidebarReferenceSelect, { meta, value, onChange })
2164
+ meta.type === "reference" && /* @__PURE__ */ jsx(
2165
+ SidebarReferenceSelect,
2166
+ {
2167
+ meta,
2168
+ value,
2169
+ onChange
2170
+ }
2171
+ )
1923
2172
  ] }),
1924
2173
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-6 mt-6 border-t border-slate-100", children: [
1925
2174
  /* @__PURE__ */ jsxs(
@@ -1959,7 +2208,9 @@ function CollectionsSection() {
1959
2208
  const list = ctx.config.collections ?? [];
1960
2209
  list.filter((c) => !c.isSeparator).forEach((c) => {
1961
2210
  ctx.adapter.listEntries(c.id).then((entries) => {
1962
- setCounts((prev) => prev[c.id] === entries.length ? prev : { ...prev, [c.id]: entries.length });
2211
+ setCounts(
2212
+ (prev) => prev[c.id] === entries.length ? prev : { ...prev, [c.id]: entries.length }
2213
+ );
1963
2214
  });
1964
2215
  });
1965
2216
  }, [ctx.adapter, colIds, ctx.collectionChangedAt]);
@@ -2018,6 +2269,16 @@ function CollectionEditor({ collection }) {
2018
2269
  const ctx = useCmsContext();
2019
2270
  const t = useAdminI18n();
2020
2271
  const { message } = App.useApp();
2272
+ const currencyCode = ctx.config.currency ?? "USD";
2273
+ const currencyLocale = ctx.config.currencyLocale ?? ctx.config.locale ?? "en-US";
2274
+ const currencyFormatter = useMemo(
2275
+ () => new Intl.NumberFormat(currencyLocale, {
2276
+ style: "currency",
2277
+ currency: currencyCode,
2278
+ maximumFractionDigits: 0
2279
+ }),
2280
+ [currencyCode, currencyLocale]
2281
+ );
2021
2282
  const [entries, setEntries] = useState([]);
2022
2283
  const [editing, setEditing] = useState(null);
2023
2284
  const [originalId, setOriginalId] = useState(null);
@@ -2078,11 +2339,16 @@ function CollectionEditor({ collection }) {
2078
2339
  }, [entries, exportMode, exportDateField, exportDateRange]);
2079
2340
  const [isImportModalOpen, setIsImportModalOpen] = useState(false);
2080
2341
  const [importFile, setImportFile] = useState(null);
2081
- const [importResult, setImportResult] = useState(null);
2342
+ const [importResult, setImportResult] = useState(
2343
+ null
2344
+ );
2082
2345
  const [isParsingImport, setIsParsingImport] = useState(false);
2083
2346
  const [isImporting, setIsImporting] = useState(false);
2084
2347
  const [importExistingAction, setImportExistingAction] = useState("omit");
2085
- const [importProgress, setImportProgress] = useState({ current: 0, total: 0 });
2348
+ const [importProgress, setImportProgress] = useState({
2349
+ current: 0,
2350
+ total: 0
2351
+ });
2086
2352
  const fileInputRef = useRef(null);
2087
2353
  const load = useCallback(() => {
2088
2354
  setLoadingEntries(true);
@@ -2200,13 +2466,17 @@ function CollectionEditor({ collection }) {
2200
2466
  `Se crearon ${createdCount} registros y se actualizaron ${updatedCount} existentes.`
2201
2467
  );
2202
2468
  } else if (createdCount > 0) {
2203
- message.success(`Se importaron ${createdCount} registros exitosamente.`);
2469
+ message.success(
2470
+ `Se importaron ${createdCount} registros exitosamente.`
2471
+ );
2204
2472
  } else if (omittedCount > 0) {
2205
2473
  message.info(
2206
2474
  `Los ${omittedCount} registros ya se encontraban creados. No se duplic\xF3 ning\xFAn dato.`
2207
2475
  );
2208
2476
  } else if (updatedCount > 0) {
2209
- message.success(`Se actualizaron ${updatedCount} registros existentes.`);
2477
+ message.success(
2478
+ `Se actualizaron ${updatedCount} registros existentes.`
2479
+ );
2210
2480
  }
2211
2481
  load();
2212
2482
  setIsImportModalOpen(false);
@@ -2236,17 +2506,6 @@ function CollectionEditor({ collection }) {
2236
2506
  if (f.endField) base[f.endField] = "";
2237
2507
  } else if (f.defaultValue !== void 0) {
2238
2508
  base[f.id] = f.defaultValue;
2239
- } else if (f.type === "branch-settings") {
2240
- base[f.id] = {
2241
- allBranches: true,
2242
- branches: [],
2243
- useBranchPricing: false,
2244
- priceBranches: [],
2245
- prices: {},
2246
- useBranchDiscounts: false,
2247
- discountBranches: [],
2248
- discounts: {}
2249
- };
2250
2509
  } else if (f.multiple) {
2251
2510
  base[f.id] = [];
2252
2511
  } else {
@@ -2337,7 +2596,9 @@ function CollectionEditor({ collection }) {
2337
2596
  }
2338
2597
  }
2339
2598
  await ctx.adapter.putEntry(collection.id, finalEditing);
2340
- message.success(originalId ? "Guardado correctamente" : "Creado correctamente");
2599
+ message.success(
2600
+ originalId ? "Guardado correctamente" : "Creado correctamente"
2601
+ );
2341
2602
  ctx.notifyCollectionChanged();
2342
2603
  setEntries((prev) => {
2343
2604
  const next = [...prev];
@@ -2365,7 +2626,9 @@ function CollectionEditor({ collection }) {
2365
2626
  try {
2366
2627
  await ctx.adapter.deleteEntry(collection.id, id);
2367
2628
  setEntries(
2368
- (prev) => prev.filter((e) => String(e.id || "").trim().toLowerCase() !== String(id).trim().toLowerCase())
2629
+ (prev) => prev.filter(
2630
+ (e) => String(e.id || "").trim().toLowerCase() !== String(id).trim().toLowerCase()
2631
+ )
2369
2632
  );
2370
2633
  ctx.notifyCollectionChanged();
2371
2634
  load();
@@ -2408,8 +2671,12 @@ function CollectionEditor({ collection }) {
2408
2671
  setDraggedIdx(null);
2409
2672
  setDragOverIdx(null);
2410
2673
  };
2411
- const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0, 6);
2412
- const isCreatingEntry = isCreatingManual || (editing ? !entries.some((entry) => entry.id && entry.id === editing.id || entry._id && entry._id === (editing._id || editing.id)) : false);
2674
+ const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter(
2675
+ (f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden
2676
+ ).slice(0, 6);
2677
+ const isCreatingEntry = isCreatingManual || (editing ? !entries.some(
2678
+ (entry) => entry.id && entry.id === editing.id || entry._id && entry._id === (editing._id || editing.id)
2679
+ ) : false);
2413
2680
  if (isCustomCreating && collection.customCreateView) {
2414
2681
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: collection.customCreateView({
2415
2682
  onBack: () => setIsCustomCreating(false),
@@ -2492,7 +2759,9 @@ function CollectionEditor({ collection }) {
2492
2759
  size: "large",
2493
2760
  prefix: /* @__PURE__ */ jsx(Search, { className: "h-4 w-4 text-slate-400" }),
2494
2761
  placeholder: `Buscar por ${collection.searchBy.map((s) => {
2495
- const f = collection.fields.find((field) => field.id === s);
2762
+ const f = collection.fields.find(
2763
+ (field) => field.id === s
2764
+ );
2496
2765
  return f?.label ? f.label.toLowerCase() : s;
2497
2766
  }).join(", ")}...`,
2498
2767
  value: search,
@@ -2508,7 +2777,15 @@ function CollectionEditor({ collection }) {
2508
2777
  const fieldDef = collection.fields.find((cf) => cf.id === f);
2509
2778
  if (!fieldDef) return null;
2510
2779
  if (fieldDef.type === "date") {
2511
- const dateVal = filters[f] ? dayjs2(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]).isValid() ? dayjs2(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]) : null : null;
2780
+ const dateVal = filters[f] ? dayjs2(filters[f], [
2781
+ "YYYY/MM/DD",
2782
+ "YYYY-MM-DD",
2783
+ "YYYY-M-D"
2784
+ ]).isValid() ? dayjs2(filters[f], [
2785
+ "YYYY/MM/DD",
2786
+ "YYYY-MM-DD",
2787
+ "YYYY-M-D"
2788
+ ]) : null : null;
2512
2789
  return /* @__PURE__ */ jsx("div", { className: "min-w-[180px]", children: /* @__PURE__ */ jsx(
2513
2790
  DatePicker,
2514
2791
  {
@@ -2529,7 +2806,9 @@ function CollectionEditor({ collection }) {
2529
2806
  const predefinedOptions = (fieldDef.options || []).map(
2530
2807
  (opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
2531
2808
  );
2532
- const entryVals = Array.from(new Set(entries.map((e) => String(e[f] || "")))).filter(Boolean);
2809
+ const entryVals = Array.from(
2810
+ new Set(entries.map((e) => String(e[f] || "")))
2811
+ ).filter(Boolean);
2533
2812
  const combinedOptions = [...predefinedOptions];
2534
2813
  for (const ev of entryVals) {
2535
2814
  if (!combinedOptions.some((o) => o.value === ev)) {
@@ -2562,7 +2841,13 @@ function CollectionEditor({ collection }) {
2562
2841
  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" }),
2563
2842
  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}`
2564
2843
  ] }),
2565
- 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) }),
2844
+ isViewingDetail && editing && editing.estado !== void 0 && /* @__PURE__ */ jsx(
2845
+ "span",
2846
+ {
2847
+ 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"}`,
2848
+ children: String(editing.estado)
2849
+ }
2850
+ ),
2566
2851
  !isViewingDetail && !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2567
2852
  /* @__PURE__ */ jsx("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
2568
2853
  /* @__PURE__ */ jsx(
@@ -2617,14 +2902,15 @@ function CollectionEditor({ collection }) {
2617
2902
  if (f.dependsOn) {
2618
2903
  const targetVal = editing[f.dependsOn.field];
2619
2904
  if (Array.isArray(f.dependsOn.value)) {
2620
- if (!f.dependsOn.value.includes(targetVal)) return false;
2905
+ if (!f.dependsOn.value.includes(targetVal))
2906
+ return false;
2621
2907
  } else if (targetVal !== f.dependsOn.value) {
2622
2908
  return false;
2623
2909
  }
2624
2910
  }
2625
2911
  return true;
2626
2912
  }).map((f) => {
2627
- const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.multiple || 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";
2913
+ const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.multiple || f.type === "signature" || f.type === "date" || f.type === "datetime" || f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "time-range";
2628
2914
  const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
2629
2915
  if (isViewingDetail) {
2630
2916
  return /* @__PURE__ */ jsxs("div", { className: `block ${colSpanClass}`, children: [
@@ -2644,14 +2930,16 @@ function CollectionEditor({ collection }) {
2644
2930
  alt: f.label,
2645
2931
  className: "h-28 w-auto max-w-full object-contain"
2646
2932
  }
2647
- ) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 italic py-1", children: "Sin firma registrada" }) : f.type === "list" || f.multiple ? 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(
2648
- "span",
2649
- {
2650
- className: "rounded-xl bg-slate-100 text-slate-700 px-3 py-1 text-xs font-medium border border-slate-200",
2651
- children: String(item)
2652
- },
2653
- idx
2654
- )) }) : typeof editing[f.id] === "string" && editing[f.id] ? /* @__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]) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 italic py-1", children: "Ninguno" }) : f.type === "link" ? Boolean(editing[f.id]) ? /* @__PURE__ */ jsxs(
2933
+ ) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 italic py-1", children: "Sin firma registrada" }) : f.type === "list" || f.multiple ? 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(
2934
+ (item, idx) => /* @__PURE__ */ jsx(
2935
+ "span",
2936
+ {
2937
+ className: "rounded-xl bg-slate-100 text-slate-700 px-3 py-1 text-xs font-medium border border-slate-200",
2938
+ children: String(item)
2939
+ },
2940
+ idx
2941
+ )
2942
+ ) }) : typeof editing[f.id] === "string" && editing[f.id] ? /* @__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]) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 italic py-1", children: "Ninguno" }) : f.type === "link" ? Boolean(editing[f.id]) ? /* @__PURE__ */ jsxs(
2655
2943
  "a",
2656
2944
  {
2657
2945
  href: String(editing[f.id]),
@@ -2670,7 +2958,14 @@ function CollectionEditor({ collection }) {
2670
2958
  /* @__PURE__ */ jsxs("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
2671
2959
  /* @__PURE__ */ jsxs("span", { children: [
2672
2960
  f.label,
2673
- (f.required || f.unique) && /* @__PURE__ */ jsx("span", { className: "text-rose-500 ml-1 font-bold", title: "Campo obligatorio", children: "*" })
2961
+ (f.required || f.unique) && /* @__PURE__ */ jsx(
2962
+ "span",
2963
+ {
2964
+ className: "text-rose-500 ml-1 font-bold",
2965
+ title: "Campo obligatorio",
2966
+ children: "*"
2967
+ }
2968
+ )
2674
2969
  ] }),
2675
2970
  /* @__PURE__ */ jsx("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
2676
2971
  ] }),
@@ -2681,16 +2976,7 @@ function CollectionEditor({ collection }) {
2681
2976
  isCreatingEntry,
2682
2977
  isViewingDetail: false,
2683
2978
  readOnly: false
2684
- }) : f.type === "branch-settings" ? /* @__PURE__ */ jsx(
2685
- BranchSettingsEditor,
2686
- {
2687
- collectionId: f.collection || "",
2688
- value: editing[f.id],
2689
- globalPrice: Number(editing.price) || 0,
2690
- globalDiscount: Number(editing.discountPercent) || 0,
2691
- onChange: (val) => setEditing({ ...editing, [f.id]: val })
2692
- }
2693
- ) : f.type === "boolean" ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-3", children: [
2979
+ }) : f.type === "boolean" ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-3", children: [
2694
2980
  /* @__PURE__ */ jsx(
2695
2981
  Switch,
2696
2982
  {
@@ -2708,6 +2994,14 @@ function CollectionEditor({ collection }) {
2708
2994
  disabled: f.readOnly,
2709
2995
  onChange: (val) => setEditing({ ...editing, [f.id]: val ?? 0 }),
2710
2996
  className: "w-full rounded-xl",
2997
+ formatter: f.formatter ? (value) => {
2998
+ if (value === void 0 || value === null) {
2999
+ return "";
3000
+ }
3001
+ const numericValue = Number(value);
3002
+ return Number.isFinite(numericValue) ? currencyFormatter.format(numericValue) : "";
3003
+ } : void 0,
3004
+ parser: f.formatter ? (value) => parseCurrencyInput(value, currencyLocale) : void 0,
2711
3005
  placeholder: "0"
2712
3006
  }
2713
3007
  ) : f.type === "date" || f.type === "datetime" ? /* @__PURE__ */ jsx(
@@ -2715,7 +3009,10 @@ function CollectionEditor({ collection }) {
2715
3009
  {
2716
3010
  size: "large",
2717
3011
  value: editing[f.id] ? dayjs2(String(editing[f.id])).isValid() ? dayjs2(String(editing[f.id])) : null : null,
2718
- onChange: (date, dateString) => setEditing({ ...editing, [f.id]: (Array.isArray(dateString) ? dateString[0] : dateString) || (date ? date.format("YYYY/MM/DD") : "") }),
3012
+ onChange: (date, dateString) => setEditing({
3013
+ ...editing,
3014
+ [f.id]: (Array.isArray(dateString) ? dateString[0] : dateString) || (date ? date.format("YYYY/MM/DD") : "")
3015
+ }),
2719
3016
  format: "YYYY/MM/DD",
2720
3017
  placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
2721
3018
  className: "w-full rounded-xl"
@@ -2725,21 +3022,36 @@ function CollectionEditor({ collection }) {
2725
3022
  AdminTimeRangePicker,
2726
3023
  {
2727
3024
  value: [
2728
- toDayjsTime(f.startField ? editing[f.startField] : ""),
2729
- toDayjsTime(f.endField ? editing[f.endField] : "")
3025
+ toDayjsTime(
3026
+ f.startField ? editing[f.startField] : ""
3027
+ ),
3028
+ toDayjsTime(
3029
+ f.endField ? editing[f.endField] : ""
3030
+ )
2730
3031
  ],
2731
3032
  onChange: (times) => setEditing(
2732
3033
  (current) => current ? {
2733
3034
  ...current,
2734
- ...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
2735
- ...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
3035
+ ...f.startField ? {
3036
+ [f.startField]: toStoredTime(
3037
+ times?.[0]
3038
+ )
3039
+ } : {},
3040
+ ...f.endField ? {
3041
+ [f.endField]: toStoredTime(
3042
+ times?.[1]
3043
+ )
3044
+ } : {}
2736
3045
  } : current
2737
3046
  ),
2738
3047
  allowEmpty: [true, true],
2739
3048
  className: "w-full",
2740
3049
  format: "h:mm a",
2741
3050
  order: false,
2742
- placeholder: ["Hora de inicio", "Hora de cierre"],
3051
+ placeholder: [
3052
+ "Hora de inicio",
3053
+ "Hora de cierre"
3054
+ ],
2743
3055
  use12Hours: true
2744
3056
  }
2745
3057
  ),
@@ -2763,7 +3075,10 @@ function CollectionEditor({ collection }) {
2763
3075
  {
2764
3076
  size: "large",
2765
3077
  value: String(editing[f.id] ?? ""),
2766
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3078
+ onChange: (e) => setEditing({
3079
+ ...editing,
3080
+ [f.id]: e.target.value
3081
+ }),
2767
3082
  rows: 4,
2768
3083
  placeholder: `Escribe ${f.label.toLowerCase()}...`,
2769
3084
  className: "w-full rounded-xl font-sans"
@@ -2783,7 +3098,10 @@ function CollectionEditor({ collection }) {
2783
3098
  {
2784
3099
  size: "large",
2785
3100
  value: String(editing[f.id] ?? ""),
2786
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3101
+ onChange: (e) => setEditing({
3102
+ ...editing,
3103
+ [f.id]: e.target.value
3104
+ }),
2787
3105
  className: "flex-1 rounded-xl"
2788
3106
  }
2789
3107
  ),
@@ -2793,7 +3111,9 @@ function CollectionEditor({ collection }) {
2793
3111
  size: "large",
2794
3112
  onClick: () => {
2795
3113
  const sourceField = f.source || "title";
2796
- let val = String(editing[sourceField] || editing.id || "");
3114
+ let val = String(
3115
+ editing[sourceField] || editing.id || ""
3116
+ );
2797
3117
  val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
2798
3118
  setEditing({ ...editing, [f.id]: val });
2799
3119
  },
@@ -2815,7 +3135,12 @@ function CollectionEditor({ collection }) {
2815
3135
  onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2816
3136
  onSelectRecord: (rec) => {
2817
3137
  if (f.onSelectRecord) {
2818
- setEditing((prev) => prev ? { ...prev, ...f.onSelectRecord(rec, prev) } : prev);
3138
+ setEditing(
3139
+ (prev) => prev ? {
3140
+ ...prev,
3141
+ ...f.onSelectRecord(rec, prev)
3142
+ } : prev
3143
+ );
2819
3144
  }
2820
3145
  }
2821
3146
  }
@@ -2829,7 +3154,10 @@ function CollectionEditor({ collection }) {
2829
3154
  placeholder: f.label,
2830
3155
  allowClear: true,
2831
3156
  onChange: (val) => {
2832
- const next = { ...editing, [f.id]: val || "" };
3157
+ const next = {
3158
+ ...editing,
3159
+ [f.id]: val || ""
3160
+ };
2833
3161
  collection.fields.forEach((otherField) => {
2834
3162
  if (otherField.dependsOnField === f.id && otherField.optionsMap) {
2835
3163
  const newOpts = otherField.optionsMap[String(val || "")];
@@ -2849,25 +3177,56 @@ function CollectionEditor({ collection }) {
2849
3177
  }
2850
3178
  );
2851
3179
  })() : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
2852
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => {
2853
- const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
2854
- return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
2855
- isVideo ? /* @__PURE__ */ jsx("video", { src: url, className: "w-full h-full object-cover rounded-lg", autoPlay: true, muted: true, loop: true, playsInline: true }) : /* @__PURE__ */ jsx("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
2856
- /* @__PURE__ */ jsx(
2857
- "button",
3180
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map(
3181
+ (url, i) => {
3182
+ const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
3183
+ return /* @__PURE__ */ jsxs(
3184
+ "div",
2858
3185
  {
2859
- type: "button",
2860
- onClick: () => {
2861
- const arr = [...editing[f.id] || []];
2862
- arr.splice(i, 1);
2863
- setEditing({ ...editing, [f.id]: arr });
2864
- },
2865
- className: "absolute top-2 right-2 bg-red-500/80 text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500",
2866
- children: /* @__PURE__ */ jsx(X, { className: "w-3 h-3" })
2867
- }
2868
- )
2869
- ] }, i);
2870
- }) }),
3186
+ className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32",
3187
+ children: [
3188
+ isVideo ? /* @__PURE__ */ jsx(
3189
+ "video",
3190
+ {
3191
+ src: url,
3192
+ className: "w-full h-full object-cover rounded-lg",
3193
+ autoPlay: true,
3194
+ muted: true,
3195
+ loop: true,
3196
+ playsInline: true
3197
+ }
3198
+ ) : /* @__PURE__ */ jsx(
3199
+ "img",
3200
+ {
3201
+ src: url,
3202
+ alt: "",
3203
+ className: "w-full h-full object-cover rounded-lg"
3204
+ }
3205
+ ),
3206
+ /* @__PURE__ */ jsx(
3207
+ "button",
3208
+ {
3209
+ type: "button",
3210
+ onClick: () => {
3211
+ const arr = [
3212
+ ...editing[f.id] || []
3213
+ ];
3214
+ arr.splice(i, 1);
3215
+ setEditing({
3216
+ ...editing,
3217
+ [f.id]: arr
3218
+ });
3219
+ },
3220
+ className: "absolute top-2 right-2 bg-red-500/80 text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500",
3221
+ children: /* @__PURE__ */ jsx(X, { className: "w-3 h-3" })
3222
+ }
3223
+ )
3224
+ ]
3225
+ },
3226
+ i
3227
+ );
3228
+ }
3229
+ ) }),
2871
3230
  (!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
2872
3231
  /* @__PURE__ */ jsx(
2873
3232
  "input",
@@ -2877,8 +3236,14 @@ function CollectionEditor({ collection }) {
2877
3236
  onKeyDown: (e) => {
2878
3237
  if (e.key === "Enter" && e.currentTarget.value) {
2879
3238
  e.preventDefault();
2880
- const arr = [...editing[f.id] || [], e.currentTarget.value];
2881
- setEditing({ ...editing, [f.id]: arr });
3239
+ const arr = [
3240
+ ...editing[f.id] || [],
3241
+ e.currentTarget.value
3242
+ ];
3243
+ setEditing({
3244
+ ...editing,
3245
+ [f.id]: arr
3246
+ });
2882
3247
  e.currentTarget.value = "";
2883
3248
  }
2884
3249
  },
@@ -2902,7 +3267,10 @@ function CollectionEditor({ collection }) {
2902
3267
  if (f.max && current.length >= f.max) {
2903
3268
  return prev;
2904
3269
  }
2905
- return { ...prev, [f.id]: [...current, url] };
3270
+ return {
3271
+ ...prev,
3272
+ [f.id]: [...current, url]
3273
+ };
2906
3274
  });
2907
3275
  },
2908
3276
  ctx.uploadImage
@@ -2920,7 +3288,10 @@ function CollectionEditor({ collection }) {
2920
3288
  {
2921
3289
  type: "url",
2922
3290
  value: String(editing[f.id] ?? ""),
2923
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3291
+ onChange: (e) => setEditing({
3292
+ ...editing,
3293
+ [f.id]: e.target.value
3294
+ }),
2924
3295
  placeholder: "https://...",
2925
3296
  className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2926
3297
  }
@@ -2946,7 +3317,9 @@ function CollectionEditor({ collection }) {
2946
3317
  }
2947
3318
  )
2948
3319
  ] }),
2949
- editing[f.id] ? /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(editing[f.id]).match(/\.(mp4|webm|mov|ogg)$/i) || String(editing[f.id]).includes("video") ? /* @__PURE__ */ jsx(
3320
+ editing[f.id] ? /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(editing[f.id]).match(
3321
+ /\.(mp4|webm|mov|ogg)$/i
3322
+ ) || String(editing[f.id]).includes("video") ? /* @__PURE__ */ jsx(
2950
3323
  "video",
2951
3324
  {
2952
3325
  src: String(editing[f.id]),
@@ -2979,8 +3352,13 @@ function CollectionEditor({ collection }) {
2979
3352
  "input",
2980
3353
  {
2981
3354
  type: "color",
2982
- value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
2983
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3355
+ value: String(editing[f.id] ?? "#000000").startsWith(
3356
+ "#"
3357
+ ) && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
3358
+ onChange: (e) => setEditing({
3359
+ ...editing,
3360
+ [f.id]: e.target.value
3361
+ }),
2984
3362
  className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
2985
3363
  }
2986
3364
  ),
@@ -2989,7 +3367,10 @@ function CollectionEditor({ collection }) {
2989
3367
  {
2990
3368
  type: "text",
2991
3369
  value: String(editing[f.id] ?? ""),
2992
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3370
+ onChange: (e) => setEditing({
3371
+ ...editing,
3372
+ [f.id]: e.target.value
3373
+ }),
2993
3374
  placeholder: "#000000",
2994
3375
  className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2995
3376
  }
@@ -2998,62 +3379,75 @@ function CollectionEditor({ collection }) {
2998
3379
  "div",
2999
3380
  {
3000
3381
  className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
3001
- style: { backgroundColor: String(editing[f.id] ?? "#000000") }
3382
+ style: {
3383
+ backgroundColor: String(
3384
+ editing[f.id] ?? "#000000"
3385
+ )
3386
+ }
3002
3387
  }
3003
3388
  )
3004
3389
  ] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
3005
3390
  (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : []).map((item, idx) => {
3006
3391
  const colorVal = String(item ?? "").trim();
3007
3392
  const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
3008
- return /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
3009
- /* @__PURE__ */ jsx(
3010
- "input",
3011
- {
3012
- type: "color",
3013
- value: validHex.length === 7 ? validHex : "#000000",
3014
- onChange: (e) => {
3015
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3016
- arr[idx] = e.target.value;
3017
- setEditing({ ...editing, [f.id]: arr });
3018
- },
3019
- className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
3020
- }
3021
- ),
3022
- /* @__PURE__ */ jsx(
3023
- "input",
3024
- {
3025
- type: "text",
3026
- value: colorVal,
3027
- onChange: (e) => {
3028
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3029
- arr[idx] = e.target.value;
3030
- setEditing({ ...editing, [f.id]: arr });
3031
- },
3032
- placeholder: "#1c2a44",
3033
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
3034
- }
3035
- ),
3036
- /* @__PURE__ */ jsx(
3037
- "div",
3038
- {
3039
- className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
3040
- style: { backgroundColor: colorVal || "#000000" }
3041
- }
3042
- ),
3043
- /* @__PURE__ */ jsx(
3044
- "button",
3045
- {
3046
- type: "button",
3047
- onClick: () => {
3048
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3049
- arr.splice(idx, 1);
3050
- setEditing({ ...editing, [f.id]: arr });
3051
- },
3052
- className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
3053
- children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
3054
- }
3055
- )
3056
- ] }, idx);
3393
+ return /* @__PURE__ */ jsxs(
3394
+ "div",
3395
+ {
3396
+ className: "flex gap-2 items-center",
3397
+ children: [
3398
+ /* @__PURE__ */ jsx(
3399
+ "input",
3400
+ {
3401
+ type: "color",
3402
+ value: validHex.length === 7 ? validHex : "#000000",
3403
+ onChange: (e) => {
3404
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3405
+ arr[idx] = e.target.value;
3406
+ setEditing({ ...editing, [f.id]: arr });
3407
+ },
3408
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
3409
+ }
3410
+ ),
3411
+ /* @__PURE__ */ jsx(
3412
+ "input",
3413
+ {
3414
+ type: "text",
3415
+ value: colorVal,
3416
+ onChange: (e) => {
3417
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3418
+ arr[idx] = e.target.value;
3419
+ setEditing({ ...editing, [f.id]: arr });
3420
+ },
3421
+ placeholder: "#1c2a44",
3422
+ className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
3423
+ }
3424
+ ),
3425
+ /* @__PURE__ */ jsx(
3426
+ "div",
3427
+ {
3428
+ className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
3429
+ style: {
3430
+ backgroundColor: colorVal || "#000000"
3431
+ }
3432
+ }
3433
+ ),
3434
+ /* @__PURE__ */ jsx(
3435
+ "button",
3436
+ {
3437
+ type: "button",
3438
+ onClick: () => {
3439
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3440
+ arr.splice(idx, 1);
3441
+ setEditing({ ...editing, [f.id]: arr });
3442
+ },
3443
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
3444
+ children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
3445
+ }
3446
+ )
3447
+ ]
3448
+ },
3449
+ idx
3450
+ );
3057
3451
  }),
3058
3452
  /* @__PURE__ */ jsxs(
3059
3453
  "button",
@@ -3076,50 +3470,69 @@ function CollectionEditor({ collection }) {
3076
3470
  const displayArr = currentArr.length > 0 ? currentArr : [""];
3077
3471
  const singularLabel = f.label.endsWith("es") ? f.label.slice(0, -2) : f.label.endsWith("s") ? f.label.slice(0, -1) : f.label;
3078
3472
  return /* @__PURE__ */ jsxs("div", { className: "space-y-2.5", children: [
3079
- displayArr.map((item, idx) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
3080
- /* @__PURE__ */ jsxs("span", { className: "text-xs font-mono font-bold text-slate-400 w-7 text-right shrink-0", children: [
3081
- "#",
3082
- idx + 1
3083
- ] }),
3084
- /* @__PURE__ */ jsx(
3085
- "input",
3086
- {
3087
- type: "text",
3088
- value: String(item ?? ""),
3089
- placeholder: `${singularLabel} #${idx + 1}...`,
3090
- onChange: (e) => {
3091
- const arr = [...displayArr];
3092
- arr[idx] = e.target.value;
3093
- setEditing({ ...editing, [f.id]: arr });
3094
- },
3095
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white"
3096
- }
3097
- ),
3098
- displayArr.length > 1 && /* @__PURE__ */ jsx(
3099
- "button",
3100
- {
3101
- type: "button",
3102
- onClick: () => {
3103
- const arr = displayArr.filter((_, i) => i !== idx);
3104
- setEditing({ ...editing, [f.id]: arr.length > 0 ? arr : [""] });
3105
- },
3106
- className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer shrink-0",
3107
- title: "Eliminar elemento",
3108
- children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
3109
- }
3110
- )
3111
- ] }, idx)),
3473
+ displayArr.map((item, idx) => /* @__PURE__ */ jsxs(
3474
+ "div",
3475
+ {
3476
+ className: "flex gap-2 items-center",
3477
+ children: [
3478
+ /* @__PURE__ */ jsxs("span", { className: "text-xs font-mono font-bold text-slate-400 w-7 text-right shrink-0", children: [
3479
+ "#",
3480
+ idx + 1
3481
+ ] }),
3482
+ /* @__PURE__ */ jsx(
3483
+ "input",
3484
+ {
3485
+ type: "text",
3486
+ value: String(item ?? ""),
3487
+ placeholder: `${singularLabel} #${idx + 1}...`,
3488
+ onChange: (e) => {
3489
+ const arr = [...displayArr];
3490
+ arr[idx] = e.target.value;
3491
+ setEditing({
3492
+ ...editing,
3493
+ [f.id]: arr
3494
+ });
3495
+ },
3496
+ className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white"
3497
+ }
3498
+ ),
3499
+ displayArr.length > 1 && /* @__PURE__ */ jsx(
3500
+ "button",
3501
+ {
3502
+ type: "button",
3503
+ onClick: () => {
3504
+ const arr = displayArr.filter(
3505
+ (_, i) => i !== idx
3506
+ );
3507
+ setEditing({
3508
+ ...editing,
3509
+ [f.id]: arr.length > 0 ? arr : [""]
3510
+ });
3511
+ },
3512
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer shrink-0",
3513
+ title: "Eliminar elemento",
3514
+ children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
3515
+ }
3516
+ )
3517
+ ]
3518
+ },
3519
+ idx
3520
+ )),
3112
3521
  /* @__PURE__ */ jsxs(
3113
3522
  "button",
3114
3523
  {
3115
3524
  type: "button",
3116
3525
  onClick: () => {
3117
- setEditing({ ...editing, [f.id]: [...displayArr, ""] });
3526
+ setEditing({
3527
+ ...editing,
3528
+ [f.id]: [...displayArr, ""]
3529
+ });
3118
3530
  },
3119
3531
  className: "inline-flex items-center gap-1.5 px-3.5 py-2 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-bold rounded-xl border border-indigo-100 transition-colors cursor-pointer",
3120
3532
  children: [
3121
3533
  /* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
3122
- " Agregar ",
3534
+ " Agregar",
3535
+ " ",
3123
3536
  singularLabel.toLowerCase()
3124
3537
  ]
3125
3538
  }
@@ -3133,7 +3546,10 @@ function CollectionEditor({ collection }) {
3133
3546
  value: String(editing[f.id] ?? ""),
3134
3547
  readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
3135
3548
  disabled: f.readOnly,
3136
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3549
+ onChange: (e) => setEditing({
3550
+ ...editing,
3551
+ [f.id]: e.target.value
3552
+ }),
3137
3553
  placeholder: f.label,
3138
3554
  className: "flex-1 rounded-xl"
3139
3555
  }
@@ -3185,8 +3601,13 @@ function CollectionEditor({ collection }) {
3185
3601
  if (dup) {
3186
3602
  const dupName = dup.nombre ? ` (\xAB${dup.nombre} ${dup.apellido || ""}\xBB)` : "";
3187
3603
  const errMsg = `Esta identificaci\xF3n ya est\xE1 registrada${dupName}. No puedes usar una c\xE9dula o NIT repetido.`;
3188
- setDuplicateErrors((prev) => ({ ...prev, [f.id]: errMsg }));
3189
- message.warning(`\u26A0\uFE0F Ya existe un registro con esta identificaci\xF3n: ${e.target.value.trim()}.`);
3604
+ setDuplicateErrors((prev) => ({
3605
+ ...prev,
3606
+ [f.id]: errMsg
3607
+ }));
3608
+ message.warning(
3609
+ `\u26A0\uFE0F Ya existe un registro con esta identificaci\xF3n: ${e.target.value.trim()}.`
3610
+ );
3190
3611
  } else {
3191
3612
  setDuplicateErrors((prev) => {
3192
3613
  const next = { ...prev };
@@ -3281,7 +3702,10 @@ function CollectionEditor({ collection }) {
3281
3702
  value: exportMode,
3282
3703
  onChange: (val) => setExportMode(val),
3283
3704
  options: [
3284
- { label: `${t.exportAllRecords} (${entries.length})`, value: "all" },
3705
+ {
3706
+ label: `${t.exportAllRecords} (${entries.length})`,
3707
+ value: "all"
3708
+ },
3285
3709
  { label: t.exportFilterByDate, value: "byDate" }
3286
3710
  ]
3287
3711
  }
@@ -3300,11 +3724,26 @@ function CollectionEditor({ collection }) {
3300
3724
  value: exportDateRange,
3301
3725
  onChange: (dates) => setExportDateRange(dates),
3302
3726
  presets: [
3303
- { label: "Hoy", value: [dayjs2().startOf("day"), dayjs2().endOf("day")] },
3304
- { label: "Esta semana", value: [dayjs2().startOf("week"), dayjs2().endOf("week")] },
3305
- { label: "Este mes", value: [dayjs2().startOf("month"), dayjs2().endOf("month")] },
3306
- { label: "\xDAltimos 30 d\xEDas", value: [dayjs2().subtract(30, "day"), dayjs2()] },
3307
- { label: "Este a\xF1o", value: [dayjs2().startOf("year"), dayjs2().endOf("year")] }
3727
+ {
3728
+ label: "Hoy",
3729
+ value: [dayjs2().startOf("day"), dayjs2().endOf("day")]
3730
+ },
3731
+ {
3732
+ label: "Esta semana",
3733
+ value: [dayjs2().startOf("week"), dayjs2().endOf("week")]
3734
+ },
3735
+ {
3736
+ label: "Este mes",
3737
+ value: [dayjs2().startOf("month"), dayjs2().endOf("month")]
3738
+ },
3739
+ {
3740
+ label: "\xDAltimos 30 d\xEDas",
3741
+ value: [dayjs2().subtract(30, "day"), dayjs2()]
3742
+ },
3743
+ {
3744
+ label: "Este a\xF1o",
3745
+ value: [dayjs2().startOf("year"), dayjs2().endOf("year")]
3746
+ }
3308
3747
  ]
3309
3748
  }
3310
3749
  )
@@ -3407,7 +3846,15 @@ function CollectionEditor({ collection }) {
3407
3846
  /* @__PURE__ */ jsx("p", { className: "font-semibold text-sm text-slate-700", children: t.importDropzone }),
3408
3847
  /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-400 mt-1", children: t.importDropzoneSub })
3409
3848
  ] }),
3410
- /* @__PURE__ */ jsx(Button, { size: "middle", loading: isParsingImport, className: "mt-2 rounded-lg font-medium", children: isParsingImport ? "Leyendo archivo..." : "Seleccionar archivo" })
3849
+ /* @__PURE__ */ jsx(
3850
+ Button,
3851
+ {
3852
+ size: "middle",
3853
+ loading: isParsingImport,
3854
+ className: "mt-2 rounded-lg font-medium",
3855
+ children: isParsingImport ? "Leyendo archivo..." : "Seleccionar archivo"
3856
+ }
3857
+ )
3411
3858
  ]
3412
3859
  }
3413
3860
  ) : /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
@@ -3495,13 +3942,21 @@ function CollectionEditor({ collection }) {
3495
3942
  t.importPreviewTitle,
3496
3943
  " (",
3497
3944
  Math.min(5, importResult.samplePreview.length),
3498
- " de ",
3945
+ " de",
3946
+ " ",
3499
3947
  importResult.totalRows,
3500
3948
  "):"
3501
3949
  ] }),
3502
3950
  /* @__PURE__ */ jsx("div", { className: "overflow-x-auto border border-slate-200 rounded-xl max-h-48 text-xs", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left", children: [
3503
3951
  /* @__PURE__ */ jsx("thead", { className: "bg-slate-100/80 text-slate-700 font-semibold border-b border-slate-200", children: /* @__PURE__ */ jsx("tr", { children: importResult.matchedFields.slice(0, 6).map((m, idx) => /* @__PURE__ */ jsx("th", { className: "p-2 whitespace-nowrap", children: m.label }, idx)) }) }),
3504
- /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-slate-100", children: importResult.samplePreview.map((row, rIdx) => /* @__PURE__ */ jsx("tr", { className: "hover:bg-slate-50/60", children: importResult.matchedFields.slice(0, 6).map((m, cIdx) => /* @__PURE__ */ jsx("td", { className: "p-2 whitespace-nowrap max-w-[160px] truncate text-slate-600", children: String(row[m.fieldId] ?? "") }, cIdx)) }, rIdx)) })
3952
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-slate-100", children: importResult.samplePreview.map((row, rIdx) => /* @__PURE__ */ jsx("tr", { className: "hover:bg-slate-50/60", children: importResult.matchedFields.slice(0, 6).map((m, cIdx) => /* @__PURE__ */ jsx(
3953
+ "td",
3954
+ {
3955
+ className: "p-2 whitespace-nowrap max-w-[160px] truncate text-slate-600",
3956
+ children: String(row[m.fieldId] ?? "")
3957
+ },
3958
+ cIdx
3959
+ )) }, rIdx)) })
3505
3960
  ] }) })
3506
3961
  ] }),
3507
3962
  isImporting && /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
@@ -3516,7 +3971,9 @@ function CollectionEditor({ collection }) {
3516
3971
  /* @__PURE__ */ jsx(
3517
3972
  Progress,
3518
3973
  {
3519
- percent: Math.round(importProgress.current / (importProgress.total || 1) * 100),
3974
+ percent: Math.round(
3975
+ importProgress.current / (importProgress.total || 1) * 100
3976
+ ),
3520
3977
  status: "active"
3521
3978
  }
3522
3979
  )
@@ -3554,13 +4011,26 @@ function CollectionEditor({ collection }) {
3554
4011
  ),
3555
4012
  /* @__PURE__ */ jsx("div", { className: "overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm text-left", children: [
3556
4013
  /* @__PURE__ */ jsx("thead", { className: "bg-slate-50/80 border-b border-slate-200", children: /* @__PURE__ */ jsxs("tr", { children: [
3557
- visibleFields.map((f) => /* @__PURE__ */ jsx("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: f.label }, f.id)),
4014
+ visibleFields.map((f) => /* @__PURE__ */ jsx(
4015
+ "th",
4016
+ {
4017
+ className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",
4018
+ children: f.label
4019
+ },
4020
+ f.id
4021
+ )),
3558
4022
  /* @__PURE__ */ jsx("th", { className: "px-6 py-4 text-right text-xs font-bold text-slate-500 uppercase tracking-wider sticky right-0 bg-slate-50 border-l border-slate-200 z-10", children: t.actions })
3559
4023
  ] }) }),
3560
4024
  /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
3561
4025
  // Loading skeleton rows
3562
4026
  Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxs("tr", { children: [
3563
- visibleFields.map((f) => /* @__PURE__ */ jsx("td", { className: "px-6 py-4", children: /* @__PURE__ */ jsx("div", { className: "h-4 bg-slate-100 rounded animate-pulse", style: { width: `${60 + i * 13 % 30}%` } }) }, f.id)),
4027
+ visibleFields.map((f) => /* @__PURE__ */ jsx("td", { className: "px-6 py-4", children: /* @__PURE__ */ jsx(
4028
+ "div",
4029
+ {
4030
+ className: "h-4 bg-slate-100 rounded animate-pulse",
4031
+ style: { width: `${60 + i * 13 % 30}%` }
4032
+ }
4033
+ ) }, f.id)),
3564
4034
  /* @__PURE__ */ jsx("td", { className: "px-6 py-4 sticky right-0 bg-white border-l border-slate-100", children: /* @__PURE__ */ jsx("div", { className: "h-4 w-16 bg-slate-100 rounded animate-pulse ml-auto" }) })
3565
4035
  ] }, i))
3566
4036
  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -3594,7 +4064,10 @@ function CollectionEditor({ collection }) {
3594
4064
  return true;
3595
4065
  });
3596
4066
  }
3597
- const paginatedRes = res.slice((page - 1) * itemsPerPage, page * itemsPerPage);
4067
+ const paginatedRes = res.slice(
4068
+ (page - 1) * itemsPerPage,
4069
+ page * itemsPerPage
4070
+ );
3598
4071
  return /* @__PURE__ */ jsx(Fragment, { children: paginatedRes.map((e, idx) => /* @__PURE__ */ jsxs(
3599
4072
  "tr",
3600
4073
  {
@@ -3605,45 +4078,112 @@ function CollectionEditor({ collection }) {
3605
4078
  onDragEnd,
3606
4079
  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" : ""}`,
3607
4080
  children: [
3608
- visibleFields.map((f) => /* @__PURE__ */ jsx("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.renderCell ? f.renderCell(e[f.id], e) : 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] ? f.onCellClick ? /* @__PURE__ */ jsx(
3609
- "button",
3610
- {
3611
- type: "button",
3612
- onClick: () => f.onCellClick(e[f.id], e),
3613
- className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block max-w-full",
3614
- children: /* @__PURE__ */ jsx(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple })
3615
- }
3616
- ) : /* @__PURE__ */ jsx(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : (f.type === "list" || f.multiple) && e[f.id] ? Array.isArray(e[f.id]) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
3617
- /* @__PURE__ */ jsx("span", { className: "truncate", children: String(e[f.id][0] || "") }),
3618
- e[f.id].length > 1 && /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center px-1.5 py-0.2 rounded text-[10px] font-bold bg-indigo-50 text-indigo-700 border border-indigo-100 shrink-0", children: [
3619
- "+",
3620
- e[f.id].length - 1,
3621
- " m\xE1s"
3622
- ] })
3623
- ] }) : /* @__PURE__ */ jsx("span", { children: String(e[f.id]) }) : f.onCellClick ? /* @__PURE__ */ jsx(
3624
- "button",
3625
- {
3626
- type: "button",
3627
- onClick: () => f.onCellClick(e[f.id], e),
3628
- className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block w-full",
3629
- children: String(e[f.id] ?? "")
3630
- }
3631
- ) : 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: [
3632
- "$ ",
3633
- Number(e[f.id]).toLocaleString("es-CO")
3634
- ] }) : /* @__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(
3635
- "a",
4081
+ visibleFields.map((f) => /* @__PURE__ */ jsx(
4082
+ "td",
3636
4083
  {
3637
- href: String(e[f.id]),
3638
- target: "_blank",
3639
- rel: "noopener noreferrer",
3640
- className: "inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 underline font-medium",
3641
- children: [
3642
- /* @__PURE__ */ jsx(ExternalLink, { className: "w-3 h-3" }),
3643
- String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
3644
- ]
3645
- }
3646
- ) : 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)),
4084
+ className: "px-6 py-4 text-slate-700 max-w-[200px] truncate",
4085
+ children: f.renderCell ? f.renderCell(e[f.id], e) : 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(
4086
+ "img",
4087
+ {
4088
+ src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]),
4089
+ alt: "",
4090
+ className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200"
4091
+ }
4092
+ ) : 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(
4093
+ "svg",
4094
+ {
4095
+ className: "w-4 h-4",
4096
+ fill: "none",
4097
+ stroke: "currentColor",
4098
+ viewBox: "0 0 24 24",
4099
+ children: /* @__PURE__ */ jsx(
4100
+ "path",
4101
+ {
4102
+ strokeLinecap: "round",
4103
+ strokeLinejoin: "round",
4104
+ strokeWidth: "2",
4105
+ 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"
4106
+ }
4107
+ )
4108
+ }
4109
+ ) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ jsx(
4110
+ "span",
4111
+ {
4112
+ 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(
4113
+ "Preparaci\xF3n"
4114
+ ) ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes(
4115
+ "Cancelado"
4116
+ ) ? "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"}`,
4117
+ children: String(e[f.id])
4118
+ }
4119
+ ) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? f.onCellClick ? /* @__PURE__ */ jsx(
4120
+ "button",
4121
+ {
4122
+ type: "button",
4123
+ onClick: () => f.onCellClick(e[f.id], e),
4124
+ className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block max-w-full",
4125
+ children: /* @__PURE__ */ jsx(
4126
+ ReferenceTableCell,
4127
+ {
4128
+ collectionId: f.collection,
4129
+ entryId: e[f.id],
4130
+ displayField: f.displayField,
4131
+ valueField: f.valueField,
4132
+ multiple: f.multiple
4133
+ }
4134
+ )
4135
+ }
4136
+ ) : /* @__PURE__ */ jsx(
4137
+ ReferenceTableCell,
4138
+ {
4139
+ collectionId: f.collection,
4140
+ entryId: e[f.id],
4141
+ displayField: f.displayField,
4142
+ valueField: f.valueField,
4143
+ multiple: f.multiple
4144
+ }
4145
+ ) : (f.type === "list" || f.multiple) && e[f.id] ? Array.isArray(e[f.id]) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
4146
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: String(e[f.id][0] || "") }),
4147
+ e[f.id].length > 1 && /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center px-1.5 py-0.2 rounded text-[10px] font-bold bg-indigo-50 text-indigo-700 border border-indigo-100 shrink-0", children: [
4148
+ "+",
4149
+ e[f.id].length - 1,
4150
+ " m\xE1s"
4151
+ ] })
4152
+ ] }) : /* @__PURE__ */ jsx("span", { children: String(e[f.id]) }) : f.onCellClick ? /* @__PURE__ */ jsx(
4153
+ "button",
4154
+ {
4155
+ type: "button",
4156
+ onClick: () => f.onCellClick(e[f.id], e),
4157
+ className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block w-full",
4158
+ children: String(e[f.id] ?? "")
4159
+ }
4160
+ ) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ jsx(
4161
+ Image,
4162
+ {
4163
+ src: String(e[f.id]),
4164
+ alt: "Firma",
4165
+ className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer",
4166
+ preview: { mask: "Ver" }
4167
+ }
4168
+ ) : 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: [
4169
+ "$ ",
4170
+ Number(e[f.id]).toLocaleString("es-CO")
4171
+ ] }) : /* @__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(
4172
+ "a",
4173
+ {
4174
+ href: String(e[f.id]),
4175
+ target: "_blank",
4176
+ rel: "noopener noreferrer",
4177
+ className: "inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 underline font-medium",
4178
+ children: [
4179
+ /* @__PURE__ */ jsx(ExternalLink, { className: "w-3 h-3" }),
4180
+ String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
4181
+ ]
4182
+ }
4183
+ ) : 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] ?? "")
4184
+ },
4185
+ f.id
4186
+ )),
3647
4187
  /* @__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: [
3648
4188
  collection.customRowActions && collection.customRowActions({
3649
4189
  record: e,
@@ -3742,10 +4282,36 @@ function CollectionEditor({ collection }) {
3742
4282
  disabled: deletingId === e.id,
3743
4283
  className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
3744
4284
  title: t.delete,
3745
- children: deletingId === e.id ? /* @__PURE__ */ jsxs("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
3746
- /* @__PURE__ */ jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
3747
- /* @__PURE__ */ jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
3748
- ] }) : /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
4285
+ children: deletingId === e.id ? /* @__PURE__ */ jsxs(
4286
+ "svg",
4287
+ {
4288
+ className: "animate-spin h-4 w-4",
4289
+ xmlns: "http://www.w3.org/2000/svg",
4290
+ fill: "none",
4291
+ viewBox: "0 0 24 24",
4292
+ children: [
4293
+ /* @__PURE__ */ jsx(
4294
+ "circle",
4295
+ {
4296
+ className: "opacity-25",
4297
+ cx: "12",
4298
+ cy: "12",
4299
+ r: "10",
4300
+ stroke: "currentColor",
4301
+ strokeWidth: "4"
4302
+ }
4303
+ ),
4304
+ /* @__PURE__ */ jsx(
4305
+ "path",
4306
+ {
4307
+ className: "opacity-75",
4308
+ fill: "currentColor",
4309
+ d: "M4 12a8 8 0 018-8v8H4z"
4310
+ }
4311
+ )
4312
+ ]
4313
+ }
4314
+ ) : /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
3749
4315
  }
3750
4316
  )
3751
4317
  ] }) })
@@ -3772,7 +4338,11 @@ function CollectionEditor({ collection }) {
3772
4338
  let res = entries;
3773
4339
  if (search && collection.searchBy?.length) {
3774
4340
  const q = search.toLowerCase();
3775
- res = res.filter((e) => collection.searchBy.some((field) => String(e[field] || "").toLowerCase().includes(q)));
4341
+ res = res.filter(
4342
+ (e) => collection.searchBy.some(
4343
+ (field) => String(e[field] || "").toLowerCase().includes(q)
4344
+ )
4345
+ );
3776
4346
  }
3777
4347
  if (Object.keys(filters).length > 0) {
3778
4348
  res = res.filter((e) => {
@@ -3788,7 +4358,11 @@ function CollectionEditor({ collection }) {
3788
4358
  let res = entries;
3789
4359
  if (search && collection.searchBy?.length) {
3790
4360
  const q = search.toLowerCase();
3791
- res = res.filter((e) => collection.searchBy.some((field) => String(e[field] || "").toLowerCase().includes(q)));
4361
+ res = res.filter(
4362
+ (e) => collection.searchBy.some(
4363
+ (field) => String(e[field] || "").toLowerCase().includes(q)
4364
+ )
4365
+ );
3792
4366
  }
3793
4367
  if (Object.keys(filters).length > 0) {
3794
4368
  res = res.filter((e) => {
@@ -3798,7 +4372,10 @@ function CollectionEditor({ collection }) {
3798
4372
  return true;
3799
4373
  });
3800
4374
  }
3801
- const totalPages = Math.max(1, Math.ceil(res.length / itemsPerPage));
4375
+ const totalPages = Math.max(
4376
+ 1,
4377
+ Math.ceil(res.length / itemsPerPage)
4378
+ );
3802
4379
  if (totalPages <= 1) return null;
3803
4380
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3804
4381
  /* @__PURE__ */ jsx(
@@ -3855,20 +4432,39 @@ function SubmissionsSection() {
3855
4432
  /* @__PURE__ */ jsxs("div", { className: "w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-slate-200 bg-white/50 p-4", children: [
3856
4433
  /* @__PURE__ */ jsx("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Data Collections" }),
3857
4434
  /* @__PURE__ */ jsxs("ul", { className: "flex overflow-x-auto gap-2 pb-2 md:block md:space-x-0 md:space-y-1 md:pb-0 md:overflow-visible", children: [
3858
- formIds.map((id) => /* @__PURE__ */ jsx("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */ jsxs(
3859
- "button",
4435
+ formIds.map((id) => /* @__PURE__ */ jsx(
4436
+ "li",
3860
4437
  {
3861
- onClick: () => setSelectedFormId(id),
3862
- className: `w-full rounded-lg px-3 py-2.5 text-left text-sm transition-all duration-200 ${selectedFormId === id ? "bg-white shadow-sm ring-1 ring-slate-200 font-semibold" : "hover:bg-slate-100"}`,
3863
- children: [
3864
- /* @__PURE__ */ jsx("div", { className: selectedFormId === id ? "text-slate-900" : "text-slate-700 capitalize", children: id }),
3865
- /* @__PURE__ */ jsxs("div", { className: `text-xs mt-0.5 ${selectedFormId === id ? "text-indigo-500" : "text-slate-400"}`, children: [
3866
- submissions.filter((s) => s.formId === id).length,
3867
- " items"
3868
- ] })
3869
- ]
3870
- }
3871
- ) }, id)),
4438
+ className: "shrink-0 min-w-[140px] md:w-full md:min-w-0",
4439
+ children: /* @__PURE__ */ jsxs(
4440
+ "button",
4441
+ {
4442
+ onClick: () => setSelectedFormId(id),
4443
+ className: `w-full rounded-lg px-3 py-2.5 text-left text-sm transition-all duration-200 ${selectedFormId === id ? "bg-white shadow-sm ring-1 ring-slate-200 font-semibold" : "hover:bg-slate-100"}`,
4444
+ children: [
4445
+ /* @__PURE__ */ jsx(
4446
+ "div",
4447
+ {
4448
+ className: selectedFormId === id ? "text-slate-900" : "text-slate-700 capitalize",
4449
+ children: id
4450
+ }
4451
+ ),
4452
+ /* @__PURE__ */ jsxs(
4453
+ "div",
4454
+ {
4455
+ className: `text-xs mt-0.5 ${selectedFormId === id ? "text-indigo-500" : "text-slate-400"}`,
4456
+ children: [
4457
+ submissions.filter((s) => s.formId === id).length,
4458
+ " items"
4459
+ ]
4460
+ }
4461
+ )
4462
+ ]
4463
+ }
4464
+ )
4465
+ },
4466
+ id
4467
+ )),
3872
4468
  formIds.length === 0 && /* @__PURE__ */ jsx("li", { className: "px-3 py-6 text-center text-sm text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-200", children: "No data collected." })
3873
4469
  ] })
3874
4470
  ] }),
@@ -3887,7 +4483,12 @@ function SubmissionsSection() {
3887
4483
  ] })
3888
4484
  ] });
3889
4485
  }
3890
- function SubmissionsList({ formId, submissions, onLoad, loading }) {
4486
+ function SubmissionsList({
4487
+ formId,
4488
+ submissions,
4489
+ onLoad,
4490
+ loading
4491
+ }) {
3891
4492
  const ctx = useCmsContext();
3892
4493
  const [search, setSearch] = useState("");
3893
4494
  const [page, setPage] = useState(1);
@@ -3915,7 +4516,10 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
3915
4516
  const unreadCount = submissions.filter((s) => !s.read).length;
3916
4517
  const formatDate = (iso) => {
3917
4518
  try {
3918
- return new Intl.DateTimeFormat("en-US", { dateStyle: "medium", timeStyle: "short" }).format(new Date(iso));
4519
+ return new Intl.DateTimeFormat("en-US", {
4520
+ dateStyle: "medium",
4521
+ timeStyle: "short"
4522
+ }).format(new Date(iso));
3919
4523
  } catch {
3920
4524
  return iso;
3921
4525
  }
@@ -3953,54 +4557,61 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
3953
4557
  const strVal = String(val ?? "\u2014");
3954
4558
  const isImage = typeof val === "string" && (val.startsWith("data:image/") || /\.(jpg|jpeg|png|webp|avif|gif|svg)(\?.*)?$/i.test(val) || val.includes("/images/") && val.includes("sanity.io"));
3955
4559
  const isUrl = typeof val === "string" && /^https?:\/\//i.test(val);
3956
- return /* @__PURE__ */ jsxs("div", { className: "py-4 grid grid-cols-[160px_1fr] gap-4 items-start", children: [
3957
- /* @__PURE__ */ jsx("dt", { className: "text-xs font-bold uppercase tracking-wide text-slate-400 pt-0.5", children: key }),
3958
- /* @__PURE__ */ jsx("dd", { className: "text-sm text-slate-800", children: isImage ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3959
- /* @__PURE__ */ jsx(
3960
- "a",
3961
- {
3962
- href: strVal,
3963
- target: "_blank",
3964
- rel: "noopener noreferrer",
3965
- className: "inline-block max-w-sm rounded-lg overflow-hidden border border-slate-200 shadow-sm hover:shadow transition-shadow bg-slate-50 p-1",
3966
- children: /* @__PURE__ */ jsx(
3967
- "img",
4560
+ return /* @__PURE__ */ jsxs(
4561
+ "div",
4562
+ {
4563
+ className: "py-4 grid grid-cols-[160px_1fr] gap-4 items-start",
4564
+ children: [
4565
+ /* @__PURE__ */ jsx("dt", { className: "text-xs font-bold uppercase tracking-wide text-slate-400 pt-0.5", children: key }),
4566
+ /* @__PURE__ */ jsx("dd", { className: "text-sm text-slate-800", children: isImage ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
4567
+ /* @__PURE__ */ jsx(
4568
+ "a",
3968
4569
  {
3969
- src: strVal,
3970
- alt: key,
3971
- className: "max-h-64 w-auto object-contain rounded"
4570
+ href: strVal,
4571
+ target: "_blank",
4572
+ rel: "noopener noreferrer",
4573
+ className: "inline-block max-w-sm rounded-lg overflow-hidden border border-slate-200 shadow-sm hover:shadow transition-shadow bg-slate-50 p-1",
4574
+ children: /* @__PURE__ */ jsx(
4575
+ "img",
4576
+ {
4577
+ src: strVal,
4578
+ alt: key,
4579
+ className: "max-h-64 w-auto object-contain rounded"
4580
+ }
4581
+ )
3972
4582
  }
3973
- )
3974
- }
3975
- ),
3976
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
3977
- "a",
3978
- {
3979
- href: strVal,
3980
- target: "_blank",
3981
- rel: "noopener noreferrer",
3982
- className: "inline-flex items-center gap-1.5 text-xs text-indigo-600 font-semibold hover:underline",
3983
- children: [
3984
- /* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5" }),
3985
- " View / Download file"
3986
- ]
3987
- }
3988
- ) })
3989
- ] }) : isUrl ? /* @__PURE__ */ jsxs(
3990
- "a",
3991
- {
3992
- href: strVal,
3993
- target: "_blank",
3994
- rel: "noopener noreferrer",
3995
- className: "inline-flex items-center gap-1.5 text-indigo-600 font-medium hover:underline break-all text-sm",
3996
- children: [
3997
- /* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5 flex-shrink-0" }),
3998
- " ",
3999
- strVal
4000
- ]
4001
- }
4002
- ) : /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", children: strVal }) })
4003
- ] }, key);
4583
+ ),
4584
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
4585
+ "a",
4586
+ {
4587
+ href: strVal,
4588
+ target: "_blank",
4589
+ rel: "noopener noreferrer",
4590
+ className: "inline-flex items-center gap-1.5 text-xs text-indigo-600 font-semibold hover:underline",
4591
+ children: [
4592
+ /* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5" }),
4593
+ " View / Download file"
4594
+ ]
4595
+ }
4596
+ ) })
4597
+ ] }) : isUrl ? /* @__PURE__ */ jsxs(
4598
+ "a",
4599
+ {
4600
+ href: strVal,
4601
+ target: "_blank",
4602
+ rel: "noopener noreferrer",
4603
+ className: "inline-flex items-center gap-1.5 text-indigo-600 font-medium hover:underline break-all text-sm",
4604
+ children: [
4605
+ /* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5 flex-shrink-0" }),
4606
+ " ",
4607
+ strVal
4608
+ ]
4609
+ }
4610
+ ) : /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", children: strVal }) })
4611
+ ]
4612
+ },
4613
+ key
4614
+ );
4004
4615
  }) })
4005
4616
  ] })
4006
4617
  ] });
@@ -4022,7 +4633,8 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
4022
4633
  className: "inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-700 shadow-sm hover:bg-slate-50 transition-colors disabled:opacity-50",
4023
4634
  children: [
4024
4635
  /* @__PURE__ */ jsx(RefreshCw, { className: `h-4 w-4 ${loading ? "animate-spin" : ""}` }),
4025
- " Refresh"
4636
+ " ",
4637
+ "Refresh"
4026
4638
  ]
4027
4639
  }
4028
4640
  )
@@ -4063,37 +4675,44 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
4063
4675
  !s.read && /* @__PURE__ */ jsx("span", { className: "ml-2 inline-block h-2 w-2 rounded-full bg-indigo-500" })
4064
4676
  ] }),
4065
4677
  /* @__PURE__ */ jsx("td", { className: "px-6 py-4 text-slate-500 whitespace-nowrap", children: formatDate(s.submittedAt) }),
4066
- /* @__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", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-1", children: [
4067
- /* @__PURE__ */ jsx(
4068
- "button",
4069
- {
4070
- onClick: () => openDetail(s),
4071
- className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
4072
- title: "View detail",
4073
- children: /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" })
4074
- }
4075
- ),
4076
- /* @__PURE__ */ jsx(
4077
- "button",
4078
- {
4079
- onClick: () => deleteOne(s.id),
4080
- className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors",
4081
- title: "Delete",
4082
- children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
4083
- }
4084
- )
4085
- ] }) })
4086
- ]
4087
- },
4088
- s.id
4089
- );
4090
- }),
4091
- paginated.length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 3, className: "px-6 py-16 text-center", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 text-slate-400", children: [
4092
- /* @__PURE__ */ jsx(Inbox, { className: "h-12 w-12 text-slate-200" }),
4093
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: search ? "No matches." : "No data yet." })
4094
- ] }) }) })
4095
- ] })
4096
- ] }) }),
4678
+ /* @__PURE__ */ jsx(
4679
+ "td",
4680
+ {
4681
+ 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",
4682
+ onClick: (e) => e.stopPropagation(),
4683
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-1", children: [
4684
+ /* @__PURE__ */ jsx(
4685
+ "button",
4686
+ {
4687
+ onClick: () => openDetail(s),
4688
+ className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
4689
+ title: "View detail",
4690
+ children: /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" })
4691
+ }
4692
+ ),
4693
+ /* @__PURE__ */ jsx(
4694
+ "button",
4695
+ {
4696
+ onClick: () => deleteOne(s.id),
4697
+ className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors",
4698
+ title: "Delete",
4699
+ children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
4700
+ }
4701
+ )
4702
+ ] })
4703
+ }
4704
+ )
4705
+ ]
4706
+ },
4707
+ s.id
4708
+ );
4709
+ }),
4710
+ paginated.length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 3, className: "px-6 py-16 text-center", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 text-slate-400", children: [
4711
+ /* @__PURE__ */ jsx(Inbox, { className: "h-12 w-12 text-slate-200" }),
4712
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: search ? "No matches." : "No data yet." })
4713
+ ] }) }) })
4714
+ ] })
4715
+ ] }) }),
4097
4716
  totalPages > 1 && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-sm text-slate-500", children: [
4098
4717
  /* @__PURE__ */ jsxs("span", { children: [
4099
4718
  filtered.length,
@@ -4140,7 +4759,13 @@ function SettingsSection() {
4140
4759
  /* @__PURE__ */ jsx("div", { className: "px-6 py-4 border-b border-slate-100 bg-slate-50/50", children: /* @__PURE__ */ jsx("h3", { className: "font-bold text-slate-800", children: "Configuration Snapshot" }) }),
4141
4760
  /* @__PURE__ */ jsxs("dl", { className: "divide-y divide-slate-100 text-sm", children: [
4142
4761
  /* @__PURE__ */ jsx(Row, { label: "Site Name", value: ctx.config.siteName ?? "\u2014" }),
4143
- /* @__PURE__ */ jsx(Row, { label: "Registered Pages", value: String(ctx.config.pages.length) }),
4762
+ /* @__PURE__ */ jsx(
4763
+ Row,
4764
+ {
4765
+ label: "Registered Pages",
4766
+ value: String(ctx.config.pages.length)
4767
+ }
4768
+ ),
4144
4769
  /* @__PURE__ */ jsx(
4145
4770
  Row,
4146
4771
  {
@@ -4189,7 +4814,13 @@ function ConfigSection() {
4189
4814
  {
4190
4815
  onClick: () => setSelectedGroupId(g.id),
4191
4816
  className: `w-full rounded-lg px-3 py-2.5 text-left text-sm transition-all duration-200 ${selectedGroupId === g.id ? "bg-white shadow-sm ring-1 ring-slate-200 font-semibold" : "hover:bg-slate-100"}`,
4192
- children: /* @__PURE__ */ jsx("div", { className: `truncate ${selectedGroupId === g.id ? "text-slate-900" : "text-slate-700"}`, children: g.label })
4817
+ children: /* @__PURE__ */ jsx(
4818
+ "div",
4819
+ {
4820
+ className: `truncate ${selectedGroupId === g.id ? "text-slate-900" : "text-slate-700"}`,
4821
+ children: g.label
4822
+ }
4823
+ )
4193
4824
  }
4194
4825
  ) }, g.id)),
4195
4826
  globals.length === 0 && /* @__PURE__ */ jsx("li", { className: "px-3 py-6 text-center text-sm text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-200 w-full", children: "No global configurations." })
@@ -4256,10 +4887,22 @@ function Row({
4256
4887
  }) {
4257
4888
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4 hover:bg-slate-50/50 transition-colors", children: [
4258
4889
  /* @__PURE__ */ jsx("dt", { className: "text-slate-500 font-medium", children: label }),
4259
- /* @__PURE__ */ jsx("dd", { className: `font-semibold ${highlight ? "text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded" : status === "warning" ? "text-amber-600" : status === "success" ? "text-emerald-600" : "text-slate-900"}`, children: value })
4890
+ /* @__PURE__ */ jsx(
4891
+ "dd",
4892
+ {
4893
+ className: `font-semibold ${highlight ? "text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded" : status === "warning" ? "text-amber-600" : status === "success" ? "text-emerald-600" : "text-slate-900"}`,
4894
+ children: value
4895
+ }
4896
+ )
4260
4897
  ] });
4261
4898
  }
4262
- function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
4899
+ function SearchableSelect({
4900
+ value,
4901
+ onChange,
4902
+ options,
4903
+ placeholder,
4904
+ iconMap
4905
+ }) {
4263
4906
  const [open, setOpen] = useState(false);
4264
4907
  const [search, setSearch] = useState("");
4265
4908
  const btnRef = useRef(null);
@@ -4276,7 +4919,10 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
4276
4919
  const opensUp = spaceBelow < dropdownHeight && rect.top > dropdownHeight;
4277
4920
  setCoords({
4278
4921
  top: opensUp ? Math.max(10, rect.top - dropdownHeight - 6) : rect.bottom + 6,
4279
- left: Math.max(10, Math.min(rect.left, window.innerWidth - rect.width - 10)),
4922
+ left: Math.max(
4923
+ 10,
4924
+ Math.min(rect.left, window.innerWidth - rect.width - 10)
4925
+ ),
4280
4926
  width: rect.width
4281
4927
  });
4282
4928
  }
@@ -4401,7 +5047,10 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
4401
5047
  )
4402
5048
  ] });
4403
5049
  }
4404
- function PasswordField({ value, onChange }) {
5050
+ function PasswordField({
5051
+ value,
5052
+ onChange
5053
+ }) {
4405
5054
  const [show, setShow] = useState(false);
4406
5055
  const hasExisting = Boolean(value && String(value).trim().length > 0);
4407
5056
  const [displayValue, setDisplayValue] = useState("");
@@ -4587,8 +5236,24 @@ function SignatureInput({
4587
5236
  centered: true,
4588
5237
  width: 560,
4589
5238
  footer: [
4590
- /* @__PURE__ */ jsx(Button, { onClick: clearCanvas, className: "rounded-xl font-medium", children: t.clear }, "clear"),
4591
- /* @__PURE__ */ jsx(Button, { onClick: () => setModalOpen(false), className: "rounded-xl font-medium", children: t.cancel }, "cancel"),
5239
+ /* @__PURE__ */ jsx(
5240
+ Button,
5241
+ {
5242
+ onClick: clearCanvas,
5243
+ className: "rounded-xl font-medium",
5244
+ children: t.clear
5245
+ },
5246
+ "clear"
5247
+ ),
5248
+ /* @__PURE__ */ jsx(
5249
+ Button,
5250
+ {
5251
+ onClick: () => setModalOpen(false),
5252
+ className: "rounded-xl font-medium",
5253
+ children: t.cancel
5254
+ },
5255
+ "cancel"
5256
+ ),
4592
5257
  /* @__PURE__ */ jsx(
4593
5258
  Button,
4594
5259
  {
@@ -4639,7 +5304,9 @@ function FormattedNumberInput({
4639
5304
  if (!cleanDigits) return "";
4640
5305
  return cleanDigits.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
4641
5306
  };
4642
- const [displayVal, setDisplayVal] = useState(() => formatWithDots(value));
5307
+ const [displayVal, setDisplayVal] = useState(
5308
+ () => formatWithDots(value)
5309
+ );
4643
5310
  useEffect(() => {
4644
5311
  setDisplayVal(formatWithDots(value));
4645
5312
  }, [value]);
@@ -4681,440 +5348,6 @@ function FormattedNumberInput({
4681
5348
  )
4682
5349
  ] });
4683
5350
  }
4684
- function BranchSettingsEditor({
4685
- collectionId,
4686
- value,
4687
- globalPrice,
4688
- globalDiscount,
4689
- onChange
4690
- }) {
4691
- const ctx = useCmsContext();
4692
- const [branches, setBranches] = useState([]);
4693
- const [loading, setLoading] = useState(true);
4694
- const [loadError, setLoadError] = useState("");
4695
- const settings = value && typeof value === "object" ? value : {};
4696
- const selectedBranches = Array.isArray(settings.branches) ? settings.branches.map(String) : [];
4697
- const prices = settings.prices && typeof settings.prices === "object" ? settings.prices : {};
4698
- const selectedPriceBranches = [
4699
- .../* @__PURE__ */ new Set([
4700
- ...Array.isArray(settings.priceBranches) ? settings.priceBranches.map(String) : [],
4701
- ...Object.keys(prices)
4702
- ])
4703
- ];
4704
- const discounts = settings.discounts && typeof settings.discounts === "object" ? settings.discounts : {};
4705
- const selectedDiscountBranches = [
4706
- .../* @__PURE__ */ new Set([
4707
- ...Array.isArray(settings.discountBranches) ? settings.discountBranches.map(String) : [],
4708
- ...Object.keys(discounts)
4709
- ])
4710
- ];
4711
- const branchAvailability = settings.branchAvailability && typeof settings.branchAvailability === "object" ? settings.branchAvailability : {};
4712
- const selectedAvailabilityBranches = Object.keys(branchAvailability);
4713
- const allBranches = settings.allBranches !== false;
4714
- const useBranchPricing = settings.useBranchPricing === true;
4715
- const useBranchDiscounts = settings.useBranchDiscounts === true;
4716
- useEffect(() => {
4717
- let active = true;
4718
- setLoading(true);
4719
- setLoadError("");
4720
- ctx.adapter.listEntries(collectionId).then((entries) => {
4721
- if (active) setBranches(entries);
4722
- }).catch((error) => {
4723
- console.error("Could not load branches for product settings:", error);
4724
- if (active) setLoadError("No se pudieron cargar las sedes.");
4725
- }).finally(() => {
4726
- if (active) setLoading(false);
4727
- });
4728
- return () => {
4729
- active = false;
4730
- };
4731
- }, [collectionId, ctx.adapter]);
4732
- const getBranchName = (branch) => String(branch.name || branch.id);
4733
- const updateSettings = (patch) => {
4734
- onChange({
4735
- allBranches,
4736
- branches: selectedBranches,
4737
- useBranchPricing,
4738
- priceBranches: selectedPriceBranches,
4739
- prices: { ...prices },
4740
- useBranchDiscounts,
4741
- discountBranches: selectedDiscountBranches,
4742
- discounts: { ...discounts },
4743
- branchAvailability: { ...branchAvailability },
4744
- ...patch
4745
- });
4746
- };
4747
- const updateBranchAvailability = (name, start, end) => {
4748
- updateSettings({
4749
- branchAvailability: {
4750
- ...branchAvailability,
4751
- [name]: {
4752
- start: toStoredTime(start),
4753
- end: toStoredTime(end)
4754
- }
4755
- }
4756
- });
4757
- };
4758
- const updateBranchPrice = (name, value2) => {
4759
- const nextPrices = { ...prices };
4760
- if (value2.trim() === "") {
4761
- delete nextPrices[name];
4762
- } else {
4763
- const parsed = Number(value2);
4764
- if (Number.isFinite(parsed) && parsed >= 0) nextPrices[name] = parsed;
4765
- }
4766
- updateSettings({ prices: nextPrices });
4767
- };
4768
- const updateBranchDiscount = (name, value2) => {
4769
- const nextDiscounts = { ...discounts };
4770
- if (value2.trim() === "") {
4771
- delete nextDiscounts[name];
4772
- } else {
4773
- const parsed = Number(value2);
4774
- if (Number.isFinite(parsed) && parsed >= 0 && parsed <= 100) {
4775
- nextDiscounts[name] = parsed;
4776
- }
4777
- }
4778
- updateSettings({ discounts: nextDiscounts });
4779
- };
4780
- return /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl border border-slate-200 bg-slate-50/50 p-4", children: [
4781
- /* @__PURE__ */ jsxs("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
4782
- /* @__PURE__ */ jsx(
4783
- "input",
4784
- {
4785
- type: "checkbox",
4786
- checked: allBranches,
4787
- onChange: (event) => updateSettings({ allBranches: event.target.checked }),
4788
- className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
4789
- }
4790
- ),
4791
- /* @__PURE__ */ jsxs("span", { children: [
4792
- /* @__PURE__ */ jsx("span", { className: "block font-semibold", children: "Disponible en todas las sedes" }),
4793
- /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs text-slate-500", children: "Desactiva esta opci\xF3n para elegir una o varias sedes." })
4794
- ] })
4795
- ] }),
4796
- !allBranches && /* @__PURE__ */ jsx(
4797
- SearchableMultiSelect,
4798
- {
4799
- options: branches.map((branch) => ({
4800
- value: getBranchName(branch),
4801
- label: getBranchName(branch)
4802
- })),
4803
- value: selectedBranches,
4804
- onChange: (next) => updateSettings({ branches: next }),
4805
- loading,
4806
- error: loadError,
4807
- placeholder: "Seleccionar sedes...",
4808
- searchPlaceholder: "Buscar sede...",
4809
- emptyMessage: "No hay sedes registradas todav\xEDa."
4810
- }
4811
- ),
4812
- /* @__PURE__ */ jsxs("div", { className: "border-t border-slate-200 pt-4", children: [
4813
- /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-slate-700", children: "Horario diferente por sede (opcional)" }),
4814
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-slate-500", children: "Deja ambas horas vac\xEDas para heredar el horario general. Si defines una hora, el horario de esa sede reemplaza por completo al general." }),
4815
- /* @__PURE__ */ jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsx(
4816
- SearchableMultiSelect,
4817
- {
4818
- options: branches.map((branch) => ({
4819
- value: getBranchName(branch),
4820
- label: getBranchName(branch)
4821
- })),
4822
- value: selectedAvailabilityBranches,
4823
- onChange: (next) => {
4824
- const nextSchedules = Object.fromEntries(
4825
- next.map((name) => [
4826
- name,
4827
- branchAvailability[name] ?? { start: "", end: "" }
4828
- ])
4829
- );
4830
- updateSettings({ branchAvailability: nextSchedules });
4831
- },
4832
- loading,
4833
- error: loadError,
4834
- placeholder: "Buscar sedes para configurar su horario...",
4835
- searchPlaceholder: "Buscar sede...",
4836
- emptyMessage: "No hay sedes registradas todav\xEDa."
4837
- }
4838
- ) }),
4839
- /* @__PURE__ */ jsx("div", { className: "mt-3 space-y-2", children: branches.filter(
4840
- (branch) => selectedAvailabilityBranches.includes(getBranchName(branch))
4841
- ).map((branch) => {
4842
- const name = getBranchName(branch);
4843
- const schedule = branchAvailability[name] ?? {};
4844
- return /* @__PURE__ */ jsxs(
4845
- "div",
4846
- {
4847
- className: "space-y-3 rounded-lg border border-slate-200 bg-white p-3",
4848
- children: [
4849
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
4850
- /* @__PURE__ */ jsx("span", { className: "min-w-0 whitespace-normal break-words text-sm font-semibold leading-5 text-slate-800", children: name }),
4851
- /* @__PURE__ */ jsx(
4852
- "button",
4853
- {
4854
- type: "button",
4855
- onClick: () => {
4856
- const nextSchedules = { ...branchAvailability };
4857
- delete nextSchedules[name];
4858
- updateSettings({ branchAvailability: nextSchedules });
4859
- },
4860
- "aria-label": `Quitar horario de ${name}`,
4861
- title: `Quitar horario de ${name}`,
4862
- className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-slate-200 text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-700",
4863
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
4864
- }
4865
- )
4866
- ] }),
4867
- /* @__PURE__ */ jsx(
4868
- AdminTimeRangePicker,
4869
- {
4870
- value: [
4871
- toDayjsTime(schedule.start),
4872
- toDayjsTime(schedule.end)
4873
- ],
4874
- onChange: (times) => updateBranchAvailability(
4875
- name,
4876
- times?.[0] ?? null,
4877
- times?.[1] ?? null
4878
- ),
4879
- allowEmpty: [true, true],
4880
- className: "w-full",
4881
- format: TIME_DISPLAY_FORMAT,
4882
- order: false,
4883
- placeholder: ["Hora de inicio", "Hora de cierre"],
4884
- use12Hours: true
4885
- }
4886
- )
4887
- ]
4888
- },
4889
- branch.id
4890
- );
4891
- }) })
4892
- ] }),
4893
- /* @__PURE__ */ jsxs("div", { className: "border-t border-slate-200 pt-4", children: [
4894
- /* @__PURE__ */ jsxs("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
4895
- /* @__PURE__ */ jsx(
4896
- "input",
4897
- {
4898
- type: "checkbox",
4899
- checked: useBranchPricing,
4900
- onChange: (event) => updateSettings({ useBranchPricing: event.target.checked }),
4901
- className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
4902
- }
4903
- ),
4904
- /* @__PURE__ */ jsxs("span", { children: [
4905
- /* @__PURE__ */ jsx("span", { className: "block font-semibold", children: "Usar precio diferente por sede" }),
4906
- /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs text-slate-500", children: "El precio global se usa como base; deja una sede vac\xEDa para conservarlo." })
4907
- ] })
4908
- ] }),
4909
- useBranchPricing && /* @__PURE__ */ jsx("div", { className: "mt-3 space-y-2", children: loading ? /* @__PURE__ */ jsx("p", { className: "py-2 text-center text-xs text-slate-400", children: "Cargando sedes..." }) : loadError ? /* @__PURE__ */ jsx("p", { role: "alert", className: "py-2 text-center text-xs text-red-600", children: loadError }) : branches.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-2 text-center text-xs text-slate-400", children: "Agrega sedes a la colecci\xF3n antes de definir precios." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
4910
- /* @__PURE__ */ jsxs("p", { className: "text-xs text-slate-500", children: [
4911
- "Precio global actual: $",
4912
- globalPrice.toLocaleString("es-CO")
4913
- ] }),
4914
- /* @__PURE__ */ jsx(
4915
- SearchableMultiSelect,
4916
- {
4917
- options: branches.map((branch) => ({
4918
- value: getBranchName(branch),
4919
- label: getBranchName(branch)
4920
- })),
4921
- value: selectedPriceBranches,
4922
- onChange: (next) => {
4923
- const removed = selectedPriceBranches.filter(
4924
- (name) => !next.includes(name)
4925
- );
4926
- const nextPrices = { ...prices };
4927
- removed.forEach((name) => delete nextPrices[name]);
4928
- updateSettings({
4929
- priceBranches: next,
4930
- prices: nextPrices
4931
- });
4932
- },
4933
- loading,
4934
- error: loadError,
4935
- placeholder: "Buscar y agregar sedes...",
4936
- searchPlaceholder: "Buscar sede...",
4937
- emptyMessage: "No hay sedes registradas todav\xEDa."
4938
- }
4939
- ),
4940
- branches.filter(
4941
- (branch) => selectedPriceBranches.includes(getBranchName(branch))
4942
- ).map((branch) => {
4943
- const name = getBranchName(branch);
4944
- return /* @__PURE__ */ jsxs(
4945
- "div",
4946
- {
4947
- className: "space-y-2 rounded-lg border border-slate-200 bg-white p-3",
4948
- children: [
4949
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
4950
- /* @__PURE__ */ jsx("span", { className: "min-w-0 whitespace-normal break-words text-sm font-semibold leading-5 text-slate-800", children: name }),
4951
- /* @__PURE__ */ jsx(
4952
- "button",
4953
- {
4954
- type: "button",
4955
- onClick: () => {
4956
- const nextPrices = { ...prices };
4957
- delete nextPrices[name];
4958
- updateSettings({
4959
- priceBranches: selectedPriceBranches.filter(
4960
- (selected) => selected !== name
4961
- ),
4962
- prices: nextPrices
4963
- });
4964
- },
4965
- "aria-label": `Quitar ${name} de precios por sede`,
4966
- title: `Quitar ${name}`,
4967
- className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-slate-200 text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-700",
4968
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
4969
- }
4970
- )
4971
- ] }),
4972
- /* @__PURE__ */ jsxs("label", { className: "block w-full", children: [
4973
- /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
4974
- "Precio para ",
4975
- name
4976
- ] }),
4977
- /* @__PURE__ */ jsx(
4978
- FormattedNumberInput,
4979
- {
4980
- value: prices[name] ?? "",
4981
- onChange: (price) => updateBranchPrice(
4982
- name,
4983
- price === null ? "" : String(price)
4984
- ),
4985
- isPrice: true,
4986
- allowEmpty: true,
4987
- placeholder: String(globalPrice),
4988
- className: "bg-white text-right",
4989
- containerClassName: "w-full"
4990
- }
4991
- )
4992
- ] })
4993
- ]
4994
- },
4995
- branch.id
4996
- );
4997
- })
4998
- ] }) })
4999
- ] }),
5000
- /* @__PURE__ */ jsxs("div", { className: "border-t border-slate-200 pt-4", children: [
5001
- /* @__PURE__ */ jsxs("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
5002
- /* @__PURE__ */ jsx(
5003
- "input",
5004
- {
5005
- type: "checkbox",
5006
- checked: useBranchDiscounts,
5007
- onChange: (event) => updateSettings({ useBranchDiscounts: event.target.checked }),
5008
- className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
5009
- }
5010
- ),
5011
- /* @__PURE__ */ jsxs("span", { children: [
5012
- /* @__PURE__ */ jsx("span", { className: "block font-semibold", children: "Usar descuento diferente por sede" }),
5013
- /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs text-slate-500", children: "El descuento global aplica como base; una sede vac\xEDa hereda ese porcentaje." })
5014
- ] })
5015
- ] }),
5016
- useBranchDiscounts && /* @__PURE__ */ jsx("div", { className: "mt-3 space-y-2", children: loading ? /* @__PURE__ */ jsx("p", { className: "py-2 text-center text-xs text-slate-400", children: "Cargando sedes..." }) : loadError ? /* @__PURE__ */ jsx("p", { role: "alert", className: "py-2 text-center text-xs text-red-600", children: loadError }) : branches.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-2 text-center text-xs text-slate-400", children: "Agrega sedes a la colecci\xF3n antes de definir descuentos." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5017
- /* @__PURE__ */ jsxs("p", { className: "text-xs text-slate-500", children: [
5018
- "Descuento global actual: ",
5019
- globalDiscount,
5020
- "%"
5021
- ] }),
5022
- /* @__PURE__ */ jsx(
5023
- SearchableMultiSelect,
5024
- {
5025
- options: branches.map((branch) => ({
5026
- value: getBranchName(branch),
5027
- label: getBranchName(branch)
5028
- })),
5029
- value: selectedDiscountBranches,
5030
- onChange: (next) => {
5031
- const removed = selectedDiscountBranches.filter(
5032
- (name) => !next.includes(name)
5033
- );
5034
- const nextDiscounts = { ...discounts };
5035
- removed.forEach((name) => delete nextDiscounts[name]);
5036
- updateSettings({
5037
- discountBranches: next,
5038
- discounts: nextDiscounts
5039
- });
5040
- },
5041
- loading,
5042
- error: loadError,
5043
- placeholder: "Buscar y agregar sedes...",
5044
- searchPlaceholder: "Buscar sede...",
5045
- emptyMessage: "No hay sedes registradas todav\xEDa."
5046
- }
5047
- ),
5048
- branches.filter(
5049
- (branch) => selectedDiscountBranches.includes(getBranchName(branch))
5050
- ).map((branch) => {
5051
- const name = getBranchName(branch);
5052
- return /* @__PURE__ */ jsxs(
5053
- "div",
5054
- {
5055
- className: "space-y-2 rounded-lg border border-slate-200 bg-white p-3",
5056
- children: [
5057
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
5058
- /* @__PURE__ */ jsx("span", { className: "min-w-0 whitespace-normal break-words text-sm font-semibold leading-5 text-slate-800", children: name }),
5059
- /* @__PURE__ */ jsx(
5060
- "button",
5061
- {
5062
- type: "button",
5063
- onClick: () => {
5064
- const nextDiscounts = { ...discounts };
5065
- delete nextDiscounts[name];
5066
- updateSettings({
5067
- discountBranches: selectedDiscountBranches.filter(
5068
- (selected) => selected !== name
5069
- ),
5070
- discounts: nextDiscounts
5071
- });
5072
- },
5073
- "aria-label": `Quitar descuento de ${name}`,
5074
- title: `Quitar ${name}`,
5075
- className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-slate-200 text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-700",
5076
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
5077
- }
5078
- )
5079
- ] }),
5080
- /* @__PURE__ */ jsxs("label", { className: "block w-full", children: [
5081
- /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
5082
- "Descuento para ",
5083
- name
5084
- ] }),
5085
- /* @__PURE__ */ jsx(
5086
- FormattedNumberInput,
5087
- {
5088
- value: discounts[name] ?? "",
5089
- onChange: (discount) => updateBranchDiscount(
5090
- name,
5091
- discount === null ? "" : String(discount)
5092
- ),
5093
- isPercent: true,
5094
- allowEmpty: true,
5095
- placeholder: String(globalDiscount),
5096
- className: "bg-white text-right",
5097
- containerClassName: "w-full"
5098
- }
5099
- )
5100
- ] })
5101
- ]
5102
- },
5103
- branch.id
5104
- );
5105
- })
5106
- ] }) })
5107
- ] })
5108
- ] });
5109
- }
5110
- function BranchSettingsSummary({ value }) {
5111
- if (!value || typeof value !== "object") return /* @__PURE__ */ jsx("span", { children: "Todas las sedes" });
5112
- const settings = value;
5113
- const names = Array.isArray(settings.branches) ? settings.branches : [];
5114
- const locationSummary = settings.allBranches === false ? names.length > 0 ? names.join(", ") : "Sin sedes" : "Todas las sedes";
5115
- const pricingSummary = settings.useBranchPricing ? " \xB7 Precio por sede" : " \xB7 Precio global";
5116
- return /* @__PURE__ */ jsx("span", { children: locationSummary + pricingSummary });
5117
- }
5118
5351
  function SearchableMultiSelect({
5119
5352
  options,
5120
5353
  value,
@@ -5267,32 +5500,40 @@ function SearchableMultiSelect({
5267
5500
  ] })
5268
5501
  ] })
5269
5502
  ] }),
5270
- /* @__PURE__ */ jsx("div", { role: "listbox", "aria-multiselectable": "true", className: "max-h-56 overflow-y-auto p-2", children: loading ? /* @__PURE__ */ jsx("p", { className: "py-4 text-center text-xs text-slate-400", children: "Cargando opciones..." }) : error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "py-4 text-center text-xs text-red-600", children: error }) : visibleOptions.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-4 text-center text-xs text-slate-400", children: options.length === 0 ? emptyMessage : "No hay resultados para la b\xFAsqueda." }) : /* @__PURE__ */ jsx("div", { className: "space-y-1", children: visibleOptions.map((option) => {
5271
- const isSelected = value.includes(option.value);
5272
- const isAtMax = !!max && value.length >= max && !isSelected;
5273
- return /* @__PURE__ */ jsxs(
5274
- "button",
5275
- {
5276
- type: "button",
5277
- role: "option",
5278
- "aria-selected": isSelected,
5279
- disabled: isAtMax,
5280
- onClick: () => toggleOption(option.value),
5281
- className: `flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm transition-colors ${isSelected ? "bg-indigo-50 font-semibold text-indigo-900" : "text-slate-700 hover:bg-slate-50"} disabled:cursor-not-allowed disabled:opacity-50`,
5282
- children: [
5283
- /* @__PURE__ */ jsx(
5284
- "span",
5285
- {
5286
- className: `flex h-4 w-4 shrink-0 items-center justify-center rounded border ${isSelected ? "border-indigo-600 bg-indigo-600 text-white" : "border-slate-300 bg-white"}`,
5287
- children: isSelected && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" })
5288
- }
5289
- ),
5290
- /* @__PURE__ */ jsx("span", { className: "truncate", children: option.label })
5291
- ]
5292
- },
5293
- option.value
5294
- );
5295
- }) }) })
5503
+ /* @__PURE__ */ jsx(
5504
+ "div",
5505
+ {
5506
+ role: "listbox",
5507
+ "aria-multiselectable": "true",
5508
+ className: "max-h-56 overflow-y-auto p-2",
5509
+ children: loading ? /* @__PURE__ */ jsx("p", { className: "py-4 text-center text-xs text-slate-400", children: "Cargando opciones..." }) : error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "py-4 text-center text-xs text-red-600", children: error }) : visibleOptions.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-4 text-center text-xs text-slate-400", children: options.length === 0 ? emptyMessage : "No hay resultados para la b\xFAsqueda." }) : /* @__PURE__ */ jsx("div", { className: "space-y-1", children: visibleOptions.map((option) => {
5510
+ const isSelected = value.includes(option.value);
5511
+ const isAtMax = !!max && value.length >= max && !isSelected;
5512
+ return /* @__PURE__ */ jsxs(
5513
+ "button",
5514
+ {
5515
+ type: "button",
5516
+ role: "option",
5517
+ "aria-selected": isSelected,
5518
+ disabled: isAtMax,
5519
+ onClick: () => toggleOption(option.value),
5520
+ className: `flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm transition-colors ${isSelected ? "bg-indigo-50 font-semibold text-indigo-900" : "text-slate-700 hover:bg-slate-50"} disabled:cursor-not-allowed disabled:opacity-50`,
5521
+ children: [
5522
+ /* @__PURE__ */ jsx(
5523
+ "span",
5524
+ {
5525
+ className: `flex h-4 w-4 shrink-0 items-center justify-center rounded border ${isSelected ? "border-indigo-600 bg-indigo-600 text-white" : "border-slate-300 bg-white"}`,
5526
+ children: isSelected && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" })
5527
+ }
5528
+ ),
5529
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: option.label })
5530
+ ]
5531
+ },
5532
+ option.value
5533
+ );
5534
+ }) })
5535
+ }
5536
+ )
5296
5537
  ] })
5297
5538
  ] });
5298
5539
  }
@@ -5318,19 +5559,29 @@ function ReferenceSelect({
5318
5559
  const [formError, setFormError] = useState("");
5319
5560
  const [newRecord, setNewRecord] = useState({});
5320
5561
  const targetCol = ctx.config.collections?.find((c) => c.id === collectionId);
5562
+ const normalizeSearchValue = (field, value2) => {
5563
+ const text = String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").trim().toLocaleLowerCase();
5564
+ return /phone|telefono|teléfono/i.test(field) ? text.replace(/\D/g, "") : text.replace(/\s+/g, " ");
5565
+ };
5321
5566
  const handleSaveRecord = async () => {
5322
5567
  setFormError("");
5323
5568
  if (!targetCol) return;
5324
- const uniqueFields = targetCol.fields.filter((f) => f.unique || f.id === "id" && !f.hideOnCreate);
5569
+ const uniqueFields = targetCol.fields.filter(
5570
+ (f) => f.unique || f.id === "id" && !f.hideOnCreate
5571
+ );
5325
5572
  for (const uf of uniqueFields) {
5326
5573
  const val = String(newRecord[uf.id] || "").trim();
5327
5574
  if (!val) {
5328
5575
  setFormError(`El campo "${uf.label || uf.id}" es obligatorio.`);
5329
5576
  return;
5330
5577
  }
5331
- const isDup = options.some((opt) => String(opt.value || "").trim().toLowerCase() === val.toLowerCase());
5578
+ const isDup = options.some(
5579
+ (opt) => String(opt.value || "").trim().toLowerCase() === val.toLowerCase()
5580
+ );
5332
5581
  if (isDup) {
5333
- setFormError(`Ya existe un registro con este ${uf.label.toLowerCase()} (\xAB${val}\xBB).`);
5582
+ setFormError(
5583
+ `Ya existe un registro con este ${uf.label.toLowerCase()} (\xAB${val}\xBB).`
5584
+ );
5334
5585
  return;
5335
5586
  }
5336
5587
  }
@@ -5357,21 +5608,35 @@ function ReferenceSelect({
5357
5608
  const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
5358
5609
  const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
5359
5610
  const lab = fullName || String(r[displayField] || r.name || r.id);
5611
+ const searchText = [
5612
+ lab,
5613
+ val,
5614
+ ...(targetCol.searchBy || []).map((field) => String(r[field] ?? ""))
5615
+ ].filter(Boolean).join(" ");
5360
5616
  return {
5361
5617
  value: val,
5362
- label: val && val !== lab ? `${lab} (${val})` : lab,
5618
+ label: val && val !== lab && val.length < 20 ? `${lab} (${val})` : lab,
5619
+ searchText,
5363
5620
  raw: r
5364
5621
  };
5365
5622
  });
5366
5623
  setOptions(fromCollection);
5367
- const selectedVal = valueField && entryToSave[valueField] !== void 0 ? String(entryToSave[valueField]) : entryToSave.id;
5624
+ const persistedEntry = (res || []).find((record) => record.id === entryToSave.id) || (res || []).find(
5625
+ (record) => (targetCol.searchBy || []).some((field) => {
5626
+ const requested = normalizeSearchValue(field, entryToSave[field]);
5627
+ return requested && requested === normalizeSearchValue(field, record[field]);
5628
+ })
5629
+ ) || entryToSave;
5630
+ const selectedVal = valueField && persistedEntry[valueField] !== void 0 ? String(persistedEntry[valueField]) : persistedEntry.id;
5368
5631
  onChange(selectedVal);
5369
5632
  if (onSelectRecord) {
5370
- onSelectRecord(entryToSave);
5633
+ onSelectRecord(persistedEntry);
5371
5634
  }
5372
5635
  setModalOpen(false);
5373
5636
  setNewRecord({});
5374
- message.success(t.recordCreatedSuccess || "Registro creado y seleccionado exitosamente.");
5637
+ message.success(
5638
+ t.recordCreatedSuccess || "Registro creado y seleccionado exitosamente."
5639
+ );
5375
5640
  } catch (err) {
5376
5641
  setFormError(err?.message || "Error al crear registro.");
5377
5642
  } finally {
@@ -5381,7 +5646,11 @@ function ReferenceSelect({
5381
5646
  useEffect(() => {
5382
5647
  if (!collectionId) {
5383
5648
  if (fallbackOptions && fallbackOptions.length > 0) {
5384
- setOptions(fallbackOptions.map((opt) => typeof opt === "string" ? { value: opt, label: opt } : opt));
5649
+ setOptions(
5650
+ fallbackOptions.map(
5651
+ (opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
5652
+ )
5653
+ );
5385
5654
  }
5386
5655
  setLoading(false);
5387
5656
  return;
@@ -5392,18 +5661,31 @@ function ReferenceSelect({
5392
5661
  const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
5393
5662
  const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
5394
5663
  const lab = fullName || String(r[displayField] || r.name || r.id);
5664
+ const searchText = [
5665
+ lab,
5666
+ val,
5667
+ ...(targetCol?.searchBy || []).map((field) => String(r[field] ?? ""))
5668
+ ].filter(Boolean).join(" ");
5395
5669
  return {
5396
5670
  value: val,
5397
- label: val && val !== lab ? `${lab} (${val})` : lab,
5671
+ label: val && val !== lab && val.length < 20 ? `${lab} (${val})` : lab,
5672
+ searchText,
5398
5673
  raw: r
5399
5674
  };
5400
5675
  });
5401
5676
  setOptions(fromCollection);
5402
5677
  setLoading(false);
5403
5678
  }).catch((err) => {
5404
- console.error(`Failed to load reference entries for ${collectionId}:`, err);
5679
+ console.error(
5680
+ `Failed to load reference entries for ${collectionId}:`,
5681
+ err
5682
+ );
5405
5683
  if (fallbackOptions && fallbackOptions.length > 0) {
5406
- setOptions(fallbackOptions.map((opt) => typeof opt === "string" ? { value: opt, label: opt } : opt));
5684
+ setOptions(
5685
+ fallbackOptions.map(
5686
+ (opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
5687
+ )
5688
+ );
5407
5689
  }
5408
5690
  setLoading(false);
5409
5691
  });
@@ -5417,85 +5699,67 @@ function ReferenceSelect({
5417
5699
  }
5418
5700
  return list;
5419
5701
  }, [options, singleVal]);
5420
- const canQuickCreate = Boolean(targetCol && targetCol.enableQuickCreate !== false);
5702
+ const canQuickCreate = Boolean(
5703
+ targetCol && targetCol.enableQuickCreate !== false
5704
+ );
5421
5705
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5422
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5423
- /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
5424
- Select,
5425
- {
5426
- size: "large",
5427
- loading,
5428
- showSearch: searchable,
5429
- placeholder: loading ? t.loadingOptions : t.selectOption,
5430
- allowClear: true,
5431
- filterOption: (input, option) => {
5432
- if (!input) return true;
5433
- const q = input.toLowerCase();
5434
- const label = String(option?.label ?? "").toLowerCase();
5435
- const val = String(option?.value ?? "").toLowerCase();
5436
- return label.includes(q) || val.includes(q);
5437
- },
5438
- value: singleVal,
5439
- onChange: (v) => {
5440
- onChange(v || "");
5441
- if (onSelectRecord) {
5442
- const found = options.find((o) => o.value === v);
5443
- if (found?.raw) onSelectRecord(found.raw);
5444
- }
5445
- },
5446
- options: displayOptions,
5447
- dropdownRender: (menu) => /* @__PURE__ */ jsxs("div", { children: [
5448
- menu,
5449
- canQuickCreate && /* @__PURE__ */ jsxs("div", { className: "p-2 border-t border-slate-100 flex items-center justify-between bg-slate-50", children: [
5450
- /* @__PURE__ */ jsx("span", { className: "text-xs text-slate-500 font-medium", children: t.cantFindOption || "\xBFNo encuentras la opci\xF3n?" }),
5451
- /* @__PURE__ */ jsx(
5452
- Button,
5453
- {
5454
- type: "primary",
5455
- size: "small",
5456
- icon: /* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
5457
- onClick: () => {
5458
- setFormError("");
5459
- const init = {};
5460
- targetCol.fields.forEach((f) => {
5461
- if (f.defaultValue !== void 0) init[f.id] = f.defaultValue;
5462
- else if (f.type === "list" || f.multiple) init[f.id] = [""];
5463
- else init[f.id] = "";
5464
- });
5465
- setNewRecord(init);
5466
- setModalOpen(true);
5467
- },
5468
- className: "bg-blue-600 hover:bg-blue-700 text-xs font-semibold rounded-lg shadow-sm",
5469
- children: t.createNewOption || `Crear ${targetCol.name}`
5470
- }
5471
- )
5472
- ] })
5473
- ] }),
5474
- className: "w-full"
5475
- }
5476
- ) }),
5477
- canQuickCreate && /* @__PURE__ */ jsx(
5478
- Button,
5479
- {
5480
- type: "primary",
5481
- size: "large",
5482
- icon: /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4" }),
5483
- onClick: () => {
5484
- setFormError("");
5485
- const init = {};
5486
- targetCol.fields.forEach((f) => {
5487
- if (f.defaultValue !== void 0) init[f.id] = f.defaultValue;
5488
- else if (f.type === "list" || f.multiple) init[f.id] = [""];
5489
- else init[f.id] = "";
5490
- });
5491
- setNewRecord(init);
5492
- setModalOpen(true);
5493
- },
5494
- className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl shrink-0 h-10 px-4 text-xs uppercase tracking-wider",
5495
- children: targetCol.submitLabel || t.newBtn
5496
- }
5497
- )
5498
- ] }),
5706
+ /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx(
5707
+ Select,
5708
+ {
5709
+ size: "large",
5710
+ loading,
5711
+ showSearch: searchable,
5712
+ placeholder: loading ? t.loadingOptions : t.selectOption,
5713
+ allowClear: true,
5714
+ filterOption: (input, option) => {
5715
+ if (!input) return true;
5716
+ const q = input.toLowerCase();
5717
+ const label = String(option?.label ?? "").toLowerCase();
5718
+ const val = String(option?.value ?? "").toLowerCase();
5719
+ const searchText = String(option?.searchText ?? "").toLowerCase();
5720
+ return label.includes(q) || val.includes(q) || searchText.includes(q);
5721
+ },
5722
+ value: singleVal,
5723
+ onChange: (v) => {
5724
+ onChange(v || "");
5725
+ if (onSelectRecord) {
5726
+ const found = options.find((o) => o.value === v);
5727
+ if (found?.raw) onSelectRecord(found.raw);
5728
+ }
5729
+ },
5730
+ options: displayOptions,
5731
+ dropdownRender: (menu) => /* @__PURE__ */ jsxs("div", { children: [
5732
+ menu,
5733
+ canQuickCreate && /* @__PURE__ */ jsxs("div", { className: "p-2 border-t border-slate-100 flex items-center justify-between bg-slate-50", children: [
5734
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-slate-500 font-medium", children: t.cantFindOption || "\xBFNo encuentras la opci\xF3n?" }),
5735
+ /* @__PURE__ */ jsx(
5736
+ Button,
5737
+ {
5738
+ type: "primary",
5739
+ size: "small",
5740
+ icon: /* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
5741
+ onClick: () => {
5742
+ setFormError("");
5743
+ const init = {};
5744
+ targetCol.fields.forEach((f) => {
5745
+ if (f.defaultValue !== void 0)
5746
+ init[f.id] = f.defaultValue;
5747
+ else if (f.type === "list" || f.multiple)
5748
+ init[f.id] = [""];
5749
+ else init[f.id] = "";
5750
+ });
5751
+ setNewRecord(init);
5752
+ setModalOpen(true);
5753
+ },
5754
+ className: "bg-blue-600 hover:bg-blue-700 text-xs font-semibold rounded-lg shadow-sm",
5755
+ children: t.createNewOption || `Crear ${targetCol.name}`
5756
+ }
5757
+ )
5758
+ ] })
5759
+ ] }),
5760
+ className: "w-full"
5761
+ }
5762
+ ) }),
5499
5763
  canQuickCreate && /* @__PURE__ */ jsx(
5500
5764
  Modal,
5501
5765
  {
@@ -5506,7 +5770,9 @@ function ReferenceSelect({
5506
5770
  width: 650,
5507
5771
  footer: null,
5508
5772
  children: /* @__PURE__ */ jsxs("div", { className: "pt-2 space-y-4", children: [
5509
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: targetCol.fields.filter((f) => !f.hideOnCreate && !f.readOnly && f.type !== "signature").map((f) => {
5773
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: targetCol.fields.filter(
5774
+ (f) => !f.hideOnCreate && !f.readOnly && f.type !== "signature"
5775
+ ).map((f) => {
5510
5776
  if (f.dependsOn && newRecord[f.dependsOn.field] !== void 0) {
5511
5777
  const targetVal = f.dependsOn.value;
5512
5778
  const currentVal = newRecord[f.dependsOn.field];
@@ -5535,7 +5801,10 @@ function ReferenceSelect({
5535
5801
  onChange: (e) => {
5536
5802
  const updated = [...currentList];
5537
5803
  updated[idx] = e.target.value;
5538
- setNewRecord((prev) => ({ ...prev, [f.id]: updated }));
5804
+ setNewRecord((prev) => ({
5805
+ ...prev,
5806
+ [f.id]: updated
5807
+ }));
5539
5808
  }
5540
5809
  }
5541
5810
  ),
@@ -5544,7 +5813,9 @@ function ReferenceSelect({
5544
5813
  {
5545
5814
  type: "button",
5546
5815
  onClick: () => {
5547
- const updated = currentList.filter((_, i) => i !== idx);
5816
+ const updated = currentList.filter(
5817
+ (_, i) => i !== idx
5818
+ );
5548
5819
  setNewRecord((prev) => ({
5549
5820
  ...prev,
5550
5821
  [f.id]: updated.length > 0 ? updated : [""]
@@ -5577,7 +5848,9 @@ function ReferenceSelect({
5577
5848
  }
5578
5849
  if (f.type === "select") {
5579
5850
  const opts = f.optionsMap && f.dependsOnField ? f.optionsMap[String(newRecord[f.dependsOnField] || "")] || f.options || [] : f.options || [];
5580
- const formattedOpts = opts.map((o) => typeof o === "string" ? { label: o, value: o } : o);
5851
+ const formattedOpts = opts.map(
5852
+ (o) => typeof o === "string" ? { label: o, value: o } : o
5853
+ );
5581
5854
  return /* @__PURE__ */ jsxs("div", { className: colSpanClass, children: [
5582
5855
  /* @__PURE__ */ jsx("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: f.label }),
5583
5856
  /* @__PURE__ */ jsx(
@@ -5612,7 +5885,10 @@ function ReferenceSelect({
5612
5885
  {
5613
5886
  rows: 3,
5614
5887
  value: newRecord[f.id] || "",
5615
- onChange: (e) => setNewRecord((prev) => ({ ...prev, [f.id]: e.target.value }))
5888
+ onChange: (e) => setNewRecord((prev) => ({
5889
+ ...prev,
5890
+ [f.id]: e.target.value
5891
+ }))
5616
5892
  }
5617
5893
  )
5618
5894
  ] }, f.id);
@@ -5630,17 +5906,26 @@ function ReferenceSelect({
5630
5906
  value: newRecord[f.id] || "",
5631
5907
  placeholder: f.label,
5632
5908
  onChange: (e) => {
5633
- setNewRecord((prev) => ({ ...prev, [f.id]: e.target.value }));
5909
+ setNewRecord((prev) => ({
5910
+ ...prev,
5911
+ [f.id]: e.target.value
5912
+ }));
5634
5913
  if (formError) setFormError("");
5635
5914
  },
5636
5915
  onBlur: (e) => {
5637
5916
  if (f.unique) {
5638
5917
  const clean = (e.target.value || "").trim().toLowerCase();
5639
5918
  if (clean) {
5640
- const dup = options.find((opt) => String(opt.value || "").trim().toLowerCase() === clean);
5919
+ const dup = options.find(
5920
+ (opt) => String(opt.value || "").trim().toLowerCase() === clean
5921
+ );
5641
5922
  if (dup) {
5642
- setFormError(`Ya existe un registro con este ${f.label.toLowerCase()} (\xAB${dup.label || clean}\xBB).`);
5643
- message.warning(`\u26A0\uFE0F Ya existe un registro con este ${f.label.toLowerCase()}: ${clean}.`);
5923
+ setFormError(
5924
+ `Ya existe un registro con este ${f.label.toLowerCase()} (\xAB${dup.label || clean}\xBB).`
5925
+ );
5926
+ message.warning(
5927
+ `\u26A0\uFE0F Ya existe un registro con este ${f.label.toLowerCase()}: ${clean}.`
5928
+ );
5644
5929
  }
5645
5930
  }
5646
5931
  }
@@ -5692,11 +5977,24 @@ function ReferenceTableCell({
5692
5977
  }).catch(() => {
5693
5978
  setLabels(ids);
5694
5979
  });
5695
- }, [collectionId, displayField, valueField, JSON.stringify(ids), ctx.adapter]);
5980
+ }, [
5981
+ collectionId,
5982
+ displayField,
5983
+ valueField,
5984
+ JSON.stringify(ids),
5985
+ ctx.adapter
5986
+ ]);
5696
5987
  if (labels.length === 0) return /* @__PURE__ */ jsx("span", { children: "-" });
5697
5988
  if (multiple || labels.length > 1) {
5698
5989
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1 max-w-[260px]", children: [
5699
- labels.slice(0, 3).map((lbl, idx) => /* @__PURE__ */ jsx("span", { className: "inline-flex px-1.5 py-0.5 rounded bg-slate-100 text-slate-700 text-[11px] font-medium truncate max-w-[120px]", children: lbl }, idx)),
5990
+ labels.slice(0, 3).map((lbl, idx) => /* @__PURE__ */ jsx(
5991
+ "span",
5992
+ {
5993
+ className: "inline-flex px-1.5 py-0.5 rounded bg-slate-100 text-slate-700 text-[11px] font-medium truncate max-w-[120px]",
5994
+ children: lbl
5995
+ },
5996
+ idx
5997
+ )),
5700
5998
  labels.length > 3 && /* @__PURE__ */ jsxs("span", { className: "inline-flex px-1.5 py-0.5 rounded bg-slate-200 text-slate-600 text-[10px] font-bold", children: [
5701
5999
  "+",
5702
6000
  labels.length - 3
@@ -5815,6 +6113,7 @@ function AdminLogin({
5815
6113
  export {
5816
6114
  AdminApp,
5817
6115
  AdminLogin,
6116
+ AdminTimeRangePicker,
5818
6117
  CmsProvider,
5819
6118
  EditableFile,
5820
6119
  EditableImage,
@@ -5822,6 +6121,8 @@ export {
5822
6121
  EditableList,
5823
6122
  EditableReference,
5824
6123
  EditableText,
6124
+ FormattedNumberInput,
6125
+ SearchableMultiSelect,
5825
6126
  SubscriptionPage,
5826
6127
  SubscriptionProvider,
5827
6128
  generateDefaultTemplate,