New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

spon-expander

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spon-expander - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

dist/index.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.sponExpander=e()}(this,function(){"use strict";"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t,e=(function(t,e){var n;t.exports=(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1],i=n({},{easing:function(t,e,n,i){return(t/=i/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e},duration:1e3},t),r=i.easing,a=i.duration,o=i.start,s=i.end,c=0,l=null,u=null,d=null;return new Promise(function(t){d=window.requestAnimationFrame(function n(i){var f,h,p,v=c||o;u||(u=i),l=i-u,c=Math.round(r(l,o,s-o,a)),f=v,h=c,(o<=(p=s)?h<=p&&f<=h:h>=p&&f>=h)?(d=window.requestAnimationFrame(n),e&&e(c)):(t(v),window.cancelAnimationFrame(d),l=null,u=null,d=null,v=null)})})})}(t={exports:{}},t.exports),t.exports),n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};return function t(i){var r,a=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.defaults={activeIndex:null,closeOthers:!1,open:!1,selector:"[data-accordion-btn]",name:"accordion",init:!0,buttonActiveClass:"is-active",contentActiveClass:"is-expanded",duration:300,easing:function(t,e,n,i){return(t/=i/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e}},this.createPanels=function(){var t=a.options,e=t.buttonActiveClass,n=t.contentActiveClass,i=t.activeIndex,r=t.open,o=t.name;a.panes=[].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(a.$el.querySelectorAll(a.options.selector))).map(function(t,s){t.setAttribute("data-accordion-index",s);var c=t.dataset.target,l=a.$el.querySelector(c),u=!!r||!r&&s===i;t.setAttribute("aria-expanded",u),t.setAttribute("aria-selected",u),t.setAttribute("aria-controls",o+"-"+s),u&&(t.classList.add(e),l.classList.add(n)),l.setAttribute("data-enhanced",!0),l.setAttribute("aria-labelledby",o+"-"+s),l.setAttribute("aria-hidden",!u),l.setAttribute("role","tabpanel");var d={$button:t,$target:l,index:s,open:u,isRunning:!1};return i===s&&(a.current=d),d})},this.onEnd=function(t){var e=t.$target,n=t.$button,i=t.open;return e.style.willChange="",e.style.height="",e.style.display="",t.isRunning=!1,n.setAttribute("aria-expanded",i),n.setAttribute("aria-selected",i),e.setAttribute("aria-hidden",!i),a},this.addEvents=function(){return a.panes.forEach(function(t){var e=t.$button;e.addEventListener("click",a.clickHandle),e.addEventListener("touchstart",a.clickHandle)}),a},this.removeEvents=function(){return a.panes.forEach(function(t){var e=t.$button;e.removeEventListener("click",a.clickHandle),e.removeEventListener("touchstart",a.clickHandle)}),a},this.clickHandle=function(t){t.preventDefault();var e=t.target.hasAttribute("data-accordion-btn")?t.target:t.target.closest("[data-accordion-btn]"),n=a.options,i=n.closeOthers,r=n.buttonActiveClass,o=e.dataset.accordionIndex,s=e.classList.contains(r);if(i&&a.current){var c=a.current.index;c!==parseInt(o)&&a.collapse(c)}!0===s?a.collapse(o):a.expand(o),a.current=a.panes[o]},this.expand=function(t){var n=a.panes[t],i=a.options,r=i.duration,o=i.easing,s=i.buttonActiveClass,c=i.contentActiveClass;if(!n.isRunning){var l=n.$target,u=n.$button;l.style.display="block";var d=l.getBoundingClientRect().height;l.style.height=0,l.style.willChange="height",n.isRunning=!0,n.open=!0,a.emit("accordion:open",n),e({start:0,end:Math.round(d),duration:r,easing:o},function(t){return l.style.height=t+"px"}).then(function(){a.onEnd(n),u.classList.add(s),l.classList.add(c),a.emit("accordion:opened",n)})}return a},this.collapse=function(t){var n=a.options,i=n.duration,r=n.easing,o=n.buttonActiveClass,s=n.contentActiveClass,c=a.panes[t];if(!c.isRunning){c.open=!1;var l=c.$target,u=c.$button,d=l.getBoundingClientRect().height;l.style.height=d+"px",l.style.willChange="height",a.emit("accordion:collapse",c),c.isRunning=!0,e({start:Math.round(d),end:0,duration:i,easing:r},function(t){return l.style.height=t+"px"}).then(function(){a.onEnd(c),u.classList.remove(o),l.classList.remove(s),a.emit("accordion:collapsed",c)})}return a},this.init=function(){return a.createPanels(),a.addEvents(),a.$el.setAttribute("role","tablist"),a.$el.setAttribute("aria-multiselectable",a.options.closeOthers),a},this.destroy=function(){var t=a.options,e=t.buttonActiveClass,n=t.contentActiveClass;return a.removeEvents(),a.$el.removeAttribute("role"),a.$el.removeAttribute("aria-multiselectable"),a.panes.forEach(function(t){var i=t.$button,r=t.$target;i.classList.remove(e),i.removeAttribute("aria-expanded"),i.removeAttribute("aria-selected"),i.removeAttribute("aria-controls"),i.removeAttribute("role","tab"),r.removeAttribute("aria-hidden"),r.removeAttribute("aria-labelledby"),r.removeAttribute("role","tabpanel"),r.removeAttribute("data-enhanced",!0),r.classList.remove(n),r.removeAttribute("style")}),a.emit("accordion:destroy"),a},this.options=n({},this.defaults,o),this.$el=i,this.panes=[],this.current=null,this.options.init&&this.init(),Object.assign(this,(r=r||Object.create(null),{on:function(t,e){(r[t]||(r[t]=[])).push(e)},off:function(t,e){r[t]&&r[t].splice(r[t].indexOf(e)>>>0,1)},emit:function(t,e){(r[t]||[]).slice().map(function(t){t(e)}),(r["*"]||[]).slice().map(function(n){n(t,e)})}})),this}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.sponExpander=e()}(this,function(){"use strict";"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var t,e=(function(t,e){var n;t.exports=(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1],i=n({},{easing:function(t,e,n,i){return(t/=i/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e},duration:1e3},t),a=i.easing,r=i.duration,s=i.start,o=i.end,c=0,l=null,u=null,d=null;return new Promise(function(t){d=window.requestAnimationFrame(function n(i){var p,h,f,v=c||s;u||(u=i),l=i-u,c=Math.round(a(l,s,o-s,r)),p=v,h=c,(s<=(f=o)?h<=f&&p<=h:h>=f&&p>=h)?(d=window.requestAnimationFrame(n),e&&e(c)):(t(v),window.cancelAnimationFrame(d),l=null,u=null,d=null,v=null)})})})}(t={exports:{}},t.exports),t.exports),n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};return function t(i){var a,r=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.defaults={activeIndex:null,closeOthers:!1,open:!1,selector:"[data-accordion-btn]",name:"accordion",init:!0,buttonActiveClass:"is-active",contentActiveClass:"is-expanded",duration:300,easing:function(t,e,n,i){return(t/=i/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e}},this.clickHandle=function(t){t.preventDefault();var e=t.target.hasAttribute("data-accordion-btn")?t.target:t.target.closest("[data-accordion-btn]"),n=r.options.closeOthers,i=e.dataset.accordionIndex,a=r.panes[i];a.state=a.machine[a.state].CLICK;var s=r.current.index;n&&r.current&&s!==parseInt(i)?(r.current.state=r.current.machine[r.current.state].CLICK,r.collapse(s)):log("now"),"open"===a.state?r.expand(i):r.collapse(i),r.current=a},this.createPanels=function(){var t=r.options,e=t.buttonActiveClass,n=t.contentActiveClass,i=t.activeIndex,a=t.open,s=t.name;r.panes=[].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(r.$el.querySelectorAll(r.options.selector))).map(function(t,o){t.setAttribute("data-accordion-index",o);var c=t.dataset.target,l=r.$el.querySelector(c),u=!!a||!a&&o===i;t.setAttribute("aria-expanded",u),t.setAttribute("aria-selected",u),t.setAttribute("aria-controls",s+"-"+o),u&&(t.classList.add(e),l.classList.add(n)),l.setAttribute("data-enhanced",!0),l.setAttribute("aria-labelledby",s+"-"+o),l.setAttribute("aria-hidden",!u),l.setAttribute("role","tabpanel");var d={$button:t,$target:l,index:o,open:u,isRunning:!1,state:u?"open":"close",machine:{open:{CLICK:"close"},close:{CLICK:"open"}}};return i===o&&(r.current=d),d})},this.onEnd=function(t){var e=t.$target,n=t.$button,i=t.open;return e.style.willChange="",e.style.height="",e.style.display="",t.isRunning=!1,n.setAttribute("aria-expanded",i),n.setAttribute("aria-selected",i),e.setAttribute("aria-hidden",!i),r},this.addEvents=function(){return r.panes.forEach(function(t){var e=t.$button;e.addEventListener("click",r.clickHandle),e.addEventListener("touchstart",r.clickHandle)}),r},this.removeEvents=function(){return r.panes.forEach(function(t){var e=t.$button;e.removeEventListener("click",r.clickHandle),e.removeEventListener("touchstart",r.clickHandle)}),r},this.expand=function(t){var n=r.panes[t],i=r.options,a=i.duration,s=i.easing,o=i.buttonActiveClass,c=i.contentActiveClass;if(!n.isRunning){var l=n.$target,u=n.$button;l.style.display="block";var d=l.getBoundingClientRect().height;l.style.height=0,l.style.willChange="height",n.isRunning=!0,n.open=!0,r.emit("spon:open",{pane:n,index:t,panes:r.panes}),e({start:0,end:Math.round(d),duration:a,easing:s},function(t){return l.style.height=t+"px"}).then(function(){r.onEnd(n),u.classList.add(o),l.classList.add(c),r.emit("spon:opened",{pane:n,index:t,panes:r.panes})})}return r},this.collapse=function(t){var n=r.options,i=n.duration,a=n.easing,s=n.buttonActiveClass,o=n.contentActiveClass,c=r.panes[t];if(!c.isRunning){c.open=!1;var l=c.$target,u=c.$button,d=l.getBoundingClientRect().height;l.style.height=d+"px",l.style.willChange="height",r.emit("spon:close",{pane:c,index:t,panes:r.panes}),c.isRunning=!0,e({start:Math.round(d),end:0,duration:i,easing:a},function(t){return l.style.height=t+"px"}).then(function(){r.onEnd(c),u.classList.remove(s),l.classList.remove(o),r.emit("spon:closed",{pane:c,index:t,panes:r.panes})})}return r},this.init=function(){return r.createPanels(),r.addEvents(),r.$el.setAttribute("role","tablist"),r.$el.setAttribute("aria-multiselectable",r.options.closeOthers),r},this.destroy=function(){var t=r.options,e=t.buttonActiveClass,n=t.contentActiveClass;return r.removeEvents(),r.$el.removeAttribute("role"),r.$el.removeAttribute("aria-multiselectable"),r.panes.forEach(function(t){var i=t.$button,a=t.$target;i.classList.remove(e),i.removeAttribute("aria-expanded"),i.removeAttribute("aria-selected"),i.removeAttribute("aria-controls"),i.removeAttribute("role","tab"),a.removeAttribute("aria-hidden"),a.removeAttribute("aria-labelledby"),a.removeAttribute("role","tabpanel"),a.removeAttribute("data-enhanced",!0),a.classList.remove(n),a.removeAttribute("style")}),r},this.options=n({},this.defaults,s),this.$el=i,this.panes=[],this.current=null,this.options.init&&this.init(),Object.assign(this,(a=a||Object.create(null),{on:function(t,e){(a[t]||(a[t]=[])).push(e)},off:function(t,e){a[t]&&a[t].splice(a[t].indexOf(e)>>>0,1)},emit:function(t,e){(a[t]||[]).slice().map(function(t){t(e)}),(a["*"]||[]).slice().map(function(n){n(t,e)})}})),this}});
{
"name": "spon-expander",
"version": "0.0.4",
"version": "0.0.5",
"main": "dist/index.min.js",

@@ -5,0 +5,0 @@ "devDependencies": {

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