@chaibuilder/sdk 4.0.0-beta.3 → 4.0.0-beta.6

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 (186) hide show
  1. package/dist/{2SSKDMRQ-BnsZi3K3.cjs → 2SSKDMRQ-BIryEtW-.cjs} +1 -1
  2. package/dist/{2SSKDMRQ-CnSDkQcy.js → 2SSKDMRQ-trME0kvt.js} +2 -2
  3. package/dist/{AP7HFJJL-B31839PG.cjs → AP7HFJJL-5ZR38Hyh.cjs} +1 -1
  4. package/dist/{AP7HFJJL-CymCmW14.js → AP7HFJJL-CAGB9iMp.js} +1 -1
  5. package/dist/IconPicker-CQ-BgNNU.cjs +1 -0
  6. package/dist/{IconPicker-B1rWC-Ex.js → IconPicker-Mu75ni5T.js} +8 -7
  7. package/dist/{WDYDFRGG-BUVnbAci.js → WDYDFRGG-Cd4hRWj-.js} +2 -2
  8. package/dist/{WDYDFRGG-BxhOCHc3.cjs → WDYDFRGG-n8sBZVFG.cjs} +1 -1
  9. package/dist/{actions-registery-YnFmU21O.cjs → actions-registery-JdxhXhT6.cjs} +1 -1
  10. package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-y_ENc8zj.js} +2 -2
  11. package/dist/actions.cjs +1 -1
  12. package/dist/actions.js +2 -2
  13. package/dist/active-in-another-tab-CZLV-uAW.cjs +1 -0
  14. package/dist/active-in-another-tab-Cb6tnX9u.js +35 -0
  15. package/dist/{add-new-language-page-WmlCnytQ.js → add-new-language-page-BKcBaqZu.js} +54 -53
  16. package/dist/add-new-language-page-C3UzNV7W.cjs +1 -0
  17. package/dist/{add-new-page-soZ8GAkN.cjs → add-new-page-mULv9r3z.cjs} +1 -1
  18. package/dist/{add-new-page-VW2wAYZp.js → add-new-page-pH3PwqJe.js} +2 -2
  19. package/dist/ai-panel-content-BPgRdgye.cjs +1 -0
  20. package/dist/{ai-panel-content-D_o7Q_A-.js → ai-panel-content-CNxN84pv.js} +12 -11
  21. package/dist/{ai-panel-default-lang-DnElspF0.js → ai-panel-default-lang-CYcHjk8U.js} +40 -40
  22. package/dist/{ai-panel-default-lang-COYaxNwn.cjs → ai-panel-default-lang-DhTPtPgD.cjs} +2 -2
  23. package/dist/{ai-panel-other-lang-CkynNlAU.cjs → ai-panel-other-lang-CGNU3-FI.cjs} +1 -1
  24. package/dist/{ai-panel-other-lang-Dp0E9_Hx.js → ai-panel-other-lang-D8Ofvj8F.js} +8 -8
  25. package/dist/ai-prompt-input-CUutJjlf.cjs +1 -0
  26. package/dist/{ai-prompt-input-Bhc0ds7X.js → ai-prompt-input-Ceuy5bs3.js} +68 -67
  27. package/dist/{ai-translation-prompt-CZ55HQmo.js → ai-translation-prompt-BiepZRcN.js} +2 -2
  28. package/dist/ai-translation-prompt-CoCPLEed.cjs +1 -0
  29. package/dist/{apply-binding-6iwlED02.js → apply-binding-BvWfJCSZ.js} +204 -196
  30. package/dist/apply-binding-IsUf6UWJ.cjs +1 -0
  31. package/dist/{code-display-DhD_RBcg.js → code-display-Ck81Id9K.js} +1 -1
  32. package/dist/code-display-DloSPyPr.cjs +1 -0
  33. package/dist/code-editor-C1ewJzDJ.cjs +1 -0
  34. package/dist/{code-editor-DRIAnNbb.js → code-editor-Z14ByBIv.js} +11 -10
  35. package/dist/{continue-editing-in-this-client-CS2aQ7yY.js → continue-editing-in-this-client-Byi6ER3L.js} +10 -9
  36. package/dist/continue-editing-in-this-client-k9Ab5E63.cjs +1 -0
  37. package/dist/core-Dr7QYemB.js +56 -0
  38. package/dist/core-Y0lXLwkq.cjs +1 -0
  39. package/dist/core.cjs +1 -1
  40. package/dist/core.d.ts +3 -3
  41. package/dist/core.js +32 -31
  42. package/dist/css-import-modal--bSJR-_y.cjs +13 -0
  43. package/dist/{css-import-modal-Byg6wV0O.js → css-import-modal-De7Kvg5C.js} +4 -3
  44. package/dist/{delete-design-token-BRZZiWtQ.js → delete-design-token-B97CnFDU.js} +1 -1
  45. package/dist/{delete-design-token-DkVs1oBf.cjs → delete-design-token-C6s-ESB_.cjs} +1 -1
  46. package/dist/delete-page-Djn97HiP.cjs +1 -0
  47. package/dist/{delete-page-BzyX9TN-.js → delete-page-Dnf97ZHP.js} +11 -10
  48. package/dist/{design-token-usage-xQs6SlaJ.js → design-token-usage-B-SykAjD.js} +14 -13
  49. package/dist/design-token-usage-OTd93kS8.cjs +1 -0
  50. package/dist/digital-asset-manager-DHYRXaaq.cjs +1 -0
  51. package/dist/{digital-asset-manager-DbtwzxRz.js → digital-asset-manager-b8gDuLnI.js} +6 -5
  52. package/dist/{duplicate-page-BR7Dlo9d.js → duplicate-page-Bdtpl7_R.js} +19 -18
  53. package/dist/duplicate-page-C4Ovp8Ff.cjs +1 -0
  54. package/dist/dynamic-page-selector-B8DdnfrF.cjs +1 -0
  55. package/dist/{dynamic-page-selector-Cb5r_W8s.js → dynamic-page-selector-BVnIM1Rq.js} +15 -14
  56. package/dist/get-chai-builder-tailwind-config-DNp8Vhme.cjs +1 -0
  57. package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-k8l5sdcw.js} +5 -5
  58. package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-BApShjRz.cjs} +1 -1
  59. package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-DDVRJQ6Z.js} +1 -1
  60. package/dist/{image-editor-G-K28aTS.cjs → image-editor-C2zOHeKv.cjs} +1 -1
  61. package/dist/{image-editor-DV8kUKhl.js → image-editor-cckqPmk5.js} +1 -1
  62. package/dist/index-B0e71wJ1.cjs +160 -0
  63. package/dist/{index-ZuacEL1j.js → index-Bn0fFN58.js} +665 -663
  64. package/dist/{index-Ct7ElCGK.js → index-CAhEmHYP.js} +3744 -3920
  65. package/dist/index-DKuwxj1x.cjs +5 -0
  66. package/dist/{json-diff-viewer-D7z4zNvv.cjs → json-diff-viewer-D9DVIBz4.cjs} +3 -3
  67. package/dist/{json-diff-viewer-krslPepD.js → json-diff-viewer-DNizzMnu.js} +5 -4
  68. package/dist/lang-panel-C1dbn163.cjs +1 -0
  69. package/dist/{lang-panel-BwIewMyw.js → lang-panel-DL_BtSRD.js} +15 -14
  70. package/dist/manage-design-tokens-CXjYkarE.cjs +1 -0
  71. package/dist/{manage-design-tokens-Caz_20VK.js → manage-design-tokens-xxMO_RYg.js} +12 -11
  72. package/dist/{mark-as-template-D295ZQtU.js → mark-as-template-Ba2bmVd9.js} +17 -16
  73. package/dist/mark-as-template-DF1KIMr0.cjs +1 -0
  74. package/dist/{nested-path-selector-content-CKYYK-C5.js → nested-path-selector-content-Br1IWhK5.js} +24 -23
  75. package/dist/nested-path-selector-content-Cuk7NB-u.cjs +1 -0
  76. package/dist/{no-language-page-content-BvqRBP6y.js → no-language-page-content-9B2Fm-on.js} +10 -9
  77. package/dist/no-language-page-content-CxTp-LIM.cjs +1 -0
  78. package/dist/{no-language-page-dialog-PjNqTUpl.js → no-language-page-dialog-CPlKMyb8.js} +2 -2
  79. package/dist/{no-language-page-dialog-BcEoqyQB.cjs → no-language-page-dialog-DynACvgV.cjs} +1 -1
  80. package/dist/{page-creator-DiOITEMw.js → page-creator-BtyJz2sx.js} +115 -114
  81. package/dist/page-creator-Cbfv9N0P.cjs +1 -0
  82. package/dist/{page-lock-Bfbs6RgL.js → page-lock-CzsxrmN5.js} +2 -2
  83. package/dist/{page-lock-BdYmCks0.cjs → page-lock-fRos9wRU.cjs} +1 -1
  84. package/dist/{page-locked-dialog-B6MKTRfY.js → page-locked-dialog-D2q9qkPk.js} +18 -15
  85. package/dist/page-locked-dialog-D57d2gvn.cjs +1 -0
  86. package/dist/{page-manager-new-CzX22g2n.js → page-manager-new-D6DVIx2S.js} +30 -29
  87. package/dist/page-manager-new-aE198gKS.cjs +1 -0
  88. package/dist/{page-manager-search-and-filter-CM0UMb6U.js → page-manager-search-and-filter-CuZkQaZg.js} +13 -12
  89. package/dist/page-manager-search-and-filter-DGQEgKzy.cjs +1 -0
  90. package/dist/{page-revisions-content-NH9JK4Ey.js → page-revisions-content-5rbicFbD.js} +34 -31
  91. package/dist/page-revisions-content-CefqOvKX.cjs +1 -0
  92. package/dist/pages.cjs +1 -1
  93. package/dist/pages.d.ts +4 -4
  94. package/dist/pages.js +1 -1
  95. package/dist/{plugin-C6rgJDNQ.cjs → plugin-BGlQf0iy.cjs} +1 -1
  96. package/dist/{plugin-3ZKK6RXm.js → plugin-C-ht41UZ.js} +1 -1
  97. package/dist/publish-pages-content-DBb8M3TG.cjs +1 -0
  98. package/dist/{publish-pages-content-D9aixMN5.js → publish-pages-content-WeGk-YLC.js} +66 -65
  99. package/dist/register-chai-top-bar-BqwKw4uy.cjs +1 -0
  100. package/dist/register-chai-top-bar-ESJHs5s-.js +237 -0
  101. package/dist/render.cjs +2 -2
  102. package/dist/render.d.ts +2 -2
  103. package/dist/render.js +87 -80
  104. package/dist/rte-widget-modal-DBoPRXq-.cjs +1 -0
  105. package/dist/{rte-widget-modal-DOJEXLIf.js → rte-widget-modal-J-_AytmK.js} +15 -14
  106. package/dist/runtime.cjs +1 -1
  107. package/dist/runtime.d.ts +168 -4
  108. package/dist/runtime.js +68 -38
  109. package/dist/save-to-lib-0ysmXVbI.cjs +1 -0
  110. package/dist/{save-to-lib-eiOc_SSN.js → save-to-lib-CQQxoovF.js} +39 -38
  111. package/dist/sdk.css +1 -1
  112. package/dist/selected-block-display-BWupQFoQ.cjs +16 -0
  113. package/dist/{selected-block-display-CBFePS19.js → selected-block-display-CgoXS8Hr.js} +37 -36
  114. package/dist/{seo-panel-C1-iMOR1.js → seo-panel-B798Myp_.js} +12 -11
  115. package/dist/seo-panel-BkFbXIL0.cjs +2 -0
  116. package/dist/{shared-json-ld-B4PxAM_0.js → shared-json-ld-Clg_UEhd.js} +68 -67
  117. package/dist/shared-json-ld-Cn3MCW6I.cjs +1 -0
  118. package/dist/slug-input-BHyD8cxk.cjs +1 -0
  119. package/dist/{slug-input-AwNJs9im.js → slug-input-hX5VaZpj.js} +9 -8
  120. package/dist/supabase-actions.cjs +1 -1
  121. package/dist/supabase-actions.d.ts +1 -1
  122. package/dist/supabase-actions.js +1 -1
  123. package/dist/take-over-request-Dzczo20q.cjs +1 -0
  124. package/dist/{take-over-request-C4FeDtN_.js → take-over-request-s1L5Yofb.js} +17 -16
  125. package/dist/theme-panel-footer-NTNCL0SW.cjs +1 -0
  126. package/dist/{theme-panel-footer-uBQqSJXm.js → theme-panel-footer-sK6bYhEb.js} +11 -10
  127. package/dist/translation-warning-modal-BfM4HGck.cjs +1 -0
  128. package/dist/{translation-warning-modal-B64YqlbI.js → translation-warning-modal-Jadkcver.js} +9 -8
  129. package/dist/unmark-as-template-CqkHI3gR.cjs +1 -0
  130. package/dist/{unmark-as-template-CZ9sQp_P.js → unmark-as-template-D5b775eR.js} +11 -10
  131. package/dist/unpublish-page-BT5bCfs6.cjs +1 -0
  132. package/dist/unpublish-page-DLLLgY43.js +28 -0
  133. package/dist/utils.cjs +1 -1
  134. package/dist/utils.d.ts +3 -0
  135. package/dist/utils.js +2 -2
  136. package/dist/web-blocks.cjs +1 -1
  137. package/dist/web-blocks.js +5 -5
  138. package/dist/{web-preview-Djy6WIyj.js → web-preview-C_yFwxEe.js} +2 -2
  139. package/dist/web-preview-DU1MgppY.cjs +1 -0
  140. package/package.json +4 -2
  141. package/dist/IconPicker-DREyo007.cjs +0 -1
  142. package/dist/active-in-another-tab-B47YjQGN.cjs +0 -1
  143. package/dist/active-in-another-tab-CyjngVA6.js +0 -34
  144. package/dist/add-new-language-page-88xzrUy8.cjs +0 -1
  145. package/dist/ai-panel-content-7zCil042.cjs +0 -1
  146. package/dist/ai-prompt-input-CThbVp0_.cjs +0 -1
  147. package/dist/ai-translation-prompt-C2kJQFDX.cjs +0 -1
  148. package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
  149. package/dist/code-display-BnqzqzoP.cjs +0 -1
  150. package/dist/code-editor-o3___nu2.cjs +0 -1
  151. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +0 -1
  152. package/dist/core-BoRDjj4h.cjs +0 -1
  153. package/dist/core-yvI6kCyw.js +0 -56
  154. package/dist/css-import-modal-CyqkXWCO.cjs +0 -13
  155. package/dist/delete-page-DxX7PFIE.cjs +0 -1
  156. package/dist/design-token-usage-CAHzEGgJ.cjs +0 -1
  157. package/dist/digital-asset-manager--uO8Agia.cjs +0 -1
  158. package/dist/duplicate-page-CaNAbXwV.cjs +0 -1
  159. package/dist/dynamic-page-selector-Cxk_gjni.cjs +0 -1
  160. package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
  161. package/dist/index-DF5DEvqb.cjs +0 -160
  162. package/dist/index-WQwzsC7A.cjs +0 -5
  163. package/dist/lang-panel-DT96k1xg.cjs +0 -1
  164. package/dist/manage-design-tokens-CrmLe7UT.cjs +0 -1
  165. package/dist/mark-as-template-W3LmpiqN.cjs +0 -1
  166. package/dist/nested-path-selector-content-CoS_d3dc.cjs +0 -1
  167. package/dist/no-language-page-content-DkfeMl90.cjs +0 -1
  168. package/dist/page-creator-C4gc5NSC.cjs +0 -1
  169. package/dist/page-locked-dialog-B1FAtK92.cjs +0 -1
  170. package/dist/page-manager-new-CHDueBDk.cjs +0 -1
  171. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +0 -1
  172. package/dist/page-revisions-content-ChY-4f2V.cjs +0 -1
  173. package/dist/publish-pages-content-x-JuSFJ9.cjs +0 -1
  174. package/dist/rte-widget-modal-BaHIuEjF.cjs +0 -1
  175. package/dist/save-to-lib-Cgpxw8-g.cjs +0 -1
  176. package/dist/selected-block-display-BgRY82CT.cjs +0 -16
  177. package/dist/seo-panel-DfAb8U7W.cjs +0 -2
  178. package/dist/shared-json-ld-DzG398hr.cjs +0 -1
  179. package/dist/slug-input-C_ijLQ_X.cjs +0 -1
  180. package/dist/take-over-request-BNxcjY2j.cjs +0 -1
  181. package/dist/theme-panel-footer-Cq9pljro.cjs +0 -1
  182. package/dist/translation-warning-modal-BZAcwM2_.cjs +0 -1
  183. package/dist/unmark-as-template-EVvk0vmp.cjs +0 -1
  184. package/dist/unpublish-page-D4VwOlxc.js +0 -27
  185. package/dist/unpublish-page-bdSmwAVQ.cjs +0 -1
  186. package/dist/web-preview-Cio70gk5.cjs +0 -1
