@chaibuilder/sdk 1.0.19 → 1.0.21

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.
Files changed (98) hide show
  1. package/dist/{AddBlocks-eoo1CzaK.js → AddBlocks-0-e393Fn.js} +29 -27
  2. package/dist/AddBlocks-p68Cz79o.cjs +3 -0
  3. package/dist/BrandingOptions-HtNCJO9_.cjs +1 -0
  4. package/dist/{BrandingOptions-1zbCs5bl.js → BrandingOptions-QqqJ-YRb.js} +15 -22
  5. package/dist/{CanvasArea-Mpb5yTgf.js → CanvasArea-0hMAhzxn.js} +15 -14
  6. package/dist/{CanvasArea-AsL1cGRZ.cjs → CanvasArea-pZz5czrV.cjs} +4 -4
  7. package/dist/{CurrentPage-ddbm_deC.js → CurrentPage-UOkxZISs.js} +16 -15
  8. package/dist/CurrentPage-phMDH1Ub.cjs +1 -0
  9. package/dist/Layers-NKZXi2LV.cjs +1 -0
  10. package/dist/{Layers-3UtlSah_.js → Layers-TB-Lriju.js} +18 -17
  11. package/dist/MODIFIERS-MLfpKQY1.js +73 -0
  12. package/dist/MODIFIERS-WFzDQfiT.cjs +1 -0
  13. package/dist/MarkAsGlobalBlock-5h3wP4zj.cjs +1 -0
  14. package/dist/{MarkAsGlobalBlock-ySc-D4SB.js → MarkAsGlobalBlock-Pa8po8qP.js} +11 -10
  15. package/dist/PagesPanel-ffrNyFyp.cjs +1 -0
  16. package/dist/{PagesPanel-nLcJD9CK.js → PagesPanel-mAMSbYPt.js} +20 -19
  17. package/dist/ProjectPanel-1ywILLme.cjs +1 -0
  18. package/dist/{ProjectPanel-sFE2KDi-.js → ProjectPanel-XvsYajju.js} +17 -16
  19. package/dist/{Settings-UOB68lg0.js → Settings-8AbHXcDP.js} +98 -96
  20. package/dist/Settings-hdmnT_mI.cjs +1 -0
  21. package/dist/{SidePanels-IFF2nXXZ.js → SidePanels-LQg3mdC4.js} +28 -27
  22. package/dist/SidePanels-xaNrI3oK.cjs +1 -0
  23. package/dist/Topbar-A3WZDrK4.cjs +1 -0
  24. package/dist/{Topbar-lX9OMPwj.js → Topbar-wA6jhMj9.js} +27 -26
  25. package/dist/UnsplashImages-E8zPMgJf.cjs +1 -0
  26. package/dist/{UnsplashImages-u_QTABzi.js → UnsplashImages-mzIO1QeT.js} +9 -8
  27. package/dist/UploadImages-qEuDUEMn.cjs +1 -0
  28. package/dist/{UploadImages-gV5xDHIu.js → UploadImages-qMeaY4sk.js} +9 -8
  29. package/dist/add-page-modal-9deiA1W9.cjs +1 -0
  30. package/dist/{add-page-modal-1z_f7PxL.js → add-page-modal-oER3yE4F.js} +21 -19
  31. package/dist/{confirm-alert-ZQ-sxX0X.js → confirm-alert-rDSai_jQ.js} +10 -9
  32. package/dist/confirm-alert-tH8UCCSF.cjs +1 -0
  33. package/dist/controls-G0puEH71.js +120 -0
  34. package/dist/controls-aHZq-q4b.cjs +1 -0
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.js +72 -71
  37. package/dist/{delete-page-modal-OnKk3P5L.js → delete-page-modal-QzQdrLYI.js} +22 -21
  38. package/dist/delete-page-modal-ShTRkqkB.cjs +1 -0
  39. package/dist/{form-Osm1AmO5.cjs → form-MlgUSEy_.cjs} +1 -1
  40. package/dist/{form-zZJyZuNH.js → form-vWeEsG9Y.js} +2 -2
  41. package/dist/functions-eu6BbvqO.cjs +2 -0
  42. package/dist/functions-hmbWDcnW.js +1108 -0
  43. package/dist/{index-2EHcmZqL.js → index-G55KtqnU.js} +191 -190
  44. package/dist/index-T5MFAHA0.cjs +1 -0
  45. package/dist/{index-2-Cf7p7w.js → index-mLIwGF5W.js} +5439 -5429
  46. package/dist/{index-vKSUqeQx.cjs → index-pCHSFoQO.cjs} +44 -44
  47. package/dist/{jsx-runtime-qAwJ85SY.js → jsx-runtime-NV737rRe.js} +1 -1
  48. package/dist/{jsx-runtime-WKRPbKtm.cjs → jsx-runtime-WUGKV8jN.cjs} +6 -6
  49. package/dist/lib.cjs +1 -2
  50. package/dist/lib.js +116 -1208
  51. package/dist/page-viewer-GPNN1H92.cjs +1 -0
  52. package/dist/{page-viewer-d2r9KEIw.js → page-viewer-X3IEOrUC.js} +18 -17
  53. package/dist/project-general-setting-HZeYf9A1.cjs +1 -0
  54. package/dist/{project-general-setting--Qu-QJlM.js → project-general-setting-oujmeWOG.js} +22 -20
  55. package/dist/project-seo-setting-3FZQXaTn.cjs +1 -0
  56. package/dist/{project-seo-setting-v6l-AbZS.js → project-seo-setting-_X6ckVa4.js} +17 -24
  57. package/dist/render.cjs +1 -1
  58. package/dist/render.js +39 -43
  59. package/dist/server.cjs +1 -1
  60. package/dist/server.js +1 -1
  61. package/dist/single-page-detail-ILshOKys.cjs +1 -0
  62. package/dist/{single-page-detail-olLc2XXk.js → single-page-detail-SxboE7TI.js} +47 -45
  63. package/dist/studio.cjs +1 -1
  64. package/dist/studio.js +20 -19
  65. package/dist/ui.cjs +1 -1
  66. package/dist/ui.d.ts +4 -4
  67. package/dist/ui.js +145 -144
  68. package/dist/utils-It2K33fU.cjs +1 -0
  69. package/dist/{Class-nQk08vqd.js → utils-PPBbw5bk.js} +115 -183
  70. package/package.json +2 -7
  71. package/dist/AddBlocks-jU0NwP_s.cjs +0 -3
  72. package/dist/BrandingOptions-DXAH3zCN.cjs +0 -1
  73. package/dist/Class-RZuPYbUS.cjs +0 -1
  74. package/dist/CurrentPage-VYXjpKJ-.cjs +0 -1
  75. package/dist/Layers-cUeI3Uhq.cjs +0 -1
  76. package/dist/MarkAsGlobalBlock-lYL8cO9x.cjs +0 -1
  77. package/dist/PagesPanel-iFpq7X9a.cjs +0 -1
  78. package/dist/ProjectPanel-Nq_fot83.cjs +0 -1
  79. package/dist/Settings-jiWn1Oof.cjs +0 -1
  80. package/dist/SidePanels-JhPtKGnL.cjs +0 -1
  81. package/dist/Topbar-qi5ab8rR.cjs +0 -1
  82. package/dist/UnsplashImages-a2r7b3kB.cjs +0 -1
  83. package/dist/UploadImages-jLQgLujd.cjs +0 -1
  84. package/dist/add-page-modal-iRSIjkvI.cjs +0 -1
  85. package/dist/blocks.cjs +0 -1
  86. package/dist/blocks.d.ts +0 -4
  87. package/dist/blocks.js +0 -20
  88. package/dist/confirm-alert-z74-fGOT.cjs +0 -1
  89. package/dist/delete-page-modal-a3Tb8T6e.cjs +0 -1
  90. package/dist/index-XvLiA8z7.js +0 -1191
  91. package/dist/index-c8zW_D2V.cjs +0 -1
  92. package/dist/index-fwo4wa7u.cjs +0 -1
  93. package/dist/index-gmZcUXyn.js +0 -25
  94. package/dist/index-l9moYwFE.cjs +0 -9
  95. package/dist/page-viewer-9OzvKHZd.cjs +0 -1
  96. package/dist/project-general-setting-15WMnfLc.cjs +0 -1
  97. package/dist/project-seo-setting-PvLLVhvk.cjs +0 -1
  98. package/dist/single-page-detail-jIi5lRLh.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-WUGKV8jN.cjs"),t=require("react"),n=require("@radix-ui/react-icons"),o=require("./index-T5MFAHA0.cjs"),x=require("./index-pCHSFoQO.cjs");require("./MODIFIERS-WFzDQfiT.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("lodash");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("react-i18next");require("i18next");require("@floating-ui/react-dom");require("react-textarea-autosize");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("./lib.cjs");require("himalaya");require("./functions-eu6BbvqO.cjs");require("@mhsdesign/jit-browser-tailwindcss");require("@bobthered/tailwindcss-palette-generator");require("@tailwindcss/forms");require("@tailwindcss/typography");require("@tailwindcss/aspect-ratio");require("@tailwindcss/line-clamp");require("react-hotkeys-hook");require("sonner");require("lucide-react");const q=t.lazy(()=>Promise.resolve().then(()=>require("./single-page-detail-ILshOKys.cjs"))),m=({pageData:s})=>{const[r,i]=t.useState("CLOSE");return e.jsxRuntimeExports.jsxs(o.Popover,{open:r==="OPEN"||r==="ALERT"||r==="PENDING",onOpenChange:u=>{i(r==="PENDING"?"ALERT":u?"OPEN":"CLOSE")},children:[e.jsxRuntimeExports.jsx(o.PopoverTrigger,{asChild:!0,onClick:u=>{u.stopPropagation(),i("OPEN")},children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:r==="OPEN"||r==="ALERT"||r==="PENDING"?e.jsxRuntimeExports.jsx(n.ChevronRightIcon,{}):e.jsxRuntimeExports.jsx("div",{className:"hidden hover:text-blue-600 group-hover:flex",children:e.jsxRuntimeExports.jsx(n.GearIcon,{})})})}),e.jsxRuntimeExports.jsx(o.PopoverContent,{side:"right",align:"start",alignOffset:-35,className:"h-screen w-96",children:e.jsxRuntimeExports.jsx(t.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(q,{pageData:s,open:r,setOpen:i})})})]})},j=s=>{const[r]=x.useCurrentPage(),{data:i}=x.useProject(),u=x.useChangePage(),l=(i==null?void 0:i.homepage)===s.uuid,a=r===s.uuid,c=()=>u(s);return i?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(n.HomeIcon,{}):e.jsxRuntimeExports.jsx(n.FileTextIcon,{})," ",s.name]}),e.jsxRuntimeExports.jsx(m,{pageData:s})]}):null},p=({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:t.Children.toArray(s.map(i=>e.jsxRuntimeExports.jsx(j,{...i})))});exports.default=p;
