admin-lib-cms 1.1.1 → 1.1.3

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
@@ -752,6 +752,7 @@ function PageEditor({ page, showList, onToggleList }) {
752
752
  const [registered, setRegistered] = (0, import_react5.useState)([]);
753
753
  const [selectedId, setSelectedId] = (0, import_react5.useState)(null);
754
754
  const [preview, setPreview] = (0, import_react5.useState)(false);
755
+ const [drawerState, setDrawerState] = (0, import_react5.useState)("half");
755
756
  const src = (0, import_react5.useMemo)(
756
757
  () => `${page.path}${preview ? "" : "?__cms=edit"}`,
757
758
  [page.path, preview]
@@ -765,6 +766,9 @@ function PageEditor({ page, showList, onToggleList }) {
765
766
  setRegistered(d.items);
766
767
  } else if (d.type === "cms:select") {
767
768
  setSelectedId(d.id ?? null);
769
+ if (d.id) {
770
+ setDrawerState((prev) => prev === "min" ? "half" : prev);
771
+ }
768
772
  } else if (d.type === "cms:ready") {
769
773
  iframeRef.current?.contentWindow?.postMessage(
770
774
  { __cms: true, type: "cms:set-all-overrides", overrides: ctx.overrides },
@@ -855,8 +859,8 @@ function PageEditor({ page, showList, onToggleList }) {
855
859
  )
856
860
  ] })
857
861
  ] }),
858
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden", children: [
859
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 md:p-4 lg:p-6 flex flex-col items-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: `flex-1 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-lg ring-1 ring-slate-900/5 min-h-[300px] transition-all duration-300 w-full ${viewMode === "mobile" ? "max-w-[375px]" : viewMode === "tablet" ? "max-w-[768px]" : "w-full"}`, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
862
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col sm:flex-row flex-1 overflow-hidden", children: [
863
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 sm:p-4 flex flex-col items-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: `flex-1 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-lg ring-1 ring-slate-900/5 min-h-[300px] transition-all duration-300 w-full ${viewMode === "mobile" ? "max-w-[375px]" : viewMode === "tablet" ? "max-w-[768px]" : "w-full"}`, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
860
864
  "iframe",
861
865
  {
862
866
  ref: iframeRef,
@@ -866,47 +870,70 @@ function PageEditor({ page, showList, onToggleList }) {
866
870
  },
867
871
  src
868
872
  ) }) }),
