admin-lib-cms 1.1.7 → 1.1.8

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
@@ -65,6 +65,13 @@ interface EditableImageProps extends BaseProps {
65
65
  height?: number;
66
66
  }
67
67
  declare function EditableImage({ id, label, section, pageId, src, alt, className, width, height, }: EditableImageProps): react.JSX.Element;
68
+ interface EditableFileProps extends BaseProps {
69
+ src?: string;
70
+ defaultUrl?: string;
71
+ className?: string;
72
+ children?: (url: string) => React.ReactNode;
73
+ }
74
+ declare function EditableFile({ id, label, section, pageId, src, defaultUrl, className, children, }: EditableFileProps): react.JSX.Element;
68
75
  interface EditableLinkProps extends BaseProps {
69
76
  href: string;
70
77
  children?: React.ReactNode;
@@ -134,4 +141,4 @@ declare function SubscriptionProvider({ children, apiUrl, projectId, email, vali
134
141
 
135
142
  declare function SubscriptionPage(): react.JSX.Element;
136
143
 
137
- export { AdminApp, AdminLogin, type AdminLoginProps, CmsConfig, CmsProvider, EditableImage, EditableLink, EditableList, EditableMeta, EditableText, OverridesMap, StorageAdapter, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useCmsContext, useCmsOptional, useSubmit, useSubscription, useSubscriptionContext };
144
+ export { AdminApp, AdminLogin, type AdminLoginProps, CmsConfig, CmsProvider, EditableFile, EditableImage, EditableLink, EditableList, EditableMeta, EditableText, OverridesMap, StorageAdapter, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useCmsContext, useCmsOptional, useSubmit, useSubscription, useSubscriptionContext };
package/dist/index.d.ts CHANGED
@@ -65,6 +65,13 @@ interface EditableImageProps extends BaseProps {
65
65
  height?: number;
66
66
  }
67
67
  declare function EditableImage({ id, label, section, pageId, src, alt, className, width, height, }: EditableImageProps): react.JSX.Element;
68
+ interface EditableFileProps extends BaseProps {
69
+ src?: string;
70
+ defaultUrl?: string;
71
+ className?: string;
72
+ children?: (url: string) => React.ReactNode;
73
+ }
74
+ declare function EditableFile({ id, label, section, pageId, src, defaultUrl, className, children, }: EditableFileProps): react.JSX.Element;
68
75
  interface EditableLinkProps extends BaseProps {
69
76
  href: string;
70
77
  children?: React.ReactNode;
@@ -134,4 +141,4 @@ declare function SubscriptionProvider({ children, apiUrl, projectId, email, vali
134
141
 
135
142
  declare function SubscriptionPage(): react.JSX.Element;
136
143
 
137
- export { AdminApp, AdminLogin, type AdminLoginProps, CmsConfig, CmsProvider, EditableImage, EditableLink, EditableList, EditableMeta, EditableText, OverridesMap, StorageAdapter, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useCmsContext, useCmsOptional, useSubmit, useSubscription, useSubscriptionContext };
144
+ export { AdminApp, AdminLogin, type AdminLoginProps, CmsConfig, CmsProvider, EditableFile, EditableImage, EditableLink, EditableList, EditableMeta, EditableText, OverridesMap, StorageAdapter, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useCmsContext, useCmsOptional, useSubmit, useSubscription, useSubscriptionContext };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  AdminApp: () => AdminApp,
25
25
  AdminLogin: () => AdminLogin,
26
26
  CmsProvider: () => CmsProvider,
27
+ EditableFile: () => EditableFile,
27
28
  EditableImage: () => EditableImage,
28
29
  EditableLink: () => EditableLink,
29
30
  EditableList: () => EditableList,
@@ -529,6 +530,55 @@ function EditableImage({
529
530
  }
530
531
  );
531
532
  }
533
+ function EditableFile({
534
+ id,
535
+ label,
536
+ section,
537
+ pageId,
538
+ src,
539
+ defaultUrl = "",
540
+ className,
541
+ children
542
+ }) {
543
+ const initialUrl = src || defaultUrl;
544
+ const ctx = useRegister(id, "file", label, section, pageId, initialUrl);
545
+ const value = ctx && Object.prototype.hasOwnProperty.call(ctx.overrides, id) ? String(ctx.overrides[id] ?? initialUrl) : initialUrl;
546
+ const active = !!ctx?.editMode;
547
+ const selected = ctx?.selectedId === id;
548
+ const onClick = (e) => {
549
+ if (!active || !ctx) return;
550
+ e.preventDefault();
551
+ e.stopPropagation();
552
+ ctx.setSelectedId(id);
553
+ };
554
+ if (children) {
555
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
556
+ "div",
557
+ {
558
+ "data-cms-id": id,
559
+ onClick: active ? onClick : void 0,
560
+ className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
561
+ children: children(value)
562
+ }
563
+ );
564
+ }
565
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
566
+ "div",
567
+ {
568
+ "data-cms-id": id,
569
+ onClick: active ? onClick : void 0,
570
+ className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
571
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
572
+ "iframe",
573
+ {
574
+ src: value,
575
+ className: "w-full h-[500px] rounded-xl border-0",
576
+ title: label || id
577
+ }
578
+ )
579
+ }
580
+ );
581
+ }
532
582
  function EditableLink({
533
583
  id,
534
584
  label,
@@ -1139,6 +1189,41 @@ function FieldEditor({
1139
1189
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-white text-xs font-medium px-2 py-1 bg-black/50 rounded backdrop-blur", children: "Preview" }) })
1140
1190
  ] }) : null
1141
1191
  ] }),