@@ -1,14 +1,15 @@
1
- import { j as e } from "./jsx-runtime-qAwJ85SY.js";
1
+ import { j as e } from "./jsx-runtime-NV737rRe.js";
2
2
  import s, { useState as n, Suspense as l } from "react";
3
3
  import { ChevronRightIcon as c, GearIcon as u, HomeIcon as d, FileTextIcon as x } from "@radix-ui/react-icons";
4
- import { b1 as g, b2 as h, b3 as f } from "./index-2EHcmZqL.js";
5
- import { e as j, b, d as N } from "./index-2-Cf7p7w.js";
6
- import "./Class-nQk08vqd.js";
7
- import "clsx";
8
- import "tailwind-merge";
9
- import "lodash";
4
+ import { b1 as g, b2 as h, b3 as f } from "./index-G55KtqnU.js";
5
+ import { e as j, b, d as N } from "./index-mLIwGF5W.js";
6
+ import "./MODIFIERS-MLfpKQY1.js";
10
7
  import "@radix-ui/react-toggle";
11
8
  import "class-variance-authority";
9
+ import "./utils-PPBbw5bk.js";
10
+ import "lodash";
11
+ import "clsx";
12
+ import "tailwind-merge";
12
13
  import "@radix-ui/react-switch";
13
14
  import "@radix-ui/react-slot";
