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

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 (184) hide show
  1. package/README.md +27 -20
  2. package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
  3. package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
  4. package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
  5. package/dist/AP7HFJJL-CymCmW14.js +9214 -0
  6. package/dist/IconPicker-B1rWC-Ex.js +59 -0
  7. package/dist/IconPicker-DREyo007.cjs +1 -0
  8. package/dist/WDYDFRGG-BUVnbAci.js +33 -0
  9. package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
  10. package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
  11. package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
  12. package/dist/actions-registery-CZ1w0NKa.js +15545 -0
  13. package/dist/actions-registery-YnFmU21O.cjs +418 -0
  14. package/dist/actions.cjs +1 -0
  15. package/dist/actions.d.ts +3202 -0
  16. package/dist/actions.js +216 -0
  17. package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
  18. package/dist/active-in-another-tab-CyjngVA6.js +34 -0
  19. package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
  20. package/dist/add-new-language-page-WmlCnytQ.js +401 -0
  21. package/dist/add-new-page-VW2wAYZp.js +31 -0
  22. package/dist/add-new-page-soZ8GAkN.cjs +1 -0
  23. package/dist/ai-panel-content-7zCil042.cjs +1 -0
  24. package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
  25. package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
  26. package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
  27. package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
  28. package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
  29. package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
  30. package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
  31. package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
  32. package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
  33. package/dist/apply-binding-6iwlED02.js +833 -0
  34. package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
  35. package/dist/code-display-BnqzqzoP.cjs +1 -0
  36. package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
  37. package/dist/code-editor-DRIAnNbb.js +50 -0
  38. package/dist/code-editor-o3___nu2.cjs +1 -0
  39. package/dist/common-functions-B3a4xKt_.cjs +1 -0
  40. package/dist/common-functions-D2lMFR6K.js +13 -0
  41. package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
  42. package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
  43. package/dist/core-BoRDjj4h.cjs +1 -0
  44. package/dist/core-yvI6kCyw.js +56 -0
  45. package/dist/core.cjs +1 -1
  46. package/dist/core.d.ts +51 -383
  47. package/dist/core.js +39 -106
  48. package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
  49. package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
  50. package/dist/delete-design-token-BRZZiWtQ.js +40 -0
  51. package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
  52. package/dist/delete-page-BzyX9TN-.js +70 -0
  53. package/dist/delete-page-DxX7PFIE.cjs +1 -0
  54. package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
  55. package/dist/design-token-usage-xQs6SlaJ.js +113 -0
  56. package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
  57. package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
  58. package/dist/duplicate-page-BR7Dlo9d.js +133 -0
  59. package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
  60. package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
  61. package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
  62. package/dist/fonts-B-Xt29pe.cjs +1 -0
  63. package/dist/fonts-DRly3Wzd.js +78 -0
  64. package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
  65. package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
  66. package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
  67. package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
  68. package/dist/get-seo-defaults-9zHebckY.js +65 -0
  69. package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
  70. package/dist/image-compression-DZ9WMmyn.cjs +1 -0
  71. package/dist/image-compression-DsZ1oqpb.js +37 -0
  72. package/dist/image-editor-DV8kUKhl.js +108 -0
  73. package/dist/image-editor-G-K28aTS.cjs +1 -0
  74. package/dist/index-B-rSiAp_.cjs +1 -0
  75. package/dist/index-Ct7ElCGK.js +19069 -0
  76. package/dist/index-DF5DEvqb.cjs +160 -0
  77. package/dist/index-Dxfyt4d4.js +39 -0
  78. package/dist/index-WQwzsC7A.cjs +5 -0
  79. package/dist/index-ZuacEL1j.js +4732 -0
  80. package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
  81. package/dist/json-diff-viewer-krslPepD.js +258 -0
  82. package/dist/lang-panel-BwIewMyw.js +215 -0
  83. package/dist/lang-panel-DT96k1xg.cjs +1 -0
  84. package/dist/manage-design-tokens-Caz_20VK.js +240 -0
  85. package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
  86. package/dist/mark-as-template-D295ZQtU.js +156 -0
  87. package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
  88. package/dist/models-5gOsRC56.cjs +1 -0
  89. package/dist/models-D95ZYr_x.js +70 -0
  90. package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
  91. package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
  92. package/dist/no-language-page-content-BvqRBP6y.js +42 -0
  93. package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
  94. package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
  95. package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
  96. package/dist/page-creator-C4gc5NSC.cjs +1 -0
  97. package/dist/page-creator-DiOITEMw.js +795 -0
  98. package/dist/page-lock-BdYmCks0.cjs +1 -0
  99. package/dist/page-lock-Bfbs6RgL.js +30 -0
  100. package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
  101. package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
  102. package/dist/page-manager-new-CHDueBDk.cjs +1 -0
  103. package/dist/page-manager-new-CzX22g2n.js +394 -0
  104. package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
  105. package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
  106. package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
  107. package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
  108. package/dist/pages.cjs +1 -0
  109. package/dist/pages.d.ts +491 -0
  110. package/dist/pages.js +27 -0
  111. package/dist/plugin-3ZKK6RXm.js +245 -0
  112. package/dist/plugin-C6rgJDNQ.cjs +22 -0
  113. package/dist/publish-pages-content-D9aixMN5.js +178 -0
  114. package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
  115. package/dist/register-partial-type-BjtdfKHE.js +36 -0
  116. package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
  117. package/dist/render.cjs +2 -2
  118. package/dist/render.d.ts +26 -13
  119. package/dist/render.js +130 -124
  120. package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
  121. package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
  122. package/dist/runtime.cjs +1 -1
  123. package/dist/runtime.d.ts +306 -7
  124. package/dist/runtime.js +44 -1
  125. package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
  126. package/dist/save-to-lib-eiOc_SSN.js +422 -0
  127. package/dist/sdk.css +1 -1
  128. package/dist/selected-block-display-BgRY82CT.cjs +16 -0
  129. package/dist/selected-block-display-CBFePS19.js +319 -0
  130. package/dist/seo-panel-C1-iMOR1.js +798 -0
  131. package/dist/seo-panel-DfAb8U7W.cjs +2 -0
  132. package/dist/shared-json-ld-B4PxAM_0.js +565 -0
  133. package/dist/shared-json-ld-DzG398hr.cjs +1 -0
  134. package/dist/slug-input-AwNJs9im.js +86 -0
  135. package/dist/slug-input-C_ijLQ_X.cjs +1 -0
  136. package/dist/supabase-actions.cjs +1 -0
  137. package/dist/supabase-actions.d.ts +284 -0
  138. package/dist/supabase-actions.js +524 -0
  139. package/dist/take-over-request-BNxcjY2j.cjs +1 -0
  140. package/dist/take-over-request-C4FeDtN_.js +63 -0
  141. package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
  142. package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
  143. package/dist/translation-warning-modal-B64YqlbI.js +26 -0
  144. package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
  145. package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
  146. package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
  147. package/dist/unpublish-page-D4VwOlxc.js +27 -0
  148. package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
  149. package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
  150. package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
  151. package/dist/{tailwind.cjs → utils.cjs} +1 -1
  152. package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
  153. package/dist/utils.js +7 -0
  154. package/dist/web-blocks.cjs +1 -1
  155. package/dist/web-blocks.d.ts +0 -6
  156. package/dist/web-blocks.js +248 -241
  157. package/dist/web-preview-Cio70gk5.cjs +1 -0
  158. package/dist/web-preview-Djy6WIyj.js +73 -0
  159. package/package.json +175 -105
  160. package/dist/IconPicker-CGWn9C4u.cjs +0 -1
  161. package/dist/IconPicker-QvxJ-4Ez.js +0 -64
  162. package/dist/apply-binding-DCno1xQL.js +0 -711
  163. package/dist/apply-binding-DvHNFLQD.cjs +0 -1
  164. package/dist/code-display-BZ1x7SqI.cjs +0 -1
  165. package/dist/code-editor-B28LoECM.cjs +0 -1
  166. package/dist/code-editor-CfG2FhJ-.js +0 -58
  167. package/dist/common-functions-BGzDsf1z.js +0 -14
  168. package/dist/common-functions-BZmyleS1.cjs +0 -1
  169. package/dist/css-import-modal-CENUYvcl.cjs +0 -13
  170. package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
  171. package/dist/index-CaGNHF7f.js +0 -12209
  172. package/dist/index-Gn6pJt2v.cjs +0 -166
  173. package/dist/mockServiceWorker.js +0 -307
  174. package/dist/plugin-B5627hMN.js +0 -195
  175. package/dist/plugin-UxTRfDum.cjs +0 -22
  176. package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
  177. package/dist/rte-widget-modal-Dte0od04.js +0 -41
  178. package/dist/tailwind.js +0 -7
  179. package/dist/tooltip-A4qGk781.cjs +0 -1
  180. package/dist/tooltip-tLiIOgjq.js +0 -1067
  181. package/dist/ui.cjs +0 -1
  182. package/dist/ui.d.ts +0 -415
  183. package/dist/ui.js +0 -129
  184. package/dist/vite.svg +0 -1
