@chaibuilder/sdk 1.2.65 → 1.2.67

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 (125) hide show
  1. package/dist/AddBlocks-TVOOPK2w.cjs +1 -0
  2. package/dist/AddBlocks-mbuhydG3.js +123 -0
  3. package/dist/CanvasArea-KJMcis97.cjs +1 -0
  4. package/dist/CanvasArea-kg3Rgg9t.js +136 -0
  5. package/dist/CodeEditor-QP6l0mv4.cjs +1 -0
  6. package/dist/{CodeEditor-Qff4q7sx.js → CodeEditor-q5unEaUI.js} +60 -46
  7. package/dist/STRINGS--j49GZJP.js +7 -0
  8. package/dist/STRINGS-gPz7CUOk.cjs +1 -0
  9. package/dist/SettingsPanel-MWeQjDWs.cjs +1 -0
  10. package/dist/SettingsPanel-pomLrOxB.js +81 -0
  11. package/dist/SidePanels-9sbERNEv.cjs +1 -0
  12. package/dist/{SidePanels-ijaUKSek.js → SidePanels-YpRrvfiH.js} +87 -93
  13. package/dist/{Topbar-vHlnfxPs.js → Topbar-kVBx7pp4.js} +56 -61
  14. package/dist/Topbar-veJ2_blW.cjs +1 -0
  15. package/dist/{UILibrariesPanel-NVUMUPUj.js → UILibrariesPanel-ES8YzN9C.js} +92 -101
  16. package/dist/UILibrariesPanel-H8t36R6M.cjs +1 -0
  17. package/dist/UnsplashImages--MXx-DYM.cjs +1 -0
  18. package/dist/{UnsplashImages-UkHihhA5.js → UnsplashImages-sotLcz6r.js} +72 -57
  19. package/dist/{UploadImages-HtuJZJlo.js → UploadImages-I0QQ6vj1.js} +57 -44
  20. package/dist/UploadImages-xhxeYKkl.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 -20
  27. package/dist/core.js +85 -87
  28. package/dist/iconBase-vJD0OXxU.cjs +1 -0
  29. package/dist/iconBase-zweRWSz0.js +323 -0
  30. package/dist/index-5hfuDpYs.cjs +223 -0
  31. package/dist/index-Zu-K_BX7.js +33933 -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 +1 -1
  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/CanvasArea-fSdH_RiN.cjs +0 -1
  57. package/dist/CanvasArea-ut5yknzX.js +0 -168
  58. package/dist/CodeEditor-ypUx3RAV.cjs +0 -1
  59. package/dist/CurrentPage-jHSVy3hq.js +0 -120
  60. package/dist/CurrentPage-p_AM4lrF.cjs +0 -1
  61. package/dist/Functions-7jnEwJyw.js +0 -15
  62. package/dist/Functions-N3yhPYKY.cjs +0 -1
  63. package/dist/MODIFIERS-fd5XOmum.js +0 -60
  64. package/dist/MODIFIERS-mVmfEGgo.cjs +0 -1
  65. package/dist/PagesPanel-U3InJ9Db.js +0 -78
  66. package/dist/PagesPanel-wqDb4D-x.cjs +0 -1
  67. package/dist/ProjectPanel-XODJTO4J.js +0 -99
  68. package/dist/ProjectPanel-fWESzHr6.cjs +0 -1
  69. package/dist/SidePanels-lrMQqc0h.cjs +0 -1
  70. package/dist/Topbar-RrCDxd0i.cjs +0 -1
  71. package/dist/UILibrariesPanel-7btHgBD0.cjs +0 -1
  72. package/dist/UnsplashImages-6UjgojvF.cjs +0 -1
  73. package/dist/UploadImages-3h0cRsvr.cjs +0 -1
  74. package/dist/_commonjsHelpers-UyOWmZb0.js +0 -8
  75. package/dist/_commonjsHelpers-wDK0ZLPo.cjs +0 -1
  76. package/dist/add-page-modal-RwIj1FxH.cjs +0 -1
  77. package/dist/add-page-modal-TOfMfmPA.js +0 -115
  78. package/dist/confirm-alert-eIp2cAkc.js +0 -60
  79. package/dist/confirm-alert-v1lG8ex4.cjs +0 -1
  80. package/dist/controls-rRZhz0vu.cjs +0 -1
  81. package/dist/controls-yjgoZzB6.js +0 -199
  82. package/dist/delete-page-modal-4bxjpVBD.js +0 -97
  83. package/dist/delete-page-modal-qYDZmpgT.cjs +0 -1
  84. package/dist/email-blocks.cjs +0 -1
  85. package/dist/email-blocks.d.ts +0 -3
  86. package/dist/email-blocks.js +0 -294
  87. package/dist/email.cjs +0 -1
  88. package/dist/email.d.ts +0 -171
  89. package/dist/email.js +0 -90
  90. package/dist/empty-slot-Lsxjts7Q.js +0 -6
  91. package/dist/empty-slot-Sy930lX6.cjs +0 -1
  92. package/dist/form-4jTocVbZ.cjs +0 -1
  93. package/dist/form-NAzFjGs0.js +0 -125
  94. package/dist/functions--tdNWQDW.js +0 -30
  95. package/dist/functions-EVUeSwX1.cjs +0 -1
  96. package/dist/html-to-json-NqRjgFqp.cjs +0 -1
  97. package/dist/html-to-json-l_mw5y-e.js +0 -243
  98. package/dist/index--k2M8kzI.cjs +0 -1
  99. package/dist/index--mLLy7QQ.cjs +0 -1
  100. package/dist/index-5XyNUAjc.cjs +0 -290
  101. package/dist/index-C7mB4XFm.js +0 -3141
  102. package/dist/index-VBXQixVm.js +0 -117
  103. package/dist/index-YZhtVcj_.js +0 -2201
  104. package/dist/index-aeDphKpP.cjs +0 -1
  105. package/dist/index-lFgDm1oa.js +0 -83780
  106. package/dist/jsx-runtime-Z_BpKhVy.cjs +0 -27
  107. package/dist/lib.cjs +0 -3
  108. package/dist/lib.d.ts +0 -80
  109. package/dist/lib.js +0 -1350
  110. package/dist/page-viewer-4wrnWnK0.js +0 -124
  111. package/dist/page-viewer-ra0GLx1p.cjs +0 -1
  112. package/dist/project-general-setting-IwZUkYF3.js +0 -90
  113. package/dist/project-general-setting-lFjTUhHD.cjs +0 -1
  114. package/dist/project-seo-setting-e1fTqVsd.js +0 -83
  115. package/dist/project-seo-setting-o0V9acCV.cjs +0 -1
  116. package/dist/server.cjs +0 -1
  117. package/dist/server.d.ts +0 -299
  118. package/dist/server.js +0 -216
  119. package/dist/single-page-detail-ZNWFKqLW.js +0 -229
  120. package/dist/single-page-detail-g55Anu7R.cjs +0 -1
  121. package/dist/studio.cjs +0 -1
  122. package/dist/studio.d.ts +0 -176
  123. package/dist/studio.js +0 -67
  124. package/dist/utils-D_vtk3zK.cjs +0 -1
  125. 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,229 +0,0 @@
