admin-lib-cms 1.2.9 → 1.2.10

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.d.mts CHANGED
@@ -5,11 +5,18 @@ import { MenuLabels } from './types.mjs';
5
5
  export { CmsConfig, CollectionDef, CollectionEntry, CollectionField, EditableMeta, FieldType, GlobalGroup, OverridesMap, PageDef, StorageAdapter, Submission } from './types.mjs';
6
6
  export { generateDefaultTemplate, sendEmailNotification } from './emails/index.mjs';
7
7
 
8
+ interface CustomAdminSection {
9
+ id: string;
10
+ label: string;
11
+ icon?: React__default.ReactNode;
12
+ component: React__default.ReactNode | React__default.ComponentType;
13
+ }
8
14
  interface AdminAppProps {
9
15
  apiUrl?: string;
10
16
  projectId?: string;
11
17
  email?: string;
12
18
  dashboard?: React__default.ReactNode | React__default.ComponentType;
19
+ customSections?: CustomAdminSection[];
13
20
  hideSettings?: boolean;
14
21
  hideData?: boolean;
15
22
  hideGlobals?: boolean;
package/dist/index.d.ts CHANGED
@@ -5,11 +5,18 @@ import { MenuLabels } from './types.js';
5
5
  export { CmsConfig, CollectionDef, CollectionEntry, CollectionField, EditableMeta, FieldType, GlobalGroup, OverridesMap, PageDef, StorageAdapter, Submission } from './types.js';
6
6
  export { generateDefaultTemplate, sendEmailNotification } from './emails/index.js';
7
7
 
8
+ interface CustomAdminSection {
9
+ id: string;
10
+ label: string;
11
+ icon?: React__default.ReactNode;
12
+ component: React__default.ReactNode | React__default.ComponentType;
13
+ }
8
14
  interface AdminAppProps {
9
15
  apiUrl?: string;
10
16
  projectId?: string;
11
17
  email?: string;
12
18
  dashboard?: React__default.ReactNode | React__default.ComponentType;
19
+ customSections?: CustomAdminSection[];
13
20
  hideSettings?: boolean;
14
21
  hideData?: boolean;
15
22
  hideGlobals?: boolean;
package/dist/index.js CHANGED
@@ -827,6 +827,7 @@ function EditableReference({
827
827
 
828
828
  // src/admin/AdminApp.tsx
829
829
  var import_react5 = require("react");
830
+ var import_react_dom = require("react-dom");
830
831
  var import_antd = require("antd");
831
832
  var import_dayjs = __toESM(require("dayjs"));
832
833
  var import_lucide_react2 = require("lucide-react");
@@ -1026,6 +1027,16 @@ function AdminAppContent(props) {
1026
1027
  children: menuLabels.dashboard
1027
1028
  }
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
+ )),
1029
1040
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1030
1041
  SideItem,
1031
1042
  {
@@ -1103,7 +1114,10 @@ function AdminAppContent(props) {
1103
1114
  !hideData && section === "submissions" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubmissionsSection, {}),
1104
1115
  !hideConfig && !hideGlobals && section === "config" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ConfigSection, {}),
1105
1116
  !hideSettings && section === "settings" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SettingsSection, {}),
1106
- section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {})
1117
+ section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {}),
1118
+ props.customSections?.map(
1119
+ (cs) => section === cs.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1 overflow-y-auto", children: typeof cs.component === "function" ? (0, import_react5.createElement)(cs.component) : cs.component }, cs.id) : null
1120
+ )
1107
1121
  ] })
1108
1122
  ] })
1109
1123
  ] });
@@ -2328,6 +2342,7 @@ function CollectionEditor({ collection }) {
2328
2342
  newEntries[i].order = i;
2329
2343
  await ctx.adapter.putEntry(collection.id, newEntries[i]);
2330
2344
  }
2345
+ ctx.notifyCollectionChanged();
2331
2346
  };
2332
2347
  const onDragEnd = (e) => {
2333
2348
  const target = e.target;
@@ -2430,7 +2445,7 @@ function CollectionEditor({ collection }) {
2430
2445
  }
2431
2446
  },
2432
2447
  children: editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
