@sitecore-feaas/clientside 0.6.3-alpha.1 → 0.6.3-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/FEAASComponent.js +2 -0
- package/build/components/FEAASComponent.js.map +1 -1
- package/build/dom/component.js +2 -0
- package/build/dom/component.js.map +1 -1
- package/build/dom/html.js +2 -0
- package/build/dom/html.js.map +1 -1
- package/build/ui/react.js +2 -0
- package/build/ui/react.js.map +1 -1
- package/dist/browser/headless.cjs +6 -6
- package/dist/browser/headless.cjs.map +2 -2
- package/dist/browser/headless.esm.js +6 -6
- package/dist/browser/headless.esm.js.map +1 -1
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.cjs.map +2 -2
- package/dist/browser/index.esm.js +1 -1
- package/dist/browser/index.esm.js.map +1 -1
- package/dist/browser/react.cjs +6 -6
- package/dist/browser/react.cjs.map +2 -2
- package/dist/browser/react.esm.js +5 -5
- package/dist/browser/react.esm.js.map +1 -1
- package/dist/node/headless.cjs +1 -1
- package/dist/node/headless.cjs.map +2 -2
- package/dist/node/headless.esm.js +1 -1
- package/dist/node/headless.esm.js.map +2 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +2 -2
- package/dist/node/index.esm.js +1 -1
- package/dist/node/index.esm.js.map +2 -2
- package/dist/node/react.cjs +3 -3
- package/dist/node/react.cjs.map +2 -2
- package/dist/node/react.esm.js +3 -3
- package/dist/node/react.esm.js.map +2 -2
- package/headless.cjs +1 -1
- package/headless.cjs.map +2 -2
- package/headless.js +1 -1
- package/headless.js.map +2 -2
- package/package.json +1 -1
- package/react.cjs +6 -6
- package/react.cjs.map +2 -2
- package/react.js +6 -6
- package/react.js.map +2 -2
- package/src/components/FEAASComponent.tsx +2 -0
- package/src/dom/component.ts +3 -0
- package/src/dom/html.ts +2 -0
- package/src/ui/react.tsx +3 -0
- package/types/components/FEAASComponent.d.ts.map +1 -1
- package/types/dom/component.d.ts.map +1 -1
- package/types/dom/html.d.ts.map +1 -1
- package/types/ui/FEAASContext.d.ts +1 -1
- package/types/ui/FEAASEditor.d.ts +1 -1
- package/types/ui/FEAASPicker.d.ts +1 -1
- package/types/ui/react.d.ts +1 -0
- package/types/ui/react.d.ts.map +1 -1
|
@@ -4,7 +4,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4
4
|
`).trim();if(typeof t=="string")return t;if(t==null)return"";switch(t.type){case"heading":let{level:r,...n}=t.attrs;return $t(t.content,n,"h"+r);case"text":return(t.marks||[]).reduce((i,o)=>$t(i,o.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[o.type]),(e=t.text)===null||e===void 0?void 0:e.replace(/\s+/," "));default:return $t(t.content||t.text,t.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[t.type])}}var j=class{constructor(e,r=1,n){this.ownerDocument={createElement(i){return new j(i)},createDocumentFragment(){return new j(null,11)}},this.nodeName=e,this.nodeType=r,this.textContent=n,this.attributes=[],this.childNodes=[]}setAttribute(e,r){let n=this.attributes.find(i=>i.name===e);n?n.value=r:this.attributes.push({name:e,value:r})}getAttribute(e){let r=this.attributes.find(n=>n.name===e);return r?r.value:void 0}insertBefore(e,r){if(e.parentNode=this,r===null)this.childNodes.push(e);else{let n=this.childNodes.indexOf(r);n!==-1&&this.childNodes.splice(n,0,e)}}removeAttribute(e){let r=this.attributes.findIndex(n=>n.name===e);r!==-1&&this.attributes.splice(r,1)}appendChild(e){e.parentNode=this,this.childNodes.push(e)}get tagName(){var e;return(e=this.nodeName)===null||e===void 0?void 0:e.toUpperCase()}get localName(){var e;return(e=this.nodeName)===null||e===void 0?void 0:e.toLowerCase()}get innerHTML(){return It(this.childNodes)}set innerHTML(e){this.childNodes=Ut(String(e!=null?e:""))}get outerHTML(){return It([this])}get children(){return this.childNodes.filter(e=>e.nodeType==1)}closest(e){let r=this;for(;r;){if(re(e,r))return r;r=r.parentNode}return null}querySelectorAll(e){let r=e.split(/\s*,\s*/),n=[],i=o=>{for(let s of r)if(re(s,o)){n.push(o);break}for(let s of o.childNodes)i(s)};for(let o of this.childNodes)i(o);return n}querySelector(e){return this.querySelectorAll(e)[0]}findSibling(e,r){if(!this.parentNode)return null;let n=this.parentNode.childNodes,i=n.indexOf(this);if(i===-1)return null;for(let o=i+e;o>=0&&o<n.length;o+=e){let s=n[o];if(!r||s.nodeType===1)return s}return null}removeChild(e){let r=this.childNodes.indexOf(e);if(r!==-1)return this.childNodes.splice(r,1),e.parentNode=void 0,e}get previousSibling(){return this.findSibling(-1)}get nextSibling(){return this.findSibling(1)}get previousElementSibling(){return this.findSibling(-1,!0)}get nextElementSibling(){return this.findSibling(1,!0)}cloneNode(e=!1){let r=new j(this.nodeName,this.nodeType);if(r.attributes=JSON.parse(JSON.stringify(this.attributes)),this.textContent&&(r.textContent=this.textContent),e)for(let n of this.childNodes){let i=n.cloneNode(!0);r.appendChild(i)}return r}get parentElement(){var e;return((e=this.parentNode)===null||e===void 0?void 0:e.nodeType)==1?this.parentNode:null}};function re(t,e){let r=t.match(/([.#]?[\w-]+|\[([\w-]+)(="([^"]*)")?\])/g);if(!r)return!1;for(let n of r)if(n.startsWith("#")){if(e.getAttribute("id")!==n.slice(1))return!1}else if(n.startsWith(".")){if(!(e.getAttribute("class")||"").split(" ").includes(n.slice(1)))return!1}else if(n.startsWith("[")){let i=n.match(/^\[([\w-]+)(="([^"]*)")?\]$/);if(i){let o=i[1],s=i[3],a=e.getAttribute(o);if(typeof s=="undefined"){if(a===void 0)return!1}else if(a!==s)return!1}else return!1}else if(e.nodeName!==n)return!1;return!0}function Ut(t){var e;let r=[],n=[];for(;t;){let i=t.match(/^<([\w-]+)(\s[^>]*)?>/),o=t.match(/^<\/([\w-]+)>/);if(i){let s=i[1].toLowerCase(),l=((e=(i[2]||"").match(/([\w-]+)(="([^"]*)")?/g))===null||e===void 0?void 0:e.map(u=>{let[c,h,,f]=u.match(/([\w-]+)(="([^"]*)")?/);return{name:h,value:Qe(f||"")}}))||[],d=new j(s,1);if(d.attributes=l,n.length>0){let u=n[n.length-1];u.childNodes.push(d),d.parentNode=u}else r.push(d);["img","input","br"].includes(s)||n.push(d),t=t.slice(i[0].length)}else if(o)n.pop(),t=t.slice(o[0].length);else{let s=t.indexOf("<"),a=t.slice(0,s!==-1?s:void 0),l=new j("#text",3);if(l.textContent=a,n.length>0){let d=n[n.length-1];d.childNodes.push(l),l.parentNode=d}else r.push(l);t=t.slice(a.length)}}return r}function Ye(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Qe(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'")}function It(t){return t.map(e=>{if(e.nodeType===3)return e.textContent||"";let{nodeName:r,attributes:n}=e,i=n.map(({name:s,value:a})=>` ${s}="${Ye(String(a))}"`).join(""),o=It(e.childNodes);return["img","input","br"].includes(r)?`<${r}${i} />`:`<${r}${i}>${o}</${r}>`}).join("")}function ne(t){let e=new t.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(n=>{let i=n.target,o=i.getAttribute("data-embed-src");o&&dt(i,o),n.addedNodes&&n.addedNodes.forEach(s=>{s.nodeType==1&&ie(s,!1)})})});return e.observe(t,{attributes:!0,subtree:!0,childList:!0}),e}function ie(t,e=!0){let r=t.querySelectorAll("[data-embed-src]");for(var n=0;n<r.length;n++){let i=r[n];dt(i,i.getAttribute("data-embed-src"))}if(e)return ne(t)}function dt(t,e){for(var r=t;r;r=r.parentElement)if(!r.parentElement){let i=r.querySelectorAll("script");for(var n=0;n<i.length;n++)if(i[n].getAttribute("src")==e)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let o=r.ownerDocument.createElement("script");o.setAttribute("type","module"),o.setAttribute("src",e),r.appendChild(o);break}}var St={};ot(St,{adjustNumbers:()=>le,cleanCollectionBit:()=>ut,getHumanizedLabel:()=>de,getLastPathBit:()=>ue,getQualifier:()=>ae,normalizeCollectionScope:()=>Ct,parseLimit:()=>oe,parseRange:()=>se});var oe=t=>{var e;let r=parseInt((e=t==null?void 0:t.match(/\[0:(\d+)\]/))===null||e===void 0?void 0:e[1],10);return!isNaN(r)&&r>0?String(r):null},se=t=>{var e;let r=(e=t==null?void 0:t.match(/\[([^\]]+)\]/))===null||e===void 0?void 0:e[1].split(/\s*,\s*/g).filter(Boolean).map(n=>{if(n.match(/^-?\d+$/))return n;let i=n.match(/^(\d+):(\d+)$/);return i&&parseInt(i[1],10)<parseInt(i[2],10)?i[1]+"-"+i[2]:null});return r!=null&&r.every(Boolean)?r.join(","):null},ae=t=>{var e;return(e=t==null?void 0:t.match(/(\.\*|\[[^\]]*\])$/))===null||e===void 0?void 0:e[0]};function ut(t){return t.replace(/(\.?\[[^\]\[]*\]|\.\*)$/g,"")}function Ct(t){return ut(t)+".*"}function le(t,e){return t==null?void 0:t.replace(/(.|^)(\d+)/g,(r,n,i)=>n+(n==":"?i:String(parseInt(i)+e)))}function de(t,e=2){var r=ut(t).split(/]\.|\.\*\./g).pop().split(/\./g).slice(-3);return r=r.filter(n=>isNaN(parseInt(n))),r.map(n=>n.charAt(0).toUpperCase()+n.slice(1)).slice(-e).join(" ")}function ue(t){return ut(t).split(".").pop()}var Ze=["January","February","March","April","May","June","July","August","September","October","November","December"],ce=t=>{if(!t||typeof t.getDay!="function")return;let e=t.getFullYear(),r=Ze[t.getMonth()],n=t.getDate();return`${r} ${n}, ${e}`},he=function(t){return String(new Date(t))!=="Invalid Date"&&!isNaN(Number(new Date(t)))};function pe(t){let e=t.getAttribute("data-path-scope");for(var r=0,n=t;n=n.previousElementSibling;)n.getAttribute("data-path-scope")==e&&r++;return r}function tr(t,e,r){let n=t.getAttribute("data-path-scope");if(n==null)return;var i=pe(t);if(i!=0)return;let o=t.parentNode;if(o!=null){e==0?t.setAttribute("hidden","hidden"):t.getAttribute("hidden")!=null&&t.removeAttribute("hidden");for(var s=i+1,a=t,l=t;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==n&&(s++,a=l);for(var d=s;d<e;d++)o.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var d=Math.max(1,e);d<s;d++)a=a.previousElementSibling,o.removeChild(a.nextElementSibling)}}function I(t,e,r,n,i=!0){var o,s,a;if(!t)return;var l=t;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=H(r)),n!=null&&n.processValue&&(r=n==null?void 0:n.processValue(t,e,r));var d=e.replace("data-path-","");if(e=="data-path-src"||e=="data-path-alt"){let b=Array.from(t.children).find(_=>_.localName=="picture")||t;l=t.localName=="img"?t:b.querySelector("img, video")}else if(e=="data-path-href")l=t.querySelector("a")||t.closest("a");else if(e=="data-path-hidden")r=r?null:!0;else if(e=="data-path"||e=="data-embed-html"||e=="html")d="innerHTML";else if(e=="data-embed-src"&&i)dt(t,r);else if(e=="data-path-attributes"){if(!Array.isArray(r)){let b=((o=t.getAttribute("data-attributes-keys"))===null||o===void 0?void 0:o.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var u in r){var c=r[u];I(t,u,typeof c=="object"&&c?JSON.stringify(c):c,n,i)}for(var h=0;h<b.length;h++)(r==null||!(b[h]in r))&&I(t,b[h],null,n,i);I(t,"data-attributes-keys",Object.keys(r||{}).join(","),{},i)}if(t.tagName=="FEAAS-EXTERNAL"){let b=String(t.getAttribute("data-path-attributes")||"").slice(0,-1).split(".")[0]||"_";I(t,"datasources",JSON.stringify({[b]:r}),{},i)}return}if(typeof r=="boolean"&&(r=r?"":null),!l)return;let f=d=="innerHTML"||d=="src";if(console.log("debug set dom",t,e,d,r,f),f&&(r==null||r==="")){var p=String((a=(s=t.getAttribute("data-path-placeholder")||l[d])!==null&&s!==void 0?s:l.getAttribute(d))!==null&&a!==void 0?a:"");d=="innerHTML"?l.innerHTML=p:p?(console.log("set with empty value placeholder",e,d,p),l.setAttribute(d,p)):l.removeAttribute(d)}else if(r!=null)if(d=="innerHTML"){for(var v=String(r),y=l;y.parentElement&&y.localName.match(/^(a|var|strong|em|i|b)$/);)y=y.parentElement;y.localName.match(/p|h\d|button|time|li/)&&(v=v.replace(/<(p|h\d|li|ul)[^>]*?>|<\/(p|h\d|li|ul)[^>]*?>/g," ").trim().replace(/\s+/g," ")),String(y.getAttribute("class")).includes("-inline--time")&&he(v)&&(v=ce(new Date(v))),l.innerHTML!=v&&(l.innerHTML=v)}else l.getAttribute(d)!=r&&(console.log("set with value",e,d),l.setAttribute(d,r));else l.removeAttribute(d)}var fe=["data-attributes-keys","data-path-attributes","data-path-scope"];function F(t,e,r,n,i=!0){var o,s,a;let l=t;if(n||(e=((o=r==null?void 0:r.processData)===null||o===void 0?void 0:o.call(r,l,e))||e),l.nodeType==1){let c=l.getAttribute("data-path-scope");if(c){let f=pe(l),p=X(e,c,!1);f==0&&tr(l,((s=r==null?void 0:r.shouldRepeat)===null||s===void 0?void 0:s.call(r,l,p))===!1?1:p.length,r),e={...e,[Ct(c)]:p[f]}}let h=Array.prototype.slice.call(l.attributes).sort((f,p)=>fe.indexOf(f.name)-fe.indexOf(p.name));for(var d=0;d<h.length;d++){let{name:f,value:p}=h[d];f.startsWith("data-path")&&f!="data-path-scope"&&(console.log("debug entry",f,X(e,p,!0,void 0,l.tagName!="FEAAS-EXTERNAL")),I(l,f,X(e,p,!0,void 0,l.tagName!="FEAAS-EXTERNAL"),r,i)),f=="data-embed-src"&&I(l,f,l.getAttribute(f),r,i)}}for(var d=0,u;u=l.childNodes[d++];)me(u)&&F(u,e,r,!0,i);return n||(a=r==null?void 0:r.onRender)===null||a===void 0||a.call(r,l,e),l}function me(t){return t.nodeType==1}function z(t,e,r,n,i=!0){var o;let s=((o=n==null?void 0:n.processTemplate)===null||o===void 0?void 0:o.call(n,t,e,r))||e;if(t.innerHTML=s,t.classList.add("-feaas"),(t.closest(".component.feaas")||t).className.includes("-theme--"))for(var l=0,d;d=t.childNodes[l++];)me(d)&&(d.className=d.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1"));return F(t,r,n,null,i)}function ve(t,e,r,n=!1,i=!0){var o;let s=((o=r==null?void 0:r.processTemplate)===null||o===void 0?void 0:o.call(r,null,t,e))||t;if(typeof document=="undefined"||n){let a=Ut(s);return F(a[0],e,r,null,i).outerHTML}else{let a=document.createElement("div");return a.innerHTML=s,F(a,e,r,null,i),a.innerHTML}}var ge=["initial","check","updated"],ct={};function er(){ct={}}async function ht(t,e,r,n,i=ct){return V({url:t,options:e,validator:r,callback:n,cache:i}).then(ft).then(o=>o.response)}async function V({url:t,options:e,validator:r,callback:n,cache:i},o="initial"){let s=new Date;if(i!=null){var a=ye(t);if(ge.indexOf(a.phase)>=ge.indexOf(o))var l=a[o];else a.phase=o}let d=await(l||fetch(t,e));if(!l&&a&&(d.ok?a[o].resolve(d):a[o].reject(new Error("Fetch failed"))),!d.ok)throw new Error("Fetch failed");let u=new Date(d.headers.get("date"))<s||l&&o=="initial"&&(a.phase=="updated"||a.phase=="check");if((r==null?void 0:r(d,u))===!1)throw new _t("Response is not valid");return await(n==null?void 0:n(d,o,u)),{url:t,options:e,isCached:u,response:d,validator:r,callback:n,cache:i}}function ye(t,e=!1){let r=String(t).replace("?head","");var n=ct[r];return!n&&!e&&(n=ct[r]={phase:null,initial:D(),check:D(),updated:D(),final:D()}),n}var _t=class extends Error{};async function ft(t){let{url:e,isCached:r,options:n,validator:i,response:o,cache:s}=t;if(r){let{response:a}=await V({url:e+(e.toString().includes("?")?"&":"?")+"head",options:{...n,method:"HEAD",cache:"no-cache"},validator:i,cache:s},"check");if(a.headers.get("last-modified")!=o.headers.get("last-modified"))return Dt(t)}return t}async function Dt(t){return V({...t,options:{...t.options,cache:"reload"}},"updated")}var P="https://feaas.blob.core.windows.net";function pt(t){let e=t==null?void 0:t.match(/^(?:(.*?)\/components)?\/?([^\/]+)\/([^\/]+)(?:\/([^\/]+)(?:\/(published|staged|saved|\d+)(?:\.html?)?)?)?$/);if(e){var[,r,n,i,o,s]=e;return{cdn:r,library:n,component:i,version:o,revision:s}}}function rr(t){if(!t||!t.library||!t.component)throw new Error("Component requires `library` and `component` properties");return`${t.cdn&&t.cdn!=P?`${t.cdn}/components`:""}/${t.library}/${t.component}/${!t.version||t.version=="responsive"&&(!t.revision||t.revision=="published")?"":t.version}/${!t.revision||t.revision=="published"?"":t.revision}`.replace(/(^\/|\/$|\/\/)(?!.+\/components\/)/g,"")}function nr(t){return`${t.cdn&&t.cdn!=P?`${t.cdn}/styles/`:""}${t.library}/${!t.revision||t.revision=="published"?"":t.revision}`.replace(/\/$|\/\/(?!.+\/styles\/)/g,"")}function Y(t){let e=t==null?void 0:t.match(/^(?:(.*?)\/styles\/)?([^\/]+)(?:\/(published|staged|saved|\d+)(?:.css)?)?$/);if(e){var[,r,n,i]=e;return{cdn:r,library:n,revision:i}}else{let o=pt(t);if(o){var{cdn:r,library:n,revision:i}=o;return i!=null&&i.match(/\d/)&&(i=void 0),{cdn:r,library:n,revision:i}}}}function Bt(t){return typeof t=="string"&&(t={src:t}),"src"in t&&t.src?t={...pt(t.src)}:t={...t},`${t.cdn||t.hostname||P}/components/${t.library}/${t.component}/${t.version||"responsive"}/${t.revision||"published"}.html`}function mt(t){if(typeof t=="string"&&(t={src:t}),"src"in t){if(String(t.src).includes("v1/files/components/styles"))return t.src;t={...Y(t.src)}}else t={...t};return`${t.cdn||t.hostname||P}/styles/${t.library}/${t.revision=="staged"?"staged":t.revision=="saved"?"saved":"published"}.css`}async function Q(t,e,r=!1){let n=a=>a.headers.get("x-ms-meta-versionDeletedAt")==null,i=a=>a.clone().text().then(e),o=await Promise.all([t.instance&&V({options:{headers:{Accept:"text/html"},credentials:"omit"},url:Bt({...t,version:t.instance}),validator:n}).catch(a=>a),V({url:Bt(t),validator:n}).catch(a=>a)]),s=o.find(a=>a&&"isCached"in a&&a);if(!s||s instanceof Error)throw o.find(l=>l&&l instanceof Error)||new Error("Can not fetch component");return o[0]==s&&console.log("Using fork!",o),await i(s.response),r?s:ft({...s,callback:i}).catch(a=>{if(o[0]==s&&(Dt({...s,callback:null,validator:null}),console.log("Fork was deleted"),!(o[1]instanceof Error)))return i(o[1].response),ft({...o[1],callback:i});throw a})}async function ir(t){typeof t=="string"&&(t={src:t});var e;let{response:r}=await Q(t,n=>{e=n},!0);return{...t,template:e,lastModified:r.headers.get("last-modified")}}async function Ft(t,e){return ht(mt(t),{headers:{Accept:"text/css"},credentials:"omit"},r=>r.headers.get("x-ms-meta-deletedAt")==null,(r,n)=>r.clone().text().then(i=>e(i,n)))}function or(t,e){return be(t,e||(e=document.createElement("style"))),e}function be(t,e){return e||(e=document.createElement("style")),Ft(t,(r,n)=>{e.textContent=r}).then(()=>e)}var sr=new WeakSet;function Nt(t,e){var r,n=Ae(t);if(n){if(sr.has(n))return Promise.resolve(n);t=n.getAttribute("data-href")||n.getAttribute("href")}return Ft(t,(i,o)=>{o=="initial"&&n||(r||(r=!n||n.tagName=="LINK"?Ee(t):n),r.textContent=i),e==null||e(i,o)}).then(()=>r||n)}function Wt(t){return new Promise((e,r)=>{Nt(t,e).catch(r)})}function Ae(t){let e=mt(t),{library:r}=Y(e),n=`/files/components/styles/${r}.css`;return document.querySelector(`style[data-href="${e}"],
|
|
5
5
|
link[rel="stylesheet"][href="${e}"],
|
|
6
6
|
style[data-href*="${n}"],
|
|
7
|
-
link[rel="stylesheet"][href*="${n}"]`)}function Ee(t){let e=mt(t),r=document.createElement("style");return r.setAttribute("data-href",e),document.head.appendChild(r),r}function ar(t,e){let r=document.createElement("div");r.innerHTML=t;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return F(n,e),r}function Ht(t,e,r=!0){return we(t,e||(e=document.createElement("div")),r),e}async function we(t,e,r=!0){return e||(e=document.createElement("div")),e.childNodes.length?F(e,t.data,t,null,r):"template"in t?z(e,t.template,t.data,t,r):Q(t,n=>z(e,n,t.data,t,r)).then(()=>e)}import{customizeDataSettings as lr}from"@sitecore/byoc";function dr(t){let{params:e,method:r,headers:n,body:i,url:o}=x(t);var s={url:o},a={...n};return n["Content-Type"]==="application/json"&&delete a["Content-Type"],n.Accept==="application/json"&&delete a.Accept,Object.keys(a).length>0&&(s.headers=a),r!=="GET"&&(s.method=r),r==="GET"||r==="HEAD"||Object.keys(i).length===0||(s.body=i),Object.keys(e).length>0&&(s={...s,params:e}),s}var Z=t=>{if(!t||typeof t.url!="string")return!1;for(var e in t)if(!(e=="body"||e=="params"||e=="headers"||e=="url"||e==="method"||e=="jsonpath"&&typeof t[e]=="string"))return!1;return!0};function xe(t){let{url:e,headers:r,params:n,method:i,body:o}=x(t),s,a=r["Content-Type"];i!="GET"&&i!="HEAD"&&(a==="application/json"&&(s=JSON.stringify(o)),a==="multipart/form-data"&&(s=Object.keys(o).reduce((d,u)=>(d.append(u,o[u]),d),new FormData)),a==="application/x-www-form-urlencoded"&&(s=new URLSearchParams(o)));let l=Object.keys(n).length?`?${new URLSearchParams(n)}`:"";return[`${e}${l}`,{headers:r,body:s,method:i}]}function x(t){let e={};for(let r in(t==null?void 0:t.headers)||{})if(t.headers.hasOwnProperty(r)){let n=r.replace(/^[a-z]|\-[a-z]/g,i=>i.toUpperCase());e[n]=t.headers[r]}return e.Accept||(e.Accept="application/json"),{params:(t==null?void 0:t.params)||{},headers:e,jsonpath:String((t==null?void 0:t.jsonpath)||"$"),method:((t==null?void 0:t.method)||"GET").toUpperCase(),body:(t==null?void 0:t.body)||{},url:String((t==null?void 0:t.url)||"")}}var zt=async(t,e)=>{let r=lr(e,t);if(r instanceof Promise)return r;let n=t;r&&(n=x(r));try{let[i,o]=xe(n),a=await(await x.fetchImplementation(i,{...o,method:o.method.toLowerCase()})).json();return n.jsonpath&&n.jsonpath!="$"?K(a,n.jsonpath):a}catch(i){return{}}};async function Vt(t){if(!t)return t;if(Z(t))return zt(t);let e=Object.keys(t),r=await Promise.all(e.map(n=>Z(t[n])?zt(t[n],n):null).filter(Boolean));return e.reduce((n,i)=>({...n,[i]:Z(t[i])?r.shift():t[i]}),{})}function ur(t){return t?Z(t)||Object.values(t).some(Z):!1}x.clean=dr;x.toFetchArguments=xe;x.fetchOne=zt;x.fetch=Vt;x.isDataSettings=Z;x.hasDataSettings=ur;x.fetchImplementation=(...t)=>fetch(...t);function Ce(t){var e,r,n,i,o,s,a,l;let d,u=t.getAttribute("src");if(u){let _=pt(u);if(!_)throw new Error(`Could not parse FEAAS Component source: ${u}`);var{cdn:c,library:h,component:f,version:p,revision:v}=_}let y=t.getAttribute("data");if(y!=null&&y!="")try{d=typeof y=="string"?JSON.parse(y):{}}catch(_){console.error(_)}let b=t.getAttribute("fetch");return{data:d||{},cdn:(r=(e=t.getContextAttribute("cdn"))!==null&&e!==void 0?e:c)!==null&&r!==void 0?r:P,library:(n=t.getAttribute("library"))!==null&&n!==void 0?n:h,component:(i=t.getAttribute("component"))!==null&&i!==void 0?i:f,version:(s=(o=t.getAttribute("version"))!==null&&o!==void 0?o:p)!==null&&s!==void 0?s:"responsive",revision:(l=(a=t.getAttribute("revision"))!==null&&a!==void 0?a:v)!==null&&l!==void 0?l:"published",hostname:t.getAttribute("hostname"),template:t.getAttribute("template"),instance:t.getAttribute("instance"),editable:t.getAttribute("editable")!=null,suspended:t.getAttribute("suspended")!=null,lastModified:t.getAttribute("last-modified"),fetch:b=="false"||b==null&&t.hasAttribute("fetch")?[]:b==null||b=="true"?["data","template","stylesheet"]:b.split(/(\s+|\-)+/g).filter(Boolean)}}var vt=class extends w{setData(e){this.set({data:e})}getProps(){return Ce(this)}isJSONAttribute(e){return e=="data"}attributeChangedCallback(e,r,n){r!==n&&((e=="library"||e=="component"||e=="revision"||e=="version")&&(this.payload=void 0,this.alreadyRendered&&this.connected&&(this.needsRefresh=!0,this.needsToFetchTemplate=!0)),super.attributeChangedCallback(e,r,n),e=="data"&&(this.needsRefresh=!0,(this.props.fetch.includes("data")||this.alreadyRendered||!x.hasDataSettings(this.props.data))&&this.fetchData()))}async fetchData(){this.readyData=void 0,this.whenDataReady=this.whenDataReady.restart();let e=await x.fetch(this.props.data),r=this.alreadyRendered;await this.whenDataReady.resolve(e),r&&this.advance()}getEditor(){var e;return(e=document.querySelector("feaas-context"))===null||e===void 0?void 0:e.refs.editor}constructor(){super(),this.readyData={},this.whenDataReady=D(r=>this.readyData=r,r=>this.onError(r)),this.defaultProps={cdn:P,revision:"published",version:"responsive",editable:!1,suspended:!1,data:{}},this.onLoad=r=>{this.payload=r,this.advance()};let e=this.getAttribute("data");this.getAttribute("data")||this.whenDataReady.resolve({}),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}edit(){let e=this.getEditor();if(e!=null&&e.setTarget(this))return e.open(),!0}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){var e;if(this.getOriginal())return;let r=()=>{this.payload!=null&&(n||this.readyData&&this.onLoad(this.payload))};if(this.props.fetch.includes("stylesheet"))var n=Wt({...this.props}).then(()=>{n=null,r()});if(this.props.fetch.includes("template")||this.needsToFetchTemplate){this.needsToFetchTemplate=!1;var i=Q(this.props,o=>{this.payload=o,this.needsRefresh=!0,r()})}else this.payload=(e=this.props.template)!==null&&e!==void 0?e:this.innerHTML;return Promise.all([n,this.whenDataReady.then(()=>r()),i]).then(()=>this.payload)}flush(){this.readyData&&super.flush()}update(){if(this.alreadyRendered=!0,!(!this.props.fetch.includes("data")&&!this.props.fetch.includes("template")&&this.firstElementChild&&!this.needsRefresh))if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)F(this,this.readyData);else{if(this.needsRefresh=!1,this.getOriginal())return;z(this,this.payload,this.readyData)}}};vt.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable","with-stylesheet","fetch"];vt.register("feaas-component");function Se(t){return{opacity:t!=null&&t.getAttribute("opacity")?parseFloat(t==null?void 0:t.getAttribute("opacity")):1,hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var gt=class extends w{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return Se(this)}attributeChangedCallback(e,r,n){if(r!==n)return e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,n)}connectedCallback(){this.payload=null,super.connectedCallback(),this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
|
|
7
|
+
link[rel="stylesheet"][href*="${n}"]`)}function Ee(t){let e=mt(t),r=document.createElement("style");return r.setAttribute("data-href",e),document.head.appendChild(r),r}function ar(t,e){let r=document.createElement("div");r.innerHTML=t;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return console.log("=== renderComponentElement",n,e),F(n,e),r}function Ht(t,e,r=!0){return we(t,e||(e=document.createElement("div")),r),e}async function we(t,e,r=!0){return e||(e=document.createElement("div")),e.childNodes.length?(console.log("=== renderComponentPromise",e,t.data),F(e,t.data,t,null,r)):"template"in t?z(e,t.template,t.data,t,r):Q(t,n=>z(e,n,t.data,t,r)).then(()=>e)}import{customizeDataSettings as lr}from"@sitecore/byoc";function dr(t){let{params:e,method:r,headers:n,body:i,url:o}=x(t);var s={url:o},a={...n};return n["Content-Type"]==="application/json"&&delete a["Content-Type"],n.Accept==="application/json"&&delete a.Accept,Object.keys(a).length>0&&(s.headers=a),r!=="GET"&&(s.method=r),r==="GET"||r==="HEAD"||Object.keys(i).length===0||(s.body=i),Object.keys(e).length>0&&(s={...s,params:e}),s}var Z=t=>{if(!t||typeof t.url!="string")return!1;for(var e in t)if(!(e=="body"||e=="params"||e=="headers"||e=="url"||e==="method"||e=="jsonpath"&&typeof t[e]=="string"))return!1;return!0};function xe(t){let{url:e,headers:r,params:n,method:i,body:o}=x(t),s,a=r["Content-Type"];i!="GET"&&i!="HEAD"&&(a==="application/json"&&(s=JSON.stringify(o)),a==="multipart/form-data"&&(s=Object.keys(o).reduce((d,u)=>(d.append(u,o[u]),d),new FormData)),a==="application/x-www-form-urlencoded"&&(s=new URLSearchParams(o)));let l=Object.keys(n).length?`?${new URLSearchParams(n)}`:"";return[`${e}${l}`,{headers:r,body:s,method:i}]}function x(t){let e={};for(let r in(t==null?void 0:t.headers)||{})if(t.headers.hasOwnProperty(r)){let n=r.replace(/^[a-z]|\-[a-z]/g,i=>i.toUpperCase());e[n]=t.headers[r]}return e.Accept||(e.Accept="application/json"),{params:(t==null?void 0:t.params)||{},headers:e,jsonpath:String((t==null?void 0:t.jsonpath)||"$"),method:((t==null?void 0:t.method)||"GET").toUpperCase(),body:(t==null?void 0:t.body)||{},url:String((t==null?void 0:t.url)||"")}}var zt=async(t,e)=>{let r=lr(e,t);if(r instanceof Promise)return r;let n=t;r&&(n=x(r));try{let[i,o]=xe(n),a=await(await x.fetchImplementation(i,{...o,method:o.method.toLowerCase()})).json();return n.jsonpath&&n.jsonpath!="$"?K(a,n.jsonpath):a}catch(i){return{}}};async function Vt(t){if(!t)return t;if(Z(t))return zt(t);let e=Object.keys(t),r=await Promise.all(e.map(n=>Z(t[n])?zt(t[n],n):null).filter(Boolean));return e.reduce((n,i)=>({...n,[i]:Z(t[i])?r.shift():t[i]}),{})}function ur(t){return t?Z(t)||Object.values(t).some(Z):!1}x.clean=dr;x.toFetchArguments=xe;x.fetchOne=zt;x.fetch=Vt;x.isDataSettings=Z;x.hasDataSettings=ur;x.fetchImplementation=(...t)=>fetch(...t);function Ce(t){var e,r,n,i,o,s,a,l;let d,u=t.getAttribute("src");if(u){let _=pt(u);if(!_)throw new Error(`Could not parse FEAAS Component source: ${u}`);var{cdn:c,library:h,component:f,version:p,revision:v}=_}let y=t.getAttribute("data");if(y!=null&&y!="")try{d=typeof y=="string"?JSON.parse(y):{}}catch(_){console.error(_)}let b=t.getAttribute("fetch");return{data:d||{},cdn:(r=(e=t.getContextAttribute("cdn"))!==null&&e!==void 0?e:c)!==null&&r!==void 0?r:P,library:(n=t.getAttribute("library"))!==null&&n!==void 0?n:h,component:(i=t.getAttribute("component"))!==null&&i!==void 0?i:f,version:(s=(o=t.getAttribute("version"))!==null&&o!==void 0?o:p)!==null&&s!==void 0?s:"responsive",revision:(l=(a=t.getAttribute("revision"))!==null&&a!==void 0?a:v)!==null&&l!==void 0?l:"published",hostname:t.getAttribute("hostname"),template:t.getAttribute("template"),instance:t.getAttribute("instance"),editable:t.getAttribute("editable")!=null,suspended:t.getAttribute("suspended")!=null,lastModified:t.getAttribute("last-modified"),fetch:b=="false"||b==null&&t.hasAttribute("fetch")?[]:b==null||b=="true"?["data","template","stylesheet"]:b.split(/(\s+|\-)+/g).filter(Boolean)}}var vt=class extends w{setData(e){this.set({data:e})}getProps(){return Ce(this)}isJSONAttribute(e){return e=="data"}attributeChangedCallback(e,r,n){r!==n&&((e=="library"||e=="component"||e=="revision"||e=="version")&&(this.payload=void 0,this.alreadyRendered&&this.connected&&(this.needsRefresh=!0,this.needsToFetchTemplate=!0)),super.attributeChangedCallback(e,r,n),e=="data"&&(this.needsRefresh=!0,(this.props.fetch.includes("data")||this.alreadyRendered||!x.hasDataSettings(this.props.data))&&this.fetchData()))}async fetchData(){this.readyData=void 0,this.whenDataReady=this.whenDataReady.restart();let e=await x.fetch(this.props.data),r=this.alreadyRendered;await this.whenDataReady.resolve(e),r&&this.advance()}getEditor(){var e;return(e=document.querySelector("feaas-context"))===null||e===void 0?void 0:e.refs.editor}constructor(){super(),this.readyData={},this.whenDataReady=D(r=>this.readyData=r,r=>this.onError(r)),this.defaultProps={cdn:P,revision:"published",version:"responsive",editable:!1,suspended:!1,data:{}},this.onLoad=r=>{this.payload=r,this.advance()};let e=this.getAttribute("data");this.getAttribute("data")||this.whenDataReady.resolve({}),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}edit(){let e=this.getEditor();if(e!=null&&e.setTarget(this))return e.open(),!0}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){var e;if(this.getOriginal())return;let r=()=>{this.payload!=null&&(n||this.readyData&&this.onLoad(this.payload))};if(this.props.fetch.includes("stylesheet"))var n=Wt({...this.props}).then(()=>{n=null,r()});if(this.props.fetch.includes("template")||this.needsToFetchTemplate){this.needsToFetchTemplate=!1;var i=Q(this.props,o=>{this.payload=o,this.needsRefresh=!0,r()})}else this.payload=(e=this.props.template)!==null&&e!==void 0?e:this.innerHTML;return Promise.all([n,this.whenDataReady.then(()=>r()),i]).then(()=>this.payload)}flush(){this.readyData&&super.flush()}update(){if(this.alreadyRendered=!0,console.log("=== feaascomponent update",this.alreadyRendered),!(!this.props.fetch.includes("data")&&!this.props.fetch.includes("template")&&this.firstElementChild&&!this.needsRefresh))if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)console.log("=== feaas component render dom",this.readyData),F(this,this.readyData);else{if(this.needsRefresh=!1,this.getOriginal())return;z(this,this.payload,this.readyData)}}};vt.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable","with-stylesheet","fetch"];vt.register("feaas-component");function Se(t){return{opacity:t!=null&&t.getAttribute("opacity")?parseFloat(t==null?void 0:t.getAttribute("opacity")):1,hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var gt=class extends w{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return Se(this)}attributeChangedCallback(e,r,n){if(r!==n)return e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),n?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all")),super.attributeChangedCallback(e,r,n)}connectedCallback(){this.payload=null,super.connectedCallback(),this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
|
|
8
8
|
#loader {
|
|
9
9
|
position: absolute;
|
|
10
10
|
top: 0;
|