1
- import { j as s } 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 { aJ as Y, B as q } from "./index-C7mB4XFm.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-NAzFjGs0.js";
9
- import { f as V, a as X, g as _, b as J } from "./index-YZhtVcj_.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-lFgDm1oa.js";
47
- import "i18next";
48
- import "react-arborist";
49
- import "lucide-react";
50
- import "./index-VBXQixVm.js";
51
- import "prop-types";
52
- import "react-hotkeys-hook";
53
- import "@floating-ui/dom";
54
- import "@floating-ui/react-dom";
55
- import "flagged";
56
- import "@tailwindcss/typography";
57
- import "@tailwindcss/forms";
58
- import "@tailwindcss/aspect-ratio";
59
- import "tailwindcss-palette-generator";
60
- import "./html-to-json-l_mw5y-e.js";
61
- import "himalaya";
62
- import "lodash";
63
- import "react-wrap-balancer";
64
- import "react-autosuggest";
65
- import "fuse.js";
66
- const K = I.lazy(() => import("./delete-page-modal-4bxjpVBD.js")), O = I.lazy(() => import("./confirm-alert-eIp2cAkc.js")), P = (r) => {
67
- if (!L(r) || !(r.includes("/[") && r.includes("]")))
68
- return !1;
69
- const t = /^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/, p = /^[a-zA-Z0-9_-]+$/;
70
- let e = !0;
71
- return r.split("/").forEach((m) => {
72
- e && (m.includes("[[") && m.includes("]]") ? e = /^\[\[\.{3}[a-zA-Z0-9_-]+\]\]$/.test(m) : m.includes("[") && m.includes("]") ? e = t.test(m) : e = p.test(m));
73
- }), e;
74
- }, f = (r) => r && x(r.seoData) ? {
75
- ...r,
76
- seoData: { title: "", description: "", image: "" }
77
- } : r, W = (r, n) => {
78
- const t = !C(y(r, ["seoData"]), y(n, ["seoData"])), p = !C(f(n).seoData, f(r).seoData);
79
- return t || p;
80
- }, ci = ({ open: r, setOpen: n, pageData: t }) => {
81
- const p = V(), { data: e } = X(), m = _(), c = J("Homepage updated successfully."), [i, T] = j(f(t)), [d, v] = j({
82
- isHomePage: (e == null ? void 0 : e.homepage) === t.uuid
83
- }), N = W(i, t);
84
- z(() => {
85
- const l = !C(f(t), i), o = (e == null ? void 0 : e.homepage) !== t.uuid && d.isHomePage;
86
- n(l || o ? "PENDING" : "OPEN");
87
- }, [e, t, i, d, n]);
88
- const S = () => {
89
- if (N) {
90
- if (t.type === "DYNAMIC" && !P((i == null ? void 0 : i.slug) || "")) {
91
- r === "ALERT" && n("PENDING");
92
- return;
93
- }
94
- m.mutate(i, {
95
- onSuccess: () => {
96
- p.invalidateQueries({
97
- refetchType: "active",
98
- queryKey: ["pages", e == null ? void 0 : e.uuid]
99
- }), n("CLOSE"), U.success("Page updated successfully.");
100
- }
101
- });
102
- }
103
- d.isHomePage && (e == null ? void 0 : e.homepage) !== t.uuid && c.mutate({ ...e, homepage: t == null ? void 0 : t.uuid }, { onSuccess: () => n("CLOSE") });
104
- }, E = ({ formData: l }, o) => {
105
- T((u) => {
106
- var b, A;
107
- if (!o)
108
- return u;
109
- const a = { [o]: l[o] };
110
- 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 = {
111
- title: l[o].title || "",
112
- description: l[o].description || "",
113
- image: l[o].image || ""
114
- }), {
115
- ...u,
116
- ...a
117
- };
118
- });
119
- }, H = ({ formData: l }, o) => {
120
- v((u) => {
121
- const a = { [o]: l[o] };
122
- return {
123
- ...u,
124
- ...a
125
- };
126
- });
127
- }, M = {
128
- name: g({
129
- title: "Page Name",
130
- default: i.name
131
- }),
132
- slug: g({ title: "Page Slug", default: i.slug })
133
- }, w = {
134
- seoData: Z({
135
- title: "",
136
- description: "",
137
- default: {
138
- title: "",
139
- description: "",
140
- image: ""
141
- },
142
- properties: {
143
- title: g({
144
- title: "Meta Title",
145
- default: i.name
146
- }),
147
- description: $({
148
- title: "Meta Description",
149
- default: i.slug
150
- }),
151
- image: F({ title: "Social Media Image", default: "" })
152
- }
153
- })
154
- }, R = {
155
- isHomePage: Q({
156
- title: "Set as homepage",
157
- default: d.isHomePage
158
- })
159
- };
160
- return /* @__PURE__ */ s.jsxs(Y, { className: "flex h-full select-none flex-col", children: [
161
- /* @__PURE__ */ s.jsx(
162
- O,
163
- {
164
- open: r === "ALERT",
165
- title: "Do yo want to save changes?",
166
- onCancel: () => n("CLOSE"),
167
- onConfirm: S,
168
- disabled: c.isPending || m.isPending
169
- }
170
- ),
171
- /* @__PURE__ */ s.jsx("div", { className: "rounded-md bg-background/30 px-2.5 py-1", children: /* @__PURE__ */ s.jsx("h1", { className: "px-1 font-semibold", children: "Page Details" }) }),
172
- /* @__PURE__ */ s.jsx("div", { className: "px-2.5 pt-2", children: /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col space-y-2", children: [
173
- /* @__PURE__ */ s.jsx(
174
- h,
175
- {
176
- title: "Basic Details",
177
- formData: i,
178
- properties: M,
179
- onChange: E,
180
- disabled: m.isPending || c.isPending
181
- }
182
- ),
183
- /* @__PURE__ */ s.jsx("div", { className: "h-2 w-full" }),
184
- /* @__PURE__ */ s.jsx(
185
- h,
186
- {
187
- title: "SEO Details",
188
- formData: i,
189
- properties: w,
190
- onChange: E,
191
- disabled: m.isPending || c.isPending
192
- }
193
- ),
194
- (e == null ? void 0 : e.homepage) !== t.uuid && t.type === "STATIC" ? /* @__PURE__ */ s.jsx(
195
- h,
196
- {
197
- formData: d,
198
- properties: R,
199
- onChange: H,
200
- disabled: m.isPending || c.isPending
201
- }
202
- ) : t.type === "STATIC" && /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-x-1 px-1 pt-2 text-xs font-medium text-gray-500", children: [
203
- /* @__PURE__ */ s.jsx(G, {}),
204
- " This is homepage",
205
- " "
206
- ] }),
207
- i.type === "DYNAMIC" && !P((i == null ? void 0 : i.slug) || "") && /* @__PURE__ */ s.jsxs("small", { className: "px-1 text-red-400", children: [
208
- "Add dynamic ID in page slug Eg: ",
209
- /* @__PURE__ */ s.jsx("i", { className: "underline", children: "some-url/[some-id]" })
210
- ] }),
211
- /* @__PURE__ */ s.jsxs("div", { className: "my-2 flex w-full items-center justify-between gap-x-2 px-1", children: [
212
- /* @__PURE__ */ s.jsx(
213
- q,
214
- {
215
- className: "w-full",
216
- type: "submit",
217
- onClick: S,
218
- disabled: (e == null ? void 0 : e.homepage) !== t.uuid && d.isHomePage ? !1 : x(i.name) || x(i.slug) || !N || m.isPending || c.isPending || i.type === "DYNAMIC" && !P((i == null ? void 0 : i.slug) || ""),
219
- children: "Save"
220
- }
221
- ),
222
- /* @__PURE__ */ s.jsx(K, { pageData: t, projectData: e })
223
- ] })
224
- ] }) })
225
- ] });
226
- };
227
- export {
228
- ci as default
229
- };
@@ -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--k2M8kzI.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-5XyNUAjc.cjs");require("i18next");require("react-arborist");require("lucide-react");require("./index--mLLy7QQ.cjs");require("prop-types");require("react-hotkeys-hook");require("@floating-ui/dom");require("@floating-ui/react-dom");require("flagged");require("@tailwindcss/typography");require("@tailwindcss/forms");require("@tailwindcss/aspect-ratio");require("tailwindcss-palette-generator");require("./html-to-json-NqRjgFqp.cjs");require("himalaya");require("lodash");require("react-wrap-balancer");require("react-autosuggest");require("fuse.js");const z=g.lazy(()=>Promise.resolve().then(()=>require("./delete-page-modal-qYDZmpgT.cjs"))),L=g.lazy(()=>Promise.resolve().then(()=>require("./confirm-alert-v1lG8ex4.cjs"))),E=u=>{if(!c.isString(u)||!(u.includes("/[")&&u.includes("]")))return!1;const s=/^\[((?:\.{3})?[a-zA-Z0-9_-]+)\]$/,x=/^[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=x.test(n))}),e},P=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"])),x=!c.isEqual(P(o).seoData,P(u).seoData);return s||x},Y=({open:u,setOpen:o,pageData:s})=>{const x=h.useQueryClient(),{data:e}=h.useProject(),n=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)||"")){u==="ALERT"&&o("PENDING");return}n.mutate(i,{onSuccess:()=>{x.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 q={[t]:l[t]};return t==="name"?q.slug=c.kebabCase((S=l[t])==null?void 0:S.replace(/\d/g,"")):t==="slug"?q.slug=(N=l[t])==null?void 0:N.replace(/\d/g,"").replace(/\s+/g,"").replace("--","-").replace("__","_"):t==="seoData"&&(q.seoData={title:l[t].title||"",description:l[t].description||"",image:l[t].image||""}),{...f,...q}})},I=({formData:l},t)=>{A(f=>{const q={[t]:l[t]};return{...f,...q}})},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: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;
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--k2M8kzI.cjs");require("react");require("sonner");require("./_commonjsHelpers-wDK0ZLPo.cjs");require("./index-5XyNUAjc.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("prop-types");require("react-hotkeys-hook");require("@floating-ui/dom");require("@floating-ui/react-dom");require("flagged");require("@tailwindcss/typography");require("@tailwindcss/forms");require("@tailwindcss/aspect-ratio");require("tailwindcss-palette-generator");require("./html-to-json-NqRjgFqp.cjs");require("himalaya");require("lodash");require("react-wrap-balancer");require("@rjsf/core");require("@rjsf/validator-ajv8");require("react-autosuggest");require("fuse.js");require("./controls-rRZhz0vu.cjs");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 { }