1192
+ meta.type === "file" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
1193
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
1194
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1195
+ "input",
1196
+ {
1197
+ type: "url",
1198
+ value: String(value ?? ""),
1199
+ onChange: (e) => onChange(e.target.value),
1200
+ placeholder: "https://... or upload PDF/file",
1201
+ 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"
1202
+ }
1203
+ ),
1204
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex-shrink-0 cursor-pointer rounded-xl bg-indigo-50 px-4 py-2.5 text-sm font-semibold text-indigo-700 hover:bg-indigo-100 transition-colors border border-indigo-100 flex items-center justify-center", children: [
1205
+ "Upload File",
1206
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1207
+ "input",
1208
+ {
1209
+ type: "file",
1210
+ accept: "application/pdf,.pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,image/*",
1211
+ className: "hidden",
1212
+ onChange: (e) => {
1213
+ const file = e.target.files?.[0];
1214
+ if (file) {
1215
+ void handleImageFile(file, onChange, ctx.uploadImage);
1216
+ }
1217
+ }
1218
+ }
1219
+ )
1220
+ ] })
1221
+ ] }),
1222
+ value ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-3 bg-slate-50 text-xs font-mono text-slate-600 truncate flex items-center gap-2", children: [
1223
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "\u{1F4C4} File URL:" }),
1224
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate text-indigo-600 font-semibold", children: String(value) })
1225
+ ] }) : null
1226
+ ] }),
1142
1227
  meta.type === "link" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-4 bg-slate-50 p-4 rounded-xl border border-slate-100", children: [
1143
1228
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block", children: [
1144
1229
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold text-slate-500 uppercase tracking-wide", children: "Link Text" }),
@@ -1659,7 +1744,149 @@ function CollectionEditor({ collection }) {
1659
1744
  value: String(editing[f.id] ?? ""),
1660
1745
  onChange: (val) => setEditing({ ...editing, [f.id]: val })
1661
1746
  }
