admin-lib-cms 1.2.10 → 1.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -826,13 +826,196 @@ function EditableReference({
826
826
  }
827
827
 
828
828
  // src/admin/AdminApp.tsx
829
- var import_react5 = require("react");
829
+ var import_react5 = __toESM(require("react"));
830
830
  var import_react_dom = require("react-dom");
831
831
  var import_antd = require("antd");
832
832
  var import_dayjs = __toESM(require("dayjs"));
833
833
  var import_lucide_react2 = require("lucide-react");
834
+
835
+ // src/admin/i18n.ts
836
+ var translations = {
837
+ es: {
838
+ menuDashboard: "Dashboard",
839
+ menuPages: "P\xE1ginas",
840
+ menuCollections: "Colecciones",
841
+ menuData: "Datos",
842
+ menuConfig: "Configuraci\xF3n",
843
+ menuSettings: "Ajustes",
844
+ menuSubscription: "Suscripci\xF3n",
845
+ liveEditor: "Editor en vivo",
846
+ viewSite: "Ver sitio",
847
+ signOut: "Cerrar sesi\xF3n",
848
+ signedInAs: "Conectado como",
849
+ saving: "Guardando...",
850
+ saved: "Guardado",
851
+ saveChanges: "Guardar cambios",
852
+ discardChanges: "Descartar",
853
+ unsavedChanges: "Cambios sin guardar",
854
+ desktop: "Escritorio",
855
+ tablet: "Tableta",
856
+ mobile: "M\xF3vil",
857
+ search: "Buscar...",
858
+ filterBy: "Filtrar por...",
859
+ all: "Todos",
860
+ actions: "Acciones",
861
+ edit: "Editar",
862
+ delete: "Eliminar",
863
+ cancel: "Cancelar",
864
+ save: "Guardar",
865
+ create: "Crear",
866
+ newEntry: "Nuevo",
867
+ createNew: "Crear nuevo",
868
+ confirmDeleteTitle: "\xBFEliminar este registro?",
869
+ confirmDeleteText: "Esta acci\xF3n no se puede deshacer.",
870
+ deleteSuccess: "Registro eliminado exitosamente.",
871
+ saveSuccess: "Registro guardado exitosamente.",
872
+ noRecords: "No hay registros disponibles.",
873
+ recordsFound: "registros encontrados",
874
+ back: "Volver",
875
+ apply: "Aplicar",
876
+ close: "Cerrar",
877
+ signatureRegistered: "Firma registrada",
878
+ viewLarger: "Click en la firma para verla en pantalla grande",
879
+ previewMask: "Ver m\xE1s grande",
880
+ addSignature: "AGREGAR FIRMA",
881
+ replaceSignature: "REEMPLAZAR FIRMA",
882
+ uploadImage: "SUBIR IMAGEN",
883
+ uploadNewImage: "SUBIR NUEVA IMAGEN",
884
+ signOnScreen: "Firmar en pantalla",
885
+ signInstructions: "Dibuja la firma en el recuadro usando el dedo o el mouse:",
886
+ clear: "Limpiar",
887
+ saveSignature: "Guardar Firma",
888
+ selectOption: "-- Selecciona una opci\xF3n --",
889
+ loadingOptions: "Cargando opciones...",
890
+ cantFindClient: "\xBFNo encuentras el cliente?",
891
+ createClient: "Crear cliente",
892
+ newBtn: "Nuevo",
893
+ basicDetails: "Datos b\xE1sicos",
894
+ clientType: "Tipo",
895
+ clientDocType: "Tipo de documento",
896
+ clientIdentification: "Identificaci\xF3n",
897
+ clientBranch: "Sucursal o sede",
898
+ clientName: "Nombre",
899
+ clientEmail: "Email",
900
+ clientPhone: "Tel\xE9fono",
901
+ clientCity: "Ciudad",
902
+ clientAddress: "direcci\xF3n",
903
+ clientCreatedSuccess: "Cliente creado y seleccionado exitosamente.",
904
+ idRequired: "La identificaci\xF3n es obligatoria.",
905
+ nameRequired: "El nombre es obligatorio.",
906
+ signInTitle: "Iniciar sesi\xF3n",
907
+ signInSubtitle: "Ingresa tus credenciales para acceder al panel",
908
+ emailLabel: "Correo electr\xF3nico",
909
+ passwordLabel: "Contrase\xF1a",
910
+ signInButton: "Iniciar sesi\xF3n",
911
+ invalidCredentials: "Credenciales inv\xE1lidas",
912
+ loggingIn: "Iniciando sesi\xF3n...",
913
+ submissions: "Mensajes y Formularios",
914
+ noSubmissions: "No hay env\xEDos registrados",
915
+ exportCsv: "Exportar CSV",
916
+ markRead: "Marcar como le\xEDdo",
917
+ settingsTitle: "Ajustes del sitio",
918
+ entries: "registros"
919
+ },
920
+ en: {
921
+ menuDashboard: "Dashboard",
922
+ menuPages: "Pages",
923
+ menuCollections: "Collections",
924
+ menuData: "Data",
925
+ menuConfig: "Settings",
926
+ menuSettings: "Preferences",
927
+ menuSubscription: "Subscription",
928
+ liveEditor: "Live Editor",
929
+ viewSite: "View site",
930
+ signOut: "Sign out",
931
+ signedInAs: "Signed in as",
932
+ saving: "Saving...",
933
+ saved: "Saved",
934
+ saveChanges: "Save changes",
935
+ discardChanges: "Discard",
936
+ unsavedChanges: "Unsaved changes",
937
+ desktop: "Desktop",
938
+ tablet: "Tablet",
939
+ mobile: "Mobile",
940
+ search: "Search...",
941
+ filterBy: "Filter by...",
942
+ all: "All",
943
+ actions: "Actions",
944
+ edit: "Edit",
945
+ delete: "Delete",
946
+ cancel: "Cancel",
947
+ save: "Save",
948
+ create: "Create",
949
+ newEntry: "New",
950
+ createNew: "Create new",
951
+ confirmDeleteTitle: "Delete this record?",
952
+ confirmDeleteText: "This action cannot be undone.",
953
+ deleteSuccess: "Record deleted successfully.",
954
+ saveSuccess: "Record saved successfully.",
955
+ noRecords: "No records found.",
956
+ recordsFound: "records found",
957
+ back: "Back",
958
+ apply: "Apply",
959
+ close: "Close",
960
+ signatureRegistered: "Signature registered",
961
+ viewLarger: "Click signature to view full size",
962
+ previewMask: "View larger",
963
+ addSignature: "ADD SIGNATURE",
964
+ replaceSignature: "REPLACE SIGNATURE",
965
+ uploadImage: "UPLOAD IMAGE",
966
+ uploadNewImage: "UPLOAD NEW IMAGE",
967
+ signOnScreen: "Sign on screen",
968
+ signInstructions: "Draw signature in the box using finger or mouse:",
969
+ clear: "Clear",
970
+ saveSignature: "Save Signature",
971
+ selectOption: "-- Select an option --",
972
+ loadingOptions: "Loading options...",
973
+ cantFindClient: "Can't find the client?",
974
+ createClient: "Create client",
975
+ newBtn: "New",
976
+ basicDetails: "Basic details",
977
+ clientType: "Type",
978
+ clientDocType: "Document type",
979
+ clientIdentification: "Identification",
980
+ clientBranch: "Branch or site",
981
+ clientName: "Name",
982
+ clientEmail: "Email",
983
+ clientPhone: "Phone",
984
+ clientCity: "City",
985
+ clientAddress: "Address",
986
+ clientCreatedSuccess: "Client created and selected successfully.",
987
+ idRequired: "Identification is required.",
988
+ nameRequired: "Name is required.",
989
+ signInTitle: "Sign In",
990
+ signInSubtitle: "Enter your credentials to access the panel",
991
+ emailLabel: "Email address",
992
+ passwordLabel: "Password",
993
+ signInButton: "Sign In",
994
+ invalidCredentials: "Invalid credentials",
995
+ loggingIn: "Signing in...",
996
+ submissions: "Form Submissions",
997
+ noSubmissions: "No submissions yet",
998
+ exportCsv: "Export CSV",
999
+ markRead: "Mark as read",
1000
+ settingsTitle: "Site Settings",
1001
+ entries: "entries"
1002
+ }
1003
+ };
1004
+ function getAdminTranslations(locale) {
1005
+ const norm = String(locale || "").trim().toLowerCase();
1006
+ if (norm === "es" || norm.startsWith("es-")) {
1007
+ return translations.es;
1008
+ }
1009
+ return translations.en;
1010
+ }
1011
+
1012
+ // src/admin/AdminApp.tsx
834
1013
  var import_lucide_react3 = require("lucide-react");
835
1014
  var import_jsx_runtime5 = require("react/jsx-runtime");
1015
+ var AdminI18nContext = import_react5.default.createContext(getAdminTranslations("en"));
1016
+ function useAdminI18n() {
1017
+ return import_react5.default.useContext(AdminI18nContext);
1018
+ }
836
1019
  var TIME_STORAGE_FORMAT = "HH:mm";
837
1020
  var TIME_DISPLAY_FORMAT = "h:mm A";
838
1021
  var TIME_PICKER_THEME = {
@@ -873,23 +1056,24 @@ function AdminTimeRangePicker(props) {
873
1056
  }
874
1057
  ) });
875
1058
  }
876
- function AdminTimePicker(props) {
877
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
878
- import_antd.TimePicker,
879
- {
880
- ...props,
881
- className: `w-full min-w-0 ${props.className ?? ""}`,
882
- style: {
883
- boxShadow: "0 1px 2px rgba(15, 23, 42, 0.08)",
884
- ...props.style
885
- }
886
- }
887
- ) });
888
- }
889
1059
  function toDayjsTime(value) {
890
- const match = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(String(value ?? ""));
891
- if (!match) return null;
892
- return (0, import_dayjs.default)().hour(Number(match[1])).minute(Number(match[2])).second(0).millisecond(0);
1060
+ const str = String(value ?? "").trim();
1061
+ if (!str) return null;
1062
+ const match12 = /^(\d{1,2}):(\d{2})\s*([ap]\.?m\.?)$/i.exec(str);
1063
+ if (match12) {
1064
+ let h = Number(match12[1]);
1065
+ const m = Number(match12[2]);
1066
+ const isPm = match12[3].toLowerCase().startsWith("p");
1067
+ if (isPm && h < 12) h += 12;
1068
+ if (!isPm && h === 12) h = 0;
1069
+ return (0, import_dayjs.default)().hour(h).minute(m).second(0).millisecond(0);
1070
+ }
1071
+ const match24 = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(str);
1072
+ if (match24) {
1073
+ return (0, import_dayjs.default)().hour(Number(match24[1])).minute(Number(match24[2])).second(0).millisecond(0);
1074
+ }
1075
+ const parsed = (0, import_dayjs.default)(str, ["h:mm a", "h:mm A", "hh:mm a", "hh:mm A", "HH:mm"]);
1076
+ return parsed.isValid() ? parsed : null;
893
1077
  }
