@chaibuilder/sdk 3.1.9 → 3.1.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.
- package/dist/apply-binding-DCZAw7M-.cjs +1 -0
- package/dist/{apply-binding-w7OMcHcu.js → apply-binding-DXR0sMuX.js} +91 -90
- package/dist/{code-editor-B1G67AXy.js → code-editor-CfrDD-_Q.js} +1 -1
- package/dist/{code-editor-CgrS41Jk.cjs → code-editor-phK7gXCy.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +2 -2
- package/dist/index--Qiql02b.cjs +151 -0
- package/dist/{index-Do47CY7C.js → index-BXLWWUUp.js} +10 -11
- package/dist/render.cjs +1 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-CB3K6Mon.cjs → rte-widget-modal-D3fAQUEu.cjs} +1 -1
- package/dist/{rte-widget-modal-BiZPyPF3.js → rte-widget-modal-DG4qh6_A.js} +1 -1
- package/package.json +1 -1
- package/dist/apply-binding-CExho6DS.cjs +0 -1
- package/dist/index-kbs2fSny.cjs +0 -151
|
@@ -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),B=s=>s.map(n=>n.type==="text"?t.get(n,"content",""):t.isEmpty(n.children)?"":B(n.children)).join(""),v=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(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://via.placeholder.com/${l==null?void 0:l.value}x${p==null?void 0:p.value}`:r="https://via.placeholder.com/150x150"}t.set(n,a[i],v(r))}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}`]=v(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)}}}},E=(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 b=v(P);typeof b=="string"&&t.startsWith(b,"#styles:")&&(b=b.replace("#styles:","#styles:,")),e[O]=b});const g=E(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=B(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:B(a.children),...q(a)}),[];const x=E(a.children,{block:e,node:a});return[e,...x]}),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:t.map(s,a=>{const e=st(n,a._id);return e?(e._type==="Icon"&&t.get(a,"icon","").match(/chai-default-svg/)&&delete a.icon,{...e,...a}):a}),nt=s=>{const n=_.parse(et(s));return t.isEmpty(s)?[]:t.flatten(E(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 x=t.get(n,f);x===void 0?r=r.replace(o,""):h&&!t.isArray(x)?r=x:r=t.isArray(x)?x:r.replace(o,x)})}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,9 +1,9 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { isEmpty as f, flatten as
|
|
3
|
-
import { parse as
|
|
4
|
-
import { getRegisteredChaiBlock as
|
|
5
|
-
import { twMerge as
|
|
6
|
-
const x = "#styles:",
|
|
1
|
+
import { g as rt, c as S } from "./common-functions-BGzDsf1z.js";
|
|
2
|
+
import { isEmpty as f, flatten as ot, flatMapDeep as lt, get as d, set as E, startsWith as _, find as m, startCase as ct, forEach as $, camelCase as pt, includes as v, has as A, filter as Z, some as ut, map as Q, compact as dt, trim as ht, capitalize as gt, memoize as tt, cloneDeep as q, keys as M, isString as B, isArray as C, last as mt } from "lodash-es";
|
|
3
|
+
import { parse as yt, stringify as N } from "himalaya";
|
|
4
|
+
import { getRegisteredChaiBlock as bt } from "@chaibuilder/runtime";
|
|
5
|
+
import { twMerge as ft } from "tailwind-merge";
|
|
6
|
+
const x = "#styles:", Ht = "__ADD_BLOCK_INTERNAL_ROOT", jt = "@", xt = "#", et = (e) => {
|
|
7
7
|
if (e = e.replace(x, ""), !e) return { baseClasses: "", classes: "" };
|
|
8
8
|
const s = e.split(/,(?![^\[]*\])/);
|
|
9
9
|
if (s.length === 1)
|
|
@@ -46,14 +46,14 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
|
-
const
|
|
49
|
+
const _t = (e) => {
|
|
50
50
|
const s = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, t = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
|
|
51
51
|
return s.test(e) || t.test(e);
|
|
52
|
-
},
|
|
52
|
+
}, kt = (e) => {
|
|
53
53
|
if (f(e)) return e;
|
|
54
54
|
const s = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = e.match(s), n = e.match(t), r = a ? a[1] : n ? n[1] : null, o = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, c = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
|
|
55
55
|
return r && (o.test(r) || c.test(r)) ? r : e;
|
|
56
|
-
}, at = ["chai-name", "data-chai-name"],
|
|
56
|
+
}, at = ["chai-name", "data-chai-name"], vt = {
|
|
57
57
|
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
58
58
|
video: {
|
|
59
59
|
src: "url",
|
|
@@ -89,11 +89,11 @@ const ft = (e) => {
|
|
|
89
89
|
form: {
|
|
90
90
|
action: "action"
|
|
91
91
|
}
|
|
92
|
-
},
|
|
92
|
+
}, wt = (e, s) => e.children.length === 1 && v(
|
|
93
93
|
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
94
94
|
s._type
|
|
95
95
|
), R = (e) => e.map((s) => s.type === "text" ? d(s, "content", "") : f(s.children) ? "" : R(s.children)).join(""), H = (e) => e === null ? "" : e, st = (e) => {
|
|
96
|
-
const s =
|
|
96
|
+
const s = dt(Q(e.split(/\s+/), ht)), t = m(s, (c) => /^w-/.test(c)), a = m(s, (c) => /^h-/.test(c));
|
|
97
97
|
if (!a || !t) return { height: "", width: "" };
|
|
98
98
|
const n = (c) => {
|
|
99
99
|
if (!c) return;
|
|
@@ -109,7 +109,7 @@ const ft = (e) => {
|
|
|
109
109
|
};
|
|
110
110
|
}, G = (e) => {
|
|
111
111
|
if (e.tagName === "svg") return {};
|
|
112
|
-
const s = {}, t =
|
|
112
|
+
const s = {}, t = vt[e.tagName] || {}, a = e.attributes;
|
|
113
113
|
return $(a, ({ key: n, value: r }) => {
|
|
114
114
|
if (!v(at, n))
|
|
115
115
|
if (t[n]) {
|
|
@@ -118,9 +118,9 @@ const ft = (e) => {
|
|
|
118
118
|
o && c ? r = `https://via.placeholder.com/${o == null ? void 0 : o.value}x${c == null ? void 0 : c.value}` : r = "https://via.placeholder.com/150x150";
|
|
119
119
|
}
|
|
120
120
|
E(s, t[n], H(r));
|
|
121
|
-
} else v(["style", "class", "srcset"], n) || (A(s, "styles_attrs") || (s.styles_attrs = {}),
|
|
121
|
+
} else v(["style", "class", "srcset"], n) || (A(s, "styles_attrs") || (s.styles_attrs = {}), _(n, "@") && (n = n.replace("@", "x-on:")), s.styles_attrs[`${n}`] = H(r));
|
|
122
122
|
}), delete s.class, s;
|
|
123
|
-
},
|
|
123
|
+
}, Tt = (e, s = "styles") => {
|
|
124
124
|
if (!e.attributes) return { [s]: `${x},` };
|
|
125
125
|
const t = m(e.attributes, { key: "class" });
|
|
126
126
|
if (t) {
|
|
@@ -128,7 +128,7 @@ const ft = (e) => {
|
|
|
128
128
|
return { [s]: `${x},${a}` };
|
|
129
129
|
}
|
|
130
130
|
return { [s]: `${x},` };
|
|
131
|
-
},
|
|
131
|
+
}, Et = (e) => {
|
|
132
132
|
const s = d(e, "attributes", []), t = s.find((i) => i.key === "data-chai-richtext" || i.key === "chai-richtext"), a = s.find((i) => i.key === "data-chai-lightbox" || i.key === "chai-lightbox"), n = s.find((i) => i.key === "data-chai-dropdown" || i.key === "chai-dropdown"), r = s.find(
|
|
133
133
|
(i) => i.key === "data-chai-dropdown-button" || i.key === "chai-dropdown-button"
|
|
134
134
|
), o = s.find(
|
|
@@ -226,26 +226,27 @@ const ft = (e) => {
|
|
|
226
226
|
return {
|
|
227
227
|
_type: i,
|
|
228
228
|
tag: e.tagName,
|
|
229
|
-
_name: i == "EmptyBox" || e.tagName === "div" ? i :
|
|
229
|
+
_name: i == "EmptyBox" || e.tagName === "div" ? i : gt(e.tagName)
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
}, j = (e, s = null) =>
|
|
233
|
+
}, j = (e, s = null) => lt(e, (t) => {
|
|
234
234
|
var P, J, O, z, V, W, F, U, Y, K;
|
|
235
235
|
if (t.type === "comment") return [];
|
|
236
|
-
let a = { _id:
|
|
236
|
+
let a = { _id: rt() };
|
|
237
237
|
if (s && (a._parent = s.block._id), t.type === "text")
|
|
238
|
-
return f(d(t, "content", "")) ? [] : s &&
|
|
239
|
-
if (
|
|
240
|
-
const l = t.attributes, p = m(l, { key: "chai-type" }), u = (p == null ? void 0 : p.value) ||
|
|
241
|
-
a._type = u, $(l, ({ key:
|
|
242
|
-
if (
|
|
243
|
-
if (
|
|
238
|
+
return f(d(t, "content", "")) ? [] : s && wt(s.node, s.block) ? (E(s, "block.content", d(t, "content", "")), []) : { ...a, _type: "Text", content: d(t, "content", "") };
|
|
239
|
+
if (_(t.tagName, "chai-")) {
|
|
240
|
+
const l = t.attributes, p = m(l, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || ct(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
|
|
241
|
+
a._type = u, $(l, ({ key: y, value: X }) => {
|
|
242
|
+
if (y === "about-this-component" || y === "chai-type" || y === "can-move" || y === "can-delete") return;
|
|
243
|
+
if (y === "id") {
|
|
244
244
|
a._id = X;
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
|
+
const nt = _(y, "_") ? y : pt(y);
|
|
247
248
|
let I = H(X);
|
|
248
|
-
typeof I == "string" &&
|
|
249
|
+
typeof I == "string" && _(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")), a[nt] = I;
|
|
249
250
|
});
|
|
250
251
|
const h = j(t.children, { block: a, node: t });
|
|
251
252
|
return [a, ...h];
|
|
@@ -263,9 +264,9 @@ const ft = (e) => {
|
|
|
263
264
|
);
|
|
264
265
|
if (a = {
|
|
265
266
|
...a,
|
|
266
|
-
...
|
|
267
|
+
...Et(t),
|
|
267
268
|
...G(t),
|
|
268
|
-
...
|
|
269
|
+
...Tt(t)
|
|
269
270
|
}, t.attributes) {
|
|
270
271
|
const l = t.attributes.find((p) => v(at, p.key));
|
|
271
272
|
l && (a._name = l.value);
|
|
@@ -301,14 +302,14 @@ const ft = (e) => {
|
|
|
301
302
|
a.content = R(l);
|
|
302
303
|
const p = m(
|
|
303
304
|
t.children || [],
|
|
304
|
-
(u) => (u == null ? void 0 : u.tagName) === "span" &&
|
|
305
|
+
(u) => (u == null ? void 0 : u.tagName) === "span" && ut(u.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
|
|
305
306
|
);
|
|
306
307
|
if (p) {
|
|
307
308
|
const u = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
|
|
308
309
|
if (u) {
|
|
309
310
|
a.icon = N([u]);
|
|
310
|
-
const { height: h, width:
|
|
311
|
-
a.iconHeight = h, a.iconWidth =
|
|
311
|
+
const { height: h, width: y } = $t(u, "16px", "16px");
|
|
312
|
+
a.iconHeight = h, a.iconWidth = y;
|
|
312
313
|
}
|
|
313
314
|
}
|
|
314
315
|
return [a];
|
|
@@ -318,14 +319,14 @@ const ft = (e) => {
|
|
|
318
319
|
l === "checkbox" ? E(a, "_type", "Checkbox") : l === "radio" && E(a, "_type", "Radio");
|
|
319
320
|
} else if (t.tagName === "video" || t.tagName === "iframe") {
|
|
320
321
|
const l = N([t]);
|
|
321
|
-
return
|
|
322
|
+
return _t(l) && (E(a, "_type", "Video"), E(a, "url", kt(l)), E(a, "styles", `${x},`), E(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = l, [a];
|
|
322
323
|
} else if (t.tagName === "svg") {
|
|
323
324
|
const l = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = st(l);
|
|
324
325
|
if (p && u)
|
|
325
326
|
a.styles = `${x}, ${S(`w-${u} h-${p}`, l)}`.trim(), a.height = p == null ? void 0 : p.replace("px", ""), a.width = u == null ? void 0 : u.replace("px", "");
|
|
326
327
|
else {
|
|
327
|
-
const h = (U = m(t.attributes, { key: "height" })) == null ? void 0 : U.value,
|
|
328
|
-
h &&
|
|
328
|
+
const h = (U = m(t.attributes, { key: "height" })) == null ? void 0 : U.value, y = (Y = m(t.attributes, { key: "width" })) == null ? void 0 : Y.value;
|
|
329
|
+
h && y ? (a.styles = `${x}, ${S(`w-[${y}px] h-[${h}px]`, l)}`.trim(), a.height = h, a.width = y) : a.styles = `${x}, ${S("w-full h-full", l)}`.trim();
|
|
329
330
|
}
|
|
330
331
|
return t.attributes = Z(t.attributes, (h) => !v(["style", "width", "height", "class"], h.key)), a.icon = N([t]), [a];
|
|
331
332
|
} else if (t.tagName == "option" && s && ((K = s.block) == null ? void 0 : K._type) === "Select")
|
|
@@ -335,7 +336,7 @@ const ft = (e) => {
|
|
|
335
336
|
}), [];
|
|
336
337
|
const T = j(t.children, { block: a, node: t });
|
|
337
338
|
return [a, ...T];
|
|
338
|
-
}),
|
|
339
|
+
}), $t = (e, s, t) => {
|
|
339
340
|
var g, i;
|
|
340
341
|
const a = d(e, "attributes", []), { height: n, width: r } = st(
|
|
341
342
|
d(m(a, { key: "class" }), "value", "")
|
|
@@ -350,21 +351,21 @@ const ft = (e) => {
|
|
|
350
351
|
height: o ? `[${o}px]` : t,
|
|
351
352
|
width: c ? `[${c}px]` : s
|
|
352
353
|
};
|
|
353
|
-
},
|
|
354
|
+
}, Bt = (e) => {
|
|
354
355
|
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, n, r) => {
|
|
355
356
|
let o = r.replace(/\\"/g, '"');
|
|
356
357
|
return o = o.replace(/{([^}]+)}/g, (c) => c.replace(/"/g, '\\"')), `${n}="${o.replace(/\\"/g, '"')}"`;
|
|
357
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, "");
|
|
358
359
|
const s = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
359
360
|
return (s && s.length > 0 ? s[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
360
|
-
},
|
|
361
|
-
const a =
|
|
361
|
+
}, It = (e, s) => m(e, { _id: s }), qt = (e, s) => f(s) ? e : Q(e, (t) => {
|
|
362
|
+
const a = It(s, t._id);
|
|
362
363
|
return a ? (a._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon, { ...a, ...t }) : t;
|
|
363
|
-
}),
|
|
364
|
-
const s =
|
|
365
|
-
return f(e) ? [] :
|
|
364
|
+
}), Mt = (e) => {
|
|
365
|
+
const s = yt(Bt(e));
|
|
366
|
+
return f(e) ? [] : ot(j(s));
|
|
366
367
|
};
|
|
367
|
-
function
|
|
368
|
+
function Pt(e, s, t) {
|
|
368
369
|
const a = d(t, "i18nProps", []);
|
|
369
370
|
if (f(s) || f(a)) return e;
|
|
370
371
|
const n = q(e);
|
|
@@ -375,18 +376,18 @@ function qt(e, s, t) {
|
|
|
375
376
|
}
|
|
376
377
|
}), n;
|
|
377
378
|
}
|
|
378
|
-
const
|
|
379
|
+
const Ct = tt((e) => {
|
|
379
380
|
const { baseClasses: s, classes: t } = et(e);
|
|
380
|
-
return
|
|
381
|
+
return ft(s, t);
|
|
381
382
|
});
|
|
382
|
-
function
|
|
383
|
+
function Dt(e, s) {
|
|
383
384
|
return d(e, `${s}_attrs`, {});
|
|
384
385
|
}
|
|
385
|
-
function
|
|
386
|
+
function Jt(e, s = !0) {
|
|
386
387
|
const t = {};
|
|
387
388
|
return Object.keys(e).forEach((a) => {
|
|
388
389
|
if (B(e[a]) && e[a].startsWith(x)) {
|
|
389
|
-
const n =
|
|
390
|
+
const n = Ct(e[a]), r = Dt(e, a);
|
|
390
391
|
t[a] = {
|
|
391
392
|
...!f(n) && { className: n },
|
|
392
393
|
...r,
|
|
@@ -399,17 +400,17 @@ function Mt(e, s = !0) {
|
|
|
399
400
|
}
|
|
400
401
|
}), t;
|
|
401
402
|
}
|
|
402
|
-
const
|
|
403
|
-
const s =
|
|
403
|
+
const Ot = tt((e) => {
|
|
404
|
+
const s = bt(e), t = d(s, "schema.properties", {});
|
|
404
405
|
return Object.fromEntries(Object.entries(t).filter(([, a]) => d(a, "runtime", !1)));
|
|
405
|
-
}),
|
|
406
|
+
}), zt = (e, s) => {
|
|
406
407
|
if (!C(e)) return e;
|
|
407
408
|
let t = e, a;
|
|
408
409
|
return typeof s.limit == "number" && s.limit > 0 && (a = s.limit), a !== void 0 && (t = t.slice(0, a)), t;
|
|
409
|
-
},
|
|
410
|
+
}, Vt = (e, s) => {
|
|
410
411
|
const t = q(e);
|
|
411
412
|
return $(M(t), (a) => {
|
|
412
|
-
if (B(t[a]) && !
|
|
413
|
+
if (B(t[a]) && !_(a, "_")) {
|
|
413
414
|
let n = t[a];
|
|
414
415
|
a === "repeaterItems" && (t.repeaterItemsBinding = n);
|
|
415
416
|
const r = /\{\{(.*?)\}\}/g, o = n.match(r);
|
|
@@ -420,12 +421,12 @@ const Pt = tt((e) => {
|
|
|
420
421
|
}), t[a] = n;
|
|
421
422
|
}
|
|
422
423
|
}), t;
|
|
423
|
-
},
|
|
424
|
-
const s =
|
|
424
|
+
}, k = (e) => {
|
|
425
|
+
const s = mt(e);
|
|
425
426
|
return e.map((t) => {
|
|
426
427
|
const a = Object.keys(t);
|
|
427
428
|
for (let n = 0; n < a.length; n++)
|
|
428
|
-
if (B(t[a[n]]) &&
|
|
429
|
+
if (B(t[a[n]]) && _(a[n], "content")) {
|
|
429
430
|
const r = t === s ? "" : " ";
|
|
430
431
|
t[a[n]] = `${t[a[n]].trim()}${r}`;
|
|
431
432
|
}
|
|
@@ -436,50 +437,50 @@ if (import.meta.vitest) {
|
|
|
436
437
|
const { describe: e, it: s, expect: t } = import.meta.vitest;
|
|
437
438
|
e("adjustSpacingInContentBlocks", () => {
|
|
438
439
|
s("should add space after content fields except for the last block", () => {
|
|
439
|
-
const n =
|
|
440
|
+
const n = k([
|
|
440
441
|
{ _id: "1", _type: "Text", content: "First" },
|
|
441
442
|
{ _id: "2", _type: "Text", content: "Second" },
|
|
442
443
|
{ _id: "3", _type: "Text", content: "Third" }
|
|
443
444
|
]);
|
|
444
445
|
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second "), t(n[2].content).toBe("Third");
|
|
445
446
|
}), s("should trim whitespace from content before adding space", () => {
|
|
446
|
-
const n =
|
|
447
|
+
const n = k([
|
|
447
448
|
{ _id: "1", _type: "Text", content: " First " },
|
|
448
449
|
{ _id: "2", _type: "Text", content: " Second " }
|
|
449
450
|
]);
|
|
450
451
|
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second");
|
|
451
452
|
}), s("should handle multiple content fields in a single block", () => {
|
|
452
|
-
const n =
|
|
453
|
+
const n = k([
|
|
453
454
|
{ _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
|
|
454
455
|
{ _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
|
|
455
456
|
]);
|
|
456
457
|
t(n[0].content).toBe("Main "), t(n[0].contentAlt).toBe("Alt "), t(n[1].content).toBe("Last"), t(n[1].contentSecondary).toBe("Secondary");
|
|
457
458
|
}), s("should only process fields that start with 'content'", () => {
|
|
458
|
-
const n =
|
|
459
|
+
const n = k([
|
|
459
460
|
{ _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
|
|
460
461
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
461
462
|
]);
|
|
462
463
|
t(n[0].content).toBe("Text "), t(n[0].title).toBe("Title"), t(n[0].text).toBe("Text"), t(n[1].content).toBe("Last");
|
|
463
464
|
}), s("should handle empty array", () => {
|
|
464
|
-
const n =
|
|
465
|
+
const n = k([]);
|
|
465
466
|
t(n).toEqual([]);
|
|
466
467
|
}), s("should handle single block", () => {
|
|
467
|
-
const n =
|
|
468
|
+
const n = k([{ _id: "1", _type: "Text", content: "Only" }]);
|
|
468
469
|
t(n[0].content).toBe("Only");
|
|
469
470
|
}), s("should handle blocks without content fields", () => {
|
|
470
|
-
const n =
|
|
471
|
+
const n = k([
|
|
471
472
|
{ _id: "1", _type: "Container", title: "Title" },
|
|
472
473
|
{ _id: "2", _type: "Container", name: "Name" }
|
|
473
474
|
]);
|
|
474
475
|
t(n[0].title).toBe("Title"), t(n[1].name).toBe("Name");
|
|
475
476
|
}), s("should handle blocks with non-string content fields", () => {
|
|
476
|
-
const n =
|
|
477
|
+
const n = k([
|
|
477
478
|
{ _id: "1", _type: "Text", content: "Text", contentNum: 123 },
|
|
478
479
|
{ _id: "2", _type: "Text", content: "Last", contentBool: !0 }
|
|
479
480
|
]);
|
|
480
481
|
t(n[0].content).toBe("Text "), t(n[0].contentNum).toBe(123), t(n[1].content).toBe("Last"), t(n[1].contentBool).toBe(!0);
|
|
481
482
|
}), s("should handle empty string content", () => {
|
|
482
|
-
const n =
|
|
483
|
+
const n = k([
|
|
483
484
|
{ _id: "1", _type: "Text", content: "" },
|
|
484
485
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
485
486
|
]);
|
|
@@ -487,7 +488,7 @@ if (import.meta.vitest) {
|
|
|
487
488
|
});
|
|
488
489
|
});
|
|
489
490
|
}
|
|
490
|
-
const
|
|
491
|
+
const b = (e, s, { index: t, key: a }, n) => {
|
|
491
492
|
if (B(e)) {
|
|
492
493
|
let r = e;
|
|
493
494
|
const o = /\{\{(.*?)\}\}/g, c = e.match(o);
|
|
@@ -495,7 +496,7 @@ const y = (e, s, { index: t, key: a }, n) => {
|
|
|
495
496
|
const g = n === "image" || n === "mobileImage";
|
|
496
497
|
c.forEach((i) => {
|
|
497
498
|
let w = i.slice(2, -2).trim(), D = a.slice(2, -2).trim();
|
|
498
|
-
t !== -1 &&
|
|
499
|
+
t !== -1 && _(w, "$index.") ? w = `${D}.${t}.${w.slice(7)}` : t !== -1 && _(w, "$index") && (w = `${D}.${t}`);
|
|
499
500
|
const T = d(s, w);
|
|
500
501
|
T === void 0 ? r = r.replace(i, "") : g && !C(T) ? r = T : r = C(T) ? T : r.replace(i, T);
|
|
501
502
|
});
|
|
@@ -503,24 +504,24 @@ const y = (e, s, { index: t, key: a }, n) => {
|
|
|
503
504
|
return r;
|
|
504
505
|
}
|
|
505
506
|
if (C(e))
|
|
506
|
-
return e.map((r) =>
|
|
507
|
+
return e.map((r) => b(r, s, { index: t, key: a }, n));
|
|
507
508
|
if (e && typeof e == "object") {
|
|
508
509
|
const r = {};
|
|
509
510
|
return $(M(e), (o) => {
|
|
510
|
-
!
|
|
511
|
+
!_(o, "_") && o !== "$repeaterItemsKey" ? r[o] = b(e[o], s, { index: t, key: a }, o) : r[o] = e[o];
|
|
511
512
|
}), r;
|
|
512
513
|
}
|
|
513
514
|
return e;
|
|
514
515
|
}, L = (e, s, { index: t, key: a }) => {
|
|
515
516
|
let n = q(e);
|
|
516
|
-
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems,
|
|
517
|
+
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, _(n.repeaterItems, `{{${xt}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !f(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, s, { index: t, key: a });
|
|
517
518
|
};
|
|
518
519
|
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
519
520
|
it("should handle string values with bindings", () => {
|
|
520
|
-
const t =
|
|
521
|
+
const t = b("Hello {{user.name}}", { user: { name: "John" } }, { index: -1, key: "" });
|
|
521
522
|
expect(t).toBe("Hello John");
|
|
522
523
|
}), it("should handle nested object properties", () => {
|
|
523
|
-
const t =
|
|
524
|
+
const t = b({
|
|
524
525
|
name: "John",
|
|
525
526
|
address: {
|
|
526
527
|
city: "{{user.city}}",
|
|
@@ -535,19 +536,19 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
535
536
|
}
|
|
536
537
|
});
|
|
537
538
|
}), it("should handle arrays of values", () => {
|
|
538
|
-
const t =
|
|
539
|
+
const t = b(["Hello {{user.name}}", "Welcome {{user.role}}"], { user: { name: "John", role: "Admin" } }, { index: -1, key: "" });
|
|
539
540
|
expect(t).toEqual(["Hello John", "Welcome Admin"]);
|
|
540
541
|
}), it("should handle $index binding in repeater context", () => {
|
|
541
|
-
const t =
|
|
542
|
+
const t = b("Item {{$index}}", { items: ["a", "b", "c"] }, { index: 1, key: "{{items}}" });
|
|
542
543
|
expect(t).toBe("Item b");
|
|
543
544
|
}), it("should handle $index binding with dot notation", () => {
|
|
544
|
-
const t =
|
|
545
|
+
const t = b("Item {{$index.value}}", { items: [{ value: "apple" }, { value: "banana" }, { value: "cherry" }] }, { index: 1, key: "{{items}}" });
|
|
545
546
|
expect(t).toBe("Item banana");
|
|
546
547
|
}), it("should return an empty string for non-existing bindings", () => {
|
|
547
|
-
const t =
|
|
548
|
+
const t = b("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
|
|
548
549
|
expect(t).toBe("Hello ");
|
|
549
550
|
}), it("should preserve private properties starting with _", () => {
|
|
550
|
-
const s =
|
|
551
|
+
const s = b({
|
|
551
552
|
name: "John",
|
|
552
553
|
_private: "secret"
|
|
553
554
|
}, {}, { index: -1, key: "" });
|
|
@@ -556,7 +557,7 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
556
557
|
_private: "secret"
|
|
557
558
|
});
|
|
558
559
|
}), it("should completely replace image property value when binding exists", () => {
|
|
559
|
-
const t =
|
|
560
|
+
const t = b({
|
|
560
561
|
image: "https://default.jpg{{user.avatar}}",
|
|
561
562
|
title: "Hello {{user.name}}"
|
|
562
563
|
}, { user: { avatar: "https://avatar.jpg", name: "John" } }, { index: -1, key: "" });
|
|
@@ -567,7 +568,7 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
567
568
|
// Normal replacement
|
|
568
569
|
});
|
|
569
570
|
}), it("should completely replace mobileImage property value when binding exists", () => {
|
|
570
|
-
const t =
|
|
571
|
+
const t = b({
|
|
571
572
|
mobileImage: "https://default-mobile.jpg{{user.mobileAvatar}}",
|
|
572
573
|
alt: "Avatar for {{user.name}}"
|
|
573
574
|
}, { user: { mobileAvatar: "https://mobile-avatar.jpg", name: "John" } }, { index: -1, key: "" });
|
|
@@ -578,14 +579,14 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
578
579
|
// Normal replacement
|
|
579
580
|
});
|
|
580
581
|
}), it("should handle image binding with only binding syntax", () => {
|
|
581
|
-
const t =
|
|
582
|
+
const t = b({
|
|
582
583
|
image: "{{product.thumbnail}}"
|
|
583
584
|
}, { product: { thumbnail: "https://product.jpg" } }, { index: -1, key: "" });
|
|
584
585
|
expect(t).toEqual({
|
|
585
586
|
image: "https://product.jpg"
|
|
586
587
|
});
|
|
587
588
|
}), it("should not affect non-image properties with similar bindings", () => {
|
|
588
|
-
const t =
|
|
589
|
+
const t = b({
|
|
589
590
|
url: "https://default.com{{page.slug}}",
|
|
590
591
|
link: "https://example.com/{{page.id}}"
|
|
591
592
|
}, { page: { slug: "/about", id: "123" } }, { index: -1, key: "" });
|
|
@@ -687,18 +688,18 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
687
688
|
});
|
|
688
689
|
}));
|
|
689
690
|
export {
|
|
690
|
-
|
|
691
|
-
|
|
691
|
+
xt as C,
|
|
692
|
+
jt as R,
|
|
692
693
|
x as S,
|
|
693
694
|
L as a,
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
695
|
+
Pt as b,
|
|
696
|
+
Ot as c,
|
|
697
|
+
zt as d,
|
|
698
|
+
k as e,
|
|
699
|
+
Vt as f,
|
|
700
|
+
Jt as g,
|
|
701
|
+
Mt as h,
|
|
701
702
|
et as i,
|
|
702
|
-
|
|
703
|
-
|
|
703
|
+
Ht as j,
|
|
704
|
+
qt as m
|
|
704
705
|
};
|
|
@@ -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--Qiql02b.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-C2BCZ8Al.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--Qiql02b.cjs"),s=require("./common-functions-BZmyleS1.cjs"),a=require("./apply-binding-DCZAw7M-.cjs"),i=require("react-i18next"),l=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.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:()=>i.useTranslation});exports.i18n=l;
|
package/dist/core.d.ts
CHANGED
|
@@ -656,7 +656,7 @@ export declare const useHighlightBlockId: () => [string, Function];
|
|
|
656
656
|
|
|
657
657
|
export declare const useHtmlToBlocks: () => (html: string) => ChaiBlock[];
|
|
658
658
|
|
|
659
|
-
export declare const useI18nBlocks: () => (lang?: string | "ALL") =>
|
|
659
|
+
export declare const useI18nBlocks: () => (lang?: string | "ALL") => any;
|
|
660
660
|
|
|
661
661
|
export declare const useInlineEditing: () => {
|
|
662
662
|
editingBlockId: string;
|
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, E as B, I as k, L as n, g, T as h, U as p, h as S, y as m, P, m as F, n as A, o as T, p as M, r as b, z as y, F as I, s as v, t as L, q as f, v as R, w as E, x as H, M as D, O as U, Q as x, R as W, S as O, V as w, aB as z, W as j, X as q, Y as G, aD as V, aC as Z, Z as J, G as K, H as N, u as Q, _ 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, K as ca, ab as da, ac as Ca, ad as Ba, ae as ka, af as na, ag as ga, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, aE as Ta, ao as Ma, ap as ba, aq as ya, a as Ia, ar as va, as as La, aF as fa, at as Ra, aG as Ea, au as Ha, av as Da, aw as Ua, ax as xa, ay as Wa, J as Oa, az as wa, b as za, c as ja, aA as qa } 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, E as B, I as k, L as n, g, T as h, U as p, h as S, y as m, P, m as F, n as A, o as T, p as M, r as b, z as y, F as I, s as v, t as L, q as f, v as R, w as E, x as H, M as D, O as U, Q as x, R as W, S as O, V as w, aB as z, W as j, X as q, Y as G, aD as V, aC as Z, Z as J, G as K, H as N, u as Q, _ 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, K as ca, ab as da, ac as Ca, ad as Ba, ae as ka, af as na, ag as ga, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, aE as Ta, ao as Ma, ap as ba, aq as ya, a as Ia, ar as va, as as La, aF as fa, at as Ra, aG as Ea, au as Ha, av as Da, aw as Ua, ax as xa, ay as Wa, J as Oa, az as wa, b as za, c as ja, aA as qa } from "./index-BXLWWUUp.js";
|
|
2
2
|
import { g as Va, c as Za } from "./common-functions-BGzDsf1z.js";
|
|
3
|
-
import { h as Ka, h as Na } from "./apply-binding-
|
|
3
|
+
import { h as Ka, h as Na } from "./apply-binding-DXR0sMuX.js";
|
|
4
4
|
import { useTranslation as Xa } from "react-i18next";
|
|
5
5
|
import { default as _a } from "i18next";
|
|
6
6
|
export {
|