1662
- ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1747
+ ) : f.type === "color" && !f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
1748
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1749
+ "input",
1750
+ {
1751
+ type: "color",
1752
+ value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
1753
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
1754
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
1755
+ }
1756
+ ),
1757
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1758
+ "input",
1759
+ {
1760
+ type: "text",
1761
+ value: String(editing[f.id] ?? ""),
1762
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
1763
+ placeholder: "#000000",
1764
+ 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"
1765
+ }
1766
+ ),
1767
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1768
+ "div",
1769
+ {
1770
+ className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
1771
+ style: { backgroundColor: String(editing[f.id] ?? "#000000") }
1772
+ }
1773
+ )
1774
+ ] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
1775
+ (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) => {
1776
+ const colorVal = String(item ?? "").trim();
1777
+ const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
1778
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
1779
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1780
+ "input",
1781
+ {
1782
+ type: "color",
1783
+ value: validHex.length === 7 ? validHex : "#000000",
1784
+ onChange: (e) => {
1785
+ 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) : [];
1786
+ arr[idx] = e.target.value;
1787
+ setEditing({ ...editing, [f.id]: arr });
1788
+ },
1789
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
1790
+ }
1791
+ ),
1792
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1793
+ "input",
1794
+ {
1795
+ type: "text",
1796
+ value: colorVal,
1797
+ onChange: (e) => {
1798
+ 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) : [];
1799
+ arr[idx] = e.target.value;
1800
+ setEditing({ ...editing, [f.id]: arr });
1801
+ },
1802
+ placeholder: "#1c2a44",
1803
+ 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"
1804
+ }
1805
+ ),
1806
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1807
+ "div",
1808
+ {
1809
+ className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
1810
+ style: { backgroundColor: colorVal || "#000000" }
1811
+ }
1812
+ ),
1813
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1814
+ "button",
1815
+ {
1816
+ type: "button",
1817
+ onClick: () => {
1818
+ 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) : [];
1819
+ arr.splice(idx, 1);
1820
+ setEditing({ ...editing, [f.id]: arr });
1821
+ },
1822
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
1823
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
1824
+ }
1825
+ )
1826
+ ] }, idx);
1827
+ }),
1828
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1829
+ "button",
1830
+ {
1831
+ type: "button",
1832
+ onClick: () => {
1833
+ 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) : [];
1834
+ arr.push("#000000");
1835
+ setEditing({ ...editing, [f.id]: arr });
1836
+ },
1837
+ 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",
1838
+ children: [
1839
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
1840
+ " Add Color"
1841
+ ]
1842
+ }
1843
+ )
1844
+ ] }) : f.type === "list" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
1845
+ (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: [
1846
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1847
+ "input",
1848
+ {
1849
+ type: "text",
1850
+ value: String(item ?? ""),
1851
+ onChange: (e) => {
1852
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
1853
+ arr[idx] = e.target.value;
1854
+ setEditing({ ...editing, [f.id]: arr });
1855
+ },
1856
+ 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"
1857
+ }
1858
+ ),
1859
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1860
+ "button",
1861
+ {
1862
+ type: "button",
1863
+ onClick: () => {
1864
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
1865
+ arr.splice(idx, 1);
1866
+ setEditing({ ...editing, [f.id]: arr });
1867
+ },
1868
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
1869
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
1870
+ }
1871
+ )
1872
+ ] }, idx)),
1873
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1874
+ "button",
1875
+ {
1876
+ type: "button",
1877
+ onClick: () => {
1878
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
1879
+ arr.push("");
1880
+ setEditing({ ...editing, [f.id]: arr });
1881
+ },
1882
+ 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",
1883
+ children: [
1884
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
1885
+ " Add Item"
1886
+ ]
1887
+ }
1888
+ )
1889
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1663
1890
  "input",