894
1078
  function toStoredTime(value) {
895
1079
  return value?.format(TIME_STORAGE_FORMAT) ?? "";
@@ -950,6 +1134,8 @@ function AdminApp(props) {
950
1134
  }
951
1135
  function AdminAppContent(props) {
952
1136
  const ctx = useCmsContext();
1137
+ const rawLocale = props.locale ?? props.lang ?? ctx.config.locale ?? ctx.config.lang ?? "en";
1138
+ const t = (0, import_react5.useMemo)(() => getAdminTranslations(rawLocale), [rawLocale]);
953
1139
  const hasDashboard = Boolean(props.dashboard);
954
1140
  const [section, setSection] = (0, import_react5.useState)(hasDashboard ? "dashboard" : "pages");
955
1141
  const [authChecking, setAuthChecking] = (0, import_react5.useState)(true);
@@ -959,13 +1145,13 @@ function AdminAppContent(props) {
959
1145
  const hideGlobals = props.hideGlobals ?? ctx.config.hideGlobals ?? false;
960
1146
  const hideConfig = props.hideConfig ?? ctx.config.hideConfig ?? false;
961
1147
  const menuLabels = {
962
- dashboard: "Dashboard",
963
- pages: "P\xE1ginas",
964
- collections: "Colecciones",
965
- data: "Datos",
966
- config: "Configuraci\xF3n",
967
- settings: "Ajustes",
968
- subscription: "Suscripci\xF3n",
1148
+ dashboard: t.menuDashboard,
1149
+ pages: t.menuPages,
1150
+ collections: t.menuCollections,
1151
+ data: t.menuData,
1152
+ config: t.menuConfig,
1153
+ settings: t.menuSettings,
1154
+ subscription: t.menuSubscription,
969
1155
  ...ctx.config.menuLabels,
970
1156
  ...props.menuLabels
971
1157
  };
@@ -1001,7 +1187,7 @@ function AdminAppContent(props) {
1001
1187
  if (!isSubscriptionActive) {
1002
1188
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-col lg:flex-row h-screen w-full overflow-hidden bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {}) });
1003
1189
  }
1004
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-screen w-full bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900 overflow-hidden", children: [
1190
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AdminI18nContext.Provider, { value: t, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-screen w-full bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900 overflow-hidden", children: [
1005
1191
  daysOverdue > 0 && daysOverdue <= 15 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-amber-400 text-amber-950 px-4 py-2.5 text-center text-sm font-semibold shadow-sm z-50", children: "Your account has an overdue balance. Please update your payment." }),
1006
1192
  daysOverdue > 15 && daysOverdue < 30 && /* @__PURE__ */ (0, import_jsx_runtime5.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." }),
1007
1193
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
@@ -1017,81 +1203,155 @@ function AdminAppContent(props) {
1017
1203
  ] }),
1018
1204
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
1019
1205
  ] }),
1020
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("nav", { className: "flex flex-row lg:flex-col overflow-x-auto lg:overflow-visible space-x-2 lg:space-x-0 lg:space-y-1.5 p-3 lg:p-4 text-sm font-medium hide-scrollbar", children: [
1021
- hasDashboard && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1022
- SideItem,
1023
- {
1024
- active: section === "dashboard",
1025
- onClick: () => setSection("dashboard"),
1026
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.BarChart3, { className: "h-4 w-4 shrink-0" }),
1027
- children: menuLabels.dashboard
1028
- }
1029
- ),
1030
- props.customSections?.map((cs) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1031
- SideItem,
1032
- {
1033
- active: section === cs.id,
1034
- onClick: () => setSection(cs.id),
1035
- icon: cs.icon || /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
1036
- children: cs.label
1037
- },
1038
- cs.id
1039
- )),
1040
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1041
- SideItem,
1042
- {
1043
- active: section === "pages",
1044
- onClick: () => setSection("pages"),
1045
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileText, { className: "h-4 w-4 shrink-0" }),
1046
- children: menuLabels.pages
1047
- }
1048
- ),
1049
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1050
- SideItem,
1051
- {
1052
- active: section === "collections",
1053
- onClick: () => setSection("collections"),
1054
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
1055
- children: menuLabels.collections
1056
- }
1057
- ),
1058
- !hideData && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1059
- SideItem,
1060
- {
1061
- active: section === "submissions",
1062
- onClick: () => setSection("submissions"),
1063
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-4 w-4 shrink-0" }),
1064
- children: menuLabels.data
1065
- }
1066
- ),
1067
- !hideConfig && !hideGlobals && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1068
- SideItem,
1069
- {
1070
- active: section === "config",
1071
- onClick: () => setSection("config"),
1072
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
1073
- children: menuLabels.config
1074
- }
1075
- ),
1076
- !hideSettings && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1077
- SideItem,
1078
- {
1079
- active: section === "settings",
1080
- onClick: () => setSection("settings"),
1081
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Settings, { className: "h-4 w-4 shrink-0" }),
1082
- children: menuLabels.settings
1083
- }
1084
- ),
1085
- subscriptionCtx && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1086
- SideItem,
1087
- {
1088
- active: section === "subscription",
1089
- onClick: () => setSection("subscription"),
1090
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CreditCard, { className: "h-4 w-4 shrink-0" }),
1091
- children: menuLabels.subscription
1092
- }
1093
- )
1094
- ] }),
1206
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("nav", { className: "flex flex-row lg:flex-col overflow-x-auto lg:overflow-visible space-x-2 lg:space-x-0 lg:space-y-1.5 p-3 lg:p-4 text-sm font-medium hide-scrollbar", children: (() => {
1207
+ const navItemsMap = /* @__PURE__ */ new Map();
1208
+ if (hasDashboard) {
1209
+ navItemsMap.set(
1210
+ "dashboard",
1211
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1212
+ SideItem,
1213
+ {
1214
+ active: section === "dashboard",
1215
+ onClick: () => setSection("dashboard"),
1216
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.BarChart3, { className: "h-4 w-4 shrink-0" }),
1217
+ children: menuLabels.dashboard
1218
+ },
1219
+ "dashboard"
1220
+ )
1221
+ );
1222
+ }
1223
+ navItemsMap.set(
1224
+ "pages",
1225
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1226
+ SideItem,
1227
+ {
1228
+ active: section === "pages",
1229
+ onClick: () => setSection("pages"),
1230
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileText, { className: "h-4 w-4 shrink-0" }),
1231
+ children: menuLabels.pages
1232
+ },
1233
+ "pages"
1234
+ )
1235
+ );
1236
+ navItemsMap.set(
1237
+ "collections",
1238
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1239
+ SideItem,
1240
+ {
1241
+ active: section === "collections",
1242
+ onClick: () => setSection("collections"),
1243
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
1244
+ children: menuLabels.collections
1245
+ },
1246
+ "collections"
1247
+ )
1248
+ );
1249
+ props.customSections?.forEach((cs) => {
1250
+ navItemsMap.set(
1251
+ cs.id,
1252
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1253
+ SideItem,
1254
+ {
1255
+ active: section === cs.id,
1256
+ onClick: () => setSection(cs.id),
1257
+ icon: cs.icon || /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
1258
+ children: cs.label
1259
+ },
1260
+ cs.id
1261
+ )
1262
+ );
1263
+ });
1264
+ if (!hideData) {
1265
+ navItemsMap.set(
1266
+ "submissions",
1267
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1268
+ SideItem,
1269
+ {
1270
+ active: section === "submissions",
1271
+ onClick: () => setSection("submissions"),
1272
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-4 w-4 shrink-0" }),
1273
+ children: menuLabels.data
1274
+ },
1275
+ "submissions"
1276
+ )
1277
+ );
1278
+ }
1279
+ if (!hideConfig && !hideGlobals) {
1280
+ navItemsMap.set(
1281
+ "config",
1282
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1283
+ SideItem,
1284
+ {
1285
+ active: section === "config",
1286
+ onClick: () => setSection("config"),
1287
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
1288
+ children: menuLabels.config
1289
+ },
1290
+ "config"
1291
+ )
1292
+ );
1293
+ }
1294
+ if (!hideSettings) {
1295
+ navItemsMap.set(
1296
+ "settings",
1297
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1298
+ SideItem,
1299
+ {
1300
+ active: section === "settings",
1301
+ onClick: () => setSection("settings"),
1302
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Settings, { className: "h-4 w-4 shrink-0" }),
1303
+ children: menuLabels.settings
1304
+ },
1305
+ "settings"
1306
+ )
1307
+ );
1308
+ }
1309
+ if (subscriptionCtx) {
1310
+ navItemsMap.set(
1311
+ "subscription",
1312
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1313
+ SideItem,
1314
+ {
1315
+ active: section === "subscription",
1316
+ onClick: () => setSection("subscription"),
1317
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CreditCard, { className: "h-4 w-4 shrink-0" }),
1318
+ children: menuLabels.subscription
1319
+ },
1320
+ "subscription"
1321
+ )
1322
+ );
1323
+ }
1324
+ const orderedKeys = [];
1325
+ if (props.menuOrder && Array.isArray(props.menuOrder) && props.menuOrder.length > 0) {
1326
+ props.menuOrder.forEach((k) => {
1327
+ if (navItemsMap.has(k) && !orderedKeys.includes(k)) {
1328
+ orderedKeys.push(k);
1329
+ }
1330
+ });
1331
+ navItemsMap.forEach((_, k) => {
1332
+ if (!orderedKeys.includes(k)) {
1333
+ orderedKeys.push(k);
1334
+ }
1335
+ });
1336
+ } else {
1337
+ const topCustom = (props.customSections || []).filter((cs) => cs.position === "top").map((cs) => cs.id);
1338
+ const bottomCustom = (props.customSections || []).filter((cs) => cs.position === "bottom" || cs.position === "after-collections").map((cs) => cs.id);
1339
+ const otherCustom = (props.customSections || []).filter(
1340
+ (cs) => cs.position !== "top" && cs.position !== "bottom" && cs.position !== "after-collections"
1341
+ ).map((cs) => cs.id);
1342
+ if (hasDashboard) orderedKeys.push("dashboard");
1343
+ topCustom.forEach((k) => orderedKeys.push(k));
1344
+ orderedKeys.push("pages");
1345
+ orderedKeys.push("collections");
1346
+ otherCustom.forEach((k) => orderedKeys.push(k));
1347
+ bottomCustom.forEach((k) => orderedKeys.push(k));
1348
+ if (!hideData) orderedKeys.push("submissions");
1349
+ if (!hideConfig && !hideGlobals) orderedKeys.push("config");
1350
+ if (!hideSettings) orderedKeys.push("settings");
1351
+ if (subscriptionCtx) orderedKeys.push("subscription");
1352
+ }
1353
+ return orderedKeys.map((k) => navItemsMap.get(k));
1354
+ })() }),
1095
1355
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1096
1356
  "button",
1097
1357
  {
@@ -1102,7 +1362,7 @@ function AdminAppContent(props) {
1102
1362
  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",
1103
1363
  children: [
1104
1364
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.LogOut, { className: "w-4 h-4" }),
1105
- "Logout"
1365
+ t.signOut
1106
1366
  ]
1107
1367
  }
1108
1368
  ) })
@@ -1120,7 +1380,7 @@ function AdminAppContent(props) {
1120
1380
  )
1121
1381
  ] })
1122
1382
  ] })
1123
- ] });
1383
+ ] }) });
1124
1384
  }
