@chaibuilder/sdk 1.0.9 → 1.0.10

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 (162) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +123 -21
  3. package/dist/AddBlocks-tdvDe7xL.cjs +3 -0
  4. package/dist/{AddBlocks-d10b7b87.js → AddBlocks-xR2s2BVa.js} +47 -44
  5. package/dist/BrandingOptions-DpJ-oNnf.cjs +1 -0
  6. package/dist/{BrandingOptions-f4ab5d9f.js → BrandingOptions-cHK2bVZy.js} +14 -18
  7. package/dist/{CanvasArea-10356200.js → CanvasArea-2zqT1lSE.js} +492 -503
  8. package/dist/CanvasArea-Br8bBSeT.cjs +46 -0
  9. package/dist/ChaiBuilderEditor-SacH75l4.cjs +163 -0
  10. package/dist/{index-aa42febc.js → ChaiBuilderEditor-h9bXC4l-.js} +11215 -15404
  11. package/dist/Class-_uCzl5v1.cjs +1 -0
  12. package/dist/{html-to-json-45e0e3b5.js → Class-l7qYbuoN.js} +185 -366
  13. package/dist/{CurrentPage-35e14043.js → CurrentPage-4lTETR2f.js} +26 -23
  14. package/dist/CurrentPage-nlUWJiUA.cjs +1 -0
  15. package/dist/{ImagesPanel-8b7a989d.cjs → ImagesPanel-6us7hiLN.cjs} +1 -1
  16. package/dist/{ImagesPanel-47ac13c3.js → ImagesPanel-oaHOD-Ex.js} +4 -4
  17. package/dist/Layers-Vw4XE6YB.cjs +1 -0
  18. package/dist/{Layers-c3dd4fc8.js → Layers-wOfijZnb.js} +42 -41
  19. package/dist/MarkAsGlobalBlock-1J_YyL1L.cjs +1 -0
  20. package/dist/{MarkAsGlobalBlock-505ae793.js → MarkAsGlobalBlock-xRyn29gC.js} +17 -20
  21. package/dist/{PagesPanel-bafc506f.js → PagesPanel-82gCVzHS.js} +16 -13
  22. package/dist/PagesPanel-ZKRdK-mI.cjs +1 -0
  23. package/dist/ProjectPanel-kYg4KkJu.cjs +1 -0
  24. package/dist/{ProjectPanel-6113f394.js → ProjectPanel-vz5WOyqZ.js} +22 -19
  25. package/dist/Settings-1E3Y_5r6.cjs +1 -0
  26. package/dist/{Settings-1c41c514.js → Settings-IuAF359L.js} +297 -296
  27. package/dist/SidePanels-WL1UioF2.cjs +1 -0
  28. package/dist/{SidePanels-c13f87dc.js → SidePanels-xssTWt4M.js} +34 -42
  29. package/dist/Topbar-3ozdWfSy.cjs +1 -0
  30. package/dist/{Topbar-b38d5d50.js → Topbar-H0f0EL6-.js} +33 -35
  31. package/dist/UnsplashImages-BoBBSi1a.cjs +1 -0
  32. package/dist/{UnsplashImages-4edb97e7.js → UnsplashImages-gPcBLjgB.js} +13 -14
  33. package/dist/UploadImages-T6kW0s3G.cjs +1 -0
  34. package/dist/{UploadImages-52181c3e.js → UploadImages-_ZyUU66E.js} +11 -12
  35. package/dist/{accordion-c0176dc5.js → accordion-oPUeqPCZ.js} +2 -2
  36. package/dist/{accordion-0afd8143.cjs → accordion-ynvFtV_p.cjs} +1 -1
  37. package/dist/{add-page-modal-08a19915.js → add-page-modal-J1E7rh1U.js} +25 -22
  38. package/dist/add-page-modal-eiiUZCJX.cjs +1 -0
  39. package/dist/alert-dialog-GNfnpqFB.js +64 -0
  40. package/dist/alert-dialog-Mv0-wAvS.cjs +1 -0
  41. package/dist/{command-b1103666.cjs → command-ThdTuUxt.cjs} +1 -1
  42. package/dist/{command-6f260f61.js → command-VHca6CcN.js} +3 -3
  43. package/dist/confirm-alert-8EHe0OOd.cjs +1 -0
  44. package/dist/confirm-alert-b0e_BLhF.js +36 -0
  45. package/dist/{context-menu-e1c240ce.js → context-menu-8dC9uGXj.js} +2 -2
  46. package/dist/{context-menu-fec580f2.cjs → context-menu-IgLbIuth.cjs} +1 -1
  47. package/dist/controls-Ni5kEzLz.js +103 -0
  48. package/dist/controls-xUKa23ic.cjs +1 -0
  49. package/dist/core.cjs +1 -1
  50. package/dist/core.d.ts +1 -10
  51. package/dist/core.js +116 -69
  52. package/dist/delete-page-modal-TGTmRjyn.cjs +1 -0
  53. package/dist/{delete-page-modal-9b37665b.js → delete-page-modal-ysj4O0bM.js} +25 -22
  54. package/dist/{dialog-170eaad9.cjs → dialog-S_QbL1iq.cjs} +1 -1
  55. package/dist/{dialog-18207bef.js → dialog-jrw9DF1f.js} +2 -2
  56. package/dist/{dropdown-menu-ae3ed09b.js → dropdown-menu-S03K_fNs.js} +2 -2
  57. package/dist/{dropdown-menu-84b2439e.cjs → dropdown-menu-sMXR59cB.cjs} +1 -1
  58. package/dist/{form-25e1af37.js → form-dVpOAyRl.js} +2 -2
  59. package/dist/{form-ea21db6c.cjs → form-nRAvKPQj.cjs} +1 -1
  60. package/dist/{functions-83b1de8d.js → functions-nNTuSTsR.js} +1 -1
  61. package/dist/functions-pcUZhFJM.js +12 -0
  62. package/dist/{functions-f84d5e2a.cjs → functions-sCuB7nvZ.cjs} +1 -1
  63. package/dist/functions-uw7QP2kT.cjs +1 -0
  64. package/dist/html-to-json-P6GpbcQX.cjs +1 -0
  65. package/dist/html-to-json-pdHQfRkN.js +178 -0
  66. package/dist/index-8L3zCc6V.cjs +1 -0
  67. package/dist/index-cZ4uo6aT.js +2256 -0
  68. package/dist/{label-e770a087.js → label-KaP7MRrs.js} +2 -2
  69. package/dist/{label-167415e5.cjs → label-tFm8HZdb.cjs} +1 -1
  70. package/dist/lib.cjs +1 -1
  71. package/dist/lib.d.ts +20 -13
  72. package/dist/lib.js +24 -23
  73. package/dist/{link-57de608a.js → link-6o6n2Tnd.js} +4 -4
  74. package/dist/link-ece8dZGH.cjs +1 -0
  75. package/dist/{page-viewer-5c733179.js → page-viewer-84Giu0Rs.js} +29 -26
  76. package/dist/page-viewer-OdVEG83P.cjs +1 -0
  77. package/dist/{popover-f7addcf4.js → popover-a84pbVhQ.js} +2 -2
  78. package/dist/{popover-7cb9079b.cjs → popover-fKjgcRUx.cjs} +1 -1
  79. package/dist/{project-general-setting-d9736056.js → project-general-setting-8OEVVxzn.js} +20 -17
  80. package/dist/project-general-setting-laHNQPW5.cjs +1 -0
  81. package/dist/{project-seo-setting-d81fc1e3.js → project-seo-setting-9kD_stdI.js} +11 -12
  82. package/dist/project-seo-setting-F3Opt9Uj.cjs +1 -0
  83. package/dist/render.cjs +1 -1
  84. package/dist/render.d.ts +7 -7
  85. package/dist/render.js +3 -3
  86. package/dist/{scroll-area-bb343b86.cjs → scroll-area-FiHvy-TZ.cjs} +1 -1
  87. package/dist/{scroll-area-83bd9e8f.js → scroll-area-ewXbxc3n.js} +2 -2
  88. package/dist/{select-0e32300c.cjs → select-7bjg-rr9.cjs} +1 -1
  89. package/dist/{select-7fddd7c3.js → select-POGdEDHT.js} +2 -2
  90. package/dist/{separator-a597dba7.cjs → separator-3Civ-6hb.cjs} +1 -1
  91. package/dist/{separator-a80d065b.js → separator-SctTn0Qi.js} +2 -2
  92. package/dist/server.d.ts +7 -10
  93. package/dist/server.js +0 -3
  94. package/dist/single-page-detail-X0TGlsT4.cjs +1 -0
  95. package/dist/{single-page-detail-04410e64.js → single-page-detail-iXpavDy8.js} +32 -29
  96. package/dist/skeleton-CU_FIbg3.js +239 -0
  97. package/dist/skeleton-JHP9zwL2.cjs +1 -0
  98. package/dist/studio.cjs +1 -0
  99. package/dist/studio.d.ts +13 -0
  100. package/dist/studio.js +39 -0
  101. package/dist/{tabs-85caa1e8.js → tabs-Gb9v5dVb.js} +2 -2
  102. package/dist/{tabs-860e37aa.cjs → tabs-iWeaaVrg.cjs} +1 -1
  103. package/dist/{textarea-a338ede6.cjs → textarea-1kZEh7ki.cjs} +1 -1
  104. package/dist/{textarea-0750bcd2.js → textarea-b2QvVhrK.js} +2 -2
  105. package/dist/{toggle-00c9d11e.js → toggle-ASJRAaGP.js} +2 -2
  106. package/dist/{toggle-b90fed97.cjs → toggle-ehNIPmme.cjs} +1 -1
  107. package/dist/ui.cjs +1 -1
  108. package/dist/ui.d.ts +69 -4
  109. package/dist/ui.js +272 -212
  110. package/dist/useAddBlock-1cMXaOVk.cjs +1 -0
  111. package/dist/useAddBlock-BOjrGBEO.js +86 -0
  112. package/dist/useAllBlocks-RU_Xw8j9.cjs +1 -0
  113. package/dist/useAllBlocks-lX6uVO39.js +20 -0
  114. package/dist/useChaiExternalData-4K9WxANa.js +6 -0
  115. package/dist/useChaiExternalData-DkyBJ81C.cjs +1 -0
  116. package/dist/useDarkMode-JWkrNFpH.js +23 -0
  117. package/dist/useDarkMode-zeTW_UUR.cjs +1 -0
  118. package/dist/useFeatureSupport-jWSuY7wk.js +16 -0
  119. package/dist/useFeatureSupport-tZ0QfBxp.cjs +1 -0
  120. package/dist/useHiddenBlocks-3MsGOJ1s.js +15 -0
  121. package/dist/useHiddenBlocks-oJuQDmTy.cjs +1 -0
  122. package/dist/useLanguage-O1uu2Bzu.js +216 -0
  123. package/dist/useLanguage-Y3qgAbgG.cjs +1 -0
  124. package/dist/useMarkAsGlobalBlock-DB5B1UP6.js +25 -0
  125. package/dist/useMarkAsGlobalBlock-toxRSLc_.cjs +1 -0
  126. package/dist/useUiLibraries-4hPOi8DI.js +12 -0
  127. package/dist/useUiLibraries-9FhQCpKo.cjs +1 -0
  128. package/package.json +19 -5
  129. package/dist/AddBlocks-76275943.cjs +0 -3
  130. package/dist/BrandingOptions-d3b3309a.cjs +0 -1
  131. package/dist/CanvasArea-9f94cd28.cjs +0 -46
  132. package/dist/CurrentPage-edb509db.cjs +0 -1
  133. package/dist/Layers-ecba52c1.cjs +0 -1
  134. package/dist/MarkAsGlobalBlock-3a06a159.cjs +0 -1
  135. package/dist/PagesPanel-f4329082.cjs +0 -1
  136. package/dist/ProjectPanel-ce3116d3.cjs +0 -1
  137. package/dist/Settings-b6a2bef6.cjs +0 -1
  138. package/dist/SidePanels-2cc72c0b.cjs +0 -1
  139. package/dist/Topbar-3b9db9f3.cjs +0 -1
  140. package/dist/UnsplashImages-98c085c2.cjs +0 -1
  141. package/dist/UploadImages-61ef83ad.cjs +0 -1
  142. package/dist/add-page-modal-7f9ff733.cjs +0 -1
  143. package/dist/confirm-alert-c1fdf1e4.js +0 -35
  144. package/dist/confirm-alert-e1ea5110.cjs +0 -1
  145. package/dist/delete-page-modal-7066b01f.cjs +0 -1
  146. package/dist/html-to-json-aadcbf66.cjs +0 -1
  147. package/dist/index-c535cc95.cjs +0 -164
  148. package/dist/link-24679521.cjs +0 -1
  149. package/dist/page-viewer-da99c71e.cjs +0 -1
  150. package/dist/project-general-setting-90f8416d.cjs +0 -1
  151. package/dist/project-seo-setting-6eef8387.cjs +0 -1
  152. package/dist/single-page-detail-90f49d7a.cjs +0 -1
  153. package/dist/useBuilderProp-21feb2da.js +0 -296
  154. package/dist/useBuilderProp-adacf42f.cjs +0 -1
  155. package/dist/useChaiExternalData-192c7896.js +0 -5
  156. package/dist/useChaiExternalData-a90e8aac.cjs +0 -1
  157. /package/dist/{MODIFIERS-2f19c314.js → MODIFIERS-DsEzQ3aH.js} +0 -0
  158. /package/dist/{MODIFIERS-4716c669.cjs → MODIFIERS-Fx6WAZcw.cjs} +0 -0
  159. /package/dist/{jsx-runtime-5c3ac4f7.cjs → jsx-runtime-JYMCiFoE.cjs} +0 -0
  160. /package/dist/{jsx-runtime-944c88e2.js → jsx-runtime-Sp0orL4X.js} +0 -0
  161. /package/dist/{utils-ac68b2c8.js → utils-dze1SGvB.js} +0 -0
  162. /package/dist/{utils-3c452dd0.cjs → utils-qK_SjzzV.cjs} +0 -0