1664
1891
  {
1665
1892
  value: String(editing[f.id] ?? ""),
@@ -2512,6 +2739,7 @@ async function sendEmailNotification(content, apiUrl) {
2512
2739
  AdminApp,
2513
2740
  AdminLogin,
2514
2741
  CmsProvider,
2742
+ EditableFile,
2515
2743
  EditableImage,
2516
2744
  EditableLink,
2517
2745
  EditableList,
package/dist/index.mjs CHANGED
@@ -502,6 +502,55 @@ function EditableImage({
502
502
  }
503
503
  );
504
504
  }
505
+ function EditableFile({
506
+ id,
507
+ label,
508
+ section,
509
+ pageId,
510
+ src,
511
+ defaultUrl = "",
512
+ className,
513
+ children
514
+ }) {
515
+ const initialUrl = src || defaultUrl;
516
+ const ctx = useRegister(id, "file", label, section, pageId, initialUrl);
517
+ const value = ctx && Object.prototype.hasOwnProperty.call(ctx.overrides, id) ? String(ctx.overrides[id] ?? initialUrl) : initialUrl;
518
+ const active = !!ctx?.editMode;
519
+ const selected = ctx?.selectedId === id;
520
+ const onClick = (e) => {
521
+ if (!active || !ctx) return;
522
+ e.preventDefault();
523
+ e.stopPropagation();
524
+ ctx.setSelectedId(id);
525
+ };
526
+ if (children) {
527
+ return /* @__PURE__ */ jsx4(
528
+ "div",
529
+ {
530
+ "data-cms-id": id,
531
+ onClick: active ? onClick : void 0,
532
+ className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
533
+ children: children(value)
534
+ }
535
+ );
536
+ }
537
+ return /* @__PURE__ */ jsx4(
538
+ "div",
539
+ {
540
+ "data-cms-id": id,
541
+ onClick: active ? onClick : void 0,
542
+ className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
543
+ children: /* @__PURE__ */ jsx4(
544
+ "iframe",
545
+ {
546
+ src: value,
547
+ className: "w-full h-[500px] rounded-xl border-0",
548
+ title: label || id
549
+ }
550
+ )
551
+ }
552
+ );
553
+ }
505
554
  function EditableLink({
506
555
  id,
507
556
  label,
@@ -1138,6 +1187,41 @@ function FieldEditor({
1138
1187
  /* @__PURE__ */ jsx5("div", { className: "absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity", children: /* @__PURE__ */ jsx5("span", { className: "text-white text-xs font-medium px-2 py-1 bg-black/50 rounded backdrop-blur", children: "Preview" }) })
1139
1188
  ] }) : null
1140
1189
  ] }),