1125
1385
  function SideItem({
1126
1386
  active,
@@ -1229,6 +1489,7 @@ function PagesSection() {
1229
1489
  }
1230
1490
  function PageEditor({ page, showList, onToggleList }) {
1231
1491
  const ctx = useCmsContext();
1492
+ const t = useAdminI18n();
1232
1493
  const iframeRef = (0, import_react5.useRef)(null);
1233
1494
  const [registered, setRegistered] = (0, import_react5.useState)([]);
1234
1495
  const [selectedId, setSelectedId] = (0, import_react5.useState)(null);
@@ -1322,7 +1583,7 @@ function PageEditor({ page, showList, onToggleList }) {
1322
1583
  className: "inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 hover:text-slate-900 disabled:opacity-50 transition-colors bg-white shadow-sm shrink-0",
1323
1584
  children: [
1324
1585
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-3.5 w-3.5" }),
1325
- "Discard"
1586
+ t.discardChanges
1326
1587
  ]
1327
1588
  }
1328
1589
  ),
@@ -1334,7 +1595,7 @@ function PageEditor({ page, showList, onToggleList }) {
1334
1595
  className: "inline-flex items-center gap-1.5 rounded-lg bg-indigo-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-indigo-700 disabled:opacity-50 transition-colors shadow-sm shrink-0",
1335
1596
  children: [
1336
1597
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-3.5 w-3.5" }),
1337
- "Save"
1598
+ t.save
1338
1599
  ]
1339
1600
  }
1340
1601
  )
@@ -2167,13 +2428,18 @@ function CollectionsSection() {
2167
2428
  collections.find((c) => !c.isSeparator) ?? null
2168
2429
  );
2169
2430
  const [counts, setCounts] = (0, import_react5.useState)({});
2431
+ const colIds = (0, import_react5.useMemo)(
2432
+ () => (ctx.config.collections ?? []).filter((c) => !c.isSeparator).map((c) => c.id).join(","),
2433
+ [ctx.config.collections]
2434
+ );
2170
2435
  (0, import_react5.useEffect)(() => {
2171
- collections.filter((c) => !c.isSeparator).forEach((c) => {
2436
+ const list = ctx.config.collections ?? [];
2437
+ list.filter((c) => !c.isSeparator).forEach((c) => {
2172
2438
  ctx.adapter.listEntries(c.id).then((entries) => {
2173
- setCounts((prev) => ({ ...prev, [c.id]: entries.length }));
2439
+ setCounts((prev) => prev[c.id] === entries.length ? prev : { ...prev, [c.id]: entries.length });
2174
2440
  });
2175
2441
  });
2176
- }, [ctx.adapter, collections]);
2442
+ }, [ctx.adapter, colIds, ctx.collectionChangedAt]);
2177
2443
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
2178
2444
  /* @__PURE__ */ (0, import_jsx_runtime5.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: [
2179
2445
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
@@ -2183,7 +2449,8 @@ function CollectionsSection() {
2183
2449
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2184
2450
  "li",
2185
2451
  {
2186
- className: "my-2 border-t border-slate-200/80"
2452
+ className: "my-3 border-t border-slate-200/80 pt-2 px-1 list-none",
2453
+ children: c.name && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400", children: c.name })
2187
2454
  },
2188
2455
  c.id || `sep-${idx}`
2189
2456
  );
@@ -2226,8 +2493,10 @@ function CollectionsSection() {
2226
2493
  }
2227
2494
  function CollectionEditor({ collection }) {
2228
2495
  const ctx = useCmsContext();
2496
+ const t = useAdminI18n();
2229
2497
  const [entries, setEntries] = (0, import_react5.useState)([]);
2230
2498
  const [editing, setEditing] = (0, import_react5.useState)(null);
2499
+ const [isCreatingManual, setIsCreatingManual] = (0, import_react5.useState)(false);
2231
2500
  const [saving, setSaving] = (0, import_react5.useState)(false);
2232
2501
  const [deletingId, setDeletingId] = (0, import_react5.useState)(null);
2233
2502
  const [loadingEntries, setLoadingEntries] = (0, import_react5.useState)(true);
@@ -2253,6 +2522,7 @@ function CollectionEditor({ collection }) {
2253
2522
  load();
2254
2523
  }, [load]);
2255
2524
  const startNew = () => {
2525
+ setIsCreatingManual(true);
2256
2526
  const base = { id: crypto.randomUUID() };
2257
2527
  collection.fields.forEach((f) => {
2258
2528
  if (f.id === "order") {
@@ -2287,6 +2557,16 @@ function CollectionEditor({ collection }) {
2287
2557
  try {
2288
2558
  const finalEditing = { ...editing };
2289
2559
  collection.fields.forEach((f) => {
2560
+ if (f.autoIncrement && isCreatingEntry && (!finalEditing[f.id] || Number(finalEditing[f.id]) === 0)) {
2561
+ const maxVal = entries.reduce(
2562
+ (max, e) => Math.max(max, Number(e[f.id]) || 0),
2563
+ 0
2564
+ );
2565
+ finalEditing[f.id] = maxVal > 0 ? maxVal + 1 : 1;
2566
+ }
2567
+ if (f.id === "estado" && !finalEditing[f.id]) {
2568
+ finalEditing[f.id] = "Nueva";
2569
+ }
2290
2570
  if (f.type === "time-range") {
2291
2571
  delete finalEditing[f.id];
2292
2572
  } else if (f.type === "slug" && !finalEditing[f.id]) {
@@ -2299,6 +2579,7 @@ function CollectionEditor({ collection }) {
2299
2579
  await ctx.adapter.putEntry(collection.id, finalEditing);
2300
2580
  ctx.notifyCollectionChanged();
2301
2581
  setEditing(null);
2582
+ setIsCreatingManual(false);
2302
2583
  load();
2303
2584
  } finally {
2304
2585
  setSaving(false);
@@ -2350,80 +2631,124 @@ function CollectionEditor({ collection }) {
2350
2631
  setDraggedIdx(null);
2351
2632
  setDragOverIdx(null);
2352
2633
  };
2353
- const visibleFields = collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0, 5);
2354
- const isCreatingEntry = editing ? !entries.some((entry) => entry.id === editing.id) : false;
2634
+ 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);
2635
+ const isCreatingEntry = isCreatingManual || (editing ? !entries.some((entry) => entry.id && entry.id === editing.id || entry._id && entry._id === (editing._id || editing.id)) : false);
2355
2636
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mx-auto max-w-5xl", children: [
2356
2637
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-8 flex items-center justify-between", children: [
2357
2638
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
2358
2639
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: collection.name }),
2359
2640
  collection.description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm text-slate-500 mt-1", children: collection.description })
2360
2641
  ] }),
2361
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2362
- "button",
2642
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2643
+ import_antd.Button,
2363
2644
  {
2645
+ type: "primary",
2646
+ size: "large",
2647
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
2364
2648
  onClick: startNew,
2365
- className: "inline-flex items-center gap-2 rounded-xl bg-indigo-600 px-4 py-2.5 text-sm font-bold text-white shadow-sm hover:bg-indigo-700 hover:shadow transition-all",
2366
- children: [
2367
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
2368
- " New Entry"
2369
- ]
2649
+ className: "rounded-xl font-bold shadow-sm",
2650
+ children: t.newEntry
2370
2651
  }
2371
2652
  )
2372
2653
  ] }),
2373
2654
  !editing && (collection.searchBy?.length || collection.filterBy?.length) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-6 flex flex-wrap gap-4 items-center p-4 bg-white rounded-2xl border border-slate-200 shadow-sm animate-in fade-in slide-in-from-top-2", children: [
2374
- collection.searchBy?.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative flex-1 min-w-[200px]", children: [
2375
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" }),
2376
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2377
- "input",
2378
- {
2379
- type: "text",
2380
- placeholder: `Search by ${collection.searchBy.join(", ")}...`,
2381
- value: search,
2382
- onChange: (e) => {
2383
- setSearch(e.target.value);
2384
- setPage(1);
2385
- },
2386
- className: "w-full rounded-xl border border-slate-200 bg-slate-50 py-2.5 pl-10 pr-4 text-sm focus:border-indigo-500 focus:bg-white focus:ring-4 focus:ring-indigo-500/10 outline-none transition-all"
2387
- }
2388
- )
2389
- ] }) : null,
2655
+ collection.searchBy?.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "relative flex-1 min-w-[220px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2656
+ import_antd.Input,
2657
+ {
2658
+ size: "large",
2659
+ prefix: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "h-4 w-4 text-slate-400" }),
2660
+ placeholder: `Buscar por ${collection.searchBy.map((s) => s === "numero" ? "n\xFAmero" : s === "clienteNombre" ? "cliente" : s === "clienteId" ? "identificaci\xF3n" : s === "fecha" ? "fecha" : s).join(", ")}...`,
2661
+ value: search,
2662
+ allowClear: true,
2663
+ onChange: (e) => {
2664
+ setSearch(e.target.value);
2665
+ setPage(1);
2666
+ },
2667
+ className: "rounded-xl"
2668
+ }
2669
+ ) }) : null,
2390
2670
  collection.filterBy?.map((f) => {
2391
2671
  const fieldDef = collection.fields.find((cf) => cf.id === f);
2392
- const uniqueVals = Array.from(new Set(entries.map((e) => String(e[f] || "")))).filter(Boolean);
2393
- if (!fieldDef || uniqueVals.length === 0) return null;
2394
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "min-w-[150px] relative", children: [
2395
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2396
- "select",
2672
+ if (!fieldDef) return null;
2673
+ if (fieldDef.type === "date") {
2674
+ const dateVal = filters[f] ? (0, import_dayjs.default)(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]).isValid() ? (0, import_dayjs.default)(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]) : null : null;
2675
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-[180px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2676
+ import_antd.DatePicker,
2397
2677
  {
2398
- value: filters[f] || "",
2399
- onChange: (e) => {
2400
- setFilters((prev) => ({ ...prev, [f]: e.target.value }));
2678
+ size: "large",
2679
+ format: "YYYY/MM/DD",
2680
+ placeholder: `Filtrar por ${fieldDef.label}`,
2681
+ allowClear: true,
2682
+ value: dateVal,
2683
+ onChange: (_, dateStr) => {
2684
+ const val = Array.isArray(dateStr) ? dateStr[0] : dateStr;
2685
+ setFilters((prev) => ({ ...prev, [f]: val || "" }));
2401
2686
  setPage(1);
2402
2687
  },
2403
- className: "w-full rounded-xl border border-slate-200 bg-slate-50 py-2.5 px-4 pr-10 text-sm focus:border-indigo-500 focus:bg-white focus:ring-4 focus:ring-indigo-500/10 outline-none transition-all appearance-none",
2404
- children: [
2405
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
2406
- "All ",
2407
- fieldDef.label
2408
- ] }),
2409
- uniqueVals.map((v) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: v, children: v }, v))
2410
- ]
2688
+ className: "w-full rounded-xl"
2411
2689
  }
2412
- ),
2413
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
2414
- ] }, f);
2690
+ ) }, f);
2691
+ }
2692
+ const predefinedOptions = (fieldDef.options || []).map(
2693
+ (opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
2694
+ );
2695
+ const entryVals = Array.from(new Set(entries.map((e) => String(e[f] || "")))).filter(Boolean);
2696
+ const combinedOptions = [...predefinedOptions];
2697
+ for (const ev of entryVals) {
2698
+ if (!combinedOptions.some((o) => o.value === ev)) {
2699
+ combinedOptions.push({ value: ev, label: ev });
2700
+ }
2701
+ }
2702
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-[170px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2703
+ import_antd.Select,
2704
+ {
2705
+ size: "large",
2706
+ value: filters[f] || void 0,
2707
+ placeholder: `Filtrar por ${fieldDef.label}`,
2708
+ allowClear: true,
2709
+ onChange: (v) => {
2710
+ setFilters((prev) => ({ ...prev, [f]: v || "" }));
2711
+ setPage(1);
2712
+ },
2713
+ options: combinedOptions,
2714
+ className: "w-full"
2715
+ }
2716
+ ) }, f);
2415
2717
  })
2416
2718
  ] }),
2417
2719
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2418
2720
  import_antd.Modal,
2419
2721
  {
2420
2722
  open: Boolean(editing),
2421
- title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2 text-slate-900", children: [
2422
- isCreatingEntry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4 text-indigo-600" }),
2423
- isCreatingEntry ? "Create Entry" : "Edit Entry"
2723
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between pr-8", children: [
2724
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2 text-slate-900 font-bold", children: [
2725
+ isCreatingEntry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4 text-indigo-600" }),
2726
+ 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}`
2727
+ ] }),
2728
+ !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
2729
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
2730
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2731
+ import_antd.Select,
2732
+ {
2733
+ size: "middle",
2734
+ value: String(editing.estado || "Nueva"),
2735
+ onChange: (val) => setEditing({ ...editing, estado: val }),
2736
+ options: [
2737
+ { value: "Nueva", label: "Nueva" },
2738
+ { value: "Proceso", label: "Proceso" },
2739
+ { value: "Terminado", label: "Terminado" },
2740
+ { value: "Cancelado", label: "Cancelado" }
2741
+ ],
2742
+ className: "w-32"
2743
+ }
2744
+ )
2745
+ ] })
2424
2746
  ] }),
2425
2747
  onCancel: () => {
2426
- if (!saving) setEditing(null);
2748
+ if (!saving) {
2749
+ setEditing(null);
2750
+ setIsCreatingManual(false);
2751
+ }
2427
2752
  },
2428
2753
  footer: null,
2429
2754
  centered: true,
@@ -2444,463 +2769,559 @@ function CollectionEditor({ collection }) {
2444
2769
  backdropFilter: "blur(8px)"
2445
2770
  }
2446
2771
  },
2447
- children: editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
2448
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-1 gap-5 lg:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order" && !f.hidden).map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "branch-settings" || f.type === "time-range" ? "lg:col-span-2" : ""}`, children: [
2449
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
2450
- f.label,
2451
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
2452
- ] }),
2453
- f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2454
- BranchSettingsEditor,
2455
- {
2456
- collectionId: f.collection || "",
2457
- value: editing[f.id],
2458
- globalPrice: Number(editing.price) || 0,
2459
- globalDiscount: Number(editing.discountPercent) || 0,
2460
- onChange: (val) => setEditing({ ...editing, [f.id]: val })
2772
+ children: editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
2773
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-1 gap-5 lg:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order" && !f.hidden).filter((f) => {
2774
+ if (f.id === "estado" && !isCreatingEntry) return false;
2775
+ if (isCreatingEntry && f.hideOnCreate) return false;
2776
+ if (f.dependsOn) {
2777
+ const targetVal = editing[f.dependsOn.field];
2778
+ if (Array.isArray(f.dependsOn.value)) {
2779
+ if (!f.dependsOn.value.includes(targetVal)) return false;
2780
+ } else if (targetVal !== f.dependsOn.value) {
2781
+ return false;
2461
2782
  }
2462
- ) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center gap-3", children: [
2463
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "relative inline-flex items-center cursor-pointer select-none", children: [
2783
+ }
2784
+ return true;
2785
+ }).map((f) => {
2786
+ const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.type === "signature" || f.type === "date" || f.type === "datetime" || f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "branch-settings" || f.type === "time-range";
2787
+ const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
2788
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
2789
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
2790
+ f.label,
2791
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
2792
+ ] }),
2793
+ f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2794
+ BranchSettingsEditor,
2795
+ {
2796
+ collectionId: f.collection || "",
2797
+ value: editing[f.id],
2798
+ globalPrice: Number(editing.price) || 0,
2799
+ globalDiscount: Number(editing.discountPercent) || 0,
2800
+ onChange: (val) => setEditing({ ...editing, [f.id]: val })
2801
+ }
2802
+ ) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center gap-3", children: [
2464
2803
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2465
- "input",
2804
+ import_antd.Switch,
2466
2805
  {
2467
- type: "checkbox",
2468
2806
  checked: !!editing[f.id],
2469
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.checked }),
2470
- className: "sr-only peer"
2807
+ onChange: (checked) => setEditing({ ...editing, [f.id]: checked })
2471
2808
  }
