@chaibuilder/sdk 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{apply-binding-BEdnEDe4.cjs → apply-binding-CExho6DS.cjs} +1 -1
- package/dist/{apply-binding-FoDMumPo.js → apply-binding-w7OMcHcu.js} +142 -142
- package/dist/{code-editor-C62A8Uxk.cjs → code-editor-B5oshOO9.cjs} +1 -1
- package/dist/{code-editor-CZim1lTD.js → code-editor-BpQxKJGQ.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +2 -2
- package/dist/{index-_9FkXyrh.cjs → index-Bcp30Thz.cjs} +2 -2
- package/dist/{index-DyIelfZ9.js → index-C9p-YGGl.js} +17 -15
- package/dist/render.cjs +1 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-CecJhRtn.js → rte-widget-modal-BFbI7jcA.js} +1 -1
- package/dist/{rte-widget-modal-Bx0TSa19.cjs → rte-widget-modal-_UcsVj49.cjs} +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +28 -28
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const B=require("./common-functions-BZmyleS1.cjs"),t=require("lodash-es"),_=require("himalaya"),O=require("@chaibuilder/runtime"),F=require("tailwind-merge"),m="#styles:",J="__ADD_BLOCK_INTERNAL_ROOT",z="@",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,"")}},Y=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"],K={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"}},X=(s,n)=>s.children.length===1&&t.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],n._type),T=s=>s.map(n=>n.type==="text"?t.get(n,"content",""):t.isEmpty(n.children)?"":T(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=K[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},Z=(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},`}},G=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:B.generateUUID()};if(n&&(e._parent=n.block._id),a.type==="text")return t.isEmpty(t.get(a,"content",""))?[]:n&&X(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}let b=v(P);typeof b=="string"&&t.startsWith(b,"#styles:")&&(b=b.replace("#styles:","#styles:,")),e[y]=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,...G(a),...q(a),...Z(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=T(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}=Q(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 Y(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}, ${B.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}, ${B.cn(`w-[${y}px] h-[${g}px]`,c)}`.trim(),e.height=g,e.width=y):e.styles=`${m}, ${B.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:T(a.children),...q(a)}),[];const x=E(a.children,{block:e,node:a});return[e,...x]}),Q=(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}},tt=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()},et=(s,n)=>t.find(s,{_id:n}),st=(s,n)=>t.isEmpty(n)?s:t.map(s,a=>{const e=et(n,a._id);return e?{...e,...a}:a}),at=s=>{const n=_.parse(tt(s));return t.isEmpty(s)?[]:t.flatten(E(n))};function nt(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 rt=t.memoize(s=>{const{baseClasses:n,classes:a}=V(s);return F.twMerge(n,a)});function ot(s,n){return t.get(s,`${n}_attrs`,{})}function lt(s,n=!0){const a={};return Object.keys(s).forEach(e=>{if(t.isString(s[e])&&s[e].startsWith(m)){const i=rt(s[e]),r=ot(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 ct=t.memoize(s=>{const n=O.getRegisteredChaiBlock(s),a=t.get(n,"schema.properties",{});return Object.fromEntries(Object.entries(a).filter(([,e])=>t.get(e,"runtime",!1)))}),pt=(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},ut=(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},dt=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},gt=(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=z;exports.ROOT_TEMP_KEY=J;exports.STYLES_KEY=m;exports.adjustSpacingInContentBlocks=dt;exports.applyBindingToBlockProps=gt;exports.applyChaiDataBinding=ut;exports.applyLanguage=nt;exports.applyLimit=pt;exports.getBlockRuntimeProps=ct;exports.getBlockTagAttributes=lt;exports.getBlocksFromHTML=at;exports.getSplitChaiClasses=V;exports.mergeBlocksWithExisting=st;
|
|
1
|
+
"use strict";const T=require("./common-functions-BZmyleS1.cjs"),t=require("lodash-es"),_=require("himalaya"),O=require("@chaibuilder/runtime"),F=require("tailwind-merge"),m="#styles:",J="__ADD_BLOCK_INTERNAL_ROOT",z="@",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,"")}},Y=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"],K={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"}},X=(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=K[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},Z=(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},`}},G=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&&X(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}let b=v(P);typeof b=="string"&&t.startsWith(b,"#styles:")&&(b=b.replace("#styles:","#styles:,")),e[y]=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,...G(a),...q(a),...Z(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}=Q(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 Y(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]}),Q=(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}},tt=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()},et=(s,n)=>t.find(s,{_id:n}),st=(s,n)=>t.isEmpty(n)?s:t.map(s,a=>{const e=et(n,a._id);return e?(e._type==="Icon"&&t.get(a,"icon","").match(/chai-default-svg/)&&delete a.icon,{...e,...a}):a}),at=s=>{const n=_.parse(tt(s));return t.isEmpty(s)?[]:t.flatten(E(n))};function nt(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 rt=t.memoize(s=>{const{baseClasses:n,classes:a}=V(s);return F.twMerge(n,a)});function ot(s,n){return t.get(s,`${n}_attrs`,{})}function lt(s,n=!0){const a={};return Object.keys(s).forEach(e=>{if(t.isString(s[e])&&s[e].startsWith(m)){const i=rt(s[e]),r=ot(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 ct=t.memoize(s=>{const n=O.getRegisteredChaiBlock(s),a=t.get(n,"schema.properties",{});return Object.fromEntries(Object.entries(a).filter(([,e])=>t.get(e,"runtime",!1)))}),pt=(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},ut=(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},dt=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},gt=(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=z;exports.ROOT_TEMP_KEY=J;exports.STYLES_KEY=m;exports.adjustSpacingInContentBlocks=dt;exports.applyBindingToBlockProps=gt;exports.applyChaiDataBinding=ut;exports.applyLanguage=nt;exports.applyLimit=pt;exports.getBlockRuntimeProps=ct;exports.getBlockTagAttributes=lt;exports.getBlocksFromHTML=at;exports.getSplitChaiClasses=V;exports.mergeBlocksWithExisting=st;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { g as nt, c as S } from "./common-functions-BGzDsf1z.js";
|
|
2
|
-
import { isEmpty as f, flatten as rt, flatMapDeep as ot, get as d, set as E, startsWith as k, find as m, startCase as lt, forEach as
|
|
2
|
+
import { isEmpty as f, flatten as rt, flatMapDeep as ot, get as d, set as E, startsWith as k, find as m, startCase as lt, forEach as $, includes as v, has as A, filter as Z, some as ct, map as Q, compact as pt, trim as ut, capitalize as dt, memoize as tt, cloneDeep as q, keys as M, isString as B, isArray as C, last as ht } from "lodash-es";
|
|
3
3
|
import { parse as gt, stringify as N } from "himalaya";
|
|
4
4
|
import { getRegisteredChaiBlock as mt } from "@chaibuilder/runtime";
|
|
5
5
|
import { twMerge as yt } from "tailwind-merge";
|
|
6
6
|
const x = "#styles:", St = "__ADD_BLOCK_INTERNAL_ROOT", Rt = "@", bt = "#", et = (e) => {
|
|
7
7
|
if (e = e.replace(x, ""), !e) return { baseClasses: "", classes: "" };
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
return { baseClasses: "", classes:
|
|
11
|
-
const [t, ...
|
|
8
|
+
const s = e.split(/,(?![^\[]*\])/);
|
|
9
|
+
if (s.length === 1)
|
|
10
|
+
return { baseClasses: "", classes: s[0].trim() };
|
|
11
|
+
const [t, ...a] = s;
|
|
12
12
|
return {
|
|
13
13
|
baseClasses: t.trim(),
|
|
14
|
-
classes:
|
|
14
|
+
classes: a.join(",").trim().replace(/ +(?= )/g, "")
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
@@ -40,20 +40,20 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
40
40
|
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
for (let
|
|
44
|
-
const t = et(`${x}${
|
|
45
|
-
expect(t).toEqual(e[
|
|
43
|
+
for (let s in e) {
|
|
44
|
+
const t = et(`${x}${s}`);
|
|
45
|
+
expect(t).toEqual(e[s]);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
const ft = (e) => {
|
|
50
|
-
const
|
|
51
|
-
return
|
|
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
|
+
return s.test(e) || t.test(e);
|
|
52
52
|
}, xt = (e) => {
|
|
53
53
|
if (f(e)) return e;
|
|
54
|
-
const
|
|
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
|
-
},
|
|
56
|
+
}, at = ["chai-name", "data-chai-name"], _t = {
|
|
57
57
|
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
58
58
|
video: {
|
|
59
59
|
src: "url",
|
|
@@ -89,12 +89,12 @@ const ft = (e) => {
|
|
|
89
89
|
form: {
|
|
90
90
|
action: "action"
|
|
91
91
|
}
|
|
92
|
-
}, kt = (e,
|
|
92
|
+
}, kt = (e, s) => e.children.length === 1 && v(
|
|
93
93
|
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
94
|
-
|
|
95
|
-
), R = (e) => e.map((
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
94
|
+
s._type
|
|
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 = pt(Q(e.split(/\s+/), ut)), t = m(s, (c) => /^w-/.test(c)), a = m(s, (c) => /^h-/.test(c));
|
|
97
|
+
if (!a || !t) return { height: "", width: "" };
|
|
98
98
|
const n = (c) => {
|
|
99
99
|
if (!c) return;
|
|
100
100
|
const g = c.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
|
|
@@ -102,38 +102,38 @@ const ft = (e) => {
|
|
|
102
102
|
if (g[1]) return g[1];
|
|
103
103
|
const i = g[2];
|
|
104
104
|
return /^\d+(\.\d+)?$/.test(i) ? `${Number(i) * 4}px` : i === "auto" || v(i, "%") ? i : "16px";
|
|
105
|
-
}, r = n(t), o = n(
|
|
105
|
+
}, r = n(t), o = n(a);
|
|
106
106
|
return {
|
|
107
107
|
width: v(r, "px") ? r : "16px",
|
|
108
108
|
height: v(o, "px") ? o : "16px"
|
|
109
109
|
};
|
|
110
110
|
}, G = (e) => {
|
|
111
111
|
if (e.tagName === "svg") return {};
|
|
112
|
-
const
|
|
113
|
-
return
|
|
114
|
-
if (!v(
|
|
112
|
+
const s = {}, t = _t[e.tagName] || {}, a = e.attributes;
|
|
113
|
+
return $(a, ({ key: n, value: r }) => {
|
|
114
|
+
if (!v(at, n))
|
|
115
115
|
if (t[n]) {
|
|
116
116
|
if (e.tagName === "img" && n === "src" && !r.startsWith("http")) {
|
|
117
117
|
const o = m(e.attributes, { key: "width" }), c = m(e.attributes, { key: "height" });
|
|
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
|
-
E(
|
|
121
|
-
} else v(["style", "class", "srcset"], n) || (A(
|
|
122
|
-
}), delete
|
|
123
|
-
}, vt = (e,
|
|
124
|
-
if (!e.attributes) return { [
|
|
120
|
+
E(s, t[n], H(r));
|
|
121
|
+
} else v(["style", "class", "srcset"], n) || (A(s, "styles_attrs") || (s.styles_attrs = {}), k(n, "@") && (n = n.replace("@", "x-on:")), s.styles_attrs[`${n}`] = H(r));
|
|
122
|
+
}), delete s.class, s;
|
|
123
|
+
}, vt = (e, s = "styles") => {
|
|
124
|
+
if (!e.attributes) return { [s]: `${x},` };
|
|
125
125
|
const t = m(e.attributes, { key: "class" });
|
|
126
126
|
if (t) {
|
|
127
|
-
const
|
|
128
|
-
return { [
|
|
127
|
+
const a = t.value;
|
|
128
|
+
return { [s]: `${x},${a}` };
|
|
129
129
|
}
|
|
130
|
-
return { [
|
|
130
|
+
return { [s]: `${x},` };
|
|
131
131
|
}, wt = (e) => {
|
|
132
|
-
const
|
|
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
|
-
), o =
|
|
134
|
+
), o = s.find(
|
|
135
135
|
(i) => i.key === "data-chai-dropdown-content" || i.key === "chai-dropdown-content"
|
|
136
|
-
), c =
|
|
136
|
+
), c = s.find((i) => i.key === "class"), g = c && c.value.split(/\s+/).includes("rte");
|
|
137
137
|
if (n)
|
|
138
138
|
return { _type: "Dropdown" };
|
|
139
139
|
if (r)
|
|
@@ -142,7 +142,7 @@ const ft = (e) => {
|
|
|
142
142
|
return { _type: "DropdownContent" };
|
|
143
143
|
if (t || g)
|
|
144
144
|
return { _type: "Paragraph" };
|
|
145
|
-
if (
|
|
145
|
+
if (a)
|
|
146
146
|
return { _type: "LightBoxLink" };
|
|
147
147
|
switch (e.tagName) {
|
|
148
148
|
// self closing tags
|
|
@@ -230,25 +230,25 @@ const ft = (e) => {
|
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
}, j = (e,
|
|
233
|
+
}, j = (e, s = null) => ot(e, (t) => {
|
|
234
234
|
var P, J, O, z, V, W, F, U, Y, K;
|
|
235
235
|
if (t.type === "comment") return [];
|
|
236
|
-
let
|
|
237
|
-
if (
|
|
238
|
-
return f(d(t, "content", "")) ? [] :
|
|
236
|
+
let a = { _id: nt() };
|
|
237
|
+
if (s && (a._parent = s.block._id), t.type === "text")
|
|
238
|
+
return f(d(t, "content", "")) ? [] : s && kt(s.node, s.block) ? (E(s, "block.content", d(t, "content", "")), []) : { ...a, _type: "Text", content: d(t, "content", "") };
|
|
239
239
|
if (k(t.tagName, "chai-")) {
|
|
240
240
|
const l = t.attributes, p = m(l, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || lt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
|
|
241
|
-
|
|
241
|
+
a._type = u, $(l, ({ key: b, value: X }) => {
|
|
242
242
|
if (b === "about-this-component" || b === "chai-type" || b === "can-move" || b === "can-delete") return;
|
|
243
243
|
if (b === "id") {
|
|
244
|
-
|
|
244
|
+
a._id = X;
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
let I = H(X);
|
|
248
|
-
typeof I == "string" && k(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")),
|
|
248
|
+
typeof I == "string" && k(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")), a[b] = I;
|
|
249
249
|
});
|
|
250
|
-
const h = j(t.children, { block:
|
|
251
|
-
return [
|
|
250
|
+
const h = j(t.children, { block: a, node: t });
|
|
251
|
+
return [a, ...h];
|
|
252
252
|
}
|
|
253
253
|
const n = d(t, "attributes", []), r = n.find(
|
|
254
254
|
(l) => l.key === "data-chai-richtext" || l.key === "chai-richtext"
|
|
@@ -261,17 +261,17 @@ const ft = (e) => {
|
|
|
261
261
|
), D = n.find(
|
|
262
262
|
(l) => l.key === "data-chai-dropdown-content" || l.key === "chai-dropdown-content"
|
|
263
263
|
);
|
|
264
|
-
if (
|
|
265
|
-
...
|
|
264
|
+
if (a = {
|
|
265
|
+
...a,
|
|
266
266
|
...wt(t),
|
|
267
267
|
...G(t),
|
|
268
268
|
...vt(t)
|
|
269
269
|
}, t.attributes) {
|
|
270
|
-
const l = t.attributes.find((p) => v(
|
|
271
|
-
l && (
|
|
270
|
+
const l = t.attributes.find((p) => v(at, p.key));
|
|
271
|
+
l && (a._name = l.value);
|
|
272
272
|
}
|
|
273
273
|
if (r || c)
|
|
274
|
-
return
|
|
274
|
+
return a.content = N(t.children), A(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], A(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
|
|
275
275
|
if (g) {
|
|
276
276
|
const l = [
|
|
277
277
|
"data-chai-lightbox",
|
|
@@ -283,22 +283,22 @@ const ft = (e) => {
|
|
|
283
283
|
"data-gall",
|
|
284
284
|
"href"
|
|
285
285
|
];
|
|
286
|
-
|
|
287
|
-
...
|
|
286
|
+
a = {
|
|
287
|
+
...a,
|
|
288
288
|
href: ((P = n.find((p) => p.key === "href")) == null ? void 0 : P.value) || "",
|
|
289
289
|
hrefType: ((J = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : J.value) || "video",
|
|
290
290
|
autoplay: ((O = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : O.value) === "true" ? "true" : "false",
|
|
291
291
|
maxWidth: ((V = (z = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : z.value) == null ? void 0 : V.replace("px", "")) || "",
|
|
292
292
|
backdropColor: ((W = n.find((p) => p.key === "data-overlay")) == null ? void 0 : W.value) || "",
|
|
293
293
|
galleryName: ((F = n.find((p) => p.key === "data-gall")) == null ? void 0 : F.value) || ""
|
|
294
|
-
},
|
|
295
|
-
A(
|
|
294
|
+
}, $(l, (p) => {
|
|
295
|
+
A(a, `styles_attrs.${p}`) && delete a.styles_attrs[p];
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
|
-
if (i && (delete
|
|
299
|
-
delete
|
|
298
|
+
if (i && (delete a.styles_attrs, a.showDropdown = !1), D && delete a.styles_attrs, w) {
|
|
299
|
+
delete a.styles_attrs;
|
|
300
300
|
const l = Z(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
|
|
301
|
-
|
|
301
|
+
a.content = R(l);
|
|
302
302
|
const p = m(
|
|
303
303
|
t.children || [],
|
|
304
304
|
(u) => (u == null ? void 0 : u.tagName) === "span" && ct(u.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
|
|
@@ -306,179 +306,179 @@ const ft = (e) => {
|
|
|
306
306
|
if (p) {
|
|
307
307
|
const u = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
|
|
308
308
|
if (u) {
|
|
309
|
-
|
|
309
|
+
a.icon = N([u]);
|
|
310
310
|
const { height: h, width: b } = Tt(u, "16px", "16px");
|
|
311
|
-
|
|
311
|
+
a.iconHeight = h, a.iconWidth = b;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
return [
|
|
314
|
+
return [a];
|
|
315
315
|
}
|
|
316
|
-
if (
|
|
317
|
-
const l =
|
|
318
|
-
l === "checkbox" ? E(
|
|
316
|
+
if (a._type === "Input") {
|
|
317
|
+
const l = a.inputType || "text";
|
|
318
|
+
l === "checkbox" ? E(a, "_type", "Checkbox") : l === "radio" && E(a, "_type", "Radio");
|
|
319
319
|
} else if (t.tagName === "video" || t.tagName === "iframe") {
|
|
320
320
|
const l = N([t]);
|
|
321
|
-
return ft(l) && (E(
|
|
321
|
+
return ft(l) && (E(a, "_type", "Video"), E(a, "url", xt(l)), E(a, "styles", `${x},`), E(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = l, [a];
|
|
322
322
|
} else if (t.tagName === "svg") {
|
|
323
|
-
const l = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } =
|
|
323
|
+
const l = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = st(l);
|
|
324
324
|
if (p && u)
|
|
325
|
-
|
|
325
|
+
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
326
|
else {
|
|
327
327
|
const h = (U = m(t.attributes, { key: "height" })) == null ? void 0 : U.value, b = (Y = m(t.attributes, { key: "width" })) == null ? void 0 : Y.value;
|
|
328
|
-
h && b ? (
|
|
328
|
+
h && b ? (a.styles = `${x}, ${S(`w-[${b}px] h-[${h}px]`, l)}`.trim(), a.height = h, a.width = b) : a.styles = `${x}, ${S("w-full h-full", l)}`.trim();
|
|
329
329
|
}
|
|
330
|
-
return t.attributes = Z(t.attributes, (h) => !v(["style", "width", "height", "class"], h.key)),
|
|
331
|
-
} else if (t.tagName == "option" &&
|
|
332
|
-
return
|
|
330
|
+
return t.attributes = Z(t.attributes, (h) => !v(["style", "width", "height", "class"], h.key)), a.icon = N([t]), [a];
|
|
331
|
+
} else if (t.tagName == "option" && s && ((K = s.block) == null ? void 0 : K._type) === "Select")
|
|
332
|
+
return s.block.options.push({
|
|
333
333
|
label: R(t.children),
|
|
334
334
|
...G(t)
|
|
335
335
|
}), [];
|
|
336
|
-
const T = j(t.children, { block:
|
|
337
|
-
return [
|
|
338
|
-
}), Tt = (e,
|
|
336
|
+
const T = j(t.children, { block: a, node: t });
|
|
337
|
+
return [a, ...T];
|
|
338
|
+
}), Tt = (e, s, t) => {
|
|
339
339
|
var g, i;
|
|
340
|
-
const
|
|
341
|
-
d(m(
|
|
340
|
+
const a = d(e, "attributes", []), { height: n, width: r } = st(
|
|
341
|
+
d(m(a, { key: "class" }), "value", "")
|
|
342
342
|
);
|
|
343
343
|
if (n && r)
|
|
344
344
|
return {
|
|
345
345
|
height: `[${n}px]`,
|
|
346
346
|
width: `[${r}px]`
|
|
347
347
|
};
|
|
348
|
-
const o = (g = m(
|
|
348
|
+
const o = (g = m(a, { key: "height" })) == null ? void 0 : g.value, c = (i = m(a, { key: "width" })) == null ? void 0 : i.value;
|
|
349
349
|
return {
|
|
350
350
|
height: o ? `[${o}px]` : t,
|
|
351
|
-
width: c ? `[${c}px]` :
|
|
351
|
+
width: c ? `[${c}px]` : s
|
|
352
352
|
};
|
|
353
353
|
}, Et = (e) => {
|
|
354
|
-
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (
|
|
354
|
+
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, n, r) => {
|
|
355
355
|
let o = r.replace(/\\"/g, '"');
|
|
356
356
|
return o = o.replace(/{([^}]+)}/g, (c) => c.replace(/"/g, '\\"')), `${n}="${o.replace(/\\"/g, '"')}"`;
|
|
357
357
|
}), 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
|
-
const
|
|
359
|
-
return (
|
|
360
|
-
},
|
|
361
|
-
const
|
|
362
|
-
return
|
|
358
|
+
const s = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
359
|
+
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
|
+
}, $t = (e, s) => m(e, { _id: s }), Ht = (e, s) => f(s) ? e : Q(e, (t) => {
|
|
361
|
+
const a = $t(s, t._id);
|
|
362
|
+
return a ? (a._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon, { ...a, ...t }) : t;
|
|
363
363
|
}), jt = (e) => {
|
|
364
|
-
const
|
|
365
|
-
return f(e) ? [] : rt(j(
|
|
364
|
+
const s = gt(Et(e));
|
|
365
|
+
return f(e) ? [] : rt(j(s));
|
|
366
366
|
};
|
|
367
|
-
function qt(e,
|
|
368
|
-
const
|
|
369
|
-
if (f(
|
|
367
|
+
function qt(e, s, t) {
|
|
368
|
+
const a = d(t, "i18nProps", []);
|
|
369
|
+
if (f(s) || f(a)) return e;
|
|
370
370
|
const n = q(e);
|
|
371
|
-
return
|
|
372
|
-
if (v(
|
|
373
|
-
const o = d(n, r), c = d(n, `${r}-${
|
|
374
|
-
|
|
371
|
+
return $(M(n), (r) => {
|
|
372
|
+
if (v(a, r) && !f(s)) {
|
|
373
|
+
const o = d(n, r), c = d(n, `${r}-${s}`, "");
|
|
374
|
+
B(o) ? n[r] = B(c) && !f(c.trim()) && c.trimStart() || o : n[r] = f(c) ? o : c;
|
|
375
375
|
}
|
|
376
376
|
}), n;
|
|
377
377
|
}
|
|
378
|
-
const
|
|
379
|
-
const { baseClasses:
|
|
380
|
-
return yt(
|
|
378
|
+
const Bt = tt((e) => {
|
|
379
|
+
const { baseClasses: s, classes: t } = et(e);
|
|
380
|
+
return yt(s, t);
|
|
381
381
|
});
|
|
382
|
-
function It(e,
|
|
383
|
-
return d(e, `${
|
|
382
|
+
function It(e, s) {
|
|
383
|
+
return d(e, `${s}_attrs`, {});
|
|
384
384
|
}
|
|
385
|
-
function Mt(e,
|
|
385
|
+
function Mt(e, s = !0) {
|
|
386
386
|
const t = {};
|
|
387
|
-
return Object.keys(e).forEach((
|
|
388
|
-
if (
|
|
389
|
-
const n =
|
|
390
|
-
t[
|
|
387
|
+
return Object.keys(e).forEach((a) => {
|
|
388
|
+
if (B(e[a]) && e[a].startsWith(x)) {
|
|
389
|
+
const n = Bt(e[a]), r = It(e, a);
|
|
390
|
+
t[a] = {
|
|
391
391
|
...!f(n) && { className: n },
|
|
392
392
|
...r,
|
|
393
|
-
...
|
|
394
|
-
"data-style-prop":
|
|
393
|
+
...s ? {
|
|
394
|
+
"data-style-prop": a,
|
|
395
395
|
"data-block-parent": e._id,
|
|
396
|
-
"data-style-id": `${
|
|
396
|
+
"data-style-id": `${a}-${e._id}`
|
|
397
397
|
} : {}
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
400
|
}), t;
|
|
401
401
|
}
|
|
402
402
|
const Pt = tt((e) => {
|
|
403
|
-
const
|
|
404
|
-
return Object.fromEntries(Object.entries(t).filter(([,
|
|
405
|
-
}), Jt = (e,
|
|
403
|
+
const s = mt(e), t = d(s, "schema.properties", {});
|
|
404
|
+
return Object.fromEntries(Object.entries(t).filter(([, a]) => d(a, "runtime", !1)));
|
|
405
|
+
}), Jt = (e, s) => {
|
|
406
406
|
if (!C(e)) return e;
|
|
407
|
-
let t = e,
|
|
408
|
-
return typeof
|
|
409
|
-
}, Ot = (e,
|
|
407
|
+
let t = e, a;
|
|
408
|
+
return typeof s.limit == "number" && s.limit > 0 && (a = s.limit), a !== void 0 && (t = t.slice(0, a)), t;
|
|
409
|
+
}, Ot = (e, s) => {
|
|
410
410
|
const t = q(e);
|
|
411
|
-
return
|
|
412
|
-
if (
|
|
413
|
-
let n = t[
|
|
414
|
-
|
|
411
|
+
return $(M(t), (a) => {
|
|
412
|
+
if (B(t[a]) && !k(a, "_")) {
|
|
413
|
+
let n = t[a];
|
|
414
|
+
a === "repeaterItems" && (t.repeaterItemsBinding = n);
|
|
415
415
|
const r = /\{\{(.*?)\}\}/g, o = n.match(r);
|
|
416
416
|
o && o.forEach((c) => {
|
|
417
417
|
let g = c.slice(2, -2);
|
|
418
|
-
const i = d(
|
|
418
|
+
const i = d(s, g, c);
|
|
419
419
|
n = C(i) ? i : n.replace(c, i);
|
|
420
|
-
}), t[
|
|
420
|
+
}), t[a] = n;
|
|
421
421
|
}
|
|
422
422
|
}), t;
|
|
423
423
|
}, _ = (e) => {
|
|
424
|
-
const
|
|
424
|
+
const s = ht(e);
|
|
425
425
|
return e.map((t) => {
|
|
426
|
-
const
|
|
427
|
-
for (let n = 0; n <
|
|
428
|
-
if (
|
|
429
|
-
const r = t ===
|
|
430
|
-
t[
|
|
426
|
+
const a = Object.keys(t);
|
|
427
|
+
for (let n = 0; n < a.length; n++)
|
|
428
|
+
if (B(t[a[n]]) && k(a[n], "content")) {
|
|
429
|
+
const r = t === s ? "" : " ";
|
|
430
|
+
t[a[n]] = `${t[a[n]].trim()}${r}`;
|
|
431
431
|
}
|
|
432
432
|
return t;
|
|
433
433
|
});
|
|
434
434
|
};
|
|
435
435
|
if (import.meta.vitest) {
|
|
436
|
-
const { describe: e, it:
|
|
436
|
+
const { describe: e, it: s, expect: t } = import.meta.vitest;
|
|
437
437
|
e("adjustSpacingInContentBlocks", () => {
|
|
438
|
-
|
|
438
|
+
s("should add space after content fields except for the last block", () => {
|
|
439
439
|
const n = _([
|
|
440
440
|
{ _id: "1", _type: "Text", content: "First" },
|
|
441
441
|
{ _id: "2", _type: "Text", content: "Second" },
|
|
442
442
|
{ _id: "3", _type: "Text", content: "Third" }
|
|
443
443
|
]);
|
|
444
444
|
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second "), t(n[2].content).toBe("Third");
|
|
445
|
-
}),
|
|
445
|
+
}), s("should trim whitespace from content before adding space", () => {
|
|
446
446
|
const n = _([
|
|
447
447
|
{ _id: "1", _type: "Text", content: " First " },
|
|
448
448
|
{ _id: "2", _type: "Text", content: " Second " }
|
|
449
449
|
]);
|
|
450
450
|
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second");
|
|
451
|
-
}),
|
|
451
|
+
}), s("should handle multiple content fields in a single block", () => {
|
|
452
452
|
const n = _([
|
|
453
453
|
{ _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
|
|
454
454
|
{ _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
|
|
455
455
|
]);
|
|
456
456
|
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
|
-
}),
|
|
457
|
+
}), s("should only process fields that start with 'content'", () => {
|
|
458
458
|
const n = _([
|
|
459
459
|
{ _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
|
|
460
460
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
461
461
|
]);
|
|
462
462
|
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
|
-
}),
|
|
463
|
+
}), s("should handle empty array", () => {
|
|
464
464
|
const n = _([]);
|
|
465
465
|
t(n).toEqual([]);
|
|
466
|
-
}),
|
|
466
|
+
}), s("should handle single block", () => {
|
|
467
467
|
const n = _([{ _id: "1", _type: "Text", content: "Only" }]);
|
|
468
468
|
t(n[0].content).toBe("Only");
|
|
469
|
-
}),
|
|
469
|
+
}), s("should handle blocks without content fields", () => {
|
|
470
470
|
const n = _([
|
|
471
471
|
{ _id: "1", _type: "Container", title: "Title" },
|
|
472
472
|
{ _id: "2", _type: "Container", name: "Name" }
|
|
473
473
|
]);
|
|
474
474
|
t(n[0].title).toBe("Title"), t(n[1].name).toBe("Name");
|
|
475
|
-
}),
|
|
475
|
+
}), s("should handle blocks with non-string content fields", () => {
|
|
476
476
|
const n = _([
|
|
477
477
|
{ _id: "1", _type: "Text", content: "Text", contentNum: 123 },
|
|
478
478
|
{ _id: "2", _type: "Text", content: "Last", contentBool: !0 }
|
|
479
479
|
]);
|
|
480
480
|
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
|
-
}),
|
|
481
|
+
}), s("should handle empty string content", () => {
|
|
482
482
|
const n = _([
|
|
483
483
|
{ _id: "1", _type: "Text", content: "" },
|
|
484
484
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
@@ -487,33 +487,33 @@ if (import.meta.vitest) {
|
|
|
487
487
|
});
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
|
-
const y = (e,
|
|
491
|
-
if (
|
|
490
|
+
const y = (e, s, { index: t, key: a }, n) => {
|
|
491
|
+
if (B(e)) {
|
|
492
492
|
let r = e;
|
|
493
493
|
const o = /\{\{(.*?)\}\}/g, c = e.match(o);
|
|
494
494
|
if (c) {
|
|
495
495
|
const g = n === "image" || n === "mobileImage";
|
|
496
496
|
c.forEach((i) => {
|
|
497
|
-
let w = i.slice(2, -2).trim(), D =
|
|
497
|
+
let w = i.slice(2, -2).trim(), D = a.slice(2, -2).trim();
|
|
498
498
|
t !== -1 && k(w, "$index.") ? w = `${D}.${t}.${w.slice(7)}` : t !== -1 && k(w, "$index") && (w = `${D}.${t}`);
|
|
499
|
-
const T = d(
|
|
499
|
+
const T = d(s, w);
|
|
500
500
|
T === void 0 ? r = r.replace(i, "") : g && !C(T) ? r = T : r = C(T) ? T : r.replace(i, T);
|
|
501
501
|
});
|
|
502
502
|
}
|
|
503
503
|
return r;
|
|
504
504
|
}
|
|
505
505
|
if (C(e))
|
|
506
|
-
return e.map((r) => y(r,
|
|
506
|
+
return e.map((r) => y(r, s, { index: t, key: a }, n));
|
|
507
507
|
if (e && typeof e == "object") {
|
|
508
508
|
const r = {};
|
|
509
|
-
return
|
|
510
|
-
!k(o, "_") && o !== "$repeaterItemsKey" ? r[o] = y(e[o],
|
|
509
|
+
return $(M(e), (o) => {
|
|
510
|
+
!k(o, "_") && o !== "$repeaterItemsKey" ? r[o] = y(e[o], s, { index: t, key: a }, o) : r[o] = e[o];
|
|
511
511
|
}), r;
|
|
512
512
|
}
|
|
513
513
|
return e;
|
|
514
|
-
}, L = (e,
|
|
514
|
+
}, L = (e, s, { index: t, key: a }) => {
|
|
515
515
|
let n = q(e);
|
|
516
|
-
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, k(n.repeaterItems, `{{${bt}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !f(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), y(n,
|
|
516
|
+
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, k(n.repeaterItems, `{{${bt}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !f(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), y(n, s, { index: t, key: a });
|
|
517
517
|
};
|
|
518
518
|
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
519
519
|
it("should handle string values with bindings", () => {
|
|
@@ -547,11 +547,11 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
547
547
|
const t = y("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
|
|
548
548
|
expect(t).toBe("Hello ");
|
|
549
549
|
}), it("should preserve private properties starting with _", () => {
|
|
550
|
-
const
|
|
550
|
+
const s = y({
|
|
551
551
|
name: "John",
|
|
552
552
|
_private: "secret"
|
|
553
553
|
}, {}, { index: -1, key: "" });
|
|
554
|
-
expect(
|
|
554
|
+
expect(s).toEqual({
|
|
555
555
|
name: "John",
|
|
556
556
|
_private: "secret"
|
|
557
557
|
});
|