@jiggai/kitchen-plugin-marketing 0.5.4 → 0.5.6

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.
@@ -10,10 +10,25 @@
10
10
  const useMemo = R.useMemo;
11
11
  const useCallback = R.useCallback;
12
12
  const useRef = R.useRef;
13
- const Portal = ({ children }) => {
14
- if (RD?.createPortal) return RD.createPortal(children, document.body);
13
+ function Portal({ children }) {
14
+ const rd = RD || typeof window !== "undefined" && window.ReactDOM;
15
+ const [container] = useState(() => {
16
+ if (typeof document === "undefined") return null;
17
+ const el = document.createElement("div");
18
+ el.setAttribute("data-ck-portal", "marketing");
19
+ return el;
20
+ });
21
+ useEffect(() => {
22
+ if (!container) return;
23
+ document.body.appendChild(container);
24
+ return () => {
25
+ document.body.removeChild(container);
26
+ };
27
+ }, [container]);
28
+ if (rd?.createPortal && container) return rd.createPortal(children, container);
29
+ if (container) return rd?.createPortal ? rd.createPortal(children, container) : children;
15
30
  return children;
16
- };
31
+ }
17
32
  const s = {
18
33
  // layout
19
34
  container: { color: "var(--ck-text-primary)" },
@@ -812,11 +827,11 @@
812
827
  }
813
828
  function CreateModal() {
814
829
  if (!modalOpen) return null;
815
- const charLimit = useMemo(() => {
816
- if (modalPlatforms.length === 0) return void 0;
830
+ let charLimit = void 0;
831
+ if (modalPlatforms.length > 0) {
817
832
  const limits = modalPlatforms.map((p) => drivers.find((d) => d.platform === p)?.capabilities?.maxLength).filter((l) => l !== void 0);
818
- return limits.length > 0 ? Math.min(...limits) : void 0;
819
- }, [modalPlatforms, drivers]);
833
+ if (limits.length > 0) charLimit = Math.min(...limits);
834
+ }
820
835
  return h(
821
836
  Portal,
822
837
  null,
@@ -1251,9 +1266,9 @@
1251
1266
  h("button", { style: s.btnPrimary, onClick: () => openCreateModal() }, "+ New Post")
1252
1267
  )
1253
1268
  ),
1254
- loading ? h("div", { style: { textAlign: "center", padding: "3rem", color: "var(--ck-text-tertiary)" } }, "Loading calendar\u2026") : view === "week" ? h(WeekView, null) : h(MonthView, null),
1255
- h(PreviewModal, null),
1256
- h(CreateModal, null)
1269
+ loading ? h("div", { style: { textAlign: "center", padding: "3rem", color: "var(--ck-text-tertiary)" } }, "Loading calendar\u2026") : view === "week" ? WeekView() : MonthView(),
1270
+ PreviewModal(),
1271
+ CreateModal()
1257
1272
  );
1258
1273
  }
1259
1274
  window.KitchenPlugin.registerTab("marketing", "content-calendar", ContentCalendar);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiggai/kitchen-plugin-marketing",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Marketing Suite plugin for ClawKitchen",
5
5
  "main": "dist/index.js",
6
6
  "files": [