2433
- /* @__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 === "branch-settings" || f.type === "time-range" ? "lg:col-span-2" : ""}`, 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: [
2434
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: [
2435
2450
  f.label,
2436
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 })
@@ -2444,15 +2459,21 @@ function CollectionEditor({ collection }) {
2444
2459
  globalDiscount: Number(editing.discountPercent) || 0,
2445
2460
  onChange: (val) => setEditing({ ...editing, [f.id]: val })
2446
2461
  }
2447
- ) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-1 h-10 flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2448
- "input",
2449
- {
2450
- type: "checkbox",
2451
- checked: !!editing[f.id],
2452
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.checked }),
2453
- className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
2454
- }
2455
- ) }) : f.type === "number" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
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: [
2464
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2465
+ "input",
2466
+ {
2467
+ type: "checkbox",
2468
+ checked: !!editing[f.id],
2469
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.checked }),
2470
+ className: "sr-only peer"
2471
+ }
2472
+ ),
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)(
2456
2477
  FormattedNumberInput,
2457
2478
  {
2458
2479
  value: editing[f.id],
@@ -2493,21 +2514,22 @@ function CollectionEditor({ collection }) {
2493
2514
  format: TIME_DISPLAY_FORMAT,
2494
2515
  use12Hours: true
2495
2516
  }
2496
- ) : f.type === "richtext" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2517
+ ) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2497
2518
  "textarea",
2498
2519
  {
2499
2520
  value: String(editing[f.id] ?? ""),
2500
2521
  onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2501
2522
  rows: 4,
2502
- 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-mono text-xs"
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"
2503
2525
  }
2504
2526
  ) : f.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2505
2527
  SearchableSelect,
2506
2528
  {
2507
2529
  value: String(editing[f.id] ?? ""),
2508
2530
  onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2509
- options: f.options || [],
2510
- placeholder: `Search ${f.label.toLowerCase()}...`,
2531
+ options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
2532
+ placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
2511
2533
  iconMap: ctx.iconMap
2512
2534
  }
2513
2535
  ) : f.type === "slug" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
@@ -2782,34 +2804,44 @@ function CollectionEditor({ collection }) {
2782
2804
  }
2783
2805
  )
2784
2806
  ] }) : f.type === "list" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2785
- (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
2786
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2787
- "input",
2788
- {
2789
- type: "text",
2790
- value: String(item ?? ""),
2791
- onChange: (e) => {
2792
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2793
- arr[idx] = e.target.value;
2794
- setEditing({ ...editing, [f.id]: arr });
2795
- },
2796
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2797
- }
2798
- ),
2799
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2800
- "button",
2801
- {
2802
- type: "button",
2803
- onClick: () => {
2804
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2805
- arr.splice(idx, 1);
2806
- setEditing({ ...editing, [f.id]: arr });
2807
- },
2808
- className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
2809
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
2810
- }
2811
- )
2812
- ] }, idx)),
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
+ ] }),
2815
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2816
+ "input",
2817
+ {
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"
2827
+ }
2828
+ ),
2829
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2830
+ "button",
2831
+ {
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 });
2837
+ },
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" })
2841
+ }
2842
+ )
2843
+ ] }, idx);
2844
+ }),
2813
2845
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2814
2846
  "button",
2815
2847
  {
@@ -2819,10 +2851,11 @@ function CollectionEditor({ collection }) {
2819
2851
  arr.push("");
2820
2852
  setEditing({ ...editing, [f.id]: arr });
2821
2853
  },
2822
- className: "inline-flex items-center gap-1.5 px-3 py-2 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-semibold rounded-xl transition-colors",
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",
2823
2855
  children: [
2824
2856
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
2825
- " Add Item"
2857
+ " ",
2858
+ f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") ? "Agregar caracter\xEDstica uno a uno" : "Agregar entregable / punto uno a uno"
2826
2859
  ]
2827
2860
  }
2828
2861
  )
@@ -3443,79 +3476,143 @@ function Row({
3443
3476
  function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
3444
3477
  const [open, setOpen] = (0, import_react5.useState)(false);
3445
3478
  const [search, setSearch] = (0, import_react5.useState)("");
3446
- const filtered = options.filter((o) => o.toLowerCase().includes(search.toLowerCase()));
3447
- const capped = filtered.slice(0, 80);
3479
+ const btnRef = (0, import_react5.useRef)(null);
3480
+ const [coords, setCoords] = (0, import_react5.useState)({
3481
+ top: 0,
3482
+ left: 0,
3483
+ width: 250
3484
+ });
3485
+ const updateCoords = (0, import_react5.useCallback)(() => {
3486
+ if (btnRef.current) {
3487
+ const rect = btnRef.current.getBoundingClientRect();
3488
+ const dropdownHeight = 280;
3489
+ const spaceBelow = window.innerHeight - rect.bottom;
3490
+ const opensUp = spaceBelow < dropdownHeight && rect.top > dropdownHeight;
3491
+ setCoords({
3492
+ top: opensUp ? Math.max(10, rect.top - dropdownHeight - 6) : rect.bottom + 6,
3493
+ left: Math.max(10, Math.min(rect.left, window.innerWidth - rect.width - 10)),
3494
+ width: rect.width
3495
+ });
3496
+ }
3497
+ }, []);
3498
+ const handleToggle = () => {
3499
+ if (!open) {
3500
+ updateCoords();
3501
+ }
3502
+ setOpen((prev) => !prev);
3503
+ setSearch("");
3504
+ };
3505
+ (0, import_react5.useEffect)(() => {
3506
+ if (!open) return;
3507
+ const handleScrollOrResize = () => {
3508
+ updateCoords();
3509
+ };
3510
+ window.addEventListener("scroll", handleScrollOrResize, true);
3511
+ window.addEventListener("resize", handleScrollOrResize);
3512
+ return () => {
3513
+ window.removeEventListener("scroll", handleScrollOrResize, true);
3514
+ window.removeEventListener("resize", handleScrollOrResize);
3515
+ };
3516
+ }, [open, updateCoords]);
3517
+ const filtered = options.filter(
3518
+ (o) => o.toLowerCase().includes(search.toLowerCase())
3519
+ );
3520
+ const capped = filtered.slice(0, 100);
3448
3521
  const SelectedIcon = iconMap && value ? iconMap[value] : null;
3449
3522
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
3450
3523
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3451
3524
  "button",
3452
3525
  {
3526
+ ref: btnRef,
3453
3527
  type: "button",
3454
- onClick: () => {
3455
- setOpen(!open);
3456
- setSearch("");
3457
- },
3458
- className: "w-full flex items-center justify-between rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm hover:border-slate-300 focus:border-indigo-500 bg-white transition-colors",
3528
+ onClick: handleToggle,
3529
+ className: "w-full flex items-center justify-between rounded-xl border border-slate-200 px-3.5 py-2.5 text-sm text-slate-800 shadow-sm hover:border-slate-300 focus:border-indigo-500 bg-white transition-colors cursor-pointer",
3459
3530
  children: [
3460
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2 truncate", children: [
3461
- SelectedIcon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SelectedIcon, { className: "w-4 h-4 text-indigo-600 shrink-0" }),
3462
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: value || placeholder || "Select..." })
3531
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2.5 truncate", children: [
3532
+ SelectedIcon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "w-5 h-5 flex items-center justify-center rounded bg-slate-100 text-indigo-600 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SelectedIcon, { className: "w-3.5 h-3.5" }) }),
3533
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate font-medium", children: value || placeholder || "Seleccionar icono..." })
3463
3534
  ] }),
3464
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: `w-4 h-4 text-slate-400 transition-transform shrink-0 ${open ? "rotate-180" : ""}` })
3465
- ]
3466
- }
3467
- ),
3468
- open && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3469
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "fixed inset-0 z-[100]", onClick: () => setOpen(false) }),
3470
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "absolute z-[101] mt-1 w-full rounded-xl border border-slate-200 bg-white shadow-2xl max-h-72 flex flex-col overflow-hidden animate-in fade-in slide-in-from-top-1 duration-150", children: [
3471
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-2 border-b border-slate-100 flex items-center gap-2", children: [
3472
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "w-4 h-4 text-slate-400 shrink-0" }),
3473
3535
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3474
- "input",
3536
+ import_lucide_react2.ChevronDown,
3475
3537
  {
3476
- autoFocus: true,
3477
- type: "text",
3478
- className: "w-full text-sm outline-none bg-transparent text-slate-800 placeholder:text-slate-400",
3479
- placeholder: "Type to search\u2026",
3480
- value: search,
3481
- onChange: (e) => setSearch(e.target.value)
3538
+ className: `w-4 h-4 text-slate-400 transition-transform shrink-0 ${open ? "rotate-180" : ""}`
3482
3539
  }
3483
- ),
3484
- search && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-bold text-slate-400 bg-slate-100 px-1.5 py-0.5 rounded-full shrink-0 tabular-nums", children: filtered.length })
3485
- ] }),
3486
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "overflow-y-auto flex-1 p-1", children: [
3487
- filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-4 text-xs text-slate-500 text-center", children: [
3488
- 'No results for "',
3489
- search,
3490
- '"'
3491
- ] }),
3492
- capped.map((opt) => {
3493
- const OptIcon = iconMap ? iconMap[opt] : null;
3494
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3495
- "button",
3496
- {
3497
- type: "button",
3498
- className: `w-full flex items-center gap-2.5 text-left px-2.5 py-1.5 text-sm rounded-lg transition-colors ${value === opt ? "bg-indigo-50 text-indigo-700 font-medium" : "text-slate-700 hover:bg-slate-50"}`,
3499
- onClick: () => {
3500
- onChange(opt);
3501
- setOpen(false);
3502
- },
3503
- children: [
3504
- OptIcon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "w-5 h-5 flex items-center justify-center rounded bg-slate-100 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OptIcon, { className: "w-3.5 h-3.5" }) }),
3505
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: opt })
3506
- ]
3507
- },
3508
- opt
3509
- );
3510
- }),
3511
- filtered.length > 80 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "px-3 py-2 text-[10px] text-slate-400 text-center border-t border-slate-100 mt-1", children: [
3512
- "Showing 80 of ",
3513
- filtered.length,
3514
- " \u2014 type to narrow results"
3515
- ] })
3516
- ] })
3517
- ] })
3518
- ] })
3540
+ )
3541
+ ]
3542
+ }
3543
+ ),
3544
+ open && typeof document !== "undefined" && (0, import_react_dom.createPortal)(
3545
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
3546
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3547
+ "div",
3548
+ {
3549
+ className: "fixed inset-0 z-[99998] cursor-default",
3550
+ onClick: () => setOpen(false)
3551
+ }
3552
+ ),
3553
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3554
+ "div",
3555
+ {
3556
+ style: {
3557
+ position: "fixed",
3558
+ top: `${coords.top}px`,
3559
+ left: `${coords.left}px`,
3560
+ width: `${coords.width}px`
3561
+ },
3562
+ className: "z-[99999] rounded-2xl border border-slate-200 bg-white shadow-2xl max-h-72 flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-150",
3563
+ children: [
3564
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-2.5 border-b border-slate-100 flex items-center gap-2 bg-slate-50/50", children: [
3565
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "w-4 h-4 text-slate-400 shrink-0" }),
3566
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3567
+ "input",
3568
+ {
3569
+ autoFocus: true,
3570
+ type: "text",
3571
+ className: "w-full text-sm outline-none bg-transparent text-slate-800 placeholder:text-slate-400",
3572
+ placeholder: "Buscar icono por nombre (ej: LuCode, LuServer)...",
3573
+ value: search,
3574
+ onChange: (e) => setSearch(e.target.value)
3575
+ }
3576
+ ),
3577
+ search && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-bold text-slate-400 bg-slate-200 px-1.5 py-0.5 rounded-full shrink-0 tabular-nums", children: filtered.length })
3578
+ ] }),
3579
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "overflow-y-auto flex-1 p-1.5", children: [
3580
+ filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-4 text-xs text-slate-500 text-center", children: [
3581
+ 'No se encontraron iconos para "',
3582
+ search,
3583
+ '"'
3584
+ ] }),
3585
+ capped.map((opt) => {
3586
+ const OptIcon = iconMap ? iconMap[opt] : null;
3587
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3588
+ "button",
3589
+ {
3590
+ type: "button",
3591
+ className: `w-full flex items-center gap-2.5 text-left px-2.5 py-2 text-sm rounded-xl transition-colors cursor-pointer ${value === opt ? "bg-indigo-50 text-indigo-700 font-semibold" : "text-slate-700 hover:bg-slate-50"}`,
3592
+ onClick: () => {
3593
+ onChange(opt);
3594
+ setOpen(false);
3595
+ },
3596
+ children: [
3597
+ OptIcon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "w-6 h-6 flex items-center justify-center rounded-lg bg-slate-100 text-indigo-600 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OptIcon, { className: "w-4 h-4" }) }),
3598
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: opt })
3599
+ ]
3600
+ },
3601
+ opt
3602
+ );
3603
+ }),
3604
+ filtered.length > 100 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "px-3 py-2 text-[10px] text-slate-400 text-center border-t border-slate-100 mt-1", children: [
3605
+ "Mostrando 100 de ",
3606
+ filtered.length,
3607
+ " \u2014 escribe en el buscador para filtrar"
3608
+ ] })
3609
+ ] })
3610
+ ]
3611
+ }
3612
+ )
3613
+ ] }),
3614
+ document.body
3615
+ )
3519
3616
  ] });
3520
3617
  }
3521
3618
  function PasswordField({ value, onChange }) {
package/dist/index.mjs CHANGED
@@ -23,6 +23,7 @@ import {
23
23
 
24
24
  // src/admin/AdminApp.tsx
25
25
  import { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
26
+ import { createPortal } from "react-dom";
26
27
  import { ConfigProvider, Modal, TimePicker } from "antd";
27
28
  import dayjs from "dayjs";
28
29
  import {
@@ -251,6 +252,16 @@ function AdminAppContent(props) {
251
252
  children: menuLabels.dashboard
252
253
  }
253
254
  ),
255
+ props.customSections?.map((cs) => /* @__PURE__ */ jsx(
256
+ SideItem,
257
+ {
258
+ active: section === cs.id,
259
+ onClick: () => setSection(cs.id),
260
+ icon: cs.icon || /* @__PURE__ */ jsx(Boxes, { className: "h-4 w-4 shrink-0" }),
261
+ children: cs.label
262
+ },
263
+ cs.id
264
+ )),
254
265
  /* @__PURE__ */ jsx(
255
266
  SideItem,
256
267
  {
@@ -328,7 +339,10 @@ function AdminAppContent(props) {
328
339
  !hideData && section === "submissions" && /* @__PURE__ */ jsx(SubmissionsSection, {}),
329
340
  !hideConfig && !hideGlobals && section === "config" && /* @__PURE__ */ jsx(ConfigSection, {}),
330
341
  !hideSettings && section === "settings" && /* @__PURE__ */ jsx(SettingsSection, {}),
331
- section === "subscription" && /* @__PURE__ */ jsx(SubscriptionPage, {})
342
+ section === "subscription" && /* @__PURE__ */ jsx(SubscriptionPage, {}),
343
+ props.customSections?.map(
344
+ (cs) => section === cs.id ? /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto", children: typeof cs.component === "function" ? createElement(cs.component) : cs.component }, cs.id) : null
345
+ )
332
346
  ] })
