@chaibuilder/sdk 1.2.64 → 1.2.66

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 (139) hide show
  1. package/dist/AddBlocks-Mm5byzEC.js +124 -0
  2. package/dist/AddBlocks-jaxiAG4L.cjs +1 -0
  3. package/dist/CanvasArea-8NXGRRYC.js +137 -0
  4. package/dist/CanvasArea-SkeoJz9W.cjs +1 -0
  5. package/dist/{CodeEditor-37od44Ou.js → CodeEditor-3l-mFvg4.js} +61 -46
  6. package/dist/CodeEditor-o-CkvDnY.cjs +1 -0
  7. package/dist/STRINGS--j49GZJP.js +7 -0
  8. package/dist/STRINGS-gPz7CUOk.cjs +1 -0
  9. package/dist/SettingsPanel-2uYGx-MQ.cjs +1 -0
  10. package/dist/SettingsPanel-Q3xQQm81.js +82 -0
  11. package/dist/{SidePanels-UQj0XTnb.js → SidePanels-JyziIpDA.js} +125 -116
  12. package/dist/SidePanels-d04PONzN.cjs +1 -0
  13. package/dist/{Topbar-1O05wogM.js → Topbar-Xgd6YI66.js} +68 -57
  14. package/dist/Topbar-eIenyfZu.cjs +1 -0
  15. package/dist/UILibrariesPanel-ADjJse3_.cjs +1 -0
  16. package/dist/{UILibrariesPanel-vshiYI6G.js → UILibrariesPanel-a7TrMuAU.js} +98 -86
  17. package/dist/{UnsplashImages-Eq7hprBO.js → UnsplashImages-6Bj8nQ8n.js} +65 -49
  18. package/dist/UnsplashImages-hLdMtY12.cjs +1 -0
  19. package/dist/{UploadImages-lco2Tea3.js → UploadImages-4PxhlZMB.js} +58 -44
  20. package/dist/UploadImages-uL2R7fju.cjs +1 -0
  21. package/dist/badge-7BVT3zxN.cjs +1 -0
  22. package/dist/badge-pJqQSA13.js +23 -0
  23. package/dist/context-menu-_8TFbFEJ.cjs +1 -0
  24. package/dist/context-menu-sks9vdzC.js +906 -0
  25. package/dist/core.cjs +1 -1
  26. package/dist/core.d.ts +45 -21
  27. package/dist/core.js +93 -79
  28. package/dist/iconBase-vJD0OXxU.cjs +1 -0
  29. package/dist/iconBase-zweRWSz0.js +323 -0
  30. package/dist/index-Dgo2PNEV.js +33210 -0
  31. package/dist/index-jhNzBWrV.cjs +223 -0
  32. package/dist/jsx-runtime-JYMCiFoE.cjs +27 -0
  33. package/dist/{jsx-runtime-WbnYoNE9.js → jsx-runtime-Sp0orL4X.js} +106 -109
  34. package/dist/plugin-P0tpo_XZ.cjs +1 -0
  35. package/dist/plugin-_F-KZp1i.cjs +1 -0
  36. package/dist/plugin-f5uJtdXY.js +43 -0
  37. package/dist/plugin-sJ3Hzvpv.js +57 -0
  38. package/dist/render.cjs +3 -1
  39. package/dist/render.d.ts +19 -52
  40. package/dist/render.js +136 -183
  41. package/dist/select-JW3OMYm-.js +75 -0
  42. package/dist/select-fXj5tdMX.cjs +1 -0
  43. package/dist/separator-hT24N-xp.cjs +1 -0
  44. package/dist/separator-sgwOa1FE.js +18 -0
  45. package/dist/style.css +2 -2
  46. package/dist/tailwind.cjs +1 -1
  47. package/dist/tailwind.d.ts +41 -1
  48. package/dist/tailwind.js +16 -8
  49. package/dist/ui.cjs +1 -1
  50. package/dist/ui.d.ts +0 -10
  51. package/dist/ui.js +345 -163
  52. package/dist/web-blocks.cjs +1 -1
  53. package/dist/web-blocks.d.ts +1 -1
  54. package/dist/web-blocks.js +489 -724
  55. package/package.json +15 -45
  56. package/dist/AddBlocks-6dJmFSgk.js +0 -142
  57. package/dist/AddBlocks-doCNVVbk.cjs +0 -1
  58. package/dist/CanvasArea-kB6ky_uL.js +0 -164
  59. package/dist/CanvasArea-kdnkFfKR.cjs +0 -1
  60. package/dist/CodeEditor-ypUx3RAV.cjs +0 -1
  61. package/dist/CurrentPage-Ekl5Cwbv.cjs +0 -1
  62. package/dist/CurrentPage-bHq9Uusr.js +0 -108
  63. package/dist/Functions-7jnEwJyw.js +0 -15
  64. package/dist/Functions-N3yhPYKY.cjs +0 -1
  65. package/dist/MODIFIERS-fd5XOmum.js +0 -60
  66. package/dist/MODIFIERS-mVmfEGgo.cjs +0 -1
  67. package/dist/PagesPanel-SMHrEmCb.cjs +0 -1
  68. package/dist/PagesPanel-wIPAyjJK.js +0 -66
  69. package/dist/ProjectPanel-L-SlDizV.js +0 -87
  70. package/dist/ProjectPanel-YruLal65.cjs +0 -1
  71. package/dist/Settings-WXkCyhAv.js +0 -2380
  72. package/dist/Settings-_5VHcgFC.cjs +0 -1
  73. package/dist/SidePanels-UeIZB3e1.cjs +0 -1
  74. package/dist/StaticCanvas-7C52tXAv.js +0 -749
  75. package/dist/StaticCanvas-ll9VTXI5.cjs +0 -60
  76. package/dist/ThemeConfigPanel-_86vVxLz.cjs +0 -1
  77. package/dist/ThemeConfigPanel-gw8B2zvx.js +0 -194
  78. package/dist/Topbar-gb17oHdJ.cjs +0 -1
  79. package/dist/UILibrariesPanel-03Y3F3A_.cjs +0 -1
  80. package/dist/UnsplashImages-6UjgojvF.cjs +0 -1
  81. package/dist/UploadImages-3h0cRsvr.cjs +0 -1
  82. package/dist/_commonjsHelpers-UyOWmZb0.js +0 -8
  83. package/dist/_commonjsHelpers-wDK0ZLPo.cjs +0 -1
  84. package/dist/add-page-modal-qr7rvJzN.js +0 -106
  85. package/dist/add-page-modal-rOKavDFX.cjs +0 -1
  86. package/dist/atoms-KQpaDRnF.cjs +0 -1
  87. package/dist/atoms-Oomqut88.js +0 -6
  88. package/dist/confirm-alert-P6TAevaP.js +0 -60
  89. package/dist/confirm-alert-v1lG8ex4.cjs +0 -1
  90. package/dist/controls-rRZhz0vu.cjs +0 -1
  91. package/dist/controls-yjgoZzB6.js +0 -199
  92. package/dist/delete-page-modal-55oioI9i.js +0 -85
  93. package/dist/delete-page-modal-wdAiMVnL.cjs +0 -1
  94. package/dist/email-blocks.cjs +0 -1
  95. package/dist/email-blocks.d.ts +0 -3
  96. package/dist/email-blocks.js +0 -294
  97. package/dist/email.cjs +0 -1
  98. package/dist/email.d.ts +0 -171
  99. package/dist/email.js +0 -75
  100. package/dist/empty-slot-Lsxjts7Q.js +0 -6
  101. package/dist/empty-slot-Sy930lX6.cjs +0 -1
  102. package/dist/form-4jTocVbZ.cjs +0 -1
  103. package/dist/form-5ke_lZv8.js +0 -125
  104. package/dist/functions--tdNWQDW.js +0 -30
  105. package/dist/functions-EVUeSwX1.cjs +0 -1
  106. package/dist/html-to-json-_01DXd-a.js +0 -192
  107. package/dist/html-to-json-ndxaXRT8.cjs +0 -1
  108. package/dist/index--mLLy7QQ.cjs +0 -1
  109. package/dist/index-6w-6HYBd.cjs +0 -1
  110. package/dist/index-VBXQixVm.js +0 -117
  111. package/dist/index-aeDphKpP.cjs +0 -1
  112. package/dist/index-audsIPBC.cjs +0 -231
  113. package/dist/index-b33n_-zO.js +0 -3141
  114. package/dist/index-e0c8PmRQ.js +0 -205
  115. package/dist/index-fnkMn4Pk.js +0 -2201
  116. package/dist/index-gi1LIOCw.cjs +0 -1
  117. package/dist/index-wRAIA8zZ.js +0 -80248
  118. package/dist/jsx-runtime-Z_BpKhVy.cjs +0 -27
  119. package/dist/lib.cjs +0 -3
  120. package/dist/lib.d.ts +0 -80
  121. package/dist/lib.js +0 -1350
  122. package/dist/page-viewer-t44DP65U.js +0 -112
  123. package/dist/page-viewer-wU7T0f48.cjs +0 -1
  124. package/dist/plugin-2hf9pCRy.cjs +0 -1
  125. package/dist/plugin-wDnsBVPp.js +0 -54
  126. package/dist/project-general-setting-87cX9vvO.cjs +0 -1
  127. package/dist/project-general-setting-NEkNjf7V.js +0 -81
  128. package/dist/project-seo-setting-YmspOYsF.js +0 -83
  129. package/dist/project-seo-setting-o0V9acCV.cjs +0 -1
  130. package/dist/server.cjs +0 -1
  131. package/dist/server.d.ts +0 -299
  132. package/dist/server.js +0 -216
  133. package/dist/single-page-detail-27UjWK8L.cjs +0 -1
  134. package/dist/single-page-detail-jHzoDP7B.js +0 -220
  135. package/dist/studio.cjs +0 -1
  136. package/dist/studio.d.ts +0 -176
  137. package/dist/studio.js +0 -55
  138. package/dist/utils-D_vtk3zK.cjs +0 -1
  139. package/dist/utils-VpVqnC9m.js +0 -1075