14
15
  import "@radix-ui/react-accordion";
@@ -33,28 +34,28 @@ import "react-quill";
33
34
  import "jotai";
34
35
  import "flat-to-nested";
35
36
  import "redux-undo";
36
- import "./index-gmZcUXyn.js";
37
+ import "@chaibuilder/runtime";
37
38
  import "@react-hookz/web";
38
39
  import "react-i18next";
39
40
  import "i18next";
40
- import "./index-XvLiA8z7.js";
41
+ import "@floating-ui/react-dom";
42
+ import "react-textarea-autosize";
43
+ import "flagged";
44
+ import "react-dnd";
45
+ import "@minoru/react-dnd-treeview";
41
46
  import "./lib.js";
42
47
  import "himalaya";
48
+ import "./functions-hmbWDcnW.js";
43
49
  import "@mhsdesign/jit-browser-tailwindcss";
44
50
  import "@bobthered/tailwindcss-palette-generator";
45
51
  import "@tailwindcss/forms";
46
52
  import "@tailwindcss/typography";
47
53
  import "@tailwindcss/aspect-ratio";
48
54
  import "@tailwindcss/line-clamp";
49
- import "@floating-ui/react-dom";
50
- import "react-textarea-autosize";
51
- import "flagged";
52
- import "react-dnd";
53
- import "@minoru/react-dnd-treeview";
54
55
  import "react-hotkeys-hook";
55
56
  import "sonner";
56
57
  import "lucide-react";