869
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { className: "w-full lg:w-80 shrink-0 overflow-y-auto border-t lg:border-t-0 lg:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 max-h-[40vh] lg:max-h-none hide-scrollbar", children: [
870
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10", children: [
871
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500 flex justify-between items-center", children: [
872
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: selectedMeta ? "Edit Field" : "Editable Elements" }),
873
- selectedMeta && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: () => setSelectedId(null), className: "lg:hidden text-slate-400 hover:text-slate-700", children: "Close" })
874
- ] }),
875
- !selectedMeta && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-[10px] md:text-xs text-slate-400 mt-1", children: "Select an element on the left to edit it." })
876
- ] }),
877
- selectedMeta ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
878
- FieldEditor,
879
- {
880
- meta: selectedMeta,
881
- value: ctx.overrides[selectedMeta.id] ?? selectedMeta.defaultValue,
882
- onChange: (v) => updateOverride(selectedMeta.id, v),
883
- onReset: () => {
884
- ctx.reset(selectedMeta.id);
885
- iframeRef.current?.contentWindow?.postMessage(
873
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { className: `w-full sm:w-[320px] lg:w-[360px] shrink-0 overflow-y-auto border-t sm:border-t-0 sm:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 hide-scrollbar transition-all duration-300 ${drawerState === "min" ? "max-h-[52px] sm:max-h-none" : drawerState === "full" ? "max-h-[85vh] sm:max-h-none" : "max-h-[50vh] sm:max-h-none"}`, children: [
874
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10 flex items-center justify-between", children: [
875
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
876
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
877
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1 sm:hidden", children: [
878
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
879
+ "button",
886
880
  {
887
- __cms: true,
888
- type: "cms:set-override",
889
- id: selectedMeta.id,
890
- value: selectedMeta.defaultValue
891
- },
892
- "*"
893
- );
894
- },
895
- onClose: () => setSelectedId(null)
896
- }
897
- ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
898
- SectionAccordion,
899
- {
900
- registered,
901
- onSelect: (id) => {
902
- setSelectedId(id);
903
- iframeRef.current?.contentWindow?.postMessage(
904
- { __cms: true, type: "cms:select", id },
905
- "*"
906
- );
881
+ onClick: () => setDrawerState((prev) => prev === "full" ? "half" : prev === "half" ? "min" : "half"),
882
+ className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
883
+ title: "Shrink",
884
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "w-4 h-4" })
885
+ }
886
+ ),
887
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
888
+ "button",
889
+ {
890
+ onClick: () => setDrawerState((prev) => prev === "min" ? "half" : prev === "half" ? "full" : "half"),
891
+ className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
892
+ title: "Expand",
893
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronUp, { className: "w-4 h-4" })
894
+ }
895
+ )
896
+ ] }),
897
+ selectedMeta && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: () => setSelectedId(null), className: "sm:hidden text-slate-400 hover:text-slate-700 text-xs font-bold uppercase tracking-widest", children: "Close" })
898
+ ] })
899
+ ] }),
900
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
901
+ !selectedMeta && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-5 mt-1 mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-[10px] md:text-xs text-slate-400", children: "Select an element on the left to edit it." }) }),
902
+ selectedMeta ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
903
+ FieldEditor,
904
+ {
905
+ meta: selectedMeta,
906
+ value: ctx.overrides[selectedMeta.id] ?? selectedMeta.defaultValue,
907
+ onChange: (v) => updateOverride(selectedMeta.id, v),
908
+ onReset: () => {
909
+ ctx.reset(selectedMeta.id);
910
+ iframeRef.current?.contentWindow?.postMessage(
911
+ {
912
+ __cms: true,
913
+ type: "cms:set-override",
914
+ id: selectedMeta.id,
915
+ value: selectedMeta.defaultValue
916
+ },
917
+ "*"
918
+ );
919
+ },
920
+ onClose: () => setSelectedId(null)
907
921
  }
908
- }
909
- )
922
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
923
+ SectionAccordion,
924
+ {
925
+ registered,
926
+ onSelect: (id) => {
927
+ setSelectedId(id);
928
+ setDrawerState((prev) => prev === "min" ? "half" : prev);
929
+ iframeRef.current?.contentWindow?.postMessage(
930
+ { __cms: true, type: "cms:select", id },
931
+ "*"
932
+ );
933
+ }
934
+ }
935
+ )
936
+ ] })
910
937
  ] })
911
938
  ] })
912
939
  ] });
