@chaibuilder/sdk 0.1.23 → 0.1.25
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-2e763e41.cjs +3 -0
- package/dist/{AddBlocks-189ba69a.js → AddBlocks-340542cc.js} +13 -14
- package/dist/{BrandingOptions-e659a7bf.cjs → BrandingOptions-93298418.cjs} +1 -1
- package/dist/{BrandingOptions-c01e08fc.js → BrandingOptions-da602397.js} +1 -1
- package/dist/{CanvasArea-9106ecb5.js → CanvasArea-0ba49a92.js} +2 -2
- package/dist/{CanvasArea-933848fb.cjs → CanvasArea-20982a8b.cjs} +2 -2
- package/dist/{CurrentPage-37d2f495.js → CurrentPage-41e66713.js} +1 -1
- package/dist/{CurrentPage-92d8bfe0.cjs → CurrentPage-7c0e986b.cjs} +1 -1
- package/dist/{Layers-c08aa961.js → Layers-15b9cf48.js} +2 -2
- package/dist/{Layers-94aeb9f0.cjs → Layers-cc22fb98.cjs} +1 -1
- package/dist/{MarkAsGlobalBlock-10422d13.js → MarkAsGlobalBlock-143a204d.js} +1 -1
- package/dist/{MarkAsGlobalBlock-07cb6760.cjs → MarkAsGlobalBlock-4f9dad50.cjs} +1 -1
- package/dist/{PagesPanel-be499af0.js → PagesPanel-29e8ff05.js} +2 -2
- package/dist/{PagesPanel-e4807890.cjs → PagesPanel-6dbcc705.cjs} +1 -1
- package/dist/{ProjectPanel-fd948934.js → ProjectPanel-0cf59dff.js} +2 -2
- package/dist/{ProjectPanel-0478c85b.cjs → ProjectPanel-e3ecad42.cjs} +1 -1
- package/dist/{Settings-94b79852.js → Settings-5df6bc31.js} +450 -449
- package/dist/Settings-ae8b67c5.cjs +1 -0
- package/dist/SidePanels-7c31e973.js +329 -0
- package/dist/SidePanels-fbf3d99d.cjs +1 -0
- package/dist/{Topbar-d6382110.cjs → Topbar-506281be.cjs} +1 -1
- package/dist/{Topbar-0542b5f4.js → Topbar-f6d0676d.js} +1 -1
- package/dist/{add-page-modal-6132fdff.cjs → add-page-modal-87e921d2.cjs} +1 -1
- package/dist/{add-page-modal-36a6b406.js → add-page-modal-f7b31884.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{delete-page-modal-87c48560.cjs → delete-page-modal-8cfafe5d.cjs} +1 -1
- package/dist/{delete-page-modal-68a4d71e.js → delete-page-modal-afc5ac26.js} +1 -1
- package/dist/{index-6f5cce76.cjs → index-cbeea3bc.cjs} +18 -18
- package/dist/{index-c49887fe.js → index-d1a25967.js} +6 -6
- package/dist/{page-viewer-47098c44.cjs → page-viewer-9b33c8bb.cjs} +1 -1
- package/dist/{page-viewer-d87e5621.js → page-viewer-f651f579.js} +2 -2
- package/dist/{project-general-setting-869887d5.cjs → project-general-setting-0ceca7f5.cjs} +1 -1
- package/dist/{project-general-setting-91df16a9.js → project-general-setting-15cad783.js} +1 -1
- package/dist/render.cjs +1 -1
- package/dist/render.d.ts +2 -4
- package/dist/render.js +59 -67
- package/dist/server.cjs +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +36 -36
- package/dist/{single-page-detail-4a424725.js → single-page-detail-8d4fb1c8.js} +2 -2
- package/dist/{single-page-detail-1b276c4f.cjs → single-page-detail-ae2a5b54.cjs} +1 -1
- package/dist/textarea-0750bcd2.js +73 -0
- package/dist/textarea-a338ede6.cjs +1 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +72 -73
- package/package.json +4 -4
- package/dist/AddBlocks-36adcc50.cjs +0 -3
- package/dist/Settings-6cb217af.cjs +0 -1
- package/dist/SidePanels-4434d31b.cjs +0 -1
- package/dist/SidePanels-78d8de19.js +0 -246
- package/dist/card-14e1d020.cjs +0 -1
- package/dist/card-f8f4f985.js +0 -33
- package/dist/textarea-20b2f6b2.cjs +0 -1
- package/dist/textarea-9dfb6a32.js +0 -45
|
@@ -27488,7 +27488,7 @@ const uZ = () => {
|
|
|
27488
27488
|
const a = pr(e);
|
|
27489
27489
|
Cf(a) && (n = [a, ...pL(t, a)]), r(n);
|
|
27490
27490
|
}, [e, t, r]);
|
|
27491
|
-
}, FZ = () => Ge(fA), bL = Fn(() => import("./SidePanels-
|
|
27491
|
+
}, FZ = () => Ge(fA), bL = Fn(() => import("./SidePanels-7c31e973.js")), gL = Fn(() => import("./Topbar-f6d0676d.js")), mL = Fn(() => import("./CanvasArea-0ba49a92.js")), vL = Fn(() => import("./Settings-5df6bc31.js")), yL = () => {
|
|
27492
27492
|
const [e] = Me(Oc), t = (r) => {
|
|
27493
27493
|
r.preventDefault();
|
|
27494
27494
|
};
|
|
@@ -28743,7 +28743,7 @@ function hW() {
|
|
|
28743
28743
|
};
|
|
28744
28744
|
return nW(om(om({}, t), e));
|
|
28745
28745
|
}
|
|
28746
|
-
const bW = "@chaibuilder/sdk", gW = "0.1.
|
|
28746
|
+
const bW = "@chaibuilder/sdk", gW = "0.1.25", mW = "module", vW = [
|
|
28747
28747
|
"dist"
|
|
28748
28748
|
], yW = "dist/core.js", wW = !1, SW = {
|
|
28749
28749
|
".": {
|
|
@@ -28789,7 +28789,7 @@ const bW = "@chaibuilder/sdk", gW = "0.1.23", mW = "module", vW = [
|
|
|
28789
28789
|
docs: "jsdoc -c jsdoc.conf.json"
|
|
28790
28790
|
}, EW = {
|
|
28791
28791
|
"@bobthered/tailwindcss-palette-generator": "3.1.1",
|
|
28792
|
-
"@chaibuilder/blocks": "0.1.
|
|
28792
|
+
"@chaibuilder/blocks": "0.1.22",
|
|
28793
28793
|
"@floating-ui/dom": "1.4.5",
|
|
28794
28794
|
"@floating-ui/react-dom": "2.0.1",
|
|
28795
28795
|
"@mhsdesign/jit-browser-tailwindcss": "0.3.0",
|
|
@@ -28843,12 +28843,12 @@ const bW = "@chaibuilder/sdk", gW = "0.1.23", mW = "module", vW = [
|
|
|
28843
28843
|
"lucide-react": "^0.244.0",
|
|
28844
28844
|
nanoid: "^4.0.2",
|
|
28845
28845
|
"post-robot": "10.0.46",
|
|
28846
|
-
react: "^18
|
|
28846
|
+
react: "^18",
|
|
28847
28847
|
"react-autosuggest": "10.1.0",
|
|
28848
28848
|
"react-colorful": "5.6.1",
|
|
28849
28849
|
"react-dnd": "16.0.1",
|
|
28850
28850
|
"react-dnd-html5-backend": "16.0.1",
|
|
28851
|
-
"react-dom": "^18
|
|
28851
|
+
"react-dom": "^18",
|
|
28852
28852
|
"react-hotkeys-hook": "4.4.1",
|
|
28853
28853
|
"react-i18next": "13.0.1",
|
|
28854
28854
|
"react-icons": "^4.10.1",
|
|
@@ -30826,7 +30826,7 @@ const ls = () => {
|
|
|
30826
30826
|
})).json();
|
|
30827
30827
|
}
|
|
30828
30828
|
});
|
|
30829
|
-
}, vK = Fn(() => import("./PagesPanel-
|
|
30829
|
+
}, vK = Fn(() => import("./PagesPanel-29e8ff05.js")), yK = Fn(() => import("./ProjectPanel-0cf59dff.js")), wK = Fn(() => import("./CurrentPage-41e66713.js")), SK = () => /* @__PURE__ */ oe.jsx("h2", { children: "Your Logo" }), AK = () => {
|
|
30830
30830
|
const e = Pr();
|
|
30831
30831
|
return /* @__PURE__ */ oe.jsx("div", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ oe.jsx(
|
|
30832
30832
|
kE,
|
|
@@ -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-cbeea3bc.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-5e57d0c8.cjs");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("lucide-react");require("sonner");const m=n.lazy(()=>Promise.resolve().then(()=>require("./single-page-detail-ae2a5b54.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-d1a25967.js";
|
|
6
6
|
import "@radix-ui/react-popover";
|
|
7
7
|
import "./utils-ac68b2c8.js";
|
|
8
8
|
import "clsx";
|
|
@@ -32,7 +32,7 @@ import "@react-hookz/web";
|
|
|
32
32
|
import "@chaibuilder/blocks";
|
|
33
33
|
import "lucide-react";
|
|
34
34
|
import "sonner";
|
|
35
|
-
const P = o.lazy(() => import("./single-page-detail-
|
|
35
|
+
const P = o.lazy(() => import("./single-page-detail-8d4fb1c8.js")), v = ({ pageData: t }) => {
|
|
36
36
|
const [s, r] = m("CLOSE");
|
|
37
37
|
return /* @__PURE__ */ e.jsxs(
|
|
38
38
|
g,
|
|
@@ -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-99b51245.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-99b51245.cjs"),d=require("./index-cbeea3bc.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-86ac8848.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("@radix-ui/react-icons");require("./ImagesPanel-0db5c72f.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("./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");require("sonner");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;
|
|
@@ -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-725e3191.js";
|
|
6
|
-
import { R as x } from "./index-
|
|
6
|
+
import { R as x } from "./index-d1a25967.js";
|
|
7
7
|
import "@radix-ui/react-scroll-area";
|
|
8
8
|
import "./utils-ac68b2c8.js";
|
|
9
9
|
import "clsx";
|
package/dist/render.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./jsx-runtime-5c3ac4f7.cjs"),x=require("react"),n=require("lodash"),R=require("tailwind-merge"),u=require("./MODIFIERS-4716c669.cjs"),_=require("@chaibuilder/blocks"),j=require("./functions-f84d5e2a.cjs"),q=require("react-wrap-balancer");require("@mhsdesign/jit-browser-tailwindcss");require("@bobthered/tailwindcss-palette-generator");require("@tailwindcss/forms");require("@tailwindcss/typography");require("@tailwindcss/aspect-ratio");require("@tailwindcss/line-clamp");const y=t=>{const r={};return Object.keys(t).forEach(e=>{n.isString(t[e])&&t[e].startsWith(u.SLOT_KEY)&&(r[e]=t[e].replace(u.SLOT_KEY,"").split(","))}),r},B=n.memoize((t,r)=>{const e=t.replace(u.STYLES_KEY,"").split(","),s=R.twMerge(e[0],e[1]);return j.addPrefixToClasses(s,r).replace(u.STYLES_KEY,"").trim()});function C(t,r){return n.get(t,`${r}_attrs`,{})}function O(t,r){const e={};return Object.keys(t).forEach(s=>{if(n.isString(t[s])&&t[s].startsWith(u.STYLES_KEY)){const o=B(t[s],r);e[s]={className:o,...C(t,s)}}}),e}function T(t,r){const e=n.get(t,"_bindings",{});return n.isEmpty(e)?{...t}:(n.each(e,(s,o)=>{n.isString(s)&&n.get(r,s,null)&&(t[o]=n.get(r,s,null))}),t)}function a({blocks:t,parent:r,classPrefix:e="c-",externalData:s=[]}){const o=t,p=i=>O(i,e),f=r?n.filter(t,{_parent:r}):n.filter(t,i=>n.isEmpty(i._parent));return c.jsxRuntimeExports.jsx(c.jsxRuntimeExports.Fragment,{children:x.Children.toArray(f.map((i,h)=>{const d=y(i),m={};n.isEmpty(d)||Object.keys(d).forEach(l=>{m[l]=x.Children.toArray(d[l].map(E=>c.jsxRuntimeExports.jsx(a,{classPrefix:e,blocks:o,parent:E})))});const S=n.filter(o,{_parent:i._id});m.children=S.length>0?c.jsxRuntimeExports.jsx(a,{classPrefix:e,parent:i._id,blocks:o}):null;const g=_.getBlockComponent(i._type);if(g!==null){let l=i;const E=g.component;return l={...g.defaults,...i},x.createElement(E,n.omit({blockProps:{},inBuilder:!1,...l,index:h,...T(i,s),...p(l),...m},["_parent"]))}return c.jsxRuntimeExports.jsxs("noscript",{children:[i._type," not found"]})}))})}const Y=({pageData:t,externalData:r={},before:e=null,after:s=null,classPrefix:o="c-"})=>{const p=n.get(t.project,"brandingOptions",u.BRANDING_OPTIONS_DEFAULTS);return c.jsxRuntimeExports.jsxs(c.jsxRuntimeExports.Fragment,{children:[e,c.jsxRuntimeExports.jsx("div",{className:o.replace("-","")+" "+j.getBrandingClasses(p,o)+" min-h-screen",children:c.jsxRuntimeExports.jsx(q.Provider,{children:c.jsxRuntimeExports.jsx(a,{externalData:r,blocks:t.page.blocks||[],classPrefix:o})})}),s]})};exports.RenderChaiBlocks=a;exports.RenderChaiPage=Y;
|
package/dist/render.d.ts
CHANGED
|
@@ -9,8 +9,6 @@ declare type ChaiBlock = {
|
|
|
9
9
|
readonly _type: string;
|
|
10
10
|
} & Record<string, any>;
|
|
11
11
|
|
|
12
|
-
export declare const ChaiDataProvider: ({ children, data }: any) => JSX_2.Element;
|
|
13
|
-
|
|
14
12
|
export declare type ChaiPageData = {
|
|
15
13
|
page: {
|
|
16
14
|
blocks: ChaiBlock[];
|
|
@@ -49,12 +47,12 @@ declare type ChaiPageProps = {
|
|
|
49
47
|
externalData?: Record<string, any>;
|
|
50
48
|
};
|
|
51
49
|
|
|
52
|
-
export declare
|
|
50
|
+
export declare function RenderChaiBlocks({ blocks, parent, classPrefix, externalData, }: {
|
|
53
51
|
blocks: ChaiBlock[];
|
|
54
52
|
parent?: string;
|
|
55
53
|
classPrefix?: string;
|
|
56
54
|
externalData?: Record<string, any>;
|
|
57
|
-
})
|
|
55
|
+
}): JSX_2.Element;
|
|
58
56
|
|
|
59
57
|
export declare const RenderChaiPage: ({ pageData, externalData, before, after, classPrefix, }: ChaiPageProps) => JSX_2.Element;
|
|
60
58
|
|
package/dist/render.js
CHANGED
|
@@ -1,120 +1,112 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import
|
|
3
|
-
import { memoize as
|
|
4
|
-
import { twMerge as
|
|
5
|
-
import { S as
|
|
6
|
-
import { getBlockComponent as
|
|
7
|
-
import { a as
|
|
8
|
-
import { Provider as
|
|
1
|
+
import { j as o } from "./jsx-runtime-944c88e2.js";
|
|
2
|
+
import u from "react";
|
|
3
|
+
import { memoize as O, filter as g, isEmpty as h, omit as y, isString as E, get as p, each as A } from "lodash";
|
|
4
|
+
import { twMerge as N } from "tailwind-merge";
|
|
5
|
+
import { S as _, a as B, B as R } from "./MODIFIERS-2f19c314.js";
|
|
6
|
+
import { getBlockComponent as T } from "@chaibuilder/blocks";
|
|
7
|
+
import { a as F, g as L } from "./functions-83b1de8d.js";
|
|
8
|
+
import { Provider as Y } from "react-wrap-balancer";
|
|
9
9
|
import "@mhsdesign/jit-browser-tailwindcss";
|
|
10
10
|
import "@bobthered/tailwindcss-palette-generator";
|
|
11
11
|
import "@tailwindcss/forms";
|
|
12
12
|
import "@tailwindcss/typography";
|
|
13
13
|
import "@tailwindcss/aspect-ratio";
|
|
14
14
|
import "@tailwindcss/line-clamp";
|
|
15
|
-
const
|
|
16
|
-
const n = A(() => r, [r]);
|
|
17
|
-
return /* @__PURE__ */ s.jsx(B.Provider, { value: n, children: t });
|
|
18
|
-
}, M = (t) => {
|
|
15
|
+
const I = (t) => {
|
|
19
16
|
const r = {};
|
|
20
17
|
return Object.keys(t).forEach((n) => {
|
|
21
|
-
|
|
18
|
+
E(t[n]) && t[n].startsWith(B) && (r[n] = t[n].replace(B, "").split(","));
|
|
22
19
|
}), r;
|
|
23
|
-
},
|
|
24
|
-
const n = t.replace(
|
|
25
|
-
return
|
|
20
|
+
}, K = O((t, r) => {
|
|
21
|
+
const n = t.replace(_, "").split(","), s = N(n[0], n[1]);
|
|
22
|
+
return F(s, r).replace(_, "").trim();
|
|
26
23
|
});
|
|
27
|
-
function
|
|
28
|
-
return
|
|
24
|
+
function W(t, r) {
|
|
25
|
+
return p(t, `${r}_attrs`, {});
|
|
29
26
|
}
|
|
30
|
-
function
|
|
27
|
+
function w(t, r) {
|
|
31
28
|
const n = {};
|
|
32
|
-
return Object.keys(t).forEach((
|
|
33
|
-
if (
|
|
34
|
-
const i =
|
|
35
|
-
n[
|
|
29
|
+
return Object.keys(t).forEach((s) => {
|
|
30
|
+
if (E(t[s]) && t[s].startsWith(_)) {
|
|
31
|
+
const i = K(t[s], r);
|
|
32
|
+
n[s] = {
|
|
36
33
|
className: i,
|
|
37
|
-
...
|
|
34
|
+
...W(t, s)
|
|
38
35
|
};
|
|
39
36
|
}
|
|
40
37
|
}), n;
|
|
41
38
|
}
|
|
42
|
-
function
|
|
43
|
-
const n =
|
|
44
|
-
return h(n) ? { ...t } : (
|
|
45
|
-
|
|
39
|
+
function z(t, r) {
|
|
40
|
+
const n = p(t, "_bindings", {});
|
|
41
|
+
return h(n) ? { ...t } : (A(n, (s, i) => {
|
|
42
|
+
E(s) && p(r, s, null) && (t[i] = p(r, s, null));
|
|
46
43
|
}), t);
|
|
47
44
|
}
|
|
48
|
-
function
|
|
45
|
+
function j({
|
|
49
46
|
blocks: t,
|
|
50
47
|
parent: r,
|
|
51
|
-
classPrefix: n = "c-"
|
|
48
|
+
classPrefix: n = "c-",
|
|
49
|
+
externalData: s = []
|
|
52
50
|
}) {
|
|
53
|
-
const
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
h(
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
const i = t, m = (e) => w(e, n), S = r ? g(t, { _parent: r }) : g(t, (e) => h(e._parent));
|
|
52
|
+
return /* @__PURE__ */ o.jsx(o.Fragment, { children: u.Children.toArray(
|
|
53
|
+
S.map((e, C) => {
|
|
54
|
+
const c = I(e), l = {};
|
|
55
|
+
h(c) || Object.keys(c).forEach((a) => {
|
|
56
|
+
l[a] = u.Children.toArray(
|
|
57
|
+
c[a].map((f) => /* @__PURE__ */ o.jsx(j, { classPrefix: n, blocks: i, parent: f }))
|
|
60
58
|
);
|
|
61
59
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
const d =
|
|
60
|
+
const x = g(i, { _parent: e._id });
|
|
61
|
+
l.children = x.length > 0 ? /* @__PURE__ */ o.jsx(j, { classPrefix: n, parent: e._id, blocks: i }) : null;
|
|
62
|
+
const d = T(e._type);
|
|
65
63
|
if (d !== null) {
|
|
66
|
-
let a =
|
|
67
|
-
const
|
|
68
|
-
return a = { ...d.defaults, ...
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
let a = e;
|
|
65
|
+
const f = d.component;
|
|
66
|
+
return a = { ...d.defaults, ...e }, u.createElement(
|
|
67
|
+
f,
|
|
68
|
+
y(
|
|
71
69
|
{
|
|
72
70
|
blockProps: {},
|
|
73
71
|
inBuilder: !1,
|
|
74
72
|
...a,
|
|
75
|
-
index:
|
|
76
|
-
...
|
|
77
|
-
...
|
|
78
|
-
...
|
|
73
|
+
index: C,
|
|
74
|
+
...z(e, s),
|
|
75
|
+
...m(a),
|
|
76
|
+
...l
|
|
79
77
|
},
|
|
80
78
|
["_parent"]
|
|
81
79
|
)
|
|
82
80
|
);
|
|
83
81
|
}
|
|
84
|
-
return /* @__PURE__ */
|
|
85
|
-
|
|
82
|
+
return /* @__PURE__ */ o.jsxs("noscript", { children: [
|
|
83
|
+
e._type,
|
|
86
84
|
" not found"
|
|
87
85
|
] });
|
|
88
86
|
})
|
|
89
87
|
) });
|
|
90
88
|
}
|
|
91
|
-
const
|
|
92
|
-
blocks: t,
|
|
93
|
-
parent: r,
|
|
94
|
-
classPrefix: n = "c-",
|
|
95
|
-
externalData: e = {}
|
|
96
|
-
}) => /* @__PURE__ */ s.jsx(K, { data: e, children: /* @__PURE__ */ s.jsx(U, { blocks: t, parent: r, classPrefix: n }) }), st = ({
|
|
89
|
+
const b = ({
|
|
97
90
|
pageData: t,
|
|
98
91
|
externalData: r = {},
|
|
99
92
|
before: n = null,
|
|
100
|
-
after:
|
|
93
|
+
after: s = null,
|
|
101
94
|
classPrefix: i = "c-"
|
|
102
95
|
}) => {
|
|
103
|
-
const
|
|
104
|
-
return /* @__PURE__ */
|
|
96
|
+
const m = p(t.project, "brandingOptions", R);
|
|
97
|
+
return /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
|
|
105
98
|
n,
|
|
106
|
-
/* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ o.jsx(
|
|
107
100
|
"div",
|
|
108
101
|
{
|
|
109
|
-
className: i.replace("-", "") + " " +
|
|
110
|
-
children: /* @__PURE__ */
|
|
102
|
+
className: i.replace("-", "") + " " + L(m, i) + " min-h-screen",
|
|
103
|
+
children: /* @__PURE__ */ o.jsx(Y, { children: /* @__PURE__ */ o.jsx(j, { externalData: r, blocks: t.page.blocks || [], classPrefix: i }) })
|
|
111
104
|
}
|
|
112
105
|
),
|
|
113
|
-
|
|
106
|
+
s
|
|
114
107
|
] });
|
|
115
108
|
};
|
|
116
109
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
st as RenderChaiPage
|
|
110
|
+
j as RenderChaiBlocks,
|
|
111
|
+
b as RenderChaiPage
|
|
120
112
|
};
|
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var g=(n,t,e)=>t in n?u(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var g=(n,t,e)=>t in n?u(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var h=(n,t,e)=>(g(n,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("lodash"),p=require("@chaibuilder/blocks"),d="https://api.chaibuilder.com";class l{constructor(t,e){h(this,"authSecret");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}async getPageData(t){const e=this.getHeaders(),s=this.getURL("page-data",c.isEmpty(t)?{}:{slug:t}),a={method:"GET",headers:e,next:{tags:["everything",c.isEmpty(t)?"_homepage":t]}};return this.fetchAPI(s,a)}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}),a={method:"GET",headers:e};return this.fetchAPI(s,a)}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"),o={method:"POST",headers:s,body:e};return this.fetchAPI(r,o)}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}),a={method:"DELETE",headers:e};return this.fetchAPI(s,a)}async updatePage(t){const e=JSON.stringify(t),s=this.getHeaders(),r=this.getURL("page"),o={method:"PUT",headers:s,body:e};return this.fetchAPI(r,o)}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"),o={method:"PUT",headers:s,body:e};return this.fetchAPI(r,o)}async uploadAsset(t){const e=this.getHeaders(),s=this.getURL("asset"),r="POST",a=await t.get("file"),o=new FormData;o.append("file",a);const i={method:r,headers:e,body:o};return this.fetchAPI(s,i)}async getAssets(t,e){const s=this.getHeaders(),r=this.getURL("asset");t&&r.concat(`?limit=${t}`),e&&r.concat(`&offset=${e}`);const o={method:"GET",headers:s};return this.fetchAPI(r,o)}async authenticate({password:t}){const e=JSON.stringify({password:t}),s=this.getHeaders(),r=this.getURL("authenticate"),o={method:"POST",headers:s,body:e};return this.fetchAPI(r,o)}async verify(t){const e=JSON.stringify({token:t}),s=this.getHeaders(),r=this.getURL("verify"),o={method:"POST",headers:s,body:e};return this.fetchAPI(r,o)}getURL(t,e){const s=new URLSearchParams(e).toString();return c.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),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(n,t)=>{const e=p.getChaiDataProviders(),s=c.filter(e,o=>c.map(n,"providerKey").includes(o.providerKey)),r={},a=[];for(const o of s)try{r[o.providerKey]=await o.dataFn({},t)}catch(i){a.push(i)}return{data:r,errors:a}};exports.ChaibuilderBackend=l;exports.prepareExternalData=y;
|
package/dist/server.d.ts
CHANGED
|
@@ -245,7 +245,7 @@ export declare class ChaibuilderBackend implements ChaibuilderBackendInterface {
|
|
|
245
245
|
export declare const prepareExternalData: (providers: {
|
|
246
246
|
providerKey: string;
|
|
247
247
|
args: Record<string, unknown>;
|
|
248
|
-
}[]) => Promise<{
|
|
248
|
+
}[], currentPageUrl: string) => Promise<{
|
|
249
249
|
data: {};
|
|
250
250
|
errors: any[];
|
|
251
251
|
}>;
|
package/dist/server.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var g = Object.defineProperty;
|
|
2
2
|
var u = (n, t, e) => t in n ? g(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
-
var
|
|
4
|
-
import { isEmpty as
|
|
3
|
+
var h = (n, t, e) => (u(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { isEmpty as i, filter as p, map as l } from "lodash";
|
|
5
5
|
import { getChaiDataProviders as y } from "@chaibuilder/blocks";
|
|
6
|
-
const
|
|
6
|
+
const d = "https://api.chaibuilder.com";
|
|
7
7
|
class v {
|
|
8
8
|
constructor(t, e) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
h(this, "authSecret");
|
|
10
|
+
h(this, "appKey");
|
|
11
11
|
if (!t)
|
|
12
12
|
throw "Please provide valid auth secret.";
|
|
13
13
|
if (!e)
|
|
@@ -15,12 +15,12 @@ class v {
|
|
|
15
15
|
this.authSecret = t, this.appKey = e;
|
|
16
16
|
}
|
|
17
17
|
async getPageData(t) {
|
|
18
|
-
const e = this.getHeaders(), s = this.getURL("page-data",
|
|
18
|
+
const e = this.getHeaders(), s = this.getURL("page-data", i(t) ? {} : { slug: t }), a = {
|
|
19
19
|
method: "GET",
|
|
20
20
|
headers: e,
|
|
21
|
-
next: { tags: ["everything",
|
|
21
|
+
next: { tags: ["everything", i(t) ? "_homepage" : t] }
|
|
22
22
|
};
|
|
23
|
-
return this.fetchAPI(s,
|
|
23
|
+
return this.fetchAPI(s, a);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
*
|
|
@@ -34,8 +34,8 @@ class v {
|
|
|
34
34
|
error: { message: "Invalid page uuid" },
|
|
35
35
|
result: "error"
|
|
36
36
|
});
|
|
37
|
-
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }),
|
|
38
|
-
return this.fetchAPI(s,
|
|
37
|
+
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), a = { method: "GET", headers: e };
|
|
38
|
+
return this.fetchAPI(s, a);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
*
|
|
@@ -52,8 +52,8 @@ class v {
|
|
|
52
52
|
* @returns Detail of new page
|
|
53
53
|
*/
|
|
54
54
|
async addPage(t) {
|
|
55
|
-
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("page"),
|
|
56
|
-
return this.fetchAPI(r,
|
|
55
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("page"), o = { method: "POST", headers: s, body: e };
|
|
56
|
+
return this.fetchAPI(r, o);
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
*
|
|
@@ -67,8 +67,8 @@ class v {
|
|
|
67
67
|
error: { message: "Invalid page uuid" },
|
|
68
68
|
result: "error"
|
|
69
69
|
});
|
|
70
|
-
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }),
|
|
71
|
-
return this.fetchAPI(s,
|
|
70
|
+
const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), a = { method: "DELETE", headers: e };
|
|
71
|
+
return this.fetchAPI(s, a);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
*
|
|
@@ -76,8 +76,8 @@ class v {
|
|
|
76
76
|
* @returns Update page information or Error response
|
|
77
77
|
*/
|
|
78
78
|
async updatePage(t) {
|
|
79
|
-
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("page"),
|
|
80
|
-
return this.fetchAPI(r,
|
|
79
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("page"), o = { method: "PUT", headers: s, body: e };
|
|
80
|
+
return this.fetchAPI(r, o);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
*
|
|
@@ -93,8 +93,8 @@ class v {
|
|
|
93
93
|
* @returns Updated project detail
|
|
94
94
|
*/
|
|
95
95
|
async updateProject(t) {
|
|
96
|
-
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("project"),
|
|
97
|
-
return this.fetchAPI(r,
|
|
96
|
+
const e = JSON.stringify(t), s = this.getHeaders(), r = this.getURL("project"), o = { method: "PUT", headers: s, body: e };
|
|
97
|
+
return this.fetchAPI(r, o);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
*
|
|
@@ -103,10 +103,10 @@ class v {
|
|
|
103
103
|
* @param req
|
|
104
104
|
*/
|
|
105
105
|
async uploadAsset(t) {
|
|
106
|
-
const e = this.getHeaders(), s = this.getURL("asset"), r = "POST",
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
return this.fetchAPI(s,
|
|
106
|
+
const e = this.getHeaders(), s = this.getURL("asset"), r = "POST", a = await t.get("file"), o = new FormData();
|
|
107
|
+
o.append("file", a);
|
|
108
|
+
const c = { method: r, headers: e, body: o };
|
|
109
|
+
return this.fetchAPI(s, c);
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
*
|
|
@@ -117,8 +117,8 @@ class v {
|
|
|
117
117
|
async getAssets(t, e) {
|
|
118
118
|
const s = this.getHeaders(), r = this.getURL("asset");
|
|
119
119
|
t && r.concat(`?limit=${t}`), e && r.concat(`&offset=${e}`);
|
|
120
|
-
const
|
|
121
|
-
return this.fetchAPI(r,
|
|
120
|
+
const o = { method: "GET", headers: s };
|
|
121
|
+
return this.fetchAPI(r, o);
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
*
|
|
@@ -126,8 +126,8 @@ class v {
|
|
|
126
126
|
* @returns { token }
|
|
127
127
|
*/
|
|
128
128
|
async authenticate({ password: t }) {
|
|
129
|
-
const e = JSON.stringify({ password: t }), s = this.getHeaders(), r = this.getURL("authenticate"),
|
|
130
|
-
return this.fetchAPI(r,
|
|
129
|
+
const e = JSON.stringify({ password: t }), s = this.getHeaders(), r = this.getURL("authenticate"), o = { method: "POST", headers: s, body: e };
|
|
130
|
+
return this.fetchAPI(r, o);
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
*
|
|
@@ -135,8 +135,8 @@ class v {
|
|
|
135
135
|
* @returns { result: 'success' | 'error' }
|
|
136
136
|
*/
|
|
137
137
|
async verify(t) {
|
|
138
|
-
const e = JSON.stringify({ token: t }), s = this.getHeaders(), r = this.getURL("verify"),
|
|
139
|
-
return this.fetchAPI(r,
|
|
138
|
+
const e = JSON.stringify({ token: t }), s = this.getHeaders(), r = this.getURL("verify"), o = { method: "POST", headers: s, body: e };
|
|
139
|
+
return this.fetchAPI(r, o);
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
*
|
|
@@ -146,7 +146,7 @@ class v {
|
|
|
146
146
|
*/
|
|
147
147
|
getURL(t, e) {
|
|
148
148
|
const s = new URLSearchParams(e).toString();
|
|
149
|
-
return
|
|
149
|
+
return i(e) ? `${d}/v1/${t}` : `${d}/v1/${t}?${s}`;
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
*
|
|
@@ -171,15 +171,15 @@ class v {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
const U = async (n) => {
|
|
175
|
-
const
|
|
176
|
-
for (const o of
|
|
174
|
+
const U = async (n, t) => {
|
|
175
|
+
const e = y(), s = p(e, (o) => l(n, "providerKey").includes(o.providerKey)), r = {}, a = [];
|
|
176
|
+
for (const o of s)
|
|
177
177
|
try {
|
|
178
|
-
|
|
179
|
-
} catch (
|
|
180
|
-
|
|
178
|
+
r[o.providerKey] = await o.dataFn({}, t);
|
|
179
|
+
} catch (c) {
|
|
180
|
+
a.push(c);
|
|
181
181
|
}
|
|
182
|
-
return { data:
|
|
182
|
+
return { data: r, errors: a };
|
|
183
183
|
};
|
|
184
184
|
export {
|
|
185
185
|
v as ChaibuilderBackend,
|
|
@@ -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-725e3191.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-d1a25967.js";
|
|
11
11
|
import "@radix-ui/react-slot";
|
|
12
12
|
import "class-variance-authority";
|
|
13
13
|
import "./utils-ac68b2c8.js";
|
|
@@ -42,7 +42,7 @@ import "himalaya";
|
|
|
42
42
|
import "redux-undo";
|
|
43
43
|
import "@react-hookz/web";
|
|
44
44
|
import "lucide-react";
|
|
45
|
-
const O = y.lazy(() => import("./delete-page-modal-
|
|
45
|
+
const O = y.lazy(() => import("./delete-page-modal-afc5ac26.js")), J = y.lazy(() => import("./confirm-alert-f2a47cc7.js")), x = (n) => {
|
|
46
46
|
if (!z(n) || !(n.includes("/[") && n.includes("]")))
|
|
47
47
|
return !1;
|
|
48
48
|
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-5e57d0c8.cjs"),w=require("./scroll-area-bb343b86.cjs"),d=require("@chaibuilder/blocks"),L=require("sonner"),p=require("./form-99b51245.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-5e57d0c8.cjs"),w=require("./scroll-area-bb343b86.cjs"),d=require("@chaibuilder/blocks"),L=require("sonner"),p=require("./form-99b51245.cjs"),P=require("./index-cbeea3bc.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-86ac8848.cjs");require("react-icons-picker");require("react-dom");require("./dialog-170eaad9.cjs");require("@radix-ui/react-dialog");require("./ImagesPanel-0db5c72f.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-8cfafe5d.cjs"))),B=g.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-4f50caa7.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;
|