@sitecore-feaas/clientside 0.6.3-alpha.11 → 0.6.3-alpha.12
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 +1 -0
- package/build/components/FEAASComponent.js.map +1 -1
- package/dist/browser/headless.cjs +1 -1
- package/dist/browser/headless.cjs.map +2 -2
- package/dist/browser/headless.esm.js +1 -1
- 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 +1 -1
- package/dist/browser/react.cjs.map +2 -2
- package/dist/browser/react.esm.js +1 -1
- 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 +1 -1
- package/dist/node/react.cjs.map +2 -2
- package/dist/node/react.esm.js +1 -1
- 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 +1 -1
- package/react.cjs.map +2 -2
- package/react.js +1 -1
- package/react.js.map +2 -2
- package/src/components/FEAASComponent.tsx +1 -0
- package/types/components/FEAASComponent.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 e=="string")return e;if(e==null)return"";switch(e.type){case"heading":let{level:r,...n}=e.attrs;return le(e.content,n,"h"+r);case"text":return(e.marks||[]).reduce((i,o)=>le(i,o.attrs,{link:"a",bold:"strong",italic:"em",strike:"s",underline:"u"}[o.type]),(t=e.text)===null||t===void 0?void 0:t.replace(/\s+/," "));default:return le(e.content||e.text,e.attrs,{bulletList:"ul",orderedList:"ol",listItem:"li",horizontalRule:"hr",paragraph:"p",codeBlock:"code",blockquote:"blockquote"}[e.type])}}var F=class{constructor(t,r=1,n){this.ownerDocument={createElement(i){return new F(i)},createDocumentFragment(){return new F(null,11)}},this.nodeName=t,this.nodeType=r,this.textContent=n,this.attributes=[],this.childNodes=[]}setAttribute(t,r){let n=this.attributes.find(i=>i.name===t);n?n.value=r:this.attributes.push({name:t,value:r})}getAttribute(t){let r=this.attributes.find(n=>n.name===t);return r?r.value:void 0}insertBefore(t,r){if(t.parentNode=this,r===null)this.childNodes.push(t);else{let n=this.childNodes.indexOf(r);n!==-1&&this.childNodes.splice(n,0,t)}}removeAttribute(t){let r=this.attributes.findIndex(n=>n.name===t);r!==-1&&this.attributes.splice(r,1)}appendChild(t){t.parentNode=this,this.childNodes.push(t)}get tagName(){var t;return(t=this.nodeName)===null||t===void 0?void 0:t.toUpperCase()}get localName(){var t;return(t=this.nodeName)===null||t===void 0?void 0:t.toLowerCase()}get innerHTML(){return ce(this.childNodes)}set innerHTML(t){this.childNodes=de(String(t!=null?t:""))}get outerHTML(){return ce([this])}get children(){return this.childNodes.filter(t=>t.nodeType==1)}closest(t){let r=this;for(;r;){if(Oe(t,r))return r;r=r.parentNode}return null}querySelectorAll(t){let r=t.split(/\s*,\s*/),n=[],i=o=>{for(let a of r)if(Oe(a,o)){n.push(o);break}for(let a of o.childNodes)i(a)};for(let o of this.childNodes)i(o);return n}querySelector(t){return this.querySelectorAll(t)[0]}findSibling(t,r){if(!this.parentNode)return null;let n=this.parentNode.childNodes,i=n.indexOf(this);if(i===-1)return null;for(let o=i+t;o>=0&&o<n.length;o+=t){let a=n[o];if(!r||a.nodeType===1)return a}return null}removeChild(t){let r=this.childNodes.indexOf(t);if(r!==-1)return this.childNodes.splice(r,1),t.parentNode=void 0,t}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(t=!1){let r=new F(this.nodeName,this.nodeType);if(r.attributes=JSON.parse(JSON.stringify(this.attributes)),this.textContent&&(r.textContent=this.textContent),t)for(let n of this.childNodes){let i=n.cloneNode(!0);r.appendChild(i)}return r}get parentElement(){var t;return((t=this.parentNode)===null||t===void 0?void 0:t.nodeType)==1?this.parentNode:null}};function Oe(e,t){let r=e.match(/([.#]?[\w-]+|\[([\w-]+)(="([^"]*)")?\])/g);if(!r)return!1;for(let n of r)if(n.startsWith("#")){if(t.getAttribute("id")!==n.slice(1))return!1}else if(n.startsWith(".")){if(!(t.getAttribute("class")||"").split(" ").includes(n.slice(1)))return!1}else if(n.startsWith("[")){let i=n.match(/^\[([\w-]+)(="([^"]*)")?\]$/);if(i){let o=i[1],a=i[3],s=t.getAttribute(o);if(typeof a=="undefined"){if(s===void 0)return!1}else if(s!==a)return!1}else return!1}else if(t.nodeName!==n)return!1;return!0}function de(e){var t;let r=[],n=[];for(;e;){let i=e.match(/^<([\w-]+)(\s[^>]*)?>/),o=e.match(/^<\/([\w-]+)>/);if(i){let a=i[1].toLowerCase(),l=((t=(i[2]||"").match(/([\w-]+)(="([^"]*)")?/g))===null||t===void 0?void 0:t.map(c=>{let[d,h,,f]=c.match(/([\w-]+)(="([^"]*)")?/);return{name:h,value:ft(f||"")}}))||[],u=new F(a,1);if(u.attributes=l,n.length>0){let c=n[n.length-1];c.childNodes.push(u),u.parentNode=c}else r.push(u);["img","input","br"].includes(a)||n.push(u),e=e.slice(i[0].length)}else if(o)n.pop(),e=e.slice(o[0].length);else{let a=e.indexOf("<"),s=e.slice(0,a!==-1?a:void 0),l=new F("#text",3);if(l.textContent=s,n.length>0){let u=n[n.length-1];u.childNodes.push(l),l.parentNode=u}else r.push(l);e=e.slice(s.length)}}return r}function ht(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ft(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'")}function ce(e){return e.map(t=>{if(t.nodeType===3)return t.textContent||"";let{nodeName:r,attributes:n}=t,i=n.map(({name:a,value:s})=>` ${a}="${ht(String(s))}"`).join(""),o=ce(t.childNodes);return["img","input","br"].includes(r)?`<${r}${i} />`:`<${r}${i}>${o}</${r}>`}).join("")}function pt(e){let t=new e.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(n=>{let i=n.target,o=i.getAttribute("data-embed-src");o&&G(i,o),n.addedNodes&&n.addedNodes.forEach(a=>{a.nodeType==1&&mt(a,!1)})})});return t.observe(e,{attributes:!0,subtree:!0,childList:!0}),t}function mt(e,t=!0){let r=e.querySelectorAll("[data-embed-src]");for(var n=0;n<r.length;n++){let i=r[n];G(i,i.getAttribute("data-embed-src"))}if(t)return pt(e)}function G(e,t){for(var r=e;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")==t)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let o=r.ownerDocument.createElement("script");o.setAttribute("type","module"),o.setAttribute("src",t),r.appendChild(o);break}}var fe={};V(fe,{adjustNumbers:()=>bt,cleanCollectionBit:()=>K,getHumanizedLabel:()=>At,getLastPathBit:()=>wt,getQualifier:()=>gt,normalizeCollectionScope:()=>he,parseLimit:()=>yt,parseRange:()=>vt});var yt=e=>{var t;let r=parseInt((t=e==null?void 0:e.match(/\[0:(\d+)\]/))===null||t===void 0?void 0:t[1],10);return!isNaN(r)&&r>0?String(r):null},vt=e=>{var t;let r=(t=e==null?void 0:e.match(/\[([^\]]+)\]/))===null||t===void 0?void 0:t[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},gt=e=>{var t;return(t=e==null?void 0:e.match(/(\.\*|\[[^\]]*\])$/))===null||t===void 0?void 0:t[0]};function K(e){return e.replace(/(\.?\[[^\]\[]*\]|\.\*)$/g,"")}function he(e){return K(e)+".*"}function bt(e,t){return e==null?void 0:e.replace(/(.|^)(\d+)/g,(r,n,i)=>n+(n==":"?i:String(parseInt(i)+t)))}function At(e,t=2){var r=K(e).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(-t).join(" ")}function wt(e){return K(e).split(".").pop()}var St=["January","February","March","April","May","June","July","August","September","October","November","December"],Te=e=>{if(!e||typeof e.getDay!="function")return;let t=e.getFullYear(),r=St[e.getMonth()],n=e.getDate();return`${r} ${n}, ${t}`},$e=function(e){return String(new Date(e))!=="Invalid Date"&&!isNaN(Number(new Date(e)))};function Me(e){let t=e.getAttribute("data-path-scope");for(var r=0,n=e;n=n.previousElementSibling;)n.getAttribute("data-path-scope")==t&&r++;return r}function xt(e,t,r){let n=e.getAttribute("data-path-scope");if(n==null)return;var i=Me(e);if(i!=0)return;let o=e.parentNode;if(o!=null){t==0?e.setAttribute("hidden","hidden"):e.getAttribute("hidden")!=null&&e.removeAttribute("hidden");for(var a=i+1,s=e,l=e;l=l.nextElementSibling;)l.getAttribute("data-path-scope")==n&&(a++,s=l);for(var u=a;u<t;u++)o.insertBefore(s.cloneNode(!0),s.nextElementSibling);for(var u=Math.max(1,t);u<a;u++)s=s.previousElementSibling,o.removeChild(s.nextElementSibling)}}function O(e,t,r,n,i=!0){var o,a,s;if(!e)return;var l=e;(r==null?void 0:r.type)=="doc"&&Array.isArray(r.content)&&(r=$(r)),n!=null&&n.processValue&&(r=n==null?void 0:n.processValue(e,t,r));var u=t.replace("data-path-","");if(t=="data-path-src"||t=="data-path-alt"){let b=Array.from(e.children).find(D=>D.localName=="picture")||e;l=e.localName=="img"?e:b.querySelector("img, video")}else if(t=="data-path-href")l=e.querySelector("a")||e.closest("a");else if(t=="data-path-hidden")r=r?null:!0;else if(t=="data-path"||t=="data-embed-html"||t=="html")u="innerHTML";else if(t=="data-embed-src"&&i)G(e,r);else if(t=="data-path-attributes"){if(!Array.isArray(r)){let b=((o=e.getAttribute("data-attributes-keys"))===null||o===void 0?void 0:o.split(",").filter(Boolean))||[];if(!Array.isArray(r))for(var c in r){var d=r[c];O(e,c,typeof d=="object"&&d?JSON.stringify(d):d,n,i)}for(var h=0;h<b.length;h++)(r==null||!(b[h]in r))&&O(e,b[h],null,n,i);O(e,"data-attributes-keys",Object.keys(r||{}).join(","),{},i)}if(e.tagName=="FEAAS-EXTERNAL"){let b=String(e.getAttribute("data-path-attributes")||"").slice(0,-1).split(".")[0]||"_";O(e,"datasources",JSON.stringify({[b]:r}),{},i)}return}if(typeof r=="boolean"&&(r=r?"":null),!l)return;if((u=="innerHTML"||u=="src")&&(r==null||r==="")){var y=String((s=(a=e.getAttribute("data-path-placeholder")||l[u])!==null&&a!==void 0?a:l.getAttribute(u))!==null&&s!==void 0?s:"");u=="innerHTML"?l.innerHTML=y:y?l.setAttribute(u,y):l.removeAttribute(u)}else if(r!=null)if(u=="innerHTML"){for(var m=String(r),v=l;v.parentElement&&v.localName.match(/^(a|var|strong|em|i|b)$/);)v=v.parentElement;v.localName.match(/p|h\d|button|time|li/)&&(m=m.replace(/<(p|h\d|li|ul)[^>]*?>|<\/(p|h\d|li|ul)[^>]*?>/g," ").trim().replace(/\s+/g," ")),String(v.getAttribute("class")).includes("-inline--time")&&$e(m)&&(m=Te(new Date(m))),l.innerHTML!=m&&(l.innerHTML=m)}else l.getAttribute(u)!=r&&(u==="hidden"?(console.log("in here?..."),l[u]=!0):l.setAttribute(u,r));else l.removeAttribute(u)}var Pe=["data-attributes-keys","data-path-attributes","data-path-scope"];function S(e,t,r,n,i=!0){var o,a,s;let l=e;if(n||(t=((o=r==null?void 0:r.processData)===null||o===void 0?void 0:o.call(r,l,t))||t),l.nodeType==1){let d=l.getAttribute("data-path-scope");if(d){let f=Me(l),y=q(t,d,!1);f==0&&xt(l,((a=r==null?void 0:r.shouldRepeat)===null||a===void 0?void 0:a.call(r,l,y))===!1?1:y.length,r),t={...t,[he(d)]:y[f]}}let h=Array.prototype.slice.call(l.attributes).sort((f,y)=>Pe.indexOf(f.name)-Pe.indexOf(y.name));for(var u=0;u<h.length;u++){let{name:f,value:y}=h[u];f.startsWith("data-path")&&f!="data-path-scope"&&O(l,f,q(t,y,!0,void 0,l.tagName!="FEAAS-EXTERNAL"),r,i),f=="data-embed-src"&&O(l,f,l.getAttribute(f),r,i)}}for(var u=0,c;c=l.childNodes[u++];)ke(c)&&S(c,t,r,!0,i);return n||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,l,t),l}function ke(e){return e.nodeType==1}function P(e,t,r,n,i=!0){var o;let a=((o=n==null?void 0:n.processTemplate)===null||o===void 0?void 0:o.call(n,e,t,r))||t;if(e.innerHTML=a,e.classList.add("-feaas"),(e.closest(".component.feaas")||e).className.includes("-theme--"))for(var l=0,u;u=e.childNodes[l++];)ke(u)&&(u.className=u.className.replace(/(\s|^)-theme--[^\s]+\s*/g,"$1"));return S(e,r,n,null,i)}function Et(e,t,r,n=!1,i=!0){var o;let a=((o=r==null?void 0:r.processTemplate)===null||o===void 0?void 0:o.call(r,null,e,t))||e;if(typeof document=="undefined"||n){let s=de(a);return S(s[0],t,r,null,i).outerHTML}else{let s=document.createElement("div");return s.innerHTML=a,S(s,t,r,null,i),s.innerHTML}}var Le=["initial","check","updated"],Y={};function or(){Y={}}async function X(e,t,r,n,i=Y){return M({url:e,options:t,validator:r,callback:n,cache:i}).then(Q).then(o=>o.response)}async function M({url:e,options:t,validator:r,callback:n,cache:i},o="initial"){let a=new Date;if(i!=null){var s=Ct(e);if(Le.indexOf(s.phase)>=Le.indexOf(o))var l=s[o];else s.phase=o}let u=await(l||fetch(e,t));if(!l&&s&&(u.ok?s[o].resolve(u):s[o].reject(new Error("Fetch failed"))),!u.ok)throw new Error("Fetch failed");let c=new Date(u.headers.get("date"))<a||l&&o=="initial"&&(s.phase=="updated"||s.phase=="check");if((r==null?void 0:r(u,c))===!1)throw new me("Response is not valid");return await(n==null?void 0:n(u,o,c)),{url:e,options:t,isCached:c,response:u,validator:r,callback:n,cache:i}}function Ct(e,t=!1){let r=String(e).replace("?head","");var n=Y[r];return!n&&!t&&(n=Y[r]={phase:null,initial:x(),check:x(),updated:x(),final:x()}),n}var me=class extends Error{};async function Q(e){let{url:t,isCached:r,options:n,validator:i,response:o,cache:a}=e;if(r){let{response:s}=await M({url:t+(t.toString().includes("?")?"&":"?")+"head",options:{...n,method:"HEAD",cache:"no-cache"},validator:i,cache:a},"check");if(s.headers.get("last-modified")!=o.headers.get("last-modified"))return ye(e)}return e}async function ye(e){return M({...e,options:{...e.options,cache:"reload"}},"updated")}var _="https://feaas.blob.core.windows.net";function Z(e){let t=e==null?void 0:e.match(/^(?:(.*?)\/components)?\/?([^\/]+)\/([^\/]+)(?:\/([^\/]+)(?:\/(published|staged|saved|\d+)(?:\.html?)?)?)?$/);if(t){var[,r,n,i,o,a]=t;return{cdn:r,library:n,component:i,version:o,revision:a}}}function lr(e){if(!e||!e.library||!e.component)throw new Error("Component requires `library` and `component` properties");return`${e.cdn&&e.cdn!=_?`${e.cdn}/components`:""}/${e.library}/${e.component}/${!e.version||e.version=="responsive"&&(!e.revision||e.revision=="published")?"":e.version}/${!e.revision||e.revision=="published"?"":e.revision}`.replace(/(^\/|\/$|\/\/)(?!.+\/components\/)/g,"")}function ur(e){return`${e.cdn&&e.cdn!=_?`${e.cdn}/styles/`:""}${e.library}/${!e.revision||e.revision=="published"?"":e.revision}`.replace(/\/$|\/\/(?!.+\/styles\/)/g,"")}function W(e){let t=e==null?void 0:e.match(/^(?:(.*?)\/styles\/)?([^\/]+)(?:\/(published|staged|saved|\d+)(?:.css)?)?$/);if(t){var[,r,n,i]=t;return{cdn:r,library:n,revision:i}}else{let o=Z(e);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 je(e){return typeof e=="string"&&(e={src:e}),"src"in e&&e.src?e={...Z(e.src)}:e={...e},`${e.cdn||e.hostname||_}/components/${e.library}/${e.component}/${e.version||"responsive"}/${e.revision||"published"}.html`}function ee(e){if(typeof e=="string"&&(e={src:e}),"src"in e){if(String(e.src).includes("v1/files/components/styles"))return e.src;e={...W(e.src)}}else e={...e};return`${e.cdn||e.hostname||_}/styles/${e.library}/${e.revision=="staged"?"staged":e.revision=="saved"?"saved":"published"}.css`}async function H(e,t,r=!1){let n=s=>s.headers.get("x-ms-meta-versionDeletedAt")==null,i=s=>s.clone().text().then(t),o=await Promise.all([e.instance&&M({options:{headers:{Accept:"text/html"},credentials:"omit"},url:je({...e,version:e.instance}),validator:n}).catch(s=>s),M({url:je(e),validator:n}).catch(s=>s)]),a=o.find(s=>s&&"isCached"in s&&s);if(!a||a instanceof Error)throw o.find(l=>l&&l instanceof Error)||new Error("Can not fetch component");return o[0]==a&&console.log("Using fork!",o),await i(a.response),r?a:Q({...a,callback:i}).catch(s=>{if(o[0]==a&&(ye({...a,callback:null,validator:null}),console.log("Fork was deleted"),!(o[1]instanceof Error)))return i(o[1].response),Q({...o[1],callback:i});throw s})}async function cr(e){typeof e=="string"&&(e={src:e});var t;let{response:r}=await H(e,n=>{t=n},!0);return{...e,template:t,lastModified:r.headers.get("last-modified")}}async function ve(e,t){return X(ee(e),{headers:{Accept:"text/css"},credentials:"omit"},r=>r.headers.get("x-ms-meta-deletedAt")==null,(r,n)=>r.clone().text().then(i=>t(i,n)))}function fr(e,t){return _t(e,t||(t=document.createElement("style"))),t}function _t(e,t){return t||(t=document.createElement("style")),ve(e,(r,n)=>{t.textContent=r}).then(()=>t)}var Dt=new WeakSet;function ge(e,t){var r,n=Ft(e);if(n){if(Dt.has(n))return Promise.resolve(n);e=n.getAttribute("data-href")||n.getAttribute("href")}return ve(e,(i,o)=>{o=="initial"&&n||(r||(r=!n||n.tagName=="LINK"?Rt(e):n),r.textContent=i),t==null||t(i,o)}).then(()=>r||n)}function Ie(e){return new Promise((t,r)=>{ge(e,t).catch(r)})}function Ft(e){let t=ee(e),{library:r}=W(t),n=`/files/components/styles/${r}.css`;return document.querySelector(`style[data-href="${t}"],
|
|
5
5
|
link[rel="stylesheet"][href="${t}"],
|
|
6
6
|
style[data-href*="${n}"],
|
|
7
|
-
link[rel="stylesheet"][href*="${n}"]`)}function Rt(e){let t=ee(e),r=document.createElement("style");return r.setAttribute("data-href",t),document.head.appendChild(r),r}function vr(e,t){let r=document.createElement("div");r.innerHTML=e;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return console.log("=== renderComponentElement",n,t),S(n,t),r}function Ue(e,t,r=!0){return Nt(e,t||(t=document.createElement("div")),r),t}async function Nt(e,t,r=!0){return t||(t=document.createElement("div")),t.childNodes.length?(console.log("=== renderComponentPromise",t,e.data),S(t,e.data,e,null,r)):"template"in e?P(t,e.template,e.data,e,r):H(e,n=>P(t,n,e.data,e,r)).then(()=>t)}import{customizeDataSettings as Ot}from"@sitecore/byoc";function Tt(e){let{params:t,method:r,headers:n,body:i,url:o}=A(e);var a={url:o},s={...n};return n["Content-Type"]==="application/json"&&delete s["Content-Type"],n.Accept==="application/json"&&delete s.Accept,Object.keys(s).length>0&&(a.headers=s),r!=="GET"&&(a.method=r),r==="GET"||r==="HEAD"||Object.keys(i).length===0||(a.body=i),Object.keys(t).length>0&&(a={...a,params:t}),a}var k=e=>{if(!e||typeof e.url!="string")return!1;for(var t in e)if(!(t=="body"||t=="params"||t=="headers"||t=="url"||t==="method"||t=="jsonpath"&&typeof e[t]=="string"))return!1;return!0};function Be(e){let{url:t,headers:r,params:n,method:i,body:o}=A(e),a,s=r["Content-Type"];i!="GET"&&i!="HEAD"&&(s==="application/json"&&(a=JSON.stringify(o)),s==="multipart/form-data"&&(a=Object.keys(o).reduce((u,c)=>(u.append(c,o[c]),u),new FormData)),s==="application/x-www-form-urlencoded"&&(a=new URLSearchParams(o)));let l=Object.keys(n).length?`?${new URLSearchParams(n)}`:"";return[`${t}${l}`,{headers:r,body:a,method:i}]}function A(e){let t={};for(let r in(e==null?void 0:e.headers)||{})if(e.headers.hasOwnProperty(r)){let n=r.replace(/^[a-z]|\-[a-z]/g,i=>i.toUpperCase());t[n]=e.headers[r]}return t.Accept||(t.Accept="application/json"),{params:(e==null?void 0:e.params)||{},headers:t,jsonpath:String((e==null?void 0:e.jsonpath)||"$"),method:((e==null?void 0:e.method)||"GET").toUpperCase(),body:(e==null?void 0:e.body)||{},url:String((e==null?void 0:e.url)||"")}}var be=async(e,t)=>{let r=Ot(t,e);if(r instanceof Promise)return r;let n=e;r&&(n=A(r));try{let[i,o]=Be(n),s=await(await A.fetchImplementation(i,{...o,method:o.method.toLowerCase()})).json();return n.jsonpath&&n.jsonpath!="$"?B(s,n.jsonpath):s}catch(i){return{}}};async function We(e){if(!e)return e;if(k(e))return be(e);let t=Object.keys(e),r=await Promise.all(t.map(n=>k(e[n])?be(e[n],n):null).filter(Boolean));return t.reduce((n,i)=>({...n,[i]:k(e[i])?r.shift():e[i]}),{})}function $t(e){return e?k(e)||Object.values(e).some(k):!1}A.clean=Tt;A.toFetchArguments=Be;A.fetchOne=be;A.fetch=We;A.isDataSettings=k;A.hasDataSettings=$t;A.fetchImplementation=(...e)=>fetch(...e);function Pt(e){var t,r,n,i,o,a,s,l;let u,c=e.getAttribute("src");if(c){let D=Z(c);if(!D)throw new Error(`Could not parse FEAAS Component source: ${c}`);var{cdn:d,library:h,component:f,version:y,revision:m}=D}let v=e.getAttribute("data");if(v!=null&&v!="")try{u=typeof v=="string"?JSON.parse(v):{}}catch(D){console.error(D)}let b=e.getAttribute("fetch");return{data:u||{},cdn:(r=(t=e.getContextAttribute("cdn"))!==null&&t!==void 0?t:d)!==null&&r!==void 0?r:_,library:(n=e.getAttribute("library"))!==null&&n!==void 0?n:h,component:(i=e.getAttribute("component"))!==null&&i!==void 0?i:f,version:(a=(o=e.getAttribute("version"))!==null&&o!==void 0?o:y)!==null&&a!==void 0?a:"responsive",revision:(l=(s=e.getAttribute("revision"))!==null&&s!==void 0?s:m)!==null&&l!==void 0?l:"published",hostname:e.getAttribute("hostname"),template:e.getAttribute("template"),instance:e.getAttribute("instance"),editable:e.getAttribute("editable")!=null,suspended:e.getAttribute("suspended")!=null,lastModified:e.getAttribute("last-modified"),fetch:b=="false"||b==null&&e.hasAttribute("fetch")?[]:b==null||b=="true"?["data","template","stylesheet"]:b.split(/(\s+|\-)+/g).filter(Boolean)}}var te=class extends E{setData(t){this.set({data:t})}getProps(){return Pt(this)}isJSONAttribute(t){return t=="data"}attributeChangedCallback(t,r,n){r!==n&&((t=="library"||t=="component"||t=="revision"||t=="version")&&(this.payload=void 0,this.alreadyRendered&&this.connected&&(this.needsRefresh=!0,this.needsToFetchTemplate=!0)),super.attributeChangedCallback(t,r,n),t=="data"&&(this.needsRefresh=!0,(this.props.fetch.includes("data")||this.alreadyRendered||!A.hasDataSettings(this.props.data))&&this.fetchData()))}async fetchData(){this.readyData=void 0,this.whenDataReady=this.whenDataReady.restart();let t=await A.fetch(this.props.data),r=this.alreadyRendered;await this.whenDataReady.resolve(t),r&&this.advance()}getEditor(){var t;return(t=document.querySelector("feaas-context"))===null||t===void 0?void 0:t.refs.editor}constructor(){super(),this.readyData={},this.whenDataReady=x(r=>this.readyData=r,r=>this.onError(r)),this.defaultProps={cdn:_,revision:"published",version:"responsive",editable:!1,suspended:!1,data:{}},this.onLoad=r=>{this.payload=r,this.advance()};let t=this.getAttribute("data");this.getAttribute("data")||this.whenDataReady.resolve({}),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}edit(){let t=this.getEditor();if(t!=null&&t.setTarget(this))return t.open(),!0}getOriginal(){let t=this.getAttribute("data-path-scope");if(t){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==t;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){var t;if(this.getOriginal())return;let r=()=>{this.payload!=null&&(n||this.readyData&&this.onLoad(this.payload))};if(this.props.fetch.includes("stylesheet"))var n=Ie({...this.props}).then(()=>{n=null,r()});if(this.props.fetch.includes("template")||this.needsToFetchTemplate){this.needsToFetchTemplate=!1;var i=H(this.props,o=>{this.payload=o,this.needsRefresh=!0,r()})}else this.payload=(t=this.props.template)!==null&&t!==void 0?t: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(t=>t.tagName!="BR").length>0&&!this.needsRefresh)console.log("=== feaas component render dom",this.readyData),S(this,this.readyData);else{if(this.needsRefresh=!1,this.getOriginal())return
|
|
7
|
+
link[rel="stylesheet"][href*="${n}"]`)}function Rt(e){let t=ee(e),r=document.createElement("style");return r.setAttribute("data-href",t),document.head.appendChild(r),r}function vr(e,t){let r=document.createElement("div");r.innerHTML=e;let n=document.createDocumentFragment();for(;r.firstChild;)n.appendChild(r.firstChild);return console.log("=== renderComponentElement",n,t),S(n,t),r}function Ue(e,t,r=!0){return Nt(e,t||(t=document.createElement("div")),r),t}async function Nt(e,t,r=!0){return t||(t=document.createElement("div")),t.childNodes.length?(console.log("=== renderComponentPromise",t,e.data),S(t,e.data,e,null,r)):"template"in e?P(t,e.template,e.data,e,r):H(e,n=>P(t,n,e.data,e,r)).then(()=>t)}import{customizeDataSettings as Ot}from"@sitecore/byoc";function Tt(e){let{params:t,method:r,headers:n,body:i,url:o}=A(e);var a={url:o},s={...n};return n["Content-Type"]==="application/json"&&delete s["Content-Type"],n.Accept==="application/json"&&delete s.Accept,Object.keys(s).length>0&&(a.headers=s),r!=="GET"&&(a.method=r),r==="GET"||r==="HEAD"||Object.keys(i).length===0||(a.body=i),Object.keys(t).length>0&&(a={...a,params:t}),a}var k=e=>{if(!e||typeof e.url!="string")return!1;for(var t in e)if(!(t=="body"||t=="params"||t=="headers"||t=="url"||t==="method"||t=="jsonpath"&&typeof e[t]=="string"))return!1;return!0};function Be(e){let{url:t,headers:r,params:n,method:i,body:o}=A(e),a,s=r["Content-Type"];i!="GET"&&i!="HEAD"&&(s==="application/json"&&(a=JSON.stringify(o)),s==="multipart/form-data"&&(a=Object.keys(o).reduce((u,c)=>(u.append(c,o[c]),u),new FormData)),s==="application/x-www-form-urlencoded"&&(a=new URLSearchParams(o)));let l=Object.keys(n).length?`?${new URLSearchParams(n)}`:"";return[`${t}${l}`,{headers:r,body:a,method:i}]}function A(e){let t={};for(let r in(e==null?void 0:e.headers)||{})if(e.headers.hasOwnProperty(r)){let n=r.replace(/^[a-z]|\-[a-z]/g,i=>i.toUpperCase());t[n]=e.headers[r]}return t.Accept||(t.Accept="application/json"),{params:(e==null?void 0:e.params)||{},headers:t,jsonpath:String((e==null?void 0:e.jsonpath)||"$"),method:((e==null?void 0:e.method)||"GET").toUpperCase(),body:(e==null?void 0:e.body)||{},url:String((e==null?void 0:e.url)||"")}}var be=async(e,t)=>{let r=Ot(t,e);if(r instanceof Promise)return r;let n=e;r&&(n=A(r));try{let[i,o]=Be(n),s=await(await A.fetchImplementation(i,{...o,method:o.method.toLowerCase()})).json();return n.jsonpath&&n.jsonpath!="$"?B(s,n.jsonpath):s}catch(i){return{}}};async function We(e){if(!e)return e;if(k(e))return be(e);let t=Object.keys(e),r=await Promise.all(t.map(n=>k(e[n])?be(e[n],n):null).filter(Boolean));return t.reduce((n,i)=>({...n,[i]:k(e[i])?r.shift():e[i]}),{})}function $t(e){return e?k(e)||Object.values(e).some(k):!1}A.clean=Tt;A.toFetchArguments=Be;A.fetchOne=be;A.fetch=We;A.isDataSettings=k;A.hasDataSettings=$t;A.fetchImplementation=(...e)=>fetch(...e);function Pt(e){var t,r,n,i,o,a,s,l;let u,c=e.getAttribute("src");if(c){let D=Z(c);if(!D)throw new Error(`Could not parse FEAAS Component source: ${c}`);var{cdn:d,library:h,component:f,version:y,revision:m}=D}let v=e.getAttribute("data");if(v!=null&&v!="")try{u=typeof v=="string"?JSON.parse(v):{}}catch(D){console.error(D)}let b=e.getAttribute("fetch");return{data:u||{},cdn:(r=(t=e.getContextAttribute("cdn"))!==null&&t!==void 0?t:d)!==null&&r!==void 0?r:_,library:(n=e.getAttribute("library"))!==null&&n!==void 0?n:h,component:(i=e.getAttribute("component"))!==null&&i!==void 0?i:f,version:(a=(o=e.getAttribute("version"))!==null&&o!==void 0?o:y)!==null&&a!==void 0?a:"responsive",revision:(l=(s=e.getAttribute("revision"))!==null&&s!==void 0?s:m)!==null&&l!==void 0?l:"published",hostname:e.getAttribute("hostname"),template:e.getAttribute("template"),instance:e.getAttribute("instance"),editable:e.getAttribute("editable")!=null,suspended:e.getAttribute("suspended")!=null,lastModified:e.getAttribute("last-modified"),fetch:b=="false"||b==null&&e.hasAttribute("fetch")?[]:b==null||b=="true"?["data","template","stylesheet"]:b.split(/(\s+|\-)+/g).filter(Boolean)}}var te=class extends E{setData(t){this.set({data:t})}getProps(){return Pt(this)}isJSONAttribute(t){return t=="data"}attributeChangedCallback(t,r,n){r!==n&&((t=="library"||t=="component"||t=="revision"||t=="version")&&(this.payload=void 0,this.alreadyRendered&&this.connected&&(this.needsRefresh=!0,this.needsToFetchTemplate=!0)),super.attributeChangedCallback(t,r,n),t=="data"&&(this.needsRefresh=!0,(this.props.fetch.includes("data")||this.alreadyRendered||!A.hasDataSettings(this.props.data))&&this.fetchData()))}async fetchData(){this.readyData=void 0,this.whenDataReady=this.whenDataReady.restart();let t=await A.fetch(this.props.data),r=this.alreadyRendered;await this.whenDataReady.resolve(t),r&&this.advance()}getEditor(){var t;return(t=document.querySelector("feaas-context"))===null||t===void 0?void 0:t.refs.editor}constructor(){super(),this.readyData={},this.whenDataReady=x(r=>this.readyData=r,r=>this.onError(r)),this.defaultProps={cdn:_,revision:"published",version:"responsive",editable:!1,suspended:!1,data:{}},this.onLoad=r=>{this.payload=r,this.advance()};let t=this.getAttribute("data");this.getAttribute("data")||this.whenDataReady.resolve({}),this.addEventListener("click",()=>{this.props.editable&&this.edit()})}edit(){let t=this.getEditor();if(t!=null&&t.setTarget(this))return t.open(),!0}getOriginal(){let t=this.getAttribute("data-path-scope");if(t){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==t;)var n=r;return n}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){var t;if(this.getOriginal())return;let r=()=>{this.payload!=null&&(n||this.readyData&&this.onLoad(this.payload))};if(this.props.fetch.includes("stylesheet"))var n=Ie({...this.props}).then(()=>{n=null,r()});if(this.props.fetch.includes("template")||this.needsToFetchTemplate){this.needsToFetchTemplate=!1;var i=H(this.props,o=>{this.payload=o,this.needsRefresh=!0,r()})}else this.payload=(t=this.props.template)!==null&&t!==void 0?t: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(t=>t.tagName!="BR").length>0&&!this.needsRefresh)console.log("=== feaas component render dom",this.readyData),S(this,this.readyData);else{if(this.needsRefresh=!1,this.getOriginal()){console.log("+++ feaas comp defer rendering to original element");return}console.log("+++ feaas comp render dom content"),P(this,this.payload,this.readyData)}}};te.observedAttributes=["library","component","version","revision","hostname","cdn","template","data","instance","editable","with-stylesheet","fetch"];te.register("feaas-component");function Mt(e){return{opacity:e!=null&&e.getAttribute("opacity")?parseFloat(e==null?void 0:e.getAttribute("opacity")):1,hidden:(e==null?void 0:e.getAttribute("hidden"))!=null}}var re=class extends E{constructor(){super(...arguments),this.defaultProps={hidden:!1}}getProps(){return Mt(this)}attributeChangedCallback(t,r,n){if(r!==n)return t=="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(t,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;
|