2472
2809
  ),
2473
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-11 h-6 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-slate-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600" })
2474
- ] }),
2475
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-sm font-medium text-slate-700", children: editing[f.id] ? "Activado / S\xED" : "Desactivado / No" })
2476
- ] }) : f.type === "number" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2477
- FormattedNumberInput,
2478
- {
2479
- value: editing[f.id],
2480
- onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2481
- isPrice: f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.toLowerCase().includes("valor") || f.label.includes("$"),
2482
- isPercent: f.id.toLowerCase().includes("discount") || f.id.toLowerCase().includes("descuento") || f.label.toLowerCase().includes("descuento")
2483
- }
2484
- ) : f.type === "time-range" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1.5", children: [
2485
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2486
- AdminTimeRangePicker,
2810
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-sm font-medium text-slate-700", children: editing[f.id] ? "Activado / S\xED" : "Desactivado / No" })
2811
+ ] }) : f.type === "number" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2812
+ import_antd.InputNumber,
2487
2813
  {
2488
- value: [
2489
- toDayjsTime(f.startField ? editing[f.startField] : ""),
2490
- toDayjsTime(f.endField ? editing[f.endField] : "")
2491
- ],
2492
- onChange: (times) => setEditing(
2493
- (current) => current ? {
2494
- ...current,
2495
- ...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
2496
- ...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
2497
- } : current
2498
- ),
2499
- allowEmpty: [true, true],
2500
- className: "w-full",
2501
- format: TIME_DISPLAY_FORMAT,
2502
- order: false,
2503
- placeholder: ["Hora de inicio", "Hora de cierre"],
2504
- use12Hours: true
2814
+ size: "large",
2815
+ value: editing[f.id] !== void 0 && editing[f.id] !== null && editing[f.id] !== "" ? Number(editing[f.id]) : void 0,
2816
+ readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
2817
+ disabled: f.readOnly,
2818
+ onChange: (val) => setEditing({ ...editing, [f.id]: val ?? 0 }),
2819
+ className: "w-full rounded-xl",
2820
+ placeholder: "0"
2505
2821
  }
2506
- ),
2507
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: "Selecciona inicio y cierre en un mismo control. Usa AM/PM; si el cierre es anterior al inicio, el horario cruza medianoche. Deja ambos vac\xEDos para mantenerlo siempre disponible." })
2508
- ] }) : f.type === "time" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2509
- AdminTimePicker,
2510
- {
2511
- value: toDayjsTime(editing[f.id]),
2512
- onChange: (time) => setEditing({ ...editing, [f.id]: toStoredTime(time) }),
2513
- className: "w-full",
2514
- format: TIME_DISPLAY_FORMAT,
2515
- use12Hours: true
2516
- }
2517
- ) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2518
- "textarea",
2519
- {
2520
- value: String(editing[f.id] ?? ""),
2521
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2522
- rows: 4,
2523
- placeholder: `Escribe ${f.label.toLowerCase()}...`,
2524
- className: "w-full rounded-xl border border-slate-200 px-4 py-3 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all font-sans text-slate-800"
2525
- }
2526
- ) : f.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2527
- SearchableSelect,
2528
- {
2529
- value: String(editing[f.id] ?? ""),
2530
- onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2531
- options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
2532
- placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
2533
- iconMap: ctx.iconMap
2534
- }
2535
- ) : f.type === "slug" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2536
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2537
- "input",
2822
+ ) : f.type === "date" || f.type === "datetime" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2823
+ import_antd.DatePicker,
2538
2824
  {
2539
- type: "text",
2540
- value: String(editing[f.id] ?? ""),
2541
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2542
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all"
2825
+ size: "large",
2826
+ value: editing[f.id] ? (0, import_dayjs.default)(String(editing[f.id])).isValid() ? (0, import_dayjs.default)(String(editing[f.id])) : null : null,
2827
+ onChange: (date, dateString) => setEditing({ ...editing, [f.id]: (Array.isArray(dateString) ? dateString[0] : dateString) || (date ? date.format("YYYY/MM/DD") : "") }),
2828
+ format: "YYYY/MM/DD",
2829
+ placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
2830
+ className: "w-full rounded-xl"
2543
2831
  }
2544
- ),
2545
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2546
- "button",
2832
+ ) : f.type === "time-range" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1.5", children: [
2833
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2834
+ AdminTimeRangePicker,
2835
+ {
2836
+ value: [
2837
+ toDayjsTime(f.startField ? editing[f.startField] : ""),
2838
+ toDayjsTime(f.endField ? editing[f.endField] : "")
2839
+ ],
2840
+ onChange: (times) => setEditing(
2841
+ (current) => current ? {
2842
+ ...current,
2843
+ ...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
2844
+ ...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
2845
+ } : current
2846
+ ),
2847
+ allowEmpty: [true, true],
2848
+ className: "w-full",
2849
+ format: "h:mm a",
2850
+ order: false,
2851
+ placeholder: ["Hora de inicio", "Hora de cierre"],
2852
+ use12Hours: true
2853
+ }
2854
+ ),
2855
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: "Selecciona inicio y cierre en un mismo control. Usa AM/PM. Deja ambos vac\xEDos para mantenerlo siempre disponible." })
2856
+ ] }) : f.type === "time" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2857
+ import_antd.TimePicker,
2547
2858
  {
2548
- type: "button",
2549
- onClick: () => {
2550
- const sourceField = f.source || "title";
2551
- let val = String(editing[sourceField] || editing.id || "");
2552
- val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
2553
- setEditing({ ...editing, [f.id]: val });
2554
- },
2555
- className: "px-4 py-2.5 bg-slate-100 hover:bg-slate-200 text-slate-700 text-sm font-semibold rounded-xl border border-slate-200 transition-colors",
2556
- children: "Generate"
2859
+ size: "large",
2860
+ use12Hours: true,
2861
+ format: "h:mm a",
2862
+ value: toDayjsTime(editing[f.id]),
2863
+ onChange: (time, timeString) => setEditing({
2864
+ ...editing,
2865
+ [f.id]: (Array.isArray(timeString) ? timeString[0] : timeString) || (time ? time.format("h:mm a") : "")
2866
+ }),
2867
+ placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
2868
+ className: "w-full rounded-xl"
2557
2869
  }
2558
- )
2559
- ] }) : f.type === "reference" || f.type === "select" && f.collection ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2560
- ReferenceSelect,
2561
- {
2562
- collectionId: f.collection,
2563
- displayField: f.displayField,
2564
- valueField: f.valueField,
2565
- fallbackOptions: f.options,
2566
- multiple: f.multiple,
2567
- searchable: f.searchable,
2568
- max: f.max,
2569
- value: editing[f.id],
2570
- onChange: (val) => setEditing({ ...editing, [f.id]: val })
2571
- }
2572
- ) : f.type === "select" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
2573
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2574
- "select",
2870
+ ) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2871
+ import_antd.Input.TextArea,
2575
2872
  {
2873
+ size: "large",
2576
2874
  value: String(editing[f.id] ?? ""),
2577
2875
  onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2578
- className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white appearance-none pr-10 cursor-pointer text-slate-800",
2579
- children: [
2580
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: "-- Selecciona una opci\xF3n --" }),
2581
- f.options?.map((opt) => {
2582
- const val = typeof opt === "string" ? opt : opt.value;
2583
- const lab = typeof opt === "string" ? opt : opt.label;
2584
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: val, children: lab }, val);
2585
- })
2586
- ]
2876
+ rows: 4,
2877
+ placeholder: `Escribe ${f.label.toLowerCase()}...`,
2878
+ className: "w-full rounded-xl font-sans"
2587
2879
  }
2588
- ),
2589
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
2590
- ] }) : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2591
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => {
2592
- const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
2593
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
2594
- isVideo ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("video", { src: url, className: "w-full h-full object-cover rounded-lg", autoPlay: true, muted: true, loop: true, playsInline: true }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
2595
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2596
- "button",
2597
- {
2598
- type: "button",
2599
- onClick: () => {
2600
- const arr = [...editing[f.id] || []];
2601
- arr.splice(i, 1);
2602
- setEditing({ ...editing, [f.id]: arr });
2603
- },
2604
- 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",
2605
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "w-3 h-3" })
2606
- }
2607
- )
2608
- ] }, i);
2609
- }) }),
2610
- (!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2611
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2612
- "input",
2613
- {
2614
- type: "url",
2615
- placeholder: "Add media URL and press Enter...",
2616
- onKeyDown: (e) => {
2617
- if (e.key === "Enter" && e.currentTarget.value) {
2618
- e.preventDefault();
2619
- const arr = [...editing[f.id] || [], e.currentTarget.value];
2620
- setEditing({ ...editing, [f.id]: arr });
2621
- e.currentTarget.value = "";
2622
- }
2623
- },
2624
- 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"
2625
- }
2626
- ),
2627
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2628
- FilePickerButton,
2629
- {
2630
- accept: "image/*,video/*",
2631
- multiple: true,
2632
- className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
2633
- onFiles: (files) => {
2634
- files.forEach((file) => {
2635
- void handleImageFile(
2636
- file,
2637
- (url) => {
2638
- setEditing((prev) => {
2639
- if (!prev) return prev;
2640
- const current = prev[f.id] || [];
2641
- if (f.max && current.length >= f.max) {
2642
- return prev;
2643
- }
2644
- return { ...prev, [f.id]: [...current, url] };
2645
- });
2646
- },
2647
- ctx.uploadImage
2648
- );
2649
- });
2650
- },
2651
- children: "Upload"
2652
- }
2653
- )
2654
- ] })
2655
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2656
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2880
+ ) : f.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2881
+ SearchableSelect,
2882
+ {
2883
+ value: String(editing[f.id] ?? ""),
2884
+ onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2885
+ options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
2886
+ placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
2887
+ iconMap: ctx.iconMap
2888
+ }
2889
+ ) : f.type === "slug" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2657
2890
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2658
- "input",
2891
+ import_antd.Input,
2659
2892
  {
2660
- type: "url",
2893
+ size: "large",
2661
2894
  value: String(editing[f.id] ?? ""),
2662
2895
  onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2663
- placeholder: "https://...",
2664
- 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"
2896
+ className: "flex-1 rounded-xl"
2665
2897
  }
2666
2898
  ),
2667
2899
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2668
- FilePickerButton,
2900
+ import_antd.Button,
2669
2901
  {
2670
- accept: "image/*,video/*",
2671
- className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
2672
- onFiles: (files) => {
2673
- const file = files[0];
2674
- if (file) {
2675
- void handleImageFile(
2676
- file,
2677
- (url) => setEditing(
2678
- (current) => current ? { ...current, [f.id]: url } : current
2679
- ),
2680
- ctx.uploadImage
2681
- );
2682
- }
2902
+ size: "large",
2903
+ onClick: () => {
2904
+ const sourceField = f.source || "title";
2905
+ let val = String(editing[sourceField] || editing.id || "");
2906
+ val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
2907
+ setEditing({ ...editing, [f.id]: val });
2683
2908
  },
2684
- children: "Upload"
2909
+ className: "rounded-xl font-semibold",
2910
+ children: "Generate"
2685
2911
  }
2686
2912
  )