1190
+ meta.type === "file" && /* @__PURE__ */ jsxs3("div", { className: "space-y-3", children: [
1191
+ /* @__PURE__ */ jsxs3("div", { className: "flex gap-2", children: [
1192
+ /* @__PURE__ */ jsx5(
1193
+ "input",
1194
+ {
1195
+ type: "url",
1196
+ value: String(value ?? ""),
1197
+ onChange: (e) => onChange(e.target.value),
1198
+ placeholder: "https://... or upload PDF/file",
1199
+ 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"
1200
+ }
1201
+ ),
1202
+ /* @__PURE__ */ jsxs3("label", { className: "flex-shrink-0 cursor-pointer rounded-xl bg-indigo-50 px-4 py-2.5 text-sm font-semibold text-indigo-700 hover:bg-indigo-100 transition-colors border border-indigo-100 flex items-center justify-center", children: [
1203
+ "Upload File",
1204
+ /* @__PURE__ */ jsx5(
1205
+ "input",
1206
+ {
1207
+ type: "file",
1208
+ accept: "application/pdf,.pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,image/*",
1209
+ className: "hidden",
1210
+ onChange: (e) => {
1211
+ const file = e.target.files?.[0];
1212
+ if (file) {
1213
+ void handleImageFile(file, onChange, ctx.uploadImage);
1214
+ }
1215
+ }
1216
+ }
1217
+ )
1218
+ ] })
1219
+ ] }),
1220
+ value ? /* @__PURE__ */ jsxs3("div", { className: "rounded-xl border border-slate-200 p-3 bg-slate-50 text-xs font-mono text-slate-600 truncate flex items-center gap-2", children: [
1221
+ /* @__PURE__ */ jsx5("span", { children: "\u{1F4C4} File URL:" }),
1222
+ /* @__PURE__ */ jsx5("span", { className: "truncate text-indigo-600 font-semibold", children: String(value) })
1223
+ ] }) : null
1224
+ ] }),
1141
1225
  meta.type === "link" && /* @__PURE__ */ jsxs3("div", { className: "space-y-4 bg-slate-50 p-4 rounded-xl border border-slate-100", children: [
1142
1226
  /* @__PURE__ */ jsxs3("label", { className: "block", children: [
1143
1227
  /* @__PURE__ */ jsx5("span", { className: "text-xs font-semibold text-slate-500 uppercase tracking-wide", children: "Link Text" }),
@@ -1658,7 +1742,149 @@ function CollectionEditor({ collection }) {
1658
1742
  value: String(editing[f.id] ?? ""),
1659
1743
  onChange: (val) => setEditing({ ...editing, [f.id]: val })
1660
1744
  }
1661
- ) : /* @__PURE__ */ jsx5(
1745
+ ) : f.type === "color" && !f.multiple ? /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
1746
+ /* @__PURE__ */ jsx5(
1747
+ "input",
1748
+ {
1749
+ type: "color",
1750
+ value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
1751
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
1752
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
1753
+ }
1754
+ ),
1755
+ /* @__PURE__ */ jsx5(
1756
+ "input",
1757
+ {
1758
+ type: "text",
1759
+ value: String(editing[f.id] ?? ""),
1760
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
1761
+ placeholder: "#000000",
1762
+ 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"
1763
+ }
1764
+ ),
1765
+ /* @__PURE__ */ jsx5(
1766
+ "div",
1767
+ {
1768
+ className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
1769
+ style: { backgroundColor: String(editing[f.id] ?? "#000000") }
1770
+ }
1771
+ )
1772
+ ] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ jsxs3("div", { className: "space-y-3", children: [
1773
+ (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) => {
1774
+ const colorVal = String(item ?? "").trim();
1775
+ const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
1776
+ return /* @__PURE__ */ jsxs3("div", { className: "flex gap-2 items-center", children: [
1777
+ /* @__PURE__ */ jsx5(
1778
+ "input",
1779
+ {
1780
+ type: "color",
1781
+ value: validHex.length === 7 ? validHex : "#000000",
1782
+ onChange: (e) => {
1783
+ 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) : [];
1784
+ arr[idx] = e.target.value;
1785
+ setEditing({ ...editing, [f.id]: arr });
1786
+ },
1787
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
1788
+ }
1789
+ ),
1790
+ /* @__PURE__ */ jsx5(
1791
+ "input",
1792
+ {
1793
+ type: "text",
1794
+ value: colorVal,
1795
+ onChange: (e) => {
1796
+ 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) : [];
1797
+ arr[idx] = e.target.value;
1798
+ setEditing({ ...editing, [f.id]: arr });
1799
+ },
1800
+ placeholder: "#1c2a44",
1801
+ 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"
1802
+ }
1803
+ ),
1804
+ /* @__PURE__ */ jsx5(
1805
+ "div",
1806
+ {
1807
+ className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
1808
+ style: { backgroundColor: colorVal || "#000000" }
1809
+ }
1810
+ ),
1811
+ /* @__PURE__ */ jsx5(
1812
+ "button",
1813
+ {
1814
+ type: "button",
1815
+ onClick: () => {
1816
+ 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) : [];
1817
+ arr.splice(idx, 1);
1818
+ setEditing({ ...editing, [f.id]: arr });
1819
+ },
1820
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
1821
+ children: /* @__PURE__ */ jsx5(Trash2, { className: "w-4 h-4" })
1822
+ }
1823
+ )
1824
+ ] }, idx);
1825
+ }),
1826
+ /* @__PURE__ */ jsxs3(
1827
+ "button",
1828
+ {
1829
+ type: "button",
1830
+ onClick: () => {
1831
+ 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) : [];
1832
+ arr.push("#000000");
1833
+ setEditing({ ...editing, [f.id]: arr });
1834
+ },
1835
+ 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",
1836
+ children: [
1837
+ /* @__PURE__ */ jsx5(Plus, { className: "w-3.5 h-3.5" }),
1838
+ " Add Color"
1839
+ ]
1840
+ }
1841
+ )
1842
+ ] }) : f.type === "list" ? /* @__PURE__ */ jsxs3("div", { className: "space-y-3", children: [
1843
+ (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__ */ jsxs3("div", { className: "flex gap-2 items-center", children: [
1844
+ /* @__PURE__ */ jsx5(
1845
+ "input",
1846
+ {
1847
+ type: "text",
1848
+ value: String(item ?? ""),
1849
+ onChange: (e) => {
1850
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
1851
+ arr[idx] = e.target.value;
1852
+ setEditing({ ...editing, [f.id]: arr });
1853
+ },
1854
+ 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"
1855
+ }
1856
+ ),
1857
+ /* @__PURE__ */ jsx5(
1858
+ "button",
1859
+ {
1860
+ type: "button",
1861
+ onClick: () => {
1862
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
1863
+ arr.splice(idx, 1);
1864
+ setEditing({ ...editing, [f.id]: arr });
1865
+ },
1866
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
1867
+ children: /* @__PURE__ */ jsx5(Trash2, { className: "w-4 h-4" })
1868
+ }
1869
+ )
1870
+ ] }, idx)),
1871
+ /* @__PURE__ */ jsxs3(
1872
+ "button",
1873
+ {
1874
+ type: "button",
1875
+ onClick: () => {
1876
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
1877
+ arr.push("");
1878
+ setEditing({ ...editing, [f.id]: arr });
1879
+ },
1880
+ 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",
1881
+ children: [
1882
+ /* @__PURE__ */ jsx5(Plus, { className: "w-3.5 h-3.5" }),
1883
+ " Add Item"
1884
+ ]
1885
+ }
1886
+ )
1887
+ ] }) : /* @__PURE__ */ jsx5(
1662
1888
  "input",
1663
1889
  {
1664
1890
  value: String(editing[f.id] ?? ""),
@@ -2362,6 +2588,7 @@ export {
2362
2588
  AdminApp,
2363
2589
  AdminLogin,
2364
2590
  CmsProvider,
2591
+ EditableFile,
2365
2592
  EditableImage,
2366
2593
  EditableLink,
2367
2594
  EditableList,
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- type FieldType = "text" | "textarea" | "richtext" | "image" | "link" | "color" | "list" | "password";
1
+ type FieldType = "text" | "textarea" | "richtext" | "image" | "file" | "link" | "color" | "list" | "password";
2
2
  interface EditableMeta {
3
3
  id: string;
4
4
  label?: string;
@@ -8,7 +8,7 @@ interface EditableMeta {
8
8
  defaultValue?: unknown;
9
9
  itemSchema?: {
10
10
  key: string;
11
- type: "text" | "textarea" | "boolean" | "icon" | "image" | "number";
11
+ type: "text" | "textarea" | "boolean" | "icon" | "image" | "file" | "number";
12
12
  label?: string;
13
13
  options?: string[];
14
14
  }[];
@@ -29,6 +29,7 @@ interface CollectionField {
29
29
  value: string;
30
30
  }[];
31
31
  source?: string;
32
+ multiple?: boolean;
32
33
  defaultValue?: unknown;
33
34
  }
34
35
  interface CollectionDef {
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type FieldType = "text" | "textarea" | "richtext" | "image" | "link" | "color" | "list" | "password";
1
+ type FieldType = "text" | "textarea" | "richtext" | "image" | "file" | "link" | "color" | "list" | "password";
2
2
  interface EditableMeta {
3
3
  id: string;
4
4
  label?: string;
@@ -8,7 +8,7 @@ interface EditableMeta {
8
8
  defaultValue?: unknown;
9
9
  itemSchema?: {
10
10
  key: string;
11
- type: "text" | "textarea" | "boolean" | "icon" | "image" | "number";
11
+ type: "text" | "textarea" | "boolean" | "icon" | "image" | "file" | "number";
12
12
  label?: string;
13
13
  options?: string[];
14
14
  }[];
@@ -29,6 +29,7 @@ interface CollectionField {
29
29
  value: string;
30
30
  }[];
31
31
  source?: string;
32
+ multiple?: boolean;
32
33
  defaultValue?: unknown;
33
34
  }
34
35
  interface CollectionDef {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admin-lib-cms",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "Agnostic Admin CMS Library",
5
5
  "keywords": [
6
6
  "cms",