@@ -0,0 +1,86 @@
1
+ import { useCallback as x } from "react";
2
+ import { findIndex as l, filter as P, isEmpty as j, last as J, find as A, first as S, has as K, forIn as L, startsWith as O } from "lodash";
3
+ import { J as T, l as W } from "./ChaiBuilderEditor-h9bXC4l-.js";
4
+ import { g } from "./functions-pcUZhFJM.js";
5
+ import { u as Y, d as C } from "./useAllBlocks-lX6uVO39.js";
6
+ import { b as q } from "./controls-Ni5kEzLz.js";
7
+ import { a as D } from "./MODIFIERS-DsEzQ3aH.js";
8
+ function E(e, s, d, o, h) {
9
+ if (s === null)
10
+ return [...e, ...o];
11
+ if (d !== null) {
12
+ const r = l(e, { _parent: s }), p = (r === -1 ? 0 : r) + d;
13
+ return e.splice(p, 0, ...o), e;
14
+ }
15
+ if (!h) {
16
+ const p = l(e, { _id: s }) + 1;
17
+ return e.splice(p, 0, ...o), e;
18
+ }
19
+ let t = l(e, { _id: s });
20
+ const n = P(e, { _parent: s });
21
+ j(n) || (t = l(e, { _id: J(n)._id }));
22
+ const f = t + 1;
23
+ return e.splice(f, 0, ...o), e;
24
+ }
25
+ const Q = () => {
26
+ const e = T(), s = Y(), [, d] = W(), o = x(
27
+ (t, n, f) => {
28
+ var u;
29
+ for (let i = 0; i < t.length; i++) {
30
+ const { _id: _ } = t[i];
31
+ t[i]._id = g();
32
+ const c = P(t, { _parent: _ });
33
+ for (let a = 0; a < c.length; a++)
34
+ c[a]._parent = t[i]._id;
35
+ }
36
+ let r;
37
+ n && (r = A(s, { _id: n }), t[0]._parent = n);
38
+ const p = r ? C(r._type) : !0;
39
+ return !p && r && (t[0]._parent = r._parent), e({
40
+ type: "set_blocks",
41
+ payload: E(s, n || null, f || null, t, p)
42
+ }), d([(u = S(t)) == null ? void 0 : u._id]), S(t);
43
+ },
44
+ [s, e, d]
45
+ );
46
+ return { addCoreBlock: x(
47
+ (t, n, f) => {
48
+ if (K(t, "blocks")) {
49
+ const m = t.blocks;
50
+ return o(m, n, f);
51
+ }
52
+ const r = g(), p = q(t.props), u = [];
53
+ L(p, (m, y) => {
54
+ if (O(m, D)) {
55
+ const U = m.replace(D, "");
56
+ u.push({
57
+ _id: U,
58
+ _type: "Slot",
59
+ _parent: r,
60
+ _name: t.props[y].name,
61
+ _styles: t.props[y].styles,
62
+ _emptyStyles: t.props[y].emptyStyles
63
+ });
64
+ }
65
+ });
66
+ const i = {
67
+ _type: t.type,
68
+ _id: r,
69
+ ...p
70
+ };
71
+ let _;
72
+ n && (_ = A(s, { _id: n }), i._parent = n);
73
+ const c = _ ? C(_._type) : !0;
74
+ !c && _ && (i._parent = _._parent);
75
+ const a = [i, ...u];
76
+ return e({
77
+ type: "set_blocks",
78
+ payload: E(s, n || null, f || null, a, c)
79
+ }), d([i._id]), i;
80
+ },
81
+ [o, s, e, d]
82
+ ), addPredefinedBlock: o };
83
+ };
84
+ export {
85
+ Q as u
86
+ };
@@ -0,0 +1 @@
1
+ "use strict";const l=require("lodash"),i=require("jotai"),r=require("./ChaiBuilderEditor-SacH75l4.cjs"),s=t=>["Box","Slot","Form","DataProvider","Link","List","ListItem","Row","Column","Table","TableCell"].includes(t),u=t=>!["Slot"].includes(t),a=t=>!["Slot"].includes(t);function d(t,e){return t==="Slot"||e==="List"&&t!=="ListItem"||e==="Row"&&t!=="Column"?!1:s(e)}const B=(t,{dragSource:e,dropTarget:n})=>{const o=l.get(e,"data._type",""),c=l.get(n,"data._type","");return o==="Slot"||l.get(e,"id")&&l.get(e,"id")===l.get(n,"id")?!1:l.isEmpty(c)?!0:d(o,c)},k=()=>i.useAtomValue(r.presentBlocksAtom);exports.canAddChildBlock=s;exports.canDeleteBlock=a;exports.canDropBlock=B;exports.canDuplicateBlock=u;exports.useAllBlocks=k;
@@ -0,0 +1,20 @@
1
+ import { get as o, isEmpty as i } from "lodash";
2
+ import { useAtomValue as c } from "jotai";
3
+ import { O as a } from "./ChaiBuilderEditor-h9bXC4l-.js";
4
+ const r = (t) => ["Box", "Slot", "Form", "DataProvider", "Link", "List", "ListItem", "Row", "Column", "Table", "TableCell"].includes(
5
+ t
6
+ ), k = (t) => !["Slot"].includes(t), B = (t) => !["Slot"].includes(t);
7
+ function u(t, l) {
8
+ return t === "Slot" || l === "List" && t !== "ListItem" || l === "Row" && t !== "Column" ? !1 : r(l);
9
+ }
10
+ const p = (t, { dragSource: l, dropTarget: s }) => {
11
+ const e = o(l, "data._type", ""), n = o(s, "data._type", "");
12
+ return e === "Slot" || o(l, "id") && o(l, "id") === o(s, "id") ? !1 : i(n) ? !0 : u(e, n);
13
+ }, A = () => c(a);
14
+ export {
15
+ B as a,
16
+ p as b,
17
+ k as c,
18
+ r as d,
19
+ A as u
20
+ };
@@ -0,0 +1,6 @@
1
+ import { useAtom as a } from "jotai";
2
+ import { i as t } from "./skeleton-CU_FIbg3.js";
3
+ const m = () => a(t);
4
+ export {
5
+ m as u
6
+ };
@@ -0,0 +1 @@
1
+ "use strict";const t=require("jotai"),a=require("./skeleton-JHP9zwL2.cjs"),e=()=>t.useAtom(a.chaiExternalDataAtom);exports.useChaiExternalData=e;
@@ -0,0 +1,23 @@
1
+ import { useAtom as s, atom as c, useAtomValue as m } from "jotai";
2
+ import { useEffect as d } from "react";
3
+ import { a as u } from "./functions-pcUZhFJM.js";
4
+ import { M as k, F as n } from "./ChaiBuilderEditor-h9bXC4l-.js";
5
+ const p = () => s(k), i = n("canvasWidth", 800), f = c((t) => {
6
+ const o = t(i);
7
+ return u(o).toLowerCase();
8
+ }), W = () => {
9
+ const [t, o] = s(i), a = m(f), [e, r] = p();
10
+ return d(() => {
11
+ e !== "xs" && r(a);
12
+ }, [a, e, r]), [t, a, o];
13
+ }, h = n("darkMode", !1), g = () => {
14
+ const [t, o] = s(h);
15
+ return [t, o];
16
+ };
17
+ export {
18
+ g as a,
19
+ p as b,
20
+ f as c,
21
+ h as d,
22
+ W as u
23
+ };
@@ -0,0 +1 @@
1
+ "use strict";const o=require("jotai"),k=require("react"),m=require("./functions-uw7QP2kT.cjs"),a=require("./ChaiBuilderEditor-SacH75l4.cjs"),i=()=>o.useAtom(a.styleBreakpointAtom),c=a.atomWithStorage("canvasWidth",800),u=o.atom(t=>{const e=t(c);return m.getBreakpointValue(e).toLowerCase()}),h=()=>{const[t,e]=o.useAtom(c),s=o.useAtomValue(u),[n,r]=i();return k.useEffect(()=>{n!=="xs"&&r(s)},[s,n,r]),[t,s,e]},d=a.atomWithStorage("darkMode",!1),A=()=>{const[t,e]=o.useAtom(d);return[t,e]};exports.canvasBreakpointAtom=u;exports.darkModeAtom=d;exports.useCanvasWidth=h;exports.useDarkMode=A;exports.useStylingBreakpoint=i;
@@ -0,0 +1,16 @@
1
+ import { useAtom as e } from "jotai";
2
+ import { F as s } from "./ChaiBuilderEditor-h9bXC4l-.js";
3
+ import { get as a } from "lodash";
4
+ import { h as n } from "./skeleton-CU_FIbg3.js";
5
+ const m = s("canvasZoom", 100), l = () => e(m), c = s("selectedBreakpoints", ["XS", "MD", "XL"]), B = () => {
6
+ const [o, t] = e(c);
7
+ return [o, t];
8
+ }, k = (o, t) => {
9
+ const [r] = e(n);
10
+ return a(r, o, t);
11
+ };
12
+ export {
13
+ l as a,
14
+ B as b,
15
+ k as u
16
+ };
@@ -0,0 +1 @@
1
+ "use strict";const o=require("jotai"),s=require("./ChaiBuilderEditor-SacH75l4.cjs"),a=require("lodash"),n=require("./skeleton-JHP9zwL2.cjs"),u=s.atomWithStorage("canvasZoom",100),c=()=>o.useAtom(u),i=s.atomWithStorage("selectedBreakpoints",["XS","MD","XL"]),m=()=>{const[e,t]=o.useAtom(i);return[e,t]},p=(e,t)=>{const[r]=o.useAtom(n.chaiBuilderPropsAtom);return a.get(r,e,t)};exports.useCanvasZoom=c;exports.useFeatureSupport=p;exports.useSelectedBreakpoints=m;
@@ -0,0 +1,15 @@
1
+ import { atom as n, useAtom as c } from "jotai";
2
+ import { includes as i, without as d } from "lodash";
3
+ import { useCallback as r } from "react";
4
+ const u = n([]), k = () => {
5
+ const [e, o] = c(u), m = r(
6
+ (t) => {
7
+ o((s) => i(s, t) ? d(s, t) : [...s, t]);
8
+ },
9
+ [o]
10
+ );
11
+ return [e, o, m];
12
+ };
13
+ export {
14
+ k as u
15
+ };
@@ -0,0 +1 @@
1
+ "use strict";const c=require("jotai"),o=require("lodash"),i=require("react"),u=c.atom([]),l=()=>{const[n,s]=c.useAtom(u),d=i.useCallback(t=>{s(e=>o.includes(e,t)?o.without(e,t):[...e,t])},[s]);return[n,s,d]};exports.useHiddenBlockIds=l;
@@ -0,0 +1,216 @@
1
+ import { useCallback as b } from "react";
2
+ import { atom as d, useSetAtom as S, useAtomValue as F, useAtom as _ } from "jotai";
3
+ import { filter as i, map as x, isNull as E, includes as q, each as y, find as T, pick as $, sortBy as w, first as B, get as g, startsWith as N } from "lodash";
4
+ import { H as j, I as L, J as h, K as O, L as D, a as U } from "./ChaiBuilderEditor-h9bXC4l-.js";
5
+ import { c as A } from "./Class-l7qYbuoN.js";
6
+ import { S as k } from "./MODIFIERS-DsEzQ3aH.js";
7
+ import { c as H, d as Y } from "./useDarkMode-JWkrNFpH.js";
8
+ const G = (s) => {
9
+ const e = s.replace(k, "").split(",");
10
+ return { baseClasses: e[0], classes: e[1] };
11
+ }, P = {
12
+ xs: 420,
13
+ sm: 620,
14
+ md: 768,
15
+ lg: 1024,
16
+ xl: 1280,
17
+ "2xl": 1536
18
+ }, I = ["xs", "sm", "md", "lg", "xl", "2xl"];
19
+ function J(s, e) {
20
+ if (e === null)
21
+ return "baseClasses";
22
+ const t = e.mq;
23
+ if (t === "xs" || e.dark || e.mod !== "")
24
+ return "classes";
25
+ let o = "baseClasses", l = I.indexOf(t);
26
+ for (; l > 0; ) {
27
+ const a = I[l - 1];
28
+ if (T(s, {
29
+ mq: a,
30
+ property: e.property
31
+ })) {
32
+ o = "classes";
33
+ break;
34
+ }
35
+ l--;
36
+ }
37
+ return o;
38
+ }
39
+ const v = [];
40
+ function V(s = "", e = "", t = []) {
41
+ s = s.trim().replace(/ +/g, "");
42
+ let o = i(
43
+ x(s.split(" "), A),
44
+ (c) => !E(c)
45
+ ), l = i(x(e.split(" "), A), (c) => !E(c));
46
+ l = i(
47
+ l,
48
+ (c) => !q(v, c.property)
49
+ );
50
+ const a = [], p = [];
51
+ y(t, (c) => {
52
+ const r = A(c), u = T(o, $(r, ["dark", "mq", "mod", "property"]));
53
+ if (u && (o = i(
54
+ o,
55
+ (n) => n.fullCls !== (u == null ? void 0 : u.fullCls)
56
+ )), a.push(r), r.mq === "xs" && !r.dark && r.mod === "" && (l = i(l, (n) => n.property !== r.property)), J(o, r) === "baseClasses" && !q(v, r.property)) {
57
+ const n = T(l, $(r, ["property"]));
58
+ u && (l = i(
59
+ l,
60
+ (f) => f.fullCls !== (n == null ? void 0 : n.fullCls)
61
+ )), p.push({
62
+ ...r,
63
+ fullCls: r.cls,
64
+ mq: "xs"
65
+ });
66
+ }
67
+ });
68
+ const m = x(
69
+ w([...o, ...a], (c) => P[c.mq]),
70
+ "fullCls"
71
+ ).join(" ");
72
+ return `${x(
73
+ w([...l, ...p], (c) => P[c.mq]),
74
+ "fullCls"
75
+ ).join(" ").trim()},${m.trim()}`.trim().replace(/ +/g, "");
76
+ }
77
+ const W = (s) => {
78
+ const e = s.replace(k, "").split(",");
79
+ return { baseClasses: e[0], classes: e[1] };
80
+ }, z = d(null, (s, e, { blockIds: t, newClasses: o, dispatch: l }) => {
81
+ const a = i(
82
+ s(j),
83
+ (m) => (
84
+ // @ts-ignore
85
+ t.includes(s(m)._id)
86
+ )
87
+ ), p = B(s(L));
88
+ y(a, (m) => {
89
+ const C = s(m), c = g(C, p.prop, `${k},`), { baseClasses: r, classes: u } = W(c);
90
+ l({
91
+ type: "update_props_realtime",
92
+ payload: {
93
+ ids: [C._id],
94
+ props: { [p.prop]: `${k}${V(u, r, o)}` }
95
+ }
96
+ });
97
+ });
98
+ }), us = () => {
99
+ const s = h(), e = S(z);
100
+ return b(
101
+ (t, o, l) => {
102
+ e({ blockIds: t, newClasses: o, dispatch: s }), l && setTimeout(() => s({ type: "create_snapshot" }), 500);
103
+ },
104
+ [s, e]
105
+ );
106
+ }, X = d(null, (s, e, { blockIds: t, fullClasses: o, dispatch: l }) => {
107
+ const a = B(s(L)), p = i(
108
+ s(j),
109
+ (m) => (
110
+ // @ts-ignore
111
+ t.includes(s(m)._id)
112
+ )
113
+ );
114
+ y(p, (m) => {
115
+ const C = s(m), c = o;
116
+ let { classes: r, baseClasses: u } = G(g(C, a.prop, "styles:,"));
117
+ y(c, (n) => {
118
+ const f = new RegExp(`(^| )${n.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
119
+ r = r.replace(f, " ").replace(/ +/g, " ").trim();
120
+ const Q = B(n.split(":"));
121
+ q(["2xl", "xl", "lg", "md", "sm"], Q) && c.push(n.split(":").pop().trim());
122
+ }), y(c, (n) => {
123
+ const f = new RegExp(`(^| )${n.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
124
+ u = u.replace(f, " ").replace(/ +/g, " ").trim();
125
+ }), l({
126
+ type: "update_props_realtime",
127
+ payload: {
128
+ ids: [C._id],
129
+ props: {
130
+ [a.prop]: `${k}${u},${r}`
131
+ }
132
+ }
133
+ });
134
+ });
135
+ }), ds = () => {
136
+ const s = h(), e = S(X);
137
+ return b(
138
+ (t, o) => {
139
+ e({ blockIds: t, fullClasses: o, dispatch: s }), setTimeout(() => s({ type: "create_snapshot" }));
140
+ },
141
+ [s, e]
142
+ );
143
+ }, K = d((s) => {
144
+ const e = B(s(L)), t = s(O);
145
+ if (!e || e.blockId !== g(t, "_id", null))
146
+ return [];
147
+ const l = g(t, e.prop, `${k},`).replace(k, "").split(",").join(" ");
148
+ return i(x(l.trim().split(" "), A), (a) => !E(a));
149
+ }), ks = () => F(K), R = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, Z = d((s) => {
150
+ const e = s(H), t = s(D), o = s(Y), l = ss(e);
151
+ let a = i(s(K), { mod: t });
152
+ return N(t, "_") || (a = i(a, (p) => l.includes(p.mq))), a = a.sort((p, m) => R[p.mq] - R[m.mq]), o || (a = i(a, { dark: !1 })), a;
153
+ }), ss = (s) => {
154
+ let e = [];
155
+ switch (s) {
156
+ case "xs":
157
+ e = ["xs"];
158
+ break;
159
+ case "sm":
160
+ e = ["xs", "sm"];
161
+ break;
162
+ case "md":
163
+ e = ["xs", "sm", "md"];
164
+ break;
165
+ case "lg":
166
+ e = ["xs", "sm", "md", "lg"];
167
+ break;
168
+ case "xl":
169
+ e = ["xs", "sm", "md", "lg", "xl"];
170
+ break;
171
+ case "2xl":
172
+ e = ["xs", "sm", "md", "lg", "xl", "2xl"];
173
+ break;
174
+ default:
175
+ e = ["xs"];
176
+ break;
177
+ }
178
+ return e;
179
+ }, Cs = () => F(Z), gs = () => _(D), M = d(null, (s, e, { blockIds: t, props: o, dispatch: l }) => {
180
+ l({
181
+ type: "update_props_realtime",
182
+ payload: { ids: t, props: o }
183
+ });
184
+ }), fs = () => {
185
+ const { createSnapshot: s } = U(), e = h(), t = S(M);
186
+ return b(
187
+ (o, l) => {
188
+ t({ blockIds: o, props: l, dispatch: e }), s();
189
+ },
190
+ [s, e, t]
191
+ );
192
+ }, xs = () => {
193
+ const s = h(), e = S(M);
194
+ return b(
195
+ (t, o) => {
196
+ e({ blockIds: t, props: o, dispatch: s });
197
+ },
198
+ [s, e]
199
+ );
200
+ }, es = d("en"), ts = d("en"), os = d(["en"]), ls = () => _(es), ys = () => _(ts), As = () => _(os), Bs = (s, e) => {
201
+ const [t] = ls(), o = `${s}${t ? `-${t}` : ""}`;
202
+ return { content: g(e, o, g(e, s, "")), propKey: s };
203
+ };
204
+ export {
205
+ ds as a,
206
+ Cs as b,
207
+ ks as c,
208
+ gs as d,
209
+ fs as e,
210
+ xs as f,
211
+ ls as g,
212
+ ys as h,
213
+ As as i,
214
+ Bs as j,
215
+ us as u
216
+ };
@@ -0,0 +1 @@
1
+ "use strict";const f=require("react"),r=require("jotai"),t=require("lodash"),p=require("./ChaiBuilderEditor-SacH75l4.cjs"),A=require("./Class-_uCzl5v1.cjs"),C=require("./MODIFIERS-Fx6WAZcw.cjs"),B=require("./useDarkMode-zeTW_UUR.cjs"),T=s=>{const e=s.replace(C.STYLES_KEY,"").split(",");return{baseClasses:e[0],classes:e[1]}},y={xs:420,sm:620,md:768,lg:1024,xl:1280,"2xl":1536},b=["xs","sm","md","lg","xl","2xl"];function $(s,e){if(e===null)return"baseClasses";const l=e.mq;if(l==="xs"||e.dark||e.mod!=="")return"classes";let o="baseClasses",c=b.indexOf(l);for(;c>0;){const a=b[c-1];if(t.find(s,{mq:a,property:e.property})){o="classes";break}c--}return o}const x=[];function Y(s="",e="",l=[]){s=s.trim().replace(/ +/g,"");let o=t.filter(t.map(s.split(" "),A.constructClassObject),n=>!t.isNull(n)),c=t.filter(t.map(e.split(" "),A.constructClassObject),n=>!t.isNull(n));c=t.filter(c,n=>!t.includes(x,n.property));const a=[],m=[];t.each(l,n=>{const i=A.constructClassObject(n),k=t.find(o,t.pick(i,["dark","mq","mod","property"]));if(k&&(o=t.filter(o,u=>u.fullCls!==(k==null?void 0:k.fullCls))),a.push(i),i.mq==="xs"&&!i.dark&&i.mod===""&&(c=t.filter(c,u=>u.property!==i.property)),$(o,i)==="baseClasses"&&!t.includes(x,i.property)){const u=t.find(c,t.pick(i,["property"]));k&&(c=t.filter(c,S=>S.fullCls!==(u==null?void 0:u.fullCls))),m.push({...i,fullCls:i.cls,mq:"xs"})}});const d=t.map(t.sortBy([...o,...a],n=>y[n.mq]),"fullCls").join(" ");return`${t.map(t.sortBy([...c,...m],n=>y[n.mq]),"fullCls").join(" ").trim()},${d.trim()}`.trim().replace(/ +/g,"")}const P=s=>{const e=s.replace(C.STYLES_KEY,"").split(",");return{baseClasses:e[0],classes:e[1]}},R=r.atom(null,(s,e,{blockIds:l,newClasses:o,dispatch:c})=>{const a=t.filter(s(p.pageBlocksAtomsAtom),d=>l.includes(s(d)._id)),m=t.first(s(p.selectedStylingBlocksAtom));t.each(a,d=>{const g=s(d),n=t.get(g,m.prop,`${C.STYLES_KEY},`),{baseClasses:i,classes:k}=P(n);c({type:"update_props_realtime",payload:{ids:[g._id],props:{[m.prop]:`${C.STYLES_KEY}${Y(k,i,o)}`}}})})}),D=()=>{const s=p.useDispatch(),e=r.useSetAtom(R);return f.useCallback((l,o,c)=>{e({blockIds:l,newClasses:o,dispatch:s}),c&&setTimeout(()=>s({type:"create_snapshot"}),500)},[s,e])},K=r.atom(null,(s,e,{blockIds:l,fullClasses:o,dispatch:c})=>{const a=t.first(s(p.selectedStylingBlocksAtom)),m=t.filter(s(p.pageBlocksAtomsAtom),d=>l.includes(s(d)._id));t.each(m,d=>{const g=s(d),n=o;let{classes:i,baseClasses:k}=T(t.get(g,a.prop,"styles:,"));t.each(n,u=>{const S=new RegExp(`(^| )${u.replace("[","\\[").replace("]","\\]")}($| )`,"g");i=i.replace(S," ").replace(/ +/g," ").trim();const L=t.first(u.split(":"));t.includes(["2xl","xl","lg","md","sm"],L)&&n.push(u.split(":").pop().trim())}),t.each(n,u=>{const S=new RegExp(`(^| )${u.replace("[","\\[").replace("]","\\]")}($| )`,"g");k=k.replace(S," ").replace(/ +/g," ").trim()}),c({type:"update_props_realtime",payload:{ids:[g._id],props:{[a.prop]:`${C.STYLES_KEY}${k},${i}`}}})})}),v=()=>{const s=p.useDispatch(),e=r.useSetAtom(K);return f.useCallback((l,o)=>{e({blockIds:l,fullClasses:o,dispatch:s}),setTimeout(()=>s({type:"create_snapshot"}))},[s,e])},E=r.atom(s=>{const e=t.first(s(p.selectedStylingBlocksAtom)),l=s(p.selectedBlockAtom);if(!e||e.blockId!==t.get(l,"_id",null))return[];const c=t.get(l,e.prop,`${C.STYLES_KEY},`).replace(C.STYLES_KEY,"").split(",").join(" ");return t.filter(t.map(c.trim().split(" "),A.constructClassObject),a=>!t.isNull(a))}),w=()=>r.useAtomValue(E),_={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},I=r.atom(s=>{const e=s(B.canvasBreakpointAtom),l=s(p.styleStateAtom),o=s(B.darkModeAtom),c=j(e);let a=t.filter(s(E),{mod:l});return t.startsWith(l,"_")||(a=t.filter(a,m=>c.includes(m.mq))),a=a.sort((m,d)=>_[m.mq]-_[d.mq]),o||(a=t.filter(a,{dark:!1})),a}),j=s=>{let e=[];switch(s){case"xs":e=["xs"];break;case"sm":e=["xs","sm"];break;case"md":e=["xs","sm","md"];break;case"lg":e=["xs","sm","md","lg"];break;case"xl":e=["xs","sm","md","lg","xl"];break;case"2xl":e=["xs","sm","md","lg","xl","2xl"];break;default:e=["xs"];break}return e},F=()=>r.useAtomValue(I),O=()=>r.useAtom(p.styleStateAtom),h=r.atom(null,(s,e,{blockIds:l,props:o,dispatch:c})=>{c({type:"update_props_realtime",payload:{ids:l,props:o}})}),M=()=>{const{createSnapshot:s}=p.useCanvasHistory(),e=p.useDispatch(),l=r.useSetAtom(h);return f.useCallback((o,c)=>{l({blockIds:o,props:c,dispatch:e}),s()},[s,e,l])},N=()=>{const s=p.useDispatch(),e=r.useSetAtom(h);return f.useCallback((l,o)=>{e({blockIds:l,props:o,dispatch:s})},[s,e])},U=r.atom("en"),Q=r.atom("en"),V=r.atom(["en"]),q=()=>r.useAtom(U),G=()=>r.useAtom(Q),H=()=>r.useAtom(V),W=(s,e)=>{const[l]=q(),o=`${s}${l?`-${l}`:""}`;return{content:t.get(e,o,t.get(e,s,"")),propKey:s}};exports.useActiveLanguage=q;exports.useAddClassesToBlocks=D;exports.useBlockContentByLanguage=W;exports.useLanguages=H;exports.usePrimaryLanguage=G;exports.useRemoveClassesFromBlocks=v;exports.useSelectedBlockAllClasses=w;exports.useSelectedBlockCurrentClasses=F;exports.useStylingState=O;exports.useUpdateBlocksProps=M;exports.useUpdateBlocksPropsRealtime=N;
@@ -0,0 +1,25 @@
1
+ import { useCallback as c } from "react";
2
+ import { useAtomValue as e } from "jotai";
3
+ import { map as k } from "lodash";
4
+ import { R as u, O as i, J as B, f as d } from "./ChaiBuilderEditor-h9bXC4l-.js";
5
+ import { g } from "./functions-pcUZhFJM.js";
6
+ import { useChaiBlocks as b } from "@chaibuilder/blocks";
7
+ const f = () => {
8
+ }, G = () => {
9
+ const o = b(), s = e(u), l = () => {
10
+ }, t = c(() => f(), []);
11
+ return [o, s, l, t];
12
+ }, C = () => {
13
+ const o = e(i), s = B(), l = d(), [, , t] = G();
14
+ return c(
15
+ async (r, n) => {
16
+ const m = g(16), p = k(o, (a) => (a._id === r && (a._globalBlockId = m, a._name = n), a));
17
+ s({ type: "set_page_blocks", payload: p }), t();
18
+ },
19
+ [o, s, l, t]
20
+ );
21
+ };
22
+ export {
23
+ C as a,
24
+ G as u
25
+ };
@@ -0,0 +1 @@
1
+ "use strict";const a=require("react"),n=require("jotai"),d=require("lodash"),c=require("./ChaiBuilderEditor-SacH75l4.cjs"),b=require("./functions-uw7QP2kT.cjs"),g=require("@chaibuilder/blocks"),p=()=>{},u=()=>{const s=g.useChaiBlocks(),o=n.useAtomValue(c.globalBlocksAtom),l=()=>{},e=a.useCallback(()=>p(),[]);return[s,o,l,e]},m=()=>{const s=n.useAtomValue(c.presentBlocksAtom),o=c.useDispatch(),l=c.useGetPageData(),[,,e]=u();return a.useCallback(async(r,i)=>{const k=b.generateUUID(16),B=d.map(s,t=>(t._id===r&&(t._globalBlockId=k,t._name=i),t));o({type:"set_page_blocks",payload:B}),e()},[s,o,l,e])};exports.useBuildingBlocks=u;exports.useMarkAsGlobalBlock=m;
@@ -0,0 +1,12 @@
1
+ import { useState as a, useEffect as c } from "react";
2
+ import { atom as i, useAtom as l } from "jotai";
3
+ import { u as n } from "./skeleton-CU_FIbg3.js";
4
+ const u = i([]), B = () => {
5
+ const [o, s] = a(!1), [t, r] = l(u), e = n("getUILibraryBlocks", () => []);
6
+ return c(() => {
7
+ (async () => t.length > 0 || (s(!0), r(await e()), s(!1)))();
8
+ }, []), { data: t, isLoading: o };
9
+ };
10
+ export {
11
+ B as u
12
+ };
@@ -0,0 +1 @@
1
+ "use strict";const t=require("react"),o=require("jotai"),i=require("./skeleton-JHP9zwL2.cjs"),n=o.atom([]),u=()=>{const[r,s]=t.useState(!1),[e,c]=o.useAtom(n),a=i.useBuilderProp("getUILibraryBlocks",()=>[]);return t.useEffect(()=>{(async()=>e.length>0||(s(!0),c(await a()),s(!1)))()},[]),{data:e,isLoading:r}};exports.useUILibraryBlocks=u;
package/package.json CHANGED
@@ -1,8 +1,16 @@
1
1
  {
2
2
  "name": "@chaibuilder/sdk",
3
+ "description": "Low code visual builder",
3
4
  "private": false,
4
- "version": "1.0.9",
5
+ "author": "Suraj Air",
6
+ "license": "BSD-3-Clause",
7
+ "homepage": "https://chaibuilder.com",
8
+ "version": "1.0.10",
5
9
  "type": "module",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/chaibuilder/sdk.git"
13
+ },
6
14
  "files": [
7
15
  "dist"
8
16
  ],
@@ -34,6 +42,11 @@
34
42
  "require": "./dist/server.cjs",
35
43
  "types": "./dist/server.d.ts"
36
44
  },
45
+ "./studio": {
46
+ "import": "./dist/studio.js",
47
+ "require": "./dist/studio.cjs",
48
+ "types": "./dist/studio.d.ts"
49
+ },
37
50
  "./styles": {
38
51
  "import": "./dist/style.css",
39
52
  "require": "./dist/style.css"
@@ -50,7 +63,8 @@
50
63
  "e2e": "playwright test",
51
64
  "e2e:report": "playwright show-report",
52
65
  "e2e:ui": "playwright test --ui",
53
- "docs": "jsdoc -c jsdoc.conf.json"
66
+ "docs": "jsdoc -c jsdoc.conf.json",
67
+ "prepare": "husky"
54
68
  },
55
69
  "dependencies": {
56
70
  "@bobthered/tailwindcss-palette-generator": "3.1.1",
@@ -88,7 +102,6 @@
88
102
  "@tailwindcss/line-clamp": "^0.4.4",
89
103
  "@tailwindcss/typography": "^0.5.10",
90
104
  "@tanstack/react-query": "^5.8.4",
91
- "analytics": "^0.8.9",
92
105
  "class-variance-authority": "0.6.1",
93
106
  "clsx": "1.2.1",
94
107
  "cmdk": "0.2.0",
@@ -156,6 +169,7 @@
156
169
  "eslint": "^8.45.0",
157
170
  "eslint-plugin-react-hooks": "^4.6.0",
158
171
  "eslint-plugin-react-refresh": "^0.4.3",
172
+ "husky": "^9.0.10",
159
173
  "jest": "^29.7.0",
160
174
  "jest-environment-jsdom": "^29.7.0",
161
175
  "jotai-devtools": "^0.7.1",
@@ -168,8 +182,8 @@
168
182
  "react-router-dom": "^6.19.0",
169
183
  "tailwindcss": "^3.3.5",
170
184
  "ts-jest": "^29.1.1",
171
- "typescript": "^5.0.2",
172
- "vite": "^4.4.5",
185
+ "typescript": "^5.2.2",
186
+ "vite": "^5.0.12",
173
187
  "vite-plugin-dts": "^3.6.3"
174
188
  },
175
189
  "msw": {
@@ -1,3 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-5c3ac4f7.cjs"),n=require("react"),s=require("lodash"),b=require("jotai"),w=require("./accordion-0afd8143.cjs"),q=require("./scroll-area-bb343b86.cjs"),k=require("./tabs-860e37aa.cjs"),y=require("./useBuilderProp-adacf42f.cjs"),v=require("react-dnd"),C=require("@radix-ui/react-icons"),l=require("./index-c535cc95.cjs");require("react-i18next");const T=require("@chaibuilder/blocks"),I=require("lucide-react"),L=require("./utils-3c452dd0.cjs"),f=require("./textarea-a338ede6.cjs"),P=require("./label-167415e5.cjs"),S=require("./html-to-json-aadcbf66.cjs");require("@radix-ui/react-accordion");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");require("./MODIFIERS-4716c669.cjs");require("clsx");require("react-dom");require("@floating-ui/react-dom");require("i18next");require("flagged");require("@minoru/react-dnd-treeview");require("react-hotkeys-hook");require("flat-to-nested");require("redux-undo");require("@react-hookz/web");require("sonner");require("tailwind-merge");require("@radix-ui/react-label");require("himalaya");const M=({block:t})=>{const{type:r,icon:o,label:c}=t,{addCoreBlock:u,addPredefinedBlock:m}=l.useAddBlock(),[p]=l.useSelectedBlockIds(),[,x]=b.useAtom(l.activePanelAtom),[,i]=b.useAtom(l.addBlocksModalAtom),E=()=>{s.has(t,"blocks")?m(T.syncBlocksWithDefaults(t.blocks),s.first(p)):u(t,s.first(p)),i(!1),x("layers")},[,g,j]=v.useDrag(()=>({type:"CHAI_BLOCK",item:t}));return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(v.DragPreviewImage,{connect:j,src:"https://placehold.co/100x30/000000/FFF?text="+(c||r).replace(/ /g,"+")}),e.jsxRuntimeExports.jsxs(y.Tooltip,{children:[e.jsxRuntimeExports.jsx(y.TooltipTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs("button",{onClick:E,type:"button",ref:g,className:"cursor-grab space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50",children:[n.createElement(o||C.BoxIcon,{className:"w-4 h-4 mx-auto"}),e.jsxRuntimeExports.jsx("p",{className:"truncate text-xs",children:c||r})]})}),e.jsxRuntimeExports.jsx(y.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{children:c||r})})]})]})},F=({block:t,closePopover:r})=>{var j;const[o,c]=n.useState(!1),u=y.useBuilderProp("getExternalPredefinedBlock"),{addCoreBlock:m,addPredefinedBlock:p}=l.useAddBlock(),[x]=l.useSelectedBlockIds(),[,i,E]=v.useDrag(()=>({type:"CHAI_BLOCK",item:t}),[t]),g=n.useCallback(async R=>{if(R.stopPropagation(),s.has(t,"component")){m(t,s.first(x)),r();return}c(!0);const a=await u(t);s.isEmpty(a)||p(T.syncBlocksWithDefaults(a),s.first(x)),r()},[t]);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(v.DragPreviewImage,{connect:E,src:"https://placehold.co/100x30/000000/FFF?text="+((j=t.name||t.label)==null?void 0:j.replace(" ","+"))}),e.jsxRuntimeExports.jsxs("div",{ref:i,onClick:o?()=>{}:g,className:"relative cursor-grab overflow-hidden rounded-md border border-transparent duration-200 hover:scale-x-105 hover:border-foreground/20 hover:shadow-2xl",children:[o&&e.jsxRuntimeExports.jsxs("div",{className:"absolute flex h-full w-full items-center justify-center bg-black bg-opacity-70",children:[e.jsxRuntimeExports.jsx(I.Loader,{className:"animate-spin",size:15,color:"white"})," ",e.jsxRuntimeExports.jsx("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),t.preview?e.jsxRuntimeExports.jsx("img",{src:t.preview,className:"min-h-[50px] w-full rounded-md border border-gray-300",alt:t.name}):e.jsxRuntimeExports.jsx("div",{className:"flex h-20 items-center justify-center rounded-md border border-border border-gray-300 bg-gray-200",children:e.jsxRuntimeExports.jsx("p",{className:"max-w-xs text-center text-sm text-gray-700",children:t.name})})]})]})},H=()=>{const{data:t,isLoading:r}=l.useUILibraryBlocks(),o=T.useChaiBlocks(),c=s.filter(s.values(o),{category:"custom"}),u=s.groupBy(c,"group"),m=s.groupBy(t,"group"),[p,x]=n.useState(null),i=n.useMemo(()=>s.mergeWith(u,m,(a,h)=>{if(s.isArray(a)&&s.isArray(h))return[...a,...h]}),[u,m]),[,E]=b.useAtom(l.addBlocksModalAtom),[g,j]=n.useState("Navbar"),R=s.get(i,g,[]);return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full max-h-full overflow-hidden py-2",children:[e.jsxRuntimeExports.jsx("ul",{className:"sticky top-0 h-full w-48 space-y-1 overflow-y-auto border-r px-2",children:r?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("li",{className:"h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"}),e.jsxRuntimeExports.jsx("li",{className:"mt-2 h-8 w-full animate-pulse bg-gray-200"})]}):n.Children.toArray(s.map(i,(a,h)=>e.jsxRuntimeExports.jsx("li",{onMouseOut:()=>{clearTimeout(p),x(null)},onMouseEnter:()=>{const B=setTimeout(()=>{j(h)},300);x(B)},onClick:()=>j(h),className:L.cn("-mx-2 cursor-default rounded-md rounded-r-none px-2 py-1 text-sm font-medium capitalize",g===h?"bg-blue-500 text-white":" text-gray-700 hover:bg-foreground/10"),children:h})))}),e.jsxRuntimeExports.jsx("div",{className:"h-full w-full space-y-2 overflow-y-auto px-8",children:n.Children.toArray(R.map(a=>e.jsxRuntimeExports.jsx(F,{block:a,closePopover:()=>E(!1)})))})]})},D=()=>{const[t,r]=n.useState(""),{addPredefinedBlock:o}=l.useAddBlock(),[c]=l.useSelectedBlockIds(),[,u]=b.useAtom(l.addBlockOffCanvasAtom),[,m]=b.useAtom(l.activePanelAtom),[,p]=b.useAtom(l.addBlocksModalAtom),x=()=>{const i=S.getBlocksFromHTML(t);o([...i],s.first(c)||null),r(""),u(!1),m("layers"),p(!1)};return e.jsxRuntimeExports.jsxs(f.Card,{className:"border-border/0 p-0 shadow-none",children:[e.jsxRuntimeExports.jsxs(f.CardHeader,{className:"p-3",children:[e.jsxRuntimeExports.jsx(f.CardTitle,{children:"Import HTML"}),e.jsxRuntimeExports.jsx(f.CardDescription,{children:"Use HTML snippets from component libraries like Tailwind UI, Flowbite, Preline, Kitwind, Tailblocks etc. or just copy paste your own HTML code. Only Tailwind CSS markup is supported."})]}),e.jsxRuntimeExports.jsx(f.CardContent,{className:"space-y-2 px-3 py-0",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(P.Label,{htmlFor:"current",className:"text-sm",children:"Enter HTML Code:"}),e.jsxRuntimeExports.jsx(f.Textarea,{autoFocus:!0,tabIndex:1,ref:i=>i&&i.focus(),defaultValue:t,onChange:i=>r(i.target.value),rows:12,placeholder:`<div>
2
- <h1>Enter code here</h1>
3
- </div>`,className:"resize-none overflow-x-auto whitespace-pre font-mono font-normal"})]})}),e.jsxRuntimeExports.jsxs(f.CardFooter,{className:"flex flex-col justify-end p-3",children:[e.jsxRuntimeExports.jsx(y.Button,{disabled:t.trim()==="",onClick:()=>x(),size:"sm",className:"w-full",children:"Import"}),e.jsxRuntimeExports.jsxs(f.Alert,{variant:"default",className:"mt-2 p-1 text-blue-400",children:[e.jsxRuntimeExports.jsx(C.ExclamationTriangleIcon,{className:"h-4 w-4"}),e.jsxRuntimeExports.jsx(f.AlertTitle,{className:"text-sm leading-4",children:"Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page."})]})]})]})},O=D,N=["ListItem","TableHead","TableBody","TableRow","TableCell","Column"],U=(t,r)=>{if(!t)return!s.includes(N,r);const o=t._type;return o==="List"?r==="ListItem":o==="Table"?r==="TableHead"||r==="TableBody":o==="TableHead"||o==="TableBody"?r==="TableRow":o==="TableRow"?r==="TableCell":o==="Row"?r==="Column":!s.includes(N,r)},z=()=>{const[t,r]=n.useState("core"),[o,c]=n.useState("basic"),u=T.useChaiBlocks(),[,m]=b.useAtom(l.showPredefinedBlockCategoryAtom),[,p]=b.useAtom(l.addBlocksModalAtom),[x]=l.useSelectedBlockIds(),i=l.useAllBlocks(),E=s.find(i,{_id:s.first(x)}),{data:g,isLoading:j}=l.useUILibraryBlocks(),R=s.groupBy(s.filter(u,d=>U(E,d.type)),"category"),a=s.uniq(s.map(R.core,"group"));n.useEffect(()=>{!s.includes(a,o)&&!s.isEmpty(a)&&!s.isEmpty(o)&&c(s.first(a))},[a,o]);const h=d=>c(A=>A===d?"":d),B=!j&&!s.isEmpty(g)||s.find(s.values(u),{category:"custom"})!==void 0;return e.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-2 flex justify-between rounded-md bg-background/30 p-1",children:[e.jsxRuntimeExports.jsxs("h1",{className:"flex flex-col items-baseline px-1 text-2xl font-semibold xl:flex-row",children:["Add block",e.jsxRuntimeExports.jsx("span",{className:"p-0 text-xs font-light leading-3 opacity-80 xl:pl-1",children:t==="html"?"(Enter or paste your own HTML code)":"(Drag & drop into tree view or click to add)"})]}),e.jsxRuntimeExports.jsxs("button",{onClick:()=>p(!1),className:"flex h-max items-center gap-x-1 rounded-full border p-px text-xs text-gray-800 hover:bg-gray-100 md:p-2",children:[e.jsxRuntimeExports.jsx(C.Cross1Icon,{width:12})," Close"]})]}),e.jsxRuntimeExports.jsx(k.Tabs,{onValueChange:d=>{m(""),r(d)},value:t,className:"h-max",children:e.jsxRuntimeExports.jsxs(k.TabsList,{className:"grid w-full "+(B?"grid-cols-3":"grid-cols-2"),children:[e.jsxRuntimeExports.jsx(k.TabsTrigger,{value:"core",children:"Core"}),B?e.jsxRuntimeExports.jsx(k.TabsTrigger,{value:"ui-blocks",children:"UI Blocks"}):null,e.jsxRuntimeExports.jsx(k.TabsTrigger,{value:"html",children:"Import"})]})}),t==="core"&&e.jsxRuntimeExports.jsx(q.ScrollArea,{className:"-mx-1.5 h-full",children:e.jsxRuntimeExports.jsx(w.Accordion,{type:"single",value:o,className:"w-full px-3",children:n.Children.toArray(s.map(a,d=>s.reject(s.filter(s.values(R.core),{group:d}),{hidden:!0}).length?e.jsxRuntimeExports.jsxs(w.AccordionItem,{value:d,className:"border-border",children:[e.jsxRuntimeExports.jsx(w.AccordionTrigger,{onClick:()=>h(d),className:"py-2 capitalize",children:d}),e.jsxRuntimeExports.jsx(w.AccordionContent,{children:e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 gap-2",children:n.Children.toArray(s.reject(s.filter(s.values(R.core),{group:d}),{hidden:!0}).map(A=>e.jsxRuntimeExports.jsx(M,{block:A})))})})]}):null))})}),t==="ui-blocks"&&e.jsxRuntimeExports.jsx(n.Suspense,{fallback:e.jsxRuntimeExports.jsx(y.Skeleton,{className:"h-32 w-full"}),children:e.jsxRuntimeExports.jsx(H,{})}),t==="html"&&e.jsxRuntimeExports.jsx(O,{})]})};exports.default=z;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./jsx-runtime-5c3ac4f7.cjs"),O=require("react"),C=require("@rjsf/validator-ajv8"),B=require("@rjsf/core"),j=require("./index-c535cc95.cjs");require("react-i18next");const R=require("./useBuilderProp-adacf42f.cjs"),e=require("@chaibuilder/blocks"),P=require("lodash");require("./MODIFIERS-4716c669.cjs");require("clsx");require("@radix-ui/react-scroll-area");require("react-dom");require("@floating-ui/react-dom");require("jotai");require("i18next");require("flagged");require("react-dnd");require("@minoru/react-dnd-treeview");require("./utils-3c452dd0.cjs");require("tailwind-merge");require("react-hotkeys-hook");require("flat-to-nested");require("./html-to-json-aadcbf66.cjs");require("himalaya");require("redux-undo");require("@react-hookz/web");require("@radix-ui/react-icons");require("sonner");require("lucide-react");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-tooltip");require("@radix-ui/react-toast");function k(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const a=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}return t.default=r,Object.freeze(t)}const c=k(O),v=[{title:"Roboto",value:"Roboto"},{title:"Open Sans",value:"Open Sans"},{title:"Montserrat",value:"Montserrat"},{title:"Lato",value:"Lato"},{title:"Poppins",value:"Poppins"},{title:"Oswald",value:"Oswald"},{title:"Raleway",value:"Raleway"},{title:"Ubuntu",value:"Ubuntu"},{title:"Nunito",value:"Nunito"},{title:"Merriweather",value:"Merriweather"},{title:"Nunito Sans",value:"Nunito Sans"},{title:"Playfair Display",value:"Playfair Display"},{title:"Rubik",value:"Rubik"},{title:"Inter",value:"Inter"},{title:"Lora",value:"Lora"},{title:"Kanit",value:"Kanit"},{title:"Fira Sans",value:"Fira Sans"},{title:"Hind",value:"Hind"},{title:"Quicksand",value:"Quicksand"},{title:"Mulish",value:"Mulish"},{title:"Barlow",value:"Barlow"},{title:"Inconsolata",value:"Inconsolata"},{title:"Titillium Web",value:"Titillium Web"},{title:"Heebo",value:"Heebo"},{title:"IBM Plex Sans",value:"IBM Plex Sans"},{title:"DM Sans",value:"DM Sans"},{title:"Nanum Gothic",value:"Nanum Gothic"},{title:"Karla",value:"Karla"},{title:"Arimo",value:"Arimo"},{title:"Cabin",value:"Cabin"},{title:"Oxygen",value:"Oxygen"},{title:"Overpass",value:"Overpass"},{title:"Assistant",value:"Assistant"},{title:"Tajawal",value:"Tajawal"},{title:"Play",value:"Play"},{title:"Exo",value:"Exo"},{title:"Cinzel",value:"Cinzel"},{title:"Faustina",value:"Faustina"},{title:"Philosopher",value:"Philosopher"},{title:"Gelasio",value:"Gelasio"},{title:"Sofia Sans Condensed",value:"Sofia Sans Condensed"},{title:"Noto Sans Devanagari",value:"Noto Sans Devanagari"},{title:"Actor",value:"Actor"},{title:"Epilogue",value:"Epilogue"},{title:"Glegoo",value:"Glegoo"},{title:"Overlock",value:"Overlock"},{title:"Lustria",value:"Lustria"},{title:"Ovo",value:"Ovo"},{title:"Suranna",value:"Suranna"}],D=()=>{const r=R.useBuilderProp("onSaveBrandingOptions",async()=>{}),[t,i]=j.useBrandingOptions(),a=c.useRef(t);c.useEffect(()=>()=>{P.isEqual(t,a.current)||r(a.current)},[]);const p=({formData:l},u)=>{u&&(i(l),a.current=l)},{bodyFont:g,headingFont:f,primaryColor:b,bodyTextDarkColor:m,bodyTextLightColor:y,bodyBgDarkColor:q,secondaryColor:x,bodyBgLightColor:h,roundedCorners:S}=t,s={headingFont:e.SelectOption({title:"Heading font",default:f,options:v}),bodyFont:e.SelectOption({title:"Body font",default:g,options:v}),roundedCorners:e.Numeric({title:"Rounded Corner",default:parseInt(S||5,10)}),primaryColor:e.Color({title:"Primary",default:b}),secondaryColor:e.Color({title:"Secondary",default:x}),bodyBgLightColor:e.Color({title:"Body Background (Light)",default:h}),bodyBgDarkColor:e.Color({title:"Body Background (Dark)",default:q}),bodyTextLightColor:e.Color({title:"Body Text (Light)",default:m}),bodyTextDarkColor:e.Color({title:"Body Text (Dark)",default:y})},n={type:"object",properties:{}},d={};return Object.keys(s).forEach(l=>{const u=s[l];return n.properties||(n.properties={}),n.properties[l]=u.schema,d[l]=u.uiSchema,!0}),o.jsxRuntimeExports.jsxs("div",{className:"flex h-full select-none flex-col",children:[o.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-background/30 p-1",children:o.jsxRuntimeExports.jsx("h1",{className:"px-1 font-semibold",children:"Branding Options"})}),o.jsxRuntimeExports.jsx("div",{className:"-mx-2",children:o.jsxRuntimeExports.jsx(B,{idSeparator:".",autoComplete:"off",omitExtraData:!0,liveOmit:!0,liveValidate:!0,uiSchema:d,schema:n,formData:t,validator:C,onChange:p})})]})};exports.default=D;