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

@finsweet/attributes-cmscore

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@finsweet/attributes-cmscore - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

4

cmscore.js

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

var ae=Object.create;var P=Object.defineProperty,ue=Object.defineProperties,ce=Object.getOwnPropertyDescriptor,pe=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,fe=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var U=(r,e,t)=>e in r?P(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,M=(r,e)=>{for(var t in e||(e={}))O.call(e,t)&&U(r,t,e[t]);if(I)for(var t of I(e))G.call(e,t)&&U(r,t,e[t]);return r},J=(r,e)=>ue(r,pe(e)),de=r=>P(r,"__esModule",{value:!0});var Q=(r,e)=>{var t={};for(var n in r)O.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&I)for(var n of I(r))e.indexOf(n)<0&&G.call(r,n)&&(t[n]=r[n]);return t};var ge=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var be=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of me(e))!O.call(r,n)&&n!=="default"&&P(r,n,{get:()=>e[n],enumerable:!(t=ce(e,n))||t.enumerable});return r},ye=r=>be(de(P(r!=null?ae(fe(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var u=(r,e,t)=>new Promise((n,i)=>{var o=a=>{try{l(t.next(a))}catch(c){i(c)}},s=a=>{try{l(t.throw(a))}catch(c){i(c)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,s);l((t=t.apply(r,e)).next())});var te=ge((We,ee)=>{"use strict";var g=new WeakMap,T=new WeakMap,C=new WeakMap,V=Symbol("anyProducer"),X=Promise.resolve(),v=Symbol("listenerAdded"),W=Symbol("listenerRemoved"),k=!1;function h(r){if(typeof r!="string"&&typeof r!="symbol")throw new TypeError("eventName must be a string or a symbol")}function D(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function E(r,e){let t=T.get(r);return t.has(e)||t.set(e,new Set),t.get(e)}function x(r,e){let t=typeof e=="string"||typeof e=="symbol"?e:V,n=C.get(r);return n.has(t)||n.set(t,new Set),n.get(t)}function he(r,e,t){let n=C.get(r);if(n.has(e))for(let i of n.get(e))i.enqueue(t);if(n.has(V)){let i=Promise.all([e,t]);for(let o of n.get(V))o.enqueue(i)}}function Y(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[],o={enqueue(s){i.push(s),n()},finish(){t=!0,n()}};for(let s of e)x(r,s).add(o);return{next(){return u(this,null,function*(){return i?i.length===0?t?(i=void 0,this.next()):(yield new Promise(s=>{n=s}),this.next()):{done:!1,value:yield i.shift()}:{done:!0}})},return(l){return u(this,arguments,function*(s){i=void 0;for(let a of e)x(r,a).delete(o);return n(),arguments.length>0?{done:!0,value:yield s}:{done:!0}})},[Symbol.asyncIterator](){return this}}}function Z(r){if(r===void 0)return N;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(let e of r)if(!N.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}var F=r=>r===v||r===W,b=class{static mixin(e,t){return t=Z(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(let s of t)if(n.prototype[s]!==void 0)throw new Error(`The property \`${s}\` already exists on \`target\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new b}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});let o=s=>function(...l){return this[e][s](...l)};for(let s of t)Object.defineProperty(n.prototype,s,{enumerable:!1,value:o(s)});return n}}static get isDebugEnabled(){if(typeof process!="object")return k;let{env:e}=process||{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||k}static set isDebugEnabled(e){k=e}constructor(e={}){g.set(this,new Set),T.set(this,new Map),C.set(this,new Map),this.debug=e.debug||{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,o)=>{o=JSON.stringify(o),typeof i=="symbol"&&(i=i.toString());let s=new Date,l=`${s.getHours()}:${s.getMinutes()}:${s.getSeconds()}.${s.getMilliseconds()}`;console.log(`[${l}][emittery:${t}][${n}] Event Name: ${i}
data: ${o}`)})}logIfDebugEnabled(e,t,n){(b.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){D(t),e=Array.isArray(e)?e:[e];for(let n of e)h(n),E(this,n).add(t),this.logIfDebugEnabled("subscribe",n,void 0),F(n)||this.emit(v,{eventName:n,listener:t});return this.off.bind(this,e,t)}off(e,t){D(t),e=Array.isArray(e)?e:[e];for(let n of e)h(n),E(this,n).delete(t),this.logIfDebugEnabled("unsubscribe",n,void 0),F(n)||this.emit(W,{eventName:n,listener:t})}once(e){return new Promise(t=>{let n=this.on(e,i=>{n(),t(i)})})}events(e){e=Array.isArray(e)?e:[e];for(let t of e)h(t);return Y(this,e)}emit(e,t){return u(this,null,function*(){h(e),this.logIfDebugEnabled("emit",e,t),he(this,e,t);let n=E(this,e),i=g.get(this),o=[...n],s=F(e)?[]:[...i];yield X,yield Promise.all([...o.map(l=>u(this,null,function*(){if(n.has(l))return l(t)})),...s.map(l=>u(this,null,function*(){if(i.has(l))return l(e,t)}))])})}emitSerial(e,t){return u(this,null,function*(){h(e),this.logIfDebugEnabled("emitSerial",e,t);let n=E(this,e),i=g.get(this),o=[...n],s=[...i];yield X;for(let l of o)n.has(l)&&(yield l(t));for(let l of s)i.has(l)&&(yield l(e,t))})}onAny(e){return D(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),g.get(this).add(e),this.emit(v,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Y(this)}offAny(e){D(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),this.emit(W,{listener:e}),g.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(let t of e)if(this.logIfDebugEnabled("clear",t,void 0),typeof t=="string"||typeof t=="symbol"){E(this,t).clear();let n=x(this,t);for(let i of n)i.finish();n.clear()}else{g.get(this).clear();for(let n of T.get(this).values())n.clear();for(let n of C.get(this).values()){for(let i of n)i.finish();n.clear()}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(let n of e){if(typeof n=="string"){t+=g.get(this).size+E(this,n).size+x(this,n).size+x(this).size;continue}typeof n!="undefined"&&h(n),t+=g.get(this).size;for(let i of T.get(this).values())t+=i.size;for(let i of C.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Z(t);for(let n of t){if(e[n]!==void 0)throw new Error(`The property \`${n}\` already exists on \`target\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}},N=Object.getOwnPropertyNames(b.prototype).filter(r=>r!=="constructor");Object.defineProperty(b,"listenerAdded",{value:v,writable:!1,enumerable:!0,configurable:!1});Object.defineProperty(b,"listenerRemoved",{value:W,writable:!1,enumerable:!0,configurable:!1});ee.exports=b});var re=ye(te());var A=class{constructor(e,t,n){this.element=e;this.list=t;this.currentIndex=n;this.props={};this.mustShow=!0;var i;this.href=(i=e.querySelector("a"))==null?void 0:i.href}collectProps({fieldKey:e,typeKey:t,rangeKey:n}){let{element:i,props:o}=this,s=[...i.querySelectorAll(`[${e}]`)];for(let l of s){let a=l.getAttribute(e),c=t?l.getAttribute(t):void 0,p=n?l.getAttribute(n):void 0,{textContent:f}=l;if(!a||!f)continue;o[a]||(o[a]={type:c,range:p,values:new Set});let d=o[a],{values:L}=d;if(p==="from"||p==="to"){let y=[...L];y[p==="from"?0:1]=f,d.values=new Set(y)}L.add(f)}}};var w=class{static activateAlerts(){this.alertsActivated=!0}static alert(e,t){if(this.alertsActivated&&window.alert(e),t==="error")throw new Error(e)}};w.alertsActivated=!1;var S={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 _=r=>{let e=r.split("-"),t=parseInt(e[e.length-1]);if(!isNaN(t))return t};var B=r=>new Promise(e=>setTimeout(e,r));var q=r=>r!=null;var{wrapper:Ee,list:we,paginationWrapper:Se,paginationNext:Ce,paginationPrevious:xe,emptyState:Ae,pageCount:Le}=S;function m(r,e,t=document){let n=typeof r=="string"?t.querySelector(r):r;if(!n)return;let i=n.closest(`.${Ee}`);if(!i)return;let o=i.querySelector(`.${we}`);return e==="wrapper"?i:e==="list"?o:e==="items"?[...(o==null?void 0:o.children)||[]]:e==="empty"?i.querySelector(`.${Ae}`):e==="pageCount"?i.querySelector(`.${Le}`):e==="pagination"?i.querySelector(`.${Se}`):i.querySelector(`.${e==="next"?Ce:xe}`)}var j=(r,e=document)=>{r=r.filter(o=>o);let t=r.join(", ")||`.${S.wrapper}`;return[...e.querySelectorAll(t)].reduce((o,s)=>{if(!s)return o;let l=m(s,"wrapper");return!l||o.includes(l)||o.push(l),o},[])};var H=(r,e)=>{let t=r.getAttribute(e);return t?_(t):void 0};var ne=(r,e=!1)=>u(void 0,null,function*(){let{items:t,itemsPerPage:n,currentPage:i,emptyState:o}=r,s=[],l=[];r.visibleItems=0;for(let c of t){let{mustShow:p,currentIndex:f}=c;if(p){if(r.visibleItems+=1,!i){l.push(c);continue}r.visibleItems>(i-1)*n&&r.visibleItems<=i*n?l.push(c):typeof f=="number"&&s.push(c)}else typeof f=="number"&&s.push(c)}let a=[];if(l.forEach((c,p)=>{c.currentIndex!==p&&a.push([c,p,l[p-1]])}),e||(yield r.displayElement(o?"emptyElement":"list",!1)),yield Promise.all([...Pe(s,r,e),...Ie(a,r,e)]),yield r.emit("renderitems",l),!e){let c=!r.visibleItems;r.emptyState=c,yield r.displayElement(c?"emptyElement":"list")}}),Pe=(r,{itemsAnimation:e},t)=>r.map(n=>u(void 0,null,function*(){let{element:i}=n;if(t&&e){let{animateOut:o,options:s}=e;yield o(i,M({remove:!0},s))}else i.remove();n.currentIndex=void 0})),Ie=(r,{list:e,itemsAnimation:t},n)=>r.map((a,c)=>u(void 0,[a,c],function*([i,o,s],l){i.animating=new Promise(p=>u(void 0,null,function*(){i.rendering=new Promise(f=>u(void 0,null,function*(){yield s==null?void 0:s.rendering;let{element:d,currentIndex:L}=i,y=(s==null?void 0:s.element)||null;if(typeof L!="number"&&n&&t){let{prepareIn:ie,animateIn:oe,options:se}=t,R=se||{},{stagger:z}=R,le=Q(R,["stagger"]),K=M({target:e,insertAfter:y},le);ie(d,K),f(),z&&(yield B(z*l)),yield oe(d,J(M({},K),{prepared:!0}))}else y?e.insertBefore(d,y.nextSibling):e.prepend(d),f();p()}))})),yield i.rendering,i.currentIndex=o}));var $=class extends re.default{constructor(e,t){super();this.wrapper=e;this.index=t;this.visibleItems=0;this.list=m(this.wrapper,"list"),this.paginationWrapper=m(this.wrapper,"pagination"),this.paginationNext=m(this.wrapper,"next"),this.paginationPrevious=m(this.wrapper,"previous"),this.paginationCount=m(this.wrapper,"pageCount");let n=m(this.wrapper,"items");this.visibleItems=this.itemsPerPage=n.length,this.items=n.map((i,o)=>new A(i,this.list,o))}addItems(e){return u(this,null,function*(){let{items:t,list:n}=this,i=e.map(o=>new A(o,n));t.push(...i),yield this.emit("shouldnest",i),yield this.emit("shouldcollectprops",i),yield this.emit("shouldsort",i),yield this.emit("shouldfilter"),yield this.renderItems(!0),yield this.emit("additems",i)})}renderItems(e){return u(this,null,function*(){yield this.renderingQueue,this.renderingQueue=ne(this,e)})}displayElement(e,t=!0,n=!0){return u(this,null,function*(){let{listAnimation:i}=this,o=this[e];if(!!o)if(i&&n){let{animateIn:s,animateOut:l,options:a}=i;yield(t?s:l)(o,a)}else o.style.display=t?"":"none"})}switchPage(e){return u(this,null,function*(){let{currentPage:t}=this;e!==t&&(yield this.emit("switchpage",e),this.currentPage=e,t&&(yield this.renderItems()))})}addEmptyElement(e){let{wrapper:t,list:n,emptyElement:i}=this;i||(e.style.display="none",t.insertBefore(e,n.nextSibling),this.emptyElement=e)}addPaginationPrevious(e){var i;let{paginationPrevious:t,paginationNext:n}=this;t||(e.style.display="none",(i=n==null?void 0:n.parentElement)==null||i.prepend(e),this.paginationPrevious=e)}addLoader(e){let{loader:t}=this;t||(e.style.display="none",this.loader=e)}scrollToAnchor(){var e;(e=this.scrollAnchor)==null||e.scrollIntoView({behavior:"smooth"})}getAttribute(e){let{wrapper:t,list:n}=this;return t.getAttribute(e)||n.getAttribute(e)}getInstanceIndex(e){let{wrapper:t,list:n}=this;return H(t,e)||H(n,e)}};var Me=r=>j(r).map(Te).filter(q),Te=r=>{var s,l;let e=m(r,"wrapper");if(!e){w.alert("The element is not a Collection List.","error");return}let{fsAttributes:t}=window;(s=t.cms).lists||(s.lists=[]),(l=t.cms).listElements||(l.listElements=[...document.querySelectorAll(`.${S.wrapper}`)]);let{lists:n,listElements:i}=t.cms,o=i.indexOf(e);if(o!==-1)return n[o]||(n[o]=new $(e,o)),n[o]};export{A as CMSItem,$ as CMSList,Me as createCMSListInstances};
var ae=Object.create;var P=Object.defineProperty,ue=Object.defineProperties,ce=Object.getOwnPropertyDescriptor,pe=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,fe=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var U=(r,e,t)=>e in r?P(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,M=(r,e)=>{for(var t in e||(e={}))O.call(e,t)&&U(r,t,e[t]);if(I)for(var t of I(e))G.call(e,t)&&U(r,t,e[t]);return r},J=(r,e)=>ue(r,pe(e)),de=r=>P(r,"__esModule",{value:!0});var Q=(r,e)=>{var t={};for(var n in r)O.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&I)for(var n of I(r))e.indexOf(n)<0&&G.call(r,n)&&(t[n]=r[n]);return t};var ge=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var be=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of me(e))!O.call(r,n)&&n!=="default"&&P(r,n,{get:()=>e[n],enumerable:!(t=ce(e,n))||t.enumerable});return r},ye=r=>be(de(P(r!=null?ae(fe(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var c=(r,e,t)=>new Promise((n,i)=>{var o=a=>{try{l(t.next(a))}catch(d){i(d)}},s=a=>{try{l(t.throw(a))}catch(d){i(d)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(o,s);l((t=t.apply(r,e)).next())});var te=ge((We,ee)=>{"use strict";var g=new WeakMap,T=new WeakMap,x=new WeakMap,V=Symbol("anyProducer"),X=Promise.resolve(),v=Symbol("listenerAdded"),W=Symbol("listenerRemoved"),k=!1;function h(r){if(typeof r!="string"&&typeof r!="symbol")throw new TypeError("eventName must be a string or a symbol")}function D(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function E(r,e){let t=T.get(r);return t.has(e)||t.set(e,new Set),t.get(e)}function A(r,e){let t=typeof e=="string"||typeof e=="symbol"?e:V,n=x.get(r);return n.has(t)||n.set(t,new Set),n.get(t)}function he(r,e,t){let n=x.get(r);if(n.has(e))for(let i of n.get(e))i.enqueue(t);if(n.has(V)){let i=Promise.all([e,t]);for(let o of n.get(V))o.enqueue(i)}}function Y(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[],o={enqueue(s){i.push(s),n()},finish(){t=!0,n()}};for(let s of e)A(r,s).add(o);return{next(){return c(this,null,function*(){return i?i.length===0?t?(i=void 0,this.next()):(yield new Promise(s=>{n=s}),this.next()):{done:!1,value:yield i.shift()}:{done:!0}})},return(l){return c(this,arguments,function*(s){i=void 0;for(let a of e)A(r,a).delete(o);return n(),arguments.length>0?{done:!0,value:yield s}:{done:!0}})},[Symbol.asyncIterator](){return this}}}function Z(r){if(r===void 0)return N;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(let e of r)if(!N.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}var F=r=>r===v||r===W,b=class{static mixin(e,t){return t=Z(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(let s of t)if(n.prototype[s]!==void 0)throw new Error(`The property \`${s}\` already exists on \`target\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new b}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});let o=s=>function(...l){return this[e][s](...l)};for(let s of t)Object.defineProperty(n.prototype,s,{enumerable:!1,value:o(s)});return n}}static get isDebugEnabled(){if(typeof process!="object")return k;let{env:e}=process||{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||k}static set isDebugEnabled(e){k=e}constructor(e={}){g.set(this,new Set),T.set(this,new Map),x.set(this,new Map),this.debug=e.debug||{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,o)=>{o=JSON.stringify(o),typeof i=="symbol"&&(i=i.toString());let s=new Date,l=`${s.getHours()}:${s.getMinutes()}:${s.getSeconds()}.${s.getMilliseconds()}`;console.log(`[${l}][emittery:${t}][${n}] Event Name: ${i}
data: ${o}`)})}logIfDebugEnabled(e,t,n){(b.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){D(t),e=Array.isArray(e)?e:[e];for(let n of e)h(n),E(this,n).add(t),this.logIfDebugEnabled("subscribe",n,void 0),F(n)||this.emit(v,{eventName:n,listener:t});return this.off.bind(this,e,t)}off(e,t){D(t),e=Array.isArray(e)?e:[e];for(let n of e)h(n),E(this,n).delete(t),this.logIfDebugEnabled("unsubscribe",n,void 0),F(n)||this.emit(W,{eventName:n,listener:t})}once(e){return new Promise(t=>{let n=this.on(e,i=>{n(),t(i)})})}events(e){e=Array.isArray(e)?e:[e];for(let t of e)h(t);return Y(this,e)}emit(e,t){return c(this,null,function*(){h(e),this.logIfDebugEnabled("emit",e,t),he(this,e,t);let n=E(this,e),i=g.get(this),o=[...n],s=F(e)?[]:[...i];yield X,yield Promise.all([...o.map(l=>c(this,null,function*(){if(n.has(l))return l(t)})),...s.map(l=>c(this,null,function*(){if(i.has(l))return l(e,t)}))])})}emitSerial(e,t){return c(this,null,function*(){h(e),this.logIfDebugEnabled("emitSerial",e,t);let n=E(this,e),i=g.get(this),o=[...n],s=[...i];yield X;for(let l of o)n.has(l)&&(yield l(t));for(let l of s)i.has(l)&&(yield l(e,t))})}onAny(e){return D(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),g.get(this).add(e),this.emit(v,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Y(this)}offAny(e){D(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),this.emit(W,{listener:e}),g.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(let t of e)if(this.logIfDebugEnabled("clear",t,void 0),typeof t=="string"||typeof t=="symbol"){E(this,t).clear();let n=A(this,t);for(let i of n)i.finish();n.clear()}else{g.get(this).clear();for(let n of T.get(this).values())n.clear();for(let n of x.get(this).values()){for(let i of n)i.finish();n.clear()}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(let n of e){if(typeof n=="string"){t+=g.get(this).size+E(this,n).size+A(this,n).size+A(this).size;continue}typeof n!="undefined"&&h(n),t+=g.get(this).size;for(let i of T.get(this).values())t+=i.size;for(let i of x.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Z(t);for(let n of t){if(e[n]!==void 0)throw new Error(`The property \`${n}\` already exists on \`target\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}},N=Object.getOwnPropertyNames(b.prototype).filter(r=>r!=="constructor");Object.defineProperty(b,"listenerAdded",{value:v,writable:!1,enumerable:!0,configurable:!1});Object.defineProperty(b,"listenerRemoved",{value:W,writable:!1,enumerable:!0,configurable:!1});ee.exports=b});var re=ye(te());var L=class{constructor(e,t,n){this.element=e;this.list=t;this.currentIndex=n;this.props={};this.mustShow=!0;var i;this.href=(i=e.querySelector("a"))==null?void 0:i.href}collectProps({fieldKey:e,typeKey:t,rangeKey:n}){let{element:i,props:o}=this,s=[...i.querySelectorAll(`[${e}]`)];for(let l of s){let a=l.getAttribute(e),d=t?l.getAttribute(t):void 0,u=n?l.getAttribute(n):void 0,{textContent:p}=l;if(!a||!p)continue;o[a]||(o[a]={type:d,range:u,values:new Set});let f=o[a],{values:C}=f;if(u==="from"||u==="to"){let y=[...C];y[u==="from"?0:1]=p,f.values=new Set(y)}C.add(p)}}};var w=class{static activateAlerts(){this.alertsActivated=!0}static alert(e,t){if(this.alertsActivated&&window.alert(e),t==="error")throw new Error(e)}};w.alertsActivated=!1;var S={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 _=r=>{let e=r.split("-"),t=parseInt(e[e.length-1]);if(!isNaN(t))return t};var B=r=>new Promise(e=>setTimeout(e,r));var q=r=>r!=null;var{wrapper:Ee,list:we,paginationWrapper:Se,paginationNext:Ce,paginationPrevious:xe,emptyState:Ae,pageCount:Le}=S;function m(r,e,t=document){let n=typeof r=="string"?t.querySelector(r):r;if(!n)return;let i=n.closest(`.${Ee}`);if(!i)return;let o=i.querySelector(`.${we}`);return e==="wrapper"?i:e==="list"?o:e==="items"?[...(o==null?void 0:o.children)||[]]:e==="empty"?i.querySelector(`.${Ae}`):e==="pageCount"?i.querySelector(`.${Le}`):e==="pagination"?i.querySelector(`.${Se}`):i.querySelector(`.${e==="next"?Ce:xe}`)}var j=(r,e=document)=>{r=r.filter(o=>o);let t=r.join(", ")||`.${S.wrapper}`;return[...e.querySelectorAll(t)].reduce((o,s)=>{if(!s)return o;let l=m(s,"wrapper");return!l||o.includes(l)||o.push(l),o},[])};var H=(r,e)=>{let t=r.getAttribute(e);return t?_(t):void 0};var ne=(r,e=!1)=>c(void 0,null,function*(){let{items:t,itemsPerPage:n,currentPage:i,emptyState:o}=r,s=[],l=[],a=0;for(let u of t){let{mustShow:p,currentIndex:f}=u;if(p){if(a+=1,!i){l.push(u);continue}a>(i-1)*n&&a<=i*n?l.push(u):typeof f=="number"&&s.push(u)}else typeof f=="number"&&s.push(u)}r.visibleItems=a,r.totalPages=Math.ceil(a/n);let d=[];if(l.forEach((u,p)=>{u.currentIndex!==p&&d.push([u,p,l[p-1]])}),e||(yield r.displayElement(o?"emptyElement":"list",!1)),yield Promise.all([...Pe(s,r,e),...Ie(d,r,e)]),yield r.emit("renderitems",l),!e){let u=!a;r.emptyState=u,yield r.displayElement(u?"emptyElement":"list")}}),Pe=(r,{itemsAnimation:e},t)=>r.map(n=>c(void 0,null,function*(){let{element:i}=n;if(t&&e){let{animateOut:o,options:s}=e;yield o(i,M({remove:!0},s))}else i.remove();n.currentIndex=void 0})),Ie=(r,{list:e,itemsAnimation:t},n)=>r.map((a,d)=>c(void 0,[a,d],function*([i,o,s],l){i.animating=new Promise(u=>c(void 0,null,function*(){i.rendering=new Promise(p=>c(void 0,null,function*(){yield s==null?void 0:s.rendering;let{element:f,currentIndex:C}=i,y=(s==null?void 0:s.element)||null;if(typeof C!="number"&&n&&t){let{prepareIn:ie,animateIn:oe,options:se}=t,R=se||{},{stagger:z}=R,le=Q(R,["stagger"]),K=M({target:e,insertAfter:y},le);ie(f,K),p(),z&&(yield B(z*l)),yield oe(f,J(M({},K),{prepared:!0}))}else y?e.insertBefore(f,y.nextSibling):e.prepend(f),p();u()}))})),yield i.rendering,i.currentIndex=o}));var $=class extends re.default{constructor(e,t){super();this.wrapper=e;this.index=t;this.list=m(this.wrapper,"list"),this.paginationWrapper=m(this.wrapper,"pagination"),this.paginationNext=m(this.wrapper,"next"),this.paginationPrevious=m(this.wrapper,"previous"),this.paginationCount=m(this.wrapper,"pageCount");let n=m(this.wrapper,"items");this.visibleItems=this.itemsPerPage=n.length,this.totalPages=1,this.items=n.map((i,o)=>new L(i,this.list,o))}addItems(e){return c(this,null,function*(){let{items:t,list:n}=this,i=e.map(o=>new L(o,n));t.push(...i),yield this.emit("shouldnest",i),yield this.emit("shouldcollectprops",i),yield this.emit("shouldsort",i),yield this.emit("shouldfilter"),yield this.renderItems(!0),yield this.emit("additems",i)})}renderItems(e){return c(this,null,function*(){yield this.renderingQueue,this.renderingQueue=ne(this,e)})}displayElement(e,t=!0,n=!0){return c(this,null,function*(){let{listAnimation:i}=this,o=this[e];if(!!o)if(i&&n){let{animateIn:s,animateOut:l,options:a}=i;yield(t?s:l)(o,a)}else o.style.display=t?"":"none"})}switchPage(e){return c(this,null,function*(){let{currentPage:t}=this;e!==t&&(yield this.emit("switchpage",e),this.currentPage=e,t&&(yield this.renderItems()))})}addEmptyElement(e){let{wrapper:t,list:n,emptyElement:i}=this;i||(e.style.display="none",t.insertBefore(e,n.nextSibling),this.emptyElement=e)}addPaginationPrevious(e){var i;let{paginationPrevious:t,paginationNext:n}=this;t||(e.style.display="none",(i=n==null?void 0:n.parentElement)==null||i.prepend(e),this.paginationPrevious=e)}addLoader(e){let{loader:t}=this;t||(e.style.display="none",this.loader=e)}scrollToAnchor(){var e;(e=this.scrollAnchor)==null||e.scrollIntoView({behavior:"smooth"})}getAttribute(e){let{wrapper:t,list:n}=this;return t.getAttribute(e)||n.getAttribute(e)}getInstanceIndex(e){let{wrapper:t,list:n}=this;return H(t,e)||H(n,e)}};var Me=r=>j(r).map(Te).filter(q),Te=r=>{var s,l;let e=m(r,"wrapper");if(!e){w.alert("The element is not a Collection List.","error");return}let{fsAttributes:t}=window;(s=t.cms).lists||(s.lists=[]),(l=t.cms).listElements||(l.listElements=[...document.querySelectorAll(`.${S.wrapper}`)]);let{lists:n,listElements:i}=t.cms,o=i.indexOf(e);if(o!==-1)return n[o]||(n[o]=new $(e,o)),n[o]};export{L as CMSItem,$ as CMSList,Me as createCMSListInstances};
{
"name": "@finsweet/attributes-cmscore",
"version": "1.0.12",
"version": "1.0.13",
"description": "Core functionalities of all cms Attributes.",

@@ -5,0 +5,0 @@ "main": "cmscore.js",

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