@chaibuilder/sdk 3.0.8 → 3.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.
@@ -1,9 +1,9 @@
1
1
  import { registerChaiBlockSchema as d, StylesProp as u, registerChaiBlock as p, stylesProp as S, closestBlockProp as V } from "@chaibuilder/runtime";
2
- import { jsx as a, jsxs as b, Fragment as j } from "react/jsx-runtime";
2
+ import { jsx as a, jsxs as f, Fragment as j } from "react/jsx-runtime";
3
3
  import { c as _, g as I } from "./common-functions-BGzDsf1z.js";
4
4
  import * as y from "react";
5
5
  import { createElement as w } from "react";
6
- import { ButtonIcon as A, CodeIcon as M, DividerHorizontalIcon as F, CheckboxIcon as U, FileTextIcon as q, InputIcon as E, LetterCaseToggleIcon as Z, RadiobuttonIcon as G, DropdownMenuIcon as O, FrameIcon as H, HeadingIcon as Y, TableIcon as W, BorderTopIcon as Q, BorderAllIcon as J, ViewHorizontalIcon as X, DragHandleHorizontalIcon as K, SketchLogoIcon as ee, ImageIcon as te, Link1Icon as oe, RowsIcon as $, ColumnsIcon as le, TextIcon as re, LayoutIcon as ne, CursorTextIcon as ae, SpaceBetweenVerticallyIcon as ie, VideoIcon as se, LoopIcon as z } from "@radix-ui/react-icons";
6
+ import { ButtonIcon as A, CodeIcon as M, DividerHorizontalIcon as F, CheckboxIcon as U, FileTextIcon as q, InputIcon as E, LetterCaseToggleIcon as Z, RadiobuttonIcon as G, DropdownMenuIcon as W, FrameIcon as H, HeadingIcon as O, TableIcon as Y, BorderTopIcon as Q, BorderAllIcon as J, ViewHorizontalIcon as X, DragHandleHorizontalIcon as K, SketchLogoIcon as ee, ImageIcon as te, Link1Icon as oe, RowsIcon as $, ColumnsIcon as le, TextIcon as re, LayoutIcon as ne, CursorTextIcon as ae, SpaceBetweenVerticallyIcon as ie, VideoIcon as se, LoopIcon as z } from "@radix-ui/react-icons";
7
7
  import { isEmpty as C, get as h, map as T, isNull as ce, omit as pe, pick as de } from "lodash-es";
8
8
  const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div", { className: _("pointer-events-none flex h-20 flex-col items-center justify-center p-2", e), children: /* @__PURE__ */ a("div", { className: "h-full w-full rounded bg-gray-200 p-2 dark:bg-gray-800", children: /* @__PURE__ */ a("div", { className: "flex h-full w-full items-center justify-center outline-dashed outline-1 -outline-offset-1 outline-gray-400 duration-300 dark:outline-gray-700" }) }) }) : null, ue = (e) => {
9
9
  const { blockProps: o, inBuilder: t, backgroundImage: l, children: r, tag: n = "div", styles: i } = e;
@@ -20,12 +20,6 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
20
20
  ...d({
21
21
  properties: {
22
22
  styles: u(""),
23
- backgroundImage: {
24
- type: "string",
25
- default: "",
26
- title: "Background Image",
27
- ui: { "ui:widget": "image" }
28
- },
29
23
  tag: {
30
24
  type: "string",
31
25
  default: "div",
@@ -49,12 +43,18 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
49
43
  { const: "figcaption", title: "figcaption" },
50
44
  { const: "mark", title: "mark" }
51
45
  ]
46
+ },
47
+ backgroundImage: {
48
+ type: "string",
49
+ default: "",
50
+ title: "Background Image",
51
+ ui: { "ui:widget": "image" }
52
52
  }
53
53
  }
54
54
  }),
55
55
  canAcceptBlock: () => !0