package/dist/server.js DELETED
@@ -1,216 +0,0 @@
1
- var g = Object.defineProperty;
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-es";
5
- import { getChaiDataProviders as m } from "@chaibuilder/runtime";
6
- const d = "https://api.chaibuilder.com";
7
- class A {
8
- constructor(t, e) {
9
- h(this, "_authSecret");
10
- h(this, "_accessToken", null);
11
- h(this, "_appKey");
12
- if (!t)
13
- throw "Please provide valid auth secret.";
14
- if (!e)
15
- throw "Please provide valid project key.";
16
- this._authSecret = t, this._appKey = e;
17
- }
18
- setAccessToken(t) {
19
- this._accessToken = t;
20
- }
21
- async getPageData(t) {
22
- const e = this.getHeaders(), s = this.getURL("page-data", i(t) ? {} : { slug: t }), r = {
23
- method: "GET",
24
- headers: e,
25
- next: { tags: ["everything", i(t) ? "_homepage" : t] }
26
- };
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);
38
- }
39
- /**
40
- *
41
- * @param uuid
42
- * @returns Detail Single Page Information
43
- */
44
- async getPage(t) {
45
- if (!t)
46
- return Promise.reject({
47
- data: null,
48
- error: { message: "Invalid page uuid" },
49
- result: "error"
50
- });
51
- const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), r = { method: "GET", headers: e };
52
- return this.fetchAPI(s, r);
53
- }
54
- /**
55
- *
56
- * @returns List of all pages
57
- */
58
- // @ts-ignore
59
- async getPages() {
60
- const t = this.getHeaders(), e = this.getURL("pages"), o = { method: "GET", headers: t };
61
- return this.fetchAPI(e, o);
62
- }
63
- /**
64
- *
65
- * @param page
66
- * @returns Detail of new page
67
- */
68
- async addPage(t) {
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);
71
- }
72
- /**
73
- *
74
- * @param uuid
75
- * @returns Success | Error Message
76
- */
77
- async deletePage(t) {
78
- if (!t)
79
- return Promise.reject({
80
- data: null,
81
- error: { message: "Invalid page uuid" },
82
- result: "error"
83
- });
84
- const e = this.getHeaders(), s = this.getURL("page", { uuid: t }), r = { method: "DELETE", headers: e };
85
- return this.fetchAPI(s, r);
86
- }
87
- /**
88
- *
89
- * @param page
90
- * @returns Update page information or Error response
91
- */
92
- async updatePage(t) {
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);
95
- }
96
- /**
97
- *
98
- * @returns Project detail
99
- */
100
- async getProject() {
101
- const t = this.getHeaders(), e = this.getURL("project"), o = { method: "GET", headers: t };
102
- return this.fetchAPI(e, o);
103
- }
104
- /**
105
- *
106
- * @param project
107
- * @returns Updated project detail
108
- */
109
- async updateProject(t) {
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);
112
- }
113
- /**
114
- *
115
- * @returns Upload asset
116
- * @param formData
117
- */
118
- async uploadAsset(t) {
119
- const e = this.getHeaders(), s = this.getURL("asset"), o = "POST", r = await t.get("file"), n = new FormData();
120
- n.append("file", r);
121
- const a = { method: o, headers: e, body: n };
122
- return this.fetchAPI(s, a);
123
- }
124
- /**
125
- *
126
- * @returns Get assets
127
- * @param limit
128
- * @param offset
129
- */
130
- async getAssets(t, e) {
131
- const s = this.getHeaders(), o = this.getURL("asset");
132
- t && o.concat(`?limit=${t}`), e && o.concat(`&offset=${e}`);
133
- const n = { method: "GET", headers: s };
134
- return this.fetchAPI(o, n);
135
- }
136
- /**
137
- *
138
- * @param { password }
139
- * @returns { token }
140
- */
141
- async authenticate({ password: t }) {
142
- const e = JSON.stringify({ password: t }), s = this.getHeaders(), o = this.getURL("authenticate"), n = { method: "POST", headers: s, body: e };
143
- return this.fetchAPI(o, n);
144
- }
145
- /**
146
- *
147
- * @param { password }
148
- * @returns { token }
149
- */
150
- async login({ password: t, email: e }) {
151
- const s = JSON.stringify({ password: t, email: e }), o = this.getHeaders(), r = this.getURL("login"), a = { method: "POST", headers: o, body: s };
152
- return this.fetchAPI(r, a);
153
- }
154
- /**
155
- *
156
- * @returns { token }
157
- */
158
- async logout() {
159
- const t = this.getHeaders(), e = this.getURL("logout"), o = { method: "POST", headers: t };
160
- return this.fetchAPI(e, o);
161
- }
162
- /**
163
- *
164
- * @returns { result: 'success' | 'error' }
165
- */
166
- async verify() {
167
- const t = this.getHeaders(), e = this.getURL("verify"), o = { method: "POST", headers: t };
168
- return this.fetchAPI(e, o);
169
- }
170
- /**
171
- *
172
- * @param endpoint
173
- * @param queryParam
174
- * @returns api endpoint with query param
175
- */
176
- getURL(t, e) {
177
- const s = new URLSearchParams(e).toString();
178
- return i(e) ? `${d}/v1/${t}` : `${d}/v1/${t}?${s}`;
179
- }
180
- /**
181
- *
182
- * @returns headers for api
183
- */
184
- getHeaders() {
185
- const t = new Headers();
186
- 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;
187
- }
188
- /**
189
- *
190
- * @returns Fetch API
191
- */
192
- async fetchAPI(t, e) {
193
- try {
194
- const s = await fetch(t, e).then((o) => o.json());
195
- if ((s == null ? void 0 : s.result) === "success")
196
- return { data: s == null ? void 0 : s.data, error: null, result: "success" };
197
- throw s == null ? void 0 : s.error;
198
- } catch (s) {
199
- return { data: null, error: s, result: "error" };
200
- }
201
- }
202
- }
203
- const T = async (c, t) => {
204
- const e = m(), s = l(e, (n) => p(c, "providerKey").includes(n.providerKey)), o = {}, r = [];
205
- for (const n of s)
206
- try {
207
- o[n.providerKey] = await n.dataFn({}, t);
208
- } catch (a) {
209
- r.push(a);
210
- }
211
- return { data: o, errors: r };
212
- };
213
- export {
214
- A as ChaibuilderBackend,
215
- T as prepareExternalData
216
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./jsx-runtime-Z_BpKhVy.cjs"),g=require("react"),c=require("lodash-es"),H=require("@radix-ui/react-icons"),y=require("./index-aeDphKpP.cjs"),d=require("./controls-rRZhz0vu.cjs"),w=require("sonner"),p=require("./form-4jTocVbZ.cjs"),h=require("./index-6w-6HYBd.cjs");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-D_vtk3zK.cjs");require("./MODIFIERS-mVmfEGgo.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("./Functions-N3yhPYKY.cjs");require("@chaibuilder/runtime");require("jotai");require("@react-hookz/web");require("tree-model");require("react-i18next");require("@rjsf/core");require("@rjsf/validator-ajv8");require("./index-audsIPBC.cjs");require("i18next");require("react-arborist");require("lucide-react");require("./index--mLLy7QQ.cjs");require("@floating-ui/react-dom");require("flagged");require("react-hotkeys-hook");require("./html-to-json-ndxaXRT8.cjs");require("himalaya");require("lodash");const z=g.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-wdAiMVnL.cjs"))),L=g.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-v1lG8ex4.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},P=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(P(o).seoData,P(n).seoData);return s||q},Y=({open:n,setOpen:o,pageData:s})=>{const q=h.useQueryClient(),{data:e}=h.useProject(),u=h.useUpdatePage(),m=h.useUpdateProject("Homepage updated successfully."),[i,b]=g.useState(P(s)),[a,A]=g.useState({isHomePage:(e==null?void 0:e.homepage)===s.uuid}),j=G(i,s);g.useEffect(()=>{const l=!c.isEqual(P(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)||"")){n==="ALERT"&&o("PENDING");return}u.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(f=>{var S,N;if(!t)return f;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||""}),{...f,...x}})},I=({formData:l},t)=>{A(f=>{const x={[t]:l[t]};return{...f,...x}})},v={name:d.g({title:"Page Name",default:i.name}),slug:d.g({title:"Page Slug",default:i.slug})},T={seoData:d.h({title:"",description:"",default:{title:"",description:"",image:""},properties:{title:d.g({title:"Meta Title",default:i.name}),description:d.r({title:"Meta Description",default:i.slug}),image:d.v({title:"Social Media Image",default:""})}})},M={isHomePage:d.c({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:n==="ALERT",title:"Do yo want to save changes?",onCancel:()=>o("CLOSE"),onConfirm:C,disabled:m.isPending||u.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:u.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:u.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:u.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||u.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;
@@ -1,220 +0,0 @@
1
- import { j as t } from "./jsx-runtime-WbnYoNE9.js";
2
- import I, { useState as j, useEffect as z } from "react";
3
- import { isString as L, isEmpty as x, isEqual as C, omit as y, kebabCase as B } from "lodash-es";
4
- import { HomeIcon as G } from "@radix-ui/react-icons";
5
- import { ai as Y, B as q } from "./index-b33n_-zO.js";
6
- import { g, h as Z, r as $, v as F, c as Q } from "./controls-yjgoZzB6.js";
7
- import { toast as U } from "sonner";
8
- import { F as h } from "./form-5ke_lZv8.js";
9
- import { f as V, a as X, g as _, b as K } from "./index-fnkMn4Pk.js";
10
- import "./_commonjsHelpers-UyOWmZb0.js";
11
- import "@radix-ui/react-toggle";
12
- import "class-variance-authority";
13
- import "./utils-VpVqnC9m.js";
14
- import "./MODIFIERS-fd5XOmum.js";
15
- import "clsx";
16
- import "tailwind-merge";
17
- import "@radix-ui/react-switch";
18
- import "@radix-ui/react-slot";
19
- import "@radix-ui/react-accordion";
20
- import "@radix-ui/react-alert-dialog";
21
- import "@radix-ui/react-dialog";
22
- import "@radix-ui/react-label";
23
- import "@radix-ui/react-scroll-area";
24
- import "@radix-ui/react-tabs";
25
- import "@radix-ui/react-tooltip";
26
- import "@radix-ui/react-popover";
27
- import "@radix-ui/react-menubar";
28
- import "@radix-ui/react-hover-card";
29
- import "@radix-ui/react-select";
30
- import "@radix-ui/react-dropdown-menu";
31
- import "@radix-ui/react-separator";
32
- import "@radix-ui/react-toast";
33
- import "cmdk";
34
- import "@radix-ui/react-context-menu";
35
- import "react-icons-picker";
36
- import "react-dom";
37
- import "react-quill";
38
- import "./Functions-7jnEwJyw.js";
39
- import "@chaibuilder/runtime";
40
- import "jotai";
41
- import "@react-hookz/web";
42
- import "tree-model";
43
- import "react-i18next";
44
- import "@rjsf/core";
45
- import "@rjsf/validator-ajv8";
46
- import "./index-wRAIA8zZ.js";
47
- import "i18next";
48
- import "react-arborist";
49
- import "lucide-react";
50
- import "./index-VBXQixVm.js";
51
- import "@floating-ui/react-dom";
52
- import "flagged";
53
- import "react-hotkeys-hook";
54
- import "./html-to-json-_01DXd-a.js";
55
- import "himalaya";
56
- import "lodash";
57
- const O = I.lazy(() => import("./delete-page-modal-55oioI9i.js")), J = I.lazy(() => import("./confirm-alert-P6TAevaP.js")), P = (r) => {
58
- if (!L(r) || !(r.includes("/[") && r.includes("]")))
59
- return !1;
60
- const s = /^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/, u = /^[a-zA-Z0-9_-]+$/;
61
- let e = !0;
62
- return r.split("/").forEach((n) => {
63
- e && (n.includes("[[") && n.includes("]]") ? e = /^\[\[\.{3}[a-zA-Z0-9_-]+\]\]$/.test(n) : n.includes("[") && n.includes("]") ? e = s.test(n) : e = u.test(n));
64
- }), e;
65
- }, f = (r) => r && x(r.seoData) ? {
66
- ...r,
67
- seoData: { title: "", description: "", image: "" }
68
- } : r, W = (r, m) => {
69
- const s = !C(y(r, ["seoData"]), y(m, ["seoData"])), u = !C(f(m).seoData, f(r).seoData);
70
- return s || u;
71
- }, ei = ({ open: r, setOpen: m, pageData: s }) => {
72
- const u = V(), { data: e } = X(), n = _(), c = K("Homepage updated successfully."), [i, T] = j(f(s)), [d, v] = j({
73
- isHomePage: (e == null ? void 0 : e.homepage) === s.uuid
74
- }), N = W(i, s);
75
- z(() => {
76
- const l = !C(f(s), i), o = (e == null ? void 0 : e.homepage) !== s.uuid && d.isHomePage;
77
- m(l || o ? "PENDING" : "OPEN");
78
- }, [e, s, i, d, m]);
79
- const S = () => {
80
- if (N) {
81
- if (s.type === "DYNAMIC" && !P((i == null ? void 0 : i.slug) || "")) {
82
- r === "ALERT" && m("PENDING");
83
- return;
84
- }
85
- n.mutate(i, {
86
- onSuccess: () => {
87
- u.invalidateQueries({
88
- refetchType: "active",
89
- queryKey: ["pages", e == null ? void 0 : e.uuid]
90
- }), m("CLOSE"), U.success("Page updated successfully.");
91
- }
92
- });
93
- }
94
- d.isHomePage && (e == null ? void 0 : e.homepage) !== s.uuid && c.mutate({ ...e, homepage: s == null ? void 0 : s.uuid }, { onSuccess: () => m("CLOSE") });
95
- }, E = ({ formData: l }, o) => {
96
- T((p) => {
97
- var b, A;
98
- if (!o)
99
- return p;
100
- const a = { [o]: l[o] };
101
- return o === "name" ? a.slug = B((b = l[o]) == null ? void 0 : b.replace(/\d/g, "")) : o === "slug" ? a.slug = (A = l[o]) == null ? void 0 : A.replace(/\d/g, "").replace(/\s+/g, "").replace("--", "-").replace("__", "_") : o === "seoData" && (a.seoData = {
102
- title: l[o].title || "",
103
- description: l[o].description || "",
104
- image: l[o].image || ""
105
- }), {
106
- ...p,
107
- ...a
108
- };
109
- });
110
- }, H = ({ formData: l }, o) => {
111
- v((p) => {
112
- const a = { [o]: l[o] };
113
- return {
114
- ...p,
115
- ...a
116
- };
117
- });
118
- }, M = {
119
- name: g({
120
- title: "Page Name",
121
- default: i.name
122
- }),
123
- slug: g({ title: "Page Slug", default: i.slug })
124
- }, w = {
125
- seoData: Z({
126
- title: "",
127
- description: "",
128
- default: {
129
- title: "",
130
- description: "",
131
- image: ""
132
- },
133
- properties: {
134
- title: g({
135
- title: "Meta Title",
136
- default: i.name
137
- }),
138
- description: $({
139
- title: "Meta Description",
140
- default: i.slug
141
- }),
142
- image: F({ title: "Social Media Image", default: "" })
143
- }
144
- })
145
- }, R = {
146
- isHomePage: Q({
147
- title: "Set as homepage",
148
- default: d.isHomePage
149
- })
150
- };
151
- return /* @__PURE__ */ t.jsxs(Y, { className: "flex h-full select-none flex-col", children: [
152
- /* @__PURE__ */ t.jsx(
153
- J,
154
- {
155
- open: r === "ALERT",
156
- title: "Do yo want to save changes?",
157
- onCancel: () => m("CLOSE"),
158
- onConfirm: S,
159
- disabled: c.isPending || n.isPending
160
- }
161
- ),
162
- /* @__PURE__ */ t.jsx("div", { className: "rounded-md bg-background/30 px-2.5 py-1", children: /* @__PURE__ */ t.jsx("h1", { className: "px-1 font-semibold", children: "Page Details" }) }),
163
- /* @__PURE__ */ t.jsx("div", { className: "px-2.5 pt-2", children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col space-y-2", children: [
164
- /* @__PURE__ */ t.jsx(
165
- h,
166
- {
167
- title: "Basic Details",
168
- formData: i,
169
- properties: M,
170
- onChange: E,
171
- disabled: n.isPending || c.isPending
172
- }
173
- ),
174
- /* @__PURE__ */ t.jsx("div", { className: "h-2 w-full" }),
175
- /* @__PURE__ */ t.jsx(
176
- h,
177
- {
178
- title: "SEO Details",
179
- formData: i,
180
- properties: w,
181
- onChange: E,
182
- disabled: n.isPending || c.isPending
183
- }
184
- ),
185
- (e == null ? void 0 : e.homepage) !== s.uuid && s.type === "STATIC" ? /* @__PURE__ */ t.jsx(
186
- h,
187
- {
188
- formData: d,
189
- properties: R,
190
- onChange: H,
191
- disabled: n.isPending || c.isPending
192
- }
193
- ) : s.type === "STATIC" && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-x-1 px-1 pt-2 text-xs font-medium text-gray-500", children: [
194
- /* @__PURE__ */ t.jsx(G, {}),
195
- " This is homepage",
196
- " "
197
- ] }),
198
- i.type === "DYNAMIC" && !P((i == null ? void 0 : i.slug) || "") && /* @__PURE__ */ t.jsxs("small", { className: "px-1 text-red-400", children: [
199
- "Add dynamic ID in page slug Eg: ",
200
- /* @__PURE__ */ t.jsx("i", { className: "underline", children: "some-url/[some-id]" })
201
- ] }),
202
- /* @__PURE__ */ t.jsxs("div", { className: "my-2 flex w-full items-center justify-between gap-x-2 px-1", children: [
203
- /* @__PURE__ */ t.jsx(
204
- q,
205
- {
206
- className: "w-full",
207
- type: "submit",
208
- onClick: S,
209
- disabled: (e == null ? void 0 : e.homepage) !== s.uuid && d.isHomePage ? !1 : x(i.name) || x(i.slug) || !N || n.isPending || c.isPending || i.type === "DYNAMIC" && !P((i == null ? void 0 : i.slug) || ""),
210
- children: "Save"
211
- }
212
- ),
213
- /* @__PURE__ */ t.jsx(O, { pageData: s, projectData: e })
214
- ] })
215
- ] }) })
216
- ] });
217
- };
218
- export {
219
- ei as default
220
- };
package/dist/studio.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./jsx-runtime-Z_BpKhVy.cjs");const e=require("./index-6w-6HYBd.cjs");require("react");require("sonner");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("./index-audsIPBC.cjs");require("i18next");require("react-i18next");require("jotai");require("@react-hookz/web");require("react-arborist");require("./index-aeDphKpP.cjs");require("@radix-ui/react-toggle");require("class-variance-authority");require("./utils-D_vtk3zK.cjs");require("lodash-es");require("./MODIFIERS-mVmfEGgo.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("./Functions-N3yhPYKY.cjs");require("@chaibuilder/runtime");require("tree-model");require("lucide-react");require("./index--mLLy7QQ.cjs");require("@floating-ui/react-dom");require("flagged");require("react-hotkeys-hook");require("./html-to-json-ndxaXRT8.cjs");require("himalaya");require("lodash");exports.ChaiBuilderStudio=e.ChaiBuilderStudio;
package/dist/studio.d.ts DELETED
@@ -1,176 +0,0 @@
1
- import { JSX as JSX_2 } from 'react/jsx-runtime';
2
- import { default as React_2 } from 'react';
3
- import { ReactNode } from 'react';
4
-
5
- declare type AskAiResponse = {
6
- blocks?: Array<{
7
- _id: string;
8
- } & Partial<ChaiBlock>>;
9
- usage?: Record<any, number>;
10
- error?: any;
11
- };
12
-
13
- declare interface Block {
14
- type: string;
15
- [key: string]: any;
16
- }
17
-
18
- declare type Breakpoint = {
19
- title: string;
20
- content: string;
21
- breakpoint: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | string;
22
- icon: React_2.ReactNode | Element;
23
- width: number;
24
- };
25
-
26
- declare type ChaiBlock = {
27
- _id: string;
28
- _type: string;
29
- _name?: string;
30
- _parent?: string | null | undefined;
31
- _bindings?: Record<string, string>;
32
- } & Record<string, any>;
33
-
34
- declare interface ChaiBuilderEditorProps {
35
- onLoad?: (editorInstance: ChaiBuilderInstance) => void;
36
- customRootLayout?: React_2.ComponentType;
37
- htmlDir?: "ltr" | "rtl";
38
- hideSaveButton?: boolean;
39
- filterChaiBlock?: (block: any) => boolean;
40
- showDebugLogs?: boolean;
41
- autoSaveSupport?: boolean;
42
- autoSaveInterval?: TimeInSeconds;
43
- breakpoints?: Breakpoint[];
44
- editable?: boolean;
45
- loading?: boolean;
46
- locale?: string;
47
- nonEditableComponent?: ReactComponentType;
48
- canvas?: React_2.FC<any>;
49
- canvasTopBarComponents?: {
50
- right?: ReactComponentType[];
51
- };
52
- previewLink?: string;
53
- dataBindingSupport?: boolean;
54
- dataProviders?: DataProvider[];
55
- darkMode?: boolean;
56
- dndOptions?: any;
57
- importHTMLSupport?: boolean;
58
- fetchMediaCallback?: (limit?: number, offset?: number) => Promise<any[]>;
59
- uploadMediaCallback?: (file: File) => Promise<{
60
- url: string;
61
- }>;
62
- askAiCallBack?: (type: "styles" | "content", prompt: string, blocks: ChaiBlock[]) => Promise<AskAiResponse>;
63
- saveAiContextCallback?: (content: string) => Promise<true | Error>;
64
- aiContext?: string;
65
- getExternalPredefinedBlock?: (block: PredefinedBlock) => Promise<PredefinedBlock & {
66
- blocks: ChaiBlock[];
67
- html: string;
68
- }>;
69
- uiLibraries?: Omit<UILibrary, "blocks">[];
70
- getUILibraryBlocks?: (library: UILibrary) => Promise<UiLibraryBlock[]>;
71
- getUILibraryBlock?: (library: UILibrary, uiLibBlock: UiLibraryBlock) => Promise<ChaiBlock[]>;
72
- subPages?: Block[];
73
- subPagesSupport?: boolean;
74
- blocks?: ChaiBlock[];
75
- onSaveBlocks?: ({ blocks, providers }: any) => Promise<any>;
76
- onSavePage?: ({ blocks, providers }: SavePageData) => Promise<boolean | Error>;
77
- onSave?: ({ blocks, providers }: SavePageData) => Promise<boolean | Error>;
78
- brandingOptions?: Record<string, string>;
79
- onSaveBrandingOptions?: (brandingOptions: Record<string, any>) => Promise<boolean | Error>;
80
- onSaveStateChange?: (syncStatus: "UNSAVED" | "SAVED" | "SAVING") => void;
81
- previewComponent?: ReactComponentType;
82
- sideBarComponents?: {
83
- bottom?: ReactComponentType[];
84
- top?: {
85
- icon: ReactComponentType | string;
86
- name: string;
87
- panel: ReactComponentType;
88
- }[];
89
- };
90
- topBarComponents?: {
91
- center?: ReactComponentType[];
92
- left?: ReactComponentType[];
93
- right?: ReactComponentType[];
94
- };
95
- outlineMenuItems?: OutlineMenuItems;
96
- getPages?: () => Promise<ChaiPage[]>;
97
- unsplashAccessKey?: string;
98
- _flags?: Record<string, boolean>;
99
- }
100
-
101
- declare type ChaiBuilderInstance = {
102
- setBlocks: (blocks: ChaiBlock[]) => void;
103
- };
104
-
105
- export declare const ChaiBuilderStudio: (props: ChaiBuilderStudioProps) => JSX_2.Element;
106
-
107
- export declare type ChaiBuilderStudioProps = {
108
- apiBaseUrl?: string;
109
- logo?: React_2.FC<any> | React_2.LazyExoticComponent<any>;
110
- } & Omit<ChaiBuilderEditorProps, "topBarComponents" | "editable" | "onSaveBrandingOptions" | "onSaveBlocks" | "blocks" | "brandingOptions">;
111
-
112
- declare type ChaiPage = {
113
- uuid?: string;
114
- page_name?: string;
115
- blocks: ChaiBlock[];
116
- custom_code: string;
117
- seo_data: Record<string, string>;
118
- slug: string;
119
- translations: Record<string, Record<string, string>>;
120
- };
121
-
122
- declare type DataProvider = {
123
- providerKey: string;
124
- args: Record<string, any>;
125
- };
126
-
127
- declare type OutlineMenuItem = {
128
- item: React_2.ComponentType<{
129
- blockId: string;
130
- }>;
131
- tooltip: string | ReactNode;
132
- };
133
-
134
- declare type OutlineMenuItems = OutlineMenuItem[];
135
-
136
- declare type PredefinedBlock = {
137
- uuid: string;
138
- name: string;
139
- preview: string;
140
- blocks?: ChaiBlock[];
141
- html?: string;
142
- };
143
-
144
- declare type ReactComponentType = React_2.ComponentType<any>;
145
-
146
- declare type RichText = string;
147
-
148
- declare type SavePageData = {
149
- blocks: ChaiBlock[];
150
- providers?: DataProvider[];
151
- brandingOptions?: Record<string, any>;
152
- themeConfiguration?: Record<string, any>;
153
- };
154
-
155
- declare type TimeInSeconds = number;
156
-
157
- declare interface UILibrary {
158
- uuid: string;
159
- name: string;
160
- url: string;
161
- blocks?: UiLibraryBlock[];
162
- link?: string;
163
- description?: RichText;
164
- }
165
-
166
- declare type UiLibraryBlock = {
167
- uuid: string;
168
- group: string;
169
- name?: string;
170
- path: string;
171
- preview?: string;
172
- tags?: string[];
173
- description?: string;
174
- };
175
-
176
- export { }
package/dist/studio.js DELETED
@@ -1,55 +0,0 @@
1
- import "./jsx-runtime-WbnYoNE9.js";
2
- import { C as $ } from "./index-fnkMn4Pk.js";
3
- import "react";
4
- import "sonner";
5
- import "./_commonjsHelpers-UyOWmZb0.js";
6
- import "./index-wRAIA8zZ.js";
7
- import "i18next";
8
- import "react-i18next";
9
- import "jotai";
10
- import "@react-hookz/web";
11
- import "react-arborist";
12
- import "./index-b33n_-zO.js";
13
- import "@radix-ui/react-toggle";
14
- import "class-variance-authority";
15
- import "./utils-VpVqnC9m.js";
16
- import "lodash-es";
17
- import "./MODIFIERS-fd5XOmum.js";
18
- import "clsx";
19
- import "tailwind-merge";
20
- import "@radix-ui/react-switch";
21
- import "@radix-ui/react-slot";
22
- import "@radix-ui/react-accordion";
23
- import "@radix-ui/react-icons";
24
- import "@radix-ui/react-alert-dialog";
25
- import "@radix-ui/react-dialog";
26
- import "@radix-ui/react-label";
27
- import "@radix-ui/react-scroll-area";
28
- import "@radix-ui/react-tabs";
29
- import "@radix-ui/react-tooltip";
30
- import "@radix-ui/react-popover";
31
- import "@radix-ui/react-menubar";
32
- import "@radix-ui/react-hover-card";
33
- import "@radix-ui/react-select";
34
- import "@radix-ui/react-dropdown-menu";
35
- import "@radix-ui/react-separator";
36
- import "@radix-ui/react-toast";
37
- import "cmdk";
38
- import "@radix-ui/react-context-menu";
39
- import "react-icons-picker";
40
- import "react-dom";
41
- import "react-quill";
42
- import "./Functions-7jnEwJyw.js";
43
- import "@chaibuilder/runtime";
44
- import "tree-model";
45
- import "lucide-react";
46
- import "./index-VBXQixVm.js";
47
- import "@floating-ui/react-dom";
48
- import "flagged";
49
- import "react-hotkeys-hook";
50
- import "./html-to-json-_01DXd-a.js";
51
- import "himalaya";
52
- import "lodash";
53
- export {
54
- $ as ChaiBuilderStudio
55
- };