57
- const v = s.lazy(() => import("./single-page-detail-olLc2XXk.js")), P = ({ pageData: r }) => {
58
+ const v = s.lazy(() => import("./single-page-detail-SxboE7TI.js")), P = ({ pageData: r }) => {
58
59
  const [t, i] = n("CLOSE");
59
60
  return /* @__PURE__ */ e.jsxs(
60
61
  g,
@@ -106,11 +107,11 @@ const v = s.lazy(() => import("./single-page-detail-olLc2XXk.js")), P = ({ pageD
106
107
  ]
107
108
  }
108
109
  ) : null;
109
- }, ke = ({ pages: r, isLoading: t }) => t ? /* @__PURE__ */ e.jsxs("div", { className: "flex animate-pulse flex-col gap-y-1 px-2.5 pt-2", children: [
110
+ }, Oe = ({ pages: r, isLoading: t }) => t ? /* @__PURE__ */ e.jsxs("div", { className: "flex animate-pulse flex-col gap-y-1 px-2.5 pt-2", children: [
110
111
  /* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" }),
111
112
  /* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" }),
112
113
  /* @__PURE__ */ e.jsx("div", { className: "bg-background-200 h-7 w-full" })
113
114
  ] }) : r.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: s.Children.toArray(r.map((i) => /* @__PURE__ */ e.jsx(E, { ...i }))) });
114
115
  export {
115
- ke as default
116
+ Oe as default
116
117
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./jsx-runtime-WUGKV8jN.cjs"),a=require("react"),f=require("./index-T5MFAHA0.cjs"),o=require("./controls-aHZq-q4b.cjs"),d=require("./form-MlgUSEy_.cjs"),m=require("./index-pCHSFoQO.cjs");require("./MODIFIERS-WFzDQfiT.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("lodash");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("react-i18next");require("@rjsf/core");require("@rjsf/validator-ajv8");require("i18next");require("@floating-ui/react-dom");require("react-textarea-autosize");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("./lib.cjs");require("himalaya");require("./functions-eu6BbvqO.cjs");require("@mhsdesign/jit-browser-tailwindcss");require("@bobthered/tailwindcss-palette-generator");require("@tailwindcss/forms");require("@tailwindcss/typography");require("@tailwindcss/aspect-ratio");require("@tailwindcss/line-clamp");require("react-hotkeys-hook");require("sonner");require("lucide-react");function j(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 g=j(a),b=({_projectData:r,seany:i})=>{const{data:e,isLoading:u}=m.useProject();g.useEffect(()=>{e&&i(e)},[e,i]);const n=({formData:s},t)=>{i(l=>({...l,[t]:s[t]}))},c={name:o.u({title:"Project Name",default:e==null?void 0:e.name}),favicon:o.o({title:"Favicon",default:e==null?void 0:e.favicon})};return q.jsxRuntimeExports.jsx(f.ScrollArea,{className:"flex h-full select-none flex-col",children:q.jsxRuntimeExports.jsx(d.Form,{properties:c,disabled:u,formData:r,onChange:n})})};exports.default=b;
@@ -1,15 +1,16 @@
1
- import { j as i } from "./jsx-runtime-qAwJ85SY.js";
1
+ import { j as i } from "./jsx-runtime-NV737rRe.js";
2
2
  import * as l from "react";
3
- import { bp as n } from "./index-2EHcmZqL.js";
4
- import { u as c, o as u } from "./index-XvLiA8z7.js";
5
- import { F as d } from "./form-zZJyZuNH.js";
6
- import { b as x } from "./index-2-Cf7p7w.js";
7
- import "./Class-nQk08vqd.js";
8
- import "clsx";
9
- import "tailwind-merge";
10
- import "lodash";
3
+ import { bp as n } from "./index-G55KtqnU.js";
4
+ import { u as c, o as u } from "./controls-G0puEH71.js";
5
+ import { F as d } from "./form-vWeEsG9Y.js";
6
+ import { b as x } from "./index-mLIwGF5W.js";
7
+ import "./MODIFIERS-MLfpKQY1.js";
11
8
  import "@radix-ui/react-toggle";
12
9
  import "class-variance-authority";
10
+ import "./utils-PPBbw5bk.js";
11
+ import "lodash";
12
+ import "clsx";
13
+ import "tailwind-merge";
13
14
  import "@radix-ui/react-switch";
14
15
  import "@radix-ui/react-slot";
15
16
  import "@radix-ui/react-accordion";
@@ -35,17 +36,9 @@ import "react-quill";
35
36
  import "jotai";
36
37
  import "flat-to-nested";
37
38
  import "redux-undo";
38
- import "./index-gmZcUXyn.js";
39
+ import "@chaibuilder/runtime";
39
40
  import "@react-hookz/web";
40
41
  import "react-i18next";
41
- import "./lib.js";
42
- import "himalaya";
43
- import "@mhsdesign/jit-browser-tailwindcss";
44
- import "@bobthered/tailwindcss-palette-generator";
45
- import "@tailwindcss/forms";
46
- import "@tailwindcss/typography";
47
- import "@tailwindcss/aspect-ratio";
48
- import "@tailwindcss/line-clamp";
49
42
  import "@rjsf/core";
50
43
  import "@rjsf/validator-ajv8";
51
44
  import "i18next";
@@ -54,10 +47,19 @@ import "react-textarea-autosize";
54
47
  import "flagged";
55
48
  import "react-dnd";
56
49
  import "@minoru/react-dnd-treeview";
50
+ import "./lib.js";
51
+ import "himalaya";
52
+ import "./functions-hmbWDcnW.js";
53
+ import "@mhsdesign/jit-browser-tailwindcss";
54
+ import "@bobthered/tailwindcss-palette-generator";
55
+ import "@tailwindcss/forms";
56
+ import "@tailwindcss/typography";
57
+ import "@tailwindcss/aspect-ratio";
58
+ import "@tailwindcss/line-clamp";
57
59
  import "react-hotkeys-hook";
58
60
  import "sonner";
59
61
  import "lucide-react";
60
- const vo = ({
62
+ const Ro = ({
61
63
  _projectData: m,
62
64
  seany: t
63
65
  }) => {
@@ -80,5 +82,5 @@ const vo = ({
80
82
  return /* @__PURE__ */ i.jsx(n, { className: "flex h-full select-none flex-col", children: /* @__PURE__ */ i.jsx(d, { properties: a, disabled: p, formData: m, onChange: e }) });
81
83
  };
82
84
  export {
83
- vo as default
85
+ Ro as default
84
86
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./jsx-runtime-WUGKV8jN.cjs"),i=require("./controls-aHZq-q4b.cjs"),g=require("./form-MlgUSEy_.cjs");require("./MODIFIERS-WFzDQfiT.cjs");require("react");require("lodash");require("@rjsf/core");require("@rjsf/validator-ajv8");require("./index-T5MFAHA0.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("react-i18next");const D=({_projectData:e,seany:n})=>{var t,u,o,s,q,a;const d=({formData:f})=>{const r={...f};r.seoData.title===void 0&&(r.seoData.title=""),r.seoData.description===void 0&&(r.seoData.description=""),r.seoData.image===void 0&&(r.seoData.image=""),n(m=>({...m,...r}))},c={seoData:i.b({title:"",default:{title:((t=e.seoData)==null?void 0:t.title)||"",description:((u=e.seoData)==null?void 0:u.description)||"",image:((o=e.seoData)==null?void 0:o.image)||""},properties:{title:i.u({title:"Default Title",default:((s=e.seoData)==null?void 0:s.title)||""}),description:i.g({title:"Default Description",default:((q=e.seoData)==null?void 0:q.description)||""}),image:i.o({title:"Social Media Image",default:((a=e.seoData)==null?void 0:a.image)||""})}})};return l.jsxRuntimeExports.jsx("div",{className:"flex h-full select-none flex-col",children:l.jsxRuntimeExports.jsx(g.Form,{properties:c,formData:e,onChange:d})})};exports.default=D;
@@ -1,29 +1,21 @@
1
- import { j as s } from "./jsx-runtime-qAwJ85SY.js";
2
- import { b as D, u as c, g, o as x } from "./index-XvLiA8z7.js";
3
- import { F as v } from "./form-zZJyZuNH.js";
4
- import "./Class-nQk08vqd.js";
5
- import "clsx";
6
- import "tailwind-merge";
7
- import "lodash";
1
+ import { j as s } from "./jsx-runtime-NV737rRe.js";
2
+ import { b as D, u as c, g, o as x } from "./controls-G0puEH71.js";
3
+ import { F as v } from "./form-vWeEsG9Y.js";
4
+ import "./MODIFIERS-MLfpKQY1.js";
8
5
  import "react";
9
- import "./index-gmZcUXyn.js";
10
- import "@radix-ui/react-icons";
11
- import "./lib.js";
12
- import "himalaya";
13
- import "@mhsdesign/jit-browser-tailwindcss";
14
- import "@bobthered/tailwindcss-palette-generator";
15
- import "@tailwindcss/forms";
16
- import "@tailwindcss/typography";
17
- import "@tailwindcss/aspect-ratio";
18
- import "@tailwindcss/line-clamp";
6
+ import "lodash";
19
7
  import "@rjsf/core";
20
8
  import "@rjsf/validator-ajv8";
21
- import "./index-2EHcmZqL.js";
9
+ import "./index-G55KtqnU.js";
22
10
  import "@radix-ui/react-toggle";
23
11
  import "class-variance-authority";
12
+ import "./utils-PPBbw5bk.js";
13
+ import "clsx";
14
+ import "tailwind-merge";
24
15
  import "@radix-ui/react-switch";
25
16
  import "@radix-ui/react-slot";
26
17
  import "@radix-ui/react-accordion";
18
+ import "@radix-ui/react-icons";
27
19
  import "@radix-ui/react-alert-dialog";
28
20
  import "@radix-ui/react-dialog";
29
21
  import "@radix-ui/react-label";
@@ -45,13 +37,14 @@ import "react-quill";
45
37
  import "jotai";
46
38
  import "flat-to-nested";
47
39
  import "redux-undo";
40
+ import "@chaibuilder/runtime";
48
41
  import "@react-hookz/web";
49
42
  import "react-i18next";
50
- const Dt = ({
43
+ const at = ({
51
44
  _projectData: t,
52
45
  seany: l
53
46
  }) => {
54
- var o, r, m, e, p, a;
47
+ var o, e, r, m, p, a;
55
48
  const n = ({ formData: f }) => {
56
49
  const i = { ...f };
57
50
  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) => ({
@@ -63,13 +56,13 @@ const Dt = ({
63
56
  title: "",
64
57
  default: {
65
58
  title: ((o = t.seoData) == null ? void 0 : o.title) || "",
66
- description: ((r = t.seoData) == null ? void 0 : r.description) || "",
67
- image: ((m = t.seoData) == null ? void 0 : m.image) || ""
59
+ description: ((e = t.seoData) == null ? void 0 : e.description) || "",
60
+ image: ((r = t.seoData) == null ? void 0 : r.image) || ""
68
61
  },
69
62
  properties: {
70
63
  title: c({
71
64
  title: "Default Title",
72
- default: ((e = t.seoData) == null ? void 0 : e.title) || ""
65
+ default: ((m = t.seoData) == null ? void 0 : m.title) || ""
73
66
  }),
74
67
  description: g({
75
68
  title: "Default Description",
@@ -85,5 +78,5 @@ const Dt = ({
85
78
  return /* @__PURE__ */ s.jsx("div", { className: "flex h-full select-none flex-col", children: /* @__PURE__ */ s.jsx(v, { properties: d, formData: t, onChange: n }) });
86
79
  };
87
80
  export {
88
- Dt as default
81
+ at as default
89
82
  };
package/dist/render.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./jsx-runtime-WKRPbKtm.cjs"),x=require("react"),s=require("lodash"),S=require("tailwind-merge");require("./index-l9moYwFE.cjs");const l=require("./Class-RZuPYbUS.cjs"),R=require("./index-fwo4wa7u.cjs"),j=require("./lib.cjs"),_=require("react-wrap-balancer");require("@radix-ui/react-icons");require("clsx");require("himalaya");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=e=>{const n={};return Object.keys(e).forEach(t=>{s.isString(e[t])&&e[t].startsWith(l.SLOT_KEY)&&(n[t]=e[t].replace(l.SLOT_KEY,"").split(","))}),n},C=s.memoize((e,n)=>{const t=e.replace(l.STYLES_KEY,"").split(","),r=S.twMerge(t[0],t[1]);return j.addPrefixToClasses(r,n).replace(l.STYLES_KEY,"").trim()});function B(e,n){return s.get(e,`${n}_attrs`,{})}function O(e,n){const t={};return Object.keys(e).forEach(r=>{if(s.isString(e[r])&&e[r].startsWith(l.STYLES_KEY)){const o=C(e[r],n);t[r]={className:o,...B(e,r)}}}),t}function T(e,n){const t=s.get(e,"_bindings",{});return s.isEmpty(t)?{...e}:(s.each(t,(r,o)=>{s.isString(r)&&s.get(n,r,null)&&(e[o]=s.get(n,r,null))}),e)}function a({blocks:e,parent:n,classPrefix:t="c-",externalData:r={}}){const o=e,p=i=>O(i,t),h=n?s.filter(e,{_parent:n}):s.filter(e,i=>s.isEmpty(i._parent));return u.jsxRuntimeExports.jsx(u.jsxRuntimeExports.Fragment,{children:x.Children.toArray(h.map((i,f)=>{const d=y(i),m={};s.isEmpty(d)||Object.keys(d).forEach(c=>{m[c]=x.Children.toArray(d[c].map(E=>u.jsxRuntimeExports.jsx(a,{externalData:r,classPrefix:t,blocks:o,parent:E})))});const q=s.filter(o,{_parent:i._id});m.children=q.length>0?u.jsxRuntimeExports.jsx(a,{externalData:r,classPrefix:t,parent:i._id,blocks:o}):null;const g=R.h(i._type);if(g!==null){let c=i;const E=g.component;return c={...g.defaults,...i},x.createElement(E,s.omit({blockProps:{},inBuilder:!1,...c,index:f,...T(i,r),...p(c),...m},["_parent"]))}return u.jsxRuntimeExports.jsxs("noscript",{children:[i._type," not found"]})}))})}const Y=({pageData:e,externalData:n={},before:t=null,after:r=null,classPrefix:o="c-"})=>{const p=s.get(e.project,"brandingOptions",l.BRANDING_OPTIONS_DEFAULTS);return u.jsxRuntimeExports.jsxs(u.jsxRuntimeExports.Fragment,{children:[t,u.jsxRuntimeExports.jsx("div",{className:o.replace("-","")+" "+j.getBrandingClasses(p,o)+" min-h-screen",children:u.jsxRuntimeExports.jsx(_.Provider,{children:u.jsxRuntimeExports.jsx(a,{externalData:n,blocks:e.page.blocks||[],classPrefix:o})})}),r]})};exports.RenderChaiBlocks=a;exports.RenderChaiPage=Y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./jsx-runtime-WUGKV8jN.cjs"),j=require("react"),r=require("lodash"),R=require("tailwind-merge"),l=require("./MODIFIERS-WFzDQfiT.cjs"),_=require("@chaibuilder/runtime"),x=require("./functions-eu6BbvqO.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 s={};return Object.keys(t).forEach(e=>{r.isString(t[e])&&t[e].startsWith(l.SLOT_KEY)&&(s[e]=t[e].replace(l.SLOT_KEY,"").split(","))}),s},B=r.memoize((t,s)=>{const e=t.replace(l.STYLES_KEY,"").split(","),n=R.twMerge(e[0],e[1]);return x.addPrefixToClasses(n,s).replace(l.STYLES_KEY,"").trim()});function C(t,s){return r.get(t,`${s}_attrs`,{})}function O(t,s){const e={};return Object.keys(t).forEach(n=>{if(r.isString(t[n])&&t[n].startsWith(l.STYLES_KEY)){const o=B(t[n],s);e[n]={className:o,...C(t,n)}}}),e}function T(t,s){const e=r.get(t,"_bindings",{});return r.isEmpty(e)?{...t}:(r.each(e,(n,o)=>{r.isString(n)&&r.get(s,n,null)&&(t[o]=r.get(s,n,null))}),t)}function a({blocks:t,parent:s,classPrefix:e="c-",externalData:n={}}){const o=t,p=i=>O(i,e),f=s?r.filter(t,{_parent:s}):r.filter(t,i=>r.isEmpty(i._parent));return c.jsxRuntimeExports.jsx(c.jsxRuntimeExports.Fragment,{children:j.Children.toArray(f.map((i,h)=>{const d=y(i),m={};r.isEmpty(d)||Object.keys(d).forEach(u=>{m[u]=j.Children.toArray(d[u].map(E=>c.jsxRuntimeExports.jsx(a,{externalData:n,classPrefix:e,blocks:o,parent:E})))});const S=r.filter(o,{_parent:i._id});m.children=S.length>0?c.jsxRuntimeExports.jsx(a,{externalData:n,classPrefix:e,parent:i._id,blocks:o}):null;const g=_.getBlockComponent(i._type);if(g!==null){let u=i;const E=g.component;return u={...g.defaults,...i},j.createElement(E,r.omit({blockProps:{},inBuilder:!1,...u,index:h,...T(i,n),...p(u),...m},["_parent"]))}return c.jsxRuntimeExports.jsxs("noscript",{children:[i._type," not found"]})}))})}const Y=({pageData:t,externalData:s={},before:e=null,after:n=null,classPrefix:o="c-"})=>{const p=r.get(t.project,"brandingOptions",l.BRANDING_OPTIONS_DEFAULTS);return c.jsxRuntimeExports.jsxs(c.jsxRuntimeExports.Fragment,{children:[e,c.jsxRuntimeExports.jsx("div",{className:o.replace("-","")+" "+x.getBrandingClasses(p,o)+" min-h-screen",children:c.jsxRuntimeExports.jsx(q.Provider,{children:c.jsxRuntimeExports.jsx(a,{externalData:s,blocks:t.page.blocks||[],classPrefix:o})})}),n]})};exports.RenderChaiBlocks=a;exports.RenderChaiPage=Y;
package/dist/render.js CHANGED
@@ -1,15 +1,11 @@
1
- import { j as o } from "./jsx-runtime-qAwJ85SY.js";
1
+ import { j as o } from "./jsx-runtime-NV737rRe.js";
2
2
  import u from "react";
3
3
  import { isString as E, memoize as y, get as m, isEmpty as h, each as A, filter as g, omit as x } from "lodash";
4
4
  import { twMerge as N } from "tailwind-merge";
5
- import "./index-XvLiA8z7.js";
6
- import { S, a as _, B as R } from "./Class-nQk08vqd.js";
7
- import { h as T } from "./index-gmZcUXyn.js";
8
- import { addPrefixToClasses as F, getBrandingClasses as L } from "./lib.js";
5
+ import { S as B, a as _, B as R } from "./MODIFIERS-MLfpKQY1.js";
6
+ import { getBlockComponent as T } from "@chaibuilder/runtime";
7
+ import { a as F, g as L } from "./functions-hmbWDcnW.js";
9
8
  import { Provider as Y } from "react-wrap-balancer";
10
- import "@radix-ui/react-icons";
11
- import "clsx";
12
- import "himalaya";
13
9
  import "@mhsdesign/jit-browser-tailwindcss";
14
10
  import "@bobthered/tailwindcss-palette-generator";
15
11
  import "@tailwindcss/forms";
@@ -18,51 +14,51 @@ import "@tailwindcss/aspect-ratio";
18
14
  import "@tailwindcss/line-clamp";
19
15
  const I = (t) => {
20
16
  const s = {};
21
- return Object.keys(t).forEach((r) => {
22
- E(t[r]) && t[r].startsWith(S) && (s[r] = t[r].replace(S, "").split(","));
17
+ return Object.keys(t).forEach((n) => {
18
+ E(t[n]) && t[n].startsWith(B) && (s[n] = t[n].replace(B, "").split(","));
23
19
  }), s;
24
20
  }, K = y((t, s) => {
25
- const r = t.replace(_, "").split(","), n = N(r[0], r[1]);
26
- return F(n, s).replace(_, "").trim();
21
+ const n = t.replace(_, "").split(","), r = N(n[0], n[1]);
22
+ return F(r, s).replace(_, "").trim();
27
23
  });
28
24
  function W(t, s) {
29
25
  return m(t, `${s}_attrs`, {});
30
26
  }
31
27
  function w(t, s) {
32
- const r = {};
33
- return Object.keys(t).forEach((n) => {
34
- if (E(t[n]) && t[n].startsWith(_)) {
35
- const i = K(t[n], s);
36
- r[n] = {
28
+ const n = {};
29
+ return Object.keys(t).forEach((r) => {
30
+ if (E(t[r]) && t[r].startsWith(_)) {
31
+ const i = K(t[r], s);
32
+ n[r] = {
37
33
  className: i,
38
- ...W(t, n)
34
+ ...W(t, r)
39
35
  };
40
36
  }
41
- }), r;
37
+ }), n;
42
38
  }
43
39
  function z(t, s) {
44
- const r = m(t, "_bindings", {});
45
- return h(r) ? { ...t } : (A(r, (n, i) => {
46
- E(n) && m(s, n, null) && (t[i] = m(s, n, null));
40
+ const n = m(t, "_bindings", {});
41
+ return h(n) ? { ...t } : (A(n, (r, i) => {
42
+ E(r) && m(s, r, null) && (t[i] = m(s, r, null));
47
43
  }), t);
48
44
  }
49
45
  function j({
50
46
  blocks: t,
51
47
  parent: s,
52
- classPrefix: r = "c-",
53
- externalData: n = {}
48
+ classPrefix: n = "c-",
49
+ externalData: r = {}
54
50
  }) {
55
- const i = t, c = (e) => w(e, r), B = s ? g(t, { _parent: s }) : g(t, (e) => h(e._parent));
51
+ const i = t, a = (e) => w(e, n), S = s ? g(t, { _parent: s }) : g(t, (e) => h(e._parent));
56
52
  return /* @__PURE__ */ o.jsx(o.Fragment, { children: u.Children.toArray(
57
- B.map((e, C) => {
58
- const a = I(e), l = {};
59
- h(a) || Object.keys(a).forEach((p) => {
53
+ S.map((e, C) => {
54
+ const c = I(e), l = {};
55
+ h(c) || Object.keys(c).forEach((p) => {
60
56
  l[p] = u.Children.toArray(
61
- a[p].map((f) => /* @__PURE__ */ o.jsx(
57
+ c[p].map((f) => /* @__PURE__ */ o.jsx(
62
58
  j,
63
59
  {
64
- externalData: n,
65
- classPrefix: r,
60
+ externalData: r,
61
+ classPrefix: n,
66
62
  blocks: i,
67
63
  parent: f
68
64
  }
@@ -73,8 +69,8 @@ function j({
73
69
  l.children = O.length > 0 ? /* @__PURE__ */ o.jsx(
74
70
  j,
75
71
  {
76
- externalData: n,
77
- classPrefix: r,
72
+ externalData: r,
73
+ classPrefix: n,
78
74
  parent: e._id,
79
75
  blocks: i
80
76
  }
@@ -91,8 +87,8 @@ function j({
91
87
  inBuilder: !1,
92
88
  ...p,
93
89
  index: C,
94
- ...z(e, n),
95
- ...c(p),
90
+ ...z(e, r),
91
+ ...a(p),
96
92
  ...l
97
93
  },
98
94
  ["_parent"]
@@ -106,27 +102,27 @@ function j({
106
102
  })
107
103
  ) });
108
104
  }
109
- const nt = ({
105
+ const b = ({
110
106
  pageData: t,
111
107
  externalData: s = {},
112
- before: r = null,
113
- after: n = null,
108
+ before: n = null,
109
+ after: r = null,
114
110
  classPrefix: i = "c-"
115
111
  }) => {
116
- const c = m(t.project, "brandingOptions", R);
112
+ const a = m(t.project, "brandingOptions", R);
117
113
  return /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
118
- r,
114
+ n,
119
115
  /* @__PURE__ */ o.jsx(
120
116
  "div",
121
117
  {
122
- className: i.replace("-", "") + " " + L(c, i) + " min-h-screen",
118
+ className: i.replace("-", "") + " " + L(a, i) + " min-h-screen",
123
119
  children: /* @__PURE__ */ o.jsx(Y, { children: /* @__PURE__ */ o.jsx(j, { externalData: s, blocks: t.page.blocks || [], classPrefix: i }) })
124
120
  }
125
121
  ),
126
- n
122
+ r
127
123
  ] });
128
124
  };
129
125
  export {
130
126
  j as RenderChaiBlocks,
131
- nt as RenderChaiPage
127
+ b as RenderChaiPage
132
128
  };
package/dist/server.cjs CHANGED
@@ -1 +1 @@
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("./index-fwo4wa7u.cjs"),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(){const t=this.getHeaders(),e=this.getURL("verify"),r={method:"POST",headers:t};return this.fetchAPI(e,r)}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.A(),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;
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/runtime"),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(){const t=this.getHeaders(),e=this.getURL("verify"),r={method:"POST",headers:t};return this.fetchAPI(e,r)}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.js CHANGED
@@ -2,7 +2,7 @@ var g = Object.defineProperty;
2
2
  var u = (c, t, e) => t in c ? g(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
3
  var h = (c, t, e) => (u(c, typeof t != "symbol" ? t + "" : t, e), e);
4
4
  import { isEmpty as i, filter as l, map as p } from "lodash";
5
- import { A as m } from "./index-gmZcUXyn.js";
5
+ import { getChaiDataProviders as m } from "@chaibuilder/runtime";
6
6
  const d = "https://api.chaibuilder.com";
7
7
  class A {
8
8
  constructor(t, e) {
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./jsx-runtime-WUGKV8jN.cjs"),f=require("react"),c=require("lodash"),H=require("@radix-ui/react-icons"),y=require("./index-T5MFAHA0.cjs"),d=require("./controls-aHZq-q4b.cjs"),w=require("sonner"),p=require("./form-MlgUSEy_.cjs"),P=require("./index-pCHSFoQO.cjs");require("./MODIFIERS-WFzDQfiT.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-It2K33fU.cjs");require("clsx");require("tailwind-merge");require("@radix-ui/react-switch");require("@radix-ui/react-slot");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-menubar");require("@radix-ui/react-hover-card");require("@radix-ui/react-select");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("cmdk");require("@radix-ui/react-context-menu");require("react-icons-picker");require("react-dom");require("react-quill");require("jotai");require("flat-to-nested");require("redux-undo");require("@chaibuilder/runtime");require("@react-hookz/web");require("react-i18next");require("@rjsf/core");require("@rjsf/validator-ajv8");require("i18next");require("@floating-ui/react-dom");require("react-textarea-autosize");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("./lib.cjs");require("himalaya");require("./functions-eu6BbvqO.cjs");require("@mhsdesign/jit-browser-tailwindcss");require("@bobthered/tailwindcss-palette-generator");require("@tailwindcss/forms");require("@tailwindcss/typography");require("@tailwindcss/aspect-ratio");require("@tailwindcss/line-clamp");require("react-hotkeys-hook");require("lucide-react");const z=f.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-ShTRkqkB.cjs"))),L=f.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-tH8UCCSF.cjs"))),E=u=>{if(!c.isString(u)||!(u.includes("/[")&&u.includes("]")))return!1;const s=/^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/,q=/^[a-zA-Z0-9_-]+$/;let e=!0;return u.split("/").forEach(n=>{e&&(n.includes("[[")&&n.includes("]]")?e=/^\[\[\.{3}[a-zA-Z0-9_-]+\]\]$/.test(n):n.includes("[")&&n.includes("]")?e=s.test(n):e=q.test(n))}),e},h=u=>u&&c.isEmpty(u.seoData)?{...u,seoData:{title:"",description:"",image:""}}:u,G=(u,o)=>{const s=!c.isEqual(c.omit(u,["seoData"]),c.omit(o,["seoData"])),q=!c.isEqual(h(o).seoData,h(u).seoData);return s||q},Y=({open:u,setOpen:o,pageData:s})=>{const q=P.useQueryClient(),{data:e}=P.useProject(),n=P.useUpdatePage(),m=P.useUpdateProject("Homepage updated successfully."),[i,b]=f.useState(h(s)),[a,A]=f.useState({isHomePage:(e==null?void 0:e.homepage)===s.uuid}),j=G(i,s);f.useEffect(()=>{const l=!c.isEqual(h(s),i),t=(e==null?void 0:e.homepage)!==s.uuid&&a.isHomePage;o(l||t?"PENDING":"OPEN")},[e,s,i,a,o]);const C=()=>{if(j){if(s.type==="DYNAMIC"&&!E((i==null?void 0:i.slug)||"")){u==="ALERT"&&o("PENDING");return}n.mutate(i,{onSuccess:()=>{q.invalidateQueries({refetchType:"active",queryKey:["pages",e==null?void 0:e.uuid]}),o("CLOSE"),w.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")})},R=({formData:l},t)=>{b(g=>{var S,N;if(!t)return g;const x={[t]:l[t]};return t==="name"?x.slug=c.kebabCase((S=l[t])==null?void 0:S.replace(/\d/g,"")):t==="slug"?x.slug=(N=l[t])==null?void 0:N.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):t==="seoData"&&(x.seoData={title:l[t].title||"",description:l[t].description||"",image:l[t].image||""}),{...g,...x}})},I=({formData:l},t)=>{A(g=>{const x={[t]:l[t]};return{...g,...x}})},v={name:d.u({title:"Page Name",default:i.name}),slug:d.u({title:"Page Slug",default:i.slug})},T={seoData:d.b({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.u({title:"Meta Title",default:i.name}),description:d.g({title:"Meta Description",default:i.slug}),image:d.o({title:"Social Media Image",default:""})}})},M={isHomePage:d.r({title:"Set as homepage",default:a.isHomePage})};return r.jsxRuntimeExports.jsxs(y.ScrollArea,{className:"flex h-full select-none flex-col",children:[r.jsxRuntimeExports.jsx(L,{open:u==="ALERT",title:"Do yo want to save changes?",onCancel:()=>o("CLOSE"),onConfirm:C,disabled:m.isPending||n.isPending}),r.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 px-2.5 py-1",children:r.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:"Page Details"})}),r.jsxRuntimeExports.jsx("div",{className:"px-2.5 pt-2",children:r.jsxRuntimeExports.jsxs("div",{className:"flex flex-col space-y-2",children:[r.jsxRuntimeExports.jsx(p.Form,{title:"Basic Details",formData:i,properties:v,onChange:R,disabled:n.isPending||m.isPending}),r.jsxRuntimeExports.jsx("div",{className:"h-2 w-full"}),r.jsxRuntimeExports.jsx(p.Form,{title:"SEO Details",formData:i,properties:T,onChange:R,disabled:n.isPending||m.isPending}),(e==null?void 0:e.homepage)!==s.uuid&&s.type==="STATIC"?r.jsxRuntimeExports.jsx(p.Form,{formData:a,properties:M,onChange:I,disabled:n.isPending||m.isPending}):s.type==="STATIC"&&r.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-1 px-1 pt-2 text-xs font-medium text-gray-500",children:[r.jsxRuntimeExports.jsx(H.HomeIcon,{})," This is homepage"," "]}),i.type==="DYNAMIC"&&!E((i==null?void 0:i.slug)||"")&&r.jsxRuntimeExports.jsxs("small",{className:"px-1 text-red-400",children:["Add dynamic ID in page slug Eg: ",r.jsxRuntimeExports.jsx("i",{className:"underline",children:"some-url/[some-id]"})]}),r.jsxRuntimeExports.jsxs("div",{className:"my-2 flex w-full items-center justify-between gap-x-2 px-1",children:[r.jsxRuntimeExports.jsx(y.Button,{className:"w-full",type:"submit",onClick:C,disabled:(e==null?void 0:e.homepage)!==s.uuid&&a.isHomePage?!1:c.isEmpty(i.name)||c.isEmpty(i.slug)||!j||n.isPending||m.isPending||i.type==="DYNAMIC"&&!E((i==null?void 0:i.slug)||""),children:"Save"}),r.jsxRuntimeExports.jsx(z,{pageData:s,projectData:e})]})]})})]})};exports.default=Y;