2687
- ] }),
2688
- editing[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.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__ */ (0, import_jsx_runtime5.jsx)(
2689
- "video",
2690
- {
2691
- src: String(editing[f.id]),
2692
- controls: true,
2693
- className: "w-full h-auto max-h-48 object-contain rounded-lg"
2694
- }
2695
- ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2696
- "img",
2697
- {
2698
- src: String(editing[f.id]),
2699
- alt: "",
2700
- className: "w-full h-auto max-h-48 object-contain rounded-lg"
2701
- }
2702
- ) }) : null
2703
- ] }) : f.type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2704
- PasswordField,
2705
- {
2706
- value: String(editing[f.id] ?? ""),
2707
- onChange: (val) => setEditing({ ...editing, [f.id]: val })
2708
- }
2709
- ) : f.type === "color" && !f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
2710
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2711
- "input",
2712
- {
2713
- type: "color",
2714
- value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
2715
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2716
- className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
2717
- }
2718
- ),
2719
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2720
- "input",
2721
- {
2722
- type: "text",
2723
- value: String(editing[f.id] ?? ""),
2724
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2725
- placeholder: "#000000",
2726
- 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"
2727
- }
2728
- ),
2729
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2730
- "div",
2913
+ ] }) : f.type === "reference" || f.type === "select" && f.collection ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2914
+ ReferenceSelect,
2731
2915
  {
2732
- className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
2733
- style: { backgroundColor: String(editing[f.id] ?? "#000000") }
2916
+ collectionId: f.collection,
2917
+ displayField: f.displayField,
2918
+ valueField: f.valueField,
2919
+ fallbackOptions: f.options,
2920
+ multiple: f.multiple,
2921
+ searchable: f.searchable,
2922
+ max: f.max,
2923
+ value: editing[f.id],
2924
+ onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2925
+ onSelectRecord: (rec) => {
2926
+ if (f.id === "clienteId" && rec) {
2927
+ setEditing((prev) => prev ? {
2928
+ ...prev,
2929
+ clienteId: rec.id || prev.clienteId,
2930
+ clienteNombre: rec.nombre || rec.name || prev.clienteNombre,
2931
+ ciudad: rec.ciudad || prev.ciudad,
2932
+ direccion: rec.direccion || prev.direccion,
2933
+ telefono: rec.telefono || prev.telefono
2934
+ } : prev);
2935
+ } else if (f.id === "empleadoId" && rec) {
2936
+ setEditing((prev) => prev ? {
2937
+ ...prev,
2938
+ empleadoId: rec.id || prev.empleadoId,
2939
+ empleadoNombre: rec.apellido ? `${rec.nombre || rec.name || ""} ${rec.apellido}`.trim() : rec.nombre || rec.name || prev.empleadoNombre
2940
+ } : prev);
2941
+ }
2942
+ }
2734
2943
  }
2735
- )
2736
- ] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2737
- (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) => {
2738
- const colorVal = String(item ?? "").trim();
2739
- const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
2740
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
2944
+ ) : f.type === "select" ? (() => {
2945
+ const dynamicOptions = f.optionsMap && f.dependsOnField ? f.optionsMap[String(editing[f.dependsOnField] || "")] || f.options || [] : f.options || [];
2946
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2947
+ import_antd.Select,
2948
+ {
2949
+ size: "large",
2950
+ value: editing[f.id] ? String(editing[f.id]) : void 0,
2951
+ placeholder: f.label,
2952
+ allowClear: true,
2953
+ onChange: (val) => {
2954
+ const next = { ...editing, [f.id]: val || "" };
2955
+ collection.fields.forEach((otherField) => {
2956
+ if (otherField.dependsOnField === f.id && otherField.optionsMap) {
2957
+ const newOpts = otherField.optionsMap[String(val || "")];
2958
+ if (newOpts && newOpts.length > 0) {
2959
+ const firstVal = typeof newOpts[0] === "string" ? newOpts[0] : newOpts[0].value;
2960
+ next[otherField.id] = firstVal;
2961
+ }
2962
+ }
2963
+ });
2964
+ setEditing(next);
2965
+ },
2966
+ options: dynamicOptions.map((opt) => ({
2967
+ label: typeof opt === "string" ? opt : opt.label,
2968
+ value: typeof opt === "string" ? opt : opt.value
2969
+ })),
2970
+ className: "w-full"
2971
+ }
2972
+ );
2973
+ })() : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2974
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => {
2975
+ const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
2976
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
2977
+ isVideo ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("video", { src: url, className: "w-full h-full object-cover rounded-lg", autoPlay: true, muted: true, loop: true, playsInline: true }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
2978
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2979
+ "button",
2980
+ {
2981
+ type: "button",
2982
+ onClick: () => {
2983
+ const arr = [...editing[f.id] || []];
2984
+ arr.splice(i, 1);
2985
+ setEditing({ ...editing, [f.id]: arr });
2986
+ },
2987
+ 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",
2988
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "w-3 h-3" })
2989
+ }
2990
+ )
2991
+ ] }, i);
2992
+ }) }),
2993
+ (!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2741
2994
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2742
2995
  "input",
2743
2996
  {
2744
- type: "color",
2745
- value: validHex.length === 7 ? validHex : "#000000",
2746
- onChange: (e) => {
2747
- 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) : [];
2748
- arr[idx] = e.target.value;
2749
- setEditing({ ...editing, [f.id]: arr });
2750
- },
2751
- className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
2752
- }
2753
- ),
2754
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2755
- "input",
2756
- {
2757
- type: "text",
2758
- value: colorVal,
2759
- onChange: (e) => {
2760
- 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) : [];
2761
- arr[idx] = e.target.value;
2762
- setEditing({ ...editing, [f.id]: arr });
2997
+ type: "url",
2998
+ placeholder: "Add media URL and press Enter...",
2999
+ onKeyDown: (e) => {
3000
+ if (e.key === "Enter" && e.currentTarget.value) {
3001
+ e.preventDefault();
3002
+ const arr = [...editing[f.id] || [], e.currentTarget.value];
3003
+ setEditing({ ...editing, [f.id]: arr });
3004
+ e.currentTarget.value = "";
3005
+ }
2763
3006
  },
2764
- placeholder: "#1c2a44",
2765
- 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"
3007
+ 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"
2766
3008
  }
2767
3009
  ),
2768
3010
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2769
- "div",
3011
+ FilePickerButton,
2770
3012
  {
2771
- className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
2772
- style: { backgroundColor: colorVal || "#000000" }
2773
- }
2774
- ),
2775
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2776
- "button",
2777
- {
2778
- type: "button",
2779
- onClick: () => {
2780
- 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) : [];
2781
- arr.splice(idx, 1);
2782
- setEditing({ ...editing, [f.id]: arr });
3013
+ accept: "image/*,video/*",
3014
+ multiple: true,
3015
+ className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
3016
+ onFiles: (files) => {
3017
+ files.forEach((file) => {
3018
+ void handleImageFile(
3019
+ file,
3020
+ (url) => {
3021
+ setEditing((prev) => {
3022
+ if (!prev) return prev;
3023
+ const current = prev[f.id] || [];
3024
+ if (f.max && current.length >= f.max) {
3025
+ return prev;
3026
+ }
3027
+ return { ...prev, [f.id]: [...current, url] };
3028
+ });
3029
+ },
3030
+ ctx.uploadImage
3031
+ );
3032
+ });
2783
3033
  },
2784
- className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
2785
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
3034
+ children: "Upload"
2786
3035
  }
2787
3036
  )
2788
- ] }, idx);
2789
- }),
2790
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2791
- "button",
2792
- {
2793
- type: "button",
2794
- onClick: () => {
2795
- 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) : [];
2796
- arr.push("#000000");
2797
- setEditing({ ...editing, [f.id]: arr });
2798
- },
2799
- className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 rounded-lg border border-indigo-100 transition-colors",
2800
- children: [
2801
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
2802
- " Add Color"
2803
- ]
2804
- }
2805
- )
2806
- ] }) : f.type === "list" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2807
- (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => {
2808
- const isFeatures = f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") || f.label.toLowerCase().includes("beneficio");
2809
- const placeholder = isFeatures ? `Caracter\xEDstica o beneficio ${idx + 1}...` : `Entregable o punto clave ${idx + 1}...`;
2810
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
2811
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-mono font-bold text-slate-400 w-6 text-right shrink-0", children: [
2812
- idx + 1,
2813
- "."
2814
- ] }),
3037
+ ] })
3038
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
3039
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2815
3040
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2816
3041
  "input",
2817
3042
  {
2818
- type: "text",
2819
- value: String(item ?? ""),
2820
- placeholder,
2821
- onChange: (e) => {
2822
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2823
- arr[idx] = e.target.value;
2824
- setEditing({ ...editing, [f.id]: arr });
2825
- },
2826
- 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"
3043
+ type: "url",
3044
+ value: String(editing[f.id] ?? ""),
3045
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3046
+ placeholder: "https://...",
3047
+ 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"
2827
3048
  }
2828
3049
  ),
2829
3050
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2830
- "button",
3051
+ FilePickerButton,
2831
3052
  {
2832
- type: "button",
2833
- onClick: () => {
2834
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2835
- arr.splice(idx, 1);
2836
- setEditing({ ...editing, [f.id]: arr });
3053
+ accept: "image/*,video/*",
3054
+ className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
3055
+ onFiles: (files) => {
3056
+ const file = files[0];
3057
+ if (file) {
3058
+ void handleImageFile(
3059
+ file,
3060
+ (url) => setEditing(
3061
+ (current) => current ? { ...current, [f.id]: url } : current
3062
+ ),
3063
+ ctx.uploadImage
3064
+ );
3065
+ }
2837
3066
  },
2838
- className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer",
2839
- title: "Eliminar elemento",
2840
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
3067
+ children: "Upload"
2841
3068
  }
2842
3069
  )