56
56
  }, ye = (e) => {
57
- const { blockProps: o, iconSize: t, icon: l, content: r, styles: n, children: i, iconPos: s, link: c, inBuilder: m } = e, k = l, g = i || /* @__PURE__ */ b(j, { children: [
57
+ const { blockProps: o, iconSize: t, icon: l, content: r, styles: n, children: i, iconPos: s, link: c, inBuilder: m } = e, k = l, g = i || /* @__PURE__ */ f(j, { children: [
58
58
  r && /* @__PURE__ */ a("span", { children: r }),
59
59
  k && /* @__PURE__ */ a(
60
60
  "div",
@@ -125,16 +125,16 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
125
125
  },
126
126
  prefetchLink: {
127
127
  type: "boolean",
128
- default: !1,
128
+ default: !0,
129
129
  title: "Prefetch Link"
130
130
  }
131
131
  }
132
132
  }),
133
- i18nProps: ["content"],
133
+ i18nProps: ["content", "link"],
134
134
  aiProps: ["content"]
135
- }, fe = (e) => {
135
+ }, be = (e) => {
136
136
  const { blockProps: o, styles: t, htmlCode: l, inBuilder: r } = e;
137
- return r ? /* @__PURE__ */ b("div", { className: "relative", children: [
137
+ return r ? /* @__PURE__ */ f("div", { className: "relative", children: [
138
138
  r ? /* @__PURE__ */ a("div", { ...o, ...t, className: "absolute z-20 h-full w-full" }) : null,
139
139
  y.createElement("div", {
140
140
  ...t,
@@ -145,7 +145,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
145
145
  ...t,
146
146
  dangerouslySetInnerHTML: { __html: l }
147
147
  });
148
- }, be = {
148
+ }, fe = {
149
149
  type: "CustomHTML",
150
150
  description: "similar to a div or section elements in HTML",
151
151
  label: "Custom HTML",
@@ -223,7 +223,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
223
223
  })
224
224
  }, Ie = (e) => {
225
225
  const { blockProps: o, fieldName: t, label: l, styles: r, inputStyles: n, required: i, checked: s, showLabel: c = !0 } = e;
226
- return c ? /* @__PURE__ */ b("div", { ...r, ...o, children: [
226
+ return c ? /* @__PURE__ */ f("div", { ...r, ...o, children: [
227
227
  /* @__PURE__ */ a("input", { ...n, name: t, type: "checkbox", required: i, defaultChecked: s }),
228
228
  l && /* @__PURE__ */ a("label", { htmlFor: t, children: l })
229
229
  ] }) : /* @__PURE__ */ a(
@@ -280,7 +280,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
280
280
  }, Pe = (e) => {
281
281
  const { children: o, blockProps: t, errorMessage: l, successMessage: r, action: n, styles: i, inBuilder: s } = e;
282
282
  let c = o;
283
- return o || (c = /* @__PURE__ */ a(v, { inBuilder: s })), /* @__PURE__ */ b(
283
+ return o || (c = /* @__PURE__ */ a(v, { inBuilder: s })), /* @__PURE__ */ f(
284
284
  "form",
285
285
  {
286
286
  ...{
@@ -345,7 +345,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
345
345
  canAcceptBlock: () => !0
346
346
  }, Se = (e) => {
347
347
  const { blockProps: o, inBuilder: t, label: l, styles: r, icon: n, iconSize: i, iconPos: s } = e;
348
- return /* @__PURE__ */ b("button", { ...r, ...o || {}, type: t ? "button" : "submit", "aria-label": l, children: [
348
+ return /* @__PURE__ */ f("button", { ...r, ...o || {}, type: t ? "button" : "submit", "aria-label": l, children: [
349
349
  l,
350
350
  n && /* @__PURE__ */ a(
351
351
  "div",
@@ -476,7 +476,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
476
476
  inputType: m,
477
477
  defaultValue: k
478
478
  } = e, { type: g, autocomplete: x } = Te(m);
479
- return s ? /* @__PURE__ */ b("div", { ...n, ...o, children: [
479
+ return s ? /* @__PURE__ */ f("div", { ...n, ...o, children: [
480
480
  s && /* @__PURE__ */ a("label", { htmlFor: t, children: l }),
481
481
  /* @__PURE__ */ a(
482
482
  "input",
@@ -645,7 +645,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
645
645
  i18nProps: ["content"]
646
646
  }, Ee = (e) => {
647
647
  const { blockProps: o, fieldName: t, label: l, styles: r, inputStyles: n, required: i, checked: s, showLabel: c = !0 } = e;
648
- return c ? /* @__PURE__ */ b("div", { ...r, ...o, children: [
648
+ return c ? /* @__PURE__ */ f("div", { ...r, ...o, children: [
649
649
  /* @__PURE__ */ a("input", { ...n, name: t, type: "radio", required: i, defaultChecked: s }),
650
650
  l && /* @__PURE__ */ a("label", { htmlFor: t, children: l })
651
651
  ] }) : /* @__PURE__ */ a(
@@ -712,10 +712,10 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
712
712
  _multiple: m,
713
713
  options: k,
714
714
  defaultValue: g
715
- } = e, x = m && g ? g.split(",").map((f) => f.trim()) : g || "";
716
- return c ? /* @__PURE__ */ b("div", { ...n, ...o, children: [
715
+ } = e, x = m && g ? g.split(",").map((b) => b.trim()) : g || "";
716
+ return c ? /* @__PURE__ */ f("div", { ...n, ...o, children: [
717
717
  c && /* @__PURE__ */ a("label", { htmlFor: t, children: l }),
718
- /* @__PURE__ */ b(
718
+ /* @__PURE__ */ f(
719
719
  "select",
720
720
  {
721
721
  ...i,
@@ -725,11 +725,11 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
725
725
  defaultValue: x,
726
726
  children: [
727
727
  /* @__PURE__ */ a("option", { value: "", disabled: !0, hidden: !0, children: r }),
728
- T(k, (f) => /* @__PURE__ */ a("option", { value: f == null ? void 0 : f.value, children: f == null ? void 0 : f.label }, f == null ? void 0 : f.value))
728
+ T(k, (b) => /* @__PURE__ */ a("option", { value: b == null ? void 0 : b.value, children: b == null ? void 0 : b.label }, b == null ? void 0 : b.value))
729
729
  ]
730
730
  }
731
731
  )
732
- ] }) : /* @__PURE__ */ b(
732
+ ] }) : /* @__PURE__ */ f(
733
733
  "select",
734
734
  {
735
735
  ...n,
@@ -740,7 +740,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
740
740
  defaultValue: x,
741
741
  children: [
742
742
  /* @__PURE__ */ a("option", { value: "", disabled: !0, hidden: !0, children: r }),
743
- T(k, (f) => /* @__PURE__ */ a("option", { value: f == null ? void 0 : f.value, children: f == null ? void 0 : f.label }, f == null ? void 0 : f.value))
743
+ T(k, (b) => /* @__PURE__ */ a("option", { value: b == null ? void 0 : b.value, children: b == null ? void 0 : b.label }, b == null ? void 0 : b.value))
744
744
  ]
745
745
  }
746
746
  );
@@ -748,7 +748,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
748
748
  type: "Select",
749
749
  label: "web_blocks.select",
750
750
  category: "core",
751
- icon: O,
751
+ icon: W,
752
752
  group: "form",
753
753
  ...d({
754
754
  properties: {
@@ -815,7 +815,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
815
815
  i18nProps: ["label", "placeholder"]
816
816
  }, De = (e) => {
817
817
  const { blockProps: o, fieldName: t, label: l, placeholder: r, styles: n, inputStyles: i, rows: s, showLabel: c, required: m, defaultValue: k } = e;
818
- return c ? /* @__PURE__ */ b("div", { ...n, ...o, children: [
818
+ return c ? /* @__PURE__ */ f("div", { ...n, ...o, children: [
819
819
  c && /* @__PURE__ */ a("label", { htmlFor: t, children: l }),
820
820
  /* @__PURE__ */ a(
821
821
  "textarea",
@@ -894,13 +894,13 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
894
894
  i18nProps: ["label", "placeholder"]
895
895
  }, je = (e) => {
896
896
  const { blockProps: o, inBuilder: t, children: l, globalBlock: r } = e;
897
- return t && !r ? /* @__PURE__ */ b(
897
+ return t && !r ? /* @__PURE__ */ f(
898
898
  "div",
899
899
  {
900
900
  className: "flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",
901
901
  ...o,
902
902
  children: [
903
- /* @__PURE__ */ b("h1", { children: [
903
+ /* @__PURE__ */ f("h1", { children: [
904
904
  "Global Block - ",
905
905
  r
906
906
  ] }),
@@ -938,7 +938,7 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
938
938
  description: "A heading component similar to h1, h2, h3, h4, h5, h6 elements in HTML",
939
939
  label: "Heading",
940
940
  category: "core",
941
- icon: Y,
941
+ icon: O,
942
942
  group: "typography",
943
943
  ...d({
944
944
  properties: {
@@ -978,13 +978,13 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
978
978
  canDelete: () => !1,
979
979
  canMove: () => !1,
980
980
  canDuplicate: () => !1
981
- }, Oe = (e) => {
981
+ }, We = (e) => {
982
982
  const { blockProps: o, children: t, styles: l } = e;
983
983
  return t ? w("table", { ...o, ...l }, t) : /* @__PURE__ */ a(v, {});
984
- }, Ye = (e) => {
984
+ }, Oe = (e) => {
985
985
  const { blockProps: o, children: t, styles: l } = e;
986
986
  return t ? w("thead", { ...o, ...l }, t) : /* @__PURE__ */ a(v, {});
987
- }, We = (e) => {
987
+ }, Ye = (e) => {
988
988
  const { blockProps: o, children: t, styles: l } = e;
989
989
  return t ? w("tbody", { ...o, ...l }, t) : /* @__PURE__ */ a(v, {});
990
990
  }, Qe = (e) => {
@@ -998,13 +998,13 @@ const v = ({ className: e = "", inBuilder: o }) => o ? /* @__PURE__ */ a("div",
998
998
  dangerouslySetInnerHTML: { __html: l }
999
999
  });
1000
1000
  };
1001
- p(Oe, {
1001
+ p(We, {
1002
1002
  type: "Table",
1003
1003
  label: "Table",
1004
1004
  category: "core",
1005
1005
  group: "table",
1006
1006
  hidden: !0,
1007
- icon: W,
1007
+ icon: Y,
1008
1008
  ...d({
1009
1009
  properties: {
1010
1010
  styles: u("")
@@ -1012,7 +1012,7 @@ p(Oe, {
1012
1012
  }),
1013
1013
  blocks: L("Table")
1014
1014
  });
1015
- p(Ye, {
1015
+ p(Oe, {
1016
1016
  type: "TableHead",
1017
1017
  label: "Table Head",
1018
1018
  category: "core",
@@ -1026,7 +1026,7 @@ p(Ye, {
1026
1026
  }),
1027
1027
  blocks: L("TableHead")
1028
1028
  });
1029
- p(We, {
1029
+ p(Ye, {
1030
1030
  type: "TableBody",
1031
1031
  label: "Table Body",
1032
1032
  category: "core",
@@ -1164,9 +1164,9 @@ const D = (e, ...o) => ({
1164
1164
  }
1165
1165
  })
1166
1166
  }, et = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==", tt = (e) => {
1167
- const { blockProps: o, image: t, mobileImage: l, styles: r, alt: n, height: i, width: s, lazyLoading: c } = e;
1168
- return C(t) ? /* @__PURE__ */ a(v, { className: "h-36" }) : /* @__PURE__ */ b("picture", { children: [
1169
- l && /* @__PURE__ */ a("source", { srcSet: l, media: "(max-width: 480px)" }),
1167
+ const { blockProps: o, image: t, mobileImage: l, styles: r, alt: n, height: i, width: s, lazyLoading: c, mobileWidth: m, mobileHeight: k } = e;
1168
+ return C(t) ? /* @__PURE__ */ a(v, { className: "h-36" }) : /* @__PURE__ */ f("picture", { children: [
1169
+ l && /* @__PURE__ */ a("source", { srcSet: l, media: "(max-width: 480px)", width: m, height: k }),
1170
1170
  /* @__PURE__ */ a(
1171
1171
  "img",
1172
1172
  {
@@ -1196,25 +1196,14 @@ const D = (e, ...o) => ({
1196
1196
  default: et,
1197
1197
  ui: { "ui:widget": "image" }
1198
1198
  },
1199
- alt: {
1200
- type: "string",
1201
- title: "Alt text",
1202
- default: "",
1203
- ui: { "ui:placeholder": "Enter alt text" }
1204
- },
1205
- lazyLoading: {
1206
- type: "boolean",
1207
- title: "Lazy Load",
1208
- default: !0
1209
- },
1210
1199
  width: {
1211
- type: "number",
1200
+ type: "string",
1212
1201
  title: "Width",
1213
1202
  default: "",
1214
1203
  ui: { "ui:placeholder": "Enter width" }
1215
1204
  },
1216
1205
  height: {
1217
- type: "number",
1206
+ type: "string",
1218
1207
  title: "Height",
1219
1208
  default: "",
1220
1209
  ui: { "ui:placeholder": "Enter height" }
@@ -1224,6 +1213,29 @@ const D = (e, ...o) => ({
1224
1213
  title: "Mobile Image",
1225
1214
  default: "",
1226
1215
  ui: { "ui:widget": "image" }
1216
+ },
1217
+ mobileWidth: {
1218
+ type: "string",
1219
+ title: "Mobile Width",
1220
+ default: "",
1221
+ ui: { "ui:placeholder": "Enter width" }
1222
+ },
1223
+ mobileHeight: {
1224
+ type: "string",
1225
+ title: "Mobile Height",
1226
+ default: "",
1227
+ ui: { "ui:placeholder": "Enter height" }
1228
+ },
1229
+ alt: {
1230
+ type: "string",
1231
+ title: "Alt text",
1232
+ default: "",
1233
+ ui: { "ui:placeholder": "Enter alt text" }
1234
+ },
1235
+ lazyLoading: {
1236
+ type: "boolean",
1237
+ title: "Lazy Load",
1238
+ default: !0
1227
1239
  }
1228
1240
  }
1229
1241
  }),
@@ -1291,7 +1303,7 @@ const D = (e, ...o) => ({
1291
1303
  }
1292
1304
  }),
1293
1305
  aiProps: ["content"],
1294
- i18nProps: ["content"],
1306
+ i18nProps: ["content", "link"],
1295
1307
  canAcceptBlock: (e) => e !== "Link"
1296
1308
  }, nt = (e) => {
1297
1309
  const { blockProps: o, children: t, styles: l, tag: r, inBuilder: n } = e;
@@ -1394,13 +1406,13 @@ const D = (e, ...o) => ({
1394
1406
  canAcceptBlock: (e) => e === "Span" || e === "Link" || e === "Text"
1395
1407
  }, dt = (e) => {
1396
1408
  const { blockProps: o, inBuilder: t, children: l, partialBlockId: r } = e;
1397
- return t && !r ? /* @__PURE__ */ b(
1409
+ return t && !r ? /* @__PURE__ */ f(
1398
1410
  "div",
1399
1411
  {
1400
1412
  className: "flex flex-col items-center justify-center gap-y-1 rounded-lg bg-gray-100 py-4 dark:bg-gray-800",
1401
1413
  ...o,
1402
1414
  children: [
1403
- /* @__PURE__ */ b("h1", { children: [
1415
+ /* @__PURE__ */ f("h1", { children: [
1404
1416
  "Partial Block - ",
1405
1417
  r
1406
1418
  ] }),
@@ -1516,7 +1528,7 @@ const D = (e, ...o) => ({
1516
1528
  }, gt = (e) => {
1517
1529
  const { blockProps: o, children: t, styles: l, gutter: r } = e, i = { className: [h(l, "className", ""), " grid grid-cols-12"].join() };
1518
1530
  return typeof (l == null ? void 0 : l.style) == "object" ? l.style.gap = `${r}px` : i.style = { gap: `${r}px` }, /* @__PURE__ */ a("div", { ...o, ...l, ...i, children: t });
1519
- }, ft = {
1531
+ }, bt = {
1520
1532
  type: "Row",
1521
1533
  description: "A row component",
1522
1534
  label: "Row",
@@ -1547,7 +1559,7 @@ const D = (e, ...o) => ({
1547
1559
  }
1548
1560
  }
1549
1561
  })
1550
- }, bt = (e) => {
1562
+ }, ft = (e) => {
1551
1563
  const { blockProps: o, content: t, styles: l } = e, r = D(
1552
1564
  l,
1553
1565
  "prose dark:prose-invert prose-p:m-0 prose-p:min-h-[1rem] prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0",
@@ -1673,7 +1685,7 @@ const D = (e, ...o) => ({
1673
1685
  return null;
1674
1686
  }, It = (e) => {
1675
1687
  const { url: o, blockProps: t, styles: l, controls: r, videoSource: n, inBuilder: i } = e, s = vt(o, r);
1676
- return /* @__PURE__ */ b("div", { ...pe(l, "className"), className: "relative w-full overflow-hidden", style: { paddingBottom: "56.25%" }, children: [
1688
+ return /* @__PURE__ */ f("div", { ...pe(l, "className"), className: "relative w-full overflow-hidden", style: { paddingBottom: "56.25%" }, children: [
1677
1689
  !s && i ? /* @__PURE__ */ a("div", { className: "absolute flex h-full w-full items-center justify-center bg-gray-300 text-center", children: C(o) ? `Provided ${n} video link in settings Video URL.` : `Provided ${n} video link is invalid.` }) : /* @__PURE__ */ a("iframe", { width: "100%", src: s, ...de(l, "className") }),
1678
1690
  i && /* @__PURE__ */ a("div", { ...t, className: "absolute top-0 h-full w-full" })
1679
1691
  ] });
@@ -1706,7 +1718,7 @@ const D = (e, ...o) => ({
1706
1718
  ) });
1707
1719
  }, Pt = (e) => {
1708
1720
  const { videoSource: o } = e;
1709
- return o === "Custom" ? /* @__PURE__ */ a(Lt, { ...e }) : o === "Youtube" || o === "Vimeo" ? /* @__PURE__ */ a(It, { ...e }) : /* @__PURE__ */ b("div", { children: [
1721
+ return o === "Custom" ? /* @__PURE__ */ a(Lt, { ...e }) : o === "Youtube" || o === "Vimeo" ? /* @__PURE__ */ a(It, { ...e }) : /* @__PURE__ */ f("div", { children: [
1710
1722
  "Invalid video source : ",
1711
1723
  o
1712
1724
  ] });
@@ -1798,13 +1810,13 @@ const D = (e, ...o) => ({
1798
1810
  }, St = (e) => {
1799
1811
  const { children: o, tag: t, styles: l, blockProps: r, inBuilder: n, $loading: i } = e;
1800
1812
  let s = o;
1801
- return C(s) && n && (s = /* @__PURE__ */ a("div", { className: "col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground", children: "Choose a collection to display items" })), t === "none" ? i && n ? Array.from({ length: 2 }).map((c, m) => /* @__PURE__ */ b("div", { className: "animate-pulse rounded-md bg-primary/10 p-5", children: [
1813
+ return C(s) && n && (s = /* @__PURE__ */ a("div", { className: "col-span-3 flex items-center justify-center bg-orange-50 p-5 text-sm text-muted-foreground", children: "Choose a collection to display items" })), t === "none" ? i && n ? Array.from({ length: 2 }).map((c, m) => /* @__PURE__ */ f("div", { className: "animate-pulse rounded-md bg-primary/10 p-5", children: [
1802
1814
  /* @__PURE__ */ a("div", { className: "h-6 w-1/2 rounded-md bg-primary/10" }),
1803
1815
  /* @__PURE__ */ a("div", { className: "mt-2 h-4 w-1/2 rounded-md bg-primary/10" })
1804
1816
  ] }, m)) : s : y.createElement(
1805
1817
  t,
1806
1818
  { ...r, ...l },
1807
- i && n ? Array.from({ length: 2 }).map((c, m) => /* @__PURE__ */ b("div", { className: "animate-pulse rounded-md bg-primary/10 p-5", children: [
1819
+ i && n ? Array.from({ length: 2 }).map((c, m) => /* @__PURE__ */ f("div", { className: "animate-pulse rounded-md bg-primary/10 p-5", children: [
1808
1820
  /* @__PURE__ */ a("div", { className: "h-6 w-1/2 rounded-md bg-primary/10" }),
1809
1821
  /* @__PURE__ */ a("div", { className: "mt-2 h-4 w-1/2 rounded-md bg-primary/10" })
1810
1822
  ] }, m)) : s
@@ -1923,7 +1935,7 @@ const D = (e, ...o) => ({
1923
1935
  canMove: () => !1,
1924
1936
  canDuplicate: () => !1
1925
1937
  }, Vt = () => {
1926
- p(ue, me), p(Ce, ve), p(ye, ge), p(Ue, qe), p(ct, pt), p(kt, xt), p(bt, ht), p(lt, rt), p(nt, at), p(it, st), p(Xe, Ke), p(tt, ot), p(Pt, Bt), p(fe, be), p(he, ke), p(wt, Ct), p(Pe, Be), p(Se, _e), p(Ne, Re), p(Ie, Le), p(Ee, He), p($e, ze), p(De, Ve), p(Ae, Me), p(Ze, Ge), p(xe, we), p(je, Fe), p(dt, ut), p(gt, ft), p(mt, yt), p(St, _t), p(Tt, Nt), p(Rt, At);
1938
+ p(ue, me), p(Ce, ve), p(ye, ge), p(Ue, qe), p(ct, pt), p(kt, xt), p(ft, ht), p(lt, rt), p(nt, at), p(it, st), p(Xe, Ke), p(tt, ot), p(Pt, Bt), p(be, fe), p(he, ke), p(wt, Ct), p(Pe, Be), p(Se, _e), p(Ne, Re), p(Ie, Le), p(Ee, He), p($e, ze), p(De, Ve), p(Ae, Me), p(Ze, Ge), p(xe, we), p(je, Fe), p(dt, ut), p(gt, bt), p(mt, yt), p(St, _t), p(Tt, Nt), p(Rt, At);
1927
1939
  };
1928
1940
  export {
1929
1941
  Vt as loadWebBlocks
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Suraj Air",
6
6
  "license": "BSD-3-Clause",
7
7
  "homepage": "https://chaibuilder.com",
8
- "version": "3.0.8",
8
+ "version": "3.0.10",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",
@@ -132,7 +132,7 @@
132
132
  "react-colorful": "5.6.1",
133
133
  "react-error-boundary": "^6.0.0",
134
134
  "react-hotkeys-hook": "5.1.0",
135
- "react-i18next": "15.7.3",
135
+ "react-i18next": "16.0.0",
136
136
  "react-wrap-balancer": "^1.1.1",
137
137
  "sonner": "^2.0.7",
138
138
  "tailwind-merge": "^3.3.1",
@@ -163,7 +163,6 @@
163
163
  "eslint-plugin-react-refresh": "^0.4.18",
164
164
  "husky": "^9.1.7",
165
165
  "jest-environment-jsdom": "^29.7.0",
166
- "jotai-devtools": "0.13.0",
167
166
  "jsdoc": "^4.0.4",
168
167
  "msw": "^2.7.0",
169
168
  "postcss": "^8.5.1",
@@ -1 +0,0 @@
1
- "use strict";const q=require("@chaibuilder/runtime"),t=require("lodash-es"),V=require("tailwind-merge"),x=require("./common-functions-BZmyleS1.cjs"),b=require("himalaya"),y="#styles:",W="__ADD_BLOCK_INTERNAL_ROOT",O="@",S="#",A=e=>{if(e=e.replace(y,""),!e)return{baseClasses:"",classes:""};const n=e.split(/,(?![^\[]*\])/);if(n.length===1)return{baseClasses:"",classes:n[0].trim()};const[a,...s]=n;return{baseClasses:a.trim(),classes:s.join(",").trim().replace(/ +(?= )/g,"")}};function z(e,n,a){const s=t.get(a,"i18nProps",[]);if(t.isEmpty(n)||t.isEmpty(s))return e;const i=t.cloneDeep(e);return t.forEach(t.keys(i),l=>{if(t.includes(s,l)&&!t.isEmpty(n)){const c=t.get(i,`${l}-${n}`,""),r=t.get(i,l,"");i[l]=t.isString(c)&&c.trim()||r}}),i}const F=t.memoize(e=>{const{baseClasses:n,classes:a}=A(e);return V.twMerge(n,a)});function J(e,n){return t.get(e,`${n}_attrs`,{})}function Y(e,n=!0){const a={};return Object.keys(e).forEach(s=>{if(t.isString(e[s])&&e[s].startsWith(y)){const i=F(e[s]),l=J(e,s);a[s]={...!t.isEmpty(i)&&{className:i},...l,...n?{"data-style-prop":s,"data-block-parent":e._id,"data-style-id":`${s}-${e._id}`}:{}}}}),a}const j=t.memoize(e=>{const n=q.getRegisteredChaiBlock(e),a=t.get(n,"schema.properties",{});return Object.fromEntries(Object.entries(a).filter(([,s])=>t.get(s,"runtime",!1)))}),K=(e,n)=>{if(!t.isArray(e))return e;let a=e,s;return typeof n.limit=="number"&&n.limit>0&&(s=n.limit),s!==void 0&&(a=a.slice(0,s)),a},U=(e,n)=>{const a=t.cloneDeep(e);return t.forEach(t.keys(a),s=>{if(t.isString(a[s])&&!t.startsWith(s,"_")){let i=a[s];s==="repeaterItems"&&(a.repeaterItemsBinding=i);const l=/\{\{(.*?)\}\}/g,c=i.match(l);c&&c.forEach(r=>{let u=r.slice(2,-2);const g=t.get(n,u,r);i=t.isArray(g)?g:i.replace(r,g)}),a[s]=i}}),a},X=e=>{const n=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,a=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return n.test(e)||a.test(e)},Z=e=>{if(t.isEmpty(e))return e;const n=/<video[^>]+src=['"]([^'">]+)['"]/,a=/<iframe[^>]+src=['"]([^'">]+)['"]/,s=e.match(n),i=e.match(a),l=s?s[1]:i?i[1]:null,c=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return l&&(c.test(l)||r.test(l))?l:e},P=["chai-name","data-chai-name"],G={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"},form:{action:"action"}},Q=(e,n)=>e.children.length===1&&t.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],n._type),_=e=>e.map(n=>n.type==="text"?t.get(n,"content",""):t.isEmpty(n.children)?"":_(n.children)).join(""),L=e=>e===null?"":e,H=e=>{const n=t.compact(t.map(e.split(/\s+/),t.trim)),a=t.find(n,r=>/^w-/.test(r)),s=t.find(n,r=>/^h-/.test(r));if(!s||!a)return{height:"",width:""};const i=r=>{if(!r)return;const u=r.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);if(!u)return;if(u[1])return u[1];const g=u[2];return/^\d+(\.\d+)?$/.test(g)?`${Number(g)*4}px`:g==="auto"||t.includes(g,"%")?g:"16px"},l=i(a),c=i(s);return{width:t.includes(l,"px")?l:"16px",height:t.includes(c,"px")?c:"16px"}},R=e=>{if(e.tagName==="svg")return{};const n={},a=G[e.tagName]||{},s=e.attributes;return t.forEach(s,({key:i,value:l})=>{if(!t.includes(P,i))if(a[i]){if(e.tagName==="img"&&i==="src"&&!l.startsWith("http")){const c=t.find(e.attributes,{key:"width"}),r=t.find(e.attributes,{key:"height"});c&&r?l=`https://via.placeholder.com/${c==null?void 0:c.value}x${r==null?void 0:r.value}`:l="https://via.placeholder.com/150x150"}t.set(n,a[i],L(l))}else t.includes(["style","class","srcset"],i)||(t.has(n,"styles_attrs")||(n.styles_attrs={}),t.startsWith(i,"@")&&(i=i.replace("@","x-on:")),n.styles_attrs[`${i}`]=L(l))}),delete n.class,n},ee=(e,n="styles")=>{if(!e.attributes)return{[n]:`${y},`};const a=t.find(e.attributes,{key:"class"});if(a){const s=a.value;return{[n]:`${y},${s}`}}return{[n]:`${y},`}},te=e=>{const n=t.get(e,"attributes",[]),a=n.find(r=>r.key==="data-chai-richtext"||r.key==="chai-richtext"),s=n.find(r=>r.key==="data-chai-lightbox"||r.key==="chai-lightbox"),i=n.find(r=>r.key==="data-chai-dropdown"||r.key==="chai-dropdown"),l=n.find(r=>r.key==="data-chai-dropdown-button"||r.key==="chai-dropdown-button"),c=n.find(r=>r.key==="data-chai-dropdown-content"||r.key==="chai-dropdown-content");if(i)return{_type:"Dropdown"};if(l)return{_type:"DropdownButton"};if(c)return{_type:"DropdownContent"};if(a)return{_type:"RichText"};if(s)return{_type:"LightBoxLink"};switch(e.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:e.tagName,_listType:e.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:e.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:e.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Box",_name:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:e.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:e.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const r=t.get(e,"children",[]).length>0?"Box":"EmptyBox";return{_type:r,tag:e.tagName,_name:r=="EmptyBox"||e.tagName==="div"?r:t.capitalize(e.tagName)}}}},M=(e,n=null)=>t.flatMapDeep(e,a=>{var E,w,v,T,$,B,C,I,D,N;if(a.type==="comment")return[];let s={_id:x.generateUUID()};if(n&&(s._parent=n.block._id),a.type==="text")return t.isEmpty(t.get(a,"content",""))?[]:n&&Q(n.node,n.block)?(t.set(n,"block.content",t.get(a,"content","")),[]):{...s,_type:"Text",content:t.get(a,"content","")};const i=t.get(a,"attributes",[]),l=i.find(o=>o.key==="data-chai-richtext"||o.key==="chai-richtext"),c=i.find(o=>o.key==="data-chai-lightbox"||o.key==="chai-lightbox"),r=i.find(o=>o.key==="data-chai-dropdown"||o.key==="chai-dropdown"),u=i.find(o=>o.key==="data-chai-dropdown-button"||o.key==="chai-dropdown-button"),g=i.find(o=>o.key==="data-chai-dropdown-content"||o.key==="chai-dropdown-content");if(s={...s,...te(a),...R(a),...ee(a)},a.attributes){const o=a.attributes.find(p=>t.includes(P,p.key));o&&(s._name=o.value)}if(l)return s.content=b.stringify(a.children),t.has(s,"styles_attrs.data-chai-richtext")&&delete s.styles_attrs["data-chai-richtext"],t.has(s,"styles_attrs.chai-richtext")&&delete s.styles_attrs["chai-richtext"],[s];if(c){const o=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];s={...s,href:((E=i.find(p=>p.key==="href"))==null?void 0:E.value)||"",hrefType:((w=i.find(p=>p.key==="data-vbtype"))==null?void 0:w.value)||"video",autoplay:((v=i.find(p=>p.key==="data-autoplay"))==null?void 0:v.value)==="true"?"true":"false",maxWidth:(($=(T=i.find(p=>p.key==="data-maxwidth"))==null?void 0:T.value)==null?void 0:$.replace("px",""))||"",backdropColor:((B=i.find(p=>p.key==="data-overlay"))==null?void 0:B.value)||"",galleryName:((C=i.find(p=>p.key==="data-gall"))==null?void 0:C.value)||""},t.forEach(o,p=>{t.has(s,`styles_attrs.${p}`)&&delete s.styles_attrs[p]})}if(r&&(delete s.styles_attrs,s.showDropdown=!1),g&&delete s.styles_attrs,u){delete s.styles_attrs;const o=t.filter(a.children||[],d=>(d==null?void 0:d.tagName)!=="span");s.content=_(o);const p=t.find(a.children||[],d=>(d==null?void 0:d.tagName)==="span"&&t.some(d.children||[],h=>(h==null?void 0:h.tagName)==="svg"));if(p){const d=t.find(p.children||[],h=>(h==null?void 0:h.tagName)==="svg");if(d){s.icon=b.stringify([d]);const{height:h,width:f}=se(d,"16px","16px");s.iconHeight=h,s.iconWidth=f}}return[s]}if(s._type==="Input"){const o=s.inputType||"text";o==="checkbox"?t.set(s,"_type","Checkbox"):o==="radio"&&t.set(s,"_type","Radio")}else if(a.tagName==="video"||a.tagName==="iframe"){const o=b.stringify([a]);return X(o)&&(t.set(s,"_type","Video"),t.set(s,"url",Z(o)),t.set(s,"styles",`${y},`),t.set(s,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),s.content=o,[s]}else if(a.tagName==="svg"){const o=t.get(t.find(a.attributes,{key:"class"}),"value",""),{height:p,width:d}=H(o);if(p&&d)s.styles=`${y}, ${x.cn(`w-${d} h-${p}`,o)}`.trim(),s.height=p==null?void 0:p.replace("px",""),s.width=d==null?void 0:d.replace("px","");else{const h=(I=t.find(a.attributes,{key:"height"}))==null?void 0:I.value,f=(D=t.find(a.attributes,{key:"width"}))==null?void 0:D.value;h&&f?(s.styles=`${y}, ${x.cn(`w-[${f}px] h-[${h}px]`,o)}`.trim(),s.height=h,s.width=f):s.styles=`${y}, ${x.cn("w-full h-full",o)}`.trim()}return a.attributes=t.filter(a.attributes,h=>!t.includes(["style","width","height","class"],h.key)),s.icon=b.stringify([a]),[s]}else if(a.tagName=="option"&&n&&((N=n.block)==null?void 0:N._type)==="Select")return n.block.options.push({label:_(a.children),...R(a)}),[];const m=M(a.children,{block:s,node:a});return[s,...m]}),se=(e,n,a)=>{var u,g;const s=t.get(e,"attributes",[]),{height:i,width:l}=H(t.get(t.find(s,{key:"class"}),"value",""));if(i&&l)return{height:`[${i}px]`,width:`[${l}px]`};const c=(u=t.find(s,{key:"height"}))==null?void 0:u.value,r=(g=t.find(s,{key:"width"}))==null?void 0:g.value;return{height:c?`[${c}px]`:a,width:r?`[${r}px]`:n}},ae=e=>{e=e.replace(/(\w+)=\\?"(.*?)\\?"/g,(s,i,l)=>{let c=l.replace(/\\"/g,'"');return c=c.replace(/{([^}]+)}/g,r=>r.replace(/"/g,'\\"')),`${i}="${c.replace(/\\"/g,'"')}"`}),e=e.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),e=e.replace(/\$name="[^"]*"/g,"");const n=e.match(/<body[^>]*>[\s\S]*?<\/body>/);return(n&&n.length>0?n[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):e).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},ne=e=>{const n=b.parse(ae(e));return t.isEmpty(e)?[]:t.flatten(M(n))},k=(e,n,{index:a,key:s})=>{if(t.isString(e)){let i=e;const l=/\{\{(.*?)\}\}/g,c=e.match(l);return c&&c.forEach(r=>{let u=r.slice(2,-2).trim(),g=s.slice(2,-2).trim();a!==-1&&t.startsWith(u,"$index.")?u=`${g}.${a}.${u.slice(7)}`:a!==-1&&t.startsWith(u,"$index")&&(u=`${g}.${a}`);const m=t.get(n,u);m===void 0?i=i.replace(r,""):i=t.isArray(m)?m:i.replace(r,m)}),i}if(t.isArray(e))return e.map(i=>k(i,n,{index:a,key:s}));if(e&&typeof e=="object"){const i={};return t.forEach(t.keys(e),l=>{!t.startsWith(l,"_")&&l!=="$repeaterItemsKey"?i[l]=k(e[l],n,{index:a,key:s}):i[l]=e[l]}),i}return e},ie=(e,n,{index:a,key:s})=>{let i=t.cloneDeep(e);return i.repeaterItems&&(i.$repeaterItemsKey=i.repeaterItems,t.startsWith(i.repeaterItems,`{{${S}`)&&(i.$repeaterItemsKey=i.repeaterItems=`${i.repeaterItems.replace("}}",`/${i._id}}}`)}`)),k(i,n,{index:a,key:s})};exports.COLLECTION_PREFIX=S;exports.REPEATER_PREFIX=O;exports.ROOT_TEMP_KEY=W;exports.STYLES_KEY=y;exports.applyBindingToBlockProps=ie;exports.applyChaiDataBinding=U;exports.applyLanguage=z;exports.applyLimit=K;exports.getBlockRuntimeProps=j;exports.getBlockTagAttributes=Y;exports.getBlocksFromHTML=ne;exports.getSplitChaiClasses=A;