333
347
  ] })
334
348
  ] });
@@ -1553,6 +1567,7 @@ function CollectionEditor({ collection }) {
1553
1567
  newEntries[i].order = i;
1554
1568
  await ctx.adapter.putEntry(collection.id, newEntries[i]);
1555
1569
  }
1570
+ ctx.notifyCollectionChanged();
1556
1571
  };
1557
1572
  const onDragEnd = (e) => {
1558
1573
  const target = e.target;
@@ -1655,7 +1670,7 @@ function CollectionEditor({ collection }) {
1655
1670
  }
1656
1671
  },
1657
1672
  children: editing && /* @__PURE__ */ jsxs("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
1658
- /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ 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__ */ jsxs("div", { className: `block ${f.type === "richtext" || f.type === "branch-settings" || f.type === "time-range" ? "lg:col-span-2" : ""}`, children: [
1673
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ 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__ */ 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: [
1659
1674
  /* @__PURE__ */ jsxs("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
1660
1675
  f.label,
1661
1676
  /* @__PURE__ */ jsx("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
@@ -1669,15 +1684,21 @@ function CollectionEditor({ collection }) {
1669
1684
  globalDiscount: Number(editing.discountPercent) || 0,
1670
1685
  onChange: (val) => setEditing({ ...editing, [f.id]: val })
1671
1686
  }
1672
- ) : f.type === "boolean" ? /* @__PURE__ */ jsx("div", { className: "mt-1 h-10 flex items-center", children: /* @__PURE__ */ jsx(
1673
- "input",
1674
- {
1675
- type: "checkbox",
1676
- checked: !!editing[f.id],
1677
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.checked }),
1678
- className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
1679
- }
1680
- ) }) : f.type === "number" ? /* @__PURE__ */ jsx(
1687
+ ) : f.type === "boolean" ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-3", children: [
1688
+ /* @__PURE__ */ jsxs("label", { className: "relative inline-flex items-center cursor-pointer select-none", children: [
1689
+ /* @__PURE__ */ jsx(
1690
+ "input",
1691
+ {
1692
+ type: "checkbox",
1693
+ checked: !!editing[f.id],
1694
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.checked }),
1695
+ className: "sr-only peer"
1696
+ }
1697
+ ),
1698
+ /* @__PURE__ */ 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" })
1699
+ ] }),
1700
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-slate-700", children: editing[f.id] ? "Activado / S\xED" : "Desactivado / No" })
1701
+ ] }) : f.type === "number" ? /* @__PURE__ */ jsx(
1681
1702
  FormattedNumberInput,
1682
1703
  {
1683
1704
  value: editing[f.id],
@@ -1718,21 +1739,22 @@ function CollectionEditor({ collection }) {
1718
1739
  format: TIME_DISPLAY_FORMAT,
1719
1740
  use12Hours: true
1720
1741
  }
1721
- ) : f.type === "richtext" ? /* @__PURE__ */ jsx(
1742
+ ) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ jsx(
1722
1743
  "textarea",
1723
1744
  {
1724
1745
  value: String(editing[f.id] ?? ""),
1725
1746
  onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
1726
1747
  rows: 4,
1727
- 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-mono text-xs"
1748
+ placeholder: `Escribe ${f.label.toLowerCase()}...`,
1749
+ 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"
1728
1750
  }
1729
1751
  ) : f.type === "icon" ? /* @__PURE__ */ jsx(
1730
1752
  SearchableSelect,
1731
1753
  {
1732
1754
  value: String(editing[f.id] ?? ""),
1733
1755
  onChange: (val) => setEditing({ ...editing, [f.id]: val }),
1734
- options: f.options || [],
1735
- placeholder: `Search ${f.label.toLowerCase()}...`,
1756
+ options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
1757
+ placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
1736
1758
  iconMap: ctx.iconMap
1737
1759
  }
1738
1760
  ) : f.type === "slug" ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
@@ -2007,34 +2029,44 @@ function CollectionEditor({ collection }) {
2007
2029
  }
2008
2030
  )
