@chaibuilder/sdk 3.1.2 → 3.1.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.
@@ -1,6 +1,6 @@
1
1
  var U = Object.defineProperty;
2
2
  var W = (o, n, r) => n in o ? U(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
3
- var F = (o, n, r) => W(o, typeof n != "symbol" ? n + "" : n, r);
3
+ var $ = (o, n, r) => W(o, typeof n != "symbol" ? n + "" : n, r);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, syncBlocksWithDefaults, useRegisteredFonts, getBlockFormSchemas } from "@chaibuilder/runtime";
6
6
  import { get, find, filter, flatten, has, map, includes, without, compact, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, kebabCase, round, reverse, findIndex, uniq, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, sortBy } from "lodash-es";
@@ -37,7 +37,7 @@ import validator from "@rjsf/validator-ajv8";
37
37
  import Autosuggest from "react-autosuggest";
38
38
  import { useFeature } from "flagged";
39
39
  import { Tree } from "react-arborist";
40
- import { compact as compact$1, pick as pick$1, noop as noop$1 } from "lodash";
40
+ import { compact as compact$1, pick as pick$1, each as each$1, get as get$1, noop as noop$1 } from "lodash";
41
41
  import { parse, stringify } from "himalaya";
42
42
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
43
43
  import tailwindForms from "@tailwindcss/forms";
@@ -2830,8 +2830,10 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2830
2830
  if (!i) return null;
2831
2831
  const c = (i == null ? void 0 : i.i18nProps) ?? [];
2832
2832
  if (c.length === 0) return null;
2833
- const d = r === "ALL" ? Object.keys(l).filter((p) => c.find((u) => p.startsWith(u))) : c.map((p) => r ? `${p}-${r}` : p);
2834
- return pick$1(l, [...d, "_id"]);
2833
+ const d = r === "ALL" ? Object.keys(l).filter((u) => c.find((g) => u.startsWith(g))) : c.map((u) => r ? `${u}-${r}` : u), p = pick$1(l, ["_id"]);
2834
+ return each$1(d, (u) => {
2835
+ p[u] = get$1(l, u, get$1(l, u.replace(`-${r}`, "")));
2836
+ }), p;
2835
2837
  })
2836
2838
  ) : [];
2837
2839
  },
@@ -2923,7 +2925,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), ScalePerc
2923
2925
  };