@@ -0,0 +1,237 @@
1
+ import { has as E, set as N, values as w, filter as V } from "lodash-es";
2
+ import * as o from "react";
3
+ import { useMemo as i, useState as u } from "react";
4
+ import { useAtom as R } from "jotai";
5
+ import { atomWithStorage as U } from "jotai/utils";
6
+ import { jsx as s, jsxs as g } from "react/jsx-runtime";
7
+ import { cva as S } from "class-variance-authority";
8
+ import { clsx as j } from "clsx";
9
+ import { twMerge as H } from "tailwind-merge";
10
+ import { Slot as $ } from "@radix-ui/react-slot";
11
+ import { ExclamationTriangleIcon as z } from "@radix-ui/react-icons";
12
+ import { useTranslation as G } from "react-i18next";
13
+ function l(...e) {
14
+ return H(j(e));
15
+ }
16
+ const p = {}, de = (e, t) => {
17
+ p[e] = {
18
+ id: e,
19
+ component: t,
20
+ type: "widget"
21
+ };
22
+ }, ue = (e, t) => {
23
+ p[e] = {
24
+ id: e,
25
+ component: t,
26
+ type: "field"
27
+ };
28
+ }, ge = (e, t) => {
29
+ p[e] = {
30
+ id: e,
31
+ component: t,
32
+ type: "template"
33
+ };
34
+ }, fe = (e) => Object.values(p).filter((t) => t.type === e).reduce(
35
+ (t, r) => (t[r.id] = r.component, t),
36
+ {}
37
+ ), y = {}, me = (e, t) => {
38
+ E(y, e) && console.warn(`Add block tab with id ${e} already registered`), N(y, e, { id: e, ...t });
39
+ }, pe = () => i(() => w(y), []), f = {}, W = (e, t) => {
40
+ if (f[e])
41
+ throw new Error(`Flag ${e} already exists`);
42
+ f[e] = { key: e, value: !1, ...t };
43
+ }, he = (e) => {
44
+ Object.entries(e).forEach(([t, r]) => {
45
+ if (f[t])
46
+ throw new Error(`Flag ${t} already exists`);
47
+ W(t, r);
48
+ });
49
+ }, ve = () => f, _ = U("chai-feature-flags", []), q = (e) => {
50
+ const [t] = R(_);
51
+ return t.includes(e);
52
+ }, be = (e) => {
53
+ const [t, r] = R(_);
54
+ return () => {
55
+ t.includes(e) ? r(t.filter((n) => n !== e)) : r([...t, e]);
56
+ };
57
+ }, xe = ({ flagKey: e, children: t }) => q(e) ? t : null;
58
+ let A = {};
59
+ const ye = (e, t) => {
60
+ A[e] = { ...t, id: e };
61
+ }, Ce = (e) => A[e], we = () => w(A), J = S(
62
+ "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
63
+ {
64
+ variants: {
65
+ variant: {
66
+ default: "bg-background text-foreground",
67
+ destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"
68
+ }
69
+ },
70
+ defaultVariants: {
71
+ variant: "default"
72
+ }
73
+ }
74
+ ), B = o.forwardRef(({ className: e, variant: t, ...r }, a) => /* @__PURE__ */ s("div", { ref: a, role: "alert", className: l(J({ variant: t }), e), ...r }));
75
+ B.displayName = "Alert";
76
+ const K = o.forwardRef(
77
+ ({ className: e, ...t }, r) => /* @__PURE__ */ s("h5", { ref: r, className: l("mb-1 font-medium leading-none tracking-tight", e), ...t })
78
+ );
79
+ K.displayName = "AlertTitle";
80
+ const L = o.forwardRef(
81
+ ({ className: e, ...t }, r) => /* @__PURE__ */ s("div", { ref: r, className: l("text-sm [&_p]:leading-relaxed", e), ...t })
82
+ );
83
+ L.displayName = "AlertDescription";
84
+ const X = S(
85
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
86
+ {
87
+ variants: {
88
+ variant: {
89
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
90
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
91
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
92
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
93
+ ghost: "hover:bg-accent hover:text-accent-foreground",
94
+ link: "text-primary underline-offset-4 hover:underline"
95
+ },
96
+ size: {
97
+ default: "h-9 px-4 py-2",
98
+ sm: "h-8 rounded-md px-3 text-xs",
99
+ lg: "h-10 rounded-md px-8",
100
+ icon: "h-9 w-9"
101
+ }
102
+ },
103
+ defaultVariants: {
104
+ variant: "default",
105
+ size: "default"
106
+ }
107
+ }
108
+ ), C = o.forwardRef(
109
+ ({ className: e, variant: t, size: r, asChild: a = !1, ...n }, h) => /* @__PURE__ */ s(
110
+ a ? $ : "button",
111
+ {
112
+ className: l(X({ variant: t, size: r, className: e })),
113
+ ref: h,
114
+ ...n
115
+ }
116
+ )
117
+ );
118
+ C.displayName = "Button";
119
+ const I = o.forwardRef(
120
+ ({ className: e, type: t, ...r }, a) => /* @__PURE__ */ s(
121
+ "input",
122
+ {
123
+ type: t,
124
+ className: l(
125
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
126
+ e
127
+ ),
128
+ ref: a,
129
+ ...r
130
+ }
131
+ )
132
+ );
133
+ I.displayName = "Input";
134
+ const Y = ({ close: e, onSelect: t, mode: r = "image" }) => {
135
+ const [a, n] = u(""), [h, v] = u(!1), [P, b] = u(!1), [F, c] = u(null), D = async (x) => {
136
+ if (!x.trim()) {
137
+ b(!1), c("Please enter a URL");
138
+ return;
139
+ }
140
+ try {
141
+ v(!0), c(null), b(!0), c(null);
142
+ } catch {
143
+ b(!1), c("Error validating URL");
144
+ } finally {
145
+ v(!1);
146
+ }
147
+ }, { t: d } = G();
148
+ return /* @__PURE__ */ g("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
149
+ /* @__PURE__ */ s("h2", { className: "text-xl font-semibold", children: d(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
150
+ F && /* @__PURE__ */ g(B, { variant: "destructive", children: [
151
+ /* @__PURE__ */ s(z, { className: "h-4 w-4" }),
152
+ /* @__PURE__ */ s(L, { children: F })
153
+ ] }),
154
+ /* @__PURE__ */ g("div", { className: "flex flex-col gap-4", children: [
155
+ /* @__PURE__ */ s(
156
+ I,
157
+ {
158
+ placeholder: d(`Enter ${r} URL`),
159
+ value: a,
160
+ onChange: (x) => n(x.target.value),
161
+ onKeyUp: () => D(a)
162
+ }
163
+ ),
164
+ /* @__PURE__ */ g("div", { className: "flex justify-end gap-2", children: [
165
+ /* @__PURE__ */ s(C, { variant: "outline", onClick: e, children: d("Cancel") }),
166
+ /* @__PURE__ */ s(
167
+ C,
168
+ {
169
+ onClick: () => t({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
170
+ disabled: !P || h,
171
+ children: d("Insert")
172
+ }
173
+ )
174
+ ] })
175
+ ] })
176
+ ] });
177
+ }, M = {
178
+ component: Y
179
+ }, Ae = (e) => {
180
+ M.component = e;
181
+ }, Te = () => i(() => M.component, []);
182
+ let k = async (e) => e;
183
+ const Fe = (e) => {
184
+ k = e;
185
+ }, Ee = async (e) => await k(e);
186
+ let T = null;
187
+ const Ne = (e) => {
188
+ T = e;
189
+ }, Re = () => i(() => T, []), Se = () => {
190
+ T = null;
191
+ }, m = {}, _e = (e, t) => {
192
+ E(m, e) && console.warn(`Panel ${e} already registered. Overriding...`), N(m, e, { id: e, ...t });
193
+ }, Be = (e) => i(
194
+ () => V(w(m), (t) => t.position === e),
195
+ [e, m]
196
+ ), Q = () => /* @__PURE__ */ s("div", {}), O = {
197
+ component: Q
198
+ }, Le = (e) => {
199
+ O.component = e;
200
+ }, Ie = () => i(() => O.component, []);
201
+ export {
202
+ y as A,
203
+ C as B,
204
+ m as C,
205
+ B as D,
206
+ l as E,
207
+ L as F,
208
+ X as G,
209
+ xe as I,
210
+ p as R,
211
+ ue as a,
212
+ ge as b,
213
+ me as c,
214
+ pe as d,
215
+ W as e,
216
+ he as f,
217
+ ve as g,
218
+ q as h,
219
+ be as i,
220
+ ye as j,
221
+ Ce as k,
222
+ we as l,
223
+ Ae as m,
224
+ Te as n,
225
+ Ee as o,
226
+ Fe as p,
227
+ Ne as q,
228
+ de as r,
229
+ Re as s,
230
+ Se as t,
231
+ fe as u,
232
+ _e as v,
233
+ Be as w,
234
+ Le as x,
235
+ Ie as y,
236
+ I as z
237
+ };
package/dist/render.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./plugin-C6rgJDNQ.cjs"),d=require("./apply-binding-KKp5PnpZ.cjs"),m=require("react/jsx-runtime"),t=require("lodash-es"),g=require("react"),b=require("./core-BoRDjj4h.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),j=require("@tailwindcss/aspect-ratio"),q=require("@tailwindcss/container-queries"),K=require("@tailwindcss/forms"),M=require("@tailwindcss/typography"),L=require("./get-chai-builder-theme-Dl72X7cz.cjs");async function O(e){const a={pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1},n=await e.dataProvider(a);return t.has(n,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,n.$metadata),e.children({...t.omit(n,"$metadata")})}const N=()=>m.jsx("div",{}),H=e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:o,blocks:l,draft:r,pageProps:c,dataProviderMetadataCallback:k}=e,u=b.getRegisteredChaiBlock(a._type),p=t.get(u,"component",null),_=t.get(e.repeaterData,"index",-1),f=t.get(e.repeaterData,"dataKey",""),w=n===s?"":n,y=d.applyBindingToBlockProps(d.applyLanguage(a,w,u),o,{index:_,key:f}),h=d.getBlockTagAttributes(a,!1),I=D(l,a._id,d.getBlockRuntimeProps(a._type)),T=t.has(u,"dataProvider")&&t.isFunction(u.dataProvider),B={...y,...h,...I},P={blockProps:{},inBuilder:!1,lang:n||s,pageData:o,...B},v=t.get(B,"_show",!0);if(t.isNull(p)||!v)return null;if(T){const S=t.get(u,"suspenseFallback",N);return m.jsx(g.Suspense,{fallback:g.createElement(S),children:m.jsx(O,{lang:n,pageProps:c,block:B,dataProvider:u.dataProvider,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:$=>g.createElement(p,{...P,...$,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})})}return m.jsx(g.Suspense,{children:g.createElement(p,{...P,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})},x=e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let o=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const l=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link"||i==="Span")&&(o=d.adjustSpacingInContentBlocks(o)),t.map(o,r=>r?g.createElement(H,{...e,key:r._id,block:r},({_id:c,_type:k,repeaterItems:u,$repeaterItemsKey:p})=>k==="Repeater"?t.isArray(u)&&u.map((_,f)=>g.createElement(x,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${f}`,repeaterData:{index:f,dataKey:p}})):l(c)?g.createElement(x,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)},D=(e,a,n)=>t.isEmpty(n)?{}:Object.entries(n).reduce((s,[i,o])=>{const l=[];let r=t.find(e,{_id:a});for(;r;)l.push(r),r=t.find(e,{_id:r._parent});const c=t.find(l,{_type:o.block});return c&&(s[i]=t.get(c,t.get(o,"prop"),null)),s},{});function J(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;return m.jsx(x,{...e,lang:a,fallbackLang:n})}async function V(e){const a=await e.dataProvider;return t.has(a,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,a.$metadata),e.children({...t.omit(a,"$metadata")})}const W=()=>m.jsx("div",{}),U=async e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:o,blocks:l,draft:r,pageProps:c,dataProviderMetadataCallback:k,dataProviders:u}=e,p=b.getRegisteredChaiBlock(a._type),_=t.get(p,"component",null),f=t.get(e.repeaterData,"index",-1),w=t.get(e.repeaterData,"dataKey",""),y=n===s?"":n,h=d.applyBindingToBlockProps(d.applyLanguage(a,y,p),o,{index:f,key:w}),I=d.getBlockTagAttributes(a,!1),T=D(l,a._id,d.getBlockRuntimeProps(a._type)),B=t.has(p,"dataProvider")&&t.isFunction(p.dataProvider),P={...h,...I,...T},v={blockProps:{},inBuilder:!1,lang:n||s,pageData:o,...P},S=t.get(P,"_show",!0);if(t.isNull(_)||!S)return null;if(B){const $=t.get(u,a._id,Promise.resolve({})),R=t.get(p,"suspenseFallback",W);return m.jsx(g.Suspense,{fallback:g.createElement(R),children:m.jsx(V,{lang:n,pageProps:c,block:P,dataProvider:$,...k?{dataProviderMetadataCallback:k}:{},draft:r,children:A=>g.createElement(_,{...v,draft:r,...A,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})})})}return g.createElement(_,{...v,draft:r,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})},C=async e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let o=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const l=r=>t.filter(a,c=>c._parent===r).length>0;return l&&(i==="Heading"||i==="Paragraph"||i==="Link")&&(o=d.adjustSpacingInContentBlocks(o)),t.map(o,r=>r?g.createElement(U,{dataProviders:e.dataProviders,...e,key:r._id,block:r},({_id:c,_type:k,repeaterItems:u,$repeaterItemsKey:p})=>k==="Repeater"?t.isArray(u)&&u.map((_,f)=>g.createElement(C,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${f}`,repeaterData:{index:f,dataKey:p}})):l(c)?g.createElement(C,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)};async function G(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;if(e.dataProviders)return m.jsx(C,{...e,lang:a,fallbackLang:n,dataProviders:e.dataProviders});const i=e.blocks.filter(o=>{const l=b.getRegisteredChaiBlock(o._type);return!!(t.has(l,"dataProvider")&&t.isFunction(l.dataProvider))}).reduce((o,l)=>{const r=b.getRegisteredChaiBlock(l._type),c={pageProps:e.pageProps,block:l,lang:e.lang,draft:e.draft,inBuilder:!1};return o[l._id]=r.dataProvider(c),o},{});return m.jsx(C,{...e,lang:a,fallbackLang:n,dataProviders:i})}function z(e,a){const n=e.filter(s=>s._type==="GlobalBlock"||s._type==="PartialBlock");for(let s=0;s<n.length;s++){const i=n[s],o=t.get(i,"partialBlockId",t.get(i,"globalBlock",""));if(o==="")continue;let l=t.cloneDeep(t.get(a,o,[]));i._parent&&(l==null?void 0:l.length)>0&&(l=l.map(c=>(t.isEmpty(c._parent)&&(c._parent=i._parent),c)));const r=e.indexOf(i);e.splice(r,1,...l)}return e}const Q=e=>{if(!e)return[];try{return JSON.parse(X(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function X(e){const a=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(a,n=>{const s=decodeURIComponent(n),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}async function Y(e,a=[],n=!1){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:a,theme:{extend:{...L.getChaiBuilderTheme(),keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}},plugins:[K,M,j,q,L.chaiBuilderPlugin],corePlugins:{preflight:n}}}).generateStylesFromContent(` ${n?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./plugin-BGlQf0iy.cjs"),d=require("./apply-binding-IsUf6UWJ.cjs"),m=require("react/jsx-runtime"),t=require("lodash-es"),g=require("react"),b=require("./core-Y0lXLwkq.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),j=require("@tailwindcss/aspect-ratio"),q=require("@tailwindcss/container-queries"),K=require("@tailwindcss/forms"),M=require("@tailwindcss/typography"),L=require("./get-chai-builder-theme-BApShjRz.cjs");async function O(e){const a={pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1},n=await e.dataProvider(a);return t.has(n,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,n.$metadata),e.children({...t.omit(n,"$metadata")})}const N=()=>m.jsx("div",{}),H=e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:l,blocks:o,draft:r,pageProps:c,dataProviderMetadataCallback:f}=e,u=b.getRegisteredChaiBlock(a._type),p=t.get(u,"component",null),_=t.get(e.repeaterData,"index",-1),k=t.get(e.repeaterData,"dataKey",""),w=n===s?"":n??"",y=d.applyBindingToBlockProps(d.applyLanguage(a,w,u),l??{},{index:_,key:k}),h=d.getBlockTagAttributes(a,!1),I=D(o,a._id,d.getBlockRuntimeProps(a._type)),T=t.has(u,"dataProvider")&&t.isFunction(u.dataProvider),B={...y,...h,...I},P={blockProps:{},inBuilder:!1,lang:n||s||"en",draft:r??!1,pageData:l??{},...B},v=t.get(B,"_show",!0);if(t.isNull(p)||!v)return null;if(T){const S=t.get(u,"suspenseFallback",N);return m.jsx(g.Suspense,{fallback:g.createElement(S),children:m.jsx(O,{lang:n??"",pageProps:c,block:B,dataProvider:u.dataProvider,...f?{dataProviderMetadataCallback:f}:{},draft:r??!1,children:$=>g.createElement(p,{...P,...$,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})})}return m.jsx(g.Suspense,{children:g.createElement(p,{...P,children:i({_id:a._id,_type:a._type,...t.isArray(y.repeaterItems)?{repeaterItems:d.applyLimit(y.repeaterItems,a),$repeaterItemsKey:y.$repeaterItemsKey,repeaterTotalItems:y.repeaterTotalItems??-1}:{}})})})},x=e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let l=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const o=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link"||i==="Span")&&(l=d.adjustSpacingInContentBlocks(l)),t.map(l,r=>r?g.createElement(H,{...e,key:r._id,block:r},({_id:c,_type:f,repeaterItems:u,$repeaterItemsKey:p})=>f==="Repeater"?t.isArray(u)&&u.map((_,k)=>g.createElement(x,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${k}`,repeaterData:{index:k,dataKey:p}})):o(c)?g.createElement(x,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)},D=(e,a,n)=>t.isEmpty(n)?{}:Object.entries(n).reduce((s,[i,l])=>{const o=[];let r=t.find(e,{_id:a});for(;r;)o.push(r),r=t.find(e,{_id:r._parent});const c=t.find(o,{_type:l.block});return c&&(s[i]=t.get(c,t.get(l,"prop"),null)),s},{});function J(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;return m.jsx(x,{...e,lang:a,fallbackLang:n})}async function V(e){const a=await e.dataProvider;return t.has(a,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,a.$metadata),e.children({...t.omit(a,"$metadata")})}const W=()=>m.jsx("div",{}),U=async e=>{const{block:a,lang:n,fallbackLang:s,children:i,externalData:l,blocks:o,draft:r,pageProps:c,dataProviderMetadataCallback:f,dataProviders:u}=e,p=b.getRegisteredChaiBlock(a._type),_=t.get(p,"component",null),k=t.get(e.repeaterData,"index",-1),w=t.get(e.repeaterData,"dataKey",""),y=n===s?"":n??"en",h=d.applyBindingToBlockProps(d.applyLanguage(a,y,p),l??{},{index:k,key:w}),I=d.getBlockTagAttributes(a,!1),T=D(o,a._id,d.getBlockRuntimeProps(a._type)),B=t.has(p,"dataProvider")&&t.isFunction(p.dataProvider),P={...h,...I,...T},v={blockProps:{},inBuilder:!1,lang:n||s||"en",draft:r??!1,pageData:l??{},...P},S=t.get(P,"_show",!0);if(t.isNull(_)||!S)return null;if(B){const $=t.get(u,a._id,Promise.resolve({})),R=t.get(p,"suspenseFallback",W);return m.jsx(g.Suspense,{fallback:g.createElement(R),children:m.jsx(V,{lang:n??"",pageProps:c,block:P,dataProvider:$,...f?{dataProviderMetadataCallback:f}:{},draft:r??!1,children:A=>g.createElement(_,{...v,...A,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})})})}return g.createElement(_,{...v,children:i({_id:a._id,_type:a._type,...t.isArray(h.repeaterItems)?{repeaterItems:d.applyLimit(h.repeaterItems,a),$repeaterItemsKey:h.$repeaterItemsKey,repeaterTotalItems:h.repeaterTotalItems??-1}:{}})})},C=async e=>{const{blocks:a,parent:n,repeaterData:s,type:i}=e;let l=t.uniqBy(t.filter(a,r=>t.has(r,"_id")&&(t.isEmpty(n)?!r._parent:r._parent===n)),"_id");const o=r=>t.filter(a,c=>c._parent===r).length>0;return(i==="Heading"||i==="Paragraph"||i==="Link")&&(l=d.adjustSpacingInContentBlocks(l)),t.map(l,r=>r?g.createElement(U,{...e,dataProviders:e.dataProviders,key:r._id,block:r},({_id:c,_type:f,repeaterItems:u,$repeaterItemsKey:p})=>f==="Repeater"?t.isArray(u)&&u.map((_,k)=>g.createElement(C,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}-${k}`,repeaterData:{index:k,dataKey:p}})):o(c)?g.createElement(C,{...e,parent:r._id,key:`${t.get(r,"_parent","root")}-${r._id}`,repeaterData:s,type:r._type}):null):null)};async function G(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",n=e.fallbackLang??a;if(e.dataProviders)return m.jsx(C,{...e,lang:a,fallbackLang:n,dataProviders:e.dataProviders});const i=e.blocks.filter(l=>{const o=b.getRegisteredChaiBlock(l._type);return!!(t.has(o,"dataProvider")&&t.isFunction(o.dataProvider))}).reduce((l,o)=>{const r=b.getRegisteredChaiBlock(o._type);if(!r||!r.dataProvider)return l;const c={pageProps:e.pageProps,block:o,lang:e.lang,draft:e.draft,inBuilder:!1};return l[o._id]=r.dataProvider(c),l},{});return m.jsx(C,{...e,lang:a,fallbackLang:n,dataProviders:i})}function Q(e,a){const n=e.filter(s=>s._type==="GlobalBlock"||s._type==="PartialBlock");for(let s=0;s<n.length;s++){const i=n[s],l=t.get(i,"partialBlockId",t.get(i,"globalBlock",""));if(l==="")continue;let o=t.cloneDeep(t.get(a,l,[]));i._parent&&(o==null?void 0:o.length)>0&&(o=o.map(c=>(t.isEmpty(c._parent)&&(c._parent=i._parent),c)));const r=e.indexOf(i);e.splice(r,1,...o)}return e}const z=e=>{if(!e)return[];try{return JSON.parse(X(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function X(e){const a=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(a,n=>{const s=decodeURIComponent(n),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}async function Y(e,a=[],n=!1){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:a,theme:{extend:{...L.getChaiBuilderTheme(),keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}},plugins:[K,M,j,q,L.chaiBuilderPlugin],corePlugins:{preflight:n}}}).generateStylesFromContent(` ${n?"@tailwind base;":""}
2
2
  @tailwind components;
3
- @tailwind utilities;`,e)}const Z=(e,a)=>{const n=JSON.stringify(e).replace(/#styles:([^"]*)/g,(s,i)=>`#styles:${i.replace(/,/g," ")}`.replace(/#styles:/g,""));return Y([n],[],a)},ee=async(e,a=!1)=>await Z(e,a);exports.getChaiThemeCssVariables=E.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=E.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=E.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=d.applyChaiDataBinding;exports.applyDesignTokens=d.applyDesignTokens;exports.convertHTMLToChaiBlocks=d.getBlocksFromHTML;exports.AsyncRenderChaiBlocks=G;exports.RenderChaiBlocks=J;exports.convertToBlocks=Q;exports.getMergedPartialBlocks=z;exports.getStylesForBlocks=ee;
3
+ @tailwind utilities;`,e)}const Z=(e,a)=>{const n=JSON.stringify(e).replace(/#styles:([^"]*)/g,(s,i)=>`#styles:${i.replace(/,/g," ")}`.replace(/#styles:/g,""));return Y([n],[],a)},ee=async(e,a=!1)=>await Z(e,a);exports.getChaiThemeCssVariables=E.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=E.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=E.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=d.applyChaiDataBinding;exports.applyDesignTokens=d.applyDesignTokens;exports.convertHTMLToChaiBlocks=d.getBlocksFromHTML;exports.AsyncRenderChaiBlocks=G;exports.RenderChaiBlocks=J;exports.convertToBlocks=z;exports.getMergedPartialBlocks=Q;exports.getStylesForBlocks=ee;
package/dist/render.d.ts CHANGED
@@ -4,7 +4,7 @@ export declare const applyChaiDataBinding: (block: Record<string, string>, pageE
4
4
 
5
5
  export declare const applyDesignTokens: (blocks: ChaiBlock[], designTokens: DesignTokens) => ChaiBlock[];
6
6
 
7
- export declare function AsyncRenderChaiBlocks(props: RenderChaiBlocksProps): Promise<JSX.Element>;
7
+ export declare function AsyncRenderChaiBlocks(props: RenderChaiBlocksProps): Promise<JSX.Element | null>;
8
8
 
9
9
  declare type ChaiBlock<T = Record<string, any>> = {
10
10
  _id: string;
@@ -96,7 +96,7 @@ declare type HexColor = string;
96
96
 
97
97
  declare type HSLColor = string;
98
98
 
99
- export declare function RenderChaiBlocks(props: RenderChaiBlocksProps_2): JSX.Element;
99
+ export declare function RenderChaiBlocks(props: RenderChaiBlocksProps_2): JSX.Element | null;
100
100
 
101
101
  declare type RenderChaiBlocksProps = {
102
102
  blocks: ChaiBlock[];
package/dist/render.js CHANGED
@@ -1,16 +1,16 @@
1
- import { a as Le, b as De, c as Ke } from "./plugin-3ZKK6RXm.js";
2
- import { a as O, b as N, c as E, d as J, e as C, f as j } from "./apply-binding-6iwlED02.js";
3
- import { h as Ae, i as Fe, g as Me } from "./apply-binding-6iwlED02.js";
1
+ import { a as Le, b as De, c as Ke } from "./plugin-C-ht41UZ.js";
2
+ import { a as O, b as N, c as E, d as J, e as C, f as j } from "./apply-binding-BvWfJCSZ.js";
3
+ import { h as Ae, i as Fe, g as Me } from "./apply-binding-BvWfJCSZ.js";
4
4
  import { jsx as m } from "react/jsx-runtime";
5
- import { has as P, isFunction as w, omit as q, get as d, isNull as H, isArray as B, uniqBy as W, filter as $, isEmpty as h, map as U, find as R, cloneDeep as Q } from "lodash-es";
6
- import { Suspense as A, createElement as u } from "react";
7
- import { e as S } from "./core-yvI6kCyw.js";
5
+ import { has as P, isFunction as w, omit as q, get as d, isNull as H, isArray as B, uniqBy as W, filter as $, isEmpty as h, map as U, find as R, cloneDeep as z } from "lodash-es";
6
+ import { Suspense as A, createElement as g } from "react";
7
+ import { e as S } from "./core-Dr7QYemB.js";
8
8
  import { createTailwindcss as X } from "@mhsdesign/jit-browser-tailwindcss";
9
9
  import Y from "@tailwindcss/aspect-ratio";
10
10
  import Z from "@tailwindcss/container-queries";
11
11
  import ee from "@tailwindcss/forms";
12
12
  import te from "@tailwindcss/typography";
13
- import { c as ae, g as re } from "./get-chai-builder-theme-BYtp20KD.js";
13
+ import { c as ae, g as re } from "./get-chai-builder-theme-DDVRJQ6Z.js";
14
14
  async function ne(e) {
15
15
  const t = {
16
16
  pageProps: e.pageProps,
@@ -24,34 +24,35 @@ async function ne(e) {
24
24
  });
25
25
  }
26
26
  const ie = () => /* @__PURE__ */ m("div", {}), oe = (e) => {
27
- const { block: t, lang: r, fallbackLang: i, children: n, externalData: s, blocks: o, draft: a, pageProps: l, dataProviderMetadataCallback: y } = e, c = S(t._type), p = d(c, "component", null), _ = d(e.repeaterData, "index", -1), k = d(e.repeaterData, "dataKey", ""), f = O(
28
- N(t, r === i ? "" : r, c),
29
- s,
27
+ const { block: t, lang: r, fallbackLang: i, children: n, externalData: o, blocks: s, draft: a, pageProps: l, dataProviderMetadataCallback: y } = e, c = S(t._type), u = d(c, "component", null), _ = d(e.repeaterData, "index", -1), k = d(e.repeaterData, "dataKey", ""), f = O(
28
+ N(t, r === i ? "" : r ?? "", c),
29
+ o ?? {},
30
30
  { index: _, key: k }
31
- ), g = E(t, !1), x = V(o, t._id, J(t._type)), L = P(c, "dataProvider") && w(c.dataProvider), b = {
31
+ ), p = E(t, !1), x = V(s, t._id, J(t._type)), L = P(c, "dataProvider") && w(c.dataProvider), b = {
32
32
  ...f,
33
- ...g,
33
+ ...p,
34
34
  ...x
35
35
  }, v = {
36
36
  blockProps: {},
37
37
  inBuilder: !1,
38
- lang: r || i,
39
- pageData: s,
38
+ lang: r || i || "en",
39
+ draft: a ?? !1,
40
+ pageData: o ?? {},
40
41
  ...b
41
42
  }, I = d(b, "_show", !0);
42
- if (H(p) || !I) return null;
43
+ if (H(u) || !I) return null;
43
44
  if (L) {
44
45
  const D = d(c, "suspenseFallback", ie);
45
- return /* @__PURE__ */ m(A, { fallback: u(D), children: /* @__PURE__ */ m(
46
+ return /* @__PURE__ */ m(A, { fallback: g(D), children: /* @__PURE__ */ m(
46
47
  ne,
47
48
  {
48
- lang: r,
49
+ lang: r ?? "",
49
50
  pageProps: l,
50
51
  block: b,
51
52
  dataProvider: c.dataProvider,
52
53
  ...y ? { dataProviderMetadataCallback: y } : {},
53
- draft: a,
54
- children: (K) => u(p, {
54
+ draft: a ?? !1,
55
+ children: (K) => g(u, {
55
56
  ...v,
56
57
  ...K,
57
58
  children: n({
@@ -67,7 +68,7 @@ const ie = () => /* @__PURE__ */ m("div", {}), oe = (e) => {
67
68
  }
68
69
  ) });
69
70
  }
70
- return /* @__PURE__ */ m(A, { children: u(p, {
71
+ return /* @__PURE__ */ m(A, { children: g(u, {
71
72
  ...v,
72
73
  children: n({
73
74
  _id: t._id,
@@ -81,20 +82,20 @@ const ie = () => /* @__PURE__ */ m("div", {}), oe = (e) => {
81
82
  }) });
82
83
  }, F = (e) => {
83
84
  const { blocks: t, parent: r, repeaterData: i, type: n } = e;
84
- let s = W(
85
+ let o = W(
85
86
  $(t, (a) => P(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
86
87
  "_id"
87
88
  );
88
- const o = (a) => $(t, (l) => l._parent === a).length > 0;
89
- return (n === "Heading" || n === "Paragraph" || n === "Link" || n === "Span") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */ u(oe, { ...e, key: a._id, block: a }, ({ _id: l, _type: y, repeaterItems: c, $repeaterItemsKey: p }) => y === "Repeater" ? B(c) && c.map((_, k) => /* @__PURE__ */ u(
89
+ const s = (a) => $(t, (l) => l._parent === a).length > 0;
90
+ return (n === "Heading" || n === "Paragraph" || n === "Link" || n === "Span") && (o = j(o)), U(o, (a) => a ? /* @__PURE__ */ g(oe, { ...e, key: a._id, block: a }, ({ _id: l, _type: y, repeaterItems: c, $repeaterItemsKey: u }) => y === "Repeater" ? B(c) && c.map((_, k) => /* @__PURE__ */ g(
90
91
  F,
91
92
  {
92
93
  ...e,
93
94
  parent: a._id,
94
95
  key: `${d(a, "_parent", "root")}-${a._id}-${k}`,
95
- repeaterData: { index: k, dataKey: p }
96
+ repeaterData: { index: k, dataKey: u }
96
97
  }
97
- )) : o(l) ? /* @__PURE__ */ u(
98
+ )) : s(l) ? /* @__PURE__ */ g(
98
99
  F,
99
100
  {
100
101
  ...e,
@@ -104,14 +105,17 @@ const ie = () => /* @__PURE__ */ m("div", {}), oe = (e) => {
104
105
  type: a._type
105
106
  }
106
107
  ) : null) : null);
107
- }, V = (e, t, r) => h(r) ? {} : Object.entries(r).reduce((i, [n, s]) => {
108
- const o = [];
109
- let a = R(e, { _id: t });
110
- for (; a; )
111
- o.push(a), a = R(e, { _id: a._parent });
112
- const l = R(o, { _type: s.block });
113
- return l && (i[n] = d(l, d(s, "prop"), null)), i;
114
- }, {});
108
+ }, V = (e, t, r) => h(r) ? {} : Object.entries(r).reduce(
109
+ (i, [n, o]) => {
110
+ const s = [];
111
+ let a = R(e, { _id: t });
112
+ for (; a; )
113
+ s.push(a), a = R(e, { _id: a._parent });
114
+ const l = R(s, { _type: o.block });
115
+ return l && (i[n] = d(l, d(o, "prop"), null)), i;
116
+ },
117
+ {}
118
+ );
115
119
  function we(e) {
116
120
  if (h(e.lang) && !h(e.fallbackLang))
117
121
  throw new Error("lang prop is required when fallbackLang is provided");
@@ -132,85 +136,84 @@ const le = () => /* @__PURE__ */ m("div", {}), de = async (e) => {
132
136
  lang: r,
133
137
  fallbackLang: i,
134
138
  children: n,
135
- externalData: s,
136
- blocks: o,
139
+ externalData: o,
140
+ blocks: s,
137
141
  draft: a,
138
142
  pageProps: l,
139
143
  dataProviderMetadataCallback: y,
140
144
  dataProviders: c
141
- } = e, p = S(t._type), _ = d(p, "component", null), k = d(e.repeaterData, "index", -1), M = d(e.repeaterData, "dataKey", ""), g = O(
142
- N(t, r === i ? "" : r, p),
143
- s,
145
+ } = e, u = S(t._type), _ = d(u, "component", null), k = d(e.repeaterData, "index", -1), M = d(e.repeaterData, "dataKey", ""), p = O(
146
+ N(t, r === i ? "" : r ?? "en", u),
147
+ o ?? {},
144
148
  { index: k, key: M }
145
- ), x = E(t, !1), L = V(o, t._id, J(t._type)), b = P(p, "dataProvider") && w(p.dataProvider), v = {
146
- ...g,
149
+ ), x = E(t, !1), L = V(s, t._id, J(t._type)), b = P(u, "dataProvider") && w(u.dataProvider), v = {
150
+ ...p,
147
151
  ...x,
148
152
  ...L
149
153
  }, I = {
150
154
  blockProps: {},
151
155
  inBuilder: !1,
152
- lang: r || i,
153
- pageData: s,
156
+ lang: r || i || "en",
157
+ draft: a ?? !1,
158
+ pageData: o ?? {},
154
159
  ...v
155
160
  }, D = d(v, "_show", !0);
156
161
  if (H(_) || !D) return null;
157
162
  if (b) {
158
- const K = d(c, t._id, Promise.resolve({})), G = d(p, "suspenseFallback", le);
159
- return /* @__PURE__ */ m(A, { fallback: u(G), children: /* @__PURE__ */ m(
163
+ const K = d(c, t._id, Promise.resolve({})), G = d(u, "suspenseFallback", le);
164
+ return /* @__PURE__ */ m(A, { fallback: g(G), children: /* @__PURE__ */ m(
160
165
  se,
161
166
  {
162
- lang: r,
167
+ lang: r ?? "",
163
168
  pageProps: l,
164
169
  block: v,
165
170
  dataProvider: K,
166
171
  ...y ? { dataProviderMetadataCallback: y } : {},
167
- draft: a,
168
- children: (z) => u(_, {
172
+ draft: a ?? !1,
173
+ children: (Q) => g(_, {
169
174
  ...I,
170
- draft: a,
171
- ...z,
175
+ ...Q,
172
176
  children: n({
173
177
  _id: t._id,
174
178
  _type: t._type,
175
- ...B(g.repeaterItems) ? {
176
- repeaterItems: C(g.repeaterItems, t),
177
- $repeaterItemsKey: g.$repeaterItemsKey,
178
- repeaterTotalItems: g.repeaterTotalItems ?? -1
179
+ ...B(p.repeaterItems) ? {
180
+ repeaterItems: C(p.repeaterItems, t),
181
+ $repeaterItemsKey: p.$repeaterItemsKey,
182
+ repeaterTotalItems: p.repeaterTotalItems ?? -1
179
183
  } : {}
180
184
  })
181
185
  })
182
186
  }
183
187
  ) });
184
188
  }
185
- return u(_, {
189
+ return g(_, {
186
190
  ...I,
187
- draft: a,
188
191
  children: n({
189
192
  _id: t._id,
190
193
  _type: t._type,
191
- ...B(g.repeaterItems) ? {
192
- repeaterItems: C(g.repeaterItems, t),
193
- $repeaterItemsKey: g.$repeaterItemsKey,
194
- repeaterTotalItems: g.repeaterTotalItems ?? -1
194
+ ...B(p.repeaterItems) ? {
195
+ repeaterItems: C(p.repeaterItems, t),
196
+ $repeaterItemsKey: p.$repeaterItemsKey,
197
+ repeaterTotalItems: p.repeaterTotalItems ?? -1
195
198
  } : {}
196
199
  })
197
200
  });
198
201
  }, T = async (e) => {
199
202
  const { blocks: t, parent: r, repeaterData: i, type: n } = e;
200
- let s = W(
203
+ let o = W(
201
204
  $(t, (a) => P(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
202
205
  "_id"
203
206
  );
204
- const o = (a) => $(t, (l) => l._parent === a).length > 0;
205
- return o && (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */ u(de, { dataProviders: e.dataProviders, ...e, key: a._id, block: a }, ({ _id: l, _type: y, repeaterItems: c, $repeaterItemsKey: p }) => y === "Repeater" ? B(c) && c.map((_, k) => /* @__PURE__ */ u(
207
+ const s = (a) => $(t, (l) => l._parent === a).length > 0;
208
+ return (n === "Heading" || n === "Paragraph" || n === "Link") && (o = j(o)), U(o, (a) => a ? /* @__PURE__ */ g(de, { ...e, dataProviders: e.dataProviders, key: a._id, block: a }, ({ _id: l, _type: y, repeaterItems: c, $repeaterItemsKey: u }) => y === "Repeater" ? B(c) && c.map((_, k) => /* @__PURE__ */ g(
206
209
  T,
207
210
  {
208
211
  ...e,
209
212
  parent: a._id,
210
213
  key: `${d(a, "_parent", "root")}-${a._id}-${k}`,
211
- repeaterData: { index: k, dataKey: p }
214
+ repeaterData: { index: k, dataKey: u }
212
215
  }
213
- )) : o(l) ? /* @__PURE__ */ u(
216
+ )) : s(l) ? /* @__PURE__ */ g(
214
217
  T,
215
218
  {
216
219
  ...e,
@@ -229,19 +232,22 @@ async function Ie(e) {
229
232
  const t = e.lang ?? "en", r = e.fallbackLang ?? t;
230
233
  if (e.dataProviders)
231
234
  return /* @__PURE__ */ m(T, { ...e, lang: t, fallbackLang: r, dataProviders: e.dataProviders });
232
- const n = e.blocks.filter((s) => {
233
- const o = S(s._type);
234
- return !!(P(o, "dataProvider") && w(o.dataProvider));
235
+ const n = e.blocks.filter((o) => {
236
+ const s = S(o._type);
237
+ return !!(P(s, "dataProvider") && w(s.dataProvider));
235
238
  }).reduce(
236
- (s, o) => {
237
- const a = S(o._type), l = {
239
+ (o, s) => {
240
+ const a = S(s._type);
241
+ if (!a || !a.dataProvider)
242
+ return o;
243
+ const l = {
238
244
  pageProps: e.pageProps,
239
- block: o,
245
+ block: s,
240
246
  lang: e.lang,
241
247
  draft: e.draft,
242
248
  inBuilder: !1
243
249
  };
244
- return s[o._id] = a.dataProvider(l), s;
250
+ return o[s._id] = a.dataProvider(l), o;
245
251
  },
246
252
  {}
247
253
  );
@@ -250,12 +256,12 @@ async function Ie(e) {
250
256
  function Ce(e, t) {
251
257
  const r = e.filter((i) => i._type === "GlobalBlock" || i._type === "PartialBlock");
252
258
  for (let i = 0; i < r.length; i++) {
253
- const n = r[i], s = d(n, "partialBlockId", d(n, "globalBlock", ""));
254
- if (s === "") continue;
255
- let o = Q(d(t, s, []));
256
- n._parent && (o == null ? void 0 : o.length) > 0 && (o = o.map((l) => (h(l._parent) && (l._parent = n._parent), l)));
259
+ const n = r[i], o = d(n, "partialBlockId", d(n, "globalBlock", ""));
260
+ if (o === "") continue;
261
+ let s = z(d(t, o, []));
262
+ n._parent && (s == null ? void 0 : s.length) > 0 && (s = s.map((l) => (h(l._parent) && (l._parent = n._parent), l)));
257
263
  const a = e.indexOf(n);
258
- e.splice(a, 1, ...o);
264
+ e.splice(a, 1, ...s);
259
265
  }
260
266
  return e;
261
267
  }
@@ -274,12 +280,13 @@ function ce(e) {
274
280
  return n !== -1 ? i.substring(n + 6) : i;
275
281
  });
276
282
  }
277
- async function pe(e, t = [], r = !1) {
283
+ async function ue(e, t = [], r = !1) {
278
284
  return await X({
279
285
  tailwindConfig: {
280
286
  darkMode: "class",
281
287
  safelist: t,
282
288
  theme: {
289
+ // @ts-ignore
283
290
  extend: {
284
291
  ...re(),
285
292
  keyframes: {
@@ -316,10 +323,10 @@ async function pe(e, t = [], r = !1) {
316
323
  e
317
324
  );
318
325
  }
319
- const ue = (e, t) => {
326
+ const ge = (e, t) => {
320
327
  const r = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, n) => `#styles:${n.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
321
- return pe([r], [], t);
322
- }, Se = async (e, t = !1) => await ue(e, t);
328
+ return ue([r], [], t);
329
+ }, Se = async (e, t = !1) => await ge(e, t);
323
330
  export {
324
331
  Ie as AsyncRenderChaiBlocks,
325
332
  we as RenderChaiBlocks,
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("./register-chai-top-bar-BqwKw4uy.cjs"),s=require("./index-B0e71wJ1.cjs"),S=({isOpen:m,onClose:r,editor:t,rteElement:f})=>{const a=s.usePageExternalData(),u=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:j,to:g}=t.state.selection;if(j!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),l=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";l&&l!==" "&&!/[.,!?;:]/.test(l)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(s.Dialog,{open:m,onOpenChange:o=>!o&&r(),children:e.jsxs(s.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(s.DialogHeader,{children:e.jsxs(s.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),a&&Object.keys(a).length>0&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-sm text-muted-foreground",children:"Add field:"}),e.jsx("div",{className:"rte-path-selector",children:e.jsx(s.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(p.Button,{onClick:r,children:"Done"})})]})})};exports.default=S;