@chaibuilder/sdk 1.0.0 → 1.0.2
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-4f054351.cjs → AddBlocks-3a7649d5.cjs} +1 -1
- package/dist/{AddBlocks-f6836e71.js → AddBlocks-c5c0dd03.js} +1 -1
- package/dist/{BrandingOptions-cfa79ffe.cjs → BrandingOptions-56d81bc2.cjs} +1 -1
- package/dist/{BrandingOptions-33e6da26.js → BrandingOptions-e677cf11.js} +1 -1
- package/dist/{CanvasArea-1e5fa968.js → CanvasArea-14ae34d6.js} +2 -2
- package/dist/{CanvasArea-971b3ff8.cjs → CanvasArea-a17fc7da.cjs} +2 -2
- package/dist/{CurrentPage-b2d12d83.cjs → CurrentPage-68a7b712.cjs} +1 -1
- package/dist/{CurrentPage-223cc3dd.js → CurrentPage-8eb614ef.js} +1 -1
- package/dist/{Layers-b2c5aa66.js → Layers-cf39ffab.js} +2 -2
- package/dist/{Layers-860f5e42.cjs → Layers-e2b02b28.cjs} +1 -1
- package/dist/{MarkAsGlobalBlock-9b0135aa.js → MarkAsGlobalBlock-ea250b6d.js} +1 -1
- package/dist/{MarkAsGlobalBlock-1a3d5e53.cjs → MarkAsGlobalBlock-f2d5500b.cjs} +1 -1
- package/dist/{PagesPanel-034efd4c.js → PagesPanel-15bee60b.js} +2 -2
- package/dist/{PagesPanel-2a80f9b2.cjs → PagesPanel-5bf8b29e.cjs} +1 -1
- package/dist/{ProjectPanel-5deae7f1.cjs → ProjectPanel-b6938da6.cjs} +1 -1
- package/dist/{ProjectPanel-3827a349.js → ProjectPanel-ec1cc852.js} +2 -2
- package/dist/{Settings-9f61cc69.cjs → Settings-16e1b3fb.cjs} +1 -1
- package/dist/{Settings-a2d4e9c2.js → Settings-6eee46a7.js} +1 -1
- package/dist/{SidePanels-0d276d29.cjs → SidePanels-6c1f280e.cjs} +1 -1
- package/dist/{SidePanels-b881185b.js → SidePanels-84877501.js} +2 -2
- package/dist/{Topbar-fda7588e.js → Topbar-9daf50f4.js} +1 -1
- package/dist/{Topbar-68a0d125.cjs → Topbar-de650052.cjs} +1 -1
- package/dist/{add-page-modal-38af4548.js → add-page-modal-211a170b.js} +1 -1
- package/dist/{add-page-modal-fb51b45b.cjs → add-page-modal-f687df67.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{delete-page-modal-305c49fd.cjs → delete-page-modal-446def2d.cjs} +1 -1
- package/dist/{delete-page-modal-a226ed3a.js → delete-page-modal-6e2504f3.js} +1 -1
- package/dist/{index-6fc652ec.cjs → index-a651f2ae.cjs} +2 -2
- package/dist/{index-914d197c.js → index-b13e230b.js} +3 -3
- package/dist/{page-viewer-857a82f4.cjs → page-viewer-5dd1916c.cjs} +1 -1
- package/dist/{page-viewer-682940be.js → page-viewer-ade30c07.js} +2 -2
- package/dist/{project-general-setting-0fa55bb9.js → project-general-setting-104ce380.js} +1 -1
- package/dist/{project-general-setting-280ccd16.cjs → project-general-setting-fa25fad1.cjs} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +61 -14
- package/dist/server.js +74 -46
- package/dist/{single-page-detail-8b715650.js → single-page-detail-be6c051e.js} +2 -2
- package/dist/{single-page-detail-b9c4ac1e.cjs → single-page-detail-d7e76b74.cjs} +1 -1
- package/package.json +1 -1
|
@@ -27491,7 +27491,7 @@ const VZ = () => {
|
|
|
27491
27491
|
const a = hr(e);
|
|
27492
27492
|
kd(a) && (n = [a, ...NL(t, a)]), r(n);
|
|
27493
27493
|
}, [e, t, r]);
|
|
27494
|
-
}, fU = () => Ge(mA), TL = Vn(() => import("./SidePanels-
|
|
27494
|
+
}, fU = () => Ge(mA), TL = Vn(() => import("./SidePanels-84877501.js")), jL = Vn(() => import("./Topbar-9daf50f4.js")), zL = Vn(() => import("./CanvasArea-14ae34d6.js")), FL = Vn(() => import("./Settings-6eee46a7.js")), qL = () => {
|
|
27495
27495
|
const [e] = Ne(kc), t = (a) => {
|
|
27496
27496
|
a.preventDefault();
|
|
27497
27497
|
};
|
|
@@ -28749,7 +28749,7 @@ function MW() {
|
|
|
28749
28749
|
};
|
|
28750
28750
|
return SW(dm(dm({}, t), e));
|
|
28751
28751
|
}
|
|
28752
|
-
const TW = "@chaibuilder/sdk", jW = "1.0.
|
|
28752
|
+
const TW = "@chaibuilder/sdk", jW = "1.0.2", zW = "module", FW = [
|
|
28753
28753
|
"dist"
|
|
28754
28754
|
], qW = "dist/core.js", DW = !1, BW = {
|
|
28755
28755
|
".": {
|
|
@@ -30962,7 +30962,7 @@ const Rr = {
|
|
|
30962
30962
|
] })
|
|
30963
30963
|
] })
|
|
30964
30964
|
] });
|
|
30965
|
-
}, UK = () => /* @__PURE__ */ _.jsx(ZK, { children: /* @__PURE__ */ _.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ _.jsx(JE, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), JK = UK, GK = Vn(() => import("./PagesPanel-
|
|
30965
|
+
}, UK = () => /* @__PURE__ */ _.jsx(ZK, { children: /* @__PURE__ */ _.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ _.jsx(JE, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), JK = UK, GK = Vn(() => import("./PagesPanel-15bee60b.js")), YK = Vn(() => import("./ProjectPanel-ec1cc852.js")), HK = Vn(() => import("./CurrentPage-8eb614ef.js")), QK = () => /* @__PURE__ */ _.jsx("h2", { children: "Your Logo" }), XK = () => {
|
|
30966
30966
|
const { mutate: e } = zK();
|
|
30967
30967
|
return Cr("editable", !0) ? /* @__PURE__ */ _.jsx(xd, { onClick: e, className: "bg-blue-600 text-white", children: "Publish" }) : null;
|
|
30968
30968
|
}, _K = (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),n=require("react"),u=require("@radix-ui/react-icons"),o=require("./popover-7cb9079b.cjs"),x=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),n=require("react"),u=require("@radix-ui/react-icons"),o=require("./popover-7cb9079b.cjs"),x=require("./index-a651f2ae.cjs");require("@radix-ui/react-popover");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("./MODIFIERS-4716c669.cjs");require("@radix-ui/react-scroll-area");require("react-dom");require("@floating-ui/react-dom");require("jotai");require("i18next");require("react-i18next");require("flagged");require("react-dnd");require("lodash");require("@minoru/react-dnd-treeview");require("./useBuilderProp-adacf42f.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("react-hotkeys-hook");require("flat-to-nested");require("./html-to-json-aadcbf66.cjs");require("himalaya");require("redux-undo");require("@react-hookz/web");require("@chaibuilder/blocks");require("sonner");require("lucide-react");const m=n.lazy(()=>Promise.resolve().then(()=>require("./single-page-detail-d7e76b74.cjs"))),j=({pageData:s})=>{const[r,t]=n.useState("CLOSE");return e.jsxRuntimeExports.jsxs(o.Popover,{open:r==="OPEN"||r==="ALERT"||r==="PENDING",onOpenChange:i=>{t(r==="PENDING"?"ALERT":i?"OPEN":"CLOSE")},children:[e.jsxRuntimeExports.jsx(o.PopoverTrigger,{asChild:!0,onClick:i=>{i.stopPropagation(),t("OPEN")},children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:r==="OPEN"||r==="ALERT"||r==="PENDING"?e.jsxRuntimeExports.jsx(u.ChevronRightIcon,{}):e.jsxRuntimeExports.jsx("div",{className:"hidden hover:text-blue-600 group-hover:flex",children:e.jsxRuntimeExports.jsx(u.GearIcon,{})})})}),e.jsxRuntimeExports.jsx(o.PopoverContent,{side:"right",align:"start",alignOffset:-35,className:"h-screen w-96",children:e.jsxRuntimeExports.jsx(n.Suspense,{fallback:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full animate-pulse flex-col gap-y-3",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-6 w-1/2"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-300 h-20 w-full"})]}),children:e.jsxRuntimeExports.jsx(m,{pageData:s,open:r,setOpen:t})})})]})},p=s=>{const[r]=x.useCurrentPage(),{data:t}=x.useProject(),i=x.useChangePage(),l=(t==null?void 0:t.homepage)===s.uuid,a=r===s.uuid,c=()=>i(s);return t?e.jsxRuntimeExports.jsxs("button",{className:`group relative flex w-full cursor-pointer items-center justify-between px-2.5 py-2 ${a?"bg-blue-200 ":""}`,onClick:c,type:"button",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex text-sm items-center gap-x-1.5",children:[l?e.jsxRuntimeExports.jsx(u.HomeIcon,{}):e.jsxRuntimeExports.jsx(u.FileTextIcon,{})," ",s.name]}),e.jsxRuntimeExports.jsx(j,{pageData:s})]}):null},d=({pages:s,isLoading:r})=>r?e.jsxRuntimeExports.jsxs("div",{className:"flex animate-pulse flex-col gap-y-1 px-2.5 pt-2",children:[e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"}),e.jsxRuntimeExports.jsx("div",{className:"bg-background-200 h-7 w-full"})]}):s.length===0?e.jsxRuntimeExports.jsx("div",{className:"px-2.5 pb-2 pt-4",children:"No pages"}):e.jsxRuntimeExports.jsx("div",{className:"-mb-2",children:n.Children.toArray(s.map(t=>e.jsxRuntimeExports.jsx(p,{...t})))});exports.default=d;
|
|
@@ -2,7 +2,7 @@ import { j as e } from "./jsx-runtime-944c88e2.js";
|
|
|
2
2
|
import o, { useState as m, Suspense as c } from "react";
|
|
3
3
|
import { HomeIcon as p, FileTextIcon as u, ChevronRightIcon as d, GearIcon as x } from "@radix-ui/react-icons";
|
|
4
4
|
import { P as g, a as h, b as f } from "./popover-f7addcf4.js";
|
|
5
|
-
import { U as j, R as N, T as b } from "./index-
|
|
5
|
+
import { U as j, R as N, T as b } from "./index-b13e230b.js";
|
|
6
6
|
import "@radix-ui/react-popover";
|
|
7
7
|
import "./utils-ac68b2c8.js";
|
|
8
8
|
import "clsx";
|
|
@@ -33,7 +33,7 @@ import "@react-hookz/web";
|
|
|
33
33
|
import "@chaibuilder/blocks";
|
|
34
34
|
import "sonner";
|
|
35
35
|
import "lucide-react";
|
|
36
|
-
const P = o.lazy(() => import("./single-page-detail-
|
|
36
|
+
const P = o.lazy(() => import("./single-page-detail-be6c051e.js")), v = ({ pageData: s }) => {
|
|
37
37
|
const [t, r] = m("CLOSE");
|
|
38
38
|
return /* @__PURE__ */ e.jsxs(
|
|
39
39
|
g,
|
|
@@ -3,7 +3,7 @@ import * as n from "react";
|
|
|
3
3
|
import { S as f } from "./scroll-area-83bd9e8f.js";
|
|
4
4
|
import { SingleLineText as c, Image as d } from "@chaibuilder/blocks";
|
|
5
5
|
import { F as u } from "./form-25e1af37.js";
|
|
6
|
-
import { R as x } from "./index-
|
|
6
|
+
import { R as x } from "./index-b13e230b.js";
|
|
7
7
|
import "@radix-ui/react-scroll-area";
|
|
8
8
|
import "./utils-ac68b2c8.js";
|
|
9
9
|
import "clsx";
|
|
@@ -1 +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-bb343b86.cjs"),o=require("@chaibuilder/blocks"),m=require("./form-ea21db6c.cjs"),d=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./jsx-runtime-5c3ac4f7.cjs"),a=require("react"),f=require("./scroll-area-bb343b86.cjs"),o=require("@chaibuilder/blocks"),m=require("./form-ea21db6c.cjs"),d=require("./index-a651f2ae.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-24679521.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("@radix-ui/react-icons");require("./ImagesPanel-8b7a989d.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("./useBuilderProp-adacf42f.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("jotai");require("./MODIFIERS-4716c669.cjs");require("@floating-ui/react-dom");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./html-to-json-aadcbf66.cjs");require("himalaya");require("redux-undo");require("@react-hookz/web");require("sonner");require("lucide-react");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 q=({formData:l},t)=>{i(s=>({...s,[t]:l[t]}))},c={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:c,disabled:u,formData:r,onChange:q})})};exports.default=b;
|
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var g=(
|
|
1
|
+
"use strict";var u=Object.defineProperty;var g=(a,t,e)=>t in a?u(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var h=(a,t,e)=>(g(a,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("lodash"),l=require("@chaibuilder/blocks"),d="https://api.chaibuilder.com";class p{constructor(t,e){h(this,"_authSecret");h(this,"_accessToken",null);h(this,"_appKey");if(!t)throw"Please provide valid auth secret.";if(!e)throw"Please provide valid project key.";this._authSecret=t,this._appKey=e}setAccessToken(t){this._accessToken=t}async getPageData(t){const e=this.getHeaders(),s=this.getURL("page-data",i.isEmpty(t)?{}:{slug:t}),o={method:"GET",headers:e,next:{tags:["everything",i.isEmpty(t)?"_homepage":t]}};return this.fetchAPI(s,o)}async unlockPage(t){if(!t)return Promise.reject({data:null,error:{message:"Invalid page uuid"},result:"error"});const e=this.getHeaders(),s=this.getURL("page/unlock"),o={method:"POST",headers:e,body:JSON.stringify({uuid:t})};return this.fetchAPI(s,o)}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}),o={method:"GET",headers:e};return this.fetchAPI(s,o)}async getPages(){const t=this.getHeaders(),e=this.getURL("pages"),r={method:"GET",headers:t};return this.fetchAPI(e,r)}async addPage(t){const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("page"),n={method:"POST",headers:s,body:e};return this.fetchAPI(r,n)}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}),o={method:"DELETE",headers:e};return this.fetchAPI(s,o)}async updatePage(t){const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("page"),n={method:"PUT",headers:s,body:e};return this.fetchAPI(r,n)}async getProject(){const t=this.getHeaders(),e=this.getURL("project"),r={method:"GET",headers:t};return this.fetchAPI(e,r)}async updateProject(t){const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("project"),n={method:"PUT",headers:s,body:e};return this.fetchAPI(r,n)}async uploadAsset(t){const e=this.getHeaders(),s=this.getURL("asset"),r="POST",o=await t.get("file"),n=new FormData;n.append("file",o);const c={method:r,headers:e,body:n};return this.fetchAPI(s,c)}async getAssets(t,e){const s=this.getHeaders(),r=this.getURL("asset");t&&r.concat(`?limit=${t}`),e&&r.concat(`&offset=${e}`);const n={method:"GET",headers:s};return this.fetchAPI(r,n)}async authenticate({password:t}){const e=JSON.stringify({password:t}),s=this.getHeaders(),r=this.getURL("authenticate"),n={method:"POST",headers:s,body:e};return this.fetchAPI(r,n)}async login({password:t,email:e}){const s=JSON.stringify({password:t,email:e}),r=this.getHeaders(),o=this.getURL("login"),c={method:"POST",headers:r,body:s};return this.fetchAPI(o,c)}async logout(){const t=this.getHeaders(),e=this.getURL("logout"),r={method:"POST",headers:t};return this.fetchAPI(e,r)}async verify(t){const e=JSON.stringify({token:t}),s=this.getHeaders(),r=this.getURL("verify"),n={method:"POST",headers:s,body:e};return this.fetchAPI(r,n)}getURL(t,e){const s=new URLSearchParams(e).toString();return i.isEmpty(e)?`${d}/v1/${t}`:`${d}/v1/${t}?${s}`}getHeaders(){const t=new Headers;return t.append("x-chai-app-key",this._appKey),t.append("x-chai-auth-secret",this._authSecret),this._accessToken&&t.append("x-chai-access-token",this._accessToken),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"}}}}const y=async(a,t)=>{const e=l.getChaiDataProviders(),s=i.filter(e,n=>i.map(a,"providerKey").includes(n.providerKey)),r={},o=[];for(const n of s)try{r[n.providerKey]=await n.dataFn({},t)}catch(c){o.push(c)}return{data:r,errors:o}};exports.ChaibuilderBackend=p;exports.prepareExternalData=y;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare type ChaiApiResponse<T> = Promise<{
|
|
2
2
|
data: T;
|
|
3
3
|
error: null;
|
|
4
|
-
result:
|
|
4
|
+
result: "success" | "error";
|
|
5
5
|
}>;
|
|
6
6
|
|
|
7
7
|
declare type ChaiAsset = {
|
|
@@ -27,7 +27,12 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
27
27
|
getPageData(slug: string): Promise<{
|
|
28
28
|
data: ChaiPageData;
|
|
29
29
|
error: null;
|
|
30
|
-
result:
|
|
30
|
+
result: "success" | "error";
|
|
31
|
+
}>;
|
|
32
|
+
unlockPage(uuid: string): Promise<{
|
|
33
|
+
data: any;
|
|
34
|
+
error: null;
|
|
35
|
+
result: "success" | "error";
|
|
31
36
|
}>;
|
|
32
37
|
/**
|
|
33
38
|
*
|
|
@@ -39,7 +44,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
39
44
|
subPages: ChaiSubPage[];
|
|
40
45
|
};
|
|
41
46
|
error: null;
|
|
42
|
-
result:
|
|
47
|
+
result: "success" | "error";
|
|
43
48
|
}>;
|
|
44
49
|
/**
|
|
45
50
|
*
|
|
@@ -48,7 +53,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
48
53
|
getPages(): Promise<{
|
|
49
54
|
data: Omit<ChaiPage, "blocks">[];
|
|
50
55
|
error: null;
|
|
51
|
-
result:
|
|
56
|
+
result: "success" | "error";
|
|
52
57
|
}>;
|
|
53
58
|
/**
|
|
54
59
|
*
|
|
@@ -58,7 +63,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
58
63
|
addPage(page: Pick<ChaiPage, "name" | "slug">): Promise<{
|
|
59
64
|
data: ChaiPage;
|
|
60
65
|
error: null;
|
|
61
|
-
result:
|
|
66
|
+
result: "success" | "error";
|
|
62
67
|
}>;
|
|
63
68
|
/**
|
|
64
69
|
*
|
|
@@ -68,7 +73,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
68
73
|
deletePage(uuid: string): Promise<{
|
|
69
74
|
data: null;
|
|
70
75
|
error: null;
|
|
71
|
-
result:
|
|
76
|
+
result: "success" | "error";
|
|
72
77
|
}>;
|
|
73
78
|
/**
|
|
74
79
|
*
|
|
@@ -78,7 +83,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
78
83
|
updatePage(page: ChaiPage): Promise<{
|
|
79
84
|
data: ChaiPage;
|
|
80
85
|
error: null;
|
|
81
|
-
result:
|
|
86
|
+
result: "success" | "error";
|
|
82
87
|
}>;
|
|
83
88
|
/**
|
|
84
89
|
*
|
|
@@ -87,7 +92,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
87
92
|
getProject(): Promise<{
|
|
88
93
|
data: ChaiProject;
|
|
89
94
|
error: null;
|
|
90
|
-
result:
|
|
95
|
+
result: "success" | "error";
|
|
91
96
|
}>;
|
|
92
97
|
/**
|
|
93
98
|
*
|
|
@@ -97,7 +102,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
97
102
|
updateProject(project: Partial<ChaiProject>): Promise<{
|
|
98
103
|
data: ChaiProject;
|
|
99
104
|
error: null;
|
|
100
|
-
result:
|
|
105
|
+
result: "success" | "error";
|
|
101
106
|
}>;
|
|
102
107
|
/**
|
|
103
108
|
*
|
|
@@ -110,7 +115,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
110
115
|
url: string;
|
|
111
116
|
};
|
|
112
117
|
error: null;
|
|
113
|
-
result:
|
|
118
|
+
result: "success" | "error";
|
|
114
119
|
}>;
|
|
115
120
|
/**
|
|
116
121
|
*
|
|
@@ -121,7 +126,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
121
126
|
getAssets(limit?: string, offset?: string): Promise<{
|
|
122
127
|
data: ChaiAsset[];
|
|
123
128
|
error: null;
|
|
124
|
-
result:
|
|
129
|
+
result: "success" | "error";
|
|
125
130
|
}>;
|
|
126
131
|
/**
|
|
127
132
|
*
|
|
@@ -135,7 +140,34 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
135
140
|
token: string;
|
|
136
141
|
};
|
|
137
142
|
error: null;
|
|
138
|
-
result:
|
|
143
|
+
result: "success" | "error";
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
*
|
|
147
|
+
* @param { password }
|
|
148
|
+
* @returns { token }
|
|
149
|
+
*/
|
|
150
|
+
login({ password, email }: {
|
|
151
|
+
password: string;
|
|
152
|
+
email: string;
|
|
153
|
+
}): Promise<{
|
|
154
|
+
data: {
|
|
155
|
+
accessToken: string;
|
|
156
|
+
name: string;
|
|
157
|
+
email: string;
|
|
158
|
+
};
|
|
159
|
+
error: null;
|
|
160
|
+
result: "success" | "error";
|
|
161
|
+
}>;
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
* @param { password }
|
|
165
|
+
* @returns { token }
|
|
166
|
+
*/
|
|
167
|
+
logout(): Promise<{
|
|
168
|
+
data: true;
|
|
169
|
+
error: null;
|
|
170
|
+
result: "success" | "error";
|
|
139
171
|
}>;
|
|
140
172
|
/**
|
|
141
173
|
*
|
|
@@ -147,7 +179,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
147
179
|
result: string;
|
|
148
180
|
};
|
|
149
181
|
error: null;
|
|
150
|
-
result:
|
|
182
|
+
result: "success" | "error";
|
|
151
183
|
}>;
|
|
152
184
|
/**
|
|
153
185
|
*
|
|
@@ -182,6 +214,16 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
182
214
|
url: string;
|
|
183
215
|
}>;
|
|
184
216
|
getAssets(): ChaiApiResponse<ChaiAsset[]>;
|
|
217
|
+
login({ password, email, }: {
|
|
218
|
+
password: string;
|
|
219
|
+
email: string;
|
|
220
|
+
}): ChaiApiResponse<{
|
|
221
|
+
accessToken: string;
|
|
222
|
+
name: string;
|
|
223
|
+
email: string;
|
|
224
|
+
}>;
|
|
225
|
+
logout(): ChaiApiResponse<any>;
|
|
226
|
+
unlockPage(uuid: string): ChaiApiResponse<any>;
|
|
185
227
|
}
|
|
186
228
|
|
|
187
229
|
declare type ChaiPage = {
|
|
@@ -196,6 +238,11 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
196
238
|
}[];
|
|
197
239
|
type: "STATIC" | "DYNAMIC" | "SUBPAGE";
|
|
198
240
|
project: string;
|
|
241
|
+
lockedBy: null | {
|
|
242
|
+
name: string;
|
|
243
|
+
self: boolean;
|
|
244
|
+
email: string;
|
|
245
|
+
};
|
|
199
246
|
};
|
|
200
247
|
|
|
201
248
|
declare type ChaiPageData = {
|
|
@@ -242,7 +289,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
242
289
|
user?: string;
|
|
243
290
|
};
|
|
244
291
|
|
|
245
|
-
declare type ChaiSubPage = Pick<ChaiPage, "uuid" | "name" | "blocks" | "type" | "project" | "providers">;
|
|
292
|
+
declare type ChaiSubPage = Pick<ChaiPage, "uuid" | "name" | "blocks" | "type" | "project" | "providers" | "lockedBy">;
|
|
246
293
|
|
|
247
294
|
export declare const prepareExternalData: (providers: {
|
|
248
295
|
providerKey: string;
|
package/dist/server.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var g = Object.defineProperty;
|
|
2
|
-
var u = (
|
|
3
|
-
var
|
|
4
|
-
import { isEmpty as i, filter as
|
|
5
|
-
import { getChaiDataProviders as
|
|
2
|
+
var u = (c, t, e) => t in c ? g(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
|
+
var h = (c, t, e) => (u(c, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { isEmpty as i, filter as l, map as p } from "lodash";
|
|
5
|
+
import { getChaiDataProviders as m } from "@chaibuilder/blocks";
|
|
6
6
|
const d = "https://api.chaibuilder.com";
|
|
7
|
-
class
|
|
7
|
+
class A {
|
|
8
8
|
constructor(t, e) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
h(this, "_authSecret");
|
|
10
|
+
h(this, "_accessToken", null);
|
|
11
|
+
h(this, "_appKey");
|
|
12
12
|
if (!t)
|
|
13
13
|
throw "Please provide valid auth secret.";
|
|
14
14
|
if (!e)
|
|
@@ -19,12 +19,22 @@ class v {
|
|
|
19
19
|
this._accessToken = t;
|
|
20
20
|
}
|
|
21
21
|
async getPageData(t) {
|
|
22
|
-
const e = this.getHeaders(), s = this.getURL("page-data", i(t) ? {} : { slug: t }),
|
|
22
|
+
const e = this.getHeaders(), s = this.getURL("page-data", i(t) ? {} : { slug: t }), r = {
|
|
23
23
|
method: "GET",
|
|
24
24
|
headers: e,
|
|
25
25
|
next: { tags: ["everything", i(t) ? "_homepage" : t] }
|
|
26
26
|
};
|
|
27
|
-
return this.fetchAPI(s,
|
|
27
|
+
return this.fetchAPI(s, r);
|
|
28
|
+
}
|
|
29
|
+
async unlockPage(t) {
|
|
30
|
+
if (!t)
|
|
31
|
+
return Promise.reject({
|
|
32
|
+
data: null,
|
|
33
|
+
error: { message: "Invalid page uuid" },
|
|
34
|
+
result: "error"
|
|
35
|
+
});
|
|
36
|
+
const e = this.getHeaders(), s = this.getURL("page/unlock"), r = { method: "POST", headers: e, body: JSON.stringify({ uuid: t }) };
|
|
37
|
+
return this.fetchAPI(s, r);
|
|
28
38
|
}
|
|
29
39
|
/**
|
|
30
40
|
*
|
|
@@ -38,8 +48,8 @@ class v {
|
|
|
38
48
|
error: { message: "Invalid page uuid" },
|
|
39
49
|
result: "error"
|
|
40
50
|
});
|
|
41
|
-
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }),
|
|
42
|
-
return this.fetchAPI(s,
|
|
51
|
+
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), r = { method: "GET", headers: e };
|
|
52
|
+
return this.fetchAPI(s, r);
|
|
43
53
|
}
|
|
44
54
|
/**
|
|
45
55
|
*
|
|
@@ -47,8 +57,8 @@ class v {
|
|
|
47
57
|
*/
|
|
48
58
|
// @ts-ignore
|
|
49
59
|
async getPages() {
|
|
50
|
-
const t = this.getHeaders(), e = this.getURL("pages"),
|
|
51
|
-
return this.fetchAPI(e,
|
|
60
|
+
const t = this.getHeaders(), e = this.getURL("pages"), o = { method: "GET", headers: t };
|
|
61
|
+
return this.fetchAPI(e, o);
|
|
52
62
|
}
|
|
53
63
|
/**
|
|
54
64
|
*
|
|
@@ -56,8 +66,8 @@ class v {
|
|
|
56
66
|
* @returns Detail of new page
|
|
57
67
|
*/
|
|
58
68
|
async addPage(t) {
|
|
59
|
-
const e = JSON.stringify(t), s = this.getHeaders(),
|
|
60
|
-
return this.fetchAPI(
|
|
69
|
+
const e = JSON.stringify(t), s = this.getHeaders(), o = this.getURL("page"), n = { method: "POST", headers: s, body: e };
|
|
70
|
+
return this.fetchAPI(o, n);
|
|
61
71
|
}
|
|
62
72
|
/**
|
|
63
73
|
*
|
|
@@ -71,8 +81,8 @@ class v {
|
|
|
71
81
|
error: { message: "Invalid page uuid" },
|
|
72
82
|
result: "error"
|
|
73
83
|
});
|
|
74
|
-
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }),
|
|
75
|
-
return this.fetchAPI(s,
|
|
84
|
+
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), r = { method: "DELETE", headers: e };
|
|
85
|
+
return this.fetchAPI(s, r);
|
|
76
86
|
}
|
|
77
87
|
/**
|
|
78
88
|
*
|
|
@@ -80,16 +90,16 @@ class v {
|
|
|
80
90
|
* @returns Update page information or Error response
|
|
81
91
|
*/
|
|
82
92
|
async updatePage(t) {
|
|
83
|
-
const e = JSON.stringify(t), s = this.getHeaders(),
|
|
84
|
-
return this.fetchAPI(
|
|
93
|
+
const e = JSON.stringify(t), s = this.getHeaders(), o = this.getURL("page"), n = { method: "PUT", headers: s, body: e };
|
|
94
|
+
return this.fetchAPI(o, n);
|
|
85
95
|
}
|
|
86
96
|
/**
|
|
87
97
|
*
|
|
88
98
|
* @returns Project detail
|
|
89
99
|
*/
|
|
90
100
|
async getProject() {
|
|
91
|
-
const t = this.getHeaders(), e = this.getURL("project"),
|
|
92
|
-
return this.fetchAPI(e,
|
|
101
|
+
const t = this.getHeaders(), e = this.getURL("project"), o = { method: "GET", headers: t };
|
|
102
|
+
return this.fetchAPI(e, o);
|
|
93
103
|
}
|
|
94
104
|
/**
|
|
95
105
|
*
|
|
@@ -97,8 +107,8 @@ class v {
|
|
|
97
107
|
* @returns Updated project detail
|
|
98
108
|
*/
|
|
99
109
|
async updateProject(t) {
|
|
100
|
-
const e = JSON.stringify(t), s = this.getHeaders(),
|
|
101
|
-
return this.fetchAPI(
|
|
110
|
+
const e = JSON.stringify(t), s = this.getHeaders(), o = this.getURL("project"), n = { method: "PUT", headers: s, body: e };
|
|
111
|
+
return this.fetchAPI(o, n);
|
|
102
112
|
}
|
|
103
113
|
/**
|
|
104
114
|
*
|
|
@@ -107,10 +117,10 @@ class v {
|
|
|
107
117
|
* @param req
|
|
108
118
|
*/
|
|
109
119
|
async uploadAsset(t) {
|
|
110
|
-
const e = this.getHeaders(), s = this.getURL("asset"),
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
return this.fetchAPI(s,
|
|
120
|
+
const e = this.getHeaders(), s = this.getURL("asset"), o = "POST", r = await t.get("file"), n = new FormData();
|
|
121
|
+
n.append("file", r);
|
|
122
|
+
const a = { method: o, headers: e, body: n };
|
|
123
|
+
return this.fetchAPI(s, a);
|
|
114
124
|
}
|
|
115
125
|
/**
|
|
116
126
|
*
|
|
@@ -119,10 +129,10 @@ class v {
|
|
|
119
129
|
* @param offset
|
|
120
130
|
*/
|
|
121
131
|
async getAssets(t, e) {
|
|
122
|
-
const s = this.getHeaders(),
|
|
123
|
-
t &&
|
|
124
|
-
const
|
|
125
|
-
return this.fetchAPI(
|
|
132
|
+
const s = this.getHeaders(), o = this.getURL("asset");
|
|
133
|
+
t && o.concat(`?limit=${t}`), e && o.concat(`&offset=${e}`);
|
|
134
|
+
const n = { method: "GET", headers: s };
|
|
135
|
+
return this.fetchAPI(o, n);
|
|
126
136
|
}
|
|
127
137
|
/**
|
|
128
138
|
*
|
|
@@ -130,8 +140,26 @@ class v {
|
|
|
130
140
|
* @returns { token }
|
|
131
141
|
*/
|
|
132
142
|
async authenticate({ password: t }) {
|
|
133
|
-
const e = JSON.stringify({ password: t }), s = this.getHeaders(),
|
|
134
|
-
return this.fetchAPI(
|
|
143
|
+
const e = JSON.stringify({ password: t }), s = this.getHeaders(), o = this.getURL("authenticate"), n = { method: "POST", headers: s, body: e };
|
|
144
|
+
return this.fetchAPI(o, n);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
* @param { password }
|
|
149
|
+
* @returns { token }
|
|
150
|
+
*/
|
|
151
|
+
async login({ password: t, email: e }) {
|
|
152
|
+
const s = JSON.stringify({ password: t, email: e }), o = this.getHeaders(), r = this.getURL("login"), a = { method: "POST", headers: o, body: s };
|
|
153
|
+
return this.fetchAPI(r, a);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
* @param { password }
|
|
158
|
+
* @returns { token }
|
|
159
|
+
*/
|
|
160
|
+
async logout() {
|
|
161
|
+
const t = this.getHeaders(), e = this.getURL("logout"), o = { method: "POST", headers: t };
|
|
162
|
+
return this.fetchAPI(e, o);
|
|
135
163
|
}
|
|
136
164
|
/**
|
|
137
165
|
*
|
|
@@ -139,8 +167,8 @@ class v {
|
|
|
139
167
|
* @returns { result: 'success' | 'error' }
|
|
140
168
|
*/
|
|
141
169
|
async verify(t) {
|
|
142
|
-
const e = JSON.stringify({ token: t }), s = this.getHeaders(),
|
|
143
|
-
return this.fetchAPI(
|
|
170
|
+
const e = JSON.stringify({ token: t }), s = this.getHeaders(), o = this.getURL("verify"), n = { method: "POST", headers: s, body: e };
|
|
171
|
+
return this.fetchAPI(o, n);
|
|
144
172
|
}
|
|
145
173
|
/**
|
|
146
174
|
*
|
|
@@ -166,7 +194,7 @@ class v {
|
|
|
166
194
|
*/
|
|
167
195
|
async fetchAPI(t, e) {
|
|
168
196
|
try {
|
|
169
|
-
const s = await fetch(t, e).then((
|
|
197
|
+
const s = await fetch(t, e).then((o) => o.json());
|
|
170
198
|
if ((s == null ? void 0 : s.result) === "success")
|
|
171
199
|
return { data: s == null ? void 0 : s.data, error: null, result: "success" };
|
|
172
200
|
throw s == null ? void 0 : s.error;
|
|
@@ -175,17 +203,17 @@ class v {
|
|
|
175
203
|
}
|
|
176
204
|
}
|
|
177
205
|
}
|
|
178
|
-
const
|
|
179
|
-
const e =
|
|
180
|
-
for (const
|
|
206
|
+
const T = async (c, t) => {
|
|
207
|
+
const e = m(), s = l(e, (n) => p(c, "providerKey").includes(n.providerKey)), o = {}, r = [];
|
|
208
|
+
for (const n of s)
|
|
181
209
|
try {
|
|
182
|
-
|
|
183
|
-
} catch (
|
|
184
|
-
|
|
210
|
+
o[n.providerKey] = await n.dataFn({}, t);
|
|
211
|
+
} catch (a) {
|
|
212
|
+
r.push(a);
|
|
185
213
|
}
|
|
186
|
-
return { data:
|
|
214
|
+
return { data: o, errors: r };
|
|
187
215
|
};
|
|
188
216
|
export {
|
|
189
|
-
|
|
190
|
-
|
|
217
|
+
A as ChaibuilderBackend,
|
|
218
|
+
T as prepareExternalData
|
|
191
219
|
};
|
|
@@ -7,7 +7,7 @@ import { S as q } from "./scroll-area-83bd9e8f.js";
|
|
|
7
7
|
import { SingleLineText as g, Model as Z, MultilineText as $, Image as F, Checkbox as Q } from "@chaibuilder/blocks";
|
|
8
8
|
import { toast as U } from "sonner";
|
|
9
9
|
import { F as h } from "./form-25e1af37.js";
|
|
10
|
-
import { a2 as V, R as X, a3 as _, S as K } from "./index-
|
|
10
|
+
import { a2 as V, R as X, a3 as _, S as K } from "./index-b13e230b.js";
|
|
11
11
|
import "@radix-ui/react-alert-dialog";
|
|
12
12
|
import "./utils-ac68b2c8.js";
|
|
13
13
|
import "clsx";
|
|
@@ -43,7 +43,7 @@ import "himalaya";
|
|
|
43
43
|
import "redux-undo";
|
|
44
44
|
import "@react-hookz/web";
|
|
45
45
|
import "lucide-react";
|
|
46
|
-
const O = y.lazy(() => import("./delete-page-modal-
|
|
46
|
+
const O = y.lazy(() => import("./delete-page-modal-6e2504f3.js")), J = y.lazy(() => import("./confirm-alert-c1fdf1e4.js")), x = (n) => {
|
|
47
47
|
if (!z(n) || !(n.includes("/[") && n.includes("]")))
|
|
48
48
|
return !1;
|
|
49
49
|
const s = /^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/, u = /^[a-zA-Z0-9_-]+$/;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-5c3ac4f7.cjs"),g=require("react"),c=require("lodash"),M=require("@radix-ui/react-icons"),H=require("./useBuilderProp-adacf42f.cjs"),w=require("./scroll-area-bb343b86.cjs"),d=require("@chaibuilder/blocks"),L=require("sonner"),p=require("./form-ea21db6c.cjs"),P=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-5c3ac4f7.cjs"),g=require("react"),c=require("lodash"),M=require("@radix-ui/react-icons"),H=require("./useBuilderProp-adacf42f.cjs"),w=require("./scroll-area-bb343b86.cjs"),d=require("@chaibuilder/blocks"),L=require("sonner"),p=require("./form-ea21db6c.cjs"),P=require("./index-a651f2ae.cjs");require("@radix-ui/react-alert-dialog");require("./utils-3c452dd0.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-slot");require("class-variance-authority");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-24679521.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("./ImagesPanel-8b7a989d.cjs");require("./tabs-860e37aa.cjs");require("@radix-ui/react-tabs");require("react-quill");require("react-i18next");require("./MODIFIERS-4716c669.cjs");require("@floating-ui/react-dom");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("./html-to-json-aadcbf66.cjs");require("himalaya");require("redux-undo");require("@react-hookz/web");require("lucide-react");const z=g.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-446def2d.cjs"))),B=g.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-e1ea5110.cjs"))),E=n=>{if(!c.isString(n)||!(n.includes("/[")&&n.includes("]")))return!1;const s=/^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/,q=/^[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=s.test(u):e=q.test(u))}),e},h=n=>n&&c.isEmpty(n.seoData)?{...n,seoData:{title:"",description:"",image:""}}:n,G=(n,o)=>{const s=!c.isEqual(c.omit(n,["seoData"]),c.omit(o,["seoData"])),q=!c.isEqual(h(o).seoData,h(n).seoData);return s||q},Y=({open:n,setOpen:o,pageData:s})=>{const q=P.useQueryClient(),{data:e}=P.useProject(),u=P.useUpdatePage(),m=P.useUpdateProject("Homepage updated successfully."),[i,b]=g.useState(h(s)),[a,y]=g.useState({isHomePage:(e==null?void 0:e.homepage)===s.uuid}),j=G(i,s);g.useEffect(()=>{const l=!c.isEqual(h(s),i),r=(e==null?void 0:e.homepage)!==s.uuid&&a.isHomePage;o(l||r?"PENDING":"OPEN")},[e,s,i,a,o]);const S=()=>{if(j){if(s.type==="DYNAMIC"&&!E((i==null?void 0:i.slug)||"")){n==="ALERT"&&o("PENDING");return}u.mutate(i,{onSuccess:()=>{q.invalidateQueries({refetchType:"active",queryKey:["pages",e==null?void 0:e.uuid]}),o("CLOSE"),L.toast.success("Page updated successfully.")}})}a.isHomePage&&(e==null?void 0:e.homepage)!==s.uuid&&m.mutate({...e,homepage:s==null?void 0:s.uuid},{onSuccess:()=>o("CLOSE")})},C=({formData:l},r)=>{b(f=>{var R,N;if(!r)return f;const x={[r]:l[r]};return r==="name"?x.slug=c.kebabCase((R=l[r])==null?void 0:R.replace(/\d/g,"")):r==="slug"?x.slug=(N=l[r])==null?void 0:N.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):r==="seoData"&&(x.seoData={title:l[r].title||"",description:l[r].description||"",image:l[r].image||""}),{...f,...x}})},A=({formData:l},r)=>{y(f=>{const x={[r]:l[r]};return{...f,...x}})},I={name:d.SingleLineText({title:"Page Name",default:i.name}),slug:d.SingleLineText({title:"Page Slug",default:i.slug})},T={seoData:d.Model({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.SingleLineText({title:"Meta Title",default:i.name}),description:d.MultilineText({title:"Meta Description",default:i.slug}),image:d.Image({title:"Social Media Image",default:""})}})},v={isHomePage:d.Checkbox({title:"Set as homepage",default:a.isHomePage})};return t.jsxRuntimeExports.jsxs(w.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:S,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:i,properties:I,onChange:C,disabled:u.isPending||m.isPending}),t.jsxRuntimeExports.jsx("div",{className:"h-2 w-full"}),t.jsxRuntimeExports.jsx(p.Form,{title:"SEO Details",formData:i,properties:T,onChange:C,disabled:u.isPending||m.isPending}),(e==null?void 0:e.homepage)!==s.uuid&&s.type==="STATIC"?t.jsxRuntimeExports.jsx(p.Form,{formData:a,properties:v,onChange:A,disabled:u.isPending||m.isPending}):s.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(M.HomeIcon,{})," This is homepage"," "]}),i.type==="DYNAMIC"&&!E((i==null?void 0:i.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(H.Button,{className:"w-full",type:"submit",onClick:S,disabled:(e==null?void 0:e.homepage)!==s.uuid&&a.isHomePage?!1:c.isEmpty(i.name)||c.isEmpty(i.slug)||!j||u.isPending||m.isPending||i.type==="DYNAMIC"&&!E((i==null?void 0:i.slug)||""),children:"Save"}),t.jsxRuntimeExports.jsx(z,{pageData:s,projectData:e})]})]})})]})};exports.default=Y;
|