2924
2926
  class PubSub {
2925
2927
  constructor() {
2926
- F(this, "subscribers", /* @__PURE__ */ new Map());
2928
+ $(this, "subscribers", /* @__PURE__ */ new Map());
2927
2929
  }
2928
2930
  subscribe(n, r) {
2929
2931
  return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
@@ -3368,17 +3370,17 @@ class Content extends Component {
3368
3370
  class Frame extends Component {
3369
3371
  constructor(r, a) {
3370
3372
  super(r, a);
3371
- F(this, "setRef", (r) => {
3373
+ $(this, "setRef", (r) => {
3372
3374
  this.nodeRef.current = r;
3373
3375
  const { forwardedRef: a } = this.props;
3374
3376
  typeof a == "function" ? a(r) : a && (a.current = r);
3375
3377
  });
3376
- F(this, "handleLoad", () => {
3378
+ $(this, "handleLoad", () => {
3377
3379
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
3378
3380
  });
3379
3381
  // In certain situations on a cold cache DOMContentLoaded never gets called
3380
3382
  // fallback to an interval to check if that's the case
3381
- F(this, "loadCheck", () => setInterval(() => {
3383
+ $(this, "loadCheck", () => setInterval(() => {
3382
3384
  this.handleLoad();
3383
3385
  }, 500));
3384
3386
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -3415,7 +3417,7 @@ class Frame extends Component {
3415
3417
  return delete r.head, delete r.initialContent, delete r.mountTarget, delete r.contentDidMount, delete r.contentDidUpdate, delete r.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...r, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
3416
3418
  }
3417
3419
  }
3418
- F(Frame, "defaultProps", {
3420
+ $(Frame, "defaultProps", {
3419
3421
  style: {},
3420
3422
  head: null,
3421
3423
  children: void 0,
@@ -4514,7 +4516,7 @@ const CanvasEventsWatcher = () => {
4514
4516
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
4515
4517
  /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
4516
4518
  ] }) });
4517
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-BwCdfuDZ.js")), CanvasArea = () => {
4519
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-BpQxKJGQ.js")), CanvasArea = () => {
4518
4520
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
4519
4521
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
4520
4522
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -5084,7 +5086,7 @@ const DataBindingSelector = ({
5084
5086
  ]
5085
5087
  }
5086
5088
  ) });
5087
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-DrMYNEN2.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
5089
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-BFbI7jcA.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
5088
5090
  const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
5089
5091
  blockId: o,
5090
5092
  value: a,
@@ -7944,10 +7946,10 @@ const Input = ({ node: o }) => {
7944
7946
  return () => clearTimeout(N);
7945
7947
  }, [f, o, b]);
7946
7948
  const E = (N, O) => {
7947
- const $ = i.contentDocument || i.contentWindow.document, M = $.querySelector(`[data-block-id=${N}]`);
7949
+ const F = i.contentDocument || i.contentWindow.document, M = F.querySelector(`[data-block-id=${N}]`);
7948
7950
  M && M.setAttribute("data-drop", O);
7949
7951
  const V = M.getBoundingClientRect(), H = i.getBoundingClientRect();
7950
- V.top >= H.top && V.left >= H.left && V.bottom <= H.bottom && V.right <= H.right || ($.documentElement.scrollTop = M.offsetTop - H.top);
7952
+ V.top >= H.top && V.left >= H.left && V.bottom <= H.bottom && V.right <= H.right || (F.documentElement.scrollTop = M.offsetTop - H.top);
7951
7953
  }, L = (N) => {
7952
7954
  A();
7953
7955
  const O = get(o, "parent.id");
@@ -9418,7 +9420,7 @@ const UndoRedo = () => {
9418
9420
  if (w) {
9419
9421
  const E = w.selectionStart || 0, L = w.value || "", T = w.selectionEnd || E;
9420
9422
  if (T > E) {
9421
- const O = `{{${k}}}`, { text: $ } = A(L, E, O), M = L.slice(0, E) + $ + L.slice(T);
9423
+ const O = `{{${k}}}`, { text: F } = A(L, E, O), M = L.slice(0, E) + F + L.slice(T);
9422
9424
  p(M);
9423
9425
  return;
9424
9426
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as c } from "react/jsx-runtime";
2
- import { d as N, N as D } from "./index-DdxrsPQZ.js";
2
+ import { d as N, N as D } from "./index-C9p-YGGl.js";
3
3
  import { a1 as v, a3 as S, a6 as j, a9 as w, v as y } from "./tooltip-4-b9QGDK.js";
4
4
  import "clsx";
5
5
  import "tailwind-merge";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-HYzn6bSR.cjs"),n=require("./tooltip-C2BCZ8Al.cjs");require("clsx");require("tailwind-merge");const S=({isOpen:m,onClose:l,editor:t,rteElement:f})=>{const r=u.usePageExternalData(),j=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:p,to:g}=t.state.selection;if(p!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,s=c.selection.from,x=c.doc.textBetween(Math.max(0,s-1),s),a=c.doc.textBetween(s,Math.min(s+1,c.doc.content.size));let d="";s>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";a&&a!==" "&&!/[.,!?;:]/.test(a)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(n.Dialog,{open:m,onOpenChange:o=>!o&&l(),children:e.jsxs(n.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(n.DialogHeader,{children:e.jsxs(n.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),Object.keys(r).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(u.NestedPathSelector,{data:r,onSelect:j})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(n.Button,{onClick:l,children:"Done"})})]})})};exports.default=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("./index-Bcp30Thz.cjs"),n=require("./tooltip-C2BCZ8Al.cjs");require("clsx");require("tailwind-merge");const S=({isOpen:m,onClose:l,editor:t,rteElement:f})=>{const r=u.usePageExternalData(),j=o=>{if(!t)return;const i=`{{${o}}}`;t.commands.focus();const{from:p,to:g}=t.state.selection;if(p!==g)t.chain().deleteSelection().insertContent(i).run();else{const{state:c}=t,s=c.selection.from,x=c.doc.textBetween(Math.max(0,s-1),s),a=c.doc.textBetween(s,Math.min(s+1,c.doc.content.size));let d="";s>0&&x!==" "&&!/[.,!?;:]/.test(x)&&(d=" ");let h="";a&&a!==" "&&!/[.,!?;:]/.test(a)&&(h=" "),t.chain().insertContent(d+i+h).run()}};return e.jsx(n.Dialog,{open:m,onOpenChange:o=>!o&&l(),children:e.jsxs(n.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[800px]",children:[e.jsx(n.DialogHeader,{children:e.jsxs(n.DialogTitle,{className:"flex items-center justify-between pr-8",children:[e.jsx("span",{children:"Rich Text Editor"}),Object.keys(r).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(u.NestedPathSelector,{data:r,onSelect:j})})]})]})}),f,e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(n.Button,{onClick:l,children:"Done"})})]})})};exports.default=S;
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.1.2",
8
+ "version": "3.1.3",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",