2843
- ] }, idx);
2844
- }),
2845
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2846
- "button",
3070
+ ] }),
3071
+ editing[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.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__ */ (0, import_jsx_runtime5.jsx)(
3072
+ "video",
3073
+ {
3074
+ src: String(editing[f.id]),
3075
+ controls: true,
3076
+ className: "w-full h-auto max-h-48 object-contain rounded-lg"
3077
+ }
3078
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3079
+ "img",
3080
+ {
3081
+ src: String(editing[f.id]),
3082
+ alt: "",
3083
+ className: "w-full h-auto max-h-48 object-contain rounded-lg"
3084
+ }
3085
+ ) }) : null
3086
+ ] }) : f.type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3087
+ PasswordField,
2847
3088
  {
2848
- type: "button",
2849
- onClick: () => {
2850
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2851
- arr.push("");
2852
- setEditing({ ...editing, [f.id]: arr });
2853
- },
2854
- 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",
2855
- children: [
2856
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
2857
- " ",
2858
- f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") ? "Agregar caracter\xEDstica uno a uno" : "Agregar entregable / punto uno a uno"
2859
- ]
3089
+ value: String(editing[f.id] ?? ""),
3090
+ onChange: (val) => setEditing({ ...editing, [f.id]: val })
3091
+ }
3092
+ ) : f.type === "signature" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3093
+ SignatureInput,
3094
+ {
3095
+ value: editing[f.id],
3096
+ onChange: (val) => setEditing({ ...editing, [f.id]: val }),
3097
+ label: f.label
3098
+ }
3099
+ ) : f.type === "color" && !f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
3100
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3101
+ "input",
3102
+ {
3103
+ type: "color",
3104
+ value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
3105
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3106
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
3107
+ }
3108
+ ),
3109
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3110
+ "input",
3111
+ {
3112
+ type: "text",
3113
+ value: String(editing[f.id] ?? ""),
3114
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3115
+ placeholder: "#000000",
3116
+ 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"
3117
+ }
3118
+ ),
3119
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3120
+ "div",
3121
+ {
3122
+ className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
3123
+ style: { backgroundColor: String(editing[f.id] ?? "#000000") }
3124
+ }
3125
+ )
3126
+ ] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
3127
+ (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) => {
3128
+ const colorVal = String(item ?? "").trim();
3129
+ const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
3130
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
3131
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3132
+ "input",
3133
+ {
3134
+ type: "color",
3135
+ value: validHex.length === 7 ? validHex : "#000000",
3136
+ onChange: (e) => {
3137
+ 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) : [];
3138
+ arr[idx] = e.target.value;
3139
+ setEditing({ ...editing, [f.id]: arr });
3140
+ },
3141
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
3142
+ }
3143
+ ),
3144
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3145
+ "input",
3146
+ {
3147
+ type: "text",
3148
+ value: colorVal,
3149
+ onChange: (e) => {
3150
+ 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) : [];
3151
+ arr[idx] = e.target.value;
3152
+ setEditing({ ...editing, [f.id]: arr });
3153
+ },
3154
+ placeholder: "#1c2a44",
3155
+ 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"
3156
+ }
3157
+ ),
3158
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3159
+ "div",
3160
+ {
3161
+ className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
3162
+ style: { backgroundColor: colorVal || "#000000" }
3163
+ }
3164
+ ),
3165
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3166
+ "button",
3167
+ {
3168
+ type: "button",
3169
+ onClick: () => {
3170
+ 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) : [];
3171
+ arr.splice(idx, 1);
3172
+ setEditing({ ...editing, [f.id]: arr });
3173
+ },
3174
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
3175
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
3176
+ }
3177
+ )
3178
+ ] }, idx);
3179
+ }),
3180
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3181
+ "button",
3182
+ {
3183
+ type: "button",
3184
+ onClick: () => {
3185
+ 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) : [];
3186
+ arr.push("#000000");
3187
+ setEditing({ ...editing, [f.id]: arr });
3188
+ },
3189
+ className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 rounded-lg border border-indigo-100 transition-colors",
3190
+ children: [
3191
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
3192
+ " Add Color"
3193
+ ]
3194
+ }
3195
+ )
3196
+ ] }) : f.type === "list" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
3197
+ (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => {
3198
+ const isFeatures = f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") || f.label.toLowerCase().includes("beneficio");
3199
+ const placeholder = isFeatures ? `Caracter\xEDstica o beneficio ${idx + 1}...` : `Entregable o punto clave ${idx + 1}...`;
3200
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
3201
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-mono font-bold text-slate-400 w-6 text-right shrink-0", children: [
3202
+ idx + 1,
3203
+ "."
3204
+ ] }),
3205
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3206
+ "input",
3207
+ {
3208
+ type: "text",
3209
+ value: String(item ?? ""),
3210
+ placeholder,
3211
+ onChange: (e) => {
3212
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
3213
+ arr[idx] = e.target.value;
3214
+ setEditing({ ...editing, [f.id]: arr });
3215
+ },
3216
+ 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"
3217
+ }
3218
+ ),
3219
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3220
+ "button",
3221
+ {
3222
+ type: "button",
3223
+ onClick: () => {
3224
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
3225
+ arr.splice(idx, 1);
3226
+ setEditing({ ...editing, [f.id]: arr });
3227
+ },
3228
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer",
3229
+ title: "Eliminar elemento",
3230
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
3231
+ }
3232
+ )
3233
+ ] }, idx);
3234
+ }),
3235
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3236
+ "button",
3237
+ {
3238
+ type: "button",
3239
+ onClick: () => {
3240
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
3241
+ arr.push("");
3242
+ setEditing({ ...editing, [f.id]: arr });
3243
+ },
3244
+ 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",
3245
+ children: [
3246
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
3247
+ " ",
3248
+ f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") ? "Agregar caracter\xEDstica uno a uno" : "Agregar entregable / punto uno a uno"
3249
+ ]
3250
+ }
3251
+ )
3252
+ ] }) : f.type === "link" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
3253
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3254
+ import_antd.Input,
3255
+ {
3256
+ size: "large",
3257
+ value: String(editing[f.id] ?? ""),
3258
+ readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
3259
+ disabled: f.readOnly,
3260
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3261
+ placeholder: f.label,
3262
+ className: "flex-1 rounded-xl"
3263
+ }
3264
+ ),
3265
+ Boolean(editing[f.id]) && String(editing[f.id]).startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3266
+ "a",
3267
+ {
3268
+ href: String(editing[f.id]),
3269
+ target: "_blank",
3270
+ rel: "noopener noreferrer",
3271
+ className: "inline-flex items-center gap-1.5 px-3 py-2 bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-xl text-xs font-bold border border-blue-200 transition-colors shrink-0",
3272
+ children: [
3273
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5" }),
3274
+ String(editing[f.id]).includes("maps") ? "Ver en Mapa" : "Abrir"
3275
+ ]
3276
+ }
3277
+ ) : null
3278
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3279
+ import_antd.Input,
3280
+ {
3281
+ size: "large",
3282
+ value: String(editing[f.id] ?? ""),
3283
+ readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
3284
+ disabled: f.readOnly,
3285
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3286
+ placeholder: f.label,
3287
+ className: "w-full rounded-xl"
2860
3288
  }
2861
3289
  )
2862
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2863
- "input",
2864
- {
2865
- value: String(editing[f.id] ?? ""),
2866
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2867
- className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all"
2868
- }
2869
- )
2870
- ] }, f.id)) }) }),
3290
+ ] }, f.id);
3291
+ }) }) }),
2871
3292
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex shrink-0 justify-end gap-3 border-t border-slate-200 bg-white px-6 py-4", children: [
2872
3293
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2873
- "button",
3294
+ import_antd.Button,
2874
3295
  {
2875
- onClick: () => setEditing(null),
3296
+ size: "large",
3297
+ onClick: () => {
3298
+ setEditing(null);
3299
+ setIsCreatingManual(false);
3300
+ },
2876
3301
  disabled: saving,
2877
- className: "rounded-xl px-5 py-2.5 text-sm font-semibold text-slate-600 hover:bg-slate-100 transition-colors disabled:opacity-50",
2878
- children: "Cancel"
3302
+ className: "rounded-xl font-medium",
3303
+ children: t.cancel
2879
3304
  }
2880
3305
  ),
2881
3306
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2882
- "button",
3307
+ import_antd.Button,
2883
3308
  {
3309
+ size: "large",
3310
+ type: "primary",
2884
3311
  onClick: save,
2885
- disabled: saving,
2886
- className: "inline-flex items-center gap-2 rounded-xl bg-slate-900 px-6 py-2.5 text-sm font-bold text-white shadow-sm hover:bg-slate-800 hover:shadow transition-all disabled:opacity-60",
2887
- children: saving ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2888
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "animate-spin h-4 w-4 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
2889
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
2890
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
2891
- ] }),
2892
- "Saving..."
2893
- ] }) : "Save Entry"
3312
+ loading: saving,
3313
+ className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700",
3314
+ children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
2894
3315
  }
2895
3316
  )
2896
3317
  ] })
2897
- ] })
3318
+ ] }) })
2898
3319
  }
2899
3320
  ),
2900
3321
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { className: "w-full text-sm text-left", children: [
2901
3322
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: "bg-slate-50/80 border-b border-slate-200", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { children: [
2902
3323
  visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: f.label }, f.id)),
2903
- /* @__PURE__ */ (0, import_jsx_runtime5.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: "Actions" })
3324
+ /* @__PURE__ */ (0, import_jsx_runtime5.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 })
2904
3325
  ] }) }),
2905
3326
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
2906
3327
  // Loading skeleton rows
@@ -2912,13 +3333,29 @@ function CollectionEditor({ collection }) {
2912
3333
  (() => {
2913
3334
  let res = entries;
2914
3335
  if (search && collection.searchBy?.length) {
2915
- const q = search.toLowerCase();
2916
- res = res.filter((e) => collection.searchBy.some((field) => String(e[field] || "").toLowerCase().includes(q)));
3336
+ const q = search.toLowerCase().trim();
3337
+ res = res.filter((e) => {
3338
+ return collection.searchBy.some((field) => {
3339
+ const val = String(e[field] ?? "").toLowerCase();
3340
+ if (!val) return false;
3341
+ if (val.includes(q)) return true;
3342
+ const normVal = val.replace(/-/g, "/");
3343
+ const normQ = q.replace(/-/g, "/");
3344
+ return normVal.includes(normQ);
3345
+ });
3346
+ });
2917
3347
  }
2918
3348
  if (Object.keys(filters).length > 0) {
2919
3349
  res = res.filter((e) => {
2920
3350
  for (const [k, v] of Object.entries(filters)) {
2921
- if (v && String(e[k] || "") !== v) return false;
3351
+ if (!v) continue;
3352
+ const entryVal = String(e[k] ?? "").trim();
3353
+ const filterVal = String(v).trim();
3354
+ const normEntry = entryVal.replace(/-/g, "/");
3355
+ const normFilter = filterVal.replace(/-/g, "/");
3356
+ if (normEntry !== normFilter && !normEntry.includes(normFilter)) {
3357
+ return false;
3358
+ }
2922
3359
  }
2923
3360
  return true;
2924
3361
  });
@@ -2934,18 +3371,33 @@ function CollectionEditor({ collection }) {
2934
3371
  onDragEnd,
2935
3372
  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" : ""}`,
2936
3373
  children: [
2937
- visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : f.id === "status" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold ${String(e[f.id]).includes("Entregado") ? "bg-emerald-100 text-emerald-800 border border-emerald-300" : String(e[f.id]).includes("Preparaci\xF3n") ? "bg-amber-100 text-amber-800 border border-amber-300" : String(e[f.id]).includes("Camino") ? "bg-blue-100 text-blue-800 border border-blue-300" : String(e[f.id]).includes("Confirmado") ? "bg-indigo-100 text-indigo-800 border border-indigo-300" : String(e[f.id]).includes("Cancelado") ? "bg-rose-100 text-rose-800 border border-rose-300" : "bg-amber-50 text-amber-800 border border-amber-200"}`, children: String(e[f.id]) }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
3374
+ visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold ${String(e[f.id]) === "Terminado" || String(e[f.id]) === "Terminada" || String(e[f.id]).includes("Entregado") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(e[f.id]) === "Proceso" || String(e[f.id]).includes("Preparaci\xF3n") ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes("Cancelado") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-blue-50 text-blue-700 border border-blue-200"}`, children: String(e[f.id]) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? e.clienteNombre && f.id === "clienteId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.clienteNombre) }) : e.empleadoNombre && f.id === "empleadoId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.empleadoNombre) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Image, { src: String(e[f.id]), alt: "Firma", className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer", preview: { mask: "Ver" } }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
2938
3375
  "$ ",
2939
3376
  Number(e[f.id]).toLocaleString("es-CO")
2940
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) : String(e[f.id] ?? "") }, f.id)),
3377
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) : f.type === "link" || typeof e[f.id] === "string" && String(e[f.id]).startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3378
+ "a",
3379
+ {
3380
+ href: String(e[f.id]),
3381
+ target: "_blank",
3382
+ rel: "noopener noreferrer",
3383
+ className: "inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 underline font-medium",
3384
+ children: [
3385
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3 h-3" }),
3386
+ String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
3387
+ ]
3388
+ }
3389
+ ) : String(e[f.id] ?? "") }, f.id)),
2941
3390
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-end gap-2", children: [
2942
3391
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "p-2 text-slate-300 cursor-grab active:cursor-grabbing", title: "Drag to reorder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "w-4 h-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M5.5 3C6.32843 3 7 3.67157 7 4.5C7 5.32843 6.32843 6 5.5 6C4.67157 6 4 5.32843 4 4.5C4 3.67157 4.67157 3 5.5 3ZM9.5 3C10.3284 3 11 3.67157 11 4.5C11 5.32843 10.3284 6 9.5 6C8.67157 6 8 5.32843 8 4.5C8 3.67157 8.67157 3 9.5 3ZM5.5 7.5C6.32843 7.5 7 8.17157 7 9C7 9.82843 6.32843 10.5 5.5 10.5C4.67157 10.5 4 9.82843 4 9C4 8.17157 4.67157 7.5 5.5 7.5ZM9.5 7.5C10.3284 7.5 11 8.17157 11 9C11 9.82843 10.3284 10.5 9.5 10.5C8.67157 10.5 8 9.82843 8 9C8 8.17157 8.67157 7.5 9.5 7.5ZM5.5 12C6.32843 12 7 12.6716 7 13.5C7 14.3284 6.32843 15 5.5 15C4.67157 15 4 14.3284 4 13.5C4 12.6716 4.67157 12 5.5 12ZM9.5 12C10.3284 12 11 12.6716 11 13.5C11 14.3284 10.3284 15 9.5 15C8.67157 15 8 14.3284 8 13.5C8 12.6716 8.67157 12 9.5 12Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) }),
2943
3392
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2944
3393
  "button",