@@ -1316,8 +1343,8 @@ function CollectionsSection() {
1316
1343
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
1317
1344
  /* @__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: [
1318
1345
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
1319
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { className: "space-y-1", children: [
1320
- collections.map((c) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1346
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { className: "flex overflow-x-auto gap-2 pb-2 md:block md:space-x-0 md:space-y-1 md:pb-0 md:overflow-visible", children: [
1347
+ collections.map((c) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1321
1348
  "button",
1322
1349
  {
1323
1350
  onClick: () => setSelected(c),
@@ -1686,8 +1713,8 @@ function SubmissionsSection() {
1686
1713
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
1687
1714
  /* @__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: [
1688
1715
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Data Collections" }),
1689
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { className: "space-y-1", children: [
1690
- formIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1716
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { className: "flex overflow-x-auto gap-2 pb-2 md:block md:space-x-0 md:space-y-1 md:pb-0 md:overflow-visible", children: [
1717
+ formIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1691
1718
  "button",
1692
1719
  {
1693
1720
  onClick: () => setSelectedFormId(id),
@@ -2167,7 +2194,7 @@ function AdminLogin({
2167
2194
  const [loading, setLoading] = (0, import_react6.useState)(false);
2168
2195
  const [view, setView] = (0, import_react6.useState)("checking");
2169
2196
  (0, import_react6.useEffect)(() => {
2170
- fetch(authApiRoute).then((res) => res.json()).then((data) => {
2197
+ fetch(authApiRoute, { cache: "no-store" }).then((res) => res.json()).then((data) => {
2171
2198
  if (data.hasUsers) {
2172
2199
  setView("login");
2173
2200
  } else {
package/dist/index.mjs CHANGED
@@ -362,6 +362,7 @@ import {
362
362
  PanelLeftOpen,
363
363
  Search,
364
364
  ChevronDown,
365
+ ChevronUp,
365
366
  Inbox,
366
367
  RefreshCw,
367
368
  Eye,
@@ -749,6 +750,7 @@ function PageEditor({ page, showList, onToggleList }) {
749
750
  const [registered, setRegistered] = useState4([]);
750
751
  const [selectedId, setSelectedId] = useState4(null);
751
752
  const [preview, setPreview] = useState4(false);
753
+ const [drawerState, setDrawerState] = useState4("half");
752
754
  const src = useMemo2(
753
755
  () => `${page.path}${preview ? "" : "?__cms=edit"}`,
754
756
  [page.path, preview]
@@ -762,6 +764,9 @@ function PageEditor({ page, showList, onToggleList }) {
762
764
  setRegistered(d.items);
763
765
  } else if (d.type === "cms:select") {
764
766
  setSelectedId(d.id ?? null);
767
+ if (d.id) {
768
+ setDrawerState((prev) => prev === "min" ? "half" : prev);
769
+ }
765
770
  } else if (d.type === "cms:ready") {
766
771
  iframeRef.current?.contentWindow?.postMessage(
767
772
  { __cms: true, type: "cms:set-all-overrides", overrides: ctx.overrides },
@@ -852,8 +857,8 @@ function PageEditor({ page, showList, onToggleList }) {
852
857
  )
853
858
  ] })
854
859
  ] }),
855
- /* @__PURE__ */ jsxs2("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden", children: [
856
- /* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 md:p-4 lg:p-6 flex flex-col items-center", children: /* @__PURE__ */ jsx5("div", { className: `flex-1 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-lg ring-1 ring-slate-900/5 min-h-[300px] transition-all duration-300 w-full ${viewMode === "mobile" ? "max-w-[375px]" : viewMode === "tablet" ? "max-w-[768px]" : "w-full"}`, children: /* @__PURE__ */ jsx5(
860
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col sm:flex-row flex-1 overflow-hidden", children: [
861
+ /* @__PURE__ */ jsx5("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 sm:p-4 flex flex-col items-center", children: /* @__PURE__ */ jsx5("div", { className: `flex-1 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-lg ring-1 ring-slate-900/5 min-h-[300px] transition-all duration-300 w-full ${viewMode === "mobile" ? "max-w-[375px]" : viewMode === "tablet" ? "max-w-[768px]" : "w-full"}`, children: /* @__PURE__ */ jsx5(
857
862
  "iframe",
858
863
  {
859
864
  ref: iframeRef,
@@ -863,47 +868,70 @@ function PageEditor({ page, showList, onToggleList }) {
863
868
  },
864
869
  src
865
870
  ) }) }),
866
- /* @__PURE__ */ jsxs2("aside", { className: "w-full lg:w-80 shrink-0 overflow-y-auto border-t lg:border-t-0 lg:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 max-h-[40vh] lg:max-h-none hide-scrollbar", children: [
867
- /* @__PURE__ */ jsxs2("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10", children: [
868
- /* @__PURE__ */ jsxs2("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500 flex justify-between items-center", children: [
869
- /* @__PURE__ */ jsx5("span", { children: selectedMeta ? "Edit Field" : "Editable Elements" }),
870
- selectedMeta && /* @__PURE__ */ jsx5("button", { onClick: () => setSelectedId(null), className: "lg:hidden text-slate-400 hover:text-slate-700", children: "Close" })
871
- ] }),
872
- !selectedMeta && /* @__PURE__ */ jsx5("p", { className: "text-[10px] md:text-xs text-slate-400 mt-1", children: "Select an element on the left to edit it." })
873
- ] }),
874
- selectedMeta ? /* @__PURE__ */ jsx5(
875
- FieldEditor,
876
- {
877
- meta: selectedMeta,
878
- value: ctx.overrides[selectedMeta.id] ?? selectedMeta.defaultValue,
879
- onChange: (v) => updateOverride(selectedMeta.id, v),
880
- onReset: () => {
881
- ctx.reset(selectedMeta.id);
882
- iframeRef.current?.contentWindow?.postMessage(
871
+ /* @__PURE__ */ jsxs2("aside", { className: `w-full sm:w-[320px] lg:w-[360px] shrink-0 overflow-y-auto border-t sm:border-t-0 sm:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 hide-scrollbar transition-all duration-300 ${drawerState === "min" ? "max-h-[52px] sm:max-h-none" : drawerState === "full" ? "max-h-[85vh] sm:max-h-none" : "max-h-[50vh] sm:max-h-none"}`, children: [
872
+ /* @__PURE__ */ jsxs2("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10 flex items-center justify-between", children: [
873
+ /* @__PURE__ */ jsx5("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
874
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-3", children: [
875
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1 sm:hidden", children: [
876
+ /* @__PURE__ */ jsx5(
877
+ "button",
883
878
  {
884
- __cms: true,
885
- type: "cms:set-override",
886
- id: selectedMeta.id,
887
- value: selectedMeta.defaultValue
888
- },
889
- "*"
890
- );
891
- },
892
- onClose: () => setSelectedId(null)
893
- }
894
- ) : /* @__PURE__ */ jsx5(
895
- SectionAccordion,
896
- {
897
- registered,
898
- onSelect: (id) => {
899
- setSelectedId(id);
900
- iframeRef.current?.contentWindow?.postMessage(
901
- { __cms: true, type: "cms:select", id },
902
- "*"
903
- );
879
+ onClick: () => setDrawerState((prev) => prev === "full" ? "half" : prev === "half" ? "min" : "half"),
880
+ className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
881
+ title: "Shrink",
882
+ children: /* @__PURE__ */ jsx5(ChevronDown, { className: "w-4 h-4" })
883
+ }
884
+ ),
885
+ /* @__PURE__ */ jsx5(
886
+ "button",
887
+ {
888
+ onClick: () => setDrawerState((prev) => prev === "min" ? "half" : prev === "half" ? "full" : "half"),
889
+ className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
890
+ title: "Expand",
891
+ children: /* @__PURE__ */ jsx5(ChevronUp, { className: "w-4 h-4" })
892
+ }
893
+ )
894
+ ] }),
895
+ selectedMeta && /* @__PURE__ */ jsx5("button", { onClick: () => setSelectedId(null), className: "sm:hidden text-slate-400 hover:text-slate-700 text-xs font-bold uppercase tracking-widest", children: "Close" })
896
+ ] })
897
+ ] }),
898
+ /* @__PURE__ */ jsxs2("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
899
+ !selectedMeta && /* @__PURE__ */ jsx5("div", { className: "px-5 mt-1 mb-2", children: /* @__PURE__ */ jsx5("p", { className: "text-[10px] md:text-xs text-slate-400", children: "Select an element on the left to edit it." }) }),
900
+ selectedMeta ? /* @__PURE__ */ jsx5(
901
+ FieldEditor,
902
+ {
903
+ meta: selectedMeta,
904
+ value: ctx.overrides[selectedMeta.id] ?? selectedMeta.defaultValue,
905
+ onChange: (v) => updateOverride(selectedMeta.id, v),
906
+ onReset: () => {
907
+ ctx.reset(selectedMeta.id);
908
+ iframeRef.current?.contentWindow?.postMessage(
909
+ {
910
+ __cms: true,
911
+ type: "cms:set-override",
912
+ id: selectedMeta.id,
913
+ value: selectedMeta.defaultValue
914
+ },
915
+ "*"
916
+ );
917
+ },
918
+ onClose: () => setSelectedId(null)
904
919
  }
905
- }
906
- )
920
+ ) : /* @__PURE__ */ jsx5(
921
+ SectionAccordion,
922
+ {
923
+ registered,
924
+ onSelect: (id) => {
925
+ setSelectedId(id);
926
+ setDrawerState((prev) => prev === "min" ? "half" : prev);
927
+ iframeRef.current?.contentWindow?.postMessage(
928
+ { __cms: true, type: "cms:select", id },
929
+ "*"
930
+ );
931
+ }
932
+ }
933
+ )
934
+ ] })
907
935
  ] })
908
936
  ] })
909
937
  ] });
@@ -1313,8 +1341,8 @@ function CollectionsSection() {
1313
1341
  return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
1314
1342
  /* @__PURE__ */ jsxs2("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: [
1315
1343
  /* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
1316
- /* @__PURE__ */ jsxs2("ul", { className: "space-y-1", children: [
1317
- collections.map((c) => /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsxs2(
1344
+ /* @__PURE__ */ jsxs2("ul", { className: "flex overflow-x-auto gap-2 pb-2 md:block md:space-x-0 md:space-y-1 md:pb-0 md:overflow-visible", children: [
1345
+ collections.map((c) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */ jsxs2(
1318
1346
  "button",
1319
1347
  {
1320
1348
  onClick: () => setSelected(c),
@@ -1683,8 +1711,8 @@ function SubmissionsSection() {
1683
1711
  return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
1684
1712
  /* @__PURE__ */ jsxs2("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: [
1685
1713
  /* @__PURE__ */ jsx5("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Data Collections" }),
1686
- /* @__PURE__ */ jsxs2("ul", { className: "space-y-1", children: [
1687
- formIds.map((id) => /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsxs2(
1714
+ /* @__PURE__ */ jsxs2("ul", { className: "flex overflow-x-auto gap-2 pb-2 md:block md:space-x-0 md:space-y-1 md:pb-0 md:overflow-visible", children: [
1715
+ formIds.map((id) => /* @__PURE__ */ jsx5("li", { className: "shrink-0 min-w-[140px] md:w-full md:min-w-0", children: /* @__PURE__ */ jsxs2(
1688
1716
  "button",
1689
1717
  {
1690
1718
  onClick: () => setSelectedFormId(id),
@@ -2164,7 +2192,7 @@ function AdminLogin({
2164
2192
  const [loading, setLoading] = useState5(false);
2165
2193
  const [view, setView] = useState5("checking");
2166
2194
  useEffect5(() => {
2167
- fetch(authApiRoute).then((res) => res.json()).then((data) => {
2195
+ fetch(authApiRoute, { cache: "no-store" }).then((res) => res.json()).then((data) => {
2168
2196
  if (data.hasUsers) {
2169
2197
  setView("login");
2170
2198
  } else {
package/dist/storage.js CHANGED
@@ -186,8 +186,11 @@ function createSanityAdapter(config) {
186
186
  const readClient = createReadClient(config);
187
187
  const writeClient = config.token ? createWriteClient(config) : null;
188
188
  const apiBase = config.apiBase?.replace(/\/$/, "");
189
+ function canUseApi() {
190
+ return !!apiBase && (typeof window !== "undefined" || apiBase.startsWith("http"));
191
+ }
189
192
  async function writeOverrides(map) {
190
- if (apiBase) {
193
+ if (canUseApi()) {
191
194
  await apiRequest(apiBase, "/overrides", {
192
195
  method: "PUT",
193
196
  headers: { "Content-Type": "application/json" },
@@ -202,7 +205,7 @@ function createSanityAdapter(config) {
202
205
  await writeClient.transaction().createIfNotExists({ _id: OVERRIDES_DOC_ID, _type: "cms_overrides" }).patch(OVERRIDES_DOC_ID, (p) => p.set({ data: JSON.stringify(map) })).commit();
203
206
  }
204
207
  async function writeEntry(collectionId, entry) {
205
- if (apiBase) {
208
+ if (canUseApi()) {
206
209
  await apiRequest(apiBase, "/entries", {
207
210
  method: "PUT",
208
211
  headers: { "Content-Type": "application/json" },
@@ -223,7 +226,7 @@ function createSanityAdapter(config) {
223
226
  }).patch(docId, (p) => p.set({ data: JSON.stringify(entry) })).commit();
224
227
  }
225
228
  async function removeEntry(collectionId, entryId) {
226
- if (apiBase) {
229
+ if (canUseApi()) {
227
230
  await apiRequest(
228
231
  apiBase,
229
232
  `/entries?collectionId=${encodeURIComponent(collectionId)}&entryId=${encodeURIComponent(entryId)}`,
@@ -241,7 +244,7 @@ function createSanityAdapter(config) {
241
244
  name: "sanity",
242
245
  async getOverrides() {
243
246
  try {
244
- if (apiBase) {
247
+ if (canUseApi()) {
245
248
  return await apiRequest(apiBase, "/overrides");
246
249
  }
247
250
  const doc = await readClient.getDocument(OVERRIDES_DOC_ID);
@@ -262,7 +265,7 @@ function createSanityAdapter(config) {
262
265
  },
263
266
  async listEntries(collectionId) {
264
267
  try {
265
- if (apiBase) {
268
+ if (canUseApi()) {
266
269
  return await apiRequest(
267
270
  apiBase,
268
271
  `/entries?collectionId=${encodeURIComponent(collectionId)}`
@@ -295,7 +298,7 @@ function createSanityAdapter(config) {
295
298
  },
296
299
  async saveSubmission(submission) {
297
300
  try {
298
- if (apiBase) {
301
+ if (canUseApi()) {
299
302
  await apiRequest(apiBase, "/submissions", {
300
303
  method: "POST",
301
304
  headers: { "Content-Type": "application/json" },
@@ -327,7 +330,7 @@ function createSanityAdapter(config) {
327
330
  },
328
331
  async listSubmissions(formId) {
329
332
  try {
330
- if (apiBase) {
333
+ if (canUseApi()) {
331
334
  const qs = formId ? `?formId=${encodeURIComponent(formId)}` : "";
332
335
  return await apiRequest(apiBase, `/submissions${qs}`);
333
336
  }
@@ -349,7 +352,7 @@ function createSanityAdapter(config) {
349
352
  },
350
353
  async deleteSubmission(id) {
351
354
  try {
352
- if (apiBase) {
355
+ if (canUseApi()) {
353
356
  await apiRequest(
354
357
  apiBase,
355
358
  `/submissions?id=${encodeURIComponent(id)}`,
@@ -365,7 +368,7 @@ function createSanityAdapter(config) {
365
368
  },
366
369
  async markSubmissionRead(id) {
367
370
  try {
368
- if (apiBase) {
371
+ if (canUseApi()) {
369
372
  await apiRequest(apiBase, "/submissions", {
370
373
  method: "PATCH",
371
374
  headers: { "Content-Type": "application/json" },
@@ -380,7 +383,7 @@ function createSanityAdapter(config) {
380
383
  }
381
384
  },
382
385
  async uploadImage(file) {
383
- if (apiBase) {
386
+ if (canUseApi()) {
384
387
  const formData = new FormData();
385
388
  formData.append("file", file);
386
389
  const res = await fetch(`${apiBase}/upload`, {
package/dist/storage.mjs CHANGED
@@ -158,8 +158,11 @@ function createSanityAdapter(config) {
158
158
  const readClient = createReadClient(config);
159
159
  const writeClient = config.token ? createWriteClient(config) : null;
160
160
  const apiBase = config.apiBase?.replace(/\/$/, "");
161
+ function canUseApi() {
162
+ return !!apiBase && (typeof window !== "undefined" || apiBase.startsWith("http"));
163
+ }
161
164
  async function writeOverrides(map) {
162
- if (apiBase) {
165
+ if (canUseApi()) {
163
166
  await apiRequest(apiBase, "/overrides", {
164
167
  method: "PUT",
165
168
  headers: { "Content-Type": "application/json" },
@@ -174,7 +177,7 @@ function createSanityAdapter(config) {
174
177
  await writeClient.transaction().createIfNotExists({ _id: OVERRIDES_DOC_ID, _type: "cms_overrides" }).patch(OVERRIDES_DOC_ID, (p) => p.set({ data: JSON.stringify(map) })).commit();
175
178
  }
176
179
  async function writeEntry(collectionId, entry) {
177
- if (apiBase) {
180
+ if (canUseApi()) {
178
181
  await apiRequest(apiBase, "/entries", {
179
182
  method: "PUT",
180
183
  headers: { "Content-Type": "application/json" },
@@ -195,7 +198,7 @@ function createSanityAdapter(config) {
195
198
  }).patch(docId, (p) => p.set({ data: JSON.stringify(entry) })).commit();
196
199
  }
197
200
  async function removeEntry(collectionId, entryId) {
198
- if (apiBase) {
201
+ if (canUseApi()) {
199
202
  await apiRequest(
200
203
  apiBase,
201
204
  `/entries?collectionId=${encodeURIComponent(collectionId)}&entryId=${encodeURIComponent(entryId)}`,
@@ -213,7 +216,7 @@ function createSanityAdapter(config) {
213
216
  name: "sanity",
214
217
  async getOverrides() {
215
218
  try {
216
- if (apiBase) {
219
+ if (canUseApi()) {
217
220
  return await apiRequest(apiBase, "/overrides");
218
221
  }
219
222
  const doc = await readClient.getDocument(OVERRIDES_DOC_ID);
@@ -234,7 +237,7 @@ function createSanityAdapter(config) {
234
237
  },
235
238
  async listEntries(collectionId) {
236
239
  try {
237
- if (apiBase) {
240
+ if (canUseApi()) {
238
241
  return await apiRequest(
239
242
  apiBase,
240
243
  `/entries?collectionId=${encodeURIComponent(collectionId)}`
@@ -267,7 +270,7 @@ function createSanityAdapter(config) {
267
270
  },
268
271
  async saveSubmission(submission) {
269
272
  try {
270
- if (apiBase) {
273
+ if (canUseApi()) {
271
274
  await apiRequest(apiBase, "/submissions", {
272
275
  method: "POST",
273
276
  headers: { "Content-Type": "application/json" },
@@ -299,7 +302,7 @@ function createSanityAdapter(config) {
299
302
  },
300
303
  async listSubmissions(formId) {
301
304
  try {
302
- if (apiBase) {
305
+ if (canUseApi()) {
303
306
  const qs = formId ? `?formId=${encodeURIComponent(formId)}` : "";
304
307
  return await apiRequest(apiBase, `/submissions${qs}`);
305
308
  }
@@ -321,7 +324,7 @@ function createSanityAdapter(config) {
321
324
  },
322
325
  async deleteSubmission(id) {
323
326
  try {
324
- if (apiBase) {
327
+ if (canUseApi()) {
325
328
  await apiRequest(
326
329
  apiBase,
327
330
  `/submissions?id=${encodeURIComponent(id)}`,
@@ -337,7 +340,7 @@ function createSanityAdapter(config) {
337
340
  },
338
341
  async markSubmissionRead(id) {
339
342
  try {
340
- if (apiBase) {
343
+ if (canUseApi()) {
341
344
  await apiRequest(apiBase, "/submissions", {
342
345
  method: "PATCH",
343
346
  headers: { "Content-Type": "application/json" },
@@ -352,7 +355,7 @@ function createSanityAdapter(config) {
352
355
  }
353
356
  },
354
357
  async uploadImage(file) {
355
- if (apiBase) {
358
+ if (canUseApi()) {
356
359
  const formData = new FormData();
357
360
  formData.append("file", file);
358
361
  const res = await fetch(`${apiBase}/upload`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admin-lib-cms",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Agnostic Admin CMS Library",
5
5
  "keywords": [
6
6
  "cms",