@chaibuilder/sdk 3.1.25 → 3.1.26
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-DCno1xQL.js → apply-binding-COFSiTeM.js} +18 -19
- package/dist/apply-binding-Dvnd_Vhq.cjs +1 -0
- package/dist/{code-editor-CmXV8E-i.cjs → code-editor-B7JGUrWa.cjs} +1 -1
- package/dist/{code-editor-Dmq2df89.js → code-editor-TDs5CPAW.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +13 -3
- package/dist/core.js +2 -2
- package/dist/index-C4b6LcwL.cjs +154 -0
- package/dist/{index-CU5gEUbc.js → index-DFvi9z_N.js} +1356 -1349
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +3 -3
- package/dist/render.js +97 -98
- package/dist/{rte-widget-modal-BvND5bq_.js → rte-widget-modal-3KfJEwf3.js} +1 -1
- package/dist/{rte-widget-modal-B-TcV_cb.cjs → rte-widget-modal-DX07GFaV.cjs} +1 -1
- package/dist/tailwind.d.ts +2 -2
- package/package.json +2 -1
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/index-Di66eAEA.cjs +0 -154
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { g as ot, c as R } from "./common-functions-BGzDsf1z.js";
|
|
2
|
-
import { isEmpty as f, flatten as ct, flatMapDeep as lt, get as d, set as E, startsWith as _, find as m, startCase as pt, forEach as $, camelCase as ut, includes as v, has as A, filter as G, some as dt, map as tt, compact as ht, trim as gt, capitalize as mt, memoize as et, cloneDeep as M, keys as P, isString as B, isArray as C, last as yt } from "lodash-es";
|
|
2
|
+
import { isEmpty as f, flatten as ct, flatMapDeep as lt, get as d, set as E, startsWith as _, find as m, startCase as pt, forEach as $, camelCase as ut, includes as v, has as A, filter as G, some as dt, unset as H, map as tt, compact as ht, trim as gt, capitalize as mt, memoize as et, cloneDeep as M, keys as P, isString as B, isArray as C, last as yt } from "lodash-es";
|
|
3
3
|
import { parse as bt, stringify as N } from "himalaya";
|
|
4
|
-
import { unset as H } from "lodash";
|
|
5
4
|
import { getRegisteredChaiBlock as ft } from "@chaibuilder/runtime";
|
|
6
5
|
import { twMerge as xt } from "tailwind-merge";
|
|
7
|
-
const x = "#styles:",
|
|
6
|
+
const x = "#styles:", jt = "__ADD_BLOCK_INTERNAL_ROOT", qt = "@", _t = "#", st = (e) => {
|
|
8
7
|
if (e = e.replace(x, ""), !e) return { baseClasses: "", classes: "" };
|
|
9
8
|
const a = e.split(/,(?![^\[]*\])/);
|
|
10
9
|
if (a.length === 1)
|
|
@@ -359,7 +358,7 @@ const kt = (e) => {
|
|
|
359
358
|
}), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
|
|
360
359
|
const a = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
361
360
|
return (a && a.length > 0 ? a[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
362
|
-
}, Ct = (e, a) => m(e, { _id: a }),
|
|
361
|
+
}, Ct = (e, a) => m(e, { _id: a }), Mt = (e, a) => f(a) ? e.map((t) => (H(t, "_bid"), t)) : tt(e, (t) => {
|
|
363
362
|
const s = f(t._bid) ? void 0 : Ct(a, t._bid);
|
|
364
363
|
if (s) {
|
|
365
364
|
s._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
|
|
@@ -367,11 +366,11 @@ const kt = (e) => {
|
|
|
367
366
|
return H(n, "_bid"), n;
|
|
368
367
|
}
|
|
369
368
|
return H(t, "_bid"), t;
|
|
370
|
-
}),
|
|
369
|
+
}), Pt = (e) => {
|
|
371
370
|
const a = bt(It(e));
|
|
372
371
|
return f(e) ? [] : ct(q(a));
|
|
373
372
|
};
|
|
374
|
-
function
|
|
373
|
+
function Jt(e, a, t) {
|
|
375
374
|
const s = d(t, "i18nProps", []);
|
|
376
375
|
if (f(a) || f(s)) return e;
|
|
377
376
|
const n = M(e);
|
|
@@ -389,7 +388,7 @@ const Dt = et((e) => {
|
|
|
389
388
|
function Nt(e, a) {
|
|
390
389
|
return d(e, `${a}_attrs`, {});
|
|
391
390
|
}
|
|
392
|
-
function
|
|
391
|
+
function Ot(e, a = !0) {
|
|
393
392
|
const t = {};
|
|
394
393
|
return Object.keys(e).forEach((s) => {
|
|
395
394
|
if (B(e[s]) && e[s].startsWith(x)) {
|
|
@@ -406,14 +405,14 @@ function zt(e, a = !0) {
|
|
|
406
405
|
}
|
|
407
406
|
}), t;
|
|
408
407
|
}
|
|
409
|
-
const
|
|
408
|
+
const zt = et((e) => {
|
|
410
409
|
const a = ft(e), t = d(a, "schema.properties", {});
|
|
411
410
|
return Object.fromEntries(Object.entries(t).filter(([, s]) => d(s, "runtime", !1)));
|
|
412
|
-
}),
|
|
411
|
+
}), Vt = (e, a) => {
|
|
413
412
|
if (!C(e)) return e;
|
|
414
413
|
let t = e, s;
|
|
415
414
|
return typeof a.limit == "number" && a.limit > 0 && (s = a.limit), s !== void 0 && (t = t.slice(0, s)), t;
|
|
416
|
-
},
|
|
415
|
+
}, Wt = (e, a) => {
|
|
417
416
|
const t = M(e);
|
|
418
417
|
return $(P(t), (s) => {
|
|
419
418
|
if (B(t[s]) && !_(s, "_")) {
|
|
@@ -695,17 +694,17 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
695
694
|
}));
|
|
696
695
|
export {
|
|
697
696
|
_t as C,
|
|
698
|
-
|
|
697
|
+
qt as R,
|
|
699
698
|
x as S,
|
|
700
699
|
L as a,
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
700
|
+
Jt as b,
|
|
701
|
+
zt as c,
|
|
702
|
+
Vt as d,
|
|
704
703
|
k as e,
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
704
|
+
Wt as f,
|
|
705
|
+
Ot as g,
|
|
706
|
+
Pt as h,
|
|
708
707
|
st as i,
|
|
709
|
-
|
|
710
|
-
|
|
708
|
+
jt as j,
|
|
709
|
+
Mt as m
|
|
711
710
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const T=require("./common-functions-BZmyleS1.cjs"),t=require("lodash-es"),_=require("himalaya"),F=require("@chaibuilder/runtime"),J=require("tailwind-merge"),m="#styles:",z="__ADD_BLOCK_INTERNAL_ROOT",Y="@",H="#",V=s=>{if(s=s.replace(m,""),!s)return{baseClasses:"",classes:""};const n=s.split(/,(?![^\[]*\])/);if(n.length===1)return{baseClasses:"",classes:n[0].trim()};const[a,...e]=n;return{baseClasses:a.trim(),classes:e.join(",").trim().replace(/ +(?= )/g,"")}},K=s=>{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(s)||a.test(s)},U=s=>{if(t.isEmpty(s))return s;const n=/<video[^>]+src=['"]([^'">]+)['"]/,a=/<iframe[^>]+src=['"]([^'">]+)['"]/,e=s.match(n),i=s.match(a),r=e?e[1]:i?i[1]:null,l=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,p=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return r&&(l.test(r)||p.test(r))?r:s},M=["chai-name","data-chai-name"],X={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"}},Z=(s,n)=>s.children.length===1&&t.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],n._type),E=s=>s.map(n=>n.type==="text"?t.get(n,"content",""):t.isEmpty(n.children)?"":E(n.children)).join(""),B=s=>s===null?"":s,W=s=>{const n=t.compact(t.map(s.split(/\s+/),t.trim)),a=t.find(n,p=>/^w-/.test(p)),e=t.find(n,p=>/^h-/.test(p));if(!e||!a)return{height:"",width:""};const i=p=>{if(!p)return;const h=p.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);if(!h)return;if(h[1])return h[1];const o=h[2];return/^\d+(\.\d+)?$/.test(o)?`${Number(o)*4}px`:o==="auto"||t.includes(o,"%")?o:"16px"},r=i(a),l=i(e);return{width:t.includes(r,"px")?r:"16px",height:t.includes(l,"px")?l:"16px"}},q=s=>{if(s.tagName==="svg")return{};const n={},a=X[s.tagName]||{},e=s.attributes;return t.forEach(e,({key:i,value:r})=>{if(!t.includes(M,i))if(i==="bid"&&(n._bid=B(r)),a[i]){if(s.tagName==="img"&&i==="src"&&!r.startsWith("http")){const l=t.find(s.attributes,{key:"width"}),p=t.find(s.attributes,{key:"height"});l&&p?r=`https://picsum.photos/${l==null?void 0:l.value}x${p==null?void 0:p.value}`:r="https://picsum.photos/150x150"}t.set(n,a[i],B(r))}else t.includes(["style","class","srcset","bid"],i)||(t.has(n,"styles_attrs")||(n.styles_attrs={}),t.startsWith(i,"@")&&(i=i.replace("@","x-on:")),n.styles_attrs[`${i}`]=B(r))}),delete n.class,n},G=(s,n="styles")=>{if(!s.attributes)return{[n]:`${m},`};const a=t.find(s.attributes,{key:"class"});if(a){const e=a.value;return{[n]:`${m},${e}`}}return{[n]:`${m},`}},Q=s=>{const n=t.get(s,"attributes",[]),a=n.find(o=>o.key==="data-chai-richtext"||o.key==="chai-richtext"),e=n.find(o=>o.key==="data-chai-lightbox"||o.key==="chai-lightbox"),i=n.find(o=>o.key==="data-chai-dropdown"||o.key==="chai-dropdown"),r=n.find(o=>o.key==="data-chai-dropdown-button"||o.key==="chai-dropdown-button"),l=n.find(o=>o.key==="data-chai-dropdown-content"||o.key==="chai-dropdown-content"),p=n.find(o=>o.key==="class"),h=p&&p.value.split(/\s+/).includes("rte");if(i)return{_type:"Dropdown"};if(r)return{_type:"DropdownButton"};if(l)return{_type:"DropdownContent"};if(a||h)return{_type:"Paragraph"};if(e)return{_type:"LightBoxLink"};switch(s.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:s.tagName,_listType:s.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:s.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:s.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:s.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:s.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const o=t.get(s,"children",[]).length>0?"Box":"EmptyBox";return{_type:o,tag:s.tagName,_name:o=="EmptyBox"||s.tagName==="div"?o:t.capitalize(s.tagName)}}}},v=(s,n=null)=>t.flatMapDeep(s,a=>{var I,$,C,S,D,N,L,A,R,j;if(a.type==="comment")return[];let e={_id:T.generateUUID()};if(n&&(e._parent=n.block._id),a.type==="text")return t.isEmpty(t.get(a,"content",""))?[]:n&&Z(n.node,n.block)?(t.set(n,"block.content",t.get(a,"content","")),[]):{...e,_type:"Text",content:t.get(a,"content","")};if(t.startsWith(a.tagName,"chai-")){const c=a.attributes,u=t.find(c,{key:"chai-type"}),d=(u==null?void 0:u.value)||t.startCase(a.tagName.replace("chai-","")).replace(/\s+/g,"");e._type=d,t.forEach(c,({key:y,value:P})=>{if(y==="about-this-component"||y==="chai-type"||y==="can-move"||y==="can-delete")return;if(y==="id"){e._id=P;return}const O=t.startsWith(y,"_")?y:t.camelCase(y);let x=B(P);typeof x=="string"&&t.startsWith(x,"#styles:")&&(x=x.replace("#styles:","#styles:,")),e[O]=x});const g=v(a.children,{block:e,node:a});return[e,...g]}const i=t.get(a,"attributes",[]),r=i.find(c=>c.key==="data-chai-richtext"||c.key==="chai-richtext"),l=i.find(c=>c.key==="class"),p=l&&l.value.split(/\s+/).includes("rte"),h=i.find(c=>c.key==="data-chai-lightbox"||c.key==="chai-lightbox"),o=i.find(c=>c.key==="data-chai-dropdown"||c.key==="chai-dropdown"),f=i.find(c=>c.key==="data-chai-dropdown-button"||c.key==="chai-dropdown-button"),k=i.find(c=>c.key==="data-chai-dropdown-content"||c.key==="chai-dropdown-content");if(e={...e,...Q(a),...q(a),...G(a)},a.attributes){const c=a.attributes.find(u=>t.includes(M,u.key));c&&(e._name=c.value)}if(r||p)return e.content=_.stringify(a.children),t.has(e,"styles_attrs.data-chai-richtext")&&delete e.styles_attrs["data-chai-richtext"],t.has(e,"styles_attrs.chai-richtext")&&delete e.styles_attrs["chai-richtext"],[e];if(h){const c=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];e={...e,href:((I=i.find(u=>u.key==="href"))==null?void 0:I.value)||"",hrefType:(($=i.find(u=>u.key==="data-vbtype"))==null?void 0:$.value)||"video",autoplay:((C=i.find(u=>u.key==="data-autoplay"))==null?void 0:C.value)==="true"?"true":"false",maxWidth:((D=(S=i.find(u=>u.key==="data-maxwidth"))==null?void 0:S.value)==null?void 0:D.replace("px",""))||"",backdropColor:((N=i.find(u=>u.key==="data-overlay"))==null?void 0:N.value)||"",galleryName:((L=i.find(u=>u.key==="data-gall"))==null?void 0:L.value)||""},t.forEach(c,u=>{t.has(e,`styles_attrs.${u}`)&&delete e.styles_attrs[u]})}if(o&&(delete e.styles_attrs,e.showDropdown=!1),k&&delete e.styles_attrs,f){delete e.styles_attrs;const c=t.filter(a.children||[],d=>(d==null?void 0:d.tagName)!=="span");e.content=E(c);const u=t.find(a.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){e.icon=_.stringify([d]);const{height:g,width:y}=tt(d,"16px","16px");e.iconHeight=g,e.iconWidth=y}}return[e]}if(e._type==="Input"){const c=e.inputType||"text";c==="checkbox"?t.set(e,"_type","Checkbox"):c==="radio"&&t.set(e,"_type","Radio")}else if(a.tagName==="video"||a.tagName==="iframe"){const c=_.stringify([a]);return K(c)&&(t.set(e,"_type","Video"),t.set(e,"url",U(c)),t.set(e,"styles",`${m},`),t.set(e,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),e.content=c,[e]}else if(a.tagName==="svg"){const c=t.get(t.find(a.attributes,{key:"class"}),"value",""),{height:u,width:d}=W(c);if(u&&d)e.styles=`${m}, ${T.cn(`w-${d} h-${u}`,c)}`.trim(),e.height=u==null?void 0:u.replace("px",""),e.width=d==null?void 0:d.replace("px","");else{const g=(A=t.find(a.attributes,{key:"height"}))==null?void 0:A.value,y=(R=t.find(a.attributes,{key:"width"}))==null?void 0:R.value;g&&y?(e.styles=`${m}, ${T.cn(`w-[${y}px] h-[${g}px]`,c)}`.trim(),e.height=g,e.width=y):e.styles=`${m}, ${T.cn("w-full h-full",c)}`.trim()}return a.attributes=t.filter(a.attributes,g=>!t.includes(["style","width","height","class"],g.key)),e.icon=_.stringify([a]),[e]}else if(a.tagName=="option"&&n&&((j=n.block)==null?void 0:j._type)==="Select")return n.block.options.push({label:E(a.children),...q(a)}),[];const b=v(a.children,{block:e,node:a});return[e,...b]}),tt=(s,n,a)=>{var h,o;const e=t.get(s,"attributes",[]),{height:i,width:r}=W(t.get(t.find(e,{key:"class"}),"value",""));if(i&&r)return{height:`[${i}px]`,width:`[${r}px]`};const l=(h=t.find(e,{key:"height"}))==null?void 0:h.value,p=(o=t.find(e,{key:"width"}))==null?void 0:o.value;return{height:l?`[${l}px]`:a,width:p?`[${p}px]`:n}},et=s=>{s=s.replace(/(\w+)=\\?"(.*?)\\?"/g,(e,i,r)=>{let l=r.replace(/\\"/g,'"');return l=l.replace(/{([^}]+)}/g,p=>p.replace(/"/g,'\\"')),`${i}="${l.replace(/\\"/g,'"')}"`}),s=s.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),s=s.replace(/\$name="[^"]*"/g,"");const n=s.match(/<body[^>]*>[\s\S]*?<\/body>/);return(n&&n.length>0?n[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):s).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},st=(s,n)=>t.find(s,{_id:n}),at=(s,n)=>t.isEmpty(n)?s.map(a=>(t.unset(a,"_bid"),a)):t.map(s,a=>{const e=t.isEmpty(a._bid)?void 0:st(n,a._bid);if(e){e._type==="Icon"&&t.get(a,"icon","").match(/chai-default-svg/)&&delete a.icon;const i={...e,...a};return t.unset(i,"_bid"),i}return t.unset(a,"_bid"),a}),nt=s=>{const n=_.parse(et(s));return t.isEmpty(s)?[]:t.flatten(v(n))};function rt(s,n,a){const e=t.get(a,"i18nProps",[]);if(t.isEmpty(n)||t.isEmpty(e))return s;const i=t.cloneDeep(s);return t.forEach(t.keys(i),r=>{if(t.includes(e,r)&&!t.isEmpty(n)){const l=t.get(i,r),p=t.get(i,`${r}-${n}`,"");t.isString(l)?i[r]=t.isString(p)&&!t.isEmpty(p.trim())&&p.trimStart()||l:i[r]=t.isEmpty(p)?l:p}}),i}const ot=t.memoize(s=>{const{baseClasses:n,classes:a}=V(s);return J.twMerge(n,a)});function lt(s,n){return t.get(s,`${n}_attrs`,{})}function ct(s,n=!0){const a={};return Object.keys(s).forEach(e=>{if(t.isString(s[e])&&s[e].startsWith(m)){const i=ot(s[e]),r=lt(s,e);a[e]={...!t.isEmpty(i)&&{className:i},...r,...n?{"data-style-prop":e,"data-block-parent":s._id,"data-style-id":`${e}-${s._id}`}:{}}}}),a}const pt=t.memoize(s=>{const n=F.getRegisteredChaiBlock(s),a=t.get(n,"schema.properties",{});return Object.fromEntries(Object.entries(a).filter(([,e])=>t.get(e,"runtime",!1)))}),ut=(s,n)=>{if(!t.isArray(s))return s;let a=s,e;return typeof n.limit=="number"&&n.limit>0&&(e=n.limit),e!==void 0&&(a=a.slice(0,e)),a},dt=(s,n)=>{const a=t.cloneDeep(s);return t.forEach(t.keys(a),e=>{if(t.isString(a[e])&&!t.startsWith(e,"_")){let i=a[e];e==="repeaterItems"&&(a.repeaterItemsBinding=i);const r=/\{\{(.*?)\}\}/g,l=i.match(r);l&&l.forEach(p=>{let h=p.slice(2,-2);const o=t.get(n,h,p);i=t.isArray(o)?o:i.replace(p,o)}),a[e]=i}}),a},gt=s=>{const n=t.last(s);return s.map(a=>{const e=Object.keys(a);for(let i=0;i<e.length;i++)if(t.isString(a[e[i]])&&t.startsWith(e[i],"content")){const r=a===n?"":" ";a[e[i]]=`${a[e[i]].trim()}${r}`}return a})},w=(s,n,{index:a,key:e},i)=>{if(t.isString(s)){let r=s;const l=/\{\{(.*?)\}\}/g,p=s.match(l);if(p){const h=i==="image"||i==="mobileImage";p.forEach(o=>{let f=o.slice(2,-2).trim(),k=e.slice(2,-2).trim();a!==-1&&t.startsWith(f,"$index.")?f=`${k}.${a}.${f.slice(7)}`:a!==-1&&t.startsWith(f,"$index")&&(f=`${k}.${a}`);const b=t.get(n,f);b===void 0?r=r.replace(o,""):h&&!t.isArray(b)?r=b:r=t.isArray(b)?b:r.replace(o,b)})}return r}if(t.isArray(s))return s.map(r=>w(r,n,{index:a,key:e},i));if(s&&typeof s=="object"){const r={};return t.forEach(t.keys(s),l=>{!t.startsWith(l,"_")&&l!=="$repeaterItemsKey"?r[l]=w(s[l],n,{index:a,key:e},l):r[l]=s[l]}),r}return s},ht=(s,n,{index:a,key:e})=>{let i=t.cloneDeep(s);return i.repeaterItems&&(i.$repeaterItemsKey=i.repeaterItems,t.startsWith(i.repeaterItems,`{{${H}`)&&(i.$repeaterItemsKey=i.repeaterItems=`${i.repeaterItems.replace("}}",`/${i._id}}}`)}`),!t.isEmpty(i.repeaterItems)&&i.pagination&&(i.repeaterTotalItems=`${i.repeaterItems.replace("}}",`/${i._id}/totalItems}}`)}`)),w(i,n,{index:a,key:e})};exports.COLLECTION_PREFIX=H;exports.REPEATER_PREFIX=Y;exports.ROOT_TEMP_KEY=z;exports.STYLES_KEY=m;exports.adjustSpacingInContentBlocks=gt;exports.applyBindingToBlockProps=ht;exports.applyChaiDataBinding=dt;exports.applyLanguage=rt;exports.applyLimit=ut;exports.getBlockRuntimeProps=pt;exports.getBlockTagAttributes=ct;exports.getBlocksFromHTML=nt;exports.getSplitChaiClasses=V;exports.mergeBlocksWithExisting=at;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-C4b6LcwL.cjs");require("lodash-es");require("clsx");require("tailwind-merge");require("tree-model");const i=require("react");require("jotai");require("@chaibuilder/runtime");require("sonner");const q=require("react-i18next"),r=require("./tooltip-CzZ7Fvt7.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]=i.useState(!1),[a,p]=i.useState(""),[t,d]=c.useCodeEditor(),[u]=c.useSelectedBlockIds(),b=c.useUpdateBlocksProps(),f=c.useUpdateBlocksPropsRealtime(),C=g.useThrottledCallback(o=>{const l=m(o);f([t.blockId],{[t.blockProp]:l})},[],300),x=i.useCallback(()=>{if(s){const o=m(a);b([t.blockId],{[t.blockProp]:o})}},[s,a]);i.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-C4b6LcwL.cjs"),s=require("./common-functions-BZmyleS1.cjs"),a=require("./apply-binding-Dvnd_Vhq.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.d.ts
CHANGED
|
@@ -670,7 +670,17 @@ export declare const useBlocksStoreUndoableActions: () => {
|
|
|
670
670
|
/**
|
|
671
671
|
* Wrapper around useAtom
|
|
672
672
|
*/
|
|
673
|
-
export declare const useBrandingOptions: () => readonly [
|
|
673
|
+
export declare const useBrandingOptions: () => readonly [{
|
|
674
|
+
bodyFont: string;
|
|
675
|
+
headingFont: string;
|
|
676
|
+
roundedCorners: number;
|
|
677
|
+
primaryColor: string;
|
|
678
|
+
secondaryColor: string;
|
|
679
|
+
bodyBgDarkColor: string;
|
|
680
|
+
bodyBgLightColor: string;
|
|
681
|
+
bodyTextDarkColor: string;
|
|
682
|
+
bodyTextLightColor: string;
|
|
683
|
+
}, (args_0: any) => void];
|
|
674
684
|
|
|
675
685
|
export declare const useBuilderProp: <T>(propKey: keyof Omit<ChaiBuilderEditorProps, ExcludedBuilderProps> | "languages" | string, defaultValue?: T) => T;
|
|
676
686
|
|
|
@@ -723,7 +733,7 @@ export declare const useHighlightBlockId: () => [string, Function];
|
|
|
723
733
|
|
|
724
734
|
export declare const useHtmlToBlocks: () => (html: string) => ChaiBlock[];
|
|
725
735
|
|
|
726
|
-
export declare const useI18nBlocks: () => (lang?: string | "ALL") => any;
|
|
736
|
+
export declare const useI18nBlocks: () => (lang?: string | "ALL") => Pick<any, "_id">[];
|
|
727
737
|
|
|
728
738
|
export declare const useInlineEditing: () => {
|
|
729
739
|
editingBlockId: string;
|
|
@@ -752,7 +762,7 @@ export declare const useLibraryBlocks: (library?: Partial<ChaiLibrary> & {
|
|
|
752
762
|
export declare const useMediaManagerComponent: () => ComponentType<MediaManagerProps>;
|
|
753
763
|
|
|
754
764
|
export declare const usePartailBlocksStore: () => {
|
|
755
|
-
getPartailBlocks: (partailBlock: string) => any;
|
|
765
|
+
getPartailBlocks: (partailBlock: string) => any[] | ChaiBlock[];
|
|
756
766
|
reset: () => void;
|
|
757
767
|
};
|
|
758
768
|
|
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-DFvi9z_N.js";
|
|
2
2
|
import { g as Za, c as Ja } from "./common-functions-BGzDsf1z.js";
|
|
3
|
-
import { h as Na, h as Qa } from "./apply-binding-
|
|
3
|
+
import { h as Na, h as Qa } from "./apply-binding-COFSiTeM.js";
|
|
4
4
|
import { useTranslation as Ya } from "react-i18next";
|
|
5
5
|
import { default as $a } from "i18next";
|
|
6
6
|
export {
|