2945
3394
  {
2946
- onClick: () => setEditing(e),
3395
+ onClick: () => {
3396
+ setIsCreatingManual(false);
3397
+ setEditing(e);
3398
+ },
2947
3399
  className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
2948
- title: "Edit",
3400
+ title: t.edit,
2949
3401
  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4" })
2950
3402
  }
2951
3403
  ),
@@ -2955,7 +3407,7 @@ function CollectionEditor({ collection }) {
2955
3407
  onClick: () => remove(e.id),
2956
3408
  disabled: deletingId === e.id,
2957
3409
  className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
2958
- title: "Delete",
3410
+ title: t.delete,
2959
3411
  children: deletingId === e.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
2960
3412
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
2961
3413
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
@@ -2975,7 +3427,7 @@ function CollectionEditor({ collection }) {
2975
3427
  className: "px-6 py-12 text-center text-slate-500",
2976
3428
  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col items-center justify-center", children: [
2977
3429
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-10 w-10 text-slate-300 mb-3" }),
2978
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: 'No entries yet. Click "New Entry" to create one.' })
3430
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: t.noRecords })
2979
3431
  ] })
2980
3432
  }
2981
3433
  ) })
@@ -2996,7 +3448,7 @@ function CollectionEditor({ collection }) {
2996
3448
  return true;
2997
3449
  });
2998
3450
  }
2999
- return `${res.length} item${res.length !== 1 ? "s" : ""}`;
3451
+ return `${res.length} ${t.entries}`;
3000
3452
  })() }),
3001
3453
  (() => {
3002
3454
  let res = entries;
@@ -3646,6 +4098,197 @@ function PasswordField({ value, onChange }) {
3646
4098
  )
3647
4099
  ] });
3648
4100
  }