2009
2031
  ] }) : f.type === "list" ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
2010
- (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
2011
- /* @__PURE__ */ jsx(
2012
- "input",
2013
- {
2014
- type: "text",
2015
- value: String(item ?? ""),
2016
- onChange: (e) => {
2017
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2018
- arr[idx] = e.target.value;
2019
- setEditing({ ...editing, [f.id]: arr });
2020
- },
2021
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2022
- }
2023
- ),
2024
- /* @__PURE__ */ jsx(
2025
- "button",
2026
- {
2027
- type: "button",
2028
- onClick: () => {
2029
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2030
- arr.splice(idx, 1);
2031
- setEditing({ ...editing, [f.id]: arr });
2032
- },
2033
- className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
2034
- children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
2035
- }
2036
- )
2037
- ] }, idx)),
2032
+ (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => {
2033
+ const isFeatures = f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") || f.label.toLowerCase().includes("beneficio");
2034
+ const placeholder = isFeatures ? `Caracter\xEDstica o beneficio ${idx + 1}...` : `Entregable o punto clave ${idx + 1}...`;
2035
+ return /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
2036
+ /* @__PURE__ */ jsxs("span", { className: "text-xs font-mono font-bold text-slate-400 w-6 text-right shrink-0", children: [
2037
+ idx + 1,
2038
+ "."
2039
+ ] }),
2040
+ /* @__PURE__ */ jsx(
2041
+ "input",
2042
+ {
2043
+ type: "text",
2044
+ value: String(item ?? ""),
2045
+ placeholder,
2046
+ onChange: (e) => {
2047
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2048
+ arr[idx] = e.target.value;
2049
+ setEditing({ ...editing, [f.id]: arr });
2050
+ },
2051
+ 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"
2052
+ }
2053
+ ),
2054
+ /* @__PURE__ */ jsx(
2055
+ "button",
2056
+ {
2057
+ type: "button",
2058
+ onClick: () => {
2059
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2060
+ arr.splice(idx, 1);
2061
+ setEditing({ ...editing, [f.id]: arr });
2062
+ },
2063
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer",
2064
+ title: "Eliminar elemento",
2065
+ children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
2066
+ }
2067
+ )
2068
+ ] }, idx);
2069
+ }),
2038
2070
  /* @__PURE__ */ jsxs(
2039
2071
  "button",
2040
2072
  {
@@ -2044,10 +2076,11 @@ function CollectionEditor({ collection }) {
2044
2076
  arr.push("");
2045
2077
  setEditing({ ...editing, [f.id]: arr });
2046
2078
  },
2047
- className: "inline-flex items-center gap-1.5 px-3 py-2 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-semibold rounded-xl transition-colors",
2079
+ 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",
2048
2080
  children: [
2049
2081
  /* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
2050
- " Add Item"
2082
+ " ",
2083
+ f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") ? "Agregar caracter\xEDstica uno a uno" : "Agregar entregable / punto uno a uno"
2051
2084
  ]
2052
2085
  }
2053
2086
  )
@@ -2668,79 +2701,143 @@ function Row({
2668
2701
  function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
2669
2702
  const [open, setOpen] = useState(false);
2670
2703
  const [search, setSearch] = useState("");
2671
- const filtered = options.filter((o) => o.toLowerCase().includes(search.toLowerCase()));
2672
- const capped = filtered.slice(0, 80);
2704
+ const btnRef = useRef(null);
2705
+ const [coords, setCoords] = useState({
2706
+ top: 0,
2707
+ left: 0,
2708
+ width: 250
2709
+ });
2710
+ const updateCoords = useCallback(() => {
2711
+ if (btnRef.current) {
2712
+ const rect = btnRef.current.getBoundingClientRect();
2713
+ const dropdownHeight = 280;
2714
+ const spaceBelow = window.innerHeight - rect.bottom;
2715
+ const opensUp = spaceBelow < dropdownHeight && rect.top > dropdownHeight;
2716
+ setCoords({
2717
+ top: opensUp ? Math.max(10, rect.top - dropdownHeight - 6) : rect.bottom + 6,
2718
+ left: Math.max(10, Math.min(rect.left, window.innerWidth - rect.width - 10)),
2719
+ width: rect.width
2720
+ });
2721
+ }
2722
+ }, []);
2723
+ const handleToggle = () => {
2724
+ if (!open) {
2725
+ updateCoords();
2726
+ }
2727
+ setOpen((prev) => !prev);
2728
+ setSearch("");
2729
+ };
2730
+ useEffect(() => {
2731
+ if (!open) return;
2732
+ const handleScrollOrResize = () => {
2733
+ updateCoords();
2734
+ };
2735
+ window.addEventListener("scroll", handleScrollOrResize, true);
2736
+ window.addEventListener("resize", handleScrollOrResize);
2737
+ return () => {
2738
+ window.removeEventListener("scroll", handleScrollOrResize, true);
2739
+ window.removeEventListener("resize", handleScrollOrResize);
2740
+ };
2741
+ }, [open, updateCoords]);
2742
+ const filtered = options.filter(
2743
+ (o) => o.toLowerCase().includes(search.toLowerCase())
2744
+ );
2745
+ const capped = filtered.slice(0, 100);
2673
2746
  const SelectedIcon = iconMap && value ? iconMap[value] : null;
2674
2747
  return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
2675
2748
  /* @__PURE__ */ jsxs(
2676
2749
  "button",
2677
2750
  {
2751
+ ref: btnRef,
2678
2752
  type: "button",
2679
- onClick: () => {
2680
- setOpen(!open);
2681
- setSearch("");
2682
- },
2683
- className: "w-full flex items-center justify-between rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm hover:border-slate-300 focus:border-indigo-500 bg-white transition-colors",
2753
+ onClick: handleToggle,
2754
+ className: "w-full flex items-center justify-between rounded-xl border border-slate-200 px-3.5 py-2.5 text-sm text-slate-800 shadow-sm hover:border-slate-300 focus:border-indigo-500 bg-white transition-colors cursor-pointer",
2684
2755
  children: [
2685
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 truncate", children: [
2686
- SelectedIcon && /* @__PURE__ */ jsx(SelectedIcon, { className: "w-4 h-4 text-indigo-600 shrink-0" }),
2687
- /* @__PURE__ */ jsx("span", { className: "truncate", children: value || placeholder || "Select..." })
2756
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2.5 truncate", children: [
2757
+ SelectedIcon && /* @__PURE__ */ jsx("span", { className: "w-5 h-5 flex items-center justify-center rounded bg-slate-100 text-indigo-600 shrink-0", children: /* @__PURE__ */ jsx(SelectedIcon, { className: "w-3.5 h-3.5" }) }),
2758
+ /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: value || placeholder || "Seleccionar icono..." })
2688
2759
  ] }),
2689
- /* @__PURE__ */ jsx(ChevronDown, { className: `w-4 h-4 text-slate-400 transition-transform shrink-0 ${open ? "rotate-180" : ""}` })
2690
- ]
2691
- }
2692
- ),
2693
- open && /* @__PURE__ */ jsxs(Fragment, { children: [
2694
- /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-[100]", onClick: () => setOpen(false) }),
2695
- /* @__PURE__ */ jsxs("div", { className: "absolute z-[101] mt-1 w-full rounded-xl border border-slate-200 bg-white shadow-2xl max-h-72 flex flex-col overflow-hidden animate-in fade-in slide-in-from-top-1 duration-150", children: [
2696
- /* @__PURE__ */ jsxs("div", { className: "p-2 border-b border-slate-100 flex items-center gap-2", children: [
2697
- /* @__PURE__ */ jsx(Search, { className: "w-4 h-4 text-slate-400 shrink-0" }),
2698
2760
  /* @__PURE__ */ jsx(
2699
- "input",
2761
+ ChevronDown,
2700
2762
  {
2701
- autoFocus: true,
2702
- type: "text",
2703
- className: "w-full text-sm outline-none bg-transparent text-slate-800 placeholder:text-slate-400",
2704
- placeholder: "Type to search\u2026",
2705
- value: search,
2706
- onChange: (e) => setSearch(e.target.value)
2763
+ className: `w-4 h-4 text-slate-400 transition-transform shrink-0 ${open ? "rotate-180" : ""}`
2707
2764
  }
2708
- ),
2709
- search && /* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold text-slate-400 bg-slate-100 px-1.5 py-0.5 rounded-full shrink-0 tabular-nums", children: filtered.length })
2710
- ] }),
2711
- /* @__PURE__ */ jsxs("div", { className: "overflow-y-auto flex-1 p-1", children: [
2712
- filtered.length === 0 && /* @__PURE__ */ jsxs("div", { className: "p-4 text-xs text-slate-500 text-center", children: [
2713
- 'No results for "',
2714
- search,
2715
- '"'
2716
- ] }),
2717
- capped.map((opt) => {
2718
- const OptIcon = iconMap ? iconMap[opt] : null;
2719
- return /* @__PURE__ */ jsxs(
2720
- "button",
2721
- {
2722
- type: "button",
2723
- className: `w-full flex items-center gap-2.5 text-left px-2.5 py-1.5 text-sm rounded-lg transition-colors ${value === opt ? "bg-indigo-50 text-indigo-700 font-medium" : "text-slate-700 hover:bg-slate-50"}`,
2724
- onClick: () => {
2725
- onChange(opt);
2726
- setOpen(false);
2727
- },
2728
- children: [
2729
- OptIcon && /* @__PURE__ */ jsx("span", { className: "w-5 h-5 flex items-center justify-center rounded bg-slate-100 shrink-0", children: /* @__PURE__ */ jsx(OptIcon, { className: "w-3.5 h-3.5" }) }),
2730
- /* @__PURE__ */ jsx("span", { className: "truncate", children: opt })
2731
- ]
2732
- },
2733
- opt
2734
- );
2735
- }),
2736
- filtered.length > 80 && /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 text-[10px] text-slate-400 text-center border-t border-slate-100 mt-1", children: [
2737
- "Showing 80 of ",
2738
- filtered.length,
2739
- " \u2014 type to narrow results"
2740
- ] })
2741
- ] })
2742
- ] })
2743
- ] })
2765
+ )
2766
+ ]
2767
+ }
2768
+ ),
2769
+ open && typeof document !== "undefined" && createPortal(
2770
+ /* @__PURE__ */ jsxs(Fragment, { children: [
2771
+ /* @__PURE__ */ jsx(
2772
+ "div",
2773
+ {
2774
+ className: "fixed inset-0 z-[99998] cursor-default",
2775
+ onClick: () => setOpen(false)
2776
+ }
2777
+ ),
2778
+ /* @__PURE__ */ jsxs(
2779
+ "div",
2780
+ {
2781
+ style: {
2782
+ position: "fixed",
2783
+ top: `${coords.top}px`,
2784
+ left: `${coords.left}px`,
2785
+ width: `${coords.width}px`
2786
+ },
2787
+ className: "z-[99999] rounded-2xl border border-slate-200 bg-white shadow-2xl max-h-72 flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-150",
2788
+ children: [
2789
+ /* @__PURE__ */ jsxs("div", { className: "p-2.5 border-b border-slate-100 flex items-center gap-2 bg-slate-50/50", children: [
2790
+ /* @__PURE__ */ jsx(Search, { className: "w-4 h-4 text-slate-400 shrink-0" }),
2791
+ /* @__PURE__ */ jsx(
2792
+ "input",
2793
+ {
2794
+ autoFocus: true,
2795
+ type: "text",
2796
+ className: "w-full text-sm outline-none bg-transparent text-slate-800 placeholder:text-slate-400",
2797
+ placeholder: "Buscar icono por nombre (ej: LuCode, LuServer)...",
2798
+ value: search,
2799
+ onChange: (e) => setSearch(e.target.value)
2800
+ }
2801
+ ),
2802
+ search && /* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold text-slate-400 bg-slate-200 px-1.5 py-0.5 rounded-full shrink-0 tabular-nums", children: filtered.length })
2803
+ ] }),
2804
+ /* @__PURE__ */ jsxs("div", { className: "overflow-y-auto flex-1 p-1.5", children: [
2805
+ filtered.length === 0 && /* @__PURE__ */ jsxs("div", { className: "p-4 text-xs text-slate-500 text-center", children: [
2806
+ 'No se encontraron iconos para "',
2807
+ search,
2808
+ '"'
2809
+ ] }),
2810
+ capped.map((opt) => {
2811
+ const OptIcon = iconMap ? iconMap[opt] : null;
2812
+ return /* @__PURE__ */ jsxs(
2813
+ "button",
2814
+ {
2815
+ type: "button",
2816
+ className: `w-full flex items-center gap-2.5 text-left px-2.5 py-2 text-sm rounded-xl transition-colors cursor-pointer ${value === opt ? "bg-indigo-50 text-indigo-700 font-semibold" : "text-slate-700 hover:bg-slate-50"}`,
2817
+ onClick: () => {
2818
+ onChange(opt);
2819
+ setOpen(false);
2820
+ },
2821
+ children: [
2822
+ OptIcon && /* @__PURE__ */ jsx("span", { className: "w-6 h-6 flex items-center justify-center rounded-lg bg-slate-100 text-indigo-600 shrink-0", children: /* @__PURE__ */ jsx(OptIcon, { className: "w-4 h-4" }) }),
2823
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: opt })
2824
+ ]
2825
+ },
2826
+ opt
2827
+ );
2828
+ }),
2829
+ filtered.length > 100 && /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 text-[10px] text-slate-400 text-center border-t border-slate-100 mt-1", children: [
2830
+ "Mostrando 100 de ",
2831
+ filtered.length,
2832
+ " \u2014 escribe en el buscador para filtrar"
2833
+ ] })
2834
+ ] })
2835
+ ]
2836
+ }
2837
+ )
2838
+ ] }),
2839
+ document.body
2840
+ )
2744
2841
  ] });
2745
2842
  }
2746
2843
  function PasswordField({ value, onChange }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admin-lib-cms",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "description": "Agnostic Admin CMS Library",
5
5
  "keywords": [
6
6
  "cms",