package/dist/render.js CHANGED
@@ -1,19 +1,17 @@
1
- import { a as Re, b as Ae, c as Me } from "./plugin-B5627hMN.js";
2
- import { a as O, b as N, g as E, c as J, d as I, e as j } from "./apply-binding-DCno1xQL.js";
3
- import { f as Ne, h as Ee } from "./apply-binding-DCno1xQL.js";
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";
4
4
  import { jsx as m } from "react/jsx-runtime";
5
- import { getRegisteredChaiBlock as C } from "@chaibuilder/runtime";
6
- import { has as Q, isFunction as X } from "lodash";
7
- import { has as B, isFunction as x, omit as q, get as c, isNull as H, isArray as b, uniqBy as W, filter as $, isEmpty as h, map as U, find as F, cloneDeep as Y } from "lodash-es";
8
- import { Suspense as S, createElement as p } from "react";
9
- import { g as Z, c as ee } from "./get-chai-builder-theme-D0IsUvK4.js";
10
- import te from "@tailwindcss/aspect-ratio";
11
- import ae from "@tailwindcss/forms";
12
- import re from "@tailwindcss/typography";
13
- import "tailwindcss-animate";
14
- import { createTailwindcss as ne } from "@mhsdesign/jit-browser-tailwindcss";
15
- import ie from "@tailwindcss/container-queries";
16
- async function oe(e) {
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";
8
+ import { createTailwindcss as X } from "@mhsdesign/jit-browser-tailwindcss";
9
+ import Y from "@tailwindcss/aspect-ratio";
10
+ import Z from "@tailwindcss/container-queries";
11
+ import ee from "@tailwindcss/forms";
12
+ import te from "@tailwindcss/typography";
13
+ import { c as ae, g as re } from "./get-chai-builder-theme-BYtp20KD.js";
14
+ async function ne(e) {
17
15
  const t = {
18
16
  pageProps: e.pageProps,
19
17
  block: e.block,
@@ -21,45 +19,46 @@ async function oe(e) {
21
19
  draft: e.draft,
22
20
  inBuilder: !1
23
21
  }, r = await e.dataProvider(t);
24
- return B(r, "$metadata") && x(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, r.$metadata), e.children({
22
+ return P(r, "$metadata") && w(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, r.$metadata), e.children({
25
23
  ...q(r, "$metadata")
26
24
  });
27
25
  }
28
- const se = () => /* @__PURE__ */ m("div", {}), le = (e) => {
29
- const { block: t, lang: r, fallbackLang: i, children: n, externalData: s, blocks: o, draft: a, pageProps: l, dataProviderMetadataCallback: k } = e, d = C(t._type), u = c(d, "component", null), _ = c(e.repeaterData, "index", -1), y = c(e.repeaterData, "dataKey", ""), f = O(
30
- N(t, r === i ? "" : r, d),
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),
31
29
  s,
32
- { index: _, key: y }
33
- ), g = E(t, !1), L = V(o, t._id, J(t._type)), T = B(d, "dataProvider") && x(d.dataProvider), v = {
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 = {
34
32
  ...f,
35
33
  ...g,
36
- ...L
37
- }, P = {
34
+ ...x
35
+ }, v = {
38
36
  blockProps: {},
39
37
  inBuilder: !1,
40
38
  lang: r || i,
41
- ...v
42
- }, w = c(v, "_show", !0);
43
- if (H(u) || !w) return null;
44
- if (T) {
45
- const D = c(d, "suspenseFallback", se);
46
- return /* @__PURE__ */ m(S, { fallback: p(D), children: /* @__PURE__ */ m(
47
- oe,
39
+ pageData: s,
40
+ ...b
41
+ }, I = d(b, "_show", !0);
42
+ if (H(p) || !I) return null;
43
+ if (L) {
44
+ const D = d(c, "suspenseFallback", ie);
45
+ return /* @__PURE__ */ m(A, { fallback: u(D), children: /* @__PURE__ */ m(
46
+ ne,
48
47
  {
49
48
  lang: r,
50
49
  pageProps: l,
51
- block: v,
52
- dataProvider: d.dataProvider,
53
- ...k ? { dataProviderMetadataCallback: k } : {},
50
+ block: b,
51
+ dataProvider: c.dataProvider,
52
+ ...y ? { dataProviderMetadataCallback: y } : {},
54
53
  draft: a,
55
- children: (K) => p(u, {
56
- ...P,
54
+ children: (K) => u(p, {
55
+ ...v,
57
56
  ...K,
58
57
  children: n({
59
58
  _id: t._id,
60
59
  _type: t._type,
61
- ...b(f.repeaterItems) ? {
62
- repeaterItems: I(f.repeaterItems, t),
60
+ ...B(f.repeaterItems) ? {
61
+ repeaterItems: C(f.repeaterItems, t),
63
62
  $repeaterItemsKey: f.$repeaterItemsKey,
64
63
  repeaterTotalItems: f.repeaterTotalItems ?? -1
65
64
  } : {}
@@ -68,66 +67,66 @@ const se = () => /* @__PURE__ */ m("div", {}), le = (e) => {
68
67
  }
69
68
  ) });
70
69
  }
71
- return /* @__PURE__ */ m(S, { children: p(u, {
72
- ...P,
70
+ return /* @__PURE__ */ m(A, { children: u(p, {
71
+ ...v,
73
72
  children: n({
74
73
  _id: t._id,
75
74
  _type: t._type,
76
- ...b(f.repeaterItems) ? {
77
- repeaterItems: I(f.repeaterItems, t),
75
+ ...B(f.repeaterItems) ? {
76
+ repeaterItems: C(f.repeaterItems, t),
78
77
  $repeaterItemsKey: f.$repeaterItemsKey,
79
78
  repeaterTotalItems: f.repeaterTotalItems ?? -1
80
79
  } : {}
81
80
  })
82
81
  }) });
83
- }, R = (e) => {
82
+ }, F = (e) => {
84
83
  const { blocks: t, parent: r, repeaterData: i, type: n } = e;
85
84
  let s = W(
86
- $(t, (a) => B(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
85
+ $(t, (a) => P(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
87
86
  "_id"
88
87
  );
89
88
  const o = (a) => $(t, (l) => l._parent === a).length > 0;
90
- return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */ p(le, { ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: d, $repeaterItemsKey: u }) => k === "Repeater" ? b(d) && d.map((_, y) => /* @__PURE__ */ p(
91
- R,
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(
90
+ F,
92
91
  {
93
92
  ...e,
94
93
  parent: a._id,
95
- key: `${c(a, "_parent", "root")}-${a._id}-${y}`,
96
- repeaterData: { index: y, dataKey: u }
94
+ key: `${d(a, "_parent", "root")}-${a._id}-${k}`,
95
+ repeaterData: { index: k, dataKey: p }
97
96
  }
98
- )) : o(l) ? /* @__PURE__ */ p(
99
- R,
97
+ )) : o(l) ? /* @__PURE__ */ u(
98
+ F,
100
99
  {
101
100
  ...e,
102
101
  parent: a._id,
103
- key: `${c(a, "_parent", "root")}-${a._id}`,
102
+ key: `${d(a, "_parent", "root")}-${a._id}`,
104
103
  repeaterData: i,
105
104
  type: a._type
106
105
  }
107
106
  ) : null) : null);
108
107
  }, V = (e, t, r) => h(r) ? {} : Object.entries(r).reduce((i, [n, s]) => {
109
108
  const o = [];
110
- let a = F(e, { _id: t });
109
+ let a = R(e, { _id: t });
111
110
  for (; a; )
112
- o.push(a), a = F(e, { _id: a._parent });
113
- const l = F(o, { _type: s.block });
114
- return l && (i[n] = c(l, c(s, "prop"), null)), i;
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;
115
114
  }, {});
116
- function Se(e) {
115
+ function we(e) {
117
116
  if (h(e.lang) && !h(e.fallbackLang))
118
117
  throw new Error("lang prop is required when fallbackLang is provided");
119
118
  if (h(e.blocks))
120
119
  return null;
121
120
  const t = e.lang ?? "en", r = e.fallbackLang ?? t;
122
- return /* @__PURE__ */ m(R, { ...e, lang: t, fallbackLang: r });
121
+ return /* @__PURE__ */ m(F, { ...e, lang: t, fallbackLang: r });
123
122
  }
124
- async function ce(e) {
123
+ async function se(e) {
125
124
  const t = await e.dataProvider;
126
- return B(t, "$metadata") && x(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
125
+ return P(t, "$metadata") && w(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
127
126
  ...q(t, "$metadata")
128
127
  });
129
128
  }
130
- const de = () => /* @__PURE__ */ m("div", {}), ue = async (e) => {
129
+ const le = () => /* @__PURE__ */ m("div", {}), de = async (e) => {
131
130
  const {
132
131
  block: t,
133
132
  lang: r,
@@ -137,42 +136,44 @@ const de = () => /* @__PURE__ */ m("div", {}), ue = async (e) => {
137
136
  blocks: o,
138
137
  draft: a,
139
138
  pageProps: l,
140
- dataProviderMetadataCallback: k,
141
- dataProviders: d
142
- } = e, u = C(t._type), _ = c(u, "component", null), y = c(e.repeaterData, "index", -1), M = c(e.repeaterData, "dataKey", ""), g = O(
143
- N(t, r === i ? "" : r, u),
139
+ dataProviderMetadataCallback: y,
140
+ 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),
144
143
  s,
145
- { index: y, key: M }
146
- ), L = E(t, !1), T = V(o, t._id, J(t._type)), v = B(u, "dataProvider") && x(u.dataProvider), P = {
144
+ { 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 = {
147
146
  ...g,
148
- ...L,
149
- ...T
150
- }, w = {
147
+ ...x,
148
+ ...L
149
+ }, I = {
151
150
  blockProps: {},
152
151
  inBuilder: !1,
153
152
  lang: r || i,
154
- ...P
155
- }, D = c(P, "_show", !0);
153
+ pageData: s,
154
+ ...v
155
+ }, D = d(v, "_show", !0);
156
156
  if (H(_) || !D) return null;
157
- if (v) {
158
- const K = c(d, t._id, Promise.resolve({})), G = c(u, "suspenseFallback", de);
159
- return /* @__PURE__ */ m(S, { fallback: p(G), children: /* @__PURE__ */ m(
160
- ce,
157
+ 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(
160
+ se,
161
161
  {
162
162
  lang: r,
163
163
  pageProps: l,
164
- block: P,
164
+ block: v,
165
165
  dataProvider: K,
166
- ...k ? { dataProviderMetadataCallback: k } : {},
166
+ ...y ? { dataProviderMetadataCallback: y } : {},
167
167
  draft: a,
168
- children: (z) => p(_, {
169
- ...w,
168
+ children: (z) => u(_, {
169
+ ...I,
170
+ draft: a,
170
171
  ...z,
171
172
  children: n({
172
173
  _id: t._id,
173
174
  _type: t._type,
174
- ...b(g.repeaterItems) ? {
175
- repeaterItems: I(g.repeaterItems, t),
175
+ ...B(g.repeaterItems) ? {
176
+ repeaterItems: C(g.repeaterItems, t),
176
177
  $repeaterItemsKey: g.$repeaterItemsKey,
177
178
  repeaterTotalItems: g.repeaterTotalItems ?? -1
178
179
  } : {}
@@ -181,55 +182,59 @@ const de = () => /* @__PURE__ */ m("div", {}), ue = async (e) => {
181
182
  }
182
183
  ) });
183
184
  }
184
- return /* @__PURE__ */ m(S, { children: p(_, {
185
- ...w,
185
+ return u(_, {
186
+ ...I,
187
+ draft: a,
186
188
  children: n({
187
189
  _id: t._id,
188
190
  _type: t._type,
189
- ...b(g.repeaterItems) ? {
190
- repeaterItems: I(g.repeaterItems, t),
191
+ ...B(g.repeaterItems) ? {
192
+ repeaterItems: C(g.repeaterItems, t),
191
193
  $repeaterItemsKey: g.$repeaterItemsKey,
192
194
  repeaterTotalItems: g.repeaterTotalItems ?? -1
193
195
  } : {}
194
196
  })
195
- }) });
196
- }, A = async (e) => {
197
+ });
198
+ }, T = async (e) => {
197
199
  const { blocks: t, parent: r, repeaterData: i, type: n } = e;
198
200
  let s = W(
199
- $(t, (a) => B(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
201
+ $(t, (a) => P(a, "_id") && (h(r) ? !a._parent : a._parent === r)),
200
202
  "_id"
201
203
  );
202
204
  const o = (a) => $(t, (l) => l._parent === a).length > 0;
203
- return (n === "Heading" || n === "Paragraph" || n === "Link") && (s = j(s)), U(s, (a) => a ? /* @__PURE__ */ p(ue, { dataProviders: e.dataProviders, ...e, key: a._id, block: a }, ({ _id: l, _type: k, repeaterItems: d, $repeaterItemsKey: u }) => k === "Repeater" ? b(d) && d.map((_, y) => /* @__PURE__ */ p(
204
- A,
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(
206
+ T,
205
207
  {
206
208
  ...e,
207
209
  parent: a._id,
208
- key: `${c(a, "_parent", "root")}-${a._id}-${y}`,
209
- repeaterData: { index: y, dataKey: u }
210
+ key: `${d(a, "_parent", "root")}-${a._id}-${k}`,
211
+ repeaterData: { index: k, dataKey: p }
210
212
  }
211
- )) : o(l) ? /* @__PURE__ */ p(
212
- A,
213
+ )) : o(l) ? /* @__PURE__ */ u(
214
+ T,
213
215
  {
214
216
  ...e,
215
217
  parent: a._id,
216
- key: `${c(a, "_parent", "root")}-${a._id}`,
218
+ key: `${d(a, "_parent", "root")}-${a._id}`,
217
219
  repeaterData: i,
218
220
  type: a._type
219
221
  }
220
222
  ) : null) : null);
221
223
  };
222
- async function xe(e) {
224
+ async function Ie(e) {
223
225
  if (h(e.lang) && !h(e.fallbackLang))
224
226
  throw new Error("lang prop is required when fallbackLang is provided");
225
227
  if (h(e.blocks))
226
228
  return null;
227
- const t = e.lang ?? "en", r = e.fallbackLang ?? t, n = e.blocks.filter((s) => {
228
- const o = C(s._type);
229
- return !!(Q(o, "dataProvider") && X(o.dataProvider));
229
+ const t = e.lang ?? "en", r = e.fallbackLang ?? t;
230
+ if (e.dataProviders)
231
+ 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));
230
235
  }).reduce(
231
236
  (s, o) => {
232
- const a = C(o._type), l = {
237
+ const a = S(o._type), l = {
233
238
  pageProps: e.pageProps,
234
239
  block: o,
235
240
  lang: e.lang,
@@ -240,43 +245,43 @@ async function xe(e) {
240
245
  },
241
246
  {}
242
247
  );
243
- return /* @__PURE__ */ m(A, { ...e, lang: t, fallbackLang: r, dataProviders: n });
248
+ return /* @__PURE__ */ m(T, { ...e, lang: t, fallbackLang: r, dataProviders: n });
244
249
  }
245
- function Le(e, t) {
246
- const r = e.filter(({ _type: i }) => i === "GlobalBlock" || i === "PartialBlock");
250
+ function Ce(e, t) {
251
+ const r = e.filter((i) => i._type === "GlobalBlock" || i._type === "PartialBlock");
247
252
  for (let i = 0; i < r.length; i++) {
248
- const n = r[i], s = c(n, "partialBlockId", c(n, "globalBlock", ""));
253
+ const n = r[i], s = d(n, "partialBlockId", d(n, "globalBlock", ""));
249
254
  if (s === "") continue;
250
- let o = Y(c(t, s, []));
255
+ let o = Q(d(t, s, []));
251
256
  n._parent && (o == null ? void 0 : o.length) > 0 && (o = o.map((l) => (h(l._parent) && (l._parent = n._parent), l)));
252
257
  const a = e.indexOf(n);
253
258
  e.splice(a, 1, ...o);
254
259
  }
255
260
  return e;
256
261
  }
257
- const Te = (e) => {
262
+ const $e = (e) => {
258
263
  if (!e) return [];
259
264
  try {
260
- return JSON.parse(pe(e)).filter((r) => !r._type.startsWith("@chai"));
265
+ return JSON.parse(ce(e)).filter((r) => !r._type.startsWith("@chai"));
261
266
  } catch {
262
267
  return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
263
268
  }
264
269
  };
265
- function pe(e) {
270
+ function ce(e) {
266
271
  const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
267
272
  return e.replace(t, (r) => {
268
273
  const i = decodeURIComponent(r), n = i.indexOf("public");
269
274
  return n !== -1 ? i.substring(n + 6) : i;
270
275
  });
271
276
  }
272
- async function ge(e, t = [], r = !1) {
273
- return await ne({
277
+ async function pe(e, t = [], r = !1) {
278
+ return await X({
274
279
  tailwindConfig: {
275
280
  darkMode: "class",
276
281
  safelist: t,
277
282
  theme: {
278
283
  extend: {
279
- ...Z(),
284
+ ...re(),
280
285
  keyframes: {
281
286
  "accordion-down": {
282
287
  from: {
@@ -301,7 +306,7 @@ async function ge(e, t = [], r = !1) {
301
306
  }
302
307
  }
303
308
  },
304
- plugins: [ae, re, te, ie, ee],
309
+ plugins: [ee, te, Y, Z, ae],
305
310
  corePlugins: { preflight: r }
306
311
  }
307
312
  }).generateStylesFromContent(
@@ -311,19 +316,20 @@ async function ge(e, t = [], r = !1) {
311
316
  e
312
317
  );
313
318
  }
314
- const fe = (e, t) => {
319
+ const ue = (e, t) => {
315
320
  const r = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, n) => `#styles:${n.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
316
- return ge([r], [], t);
317
- }, De = async (e, t = !1) => await fe(e, t);
321
+ return pe([r], [], t);
322
+ }, Se = async (e, t = !1) => await ue(e, t);
318
323
  export {
319
- xe as AsyncRenderChaiBlocks,
320
- Se as RenderChaiBlocks,
321
- Ne as applyChaiDataBinding,
322
- Ee as convertHTMLToChaiBlocks,
323
- Te as convertToBlocks,
324
- Re as getChaiThemeCssVariables,
325
- Le as getMergedPartialBlocks,
326
- De as getStylesForBlocks,
327
- Ae as getThemeFontsCSSImport,
328
- Me as getThemeFontsLinkMarkup
324
+ Ie as AsyncRenderChaiBlocks,
325
+ we as RenderChaiBlocks,
326
+ Ae as applyChaiDataBinding,
327
+ Fe as applyDesignTokens,
328
+ Me as convertHTMLToChaiBlocks,
329
+ $e as convertToBlocks,
330
+ Le as getChaiThemeCssVariables,
331
+ Ce as getMergedPartialBlocks,
332
+ Se as getStylesForBlocks,
333
+ De as getThemeFontsCSSImport,
334
+ Ke as getThemeFontsLinkMarkup
329
335
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-DF5DEvqb.cjs"),p=({isOpen:m,onClose:i,editor:s,rteElement:f})=>{const a=t.usePageExternalData(),u=l=>{if(!s)return;const r=`{{${l}}}`;s.commands.focus();const{from:j,to:g}=s.state.selection;if(j!==g)s.chain().deleteSelection().insertContent(r).run();else{const{state:c}=s,n=c.selection.from,x=c.doc.textBetween(Math.max(0,n-1),n),o=c.doc.textBetween(n,Math.min(n+1,c.doc.content.size));let d="";n>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";o&&o!==" "&&!/[.,!?;:]/.test(o)&&(h=" "),s.chain().insertContent(d+r+h).run()}};return e.jsx(t.Dialog,{open:m,onOpenChange:l=>!l&&i(),children:e.jsxs(t.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(t.DialogHeader,{children:e.jsxs(t.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(t.NestedPathSelector,{data:a,onSelect:u})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(t.Button,{onClick:i,children:"Done"})})]})})};exports.default=p;
@@ -0,0 +1,38 @@
1
+ import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
+ import { g as D, D as N, d as S, e as j, f as v, N as w, B } from "./index-Ct7ElCGK.js";
3
+ const P = ({
4
+ isOpen: f,
5
+ onClose: i,
6
+ editor: t,
7
+ rteElement: x
8
+ }) => {
9
+ const a = D(), u = (c) => {
10
+ if (!t) return;
11
+ const r = `{{${c}}}`;
12
+ t.commands.focus();
13
+ const { from: p, to: g } = t.state.selection;
14
+ if (p !== g)
15
+ t.chain().deleteSelection().insertContent(r).run();
16
+ else {
17
+ const { state: s } = t, n = s.selection.from, d = s.doc.textBetween(Math.max(0, n - 1), n), o = s.doc.textBetween(n, Math.min(n + 1, s.doc.content.size));
18
+ let h = "";
19
+ n > 0 && d !== " " && !/[.,!?;:]/.test(d) && (h = " ");
20
+ let m = "";
21
+ o && o !== " " && !/[.,!?;:]/.test(o) && (m = " "), t.chain().insertContent(h + r + m).run();
22
+ }
23
+ };
24
+ return /* @__PURE__ */ e(N, { open: f, onOpenChange: (c) => !c && i(), children: /* @__PURE__ */ l(S, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
25
+ /* @__PURE__ */ e(j, { children: /* @__PURE__ */ l(v, { className: "flex items-center justify-between pr-8", children: [
26
+ /* @__PURE__ */ e("span", { children: "Rich Text Editor" }),
27
+ a && Object.keys(a).length > 0 && /* @__PURE__ */ l("div", { className: "flex items-center", children: [
28
+ /* @__PURE__ */ e("span", { className: "mr-2 text-sm text-muted-foreground", children: "Add field:" }),
29
+ /* @__PURE__ */ e("div", { className: "rte-path-selector", children: /* @__PURE__ */ e(w, { data: a, onSelect: u }) })
30
+ ] })
31
+ ] }) }),
32
+ x,
33
+ /* @__PURE__ */ e("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ e(B, { onClick: i, children: "Done" }) })
34
+ ] }) });
35
+ };
36
+ export {
37
+ P as default
38
+ };
package/dist/runtime.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@chaibuilder/runtime");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-B-rSiAp_.cjs"),t=require("./register-partial-type-ig9fUWIJ.cjs"),i=require("./fonts-B-Xt29pe.cjs"),e=require("./core-BoRDjj4h.cjs"),o=e.setChaiServerBlockDataProvider;exports.StylesProp=r.StylesProp;exports.builderProp=r.builderProp;exports.defaultChaiStyles=r.defaultChaiStyles;exports.registerChaiBlockSchema=r.registerChaiBlockSchema;exports.runtimeProp=r.runtimeProp;exports.stylesProp=r.stylesProp;Object.defineProperty(exports,"CHAI_GLOBAL_DATA_PROVIDER",{enumerable:!0,get:()=>t.CHAI_GLOBAL_DATA_PROVIDER});exports.COLLECTIONS=t.COLLECTIONS;exports.PAGE_TYPES=t.PAGE_TYPES;exports.getChaiCollection=t.getChaiCollection;exports.getChaiCollections=t.getChaiCollections;exports.getChaiGlobalData=t.getChaiGlobalData;exports.getChaiPageType=t.getChaiPageType;exports.getChaiPageTypes=t.getChaiPageTypes;exports.registerChaiCollection=t.registerChaiCollection;exports.registerChaiGlobalDataProvider=t.registerChaiGlobalDataProvider;exports.registerChaiPageType=t.registerChaiPageType;exports.registerChaiPartialType=t.registerChaiPartialType;exports.getAllRegisteredFonts=i.getAllRegisteredFonts;exports.getRegisteredFont=i.getRegisteredFont;exports.registerChaiFont=i.registerChaiFont;exports.useRegisteredFonts=i.useRegisteredFonts;exports.closestBlockProp=e.closestBlockProp;exports.getAIBlockProps=e.getAIBlockProps;exports.getBlockFormSchemas=e.getBlockFormSchemas;exports.getDefaultBlockProps=e.getDefaultBlockProps;exports.getI18nBlockProps=e.getI18nBlockProps;exports.getRegisteredChaiBlock=e.getRegisteredChaiBlock;exports.registerChaiBlock=e.registerChaiBlock;exports.registerChaiServerBlock=e.registerChaiServerBlock;exports.setChaiBlockComponent=e.setChaiBlockComponent;exports.setChaiServerBlockDataProvider=e.setChaiServerBlockDataProvider;exports.syncBlocksWithDefaults=e.syncBlocksWithDefaults;exports.useRegisteredChaiBlock=e.useRegisteredChaiBlock;exports.useRegisteredChaiBlocks=e.useRegisteredChaiBlocks;exports.setChaiBlockDataProvider=o;