Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@finsweet/attributes-cmsload

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@finsweet/attributes-cmsload - npm Package Compare versions

Comparing version 1.10.0 to 1.11.0

2

cmsload.js

@@ -1,1 +0,1 @@

"use strict";(()=>{var De=Object.create;var V=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var Ge=(e,t,o)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var We=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ye=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ve(t))!Fe.call(e,r)&&r!==o&&V(e,r,{get:()=>t[r],enumerable:!(n=Ke(t,r))||n.enumerable});return e};var qe=(e,t,o)=>(o=e!=null?De(He(e)):{},Ye(t||!e||!e.__esModule?V(o,"default",{value:e,enumerable:!0}):o,e));var z=(e,t,o)=>(Ge(e,typeof t!="symbol"?t+"":t,o),o);var Re=We(($r,ve)=>{ve.exports=Nt;function Nt(e,t,o,n){var r,i,s;return function(){if(s=this,i=Array.prototype.slice.call(arguments),r&&(o||n))return;if(!o)return l(),r=setTimeout(c,t),r;r=setTimeout(l,t),e.apply(s,i);function c(){l(),e.apply(s,i)}function l(){clearTimeout(r),r=null}}}});var L="fs-attributes";var J="animation";var Z="cmscore";var w="cmsload";var H="support";var b=class{static activateAlerts(){this.alertsActivated=!0}static alert(t,o){if(this.alertsActivated&&window.alert(t),o==="error")throw new Error(t)}};z(b,"alertsActivated",!1);var v=()=>{};function P(e,t,o,n){return e?(e.addEventListener(t,o,n),()=>e.removeEventListener(t,o,n)):v}var I="w--current";var ee={wrapper:"w-dyn-list",list:"w-dyn-items",item:"w-dyn-item",paginationWrapper:"w-pagination-wrapper",paginationNext:"w-pagination-next",paginationPrevious:"w-pagination-previous",pageCount:"w-page-count",emptyState:"w-dyn-empty"};var te={addToCartForm:"w-commerce-commerceaddtocartform"},oe={trigger:"w-lightbox"};var re=e=>e instanceof Element;var ne=e=>e instanceof HTMLAnchorElement;var ie=(e,t)=>!!e&&t.includes(e);var F=e=>e!=null;var B=e=>typeof e=="string",se=e=>typeof e=="number";var N=(e,t=!0)=>e.cloneNode(t);function U(e,t,o,n=!0){let r=o?[o]:[];if(!e)return r;let i=e.split(",").reduce((s,a)=>{let c=a.trim();return(!n||c)&&s.push(c),s},[]);if(t){let s=i.filter(a=>ie(a,t));return s.length?s:r}return i}var ae=new Map([["tiny","(max-width: 479px)"],["small","(max-width: 767px)"],["medium","(max-width: 991px)"],["main","(min-width: 992px)"]]);var G=()=>{for(let[e,t]of ae)if(window.matchMedia(t).matches)return e;return"main"};function le(e,t,o){var r;let n=window.fsAttributes[e];return n.destroy=o||v,(r=n.resolve)==null||r.call(n,t),t}var h=(e,t="1",o="iife")=>{let r=`${e}${o==="esm"?".esm":""}.js`;return`https://cdn.jsdelivr.net/npm/@finsweet/attributes-${e}@${t}/${r}`};var je=h(J,"1","esm"),ce=async()=>{let{fsAttributes:e}=window;e.animation||(e.animation={});let{animation:t}=e;if(t.import)return t.import;try{return t.import=import(je),t.import}catch(o){b.alert(`${o}`,"error");return}};var Xe=h(Z,"1"),me=async()=>{let{fsAttributes:e}=window;e.cmscore||(e.cmscore={});let{cmscore:t}=e;if(t.import)return t.import;try{return t.import=import(Xe),t.import.then(o=>{o&&(t.version||(t.version=o.version))}),t.import}catch(o){b.alert(`${o}`,"error");return}};var Qe=`${L}-${H}`,pe=async()=>{var r;let{fsAttributes:e,location:t}=window,{host:o,searchParams:n}=new URL(t.href);return!o.includes("webflow.io")||!n.has(Qe)?!1:(r=e.import)==null?void 0:r.call(e,H,"1")};var A=e=>t=>`${e}${t?`-${t}`:""}`,O=e=>{let t=(r,i,s)=>{let a=e[r],{key:c,values:l}=a,p;if(!i)return`[${c}]`;let u=l==null?void 0:l[i];B(u)?p=u:p=u(s&&"instanceIndex"in s?s.instanceIndex:void 0);let f=s&&"caseInsensitive"in s&&s.caseInsensitive?"i":"";if(!(s!=null&&s.operator))return`[${c}="${p}"${f}]`;switch(s.operator){case"prefixed":return`[${c}^="${p}"${f}]`;case"suffixed":return`[${c}$="${p}"${f}]`;case"contains":return`[${c}*="${p}"${f}]`}};function o(r,i){let s=t("element",r,i),a=(i==null?void 0:i.scope)||document;return i!=null&&i.all?[...a.querySelectorAll(s)]:a.querySelector(s)}return[t,o,(r,i)=>{let s=e[i];return s?r.getAttribute(s.key):null}]};var R={preventLoad:{key:`${L}-preventload`},debugMode:{key:`${L}-debug`},src:{key:"src",values:{finsweet:"@finsweet/attributes"}},dev:{key:`${L}-dev`}},[W,jo]=O(R);var ue=e=>{let{currentScript:t}=document,o={};if(!t)return{attributes:o,preventsLoad:!1};let r={preventsLoad:B(t.getAttribute(R.preventLoad.key)),attributes:o};for(let i in e){let s=t.getAttribute(e[i]);r.attributes[i]=s}return r};var de=({scriptAttributes:e,attributeKey:t,version:o,init:n})=>{var a;ze(),(a=window.fsAttributes)[t]||(a[t]={});let{preventsLoad:r,attributes:i}=ue(e),s=window.fsAttributes[t];s.version=o,s.init=n,r||(window.Webflow||(window.Webflow=[]),window.Webflow.push(()=>n(i)))},ze=()=>{let e=Ze();if(window.fsAttributes&&!Array.isArray(window.fsAttributes)){Y(window.fsAttributes,e);return}let t=Je(e);Y(t,e),et(t),window.fsAttributes=t,window.FsAttributes=window.fsAttributes,pe()},Je=e=>{let t={cms:{},push(...o){var n,r;for(let[i,s]of o)(r=(n=this[i])==null?void 0:n.loading)==null||r.then(s)},async import(o,n){let r=t[o];return r||new Promise(i=>{let s=document.createElement("script");s.src=h(o,n),s.async=!0,s.onload=()=>{let[a]=Y(t,[o]);i(a)},document.head.append(s)})},destroy(){var o,n;for(let r of e)(n=(o=window.fsAttributes[r])==null?void 0:o.destroy)==null||n.call(o)}};return t},Ze=()=>{let e=W("src","finsweet",{operator:"contains"}),t=W("dev");return[...document.querySelectorAll(`script${e}, script${t}`)].reduce((r,i)=>{var a;let s=i.getAttribute(R.dev.key)||((a=i.src.match(/[\w-. ]+(?=(\.js)$)/))==null?void 0:a[0]);return s&&!r.includes(s)&&r.push(s),r},[])},Y=(e,t)=>t.map(n=>{let r=e[n];return r||(e[n]={},r=e[n],r.loading=new Promise(i=>{r.resolve=s=>{i(s),delete r.resolve}}),r)}),et=e=>{let t=Array.isArray(window.fsAttributes)?window.fsAttributes:[];e.push(...t)};var fe="1.10.0";var ot="fs-cms-element",rt={wrapper:"wrapper",list:"list",item:"item",paginationWrapper:"pagination-wrapper",paginationNext:"pagination-next",paginationPrevious:"pagination-previous",pageCount:"page-count",emptyState:"empty"},T=e=>{let t=`.${ee[e]}`,o=`[${ot}="${rt[e]}"]`;return`:is(${t}, ${o})`},Ee=(e,t=document)=>{e=e.filter(i=>i);let o=e.join(", ")||T("wrapper");return[...t.querySelectorAll(o)].reduce((i,s)=>{if(!s)return i;let a=C(s,"wrapper");return!a||i.includes(a)||i.push(a),i},[])};function C(e,t,o=document){let n=typeof e=="string"?o.querySelector(e):e;if(!n)return;let r=n.closest(T("wrapper"));if(!r)return;let i=r.querySelector(T("list"));return t==="wrapper"?r:t==="list"?i:t==="items"?[...(i==null?void 0:i.querySelectorAll(`:scope > ${T("item")}`))||[]]:t==="pageCount"?r.querySelector(T("pageCount")):t==="empty"?r.querySelector(`:scope > ${T("emptyState")}`):t==="pagination"?r.querySelector(T("paginationWrapper")):r.querySelector(T(t==="next"?"paginationNext":"paginationPrevious"))}var $=async e=>{let o=await(await fetch(e)).text();return new DOMParser().parseFromString(o,"text/html")};var ge=({textContent:e})=>{if(!e)return;let[,t]=e.split("/");return t?parseInt(t.trim()):void 0},k=async(e,t,o,n)=>{n==null||n.preventDefault();let{items:r,itemsPerPage:i}=e;if(!(!t&&i===r.length)){if(i+o<=r.length)e.itemsPerPage=i+o;else if(t){let s=await e.once("renderitems");e.itemsPerPage=i+s.length}else e.itemsPerPage+=r.length-i;await e.renderItems(!0)}},Te=e=>{let{pagesQuery:t,currentPage:o,totalPages:n,paginationNext:r,paginationPrevious:i}=e;!o||(i&&(i.style.display=o!==1?"":"none",i.href=`?${t}=${o-1}`),r&&(r.style.display=o!==n?"":"none",r.href=`?${t}=${o+1}`))},Se=(e,{currentPage:t,totalPages:o})=>{e.setAttribute("aria-label",`Page ${t} of ${o}`),e.textContent=`${t} / ${o}`};var D=async(e,t,o)=>{var u;let{index:n,paginationNext:r,paginationPrevious:i,originalItemsPerPage:s}=t,a=Ee([],e)[n];if(!a)return;if(!i||!r){let f=C(a,"pagination"),d=C(a,"previous"),m=C(a,"next");if(d){let E=[...(f==null?void 0:f.children)||[]].indexOf(d);t.addPaginationButton(d,"paginationPrevious",E)}if(m){let E=[...(f==null?void 0:f.children)||[]].indexOf(m);d||(E+=1),t.addPaginationButton(m,"paginationNext",E)}}let c=(u=C(a,"next"))==null?void 0:u.href,l=C(a,"items"),{length:p}=l;return c&&s!==p&&(t.originalItemsPerPage=t.itemsPerPage=p),await t.addItems(l,o),c};var y=async e=>{let{paginationNext:t,paginationPrevious:o,paginationCount:n,extractingPaginationData:r}=e;if(!t&&!o)return;await r;let i=n?ge(n):void 0;await e.displayElement("loader"),i?await xe(e,i):await nt(e),await e.emit("finishload"),await e.displayElement("loader",!1)},nt=async e=>{let{paginationNext:t,currentPage:o}=e;if(o&&await xe(e,o),!t)return;let{href:n}=t,r=[n],i=async s=>{try{let a=await $(s),c=await D(a,e);if(!c||r.includes(c))return;r.push(c),await i(c)}catch(a){return}};await i(n)},xe=async(e,t)=>{let{paginationNext:o,paginationPrevious:n}=e;if(!o&&!n)return;let{pagesQuery:r,currentPage:i}=e;if(!r||!i)return;let{origin:s,pathname:a}=window.location;for(let l=i-1;l>=1;l--)try{let p=await $(`${s}${a}?${r}=${l}`);await D(p,e,"unshift")}catch(p){return}let c=[];for(let l=i+1;l<=t;l++)c[l]=(async()=>{let p=c[l-1];try{let u=await $(`${s}${a}?${r}=${l}`);await p,await D(u,e)}catch(u){await p;return}})();await Promise.all(c)};var Ae=async e=>{let{paginationNext:t,paginationPrevious:o,paginationCount:n,itemsPerPage:r}=e;if(!t)return;o&&(o.style.display="none"),n==null||n.remove();let i=!0,s=!1;e.initPagination(),e.on("renderitems",()=>{let{validItems:p,items:u,itemsPerPage:f}=e;if(!i&&u.length===f)return l();t.style.display=p.length>f?"":"none"});let c=P(t,"click",async p=>{p.preventDefault(),!s&&(s=!0,await k(e,i,r,p),s=!1)}),l=()=>{c(),t.style.display="none"};return await y(e),i=!1,l};var be=it;function it(e,t,o){var n=null,r=null,i=o&&o.leading,s=o&&o.trailing;i==null&&(i=!0),s==null&&(s=!i),i==!0&&(s=!1);var a=function(){n&&(clearTimeout(n),n=null)},c=function(){var p=r;a(),p&&p()},l=function(){var p=i&&!n,u=this,f=arguments;if(r=function(){return e.apply(u,f)},n||(n=setTimeout(function(){if(n=null,s)return r()},t)),p)return p=!1,r()};return l.cancel=a,l.flush=c,l}var S=`fs-${w}`,st="list",at="loader",lt="items-count",ct="visible-count",mt="visible-count-from",pt="visible-count-to",ut="scroll-anchor",dt="page-button",ft="page-dots",Et="empty",gt="mode",Tt={loadUnder:"load-under",renderAll:"render-all",pagination:"pagination",infinite:"infinite"},St="threshold",xt="pagesiblings",At="pageboundary",bt="animation",yt="easing",Ct="duration",_t="stagger",Lt="resetix",wt={true:"true"},Pt="showquery",ht={true:"true"},M={element:{key:`${S}-element`,values:{list:A(st),loader:A(at),itemsCount:A(lt),visibleCount:A(ct),visibleCountFrom:A(mt),visibleCountTo:A(pt),scrollAnchor:A(ut),empty:A(Et),pageButton:dt,pageDots:ft}},mode:{key:`${S}-${gt}`,values:Tt},threshold:{key:`${S}-${St}`},pageSiblings:{key:`${S}-${xt}`},pageBoundary:{key:`${S}-${At}`},animation:{key:`${S}-${bt}`},easing:{key:`${S}-${yt}`},duration:{key:`${S}-${Ct}`},stagger:{key:`${S}-${_t}`},resetIx:{key:`${S}-${Lt}`,values:wt},showQuery:{key:`${S}-${Pt}`,values:ht}},[K,x]=O(M),ye="-20",Ce=1,_e=1,Le={main:0,medium:1,small:2,tiny:3};var{pageSiblings:{key:vt},pageBoundary:{key:Rt},threshold:{key:Mt},showQuery:{key:It,values:Bt}}=M,we=e=>{let{paginationWrapper:t,paginationCount:o}=e;if(!t)return;let n=x("pageButton",{operator:"prefixed",scope:t}),r=x("pageDots",{operator:"prefixed",scope:t});r?r.remove():(r=document.createElement("div"),r.textContent="...");let i=e.getAttribute(Rt),s=(i?U(i):[]).map(d=>parseInt(d)),a=e.getAttribute(vt),c=(a?U(a):[]).map(d=>parseInt(d)),[l,p]=q(s,c),u=[s,c].some(({length:d})=>d>1),f=e.getAttribute(It)===Bt.true;return{paginationWrapper:t,pageButtonTemplate:n,pageDotsTemplate:r,paginationCount:o,pageBoundary:l,pageBoundaryValues:s,pageSiblings:p,pageSiblingsValues:c,hasBreakpoints:u,showQueryParams:f}},q=(e,t)=>{let o=G(),n=Le[o],r=[];[e,t].forEach((a,c)=>{for(let l=n;l>=0;l--){let p=a[l];if(se(p)){r[c]=p;break}}});let[i,s]=r;return i!=null||(i=_e),s!=null||(s=Ce),[i,s]},Pe=e=>1-parseInt(e.getAttribute(Mt)||ye)/100;var he=async e=>{let{list:t,paginationNext:o,paginationPrevious:n,paginationCount:r,itemsPerPage:i}=e;if(!t||!o)return;n&&(n.style.display="none"),r==null||r.remove();let s=Pe(e),a=!0,c=!1;e.initPagination(),e.on("renderitems",()=>{let{validItems:d,items:m,itemsPerPage:E}=e;if(!a&&m.length===E){f();return}o.style.display=d.length>E?"":"none"});let l=async d=>{d.preventDefault()},p=be(async()=>{if(c)return;let{innerHeight:d}=window,{bottom:m}=t.getBoundingClientRect(),E=s*d;m>0&&m<=E&&(c=!0,await k(e,a,i),c=!1)},100),u=new IntersectionObserver(d=>{for(let{isIntersecting:m}of d)window[m?"addEventListener":"removeEventListener"]("scroll",p)}),f=()=>{window.removeEventListener("scroll",p),o.removeEventListener("click",l),o.style.display="none",u.disconnect()};return o.addEventListener("click",l),u.observe(t),await y(e),a=!1,f};var Me=qe(Re(),1);var Ie=async e=>{let t=we(e);if(!t)return;let{paginationWrapper:o,pageButtonTemplate:n,pageDotsTemplate:r,paginationCount:i,pageBoundary:s,pageBoundaryValues:a,pageSiblings:c,pageSiblingsValues:l,hasBreakpoints:p,showQueryParams:u}=t,f;if(n){let{parentElement:E}=n;n.remove(),E&&(f={parentElement:E,pageButtonTemplate:n,pageDotsTemplate:r,pageBoundary:s,pageSiblings:c,renderedElements:new Map([])})}e.initPagination(u),e.on("renderitems",()=>Ut(e,f,i));let d=P(o,"click",E=>kt(E,f,e)),m;return f&&p&&(m=P(window,"resize",(0,Me.default)(()=>{Dt(f,e,a,l)},100))),await y(e),()=>{d(),m==null||m()}},Ut=(e,t,o,n=!0)=>{t&&Be(t,e),o&&Se(o,e),n&&Te(e)},Be=(e,t)=>{let{currentPage:o,totalPages:n}=t;if(!o)return;let{parentElement:r,renderedElements:i,pageBoundary:s,pageSiblings:a}=e,c=[...i],l=a*2+1,u=s*2+l+2,f=o-1<u-l,d=n-o<u-l;for(let m=1;m<=u;m++){let[E,j]=c[m-1]||[],[X]=c[m-2]||[];if(m>n){E&&(E.remove(),c[m-1]=void 0);continue}let g;n<=u?g=m:f?m>u-s?g=n-(u-m):m===u-s?g=null:g=m:d?m<s+1?g=m:m===s+1?g=null:g=n-(u-m):m<s+1?g=m:m>u-s?g=n-(u-m):m===s+1||m===u-s?g=null:g=o+(m-(s+1)-(1+a));let _;j!==g&&(E==null||E.remove(),_=Ot(e,g,t),c[m-1]=[_,g],X?r.insertBefore(_,X.nextSibling):r.appendChild(_),_.style.opacity="");let Q=_||E;!Q||$t(Q,g===o)}e.renderedElements=new Map([...c.filter(F)])},Ot=({pageButtonTemplate:e,pageDotsTemplate:t},o,{pagesQuery:n})=>{if(!o)return N(t);let r=N(e);return r.classList.remove(I),r.textContent=`${o}`,ne(r)&&n&&(r.href=`?${n}=${o}`),r},$t=(e,t)=>{t?(e.classList.add(I),e.setAttribute("aria-current","page")):(e.classList.remove(I),e.removeAttribute("aria-current"))},kt=(e,t,o)=>{let{target:n}=e;if(!re(n))return;let r=n.closest(K("element","pageButton",{operator:"prefixed"})),i=n.closest(T("paginationNext")),s=n.closest(T("paginationPrevious"));if(!r&&!i&&!s)return;e.preventDefault();let{currentPage:a,totalPages:c}=o;if(!a)return;let l;i&&(l=a+1),s&&(l=a-1),r&&(l=t==null?void 0:t.renderedElements.get(r)),!!l&&l>=1&&l<=c&&o.switchPage(l)},Dt=(e,t,...o)=>{let{pageBoundary:n,pageSiblings:r,renderedElements:i}=e,[s,a]=q(...o);if(!(n===s&&r===a)){e.pageBoundary=s,e.pageSiblings=a;for(let[c]of i)c.remove();i.clear(),Be(e,t)}};var Ne=async e=>{let{paginationNext:t,paginationPrevious:o,paginationCount:n}=e;!t||(t.style.display="none",o&&(o.style.display="none"),n==null||n.remove(),await y(e))};var{element:{key:Kt},mode:{key:Vt,values:{renderAll:Ht,infinite:Ft,pagination:Gt}},animation:{key:Wt},duration:{key:Ue},easing:{key:Oe},stagger:{key:Yt},resetIx:{key:qt,values:jt}}=M,$e=async(e,t)=>{let o=e.getInstanceIndex(Kt),{items:n}=e,{Webflow:r}=window,i=!!r&&"require"in r;t.addItemsAnimation(e,{animationKey:Wt,durationKey:Ue,easingKey:Oe,staggerKey:Yt}),t.addListAnimation(e,{durationKey:Ue,easingKey:Oe});let s=i&&!!r.require("commerce")&&n.some(({element:d})=>d.querySelector(`.${te.addToCartForm}`));s&&(e.restartCommerce=s);let a=i&&!!r.require("lightbox")&&n.some(({element:d})=>d.querySelector(`.${oe.trigger}`));a&&(e.restartLightbox=a);let c=e.getAttribute(qt)===jt.true;c&&(e.restartIx=c);let l=x("loader",{instanceIndex:o});l&&e.addLoader(l);let p=x("empty",{instanceIndex:o});if(p&&e.addEmptyElement(p),!e.itemsCount){let d=x("itemsCount",{instanceIndex:o});d&&e.addItemsCount(d)}if(!e.visibleCount||!e.visibleCountFrom||!e.visibleCountTo){let d=x("visibleCount",{instanceIndex:o}),m=x("visibleCountFrom",{instanceIndex:o}),E=x("visibleCountTo",{instanceIndex:o});e.addVisibleCount(d,m,E)}if(!e.scrollAnchor){let d=x("scrollAnchor",{instanceIndex:o});d&&(e.scrollAnchor=d)}let u=e.getAttribute(Vt);return u===Ht?await Ne(e):u===Ft?await he(e):u===Gt?await Ie(e):await Ae(e)};var ke=async()=>{let e=await me();if(!e)return[];let t=e.createCMSListInstances([K("element","list",{operator:"prefixed"})]),o=await Promise.all(t.map(n=>$e(n,e)));return le(w,t,()=>{var n;for(let r of t)(n=r.destroy)==null||n.call(r);for(let r of o)r==null||r()})};de({init:ke,version:fe,attributeKey:w});ce();})();
"use strict";(()=>{var Ge=Object.create;var F=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Xe=(e,t,o)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var Qe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ze=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ye(t))!je.call(e,r)&&r!==o&&F(e,r,{get:()=>t[r],enumerable:!(n=We(t,r))||n.enumerable});return e};var Je=(e,t,o)=>(o=e!=null?Ge(qe(e)):{},ze(t||!e||!e.__esModule?F(o,"default",{value:e,enumerable:!0}):o,e));var oe=(e,t,o)=>(Xe(e,typeof t!="symbol"?t+"":t,o),o);var Ue=Qe((zr,Ne)=>{Ne.exports=Ft;function Ft(e,t,o,n){var r,i,s;return function(){if(s=this,i=Array.prototype.slice.call(arguments),r&&(o||n))return;if(!o)return l(),r=setTimeout(c,t),r;r=setTimeout(l,t),e.apply(s,i);function c(){l(),e.apply(s,i)}function l(){clearTimeout(r),r=null}}}});var L="fs-attributes";var re="animation";var ne="cmscore";var P="cmsload";var G="support";var A=class{static activateAlerts(){this.alertsActivated=!0}static alert(t,o){if(this.alertsActivated&&window.alert(t),o==="error")throw new Error(t)}};oe(A,"alertsActivated",!1);var R=()=>{};function h(e,t,o,n){return e?(e.addEventListener(t,o,n),()=>e.removeEventListener(t,o,n)):R}var ie=e=>e instanceof Element;var se=e=>e instanceof HTMLAnchorElement;var ae=(e,t)=>!!e&&t.includes(e);var W=e=>e!=null;var B=e=>typeof e=="string",ce=e=>typeof e=="number";var N="w--current";var le={wrapper:"w-dyn-list",list:"w-dyn-items",item:"w-dyn-item",paginationWrapper:"w-pagination-wrapper",paginationNext:"w-pagination-next",paginationPrevious:"w-pagination-previous",pageCount:"w-page-count",emptyState:"w-dyn-empty"};var me={addToCartForm:"w-commerce-commerceaddtocartform"},ue={trigger:"w-lightbox"};var U=(e,t=!0)=>e.cloneNode(t);function O(e,t,o,n=!0){let r=o?[o]:[];if(!e)return r;let i=e.split(",").reduce((s,a)=>{let c=a.trim();return(!n||c)&&s.push(c),s},[]);if(t){let s=i.filter(a=>ae(a,t));return s.length?s:r}return i}var pe=new Map([["tiny","(max-width: 479px)"],["small","(max-width: 767px)"],["medium","(max-width: 991px)"],["main","(min-width: 992px)"]]);var Y=()=>{for(let[e,t]of pe)if(window.matchMedia(t).matches)return e;return"main"};var q=(e=document)=>{var o;let t="Last Published:";for(let n of e.childNodes)if(n.nodeType===Node.COMMENT_NODE&&((o=n.textContent)!=null&&o.includes(t))){let r=n.textContent.trim().split(t)[1];if(r)return new Date(r)}};var D=(e=document)=>e.documentElement.getAttribute("data-wf-site");function de(e,t,o){var r;let n=window.fsAttributes[e];return n.destroy=o||R,(r=n.resolve)==null||r.call(n,t),t}var v=(e,t="1",o="iife")=>{let r=`${e}${o==="esm"?".esm":""}.js`;return`https://cdn.jsdelivr.net/npm/@finsweet/attributes-${e}@${t}/${r}`};var Ze=v(re,"1","esm"),fe=async()=>{let{fsAttributes:e}=window;e.animation||(e.animation={});let{animation:t}=e;if(t.import)return t.import;try{return t.import=import(Ze),t.import}catch(o){A.alert(`${o}`,"error");return}};var et=v(ne,"1"),Ee=async()=>{let{fsAttributes:e}=window;e.cmscore||(e.cmscore={});let{cmscore:t}=e;if(t.import)return t.import;try{return t.import=import(et),t.import.then(o=>{o&&(t.version||(t.version=o.version))}),t.import}catch(o){A.alert(`${o}`,"error");return}};var tt=`${L}-${G}`,ge=async()=>{var r;let{fsAttributes:e,location:t}=window,{host:o,searchParams:n}=new URL(t.href);return!o.includes("webflow.io")||!n.has(tt)?!1:(r=e.import)==null?void 0:r.call(e,G,"1")};var b=e=>t=>`${e}${t?`-${t}`:""}`,$=e=>{let t=(r,i,s)=>{let a=e[r],{key:c,values:l}=a,u;if(!i)return`[${c}]`;let p=l==null?void 0:l[i];B(p)?u=p:u=p(s&&"instanceIndex"in s?s.instanceIndex:void 0);let f=s&&"caseInsensitive"in s&&s.caseInsensitive?"i":"";if(!(s!=null&&s.operator))return`[${c}="${u}"${f}]`;switch(s.operator){case"prefixed":return`[${c}^="${u}"${f}]`;case"suffixed":return`[${c}$="${u}"${f}]`;case"contains":return`[${c}*="${u}"${f}]`}};function o(r,i){let s=t("element",r,i),a=(i==null?void 0:i.scope)||document;return i!=null&&i.all?[...a.querySelectorAll(s)]:a.querySelector(s)}return[t,o,(r,i)=>{let s=e[i];return s?r.getAttribute(s.key):null}]};var I={preventLoad:{key:`${L}-preventload`},debugMode:{key:`${L}-debug`},src:{key:"src",values:{finsweet:"@finsweet/attributes"}},dev:{key:`${L}-dev`}},[j,ar]=$(I);var Te=e=>{let{currentScript:t}=document,o={};if(!t)return{attributes:o,preventsLoad:!1};let r={preventsLoad:B(t.getAttribute(I.preventLoad.key)),attributes:o};for(let i in e){let s=t.getAttribute(e[i]);r.attributes[i]=s}return r};var Se=({scriptAttributes:e,attributeKey:t,version:o,init:n})=>{var a;ot(),(a=window.fsAttributes)[t]||(a[t]={});let{preventsLoad:r,attributes:i}=Te(e),s=window.fsAttributes[t];s.version=o,s.init=n,r||(window.Webflow||(window.Webflow=[]),window.Webflow.push(()=>n(i)))},ot=()=>{let e=nt();if(window.fsAttributes&&!Array.isArray(window.fsAttributes)){X(window.fsAttributes,e);return}let t=rt(e);X(t,e),it(t),window.fsAttributes=t,window.FsAttributes=window.fsAttributes,ge()},rt=e=>{let t={cms:{},push(...o){var n,r;for(let[i,s]of o)(r=(n=this[i])==null?void 0:n.loading)==null||r.then(s)},async import(o,n){let r=t[o];return r||new Promise(i=>{let s=document.createElement("script");s.src=v(o,n),s.async=!0,s.onload=()=>{let[a]=X(t,[o]);i(a)},document.head.append(s)})},destroy(){var o,n;for(let r of e)(n=(o=window.fsAttributes[r])==null?void 0:o.destroy)==null||n.call(o)}};return t},nt=()=>{let e=j("src","finsweet",{operator:"contains"}),t=j("dev");return[...document.querySelectorAll(`script${e}, script${t}`)].reduce((r,i)=>{var a;let s=i.getAttribute(I.dev.key)||((a=i.src.match(/[\w-. ]+(?=(\.js)$)/))==null?void 0:a[0]);return s&&!r.includes(s)&&r.push(s),r},[])},X=(e,t)=>t.map(n=>{let r=e[n];return r||(e[n]={},r=e[n],r.loading=new Promise(i=>{r.resolve=s=>{i(s),delete r.resolve}}),r)}),it=e=>{let t=Array.isArray(window.fsAttributes)?window.fsAttributes:[];e.push(...t)};var xe="1.11.0";var at="fs-cms-element",ct={wrapper:"wrapper",list:"list",item:"item",paginationWrapper:"pagination-wrapper",paginationNext:"pagination-next",paginationPrevious:"pagination-previous",pageCount:"page-count",emptyState:"empty"},T=e=>{let t=`.${le[e]}`,o=`[${at}="${ct[e]}"]`;return`:is(${t}, ${o})`},be=(e,t=document)=>{e=e.filter(i=>i);let o=e.join(", ")||T("wrapper");return[...t.querySelectorAll(o)].reduce((i,s)=>{if(!s)return i;let a=C(s,"wrapper");return!a||i.includes(a)||i.push(a),i},[])};function C(e,t,o=document){let n=typeof e=="string"?o.querySelector(e):e;if(!n)return;let r=n.closest(T("wrapper"));if(!r)return;let i=r.querySelector(T("list"));return t==="wrapper"?r:t==="list"?i:t==="items"?[...(i==null?void 0:i.querySelectorAll(`:scope > ${T("item")}`))||[]]:t==="pageCount"?r.querySelector(T("pageCount")):t==="empty"?r.querySelector(`:scope > ${T("emptyState")}`):t==="pagination"?r.querySelector(T("paginationWrapper")):r.querySelector(T(t==="next"?"paginationNext":"paginationPrevious"))}var _="pages",Q=new Map,k=async e=>{try{let t=new URL(e,window.location.origin),o=D(),n=q(),r=o&&n?await mt(o,n):null,i=Q.get(t.href);if(i)return z(await i);let s=r?await ut(r,t.href):null;if(s)return z(s);i=lt(t.href),Q.set(t.href,i),s=await i;let a=z(s),c=D(a);return r&&c&&c===o&&(await pt(r,t.href,s),Q.delete(t.href)),a}catch{return null}},lt=async e=>(await fetch(e)).text(),z=e=>new DOMParser().parseFromString(e,"text/html"),mt=(e,t)=>{try{let o=window.indexedDB.open(e,t.getTime());return o.onupgradeneeded=()=>{let n=o.result;n.objectStoreNames.contains(_)&&n.deleteObjectStore(_),n.createObjectStore(_)},new Promise(n=>{o.onerror=()=>n(null),o.onsuccess=()=>{let r=o.result;n(r)}})}catch{return null}},ut=async(e,t)=>new Promise(o=>{let i=e.transaction(_).objectStore(_).get(t);i.onerror=()=>o(null),i.onsuccess=()=>o(i.result)}),pt=async(e,t,o)=>new Promise(n=>{let s=e.transaction(_,"readwrite").objectStore(_).put(o,t);s.onerror=()=>n(),s.onsuccess=()=>n()});var Ae=({textContent:e})=>{if(!e)return;let[,t]=e.split("/");return t?parseInt(t.trim()):void 0},K=async(e,t,o,n)=>{n==null||n.preventDefault();let{items:r,itemsPerPage:i}=e;if(!(!t&&i===r.length)){if(i+o<=r.length)e.itemsPerPage=i+o;else if(t){let s=await e.once("renderitems");e.itemsPerPage=i+s.length}else e.itemsPerPage+=r.length-i;await e.renderItems(!0)}},ye=e=>{let{pagesQuery:t,currentPage:o,totalPages:n,paginationNext:r,paginationPrevious:i}=e;o&&(i&&(i.style.display=o!==1?"":"none",i.href=`?${t}=${o-1}`),r&&(r.style.display=o!==n?"":"none",r.href=`?${t}=${o+1}`))},Ce=(e,{currentPage:t,totalPages:o})=>{e.setAttribute("aria-label",`Page ${t} of ${o}`),e.textContent=`${t} / ${o}`};var V=async(e,t,o)=>{var p;let{index:n,paginationNext:r,paginationPrevious:i,originalItemsPerPage:s}=t,a=be([],e)[n];if(!a)return;if(!i||!r){let f=C(a,"pagination"),d=C(a,"previous"),m=C(a,"next");if(d){let E=[...(f==null?void 0:f.children)||[]].indexOf(d);t.addPaginationButton(d,"paginationPrevious",E)}if(m){let E=[...(f==null?void 0:f.children)||[]].indexOf(m);d||(E+=1),t.addPaginationButton(m,"paginationNext",E)}}let c=(p=C(a,"next"))==null?void 0:p.href,l=C(a,"items"),{length:u}=l;return c&&s!==u&&(t.originalItemsPerPage=t.itemsPerPage=u),await t.addItems(l,o),c};var y=async e=>{let{paginationNext:t,paginationPrevious:o,paginationCount:n,extractingPaginationData:r}=e;if(!t&&!o)return;await r;let i=n?Ae(n):void 0;await e.displayElement("loader"),i?await _e(e,i):await dt(e),await e.emit("finishload"),await e.displayElement("loader",!1)},dt=async e=>{let{paginationNext:t,currentPage:o}=e;if(o&&await _e(e,o),!t)return;let{href:n}=t,r=[n],i=async s=>{let a=await k(s);if(!a)return;let c=await V(a,e);!c||r.includes(c)||(r.push(c),await i(c))};await i(n)},_e=async(e,t)=>{let{paginationNext:o,paginationPrevious:n}=e;if(!o&&!n)return;let{pagesQuery:r,currentPage:i}=e;if(!r||!i)return;let{origin:s,pathname:a}=window.location;for(let l=i-1;l>=1;l--){let u=await k(`${s}${a}?${r}=${l}`);if(!u)return;await V(u,e,"unshift")}let c=[];for(let l=i+1;l<=t;l++)c[l]=(async()=>{let u=c[l-1],p=await k(`${s}${a}?${r}=${l}`);await u,p&&await V(p,e)})();await Promise.all(c)};var we=async e=>{let{paginationNext:t,paginationPrevious:o,paginationCount:n,itemsPerPage:r}=e;if(!t)return;o&&(o.style.display="none"),n==null||n.remove();let i=!0,s=!1;e.initPagination(),e.on("renderitems",()=>{let{validItems:u,items:p,itemsPerPage:f}=e;if(!i&&p.length===f)return l();t.style.display=u.length>f?"":"none"});let c=h(t,"click",async u=>{u.preventDefault(),!s&&(s=!0,await K(e,i,r,u),s=!1)}),l=()=>{c(),t.style.display="none"};return await y(e),i=!1,l};var Le=ft;function ft(e,t,o){var n=null,r=null,i=o&&o.leading,s=o&&o.trailing;i==null&&(i=!0),s==null&&(s=!i),i==!0&&(s=!1);var a=function(){n&&(clearTimeout(n),n=null)},c=function(){var u=r;a(),u&&u()},l=function(){var u=i&&!n,p=this,f=arguments;if(r=function(){return e.apply(p,f)},n||(n=setTimeout(function(){if(n=null,s)return r()},t)),u)return u=!1,r()};return l.cancel=a,l.flush=c,l}var S=`fs-${P}`,Et="list",gt="loader",Tt="items-count",St="visible-count",xt="visible-count-from",bt="visible-count-to",At="scroll-anchor",yt="page-button",Ct="page-dots",_t="empty",wt="mode",Lt={loadUnder:"load-under",renderAll:"render-all",pagination:"pagination",infinite:"infinite"},Pt="threshold",ht="pagesiblings",vt="pageboundary",Rt="animation",It="easing",Mt="duration",Bt="stagger",Nt="resetix",Ut={true:"true"},Ot="showquery",Dt={true:"true"},M={element:{key:`${S}-element`,values:{list:b(Et),loader:b(gt),itemsCount:b(Tt),visibleCount:b(St),visibleCountFrom:b(xt),visibleCountTo:b(bt),scrollAnchor:b(At),empty:b(_t),pageButton:yt,pageDots:Ct}},mode:{key:`${S}-${wt}`,values:Lt},threshold:{key:`${S}-${Pt}`},pageSiblings:{key:`${S}-${ht}`},pageBoundary:{key:`${S}-${vt}`},animation:{key:`${S}-${Rt}`},easing:{key:`${S}-${It}`},duration:{key:`${S}-${Mt}`},stagger:{key:`${S}-${Bt}`},resetIx:{key:`${S}-${Nt}`,values:Ut},showQuery:{key:`${S}-${Ot}`,values:Dt}},[H,x]=$(M),Pe="-20",he=1,ve=1,Re={main:0,medium:1,small:2,tiny:3};var{pageSiblings:{key:$t},pageBoundary:{key:kt},threshold:{key:Kt},showQuery:{key:Vt,values:Ht}}=M,Ie=e=>{let{paginationWrapper:t,paginationCount:o}=e;if(!t)return;let n=x("pageButton",{operator:"prefixed",scope:t}),r=x("pageDots",{operator:"prefixed",scope:t});r?r.remove():(r=document.createElement("div"),r.textContent="...");let i=e.getAttribute(kt),s=(i?O(i):[]).map(d=>parseInt(d)),a=e.getAttribute($t),c=(a?O(a):[]).map(d=>parseInt(d)),[l,u]=J(s,c),p=[s,c].some(({length:d})=>d>1),f=e.getAttribute(Vt)===Ht.true;return{paginationWrapper:t,pageButtonTemplate:n,pageDotsTemplate:r,paginationCount:o,pageBoundary:l,pageBoundaryValues:s,pageSiblings:u,pageSiblingsValues:c,hasBreakpoints:p,showQueryParams:f}},J=(e,t)=>{let o=Y(),n=Re[o],r=[];[e,t].forEach((a,c)=>{for(let l=n;l>=0;l--){let u=a[l];if(ce(u)){r[c]=u;break}}});let[i,s]=r;return i!=null||(i=ve),s!=null||(s=he),[i,s]},Me=e=>1-parseInt(e.getAttribute(Kt)||Pe)/100;var Be=async e=>{let{list:t,paginationNext:o,paginationPrevious:n,paginationCount:r,itemsPerPage:i}=e;if(!t||!o)return;n&&(n.style.display="none"),r==null||r.remove();let s=Me(e),a=!0,c=!1;e.initPagination(),e.on("renderitems",()=>{let{validItems:d,items:m,itemsPerPage:E}=e;if(!a&&m.length===E){f();return}o.style.display=d.length>E?"":"none"});let l=async d=>{d.preventDefault()},u=Le(async()=>{if(c)return;let{innerHeight:d}=window,{bottom:m}=t.getBoundingClientRect(),E=s*d;m>0&&m<=E&&(c=!0,await K(e,a,i),c=!1)},100),p=new IntersectionObserver(d=>{for(let{isIntersecting:m}of d)window[m?"addEventListener":"removeEventListener"]("scroll",u)}),f=()=>{window.removeEventListener("scroll",u),o.removeEventListener("click",l),o.style.display="none",p.disconnect()};return o.addEventListener("click",l),p.observe(t),await y(e),a=!1,f};var Oe=Je(Ue(),1);var De=async e=>{let t=Ie(e);if(!t)return;let{paginationWrapper:o,pageButtonTemplate:n,pageDotsTemplate:r,paginationCount:i,pageBoundary:s,pageBoundaryValues:a,pageSiblings:c,pageSiblingsValues:l,hasBreakpoints:u,showQueryParams:p}=t,f;if(n){let{parentElement:E}=n;n.remove(),E&&(f={parentElement:E,pageButtonTemplate:n,pageDotsTemplate:r,pageBoundary:s,pageSiblings:c,renderedElements:new Map([])})}e.initPagination(p),e.on("renderitems",()=>Gt(e,f,i));let d=h(o,"click",E=>qt(E,f,e)),m;return f&&u&&(m=h(window,"resize",(0,Oe.default)(()=>{jt(f,e,a,l)},100))),await y(e),()=>{d(),m==null||m()}},Gt=(e,t,o,n=!0)=>{t&&$e(t,e),o&&Ce(o,e),n&&ye(e)},$e=(e,t)=>{let{currentPage:o,totalPages:n}=t;if(!o)return;let{parentElement:r,renderedElements:i,pageBoundary:s,pageSiblings:a}=e,c=[...i],l=a*2+1,p=s*2+l+2,f=o-1<p-l,d=n-o<p-l;for(let m=1;m<=p;m++){let[E,Z]=c[m-1]||[],[ee]=c[m-2]||[];if(m>n){E&&(E.remove(),c[m-1]=void 0);continue}let g;n<=p?g=m:f?m>p-s?g=n-(p-m):m===p-s?g=null:g=m:d?m<s+1?g=m:m===s+1?g=null:g=n-(p-m):m<s+1?g=m:m>p-s?g=n-(p-m):m===s+1||m===p-s?g=null:g=o+(m-(s+1)-(1+a));let w;Z!==g&&(E==null||E.remove(),w=Wt(e,g,t),c[m-1]=[w,g],ee?r.insertBefore(w,ee.nextSibling):r.appendChild(w),w.style.opacity="");let te=w||E;te&&Yt(te,g===o)}e.renderedElements=new Map([...c.filter(W)])},Wt=({pageButtonTemplate:e,pageDotsTemplate:t},o,{pagesQuery:n})=>{if(!o)return U(t);let r=U(e);return r.classList.remove(N),r.textContent=`${o}`,se(r)&&n&&(r.href=`?${n}=${o}`),r},Yt=(e,t)=>{t?(e.classList.add(N),e.setAttribute("aria-current","page")):(e.classList.remove(N),e.removeAttribute("aria-current"))},qt=(e,t,o)=>{let{target:n}=e;if(!ie(n))return;let r=n.closest(H("element","pageButton",{operator:"prefixed"})),i=n.closest(T("paginationNext")),s=n.closest(T("paginationPrevious"));if(!r&&!i&&!s)return;e.preventDefault();let{currentPage:a,totalPages:c}=o;if(!a)return;let l;i&&(l=a+1),s&&(l=a-1),r&&(l=t==null?void 0:t.renderedElements.get(r)),l&&l>=1&&l<=c&&o.switchPage(l)},jt=(e,t,...o)=>{let{pageBoundary:n,pageSiblings:r,renderedElements:i}=e,[s,a]=J(...o);if(!(n===s&&r===a)){e.pageBoundary=s,e.pageSiblings=a;for(let[c]of i)c.remove();i.clear(),$e(e,t)}};var ke=async e=>{let{paginationNext:t,paginationPrevious:o,paginationCount:n}=e;t&&(t.style.display="none",o&&(o.style.display="none"),n==null||n.remove(),await y(e))};var{element:{key:Xt},mode:{key:Qt,values:{renderAll:zt,infinite:Jt,pagination:Zt}},animation:{key:eo},duration:{key:Ke},easing:{key:Ve},stagger:{key:to},resetIx:{key:oo,values:ro}}=M,He=async(e,t)=>{let o=e.getInstanceIndex(Xt),{items:n}=e,{Webflow:r}=window,i=!!r&&"require"in r;t.addItemsAnimation(e,{animationKey:eo,durationKey:Ke,easingKey:Ve,staggerKey:to}),t.addListAnimation(e,{durationKey:Ke,easingKey:Ve});let s=i&&!!r.require("commerce")&&n.some(({element:d})=>d.querySelector(`.${me.addToCartForm}`));s&&(e.restartCommerce=s);let a=i&&!!r.require("lightbox")&&n.some(({element:d})=>d.querySelector(`.${ue.trigger}`));a&&(e.restartLightbox=a);let c=e.getAttribute(oo)===ro.true;c&&(e.restartIx=c);let l=x("loader",{instanceIndex:o});l&&e.addLoader(l);let u=x("empty",{instanceIndex:o});if(u&&e.addEmptyElement(u),!e.itemsCount){let d=x("itemsCount",{instanceIndex:o});d&&e.addItemsCount(d)}if(!e.visibleCount||!e.visibleCountFrom||!e.visibleCountTo){let d=x("visibleCount",{instanceIndex:o}),m=x("visibleCountFrom",{instanceIndex:o}),E=x("visibleCountTo",{instanceIndex:o});e.addVisibleCount(d,m,E)}if(!e.scrollAnchor){let d=x("scrollAnchor",{instanceIndex:o});d&&(e.scrollAnchor=d)}let p=e.getAttribute(Qt);return p===zt?await ke(e):p===Jt?await Be(e):p===Zt?await De(e):await we(e)};var Fe=async()=>{let e=await Ee();if(!e)return[];let t=e.createCMSListInstances([H("element","list",{operator:"prefixed"})]),o=await Promise.all(t.map(n=>He(n,e)));return de(P,t,()=>{var n;for(let r of t)(n=r.destroy)==null||n.call(r);for(let r of o)r==null||r()})};Se({init:Fe,version:xe,attributeKey:P});fe();})();
{
"name": "@finsweet/attributes-cmsload",
"version": "1.10.0",
"version": "1.11.0",
"description": "Load More Webflow CMS items on the page after the page has loaded.",

@@ -33,3 +33,3 @@ "homepage": "https://www.finsweet.com/attributes",

"just-debounce": "^1.1.0",
"just-throttle": "^4.0.1"
"just-throttle": "^4.2.0"
},

@@ -41,2 +41,3 @@ "scripts": {

"lint": "eslint ./src && prettier --check ./src",
"lint:fix": "eslint ./src --fix",
"check": "tsc --noEmit",

@@ -43,0 +44,0 @@ "format": "prettier --write ./src",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc