@particle-academy/fancy-cms-ui 0.1.1 → 0.2.0

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/editor.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-DLH7hU6G.cjs';
1
+ export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-CVT8sTum.cjs';
2
2
  import { ReactNode, ReactElement } from 'react';
3
3
  import { P as PageDoc, h as ElementRegistry, g as DataContext, N as Node, p as StyleProps, L as LayoutMode } from './registry-D5y5IgCR.cjs';
4
4
 
package/dist/editor.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-qmF9n2e6.js';
1
+ export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-CV5jFAgo.js';
2
2
  import { ReactNode, ReactElement } from 'react';
3
3
  import { P as PageDoc, h as ElementRegistry, g as DataContext, N as Node, p as StyleProps, L as LayoutMode } from './registry-D5y5IgCR.js';
4
4
 
package/dist/editor.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useEditor, useLatestRef, keyBetween } from './chunk-524NYOHK.js';
2
- export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-524NYOHK.js';
1
+ import { useEditor, useLatestRef, keyBetween } from './chunk-XQ3KHMBJ.js';
2
+ export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-XQ3KHMBJ.js';
3
3
  import { isBinding, childrenOf, CmsPage, defaultRegistry } from './chunk-GOXVGEKU.js';
4
4
  import { useState, useRef, useEffect, useCallback, useLayoutEffect } from 'react';
5
5
  import { ContextMenu } from '@particle-academy/react-fancy';
package/dist/index.cjs CHANGED
@@ -576,7 +576,7 @@ function useLatestRef(value) {
576
576
  });
577
577
  return ref;
578
578
  }
579
- function Canvas({ doc, selection, onSelect, apply }) {
579
+ function Canvas({ doc, selection, onSelect, apply, registry, data }) {
580
580
  const ref = react.useRef(null);
581
581
  const [box, setBox] = react.useState(null);
582
582
  const drag = react.useRef(null);
@@ -633,7 +633,7 @@ function Canvas({ doc, selection, onSelect, apply }) {
633
633
  position: "relative",
634
634
  overflow: "auto",
635
635
  height: "100%",
636
- background: "#f8fafc"
636
+ background: "var(--fcms-canvas)"
637
637
  };
638
638
  const overlay = box ? {
639
639
  position: "absolute",
@@ -641,13 +641,13 @@ function Canvas({ doc, selection, onSelect, apply }) {
641
641
  top: box.y,
642
642
  width: box.w,
643
643
  height: box.h,
644
- outline: "2px solid #8b5cf6",
644
+ outline: "2px solid var(--fcms-accent, #8b5cf6)",
645
645
  outlineOffset: -1,
646
646
  cursor: "move",
647
647
  touchAction: "none"
648
648
  } : { display: "none" };
649
649
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, onClick: handleClick, style: surface, children: [
650
- /* @__PURE__ */ jsxRuntime.jsx(CmsPage, { doc }),
650
+ /* @__PURE__ */ jsxRuntime.jsx(CmsPage, { doc, registry, data }),
651
651
  /* @__PURE__ */ jsxRuntime.jsx(
652
652
  "div",
653
653
  {
@@ -718,10 +718,10 @@ function LayerRow({ doc, id, depth, selection, onSelect, onMove, overId, setOver
718
718
  cursor: draggable ? "grab" : "pointer",
719
719
  padding: "4px 8px",
720
720
  paddingLeft: 8 + depth * 14,
721
- background: selected ? "#ede9fe" : "transparent",
722
- color: selected ? "#5b21b6" : "#334155",
721
+ background: selected ? "var(--fcms-sel-bg)" : "transparent",
722
+ color: selected ? "var(--fcms-sel-fg)" : "var(--fcms-row-fg)",
723
723
  font: "inherit",
724
- boxShadow: overId === id ? "inset 0 -2px 0 0 #8b5cf6" : "none"
724
+ boxShadow: overId === id ? "inset 0 -2px 0 0 var(--fcms-accent, #8b5cf6)" : "none"
725
725
  },
726
726
  children: [
727
727
  /* @__PURE__ */ jsxRuntime.jsx("span", { style: { opacity: 0.6 }, children: node.type }),
@@ -738,7 +738,7 @@ var label = {
738
738
  fontSize: 11,
739
739
  textTransform: "uppercase",
740
740
  letterSpacing: "0.04em",
741
- color: "#94a3b8",
741
+ color: "var(--fcms-muted)",
742
742
  margin: "10px 0 4px"
743
743
  };
744
744
  var input = {
@@ -746,21 +746,23 @@ var input = {
746
746
  boxSizing: "border-box",
747
747
  padding: "6px 8px",
748
748
  borderRadius: 6,
749
- border: "1px solid #e2e8f0",
749
+ border: "1px solid var(--fcms-border)",
750
+ background: "var(--fcms-input-bg)",
751
+ color: "var(--fcms-fg)",
750
752
  font: "inherit",
751
753
  fontSize: 13
752
754
  };
753
755
  function Inspector({ doc, selection, apply }) {
754
756
  const node = selection ? doc.nodes[selection] : null;
755
757
  if (!node) {
756
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 16, color: "#94a3b8", fontFamily: "system-ui, sans-serif", fontSize: 13 }, children: "Select an element to edit." });
758
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 16, color: "var(--fcms-muted)", fontFamily: "system-ui, sans-serif", fontSize: 13 }, children: "Select an element to edit." });
757
759
  }
758
760
  const s = node.style.base;
759
761
  const setStyle = (patch) => apply({ t: "set_style", id: node.id, breakpoint: "base", patch });
760
762
  const setProp = (key, value) => apply({ t: "set_props", id: node.id, patch: { [key]: value } });
761
763
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { overflow: "auto", padding: 16, fontFamily: "system-ui, sans-serif", height: "100%", boxSizing: "border-box" }, children: [
762
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 13, fontWeight: 600, color: "#0f172a" }, children: node.type }),
763
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, color: "#94a3b8", marginBottom: 8 }, children: node.id }),
764
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 13, fontWeight: 600, color: "var(--fcms-fg)" }, children: node.type }),
765
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontSize: 11, color: "var(--fcms-muted)", marginBottom: 8 }, children: node.id }),
764
766
  node.type === "text" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
765
767
  /* @__PURE__ */ jsxRuntime.jsx("label", { style: label, children: "Content" }),
766
768
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -838,7 +840,7 @@ function Inspector({ doc, selection, apply }) {
838
840
  )
839
841
  ] });
840
842
  }
841
- function Editor({ defaultValue, onChange }) {
843
+ function Editor({ defaultValue, onChange, registry, data }) {
842
844
  const ed = useEditor(defaultValue);
843
845
  const first = react.useRef(true);
844
846
  const onChangeRef = useLatestRef(onChange);
@@ -854,14 +856,15 @@ function Editor({ defaultValue, onChange }) {
854
856
  gridTemplateColumns: "220px 1fr 300px",
855
857
  height: "100%",
856
858
  minHeight: 0,
857
- background: "#fff",
858
- color: "#0f172a",
859
- border: "1px solid #e2e8f0",
859
+ background: "var(--fcms-bg)",
860
+ color: "var(--fcms-fg)",
861
+ border: "1px solid var(--fcms-border)",
860
862
  borderRadius: 12,
861
863
  overflow: "hidden"
862
864
  };
863
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: shell, children: [
864
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { borderRight: "1px solid #e2e8f0", display: "flex", flexDirection: "column", minHeight: 0 }, children: [
865
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fancy-cms-editor", style: shell, children: [
866
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: CHROME_CSS }),
867
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { borderRight: "1px solid var(--fcms-border)", display: "flex", flexDirection: "column", minHeight: 0 }, children: [
865
868
  /* @__PURE__ */ jsxRuntime.jsx(Toolbar, { ed }),
866
869
  /* @__PURE__ */ jsxRuntime.jsx(
867
870
  LayersPanel,
@@ -873,8 +876,8 @@ function Editor({ defaultValue, onChange }) {
873
876
  }
874
877
  )
875
878
  ] }),
876
- /* @__PURE__ */ jsxRuntime.jsx(Canvas, { doc: ed.state.doc, selection: ed.state.selection, onSelect: ed.select, apply: ed.apply }),
877
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { borderLeft: "1px solid #e2e8f0", minHeight: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(Inspector, { doc: ed.state.doc, selection: ed.state.selection, apply: ed.apply }) })
879
+ /* @__PURE__ */ jsxRuntime.jsx(Canvas, { doc: ed.state.doc, selection: ed.state.selection, onSelect: ed.select, apply: ed.apply, registry, data }),
880
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { borderLeft: "1px solid var(--fcms-border)", minHeight: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(Inspector, { doc: ed.state.doc, selection: ed.state.selection, apply: ed.apply }) })
878
881
  ] });
879
882
  }
880
883
  function Toolbar({ ed }) {
@@ -883,8 +886,9 @@ function Toolbar({ ed }) {
883
886
  fontSize: 12,
884
887
  padding: "4px 10px",
885
888
  borderRadius: 6,
886
- border: "1px solid #e2e8f0",
887
- background: "#fff",
889
+ border: "1px solid var(--fcms-border)",
890
+ background: "var(--fcms-bg)",
891
+ color: "var(--fcms-fg)",
888
892
  cursor: "pointer"
889
893
  };
890
894
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -894,7 +898,7 @@ function Toolbar({ ed }) {
894
898
  display: "flex",
895
899
  gap: 6,
896
900
  padding: 8,
897
- borderBottom: "1px solid #e2e8f0",
901
+ borderBottom: "1px solid var(--fcms-border)",
898
902
  fontFamily: "system-ui, sans-serif"
899
903
  },
900
904
  children: [
@@ -904,6 +908,9 @@ function Toolbar({ ed }) {
904
908
  }
905
909
  );
906
910
  }
911
+ var DARK_VARS = "color-scheme:dark;--fcms-bg:#0b0f19;--fcms-fg:#e5e7eb;--fcms-muted:#94a3b8;--fcms-border:#27272a;--fcms-canvas:#0f141f;--fcms-input-bg:#111827;--fcms-row-fg:#cbd5e1;--fcms-sel-bg:color-mix(in oklab, #8b5cf6 24%, transparent);--fcms-sel-fg:#ddd6fe;";
912
+ var LIGHT_VARS = "color-scheme:light;--fcms-bg:#ffffff;--fcms-fg:#0f172a;--fcms-muted:#64748b;--fcms-border:#e2e8f0;--fcms-canvas:#f8fafc;--fcms-input-bg:#ffffff;--fcms-row-fg:#334155;--fcms-sel-bg:#ede9fe;--fcms-sel-fg:#5b21b6;";
913
+ var CHROME_CSS = `.fancy-cms-editor{--fcms-accent:#8b5cf6;${LIGHT_VARS}}@media (prefers-color-scheme:dark){.fancy-cms-editor{${DARK_VARS}}}:where(.light,[data-theme="light"]) .fancy-cms-editor{${LIGHT_VARS}}:where(.dark,[data-theme="dark"]) .fancy-cms-editor{${DARK_VARS}}`;
907
914
 
908
915
  exports.Canvas = Canvas;
909
916
  exports.CmsPage = CmsPage;