@chaibuilder/sdk 3.2.0 → 3.2.2
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.
- package/dist/{apply-binding-CSWwWMjY.js → apply-binding-B11pPFEE.js} +15 -17
- package/dist/apply-binding-DOJpwjiG.cjs +1 -0
- package/dist/{code-editor-DRCY5ruT.cjs → code-editor-B4F8QB5S.cjs} +1 -1
- package/dist/{code-editor-BZMSNYkF.js → code-editor-zas3OmxC.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +2 -2
- package/dist/{index-CAiYwkFz.js → index-CPvjpLmN.js} +478 -481
- package/dist/{index-DIVARO6Y.cjs → index-IErL-ZZD.cjs} +5 -5
- package/dist/render.cjs +1 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-DwKI9icC.js → rte-widget-modal-2S4dpCHF.js} +1 -1
- package/dist/{rte-widget-modal-C7aXKVn4.cjs → rte-widget-modal-DcTD9G1X.cjs} +1 -1
- package/package.json +1 -1
- package/dist/apply-binding-DLHh7HoS.cjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as ct, c as P } from "./common-functions-D2lMFR6K.js";
|
|
2
|
-
import { isEmpty as x, flatten as pt, flatMapDeep as ut, get as d, set as E, startsWith as k, find as m, startCase as dt, forEach as
|
|
2
|
+
import { isEmpty as x, flatten as pt, flatMapDeep as ut, get as d, set as E, startsWith as k, find as m, startCase as dt, forEach as N, camelCase as ht, includes as w, has as A, filter as Q, some as yt, unset as H, map as st, compact as mt, trim as gt, capitalize as bt, memoize as xt, cloneDeep as M, keys as W, isString as $, isArray as I, each as ft, last as _t } from "lodash-es";
|
|
3
3
|
import { parse as kt, stringify as D } from "himalaya";
|
|
4
4
|
import { getRegisteredChaiBlock as vt } from "@chaibuilder/runtime";
|
|
5
5
|
import { twMerge as wt } from "tailwind-merge";
|
|
@@ -89,7 +89,7 @@ const Bt = (e) => {
|
|
|
89
89
|
form: {
|
|
90
90
|
action: "action"
|
|
91
91
|
}
|
|
92
|
-
},
|
|
92
|
+
}, Nt = (e, a) => e.children.length === 1 && w(
|
|
93
93
|
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
94
94
|
a._type
|
|
95
95
|
), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : x(a.children) ? "" : j(a.children)).join(""), R = (e) => e === null ? "" : e, ot = (e) => {
|
|
@@ -110,7 +110,7 @@ const Bt = (e) => {
|
|
|
110
110
|
}, et = (e) => {
|
|
111
111
|
if (e.tagName === "svg") return {};
|
|
112
112
|
const a = {}, t = $t[e.tagName] || {}, s = e.attributes;
|
|
113
|
-
return
|
|
113
|
+
return N(s, ({ key: n, value: o }) => {
|
|
114
114
|
if (!w(at, n))
|
|
115
115
|
if (n === "bid" && (a._bid = R(o)), t[n]) {
|
|
116
116
|
if (e.tagName === "img" && n === "src" && !o.startsWith("http")) {
|
|
@@ -120,7 +120,7 @@ const Bt = (e) => {
|
|
|
120
120
|
E(a, t[n], R(o));
|
|
121
121
|
} else w(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), k(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] = R(o));
|
|
122
122
|
}), delete a.class, a;
|
|
123
|
-
},
|
|
123
|
+
}, St = (e, a = "styles") => {
|
|
124
124
|
if (!e.attributes) return { [a]: `${f},` };
|
|
125
125
|
const t = m(e.attributes, { key: "class" });
|
|
126
126
|
if (t) {
|
|
@@ -235,25 +235,23 @@ const Bt = (e) => {
|
|
|
235
235
|
if (t.type === "comment") return [];
|
|
236
236
|
let s = { _id: ct() };
|
|
237
237
|
if (a && (s._parent = a.block._id), t.type === "text")
|
|
238
|
-
return x(d(t, "content", "")) ? [] : a &&
|
|
238
|
+
return x(d(t, "content", "")) ? [] : a && Nt(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
|
|
239
239
|
if (k(t.tagName, "chai-")) {
|
|
240
240
|
const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || dt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
|
|
241
|
-
s._type = u,
|
|
241
|
+
s._type = u, N(c, ({ key: g, value: G }) => {
|
|
242
242
|
if (g === "about-this-component" || g === "chai-type" || g === "can-move" || g === "can-delete") return;
|
|
243
243
|
if (g === "id") {
|
|
244
244
|
s._id = G;
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
const rt = k(g, "_") ? g : ht(g);
|
|
248
|
-
let
|
|
249
|
-
typeof
|
|
248
|
+
let S = R(G);
|
|
249
|
+
typeof S == "string" && k(S, "#styles:") && (S = S.replace("#styles:", "#styles:,")), s[rt] = S;
|
|
250
250
|
});
|
|
251
251
|
const y = q(t.children, { block: s, node: t });
|
|
252
252
|
return [s, ...y];
|
|
253
253
|
}
|
|
254
|
-
const n = d(t, "attributes", []), o = n.find(
|
|
255
|
-
(c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"
|
|
256
|
-
), l = n.find((c) => c.key === "class"), i = l && l.value.split(/\s+/).includes("rte"), h = n.find(
|
|
254
|
+
const n = d(t, "attributes", []), o = t.tagName === "p" || n.find((c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"), l = n.find((c) => c.key === "class"), i = l && l.value.split(/\s+/).includes("rte"), h = n.find(
|
|
257
255
|
(c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
|
|
258
256
|
), r = n.find(
|
|
259
257
|
(c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
|
|
@@ -266,13 +264,13 @@ const Bt = (e) => {
|
|
|
266
264
|
...s,
|
|
267
265
|
...It(t),
|
|
268
266
|
...et(t),
|
|
269
|
-
...
|
|
267
|
+
...St(t)
|
|
270
268
|
}, t.attributes) {
|
|
271
269
|
const c = t.attributes.find((p) => w(at, p.key));
|
|
272
270
|
c && (s._name = c.value);
|
|
273
271
|
}
|
|
274
272
|
if (o || i)
|
|
275
|
-
return s.content = D(t.children)
|
|
273
|
+
return s.content = `<p>${D(t.children || [])}</p>`, A(s, "styles_attrs.data-chai-richtext") && delete s.styles_attrs["data-chai-richtext"], A(s, "styles_attrs.chai-richtext") && delete s.styles_attrs["chai-richtext"], [s];
|
|
276
274
|
if (h) {
|
|
277
275
|
const c = [
|
|
278
276
|
"data-chai-lightbox",
|
|
@@ -292,7 +290,7 @@ const Bt = (e) => {
|
|
|
292
290
|
maxWidth: ((F = (z = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : z.value) == null ? void 0 : F.replace("px", "")) || "",
|
|
293
291
|
backdropColor: ((U = n.find((p) => p.key === "data-overlay")) == null ? void 0 : U.value) || "",
|
|
294
292
|
galleryName: ((Y = n.find((p) => p.key === "data-gall")) == null ? void 0 : Y.value) || ""
|
|
295
|
-
},
|
|
293
|
+
}, N(c, (p) => {
|
|
296
294
|
A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
|
|
297
295
|
});
|
|
298
296
|
}
|
|
@@ -374,7 +372,7 @@ function Jt(e, a, t) {
|
|
|
374
372
|
const s = d(t, "i18nProps", []);
|
|
375
373
|
if (x(a) || x(s)) return e;
|
|
376
374
|
const n = M(e);
|
|
377
|
-
return
|
|
375
|
+
return N(W(n), (o) => {
|
|
378
376
|
if (w(s, o) && !x(a)) {
|
|
379
377
|
const l = d(n, o), i = d(n, `${o}-${a}`, "");
|
|
380
378
|
$(l) ? n[o] = $(i) && !x(i.trim()) && i.trimStart() || l : n[o] = x(i) ? l : i;
|
|
@@ -417,7 +415,7 @@ const Ft = xt((e) => {
|
|
|
417
415
|
return typeof a.limit == "number" && a.limit > 0 && (s = a.limit), s !== void 0 && (t = t.slice(0, s)), t;
|
|
418
416
|
}, Yt = (e, a) => {
|
|
419
417
|
const t = M(e);
|
|
420
|
-
return
|
|
418
|
+
return N(W(t), (s) => {
|
|
421
419
|
if ($(t[s]) && !k(s, "_")) {
|
|
422
420
|
let n = t[s];
|
|
423
421
|
s === "repeaterItems" && (t.repeaterItemsBinding = n);
|
|
@@ -639,7 +637,7 @@ const b = (e, a, { index: t, key: s }, n) => {
|
|
|
639
637
|
return e.map((o) => b(o, a, { index: t, key: s }, n));
|
|
640
638
|
if (e && typeof e == "object") {
|
|
641
639
|
const o = {};
|
|
642
|
-
return
|
|
640
|
+
return N(W(e), (l) => {
|
|
643
641
|
!k(l, "_") && l !== "$repeaterItemsKey" ? o[l] = b(e[l], a, { index: t, key: s }, l) : o[l] = e[l];
|
|
644
642
|
}), o;
|
|
645
643
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const T=require("./common-functions-B3a4xKt_.cjs"),t=require("lodash-es"),k=require("himalaya"),z=require("@chaibuilder/runtime"),U=require("tailwind-merge"),m="#styles:",Y="__ADD_BLOCK_INTERNAL_ROOT",K="@",V="#",v="dt#",H=e=>{if(e=e.replace(m,""),!e)return{baseClasses:"",classes:""};const l=e.split(/,(?![^\[]*\])/);if(l.length===1)return{baseClasses:"",classes:l[0].trim()};const[s,...n]=l;return{baseClasses:s.trim(),classes:n.join(",").trim().replace(/ +(?= )/g,"")}},X=e=>{const l=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,s=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return l.test(e)||s.test(e)},G=e=>{if(t.isEmpty(e))return e;const l=/<video[^>]+src=['"]([^'">]+)['"]/,s=/<iframe[^>]+src=['"]([^'">]+)['"]/,n=e.match(l),a=e.match(s),i=n?n[1]:a?a[1]:null,o=/(?: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 i&&(o.test(i)||r.test(i))?i:e},M=["chai-name","data-chai-name"],Z={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,l)=>e.children.length===1&&t.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],l._type),E=e=>e.map(l=>l.type==="text"?t.get(l,"content",""):t.isEmpty(l.children)?"":E(l.children)).join(""),B=e=>e===null?"":e,O=e=>{const l=t.compact(t.map(e.split(/\s+/),t.trim)),s=t.find(l,r=>/^w-/.test(r)),n=t.find(l,r=>/^h-/.test(r));if(!n||!s)return{height:"",width:""};const a=r=>{if(!r)return;const y=r.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);if(!y)return;if(y[1])return y[1];const c=y[2];return/^\d+(\.\d+)?$/.test(c)?`${Number(c)*4}px`:c==="auto"||t.includes(c,"%")?c:"16px"},i=a(s),o=a(n);return{width:t.includes(i,"px")?i:"16px",height:t.includes(o,"px")?o:"16px"}},q=e=>{if(e.tagName==="svg")return{};const l={},s=Z[e.tagName]||{},n=e.attributes;return t.forEach(n,({key:a,value:i})=>{if(!t.includes(M,a))if(a==="bid"&&(l._bid=B(i)),s[a]){if(e.tagName==="img"&&a==="src"&&!i.startsWith("http")){const o=t.find(e.attributes,{key:"width"}),r=t.find(e.attributes,{key:"height"});o&&r?i=`https://picsum.photos/${o==null?void 0:o.value}x${r==null?void 0:r.value}`:i="https://picsum.photos/150x150"}t.set(l,s[a],B(i))}else t.includes(["style","class","srcset","bid"],a)||(t.has(l,"styles_attrs")||(l.styles_attrs={}),t.startsWith(a,"@")&&(a=a.replace("@","x-on:")),l.styles_attrs[`${a}`]=B(i))}),delete l.class,l},tt=(e,l="styles")=>{if(!e.attributes)return{[l]:`${m},`};const s=t.find(e.attributes,{key:"class"});if(s){const n=s.value;return{[l]:`${m},${n}`}}return{[l]:`${m},`}},et=e=>{const l=t.get(e,"attributes",[]),s=l.find(c=>c.key==="data-chai-richtext"||c.key==="chai-richtext"),n=l.find(c=>c.key==="data-chai-lightbox"||c.key==="chai-lightbox"),a=l.find(c=>c.key==="data-chai-dropdown"||c.key==="chai-dropdown"),i=l.find(c=>c.key==="data-chai-dropdown-button"||c.key==="chai-dropdown-button"),o=l.find(c=>c.key==="data-chai-dropdown-content"||c.key==="chai-dropdown-content"),r=l.find(c=>c.key==="class"),y=r&&r.value.split(/\s+/).includes("rte");if(a)return{_type:"Dropdown"};if(i)return{_type:"DropdownButton"};if(o)return{_type:"DropdownContent"};if(s||y)return{_type:"Paragraph"};if(n)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 c=t.get(e,"children",[]).length>0?"Box":"EmptyBox";return{_type:c,tag:e.tagName,_name:c=="EmptyBox"||e.tagName==="div"?c:t.capitalize(e.tagName)}}}},w=(e,l=null)=>t.flatMapDeep(e,s=>{var D,I,C,$,N,L,W,A,P,R;if(s.type==="comment")return[];let n={_id:T.generateUUID()};if(l&&(n._parent=l.block._id),s.type==="text")return t.isEmpty(t.get(s,"content",""))?[]:l&&Q(l.node,l.block)?(t.set(l,"block.content",t.get(s,"content","")),[]):{...n,_type:"Text",content:t.get(s,"content","")};if(t.startsWith(s.tagName,"chai-")){const p=s.attributes,u=t.find(p,{key:"chai-type"}),d=(u==null?void 0:u.value)||t.startCase(s.tagName.replace("chai-","")).replace(/\s+/g,"");n._type=d,t.forEach(p,({key:h,value:j})=>{if(h==="about-this-component"||h==="chai-type"||h==="can-move"||h==="can-delete")return;if(h==="id"){n._id=j;return}const J=t.startsWith(h,"_")?h:t.camelCase(h);let f=B(j);typeof f=="string"&&t.startsWith(f,"#styles:")&&(f=f.replace("#styles:","#styles:,")),n[J]=f});const g=w(s.children,{block:n,node:s});return[n,...g]}const a=t.get(s,"attributes",[]),i=s.tagName==="p"||a.find(p=>p.key==="data-chai-richtext"||p.key==="chai-richtext"),o=a.find(p=>p.key==="class"),r=o&&o.value.split(/\s+/).includes("rte"),y=a.find(p=>p.key==="data-chai-lightbox"||p.key==="chai-lightbox"),c=a.find(p=>p.key==="data-chai-dropdown"||p.key==="chai-dropdown"),b=a.find(p=>p.key==="data-chai-dropdown-button"||p.key==="chai-dropdown-button"),_=a.find(p=>p.key==="data-chai-dropdown-content"||p.key==="chai-dropdown-content");if(n={...n,...et(s),...q(s),...tt(s)},s.attributes){const p=s.attributes.find(u=>t.includes(M,u.key));p&&(n._name=p.value)}if(i||r)return n.content=`<p>${k.stringify(s.children||[])}</p>`,t.has(n,"styles_attrs.data-chai-richtext")&&delete n.styles_attrs["data-chai-richtext"],t.has(n,"styles_attrs.chai-richtext")&&delete n.styles_attrs["chai-richtext"],[n];if(y){const p=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];n={...n,href:((D=a.find(u=>u.key==="href"))==null?void 0:D.value)||"",hrefType:((I=a.find(u=>u.key==="data-vbtype"))==null?void 0:I.value)||"video",autoplay:((C=a.find(u=>u.key==="data-autoplay"))==null?void 0:C.value)==="true"?"true":"false",maxWidth:((N=($=a.find(u=>u.key==="data-maxwidth"))==null?void 0:$.value)==null?void 0:N.replace("px",""))||"",backdropColor:((L=a.find(u=>u.key==="data-overlay"))==null?void 0:L.value)||"",galleryName:((W=a.find(u=>u.key==="data-gall"))==null?void 0:W.value)||""},t.forEach(p,u=>{t.has(n,`styles_attrs.${u}`)&&delete n.styles_attrs[u]})}if(c&&(delete n.styles_attrs,n.showDropdown=!1),_&&delete n.styles_attrs,b){delete n.styles_attrs;const p=t.filter(s.children||[],d=>(d==null?void 0:d.tagName)!=="span");n.content=E(p);const u=t.find(s.children||[],d=>(d==null?void 0:d.tagName)==="span"&&t.some(d.children||[],g=>(g==null?void 0:g.tagName)==="svg"));if(u){const d=t.find(u.children||[],g=>(g==null?void 0:g.tagName)==="svg");if(d){n.icon=k.stringify([d]);const{height:g,width:h}=st(d,"16px","16px");n.iconHeight=g,n.iconWidth=h}}return[n]}if(n._type==="Input"){const p=n.inputType||"text";p==="checkbox"?t.set(n,"_type","Checkbox"):p==="radio"&&t.set(n,"_type","Radio")}else if(s.tagName==="video"||s.tagName==="iframe"){const p=k.stringify([s]);return X(p)&&(t.set(n,"_type","Video"),t.set(n,"url",G(p)),t.set(n,"styles",`${m},`),t.set(n,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),n.content=p,[n]}else if(s.tagName==="svg"){const p=t.get(t.find(s.attributes,{key:"class"}),"value",""),{height:u,width:d}=O(p);if(u&&d)n.styles=`${m}, ${T.cn(`w-${d} h-${u}`,p)}`.trim(),n.height=u==null?void 0:u.replace("px",""),n.width=d==null?void 0:d.replace("px","");else{const g=(A=t.find(s.attributes,{key:"height"}))==null?void 0:A.value,h=(P=t.find(s.attributes,{key:"width"}))==null?void 0:P.value;g&&h?(n.styles=`${m}, ${T.cn(`w-[${h}px] h-[${g}px]`,p)}`.trim(),n.height=g,n.width=h):n.styles=`${m}, ${T.cn("w-full h-full",p)}`.trim()}return s.attributes=t.filter(s.attributes,g=>!t.includes(["style","width","height","class"],g.key)),n.icon=k.stringify([s]),[n]}else if(s.tagName=="option"&&l&&((R=l.block)==null?void 0:R._type)==="Select")return l.block.options.push({label:E(s.children),...q(s)}),[];const x=w(s.children,{block:n,node:s});return[n,...x]}),st=(e,l,s)=>{var y,c;const n=t.get(e,"attributes",[]),{height:a,width:i}=O(t.get(t.find(n,{key:"class"}),"value",""));if(a&&i)return{height:`[${a}px]`,width:`[${i}px]`};const o=(y=t.find(n,{key:"height"}))==null?void 0:y.value,r=(c=t.find(n,{key:"width"}))==null?void 0:c.value;return{height:o?`[${o}px]`:s,width:r?`[${r}px]`:l}},nt=e=>{e=e.replace(/(\w+)=\\?"(.*?)\\?"/g,(n,a,i)=>{let o=i.replace(/\\"/g,'"');return o=o.replace(/{([^}]+)}/g,r=>r.replace(/"/g,'\\"')),`${a}="${o.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 l=e.match(/<body[^>]*>[\s\S]*?<\/body>/);return(l&&l.length>0?l[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):e).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},at=(e,l)=>t.find(e,{_id:l}),lt=(e,l)=>t.isEmpty(l)?e.map(s=>(t.unset(s,"_bid"),s)):t.map(e,s=>{const n=t.isEmpty(s._bid)?void 0:at(l,s._bid);if(n){n._type==="Icon"&&t.get(s,"icon","").match(/chai-default-svg/)&&delete s.icon;const a={...n,...s};return t.unset(a,"_bid"),a}return t.unset(s,"_bid"),s}),ot=e=>{const l=k.parse(nt(e));return t.isEmpty(e)?[]:t.flatten(w(l))};function rt(e,l,s){const n=t.get(s,"i18nProps",[]);if(t.isEmpty(l)||t.isEmpty(n))return e;const a=t.cloneDeep(e);return t.forEach(t.keys(a),i=>{if(t.includes(n,i)&&!t.isEmpty(l)){const o=t.get(a,i),r=t.get(a,`${i}-${l}`,"");t.isString(o)?a[i]=t.isString(r)&&!t.isEmpty(r.trim())&&r.trimStart()||o:a[i]=t.isEmpty(r)?o:r}}),a}const F=(e,l)=>{const{baseClasses:s,classes:n}=H(e),i=n.split(" ").filter(r=>r.startsWith(v)).map(r=>{var y;return(y=l[r])==null?void 0:y.value}),o=n.split(" ").filter(r=>!r.startsWith(v)).join(" ");return U.twMerge.apply(null,[s,...i,o])};function ct(e,l){return t.get(e,`${l}_attrs`,{})}function pt(e,l=!0,s={}){const n={};return Object.keys(e).forEach(a=>{if(t.isString(e[a])&&e[a].startsWith(m)){const i=F(e[a],s),o=ct(e,a);n[a]={...!t.isEmpty(i)&&{className:i},...o,...l?{"data-style-prop":a,"data-block-parent":e._id,"data-style-id":`${a}-${e._id}`}:{}}}}),n}const ut=t.memoize(e=>{const l=z.getRegisteredChaiBlock(e),s=t.get(l,"schema.properties",{});return Object.fromEntries(Object.entries(s).filter(([,n])=>t.get(n,"runtime",!1)))}),dt=(e,l)=>{if(!t.isArray(e))return e;let s=e,n;return typeof l.limit=="number"&&l.limit>0&&(n=l.limit),n!==void 0&&(s=s.slice(0,n)),s},yt=(e,l)=>{const s=t.cloneDeep(e);return t.forEach(t.keys(s),n=>{if(t.isString(s[n])&&!t.startsWith(n,"_")){let a=s[n];n==="repeaterItems"&&(s.repeaterItemsBinding=a);const i=/\{\{(.*?)\}\}/g,o=a.match(i);o&&o.forEach(r=>{let y=r.slice(2,-2);const c=t.get(l,y,r);a=t.isArray(c)?c:a.replace(r,c)}),s[n]=a}}),s},gt=(e,l)=>e.map(s=>{const n=t.keys(s).filter(a=>t.isString(s[a])&&s[a].startsWith(m));return t.each(n,a=>{s[a]=`${m},${F(s[a],l)}`}),s}),ht=e=>{const l=t.last(e);return e.map(s=>{const n=Object.keys(s);for(let a=0;a<n.length;a++)if(t.isString(s[n[a]])&&t.startsWith(n[a],"content")){const i=s===l?"":" ";s[n[a]]=`${s[n[a]].trim()}${i}`}return s})},S=(e,l,{index:s,key:n},a)=>{if(t.isString(e)){let i=e;const o=/\{\{(.*?)\}\}/g,r=e.match(o);if(r){const y=a==="image"||a==="mobileImage";r.forEach(c=>{let b=c.slice(2,-2).trim(),_=n.slice(2,-2).trim();s!==-1&&t.startsWith(b,"$index.")?b=`${_}.${s}.${b.slice(7)}`:s!==-1&&t.startsWith(b,"$index")&&(b=`${_}.${s}`);const x=t.get(l,b);x===void 0?i=i.replace(c,""):y&&!t.isArray(x)?i=x:i=t.isArray(x)?x:i.replace(c,x)})}return i}if(t.isArray(e))return e.map(i=>S(i,l,{index:s,key:n},a));if(e&&typeof e=="object"){const i={};return t.forEach(t.keys(e),o=>{!t.startsWith(o,"_")&&o!=="$repeaterItemsKey"?i[o]=S(e[o],l,{index:s,key:n},o):i[o]=e[o]}),i}return e},mt=(e,l,{index:s,key:n})=>{let a=t.cloneDeep(e);return a.repeaterItems&&(a.$repeaterItemsKey=a.repeaterItems,t.startsWith(a.repeaterItems,`{{${V}`)&&(a.$repeaterItemsKey=a.repeaterItems=`${a.repeaterItems.replace("}}",`/${a._id}}}`)}`),!t.isEmpty(a.repeaterItems)&&a.pagination&&(a.repeaterTotalItems=`${a.repeaterItems.replace("}}",`/${a._id}/totalItems}}`)}`)),S(a,l,{index:s,key:n})};exports.COLLECTION_PREFIX=V;exports.DESIGN_TOKEN_PREFIX=v;exports.REPEATER_PREFIX=K;exports.ROOT_TEMP_KEY=Y;exports.STYLES_KEY=m;exports.adjustSpacingInContentBlocks=ht;exports.applyBindingToBlockProps=mt;exports.applyChaiDataBinding=yt;exports.applyDesignTokens=gt;exports.applyLanguage=rt;exports.applyLimit=dt;exports.getBlockRuntimeProps=ut;exports.getBlockTagAttributes=pt;exports.getBlocksFromHTML=ot;exports.getSplitChaiClasses=H;exports.mergeBlocksWithExisting=lt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-IErL-ZZD.cjs");require("clsx");require("lodash-es");require("nanoid");require("tailwind-merge");require("tree-model");const c=require("react");require("jotai");require("@chaibuilder/runtime");require("sonner");const q=require("react-i18next"),r=require("./tooltip-Ba1-8jmj.cjs"),g=require("@react-hookz/web"),m=n=>{const s=document.createElement("div");return s.innerHTML=n,s.innerHTML};function j(){const{t:n}=q.useTranslation(),[s,h]=c.useState(!1),[a,p]=c.useState(""),[t,d]=i.useCodeEditor(),[u]=i.useSelectedBlockIds(),b=i.useUpdateBlocksProps(),f=i.useUpdateBlocksPropsRealtime(),C=g.useThrottledCallback(o=>{const l=m(o);f([t.blockId],{[t.blockProp]:l})},[],300),x=c.useCallback(()=>{if(s){const o=m(a);b([t.blockId],{[t.blockProp]:o})}},[s,a]);c.useEffect(()=>{u.includes(t==null?void 0:t.blockId)||(x(),d(null))},[u]);const k=()=>{x(),d(null)};return e.jsx(r.Dialog,{open:!0,onOpenChange:k,children:e.jsxs(r.DialogContent,{className:"flex max-h-[400px] min-h-[200px] max-w-4xl flex-col border-gray-700 text-black",children:[e.jsx(r.DialogHeader,{className:"shrink-0 border-b border-gray-700 pb-3",children:e.jsx(r.DialogTitle,{className:"flex items-center justify-between text-black",children:e.jsxs("div",{className:"space-x-3 text-sm font-semibold",children:[e.jsx("span",{children:n("HTML Code Editor |")}),e.jsx("span",{className:"text-xs text-gray-400",children:n("Scripts will be only executed in preview and live mode.")})]})})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(r.Textarea,{className:"h-full w-full resize-none font-mono text-xs",value:a||t.initialCode,onChange:o=>{const l=o.target.value;h(!0),p(l),C(l)},rows:10,placeholder:"Enter your code here..."})})]})})}exports.default=j;
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-IErL-ZZD.cjs"),s=require("./common-functions-B3a4xKt_.cjs"),a=require("./apply-binding-DOJpwjiG.cjs"),l=require("react-i18next"),i=require("i18next");exports.ChaiAddBlocksDialog=e.AddBlocksDialog;exports.ChaiAddBlocksPanel=e.AddBlocksPanel;exports.ChaiAskAiUserPrompt=e.AIUserPrompt;exports.ChaiBlockAttributesEditor=e.BlockAttributesEditor;exports.ChaiBlockPropsEditor=e.BlockSettings;exports.ChaiBlockStyleEditor=e.BlockStyling;exports.ChaiBuilderCanvas=e.CanvasArea;exports.ChaiBuilderEditor=e.ChaiBuilderEditor;exports.ChaiDarkModeSwitcher=e.DarkMode;exports.ChaiDefaultBlocks=e.DefaultChaiBlocks;exports.ChaiDraggableBlock=e.ChaiDraggableBlock;exports.ChaiExportCodeModal=e.ExportCodeModal;exports.ChaiImportHTML=e.ImportHTML;exports.ChaiOutline=e.ListTree;exports.ChaiScreenSizes=e.Breakpoints;exports.ChaiThemeConfigPanel=e.ThemeConfigPanel;exports.ChaiUILibrariesPanel=e.UILibrariesPanel;exports.ChaiUndoRedo=e.UndoRedo;exports.IfChaiFeatureFlag=e.IfChaiFeatureFlag;exports.PERMISSIONS=e.PERMISSIONS;exports.getClassValueAndUnit=e.getClassValueAndUnit;exports.registerBlockSettingField=e.registerBlockSettingField;exports.registerBlockSettingTemplate=e.registerBlockSettingTemplate;exports.registerBlockSettingWidget=e.registerBlockSettingWidget;exports.registerChaiAddBlockTab=e.registerChaiAddBlockTab;exports.registerChaiFeatureFlag=e.registerChaiFeatureFlag;exports.registerChaiFeatureFlags=e.registerChaiFeatureFlags;exports.registerChaiLibrary=e.registerChaiLibrary;exports.registerChaiMediaManager=e.registerChaiMediaManager;exports.registerChaiPreImportHTMLHook=e.registerChaiPreImportHTMLHook;exports.registerChaiSaveToLibrary=e.registerChaiSaveToLibrary;exports.registerChaiSidebarPanel=e.registerChaiSidebarPanel;exports.registerChaiTopBar=e.registerChaiTopBar;exports.useAddBlock=e.useAddBlock;exports.useAddClassesToBlocks=e.useAddClassesToBlocks;exports.useAskAi=e.useAskAi;exports.useBlockHighlight=e.useBlockHighlight;exports.useBlocksHtmlForAi=e.useBlocksHtmlForAi;exports.useBlocksStore=e.useBlocksStore;exports.useBlocksStoreUndoableActions=e.useBlocksStoreUndoableActions;exports.useBrandingOptions=e.useBrandingOptions;exports.useBuilderProp=e.useBuilderProp;exports.useBuilderReset=e.useBuilderReset;exports.useCanvasDisplayWidth=e.useCanvasDisplayWidth;exports.useCanvasWidth=e.useCanvasWidth;exports.useCanvasZoom=e.useCanvasZoom;exports.useChaiFeatureFlag=e.useChaiFeatureFlag;exports.useChaiFeatureFlags=e.useChaiFeatureFlags;exports.useCodeEditor=e.useCodeEditor;exports.useCopyBlockIds=e.useCopyBlocks;exports.useCopyToClipboard=e.useCopyToClipboard;exports.useCurrentPage=e.useCurrentPage;exports.useCutBlockIds=e.useCutBlockIds;exports.useDarkMode=e.useDarkMode;exports.useDuplicateBlocks=e.useDuplicateBlocks;exports.useHighlightBlockId=e.useHighlightBlockId;exports.useHtmlToBlocks=e.useHtmlToBlocks;exports.useI18nBlocks=e.useI18nBlocks;exports.useInlineEditing=e.useInlineEditing;exports.useIsPageLoaded=e.useIsPageLoaded;exports.useLanguages=e.useLanguages;exports.useLibraryBlocks=e.useLibraryBlocks;exports.useMediaManagerComponent=e.useMediaManagerComponent;exports.usePartailBlocksStore=e.usePartialBlocksStore;exports.usePartialBlocksList=e.usePartialBlocksList;exports.usePasteBlocks=e.usePasteBlocks;exports.usePermissions=e.usePermissions;exports.usePreviewMode=e.usePreviewMode;exports.usePubSub=e.usePubSub;exports.useRemoveAllClassesForBlock=e.useRemoveAllClassesForBlock;exports.useRemoveBlocks=e.useRemoveBlocks;exports.useRemoveClassesFromBlocks=e.useRemoveClassesFromBlocks;exports.useReplaceBlock=e.useReplaceBlock;exports.useResetBlockStyles=e.useResetBlockStyles;exports.useRightPanel=e.useRightPanel;exports.useSavePage=e.useSavePage;exports.useScreenSizeWidth=e.useScreenSizeWidth;exports.useSelectedBlock=e.useSelectedBlock;exports.useSelectedBlockAllClasses=e.useSelectedBlockAllClasses;exports.useSelectedBlockCurrentClasses=e.useSelectedBlockCurrentClasses;exports.useSelectedBlockIds=e.useSelectedBlockIds;exports.useSelectedBlocksDisplayChild=e.useSelectedBlocksDisplayChild;exports.useSelectedBreakpoints=e.useSelectedBreakpoints;exports.useSelectedLibrary=e.useSelectedLibrary;exports.useSelectedStylingBlocks=e.useSelectedStylingBlocks;exports.useSidebarActivePanel=e.useSidebarActivePanel;exports.useStreamMultipleBlocksProps=e.useStreamMultipleBlocksProps;exports.useStylingBreakpoint=e.useStylingBreakpoint;exports.useStylingState=e.useStylingState;exports.useTheme=e.useTheme;exports.useThemeOptions=e.useThemeOptions;exports.useToggleChaiFeatureFlag=e.useToggleChaiFeatureFlag;exports.useUndoManager=e.useUndoManager;exports.useUpdateBlocksProps=e.useUpdateBlocksProps;exports.useUpdateBlocksPropsRealtime=e.useUpdateBlocksPropsRealtime;exports.useWrapperBlock=e.useWrapperBlock;exports.generateBlockId=s.generateUUID;exports.mergeClasses=s.cn;exports.convertHTMLToChaiBlocks=a.getBlocksFromHTML;exports.getBlocksFromHTML=a.getBlocksFromHTML;Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:()=>l.useTranslation});exports.i18n=i;
|
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as e, A as o, f as i, k as l, B as r, e as t, C as u, i as c, D as d, l as C, m as B, E as k, I as g, L as n, g as h, T as p, U as S, h as m, z as P, P as F, n as A, o as T, p as b, q as M, r as y, F as I, G as v, t as L, v as f, s as H, w as R, x as D, y as E, O as U, Q as x, R as W, S as O, V as w, W as z, aC as j, X as q, Y as G, Z as V, aE as Z, aD as J, _ as K, H as N, J as Q, u as X, $ as Y, a0 as _, a1 as $, a2 as aa, a3 as sa, a4 as ea, a5 as oa, a6 as ia, a7 as la, a8 as ra, a9 as ta, aa as ua, ab as ca, M as da, ac as Ca, ad as Ba, ae as ka, af as ga, ag as na, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, ao as Ta, aF as ba, ap as Ma, aq as ya, ar as Ia, a as va, as as La, at as fa, aG as Ha, au as Ra, aH as Da, av as Ea, aw as Ua, ax as xa, ay as Wa, az as Oa, K as wa, aA as za, b as ja, c as qa, aB as Ga } from "./index-
|
|
1
|
+
import { j as e, A as o, f as i, k as l, B as r, e as t, C as u, i as c, D as d, l as C, m as B, E as k, I as g, L as n, g as h, T as p, U as S, h as m, z as P, P as F, n as A, o as T, p as b, q as M, r as y, F as I, G as v, t as L, v as f, s as H, w as R, x as D, y as E, O as U, Q as x, R as W, S as O, V as w, W as z, aC as j, X as q, Y as G, Z as V, aE as Z, aD as J, _ as K, H as N, J as Q, u as X, $ as Y, a0 as _, a1 as $, a2 as aa, a3 as sa, a4 as ea, a5 as oa, a6 as ia, a7 as la, a8 as ra, a9 as ta, aa as ua, ab as ca, M as da, ac as Ca, ad as Ba, ae as ka, af as ga, ag as na, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, ao as Ta, aF as ba, ap as Ma, aq as ya, ar as Ia, a as va, as as La, at as fa, aG as Ha, au as Ra, aH as Da, av as Ea, aw as Ua, ax as xa, ay as Wa, az as Oa, K as wa, aA as za, b as ja, c as qa, aB as Ga } from "./index-CPvjpLmN.js";
|
|
2
2
|
import { g as Za, c as Ja } from "./common-functions-D2lMFR6K.js";
|
|
3
|
-
import { h as Na, h as Qa } from "./apply-binding-
|
|
3
|
+
import { h as Na, h as Qa } from "./apply-binding-B11pPFEE.js";
|
|
4
4
|
import { useTranslation as Ya } from "react-i18next";
|
|
5
5
|
import { default as $a } from "i18next";
|
|
6
6
|
export {
|