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.7 to 1.0.8

4

cmscore.js

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

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