@chaibuilder/sdk 0.1.2 → 0.1.4
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/{AddBlocks-e23baf9a.cjs → AddBlocks-1f683caa.cjs} +1 -1
- package/dist/{AddBlocks-b5f37f2f.js → AddBlocks-b6a12d50.js} +19 -19
- package/dist/{BrandingOptions-3d1bd24a.cjs → BrandingOptions-02e4ebcf.cjs} +1 -1
- package/dist/{BrandingOptions-cfd1b740.js → BrandingOptions-1190723a.js} +27 -27
- package/dist/{CanvasArea-a065a586.js → CanvasArea-15458836.js} +19 -18
- package/dist/CanvasArea-f5d27245.cjs +60 -0
- package/dist/Class-7d6aadbc.cjs +1 -0
- package/dist/{Class-e6b07b79.js → Class-e34b2337.js} +9 -9
- package/dist/{ImagesPanel-eccf9a56.js → ImagesPanel-8ccab6d9.js} +1 -1
- package/dist/{ImagesPanel-cc136c92.cjs → ImagesPanel-addb2bf9.cjs} +1 -1
- package/dist/{Layers-f002ba1a.cjs → Layers-06fa708d.cjs} +1 -1
- package/dist/{Layers-f935e07b.js → Layers-ff4ef9c0.js} +3 -3
- package/dist/{MarkAsGlobalBlock-613bfdab.js → MarkAsGlobalBlock-dea26aa7.js} +2 -2
- package/dist/{MarkAsGlobalBlock-5f435dd5.cjs → MarkAsGlobalBlock-fa0e0543.cjs} +1 -1
- package/dist/PagesPanel-3e9163c4.js +46 -0
- package/dist/PagesPanel-b08e1357.cjs +1 -0
- package/dist/ProjectPanel-17c5f131.js +66 -0
- package/dist/ProjectPanel-f0b94e3f.cjs +1 -0
- package/dist/{Settings-a19fbb69.js → Settings-6f2e86a9.js} +25 -24
- package/dist/Settings-739cff3b.cjs +1 -0
- package/dist/{SidePanels-67ebbcb4.js → SidePanels-96e64da9.js} +3 -3
- package/dist/{SidePanels-af222189.cjs → SidePanels-ce4d41d5.cjs} +1 -1
- package/dist/{Topbar-fcb01371.js → Topbar-08d10607.js} +2 -2
- package/dist/{Topbar-e92351cc.cjs → Topbar-b97472fc.cjs} +1 -1
- package/dist/UnsplashImages-68492dc9.cjs +1 -0
- package/dist/{UnsplashImages-fda2f29a.js → UnsplashImages-afaa7706.js} +19 -28
- package/dist/add-page-modal-3275cfb2.cjs +1 -0
- package/dist/add-page-modal-bcd9249e.js +93 -0
- package/dist/alert-dialog-4ce6ed22.cjs +1 -0
- package/dist/alert-dialog-ee98f47e.js +64 -0
- package/dist/confirm-alert-4f50caa7.cjs +1 -0
- package/dist/confirm-alert-f2a47cc7.js +36 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +20 -12
- package/dist/core.js +53 -52
- package/dist/delete-page-modal-420a17e3.cjs +1 -0
- package/dist/delete-page-modal-fa7b4272.js +64 -0
- package/dist/dropdown-menu-84b2439e.cjs +1 -0
- package/dist/dropdown-menu-ae3ed09b.js +164 -0
- package/dist/form-5d5c5c9e.js +125 -0
- package/dist/form-6eac0287.cjs +1 -0
- package/dist/{html-to-json-7510f587.js → html-to-json-9304dbda.js} +1 -1
- package/dist/{html-to-json-7eba915f.cjs → html-to-json-9c9961da.cjs} +1 -1
- package/dist/index-133d90a5.cjs +2 -0
- package/dist/index-3f65447f.js +4754 -0
- package/dist/input-42acea7e.cjs +1 -0
- package/dist/input-a0ea2bc7.js +19 -0
- package/dist/lib.cjs +1 -1
- package/dist/lib.js +3 -3
- package/dist/link-86c532b5.cjs +1 -0
- package/dist/{link-e406254f.js → link-f80a947d.js} +44 -60
- package/dist/mockServiceWorker.js +292 -0
- package/dist/page-viewer-139bfb2a.cjs +1 -0
- package/dist/page-viewer-f1452439.js +88 -0
- package/dist/project-general-setting-0d7715b8.cjs +1 -0
- package/dist/project-general-setting-e5d14fa6.js +65 -0
- package/dist/project-seo-setting-01536592.js +67 -0
- package/dist/project-seo-setting-e3924578.cjs +1 -0
- package/dist/server.cjs +1 -0
- package/dist/server.d.ts +142 -0
- package/dist/server.js +126 -0
- package/dist/single-page-detail-54d7feca.cjs +1 -0
- package/dist/single-page-detail-74f88ed2.js +207 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +124 -122
- package/dist/useMutation-7d536740.cjs +1 -0
- package/dist/useMutation-97876a40.js +126 -0
- package/dist/usePageActions-ac9ad321.cjs +1 -0
- package/dist/usePageActions-de3b7515.js +37 -0
- package/dist/useProjectActions-3b1dbb5e.js +18 -0
- package/dist/useProjectActions-41af0f70.cjs +1 -0
- package/package.json +20 -2
- package/dist/CanvasArea-c4554d61.cjs +0 -60
- package/dist/Class-0801d193.cjs +0 -1
- package/dist/Settings-05b9b5fe.cjs +0 -1
- package/dist/UnsplashImages-cca34e45.cjs +0 -1
- package/dist/dropdown-menu-a9b096f9.cjs +0 -1
- package/dist/dropdown-menu-d912a52e.js +0 -223
- package/dist/index-73cf645f.cjs +0 -2
- package/dist/index-7e212fbc.js +0 -2657
- package/dist/link-1ee70bca.cjs +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { j as e } from "./jsx-runtime-944c88e2.js";
|
|
2
|
+
import o, { useState as c, Suspense as m } from "react";
|
|
3
|
+
import { HomeIcon as p, FileTextIcon as u, ChevronRightIcon as d, GearIcon as x } from "@radix-ui/react-icons";
|
|
4
|
+
import { P as g, a as h, b as f } from "./popover-f7addcf4.js";
|
|
5
|
+
import { O as j } from "./index-3f65447f.js";
|
|
6
|
+
import "@radix-ui/react-popover";
|
|
7
|
+
import "./utils-ac68b2c8.js";
|
|
8
|
+
import "clsx";
|
|
9
|
+
import "tailwind-merge";
|
|
10
|
+
import "i18next";
|
|
11
|
+
import "react-i18next";
|
|
12
|
+
import "flagged";
|
|
13
|
+
import "react-dnd";
|
|
14
|
+
import "lodash";
|
|
15
|
+
import "@minoru/react-dnd-treeview";
|
|
16
|
+
import "./useBuilderProp-81a14920.js";
|
|
17
|
+
import "@radix-ui/react-slot";
|
|
18
|
+
import "class-variance-authority";
|
|
19
|
+
import "@radix-ui/react-tooltip";
|
|
20
|
+
import "@radix-ui/react-toast";
|
|
21
|
+
import "jotai";
|
|
22
|
+
import "react-hotkeys-hook";
|
|
23
|
+
import "flat-to-nested";
|
|
24
|
+
import "./Class-e34b2337.js";
|
|
25
|
+
import "redux-undo";
|
|
26
|
+
import "@react-hookz/web";
|
|
27
|
+
import "@chaibuilder/blocks";
|
|
28
|
+
import "./CONTROLS-442caee5.js";
|
|
29
|
+
const N = o.lazy(() => import("./single-page-detail-74f88ed2.js")), b = ({ pageData: t }) => {
|
|
30
|
+
const [s, r] = c("CLOSE");
|
|
31
|
+
return /* @__PURE__ */ e.jsxs(
|
|
32
|
+
g,
|
|
33
|
+
{
|
|
34
|
+
open: s === "OPEN" || s === "ALERT" || s === "PENDING",
|
|
35
|
+
onOpenChange: (i) => {
|
|
36
|
+
r(s === "PENDING" ? "ALERT" : i ? "OPEN" : "CLOSE");
|
|
37
|
+
},
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ e.jsx(
|
|
40
|
+
h,
|
|
41
|
+
{
|
|
42
|
+
asChild: !0,
|
|
43
|
+
onClick: (i) => {
|
|
44
|
+
i.stopPropagation(), r("OPEN");
|
|
45
|
+
},
|
|
46
|
+
children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-between", children: s === "OPEN" || s === "ALERT" || s === "PENDING" ? /* @__PURE__ */ e.jsx(d, {}) : /* @__PURE__ */ e.jsx("div", { className: "hidden hover:text-blue-600 group-hover:flex", children: /* @__PURE__ */ e.jsx(x, {}) }) })
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ e.jsx(f, { side: "right", align: "start", alignOffset: -35, className: "h-screen w-96", children: /* @__PURE__ */ e.jsx(
|
|
50
|
+
m,
|
|
51
|
+
{
|
|
52
|
+
fallback: /* @__PURE__ */ e.jsxs("div", { className: "flex w-full animate-pulse flex-col gap-y-3", children: [
|
|
53
|
+
/* @__PURE__ */ e.jsx("div", { className: "bg-background-300 h-6 w-1/2" }),
|
|
54
|
+
/* @__PURE__ */ e.jsx("div", { className: "bg-background-300 h-20 w-full" }),
|
|
55
|
+
/* @__PURE__ */ e.jsx("div", { className: "bg-background-300 h-20 w-full" })
|
|
56
|
+
] }),
|
|
57
|
+
children: /* @__PURE__ */ e.jsx(N, { pageData: t, open: s, setOpen: r })
|
|
58
|
+
}
|
|
59
|
+
) })
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}, v = (t) => {
|
|
64
|
+
const [s] = ["123"], { data: r } = j(), i = {}, a = (r == null ? void 0 : r.homepage) === t.uuid, n = s === t.uuid, l = () => i(t);
|
|
65
|
+
return r ? /* @__PURE__ */ e.jsxs(
|
|
66
|
+
"button",
|
|
67
|
+
{
|
|
68
|
+
className: `group relative flex w-full cursor-pointer items-center justify-between px-2.5 py-2 ${n ? "bg-blue-200 " : ""}`,
|
|
69
|
+
onClick: l,
|
|
70
|
+
type: "button",
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-x-1.5", children: [
|
|
73
|
+
a ? /* @__PURE__ */ e.jsx(p, {}) : /* @__PURE__ */ e.jsx(u, {}),
|
|
74
|
+
" ",
|
|
75
|
+
t.name
|
|
76
|
+
] }),
|
|
77
|
+
/* @__PURE__ */ e.jsx(b, { pageData: t })
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
) : null;
|
|
81
|
+
}, W = ({ pages: t, isLoading: s }) => s ? /* @__PURE__ */ e.jsxs("div", { className: "flex animate-pulse flex-col gap-y-1 px-2.5 pt-2", children: [
|
|
82
|
+
/* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" }),
|
|
83
|
+
/* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" }),
|
|
84
|
+
/* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" })
|
|
85
|
+
] }) : t.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "px-2.5 pb-2 pt-4", children: "No pages" }) : /* @__PURE__ */ e.jsx("div", { className: "-mb-2", children: o.Children.toArray(t.map((r) => /* @__PURE__ */ e.jsx(v, { ...r }))) });
|
|
86
|
+
export {
|
|
87
|
+
W as default
|
|
88
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-5c3ac4f7.cjs"),a=require("react"),f=require("./scroll-area-088530b9.cjs"),o=require("@chaibuilder/blocks"),m=require("./form-6eac0287.cjs"),d=require("./index-133d90a5.cjs");require("@radix-ui/react-scroll-area");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("@rjsf/core");require("@rjsf/validator-ajv8");require("lodash");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("@radix-ui/react-icons");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("./useBuilderProp-5e57d0c8.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-7d6aadbc.cjs");require("redux-undo");require("@react-hookz/web");require("./CONTROLS-031e1de3.cjs");function g(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const u=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(i,e,u.get?u:{enumerable:!0,get:()=>r[e]})}}return i.default=r,Object.freeze(i)}const j=g(a),b=({_projectData:r,seany:i})=>{const{data:e,isLoading:u}=d.useProject();j.useEffect(()=>{e&&i(e)},[e,i]);const c=({formData:l},t)=>{i(s=>({...s,[t]:l[t]}))},q={name:o.SingleLineText({title:"Project Name",default:e==null?void 0:e.name}),favicon:o.Image({title:"Favicon",default:e==null?void 0:e.favicon})};return n.jsxRuntimeExports.jsx(f.ScrollArea,{className:"flex h-full select-none flex-col",children:n.jsxRuntimeExports.jsx(m.Form,{properties:q,disabled:u,formData:r,onChange:c})})};exports.default=b;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { j as i } from "./jsx-runtime-944c88e2.js";
|
|
2
|
+
import * as n from "react";
|
|
3
|
+
import { S as f } from "./scroll-area-9f64a082.js";
|
|
4
|
+
import { SingleLineText as c, Image as d } from "@chaibuilder/blocks";
|
|
5
|
+
import { F as u } from "./form-5d5c5c9e.js";
|
|
6
|
+
import { O as x } from "./index-3f65447f.js";
|
|
7
|
+
import "@radix-ui/react-scroll-area";
|
|
8
|
+
import "./utils-ac68b2c8.js";
|
|
9
|
+
import "clsx";
|
|
10
|
+
import "tailwind-merge";
|
|
11
|
+
import "@rjsf/core";
|
|
12
|
+
import "@rjsf/validator-ajv8";
|
|
13
|
+
import "lodash";
|
|
14
|
+
import "./link-f80a947d.js";
|
|
15
|
+
import "react-icons-picker";
|
|
16
|
+
import "react-dom";
|
|
17
|
+
import "./dialog-3d4e82ed.js";
|
|
18
|
+
import "@radix-ui/react-dialog";
|
|
19
|
+
import "@radix-ui/react-icons";
|
|
20
|
+
import "./ImagesPanel-8ccab6d9.js";
|
|
21
|
+
import "./tabs-85caa1e8.js";
|
|
22
|
+
import "@radix-ui/react-tabs";
|
|
23
|
+
import "react-quill";
|
|
24
|
+
import "react-i18next";
|
|
25
|
+
import "./useBuilderProp-81a14920.js";
|
|
26
|
+
import "@radix-ui/react-slot";
|
|
27
|
+
import "class-variance-authority";
|
|
28
|
+
import "@radix-ui/react-tooltip";
|
|
29
|
+
import "@radix-ui/react-toast";
|
|
30
|
+
import "jotai";
|
|
31
|
+
import "i18next";
|
|
32
|
+
import "flagged";
|
|
33
|
+
import "react-dnd";
|
|
34
|
+
import "@minoru/react-dnd-treeview";
|
|
35
|
+
import "react-hotkeys-hook";
|
|
36
|
+
import "flat-to-nested";
|
|
37
|
+
import "./Class-e34b2337.js";
|
|
38
|
+
import "redux-undo";
|
|
39
|
+
import "@react-hookz/web";
|
|
40
|
+
import "./CONTROLS-442caee5.js";
|
|
41
|
+
const to = ({
|
|
42
|
+
_projectData: m,
|
|
43
|
+
seany: t
|
|
44
|
+
}) => {
|
|
45
|
+
const { data: o, isLoading: p } = x();
|
|
46
|
+
n.useEffect(() => {
|
|
47
|
+
o && t(o);
|
|
48
|
+
}, [o, t]);
|
|
49
|
+
const e = ({ formData: s }, r) => {
|
|
50
|
+
t((l) => ({
|
|
51
|
+
...l,
|
|
52
|
+
[r]: s[r]
|
|
53
|
+
}));
|
|
54
|
+
}, a = {
|
|
55
|
+
name: c({
|
|
56
|
+
title: "Project Name",
|
|
57
|
+
default: o == null ? void 0 : o.name
|
|
58
|
+
}),
|
|
59
|
+
favicon: d({ title: "Favicon", default: o == null ? void 0 : o.favicon })
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ i.jsx(f, { className: "flex h-full select-none flex-col", children: /* @__PURE__ */ i.jsx(u, { properties: a, disabled: p, formData: m, onChange: e }) });
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
to as default
|
|
65
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { j as p } from "./jsx-runtime-944c88e2.js";
|
|
2
|
+
import { Model as D, SingleLineText as c, MultilineText as g, Image as x } from "@chaibuilder/blocks";
|
|
3
|
+
import { F as v } from "./form-5d5c5c9e.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import "@rjsf/core";
|
|
6
|
+
import "@rjsf/validator-ajv8";
|
|
7
|
+
import "lodash";
|
|
8
|
+
import "./link-f80a947d.js";
|
|
9
|
+
import "react-icons-picker";
|
|
10
|
+
import "react-dom";
|
|
11
|
+
import "./dialog-3d4e82ed.js";
|
|
12
|
+
import "@radix-ui/react-dialog";
|
|
13
|
+
import "@radix-ui/react-icons";
|
|
14
|
+
import "./utils-ac68b2c8.js";
|
|
15
|
+
import "clsx";
|
|
16
|
+
import "tailwind-merge";
|
|
17
|
+
import "./ImagesPanel-8ccab6d9.js";
|
|
18
|
+
import "./tabs-85caa1e8.js";
|
|
19
|
+
import "@radix-ui/react-tabs";
|
|
20
|
+
import "react-quill";
|
|
21
|
+
import "react-i18next";
|
|
22
|
+
import "./useBuilderProp-81a14920.js";
|
|
23
|
+
import "@radix-ui/react-slot";
|
|
24
|
+
import "class-variance-authority";
|
|
25
|
+
import "@radix-ui/react-tooltip";
|
|
26
|
+
import "@radix-ui/react-toast";
|
|
27
|
+
import "jotai";
|
|
28
|
+
const V = ({
|
|
29
|
+
_projectData: t,
|
|
30
|
+
seany: l
|
|
31
|
+
}) => {
|
|
32
|
+
var e, o, m, r, a, s;
|
|
33
|
+
const n = ({ formData: f }) => {
|
|
34
|
+
const i = { ...f };
|
|
35
|
+
i.seoData.title === void 0 && (i.seoData.title = ""), i.seoData.description === void 0 && (i.seoData.description = ""), i.seoData.image === void 0 && (i.seoData.image = ""), l((u) => ({
|
|
36
|
+
...u,
|
|
37
|
+
...i
|
|
38
|
+
}));
|
|
39
|
+
}, d = {
|
|
40
|
+
seoData: D({
|
|
41
|
+
title: "",
|
|
42
|
+
default: {
|
|
43
|
+
title: ((e = t.seoData) == null ? void 0 : e.title) || "",
|
|
44
|
+
description: ((o = t.seoData) == null ? void 0 : o.description) || "",
|
|
45
|
+
image: ((m = t.seoData) == null ? void 0 : m.image) || ""
|
|
46
|
+
},
|
|
47
|
+
properties: {
|
|
48
|
+
title: c({
|
|
49
|
+
title: "Default Title",
|
|
50
|
+
default: ((r = t.seoData) == null ? void 0 : r.title) || ""
|
|
51
|
+
}),
|
|
52
|
+
description: g({
|
|
53
|
+
title: "Default Description",
|
|
54
|
+
default: ((a = t.seoData) == null ? void 0 : a.description) || ""
|
|
55
|
+
}),
|
|
56
|
+
image: x({
|
|
57
|
+
title: "Social Media Image",
|
|
58
|
+
default: ((s = t.seoData) == null ? void 0 : s.image) || ""
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ p.jsx("div", { className: "flex h-full select-none flex-col", children: /* @__PURE__ */ p.jsx(v, { properties: d, formData: t, onChange: n }) });
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
V as default
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-5c3ac4f7.cjs"),r=require("@chaibuilder/blocks"),g=require("./form-6eac0287.cjs");require("react");require("@rjsf/core");require("@rjsf/validator-ajv8");require("lodash");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("@radix-ui/react-icons");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("./useBuilderProp-5e57d0c8.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");const D=({_projectData:e,seany:q})=>{var t,o,u,s,a,l;const d=({formData:c})=>{const i={...c};i.seoData.title===void 0&&(i.seoData.title=""),i.seoData.description===void 0&&(i.seoData.description=""),i.seoData.image===void 0&&(i.seoData.image=""),q(f=>({...f,...i}))},m={seoData:r.Model({title:"",default:{title:((t=e.seoData)==null?void 0:t.title)||"",description:((o=e.seoData)==null?void 0:o.description)||"",image:((u=e.seoData)==null?void 0:u.image)||""},properties:{title:r.SingleLineText({title:"Default Title",default:((s=e.seoData)==null?void 0:s.title)||""}),description:r.MultilineText({title:"Default Description",default:((a=e.seoData)==null?void 0:a.description)||""}),image:r.Image({title:"Social Media Image",default:((l=e.seoData)==null?void 0:l.image)||""})}})};return n.jsxRuntimeExports.jsx("div",{className:"flex h-full select-none flex-col",children:n.jsxRuntimeExports.jsx(g.Form,{properties:m,formData:e,onChange:d})})};exports.default=D;
|
package/dist/server.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var u=(o,t,e)=>t in o?d(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var c=(o,t,e)=>(u(o,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("lodash"),i="https://api.chaibuilder.com";class g{constructor(t,e){c(this,"authToken");c(this,"projectKey");if(!t)throw"Please provide valid auth token.";if(!e)throw"Please provide valid project key.";this.authToken=t,this.projectKey=e}async getPage(t){if(!t)return Promise.reject({data:null,error:{message:"Invalid page uuid"},result:"error"});const e=this.getHeaders(),s=this.getURL("page",{uuid:t}),n={method:"GET",headers:e};return this.fetchAPI(s,n)}async getPages(){const t=this.getHeaders(),e=this.getURL("pages"),r={method:"GET",headers:t};return this.fetchAPI(e,r)}async addPage(t){h.set(t,"project",this.projectKey);const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("page"),a={method:"POST",headers:s,body:e};return this.fetchAPI(r,a)}async deletePage(t){if(!t)return Promise.reject({data:null,error:{message:"Invalid page uuid"},result:"error"});const e=this.getHeaders(),s=this.getURL("page",{uuid:t}),n={method:"DELETE",headers:e};return this.fetchAPI(s,n)}async updatePage(t){const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("page"),a={method:"PUT",headers:s,body:e};return this.fetchAPI(r,a)}async getProject(){const t=this.getHeaders(),e=this.getURL("project"),r={method:"GET",headers:t};return this.fetchAPI(e,r)}async updateProject(t){t.uuid=this.projectKey,h.set(t,"uuid",this.projectKey);const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("project"),a={method:"PUT",headers:s,body:e};return this.fetchAPI(r,a)}getURL(t,e){const s=new URLSearchParams(e).toString();return h.isEmpty(e)?`${i}/v1/${t}`:`${i}/v1/${t}?${s}`}getHeaders(){const t=new Headers;return t.append("x-chai-app-key",this.projectKey),t.append("x-chai-auth-token",this.authToken),t.append("Content-Type","application/json"),t}async fetchAPI(t,e){try{const s=await fetch(t,e).then(r=>r.json());if((s==null?void 0:s.result)==="success")return{data:s==null?void 0:s.data,error:null,result:"success"};throw s==null?void 0:s.error}catch(s){return{data:null,error:s,result:"error"}}}}exports.ChaibuilderBackend=g;
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ChaiBlock } from '@chaibuilder/sdk';
|
|
2
|
+
|
|
3
|
+
export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
4
|
+
private authToken;
|
|
5
|
+
private readonly projectKey;
|
|
6
|
+
constructor(authToken: string, projectKey: string);
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param uuid
|
|
10
|
+
* @returns Detail Single Page Information
|
|
11
|
+
*/
|
|
12
|
+
getPage(uuid: string): Promise<{
|
|
13
|
+
data: ChaiPage & {
|
|
14
|
+
subPages: ChaiSubPage[];
|
|
15
|
+
};
|
|
16
|
+
error: null;
|
|
17
|
+
result: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @returns List of all pages
|
|
22
|
+
*/
|
|
23
|
+
getPages(): Promise<{
|
|
24
|
+
data: ChaiPage & {
|
|
25
|
+
subPages: ChaiSubPage[];
|
|
26
|
+
}[];
|
|
27
|
+
error: null;
|
|
28
|
+
result: string;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param page
|
|
33
|
+
* @returns Detail of new page
|
|
34
|
+
*/
|
|
35
|
+
addPage(page: Pick<ChaiPage, "name" | "slug">): Promise<{
|
|
36
|
+
data: ChaiPage;
|
|
37
|
+
error: null;
|
|
38
|
+
result: string;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param uuid
|
|
43
|
+
* @returns Success | Error Message
|
|
44
|
+
*/
|
|
45
|
+
deletePage(uuid: string): Promise<{
|
|
46
|
+
data: null;
|
|
47
|
+
error: null;
|
|
48
|
+
result: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param page
|
|
53
|
+
* @returns Update page information or Error response
|
|
54
|
+
*/
|
|
55
|
+
updatePage(page: ChaiPage): Promise<{
|
|
56
|
+
data: ChaiPage;
|
|
57
|
+
error: null;
|
|
58
|
+
result: string;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @returns Project detail
|
|
63
|
+
*/
|
|
64
|
+
getProject(): Promise<{
|
|
65
|
+
data: ChaiProject;
|
|
66
|
+
error: null;
|
|
67
|
+
result: string;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param project
|
|
72
|
+
* @returns Updated project detail
|
|
73
|
+
*/
|
|
74
|
+
updateProject(project: Partial<ChaiProject>): Promise<{
|
|
75
|
+
data: ChaiProject;
|
|
76
|
+
error: null;
|
|
77
|
+
result: string;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param endpoint
|
|
82
|
+
* @param queryParam
|
|
83
|
+
* @returns api endpoint with query param
|
|
84
|
+
*/
|
|
85
|
+
private getURL;
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @returns headers for api
|
|
89
|
+
*/
|
|
90
|
+
private getHeaders;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @returns Fetch API
|
|
94
|
+
*/
|
|
95
|
+
private fetchAPI;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export declare interface ChaibuilderBackendInterface {
|
|
99
|
+
getPage(uuid: string): TChaiResponse<ChaiPage & {
|
|
100
|
+
subPages: ChaiSubPage[];
|
|
101
|
+
}>;
|
|
102
|
+
getPages(): TChaiResponse<ChaiPage>;
|
|
103
|
+
addPage(page: Pick<ChaiPage, "name" | "slug">): TChaiResponse<ChaiPage>;
|
|
104
|
+
deletePage(uuid: string): TChaiResponse<null>;
|
|
105
|
+
updatePage(page: ChaiPage): TChaiResponse<ChaiPage>;
|
|
106
|
+
getProject(): TChaiResponse<ChaiProject>;
|
|
107
|
+
updateProject(project: Partial<ChaiProject>): TChaiResponse<ChaiProject>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare type ChaiPage = {
|
|
111
|
+
uuid: string;
|
|
112
|
+
name: string;
|
|
113
|
+
slug: string;
|
|
114
|
+
blocks: ChaiBlock[];
|
|
115
|
+
seoData: object;
|
|
116
|
+
type: "STATIC" | "DYNAMIC" | "SUBPAGE";
|
|
117
|
+
project: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
declare type ChaiProject = {
|
|
121
|
+
uuid: string;
|
|
122
|
+
brandingOptions: Record<string, string | number>;
|
|
123
|
+
favicon: string;
|
|
124
|
+
homepage: string;
|
|
125
|
+
name: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
seoData: object;
|
|
128
|
+
primaryLanguage?: string;
|
|
129
|
+
password?: string;
|
|
130
|
+
languages?: Array<string>;
|
|
131
|
+
user?: string;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
declare type ChaiSubPage = Pick<ChaiPage, "uuid" | "name" | "blocks" | "type" | "project">;
|
|
135
|
+
|
|
136
|
+
declare type TChaiResponse<T> = Promise<{
|
|
137
|
+
data: T;
|
|
138
|
+
error: null;
|
|
139
|
+
result: string;
|
|
140
|
+
}>;
|
|
141
|
+
|
|
142
|
+
export { }
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var u = (o, t, e) => t in o ? d(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var a = (o, t, e) => (u(o, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { set as h, isEmpty as g } from "lodash";
|
|
5
|
+
const i = "https://api.chaibuilder.com";
|
|
6
|
+
class y {
|
|
7
|
+
constructor(t, e) {
|
|
8
|
+
a(this, "authToken");
|
|
9
|
+
a(this, "projectKey");
|
|
10
|
+
if (!t)
|
|
11
|
+
throw "Please provide valid auth token.";
|
|
12
|
+
if (!e)
|
|
13
|
+
throw "Please provide valid project key.";
|
|
14
|
+
this.authToken = t, this.projectKey = e;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param uuid
|
|
19
|
+
* @returns Detail Single Page Information
|
|
20
|
+
*/
|
|
21
|
+
async getPage(t) {
|
|
22
|
+
if (!t)
|
|
23
|
+
return Promise.reject({
|
|
24
|
+
data: null,
|
|
25
|
+
error: { message: "Invalid page uuid" },
|
|
26
|
+
result: "error"
|
|
27
|
+
});
|
|
28
|
+
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), n = { method: "GET", headers: e };
|
|
29
|
+
return this.fetchAPI(s, n);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @returns List of all pages
|
|
34
|
+
*/
|
|
35
|
+
async getPages() {
|
|
36
|
+
const t = this.getHeaders(), e = this.getURL("pages"), r = { method: "GET", headers: t };
|
|
37
|
+
return this.fetchAPI(e, r);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param page
|
|
42
|
+
* @returns Detail of new page
|
|
43
|
+
*/
|
|
44
|
+
async addPage(t) {
|
|
45
|
+
h(t, "project", this.projectKey);
|
|
46
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("page"), c = { method: "POST", headers: s, body: e };
|
|
47
|
+
return this.fetchAPI(r, c);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param uuid
|
|
52
|
+
* @returns Success | Error Message
|
|
53
|
+
*/
|
|
54
|
+
async deletePage(t) {
|
|
55
|
+
if (!t)
|
|
56
|
+
return Promise.reject({
|
|
57
|
+
data: null,
|
|
58
|
+
error: { message: "Invalid page uuid" },
|
|
59
|
+
result: "error"
|
|
60
|
+
});
|
|
61
|
+
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), n = { method: "DELETE", headers: e };
|
|
62
|
+
return this.fetchAPI(s, n);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param page
|
|
67
|
+
* @returns Update page information or Error response
|
|
68
|
+
*/
|
|
69
|
+
async updatePage(t) {
|
|
70
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("page"), c = { method: "PUT", headers: s, body: e };
|
|
71
|
+
return this.fetchAPI(r, c);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @returns Project detail
|
|
76
|
+
*/
|
|
77
|
+
async getProject() {
|
|
78
|
+
const t = this.getHeaders(), e = this.getURL("project"), r = { method: "GET", headers: t };
|
|
79
|
+
return this.fetchAPI(e, r);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param project
|
|
84
|
+
* @returns Updated project detail
|
|
85
|
+
*/
|
|
86
|
+
async updateProject(t) {
|
|
87
|
+
t.uuid = this.projectKey, h(t, "uuid", this.projectKey);
|
|
88
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("project"), c = { method: "PUT", headers: s, body: e };
|
|
89
|
+
return this.fetchAPI(r, c);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param endpoint
|
|
94
|
+
* @param queryParam
|
|
95
|
+
* @returns api endpoint with query param
|
|
96
|
+
*/
|
|
97
|
+
getURL(t, e) {
|
|
98
|
+
const s = new URLSearchParams(e).toString();
|
|
99
|
+
return g(e) ? `${i}/v1/${t}` : `${i}/v1/${t}?${s}`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @returns headers for api
|
|
104
|
+
*/
|
|
105
|
+
getHeaders() {
|
|
106
|
+
const t = new Headers();
|
|
107
|
+
return t.append("x-chai-app-key", this.projectKey), t.append("x-chai-auth-token", this.authToken), t.append("Content-Type", "application/json"), t;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* @returns Fetch API
|
|
112
|
+
*/
|
|
113
|
+
async fetchAPI(t, e) {
|
|
114
|
+
try {
|
|
115
|
+
const s = await fetch(t, e).then((r) => r.json());
|
|
116
|
+
if ((s == null ? void 0 : s.result) === "success")
|
|
117
|
+
return { data: s == null ? void 0 : s.data, error: null, result: "success" };
|
|
118
|
+
throw s == null ? void 0 : s.error;
|
|
119
|
+
} catch (s) {
|
|
120
|
+
return { data: null, error: s, result: "error" };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
y as ChaibuilderBackend
|
|
126
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-5c3ac4f7.cjs"),q=require("react"),c=require("lodash"),H=require("@radix-ui/react-icons"),w=require("./useBuilderProp-5e57d0c8.cjs"),L=require("./scroll-area-088530b9.cjs"),d=require("@chaibuilder/blocks"),z=require("sonner"),p=require("./form-6eac0287.cjs"),N=require("./index-133d90a5.cjs"),b=require("./useProjectActions-41af0f70.cjs");require("@radix-ui/react-slot");require("class-variance-authority");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("@radix-ui/react-scroll-area");require("@rjsf/core");require("@rjsf/validator-ajv8");require("./link-86c532b5.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("./ImagesPanel-addb2bf9.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./Class-7d6aadbc.cjs");require("redux-undo");require("@react-hookz/web");require("./CONTROLS-031e1de3.cjs");require("./useMutation-7d536740.cjs");const _=q.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-420a17e3.cjs"))),B=q.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-4f50caa7.cjs"))),h=n=>{if(!c.isString(n)||!(n.includes("/[")&&n.includes("]")))return!1;const i=/^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/,g=/^[a-zA-Z0-9_-]+$/;let e=!0;return n.split("/").forEach(u=>{e&&(u.includes("[[")&&u.includes("]]")?e=/^\[\[\.{3}[a-zA-Z0-9_-]+\]\]$/.test(u):u.includes("[")&&u.includes("]")?e=i.test(u):e=g.test(u))}),e},P=n=>n&&c.isEmpty(n.seoData)?{...n,seoData:{title:"",description:"",image:""}}:n,G=(n,o)=>{const i=!c.isEqual(c.omit(n,["seoData"]),c.omit(o,["seoData"])),g=!c.isEqual(P(o).seoData,P(n).seoData);return i||g},Y=({open:n,setOpen:o,pageData:i})=>{const g=N.useQueryClient(),{data:e}=N.useProject(),u=b.useUpdateProject(),m=b.useUpdateProject("Homepage updated successfully."),[s,y]=q.useState(P(i)),[a,A]=q.useState({isHomePage:(e==null?void 0:e.homepage)===i.uuid}),E=G(s,i);q.useEffect(()=>{const l=!c.isEqual(P(i),s),r=(e==null?void 0:e.homepage)!==i.uuid&&a.isHomePage;o(l||r?"PENDING":"OPEN")},[e,i,s,a,o]);const j=()=>{if(E){if(i.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||"")){n==="ALERT"&&o("PENDING");return}u.mutate(s,{onSuccess:()=>{g.invalidateQueries({refetchType:"active",queryKey:["pages",e==null?void 0:e.uuid]}),o("CLOSE"),z.toast.success("Page updated successfully.")}})}a.isHomePage&&(e==null?void 0:e.homepage)!==i.uuid&&m.mutate({...e,homepage:i==null?void 0:i.uuid},{onSuccess:()=>o("CLOSE")})},S=({formData:l},r)=>{y(f=>{var C,R;if(!r)return f;const x={[r]:l[r]};return r==="page_name"?x.slug=c.kebabCase((C=l[r])==null?void 0:C.replace(/\d/g,"")):r==="slug"?x.slug=(R=l[r])==null?void 0:R.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):r==="seo_data"&&(x.seo_data={title:l[r].title||"",description:l[r].description||"",image:l[r].image||""}),{...f,...x}})},I=({formData:l},r)=>{A(f=>{const x={[r]:l[r]};return{...f,...x}})},T={page_name:d.SingleLineText({title:"Page Name",default:s.name}),slug:d.SingleLineText({title:"Page Slug",default:s.slug})},v={seo_data:d.Model({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.SingleLineText({title:"Meta Title",default:s.name}),description:d.MultilineText({title:"Meta Description",default:s.slug}),image:d.Image({title:"Social Media Image",default:""})}})},M={isHomePage:d.Checkbox({title:"Set as homepage",default:a.isHomePage})};return t.jsxRuntimeExports.jsxs(L.ScrollArea,{className:"flex h-full select-none flex-col",children:[t.jsxRuntimeExports.jsx(B,{open:n==="ALERT",title:"Do yo want to save changes?",onCancel:()=>o("CLOSE"),onConfirm:j,disabled:m.isPending||u.isPending}),t.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 px-2.5 py-1",children:t.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:"Page Details"})}),t.jsxRuntimeExports.jsx("div",{className:"px-2.5 pt-2",children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-2",children:[t.jsxRuntimeExports.jsx(p.Form,{title:"Basic Details",formData:s,properties:T,onChange:S,disabled:u.isPending||m.isPending}),t.jsxRuntimeExports.jsx("div",{className:"h-2 w-full"}),t.jsxRuntimeExports.jsx(p.Form,{title:"SEO Details",formData:s,properties:v,onChange:S,disabled:u.isPending||m.isPending}),(e==null?void 0:e.homepage)!==i.uuid&&i.type==="STATIC"?t.jsxRuntimeExports.jsx(p.Form,{formData:a,properties:M,onChange:I,disabled:u.isPending||m.isPending}):i.type==="STATIC"&&t.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1 px-1 pt-2 text-xs font-medium text-gray-500",children:[t.jsxRuntimeExports.jsx(H.HomeIcon,{})," This is homepage"," "]}),s.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||"")&&t.jsxRuntimeExports.jsxs("small",{className:"px-1 text-red-400",children:["Add dynamic ID in page slug Eg: ",t.jsxRuntimeExports.jsx("i",{className:"underline",children:"some-url/[some-id]"})]}),t.jsxRuntimeExports.jsxs("div",{className:"my-2 flex w-full items-center justify-between gap-x-2 px-1",children:[t.jsxRuntimeExports.jsx(w.Button,{className:"w-full",type:"submit",onClick:j,disabled:(e==null?void 0:e.homepage)!==i.uuid&&a.isHomePage?!1:c.isEmpty(s.name)||c.isEmpty(s.slug)||!E||u.isPending||m.isPending||s.type==="DYNAMIC"&&!h((s==null?void 0:s.slug)||""),children:"Save"}),t.jsxRuntimeExports.jsx(_,{pageData:i,projectData:e})]})]})})]})};exports.default=Y;
|