4101
+ function SignatureInput({
4102
+ value,
4103
+ onChange,
4104
+ label
4105
+ }) {
4106
+ const t = useAdminI18n();
4107
+ const [modalOpen, setModalOpen] = (0, import_react5.useState)(false);
4108
+ const canvasRef = (0, import_react5.useRef)(null);
4109
+ const isDrawingRef = (0, import_react5.useRef)(false);
4110
+ const fileInputRef = (0, import_react5.useRef)(null);
4111
+ const sigVal = typeof value === "string" ? value : "";
4112
+ const displayLabel = label || t.signatureRegistered;
4113
+ const startDrawing = (e) => {
4114
+ const canvas = canvasRef.current;
4115
+ if (!canvas) return;
4116
+ const ctx = canvas.getContext("2d");
4117
+ if (!ctx) return;
4118
+ isDrawingRef.current = true;
4119
+ const rect = canvas.getBoundingClientRect();
4120
+ const x = "touches" in e ? e.touches[0].clientX - rect.left : e.clientX - rect.left;
4121
+ const y = "touches" in e ? e.touches[0].clientY - rect.top : e.clientY - rect.top;
4122
+ ctx.beginPath();
4123
+ ctx.moveTo(x, y);
4124
+ };
4125
+ const draw = (e) => {
4126
+ if (!isDrawingRef.current) return;
4127
+ const canvas = canvasRef.current;
4128
+ if (!canvas) return;
4129
+ const ctx = canvas.getContext("2d");
4130
+ if (!ctx) return;
4131
+ const rect = canvas.getBoundingClientRect();
4132
+ const x = "touches" in e ? e.touches[0].clientX - rect.left : e.clientX - rect.left;
4133
+ const y = "touches" in e ? e.touches[0].clientY - rect.top : e.clientY - rect.top;
4134
+ ctx.lineTo(x, y);
4135
+ ctx.stroke();
4136
+ };
4137
+ const stopDrawing = () => {
4138
+ isDrawingRef.current = false;
4139
+ };
4140
+ const clearCanvas = () => {
4141
+ const canvas = canvasRef.current;
4142
+ if (!canvas) return;
4143
+ const ctx = canvas.getContext("2d");
4144
+ if (!ctx) return;
4145
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
4146
+ };
4147
+ const saveDrawnSignature = () => {
4148
+ const canvas = canvasRef.current;
4149
+ if (!canvas) return;
4150
+ const dataUrl = canvas.toDataURL("image/png");
4151
+ onChange(dataUrl);
4152
+ setModalOpen(false);
4153
+ };
4154
+ const handleFileUpload = (e) => {
4155
+ const file = e.target.files?.[0];
4156
+ if (!file) return;
4157
+ const reader = new FileReader();
4158
+ reader.onload = (evt) => {
4159
+ if (typeof evt.target?.result === "string") {
4160
+ onChange(evt.target.result);
4161
+ }
4162
+ };
4163
+ reader.readAsDataURL(file);
4164
+ e.target.value = "";
4165
+ };
4166
+ (0, import_react5.useEffect)(() => {
4167
+ if (modalOpen) {
4168
+ setTimeout(() => {
4169
+ const canvas = canvasRef.current;
4170
+ if (!canvas) return;
4171
+ const ctx = canvas.getContext("2d");
4172
+ if (ctx) {
4173
+ ctx.strokeStyle = "#0f172a";
4174
+ ctx.lineWidth = 2.5;
4175
+ ctx.lineCap = "round";
4176
+ ctx.lineJoin = "round";
4177
+ }
4178
+ }, 50);
4179
+ }
4180
+ }, [modalOpen]);
4181
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
4182
+ sigVal ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between p-3 rounded-xl border border-slate-200 bg-slate-50/70", children: [
4183
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
4184
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4185
+ import_antd.Image,
4186
+ {
4187
+ src: sigVal,
4188
+ alt: displayLabel,
4189
+ className: "h-16 max-w-[220px] object-contain rounded bg-white p-1 border border-slate-200 shadow-sm cursor-pointer hover:border-blue-500",
4190
+ preview: {
4191
+ mask: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold", children: t.previewMask })
4192
+ }
4193
+ }
4194
+ ),
4195
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col gap-0.5", children: [
4196
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold text-emerald-700 bg-emerald-50 border border-emerald-200 px-2.5 py-0.5 rounded-full w-fit", children: t.signatureRegistered }),
4197
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[11px] text-slate-500", children: t.viewLarger })
4198
+ ] })
4199
+ ] }),
4200
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4201
+ import_antd.Button,
4202
+ {
4203
+ danger: true,
4204
+ type: "text",
4205
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" }),
4206
+ onClick: () => onChange(""),
4207
+ className: "hover:bg-red-50 text-red-600 font-medium",
4208
+ children: t.delete
4209
+ }
4210
+ )
4211
+ ] }) : null,
4212
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
4213
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4214
+ import_antd.Button,
4215
+ {
4216
+ type: "primary",
4217
+ size: "large",
4218
+ onClick: () => {
4219
+ clearCanvas();
4220
+ setModalOpen(true);
4221
+ },
4222
+ className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm",
4223
+ children: sigVal ? t.replaceSignature : t.addSignature
4224
+ }
4225
+ ),
4226
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4227
+ import_antd.Button,
4228
+ {
4229
+ type: "primary",
4230
+ size: "large",
4231
+ onClick: () => fileInputRef.current?.click(),
4232
+ className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm",
4233
+ children: sigVal ? t.uploadNewImage : t.uploadImage
4234
+ }
4235
+ ),
4236
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4237
+ "input",
4238
+ {
4239
+ type: "file",
4240
+ ref: fileInputRef,
4241
+ accept: "image/*",
4242
+ onChange: handleFileUpload,
4243
+ className: "hidden"
4244
+ }
4245
+ )
4246
+ ] }),
4247
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4248
+ import_antd.Modal,
4249
+ {
4250
+ open: modalOpen,
4251
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-bold text-slate-800", children: t.signOnScreen }),
4252
+ onCancel: () => setModalOpen(false),
4253
+ centered: true,
4254
+ width: 560,
4255
+ footer: [
4256
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Button, { onClick: clearCanvas, className: "rounded-xl font-medium", children: t.clear }, "clear"),
4257
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Button, { onClick: () => setModalOpen(false), className: "rounded-xl font-medium", children: t.cancel }, "cancel"),
4258
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4259
+ import_antd.Button,
4260
+ {
4261
+ type: "primary",
4262
+ onClick: saveDrawnSignature,
4263
+ className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl",
4264
+ children: t.saveSignature
4265
+ },
4266
+ "save"
4267
+ )
4268
+ ],
4269
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "py-2 space-y-2", children: [
4270
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: t.signInstructions }),
4271
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "border-2 border-dashed border-slate-300 rounded-2xl bg-white overflow-hidden touch-none", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4272
+ "canvas",
4273
+ {
4274
+ ref: canvasRef,
4275
+ width: 500,
4276
+ height: 220,
4277
+ onMouseDown: startDrawing,
4278
+ onMouseMove: draw,
4279
+ onMouseUp: stopDrawing,
4280
+ onMouseLeave: stopDrawing,
4281
+ onTouchStart: startDrawing,
4282
+ onTouchMove: draw,
4283
+ onTouchEnd: stopDrawing,
4284
+ className: "w-full h-[220px] cursor-crosshair block"
4285
+ }
4286
+ ) })
4287
+ ] })
4288
+ }
4289
+ )
4290
+ ] });
4291
+ }
3649
4292
  function FormattedNumberInput({
3650
4293
  value,
3651
4294
  onChange,
@@ -4328,11 +4971,80 @@ function ReferenceSelect({
4328
4971
  searchable = false,
4329
4972
  max,
4330
4973
  value,
4331
- onChange
4974
+ onChange,
4975
+ onSelectRecord
4332
4976
  }) {
4333
4977
  const ctx = useCmsContext();
4978
+ const t = useAdminI18n();
4334
4979
  const [options, setOptions] = (0, import_react5.useState)([]);
4335
4980
  const [loading, setLoading] = (0, import_react5.useState)(true);
4981
+ const [clientModalOpen, setClientModalOpen] = (0, import_react5.useState)(false);
4982
+ const [creatingClient, setCreatingClient] = (0, import_react5.useState)(false);
4983
+ const [clientError, setClientError] = (0, import_react5.useState)("");
4984
+ const [newClient, setNewClient] = (0, import_react5.useState)({
4985
+ tipo: "Persona",
4986
+ tipoDocumento: "C\xE9dula de ciudadan\xEDa",
4987
+ id: "",
4988
+ sucursal: "",
4989
+ nombre: "",
4990
+ email: "",
4991
+ telefono: "",
4992
+ ciudad: "",
4993
+ direccion: ""
4994
+ });
4995
+ const handleSaveClient = async () => {
4996
+ setClientError("");
4997
+ if (!newClient.id.trim()) {
4998
+ setClientError(t.idRequired);
4999
+ return;
5000
+ }
5001
+ if (!newClient.nombre.trim()) {
5002
+ setClientError(t.nameRequired);
5003
+ return;
5004
+ }
5005
+ setCreatingClient(true);
5006
+ try {
5007
+ const entry = {
5008
+ ...newClient,
5009
+ id: newClient.id.trim(),
5010
+ nombre: newClient.nombre.trim()
5011
+ };
5012
+ await ctx.adapter.putEntry("clients", entry);
5013
+ const res = await ctx.adapter.listEntries("clients");
5014
+ const fromCollection = (res || []).map((r) => {
5015
+ const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
5016
+ const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
5017
+ const lab = fullName || String(r[displayField] || r.name || r.id);
5018
+ return {
5019
+ value: val,
5020
+ label: val && val !== lab ? `${lab} (${val})` : lab,
5021
+ raw: r
5022
+ };
5023
+ });
5024
+ setOptions(fromCollection);
5025
+ onChange(entry.id);
5026
+ if (onSelectRecord) {
5027
+ onSelectRecord(entry);
5028
+ }
5029
+ setClientModalOpen(false);
5030
+ setNewClient({
5031
+ tipo: "Persona",
5032
+ tipoDocumento: "C\xE9dula de ciudadan\xEDa",
5033
+ id: "",
5034
+ sucursal: "",
5035
+ nombre: "",
5036
+ email: "",
5037
+ telefono: "",
5038
+ ciudad: "",
5039
+ direccion: ""
5040
+ });
5041
+ import_antd.message.success(t.clientCreatedSuccess);
5042
+ } catch (err) {
5043
+ setClientError(err?.message || "Error al crear cliente.");
5044
+ } finally {
5045
+ setCreatingClient(false);
5046
+ }
5047
+ };
4336
5048
  (0, import_react5.useEffect)(() => {
4337
5049
  if (!collectionId) {
4338
5050
  if (fallbackOptions && fallbackOptions.length > 0) {
@@ -4343,65 +5055,279 @@ function ReferenceSelect({
4343
5055
  }
4344
5056
  setLoading(true);
4345
5057
  ctx.adapter.listEntries(collectionId).then((res) => {
4346
- const fromCollection = res.map((r) => {
5058
+ const fromCollection = (res || []).map((r) => {
4347
5059
  const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
4348
- const lab = String(r[displayField] || r.name || r.id);
4349
- return { value: val, label: lab };
5060
+ const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
5061
+ const lab = fullName || String(r[displayField] || r.name || r.id);
5062
+ return {
5063
+ value: val,
5064
+ label: val && val !== lab ? `${lab} (${val})` : lab,
5065
+ raw: r
5066
+ };
4350
5067
  });
4351
- const fallbackList = (fallbackOptions || []).map(
4352
- (opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
4353
- );
4354
- const combined = [...fromCollection];
4355
- for (const fb of fallbackList) {
4356
- if (!combined.some((c) => c.value === fb.value || c.label === fb.label)) {
4357
- combined.push(fb);
4358
- }
4359
- }
4360
- setOptions(combined);
5068
+ setOptions(fromCollection);
4361
5069
  setLoading(false);
4362
5070
  }).catch(() => {
4363
- if (fallbackOptions && fallbackOptions.length > 0) {
4364
- setOptions(fallbackOptions.map((opt) => typeof opt === "string" ? { value: opt, label: opt } : opt));
4365
- }
5071
+ setOptions([]);
4366
5072
  setLoading(false);
4367
5073
  });
4368
- }, [collectionId, displayField, valueField, fallbackOptions, ctx.adapter]);
5074
+ }, [collectionId, displayField, valueField, fallbackOptions, ctx.adapter, ctx.collectionChangedAt]);
4369
5075
  if (multiple) {
4370
5076
  const selectedList = Array.isArray(value) ? value.map(String) : typeof value === "string" && value.trim() ? value.split(",").map((s) => s.trim()).filter(Boolean) : [];
4371
5077
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4372
- SearchableMultiSelect,
5078
+ import_antd.Select,
4373
5079
  {
4374
- options,
4375
- value: selectedList,
4376
- onChange,
5080
+ size: "large",
5081
+ mode: "multiple",
4377
5082
  loading,
4378
- searchable,
5083
+ showSearch: searchable,
4379
5084
  placeholder: "Seleccionar opciones...",
4380
- searchPlaceholder: `Buscar ${collectionId === "sauces" ? "salsa" : collectionId === "extras" ? "adicional" : "opci\xF3n"}...`,
4381
- emptyMessage: "No hay opciones registradas todav\xEDa.",
4382
- max
5085
+ filterOption: (input, option) => {
5086
+ if (!input) return true;
5087
+ const q = input.toLowerCase();
5088
+ const label = String(option?.label ?? "").toLowerCase();
5089
+ const val = String(option?.value ?? "").toLowerCase();
5090
+ return label.includes(q) || val.includes(q);
5091
+ },
5092
+ maxCount: max,
5093
+ value: selectedList,
5094
+ onChange,
5095
+ options,
5096
+ className: "w-full"
4383
5097
  }
4384
5098
  );
4385
5099
  }
4386
- const singleVal = String(value ?? "");
5100
+ const singleVal = value !== void 0 && value !== null && value !== "" ? String(value) : void 0;
4387
5101
  const displayOptions = [...options];
4388
5102
  if (singleVal && !displayOptions.some((o) => o.value === singleVal)) {
4389
5103
  displayOptions.unshift({ value: singleVal, label: singleVal });
4390
5104
  }
4391
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
4392
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4393
- "select",
5105
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
5106
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
5107
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5108
+ import_antd.Select,
5109
+ {
5110
+ size: "large",
5111
+ loading,
5112
+ showSearch: searchable,
5113
+ placeholder: loading ? t.loadingOptions : t.selectOption,
5114
+ allowClear: true,
5115
+ filterOption: (input, option) => {
5116
+ if (!input) return true;
5117
+ const q = input.toLowerCase();
5118
+ const label = String(option?.label ?? "").toLowerCase();
5119
+ const val = String(option?.value ?? "").toLowerCase();
5120
+ return label.includes(q) || val.includes(q);
5121
+ },
5122
+ value: singleVal,
5123
+ onChange: (v) => {
5124
+ onChange(v || "");
5125
+ if (onSelectRecord) {
5126
+ const found = options.find((o) => o.value === v);
5127
+ if (found?.raw) onSelectRecord(found.raw);
5128
+ }
5129
+ },
5130
+ options: displayOptions,
5131
+ dropdownRender: (menu) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5132
+ menu,
5133
+ collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-2 border-t border-slate-100 flex items-center justify-between bg-slate-50", children: [
5134
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-500 font-medium", children: t.cantFindClient }),
5135
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5136
+ import_antd.Button,
5137
+ {
5138
+ type: "primary",
5139
+ size: "small",
5140
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
5141
+ onClick: () => {
5142
+ setClientError("");
5143
+ setClientModalOpen(true);
5144
+ },
5145
+ className: "bg-blue-600 hover:bg-blue-700 text-xs font-semibold rounded-lg shadow-sm",
5146
+ children: t.createClient
5147
+ }
5148
+ )
5149
+ ] })
5150
+ ] }),
5151
+ className: "w-full"
5152
+ }
5153
+ ) }),
5154
+ collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5155
+ import_antd.Button,
5156
+ {
5157
+ type: "primary",
5158
+ size: "large",
5159
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-4 h-4" }),
5160
+ onClick: () => {
5161
+ setClientError("");
5162
+ setClientModalOpen(true);
5163
+ },
5164
+ className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl shrink-0 h-10 px-4 text-xs uppercase tracking-wider",
5165
+ children: t.newBtn
5166
+ }
5167
+ )
5168
+ ] }),
5169
+ collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5170
+ import_antd.Modal,
4394
5171
  {
4395
- value: singleVal,
4396
- onChange: (e) => onChange(e.target.value),
4397
- className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white appearance-none pr-10",
4398
- children: [
4399
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: loading ? "Cargando opciones..." : "-- Selecciona una opci\xF3n --" }),
4400
- displayOptions.map((o, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: o.value, children: o.label }, `${o.value}-${idx}`))
4401
- ]
5172
+ open: clientModalOpen,
5173
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xl font-bold text-slate-900 font-display", children: t.basicDetails }),
5174
+ onCancel: () => setClientModalOpen(false),
5175
+ centered: true,
5176
+ width: 650,
5177
+ footer: null,
5178
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pt-2 space-y-4", children: [
5179
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
5180
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5181
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientType }),
5182
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5183
+ import_antd.Select,
5184
+ {
5185
+ size: "large",
5186
+ value: newClient.tipo,
5187
+ onChange: (val) => {
5188
+ setNewClient((prev) => ({
5189
+ ...prev,
5190
+ tipo: val,
5191
+ tipoDocumento: val === "Empresa" ? "Nit" : "C\xE9dula de ciudadan\xEDa"
5192
+ }));
5193
+ },
5194
+ options: [
5195
+ { label: "Persona", value: "Persona" },
5196
+ { label: "Empresa", value: "Empresa" }
5197
+ ],
5198
+ className: "w-full"
5199
+ }
5200
+ )
5201
+ ] }),
5202
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5203
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientDocType }),
5204
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5205
+ import_antd.Select,
5206
+ {
5207
+ size: "large",
5208
+ value: newClient.tipoDocumento,
5209
+ onChange: (val) => setNewClient((prev) => ({ ...prev, tipoDocumento: val })),
5210
+ options: newClient.tipo === "Persona" ? [
5211
+ { label: "C\xE9dula de ciudadan\xEDa", value: "C\xE9dula de ciudadan\xEDa" },
5212
+ { label: "C\xE9dula de extranjer\xEDa", value: "C\xE9dula de extranjer\xEDa" },
5213
+ { label: "Pasaporte", value: "Pasaporte" }
5214
+ ] : [{ label: "Nit", value: "Nit" }],
5215
+ className: "w-full"
5216
+ }
5217
+ )
5218
+ ] })
5219
+ ] }),
5220
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
5221
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5222
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: [
5223
+ t.clientIdentification,
5224
+ " *"
5225
+ ] }),
5226
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5227
+ import_antd.Input,
5228
+ {
5229
+ size: "large",
5230
+ placeholder: t.clientIdentification,
5231
+ value: newClient.id,
5232
+ onChange: (e) => setNewClient((prev) => ({ ...prev, id: e.target.value }))
5233
+ }
5234
+ )
5235
+ ] }),
5236
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5237
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientBranch }),
5238
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5239
+ import_antd.Input,
5240
+ {
5241
+ size: "large",
5242
+ placeholder: t.clientBranch,
5243
+ value: newClient.sucursal,
5244
+ onChange: (e) => setNewClient((prev) => ({ ...prev, sucursal: e.target.value }))
5245
+ }
5246
+ )
5247
+ ] })
5248
+ ] }),
5249
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
5250
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5251
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: [
5252
+ t.clientName,
5253
+ " *"
5254
+ ] }),
5255
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5256
+ import_antd.Input,
5257
+ {
5258
+ size: "large",
5259
+ placeholder: t.clientName,
5260
+ value: newClient.nombre,
5261
+ onChange: (e) => setNewClient((prev) => ({ ...prev, nombre: e.target.value }))
5262
+ }
5263
+ )
5264
+ ] }),
5265
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5266
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientEmail }),
5267
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5268
+ import_antd.Input,
5269
+ {
5270
+ size: "large",
5271
+ placeholder: t.clientEmail,
5272
+ value: newClient.email,
5273
+ onChange: (e) => setNewClient((prev) => ({ ...prev, email: e.target.value }))
5274
+ }
5275
+ )
5276
+ ] })
5277
+ ] }),
5278
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
5279
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5280
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientPhone }),
5281
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5282
+ import_antd.Input,
5283
+ {
5284
+ size: "large",
5285
+ placeholder: t.clientPhone,
5286
+ value: newClient.telefono,
5287
+ onChange: (e) => setNewClient((prev) => ({ ...prev, telefono: e.target.value }))
5288
+ }
5289
+ )
5290
+ ] }),
5291
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5292
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientCity }),
5293
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5294
+ import_antd.Input,
5295
+ {
5296
+ size: "large",
5297
+ placeholder: t.clientCity,
5298
+ value: newClient.ciudad,
5299
+ onChange: (e) => setNewClient((prev) => ({ ...prev, ciudad: e.target.value }))
5300
+ }
5301
+ )
5302
+ ] })
5303
+ ] }),
5304
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5305
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientAddress }),
5306
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5307
+ import_antd.Input,
5308
+ {
5309
+ size: "large",
5310
+ placeholder: t.clientAddress,
5311
+ value: newClient.direccion,
5312
+ onChange: (e) => setNewClient((prev) => ({ ...prev, direccion: e.target.value }))
5313
+ }
5314
+ )
5315
+ ] }),
5316
+ clientError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs font-semibold text-red-600 bg-red-50 p-2.5 rounded-lg border border-red-200", children: clientError }),
5317
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5318
+ import_antd.Button,
5319
+ {
5320
+ type: "primary",
5321
+ size: "large",
5322
+ loading: creatingClient,
5323
+ onClick: handleSaveClient,
5324
+ className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm mt-2",
5325
+ children: t.create.toUpperCase()
5326
+ }
5327
+ )
5328
+ ] })
4402
5329
  }
4403
- ),
4404
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
5330
+ )
4405
5331
  ] });
4406
5332
  }
4407
5333
  function ReferenceTableCell({