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

stimulus-use

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stimulus-use - npm Package Compare versions

Comparing version 0.23.0 to 0.24.0-0

2

dist/index.umd.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("stimulus")):"function"==typeof define&&define.amd?define(["exports","stimulus"],t):t((e=e||self).StimulusUse={},e.Stimulus)}(this,function(e,t){var n=function(e,t){var n=e[t];return"function"==typeof n?n:function(){}},r=function(e,t,n){var r=e;return!0===n?r=t.identifier+":"+e:"string"==typeof n&&(r=n+":"+e),r},i=function(e,t,n){var r=t||{bubbles:!0,cancelable:!0,composed:!0},i=r.bubbles,o=r.cancelable,s=r.composed;return t&&Object.assign(n,{originalEvent:t}),new CustomEvent(e,{bubbles:i,cancelable:o,composed:s,detail:n})},o={dispatchEvent:!0,eventPrefix:!0},s=function(e,t){var s;void 0===t&&(t={});var a=Object.assign({},o,t),l=a.dispatchEvent,c=a.eventPrefix,u=(null==(s=t)?void 0:s.element)||e.element,d=e.disconnect.bind(e),v=new IntersectionObserver(function(t){var o=t[0];o.isIntersecting?function(t){if(e.isVisible=!0,n(e,"appear").call(e,t),l){var o=r("appear",e,c),s=i(o,null,{controller:e,entry:t});u.dispatchEvent(s)}}(o):e.isVisible&&function(t){if(e.isVisible=!1,n(e,"disappear").call(e,t),l){var o=r("disappear",e,c),s=i(o,null,{controller:e,entry:t});u.dispatchEvent(s)}}(o)},t),f=function(){v.observe(u)},h=function(){v.unobserve(u)};return Object.assign(e,{isVisible:!1,disconnect:function(){h(),d()}}),f(),[f,h]};function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var d=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=s(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isVisible=!1,t}return l(t,e),t}(t.Controller)),v=function(e,t){var r=e.disconnect.bind(e),i=new IntersectionObserver(function(t){t[0].isIntersecting&&!e.isLoaded&&function(t){var r=e.data.get("src");if(r){var i=e.element;e.isLoading=!0,n(e,"loading").call(e,r),i.onload=function(){!function(t){e.isLoading=!1,e.isLoaded=!0,n(e,"loaded").call(e,t)}(r)},i.src=r}}()},t),o=function(){i.observe(e.element)},s=function(){i.unobserve(e.element)};return Object.assign(e,{isVisible:!1,disconnect:function(){s(),r()}}),o(),[o,s]},f=function(e){function t(t){var n;return(n=e.call(this,t)||this).options={rootMargin:"10%"},requestAnimationFrame(function(){var e=v(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isLoading=!1,t.isLoaded=!1,t}return l(t,e),t}(t.Controller)),h={dispatchEvent:!0,eventPrefix:!0},b=function(e,t){var o;void 0===t&&(t={});var s=Object.assign({},h,t),a=s.dispatchEvent,l=s.eventPrefix,c=(null==(o=t)?void 0:o.element)||e.element,u=e.disconnect.bind(e),d=new ResizeObserver(function(t){var o=t[0];if(n(e,"resize").call(e,o.contentRect),a){var s=r("resize",e,l),u=i(s,null,{controller:e,entry:o});c.dispatchEvent(u)}}),v=function(){d.observe(c)},f=function(){d.unobserve(c)};return Object.assign(e,{disconnect:function(){f(),u()}}),v(),[v,f]},m=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=b(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),g={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},p=function(e,t){void 0===t&&(t={});var n=Object.assign({},g,t),o=n.onlyVisible,s=n.dispatchEvent,a=n.events,l=n.eventPrefix,c=function(n){var a,c,u,d,v=(null==(a=t)?void 0:a.element)||e.element;if(!v.contains(n.target)&&(c=v.getBoundingClientRect(),u=window.innerHeight||document.documentElement.clientHeight,d=window.innerWidth||document.documentElement.clientWidth,c.top<=u&&c.top+c.height>=0&&c.left<=d&&c.left+c.width>=0||!o)&&(e.clickOutside&&e.clickOutside(n),s)){var f=r("click:outside",e,l),h=i(f,n,{controller:e});v.dispatchEvent(h)}},u=function(){null==a||a.forEach(function(e){window.addEventListener(e,c,!1)})},d=function(){null==a||a.forEach(function(e){window.removeEventListener(e,c,!1)})},v=e.disconnect.bind(e);return Object.assign(e,{disconnect:function(){d(),v()}}),u(),[u,d]},y=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=p(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),E={debug:!1,logger:console},C=function(e,t){var n,r,i,o,s,l=this;void 0===t&&(t={}),this.log=function(e,t){l.debug&&(l.logger.groupCollapsed("%c"+l.controller.identifier+" %c#"+e,"color: #3B82F6","color: unset"),l.logger.log(a({controllerId:l.controllerId},t)),l.logger.groupEnd())},this.debug=null!=(n=null!=(r=null==(i=t)?void 0:i.debug)?r:e.application.stimulusUseDebug)?n:E.debug,this.logger=null!=(o=null==(s=t)?void 0:s.logger)?o:E.logger,this.controller=e,this.controllerId=e.element.id||e.element.dataset.id,this.controllerInitialize=e.initialize.bind(e),this.controllerConnect=e.connect.bind(e),this.controllerDisconnect=e.disconnect.bind(e)},w=function(e){function t(t,n){var i,o,s,a,l;return void 0===n&&(n={}),(l=e.call(this,t,n)||this).dispatch=function(e,t){void 0===t&&(t={});var n=c(l),i=n.targetElement,o=n.eventPrefix,s=n.bubbles,a=n.cancelable,u=n.log;Object.assign(t,{controller:n.controller});var d=r(e,l.controller,o),v=new CustomEvent(d,{detail:t,bubbles:s,cancelable:a});return i.dispatchEvent(v),u("dispatch",{eventName:d,detail:t,bubbles:s,cancelable:a}),v},l.targetElement=null!=(i=n.element)?i:t.element,l.eventPrefix=null==(o=n.eventPrefix)||o,l.bubbles=null==(s=n.bubbles)||s,l.cancelable=null==(a=n.cancelable)||a,l.enhanceController(),l}return l(t,e),t.prototype.enhanceController=function(){Object.assign(this.controller,{dispatch:this.dispatch})},t}(C),O=function(e,t){return void 0===t&&(t={}),new w(e,t)},j=function(e,t){void 0===t&&(t={}),Object.defineProperty(e,"isPreview",{get:function(){return document.documentElement.hasAttribute("data-turbolinks-preview")}}),Object.defineProperty(e,"csrfToken",{get:function(){return this.metaValue("csrf-token")}}),O(e,t),Object.assign(e,{metaValue:function(e){var t=document.head.querySelector('meta[name="'+e+'"]');return t&&t.getAttribute("content")}})},P=function(e){function t(t){var n;return(n=e.call(this,t)||this).isPreview=!1,n.csrfToken="",j(c(n),n.options),n}return l(t,e),t}(t.Controller),T={ms:6e4,initialState:!1,events:["mousemove","mousedown","resize","keydown","touchstart","wheel"],dispatchEvent:!0,eventPrefix:!0},L=function(e,t){void 0===t&&(t={});var o=Object.assign({},T,t),s=o.ms,a=o.events,l=o.dispatchEvent,c=o.eventPrefix,u=o.initialState,d=setTimeout(function(){u=!0,v()},s),v=function(t){var o=r("away",e,c);if(e.isIdle=!0,n(e,"away").call(e,t),l){var s=i(o,t||null,{controller:e});e.element.dispatchEvent(s)}},f=function(t){var o=r("back",e,c);if(e.isIdle=!1,n(e,"back").call(e,t),l){var s=i(o,t||null,{controller:e});e.element.dispatchEvent(s)}},h=function(e){u&&f(e),u=!1,clearTimeout(d),d=setTimeout(function(){u=!0,v(e)},s)},b=function(e){document.hidden||h(e)};u?v():f();var m=e.disconnect.bind(e),g=function(){a.forEach(function(e){window.addEventListener(e,h)}),document.addEventListener("visibilitychange",b)},p=function(){a.forEach(function(e){window.removeEventListener(e,h)}),document.removeEventListener("visibilitychange",b)};return Object.assign(e,{disconnect:function(){p(),m()}}),g(),[g,p]},A=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=L(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isIdle=!1,t}return l(t,e),t}(t.Controller)),x={dispatchEvent:!0,eventPrefix:!0},I=function(e){function t(t,o){var s;void 0===o&&(o={}),(s=e.call(this,t,o)||this).observe=function(){s.controller.isVisible=!document.hidden,document.addEventListener("visibilitychange",s.handleVisibilityChange)},s.unobserve=function(){document.removeEventListener("visibilitychange",s.handleVisibilityChange)},s.becomesInvisible=function(e){var t=r("invisible",s.controller,s.eventPrefix);s.controller.isVisible=!1,n(s.controller,"invisible").call(s.controller),s.log("invisible",{isVisible:!1}),s.dispatch(t,e)},s.becomesVisible=function(e){var t=r("visible",s.controller,s.eventPrefix);s.controller.isVisible=!0,n(s.controller,"visible").call(s.controller),s.log("visible",{isVisible:!0}),s.dispatch(t,e)},s.dispatch=function(e,t){if(s.dispatchEvent){var n={controller:s.controller,isVisible:s.controller.isVisible},r=i(e,t||null,n);s.controller.element.dispatchEvent(r),s.log("dispatchEvent",a({eventName:e},n))}},s.handleVisibilityChange=function(e){document.hidden?s.becomesInvisible(e):s.becomesVisible(e)};var l=Object.assign({},x,o),u=l.dispatchEvent,d=l.eventPrefix;return Object.assign(c(s),{dispatchEvent:u,eventPrefix:d}),s.controller=t,Object.assign(t,{disconnect:function(){s.unobserve(),s.controllerDisconnect()}}),s.handleVisibilityChange(),s.observe(),s}return l(t,e),t}(C),N=function(e,t){void 0===t&&(t={});var n=new I(e,t);return[n.observe,n.unobserve]},V=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=N(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isVisible=!1,t}return l(t,e),t}(t.Controller)),S=function(e){function t(t,r){var i,o;return void 0===r&&(r={}),(o=e.call(this,t,r)||this).observe=function(){o.targetElement.addEventListener("mouseenter",o.onEnter),o.targetElement.addEventListener("mouseleave",o.onLeave)},o.unobserve=function(){o.targetElement.removeEventListener("mouseenter",o.onEnter),o.targetElement.removeEventListener("mouseleave",o.onLeave)},o.onEnter=function(){n(o.controller,"mouseEnter").call(o.controller),o.log("mouseEnter",{hover:!0})},o.onLeave=function(){n(o.controller,"mouseLeave").call(o.controller),o.log("mouseLeave",{hover:!1})},o.targetElement=(null==(i=r)?void 0:i.element)||t.element,o.controller=t,o.enhanceController(),o.observe(),o}return l(t,e),t.prototype.enhanceController=function(){var e=this,t=this.controller.disconnect.bind(this.controller);Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(C),F=function(e,t){void 0===t&&(t={});var n=new S(e,t);return[n.observe,n.unobserve]},M=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=F(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),U=function(e){function t(t,r){var i,o;return void 0===r&&(r={}),(o=e.call(this,t,r)||this).observe=function(){try{o.observer.observe(o.targetElement,o.options)}catch(e){o.controller.application.handleError(e,"At a minimum, one of childList, attributes, and/or characterData must be true",{})}},o.unobserve=function(){o.observer.disconnect()},o.mutation=function(e){n(o.controller,"mutate").call(o.controller,e),o.log("mutate",{entries:e})},o.targetElement=(null==(i=r)?void 0:i.element)||t.element,o.controller=t,o.options=r,o.observer=new MutationObserver(o.mutation),o.enhanceController(),o.observe(),o}return l(t,e),t.prototype.enhanceController=function(){var e=this,t=this.controller.disconnect.bind(this.controller);Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(C),q=function(e,t){void 0===t&&(t={});var n=new U(e,t);return[n.observe,n.unobserve]},z=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=q(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),k=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this,t,n)||this).observe=function(){r.observer.observe(r.targetElement,{subtree:!0,characterData:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[r.targetSelector,r.scopedTargetSelector]})},r.unobserve=function(){r.observer.disconnect()},r.mutation=function(e){for(var t,n=function(){var e=t.value;switch(e.type){case"attributes":var n=e.target.getAttribute(e.attributeName);if(e.attributeName===r.targetSelector||e.attributeName===r.scopedTargetSelector){var i=r.targetsUsedByThisController(e.oldValue),o=r.targetsUsedByThisController(n),s=i.filter(function(e){return!o.includes(e)}),a=o.filter(function(e){return!i.includes(e)});s.forEach(function(t){return r.targetRemoved(r.stripIdentifierPrefix(t),e.target,"attributeChange")}),a.forEach(function(t){return r.targetAdded(r.stripIdentifierPrefix(t),e.target,"attributeChange")})}break;case"characterData":var l=r.findTargetInAncestry(e.target);if(null==l)return{v:void 0};r.targetsUsedByThisControllerFromNode(l).forEach(function(e){r.targetChanged(r.stripIdentifierPrefix(e),l,"domMutation")});break;case"childList":var c=e.removedNodes;e.addedNodes.forEach(function(e){return r.processNodeDOMMutation(e,r.targetAdded)}),c.forEach(function(e){return r.processNodeDOMMutation(e,r.targetRemoved)})}},i=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(e);!(t=i()).done;){var o=n();if("object"==typeof o)return o.v}},r.controller=t,r.options=n,r.targetElement=t.element,r.identifier=t.scope.identifier,r.identifierPrefix=r.identifier+".",r.targetSelector=t.scope.schema.targetAttribute,r.scopedTargetSelector="data-"+r.identifier+"-target",r.targets=n.targets||t.constructor.targets,r.prefixedTargets=r.targets.map(function(e){return""+r.identifierPrefix+e}),r.observer=new MutationObserver(r.mutation),r.enhanceController(),r.observe(),r}l(t,e);var r=t.prototype;return r.processNodeDOMMutation=function(e,t){var n=this,r=e,i=t,o=[];"#text"==r.nodeName||0==this.targetsUsedByThisControllerFromNode(r).length?(i=this.targetChanged,r=this.findTargetInAncestry(e)):o=this.targetsUsedByThisControllerFromNode(r),null!=r&&(0==o.length&&(o=this.targetsUsedByThisControllerFromNode(r)),o.forEach(function(e){i.call(n,n.stripIdentifierPrefix(e),r,"domMutation")}))},r.findTargetInAncestry=function(e){var t=e,n=[];for("#text"!=t.nodeName&&(n=this.targetsUsedByThisControllerFromNode(t));null!==t.parentNode&&t.parentNode!=this.targetElement&&0==n.length;)if("#text"!==(t=t.parentNode).nodeName&&this.targetsUsedByThisControllerFromNode(t).length>0)return t;return"#text"==t.nodeName||null==t.parentNode?null:t.parentNode==this.targetElement&&this.targetsUsedByThisControllerFromNode(t).length>0?t:null},r.targetAdded=function(e,t,r){var i=e+"TargetAdded";this.controller[i]&&n(this.controller,i).call(this.controller,t),this.log("targetAdded",{target:e,node:t,trigger:r})},r.targetRemoved=function(e,t,r){var i=e+"TargetRemoved";this.controller[i]&&n(this.controller,i).call(this.controller,t),this.log("targetRemoved",{target:e,node:t,trigger:r})},r.targetChanged=function(e,t,r){var i=e+"TargetChanged";this.controller[i]&&n(this.controller,i).call(this.controller,t),this.log("targetChanged",{target:e,node:t,trigger:r})},r.targetsUsedByThisControllerFromNode=function(e){if("#text"==e.nodeName)return[];var t=e;return this.targetsUsedByThisController(t.getAttribute(this.scopedTargetSelector)||t.getAttribute(this.targetSelector))},r.targetsUsedByThisController=function(e){var t=this.stripIdentifierPrefix(e=e||"").split(" ");return this.targets.filter(function(e){return-1!==t.indexOf(e)})},r.stripIdentifierPrefix=function(e){return e.replace(new RegExp(this.identifierPrefix,"g"),"")},r.enhanceController=function(){var e=this,t=this.controller.disconnect.bind(this.controller);Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(C),R=function(e,t){void 0===t&&(t={});var n=new k(e,t);return[n.observe,n.unobserve]},B=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=R(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),D=function(e){var t=function(t){var r=window,i={height:r.innerHeight||Infinity,width:r.innerWidth||Infinity,event:t};n(e,"windowResize").call(e,i)},r=e.disconnect.bind(e),i=function(){window.addEventListener("resize",t),t()},o=function(){window.removeEventListener("resize",t)};return Object.assign(e,{disconnect:function(){o(),r()}}),i(),[i,o]},H=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=D(c(n)),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),W=function(e,t){void 0===t&&(t=200);var n=null;return function(){var r=arguments,i=this,o=function(){return e.apply(i,r)};n&&clearTimeout(n),n=setTimeout(o,t)}};function _(e,t){var n;return void 0===t&&(t=200),function(){var r=arguments,i=this;n||(n=!0,e.apply(i,r),setTimeout(function(){return n=!1},t))}}function G(e){var t=document.head.querySelector('meta[name="'+e+'"]');return t&&t.getAttribute("content")}function J(e){try{return JSON.parse(e)}catch(t){return e}}function $(e){return e.replace(/(?:[_-])([a-z0-9])/g,function(e,t){return t.toUpperCase()})}var K={enterClass:"enter",enterActiveClass:"enterStart",enterToClass:"enterEnd",leaveClass:"leave",leaveActiveClass:"leaveStart",leaveToClass:"leaveEnd"},Q={dispatchEvent:!0,eventPrefix:!0,transitioned:!1,hiddenClass:"hidden"},X=function(e,t){var n,r,i,o,s=function(e,t,n,r){try{var i,o;return(i=e.classList).add.apply(i,t),(o=e.classList).add.apply(o,n),Promise.resolve(function(){try{return Promise.resolve(new Promise(function(e){requestAnimationFrame(function(){requestAnimationFrame(e)})}))}catch(e){return Promise.reject(e)}}()).then(function(){var i,o;return(i=e.classList).remove.apply(i,n),(o=e.classList).add.apply(o,r),Promise.resolve(function(e){try{return Promise.resolve(new Promise(function(t){var n=1e3*Number(getComputedStyle(e).transitionDuration.split(",")[0].replace("s",""));setTimeout(function(){t(n)},n)}))}catch(e){return Promise.reject(e)}}(e)).then(function(){var n;(n=e.classList).remove.apply(n,t)})})}catch(e){return Promise.reject(e)}},a=function(n){try{if(!e.transitioned)return Promise.resolve();e.transitioned=!1,g&&g(n);var r=Y("leave",t,v),i=Y("leaveActive",t,v),o=Y("leaveTo",t,v);return Promise.resolve(s(d,r,i,o)).then(function(){b&&d.classList.add(b)})}catch(e){return Promise.reject(e)}},l=function(n){try{if(e.transitioned)return Promise.resolve();e.transitioned=!0,m&&m(n);var r=Y("enter",t,v),i=Y("enterActive",t,v),o=Y("enterTo",t,v);return b&&d.classList.remove(b),Promise.resolve(s(d,r,i,o)).then(function(){})}catch(e){return Promise.reject(e)}};void 0===t&&(t={});var c,u=e.element.dataset.transitionTarget;u&&(c=e[u+"Target"]);var d=(null==(n=t)?void 0:n.element)||c||e.element;if(d instanceof HTMLElement||d instanceof SVGElement){var v=d.dataset,f=Object.assign(Q,t),h=f.transitioned,b=f.hiddenClass,m=null==(r=e.enter)?void 0:r.bind(e),g=null==(i=e.leave)?void 0:i.bind(e),p=null==(o=e.toggleTransition)?void 0:o.bind(e);return e.transitioned=h,h?(b&&d.classList.remove(b),l()):(b&&d.classList.add(b),a()),Object.assign(e,{enter:l,leave:a,toggleTransition:y}),[l,a,y]}function y(t){p&&p(t),e.transitioned?a():l()}};function Y(e,t,n){var r="transition"+e[0].toUpperCase()+e.substr(1);return(t[e]||n[r]||n[K[e]]||"").split(" ")}var Z=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){X(c(n),n.options)}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).transitioned=!1,t}return l(t,e),t}(t.Controller));e.ApplicationController=P,e.ClickOutsideController=y,e.HoverController=M,e.IdleController=A,e.IntersectionController=d,e.LazyLoadController=f,e.MutationController=z,e.ResizeController=m,e.TargetMutationController=B,e.TransitionController=Z,e.UseHover=S,e.UseMutation=U,e.UseTargetMutation=k,e.UseVisibility=I,e.VisibilityController=V,e.WindowResizeController=H,e.useApplication=j,e.useClickOutside=p,e.useDebounce=function(e,t){var n;null==(n=e.constructor.debounces)||n.forEach(function(n){if("string"==typeof n&&(e[n]=W(e[n],null==t?void 0:t.wait)),"object"==typeof n){var r=n.name;if(!r)return;e[r]=W(e[r],n.wait||(null==t?void 0:t.wait))}})},e.useDispatch=O,e.useHover=F,e.useIdle=L,e.useIntersection=s,e.useLazyLoad=v,e.useMemo=function(e){var t;null==(t=e.constructor.memos)||t.forEach(function(t){!function(e,t,n){Object.defineProperty(e,t,{value:n})}(e,t,e[t])})},e.useMeta=function(e,t){void 0===t&&(t={suffix:!0});var n=e.constructor.metaNames,r=t.suffix;null==n||n.forEach(function(t){!function(e,t,n){var r=n?$(t)+"Meta":$(t);Object.defineProperty(e,r,{get:function(){return J(G(t))}})}(e,t,r)}),Object.defineProperty(e,"metas",{get:function(){var e={};return null==n||n.forEach(function(t){var n=J(G(t));null!=n&&(e[$(t)]=n)}),e}})},e.useMutation=q,e.useResize=b,e.useTargetMutation=R,e.useThrottle=function(e,t){var n;void 0===t&&(t={}),null==(n=e.constructor.throttles)||n.forEach(function(n){var r;if("string"==typeof n&&(e[n]=_(e[n],null==(r=t)?void 0:r.wait)),"object"==typeof n){var i,o=n.name;if(!o)return;e[o]=_(e[o],n.wait||(null==(i=t)?void 0:i.wait))}})},e.useTransition=X,e.useVisibility=N,e.useWindowResize=D});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("stimulus")):"function"==typeof define&&define.amd?define(["exports","stimulus"],t):t((e=e||self).StimulusUse={},e.Stimulus)}(this,function(e,t){var n=function(e,t){var n=e[t];return"function"==typeof n?n:function(){}},r=function(e,t,n){var r=e;return!0===n?r=t.identifier+":"+e:"string"==typeof n&&(r=n+":"+e),r},i=function(e,t,n){var r=t||{bubbles:!0,cancelable:!0,composed:!0},i=r.bubbles,o=r.cancelable,s=r.composed;return t&&Object.assign(n,{originalEvent:t}),new CustomEvent(e,{bubbles:i,cancelable:o,composed:s,detail:n})},o={dispatchEvent:!0,eventPrefix:!0},s=function(e,t){var s;void 0===t&&(t={});var a=Object.assign({},o,t),l=a.dispatchEvent,c=a.eventPrefix,u=(null==(s=t)?void 0:s.element)||e.element,v=e.disconnect.bind(e),d=new IntersectionObserver(function(t){var o=t[0];o.isIntersecting?function(t){if(e.isVisible=!0,n(e,"appear").call(e,t),l){var o=r("appear",e,c),s=i(o,null,{controller:e,entry:t});u.dispatchEvent(s)}}(o):e.isVisible&&function(t){if(e.isVisible=!1,n(e,"disappear").call(e,t),l){var o=r("disappear",e,c),s=i(o,null,{controller:e,entry:t});u.dispatchEvent(s)}}(o)},t),f=function(){d.observe(u)},h=function(){d.unobserve(u)};return Object.assign(e,{isVisible:!1,disconnect:function(){h(),v()}}),f(),[f,h]};function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var v=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=s(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isVisible=!1,t}return l(t,e),t}(t.Controller)),d=function(e,t){var r=e.disconnect.bind(e),i=new IntersectionObserver(function(t){t[0].isIntersecting&&!e.isLoaded&&function(t){var r=e.data.get("src");if(r){var i=e.element;e.isLoading=!0,n(e,"loading").call(e,r),i.onload=function(){!function(t){e.isLoading=!1,e.isLoaded=!0,n(e,"loaded").call(e,t)}(r)},i.src=r}}()},t),o=function(){i.observe(e.element)},s=function(){i.unobserve(e.element)};return Object.assign(e,{isVisible:!1,disconnect:function(){s(),r()}}),o(),[o,s]},f=function(e){function t(t){var n;return(n=e.call(this,t)||this).options={rootMargin:"10%"},requestAnimationFrame(function(){var e=d(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isLoading=!1,t.isLoaded=!1,t}return l(t,e),t}(t.Controller)),h={dispatchEvent:!0,eventPrefix:!0},b=function(e,t){var o;void 0===t&&(t={});var s=Object.assign({},h,t),a=s.dispatchEvent,l=s.eventPrefix,c=(null==(o=t)?void 0:o.element)||e.element,u=e.disconnect.bind(e),v=new ResizeObserver(function(t){var o=t[0];if(n(e,"resize").call(e,o.contentRect),a){var s=r("resize",e,l),u=i(s,null,{controller:e,entry:o});c.dispatchEvent(u)}}),d=function(){v.observe(c)},f=function(){v.unobserve(c)};return Object.assign(e,{disconnect:function(){f(),u()}}),d(),[d,f]},g=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=b(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),m={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},p=function(e,t){void 0===t&&(t={});var n=Object.assign({},m,t),o=n.onlyVisible,s=n.dispatchEvent,a=n.events,l=n.eventPrefix,c=function(n){var a,c,u,v,d=(null==(a=t)?void 0:a.element)||e.element;if(!d.contains(n.target)&&(c=d.getBoundingClientRect(),u=window.innerHeight||document.documentElement.clientHeight,v=window.innerWidth||document.documentElement.clientWidth,c.top<=u&&c.top+c.height>=0&&c.left<=v&&c.left+c.width>=0||!o)&&(e.clickOutside&&e.clickOutside(n),s)){var f=r("click:outside",e,l),h=i(f,n,{controller:e});d.dispatchEvent(h)}},u=function(){null==a||a.forEach(function(e){window.addEventListener(e,c,!1)})},v=function(){null==a||a.forEach(function(e){window.removeEventListener(e,c,!1)})},d=e.disconnect.bind(e);return Object.assign(e,{disconnect:function(){v(),d()}}),u(),[u,v]},y=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=p(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),E={debug:!1,logger:console},C=function(e,t){var n,r,i,o,s,l=this;void 0===t&&(t={}),this.log=function(e,t){l.debug&&(l.logger.groupCollapsed("%c"+l.controller.identifier+" %c#"+e,"color: #3B82F6","color: unset"),l.logger.log(a({controllerId:l.controllerId},t)),l.logger.groupEnd())},this.debug=null!=(n=null!=(r=null==(i=t)?void 0:i.debug)?r:e.application.stimulusUseDebug)?n:E.debug,this.logger=null!=(o=null==(s=t)?void 0:s.logger)?o:E.logger,this.controller=e,this.controllerId=e.element.id||e.element.dataset.id,this.controllerInitialize=e.initialize.bind(e),this.controllerConnect=e.connect.bind(e),this.controllerDisconnect=e.disconnect.bind(e)},O=function(e){function t(t,n){var i,o,s,a,l;return void 0===n&&(n={}),(l=e.call(this,t,n)||this).dispatch=function(e,t){void 0===t&&(t={});var n=c(l),i=n.targetElement,o=n.eventPrefix,s=n.bubbles,a=n.cancelable,u=n.log;Object.assign(t,{controller:n.controller});var v=r(e,l.controller,o),d=new CustomEvent(v,{detail:t,bubbles:s,cancelable:a});return i.dispatchEvent(d),u("dispatch",{eventName:v,detail:t,bubbles:s,cancelable:a}),d},l.targetElement=null!=(i=n.element)?i:t.element,l.eventPrefix=null==(o=n.eventPrefix)||o,l.bubbles=null==(s=n.bubbles)||s,l.cancelable=null==(a=n.cancelable)||a,l.enhanceController(),l}return l(t,e),t.prototype.enhanceController=function(){Object.assign(this.controller,{dispatch:this.dispatch})},t}(C),w=function(e,t){return void 0===t&&(t={}),new O(e,t)},j=function(e,t){void 0===t&&(t={}),Object.defineProperty(e,"isPreview",{get:function(){return document.documentElement.hasAttribute("data-turbolinks-preview")}}),Object.defineProperty(e,"csrfToken",{get:function(){return this.metaValue("csrf-token")}}),w(e,t),Object.assign(e,{metaValue:function(e){var t=document.head.querySelector('meta[name="'+e+'"]');return t&&t.getAttribute("content")}})},T=function(e){function t(t){var n;return(n=e.call(this,t)||this).isPreview=!1,n.csrfToken="",j(c(n),n.options),n}return l(t,e),t}(t.Controller),P={ms:6e4,initialState:!1,events:["mousemove","mousedown","resize","keydown","touchstart","wheel"],dispatchEvent:!0,eventPrefix:!0},A=function(e,t){void 0===t&&(t={});var o=Object.assign({},P,t),s=o.ms,a=o.events,l=o.dispatchEvent,c=o.eventPrefix,u=o.initialState,v=setTimeout(function(){u=!0,d()},s),d=function(t){var o=r("away",e,c);if(e.isIdle=!0,n(e,"away").call(e,t),l){var s=i(o,t||null,{controller:e});e.element.dispatchEvent(s)}},f=function(t){var o=r("back",e,c);if(e.isIdle=!1,n(e,"back").call(e,t),l){var s=i(o,t||null,{controller:e});e.element.dispatchEvent(s)}},h=function(e){u&&f(e),u=!1,clearTimeout(v),v=setTimeout(function(){u=!0,d(e)},s)},b=function(e){document.hidden||h(e)};u?d():f();var g=e.disconnect.bind(e),m=function(){a.forEach(function(e){window.addEventListener(e,h)}),document.addEventListener("visibilitychange",b)},p=function(){a.forEach(function(e){window.removeEventListener(e,h)}),document.removeEventListener("visibilitychange",b)};return Object.assign(e,{disconnect:function(){p(),g()}}),m(),[m,p]},L=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=A(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isIdle=!1,t}return l(t,e),t}(t.Controller)),x={dispatchEvent:!0,eventPrefix:!0},I=function(e){function t(t,o){var s;void 0===o&&(o={}),(s=e.call(this,t,o)||this).observe=function(){s.controller.isVisible=!document.hidden,document.addEventListener("visibilitychange",s.handleVisibilityChange)},s.unobserve=function(){document.removeEventListener("visibilitychange",s.handleVisibilityChange)},s.becomesInvisible=function(e){var t=r("invisible",s.controller,s.eventPrefix);s.controller.isVisible=!1,n(s.controller,"invisible").call(s.controller),s.log("invisible",{isVisible:!1}),s.dispatch(t,e)},s.becomesVisible=function(e){var t=r("visible",s.controller,s.eventPrefix);s.controller.isVisible=!0,n(s.controller,"visible").call(s.controller),s.log("visible",{isVisible:!0}),s.dispatch(t,e)},s.dispatch=function(e,t){if(s.dispatchEvent){var n={controller:s.controller,isVisible:s.controller.isVisible},r=i(e,t||null,n);s.controller.element.dispatchEvent(r),s.log("dispatchEvent",a({eventName:e},n))}},s.handleVisibilityChange=function(e){document.hidden?s.becomesInvisible(e):s.becomesVisible(e)};var l=Object.assign({},x,o),u=l.dispatchEvent,v=l.eventPrefix;return Object.assign(c(s),{dispatchEvent:u,eventPrefix:v}),s.controller=t,Object.assign(t,{disconnect:function(){s.unobserve(),s.controllerDisconnect()}}),s.handleVisibilityChange(),s.observe(),s}return l(t,e),t}(C),N=function(e,t){void 0===t&&(t={});var n=new I(e,t);return[n.observe,n.unobserve]},V=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=N(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isVisible=!1,t}return l(t,e),t}(t.Controller)),S=function(e){function t(t,r){var i,o;return void 0===r&&(r={}),(o=e.call(this,t,r)||this).observe=function(){o.targetElement.addEventListener("mouseenter",o.onEnter),o.targetElement.addEventListener("mouseleave",o.onLeave)},o.unobserve=function(){o.targetElement.removeEventListener("mouseenter",o.onEnter),o.targetElement.removeEventListener("mouseleave",o.onLeave)},o.onEnter=function(){n(o.controller,"mouseEnter").call(o.controller),o.log("mouseEnter",{hover:!0})},o.onLeave=function(){n(o.controller,"mouseLeave").call(o.controller),o.log("mouseLeave",{hover:!1})},o.targetElement=(null==(i=r)?void 0:i.element)||t.element,o.controller=t,o.enhanceController(),o.observe(),o}return l(t,e),t.prototype.enhanceController=function(){var e=this,t=this.controller.disconnect.bind(this.controller);Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(C),F=function(e,t){void 0===t&&(t={});var n=new S(e,t);return[n.observe,n.unobserve]},M=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=F(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),U=function(e){function t(t,r){var i,o;return void 0===r&&(r={}),(o=e.call(this,t,r)||this).observe=function(){try{o.observer.observe(o.targetElement,o.options)}catch(e){o.controller.application.handleError(e,"At a minimum, one of childList, attributes, and/or characterData must be true",{})}},o.unobserve=function(){o.observer.disconnect()},o.mutation=function(e){n(o.controller,"mutate").call(o.controller,e),o.log("mutate",{entries:e})},o.targetElement=(null==(i=r)?void 0:i.element)||t.element,o.controller=t,o.options=r,o.observer=new MutationObserver(o.mutation),o.enhanceController(),o.observe(),o}return l(t,e),t.prototype.enhanceController=function(){var e=this,t=this.controller.disconnect.bind(this.controller);Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(C),q=function(e,t){void 0===t&&(t={});var n=new U(e,t);return[n.observe,n.unobserve]},z=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=q(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),k=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this,t,n)||this).observe=function(){r.observer.observe(r.targetElement,{subtree:!0,characterData:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[r.targetSelector,r.scopedTargetSelector]})},r.unobserve=function(){r.observer.disconnect()},r.mutation=function(e){for(var t,n=function(){var e=t.value;switch(e.type){case"attributes":var n=e.target.getAttribute(e.attributeName);if(e.attributeName===r.targetSelector||e.attributeName===r.scopedTargetSelector){var i=r.targetsUsedByThisController(e.oldValue),o=r.targetsUsedByThisController(n),s=i.filter(function(e){return!o.includes(e)}),a=o.filter(function(e){return!i.includes(e)});s.forEach(function(t){return r.targetRemoved(r.stripIdentifierPrefix(t),e.target,"attributeChange")}),a.forEach(function(t){return r.targetAdded(r.stripIdentifierPrefix(t),e.target,"attributeChange")})}break;case"characterData":var l=r.findTargetInAncestry(e.target);if(null==l)return{v:void 0};r.targetsUsedByThisControllerFromNode(l).forEach(function(e){r.targetChanged(r.stripIdentifierPrefix(e),l,"domMutation")});break;case"childList":var c=e.removedNodes;e.addedNodes.forEach(function(e){return r.processNodeDOMMutation(e,r.targetAdded)}),c.forEach(function(e){return r.processNodeDOMMutation(e,r.targetRemoved)})}},i=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(e);!(t=i()).done;){var o=n();if("object"==typeof o)return o.v}},r.controller=t,r.options=n,r.targetElement=t.element,r.identifier=t.scope.identifier,r.identifierPrefix=r.identifier+".",r.targetSelector=t.scope.schema.targetAttribute,r.scopedTargetSelector="data-"+r.identifier+"-target",r.targets=n.targets||t.constructor.targets,r.prefixedTargets=r.targets.map(function(e){return""+r.identifierPrefix+e}),r.observer=new MutationObserver(r.mutation),r.enhanceController(),r.observe(),r}l(t,e);var r=t.prototype;return r.processNodeDOMMutation=function(e,t){var n=this,r=e,i=t,o=[];"#text"==r.nodeName||0==this.targetsUsedByThisControllerFromNode(r).length?(i=this.targetChanged,r=this.findTargetInAncestry(e)):o=this.targetsUsedByThisControllerFromNode(r),null!=r&&(0==o.length&&(o=this.targetsUsedByThisControllerFromNode(r)),o.forEach(function(e){i.call(n,n.stripIdentifierPrefix(e),r,"domMutation")}))},r.findTargetInAncestry=function(e){var t=e,n=[];for("#text"!=t.nodeName&&(n=this.targetsUsedByThisControllerFromNode(t));null!==t.parentNode&&t.parentNode!=this.targetElement&&0==n.length;)if("#text"!==(t=t.parentNode).nodeName&&this.targetsUsedByThisControllerFromNode(t).length>0)return t;return"#text"==t.nodeName||null==t.parentNode?null:t.parentNode==this.targetElement&&this.targetsUsedByThisControllerFromNode(t).length>0?t:null},r.targetAdded=function(e,t,r){var i=e+"TargetAdded";this.controller[i]&&n(this.controller,i).call(this.controller,t),this.log("targetAdded",{target:e,node:t,trigger:r})},r.targetRemoved=function(e,t,r){var i=e+"TargetRemoved";this.controller[i]&&n(this.controller,i).call(this.controller,t),this.log("targetRemoved",{target:e,node:t,trigger:r})},r.targetChanged=function(e,t,r){var i=e+"TargetChanged";this.controller[i]&&n(this.controller,i).call(this.controller,t),this.log("targetChanged",{target:e,node:t,trigger:r})},r.targetsUsedByThisControllerFromNode=function(e){if("#text"==e.nodeName)return[];var t=e;return this.targetsUsedByThisController(t.getAttribute(this.scopedTargetSelector)||t.getAttribute(this.targetSelector))},r.targetsUsedByThisController=function(e){var t=this.stripIdentifierPrefix(e=e||"").split(" ");return this.targets.filter(function(e){return-1!==t.indexOf(e)})},r.stripIdentifierPrefix=function(e){return e.replace(new RegExp(this.identifierPrefix,"g"),"")},r.enhanceController=function(){var e=this,t=this.controller.disconnect.bind(this.controller);Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(C),R=function(e,t){void 0===t&&(t={});var n=new k(e,t);return[n.observe,n.unobserve]},B=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=R(c(n),n.options),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),D=function(e){var t=function(t){var r=window,i={height:r.innerHeight||Infinity,width:r.innerWidth||Infinity,event:t};n(e,"windowResize").call(e,i)},r=e.disconnect.bind(e),i=function(){window.addEventListener("resize",t),t()},o=function(){window.removeEventListener("resize",t)};return Object.assign(e,{disconnect:function(){o(),r()}}),i(),[i,o]},H=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=D(c(n)),t=e[0],r=e[1];Object.assign(c(n),{observe:t,unobserve:r})}),n}return l(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return l(t,e),t}(t.Controller)),W=function(e,t){void 0===t&&(t=200);var n=null;return function(){var r=arguments,i=this,o=function(){return e.apply(i,r)};n&&clearTimeout(n),n=setTimeout(o,t)}};function _(e,t){var n;return void 0===t&&(t=200),function(){var r=arguments,i=this;n||(n=!0,e.apply(i,r),setTimeout(function(){return n=!1},t))}}function G(e){var t=document.head.querySelector('meta[name="'+e+'"]');return t&&t.getAttribute("content")}function J(e){try{return JSON.parse(e)}catch(t){return e}}function $(e){return e.replace(/(?:[_-])([a-z0-9])/g,function(e,t){return t.toUpperCase()})}var K={enterClass:"enter",enterActiveClass:"enterStart",enterToClass:"enterEnd",leaveClass:"leave",leaveActiveClass:"leaveStart",leaveToClass:"leaveEnd"},Q={transitioned:!1,hiddenClass:"hidden",preserveOriginalClass:!0,removeToClasses:!0},X=function(e,t){var n,r,i,o,s=function(e,t,n,r,i,o,s){try{var a=[];return o&&(t.forEach(function(t){return e.classList.contains(t)&&t!==i&&a.push(t)}),n.forEach(function(t){return e.classList.contains(t)&&t!==i&&a.push(t)}),r.forEach(function(t){return e.classList.contains(t)&&t!==i&&a.push(t)})),w(e,t),j(e,a),w(e,n),Promise.resolve(function(){try{return Promise.resolve(new Promise(function(e){requestAnimationFrame(function(){requestAnimationFrame(e)})}))}catch(e){return Promise.reject(e)}}()).then(function(){return j(e,t),w(e,r),Promise.resolve(function(e){try{return Promise.resolve(new Promise(function(t){var n=1e3*Number(getComputedStyle(e).transitionDuration.split(",")[0].replace("s",""));setTimeout(function(){t(n)},n)}))}catch(e){return Promise.reject(e)}}(e)).then(function(){j(e,n),s&&j(e,r),w(e,a)})})}catch(e){return Promise.reject(e)}},a=function(n){try{if(!e.transitioned)return Promise.resolve();e.transitioned=!1,E&&E(n);var r=Y("leave",t,d),i=Y("leaveActive",t,d),o=Y("leaveTo",t,d),a=Y("enterTo",t,d);return p||j(v,a),Promise.resolve(s(v,r,i,o,g,m,p)).then(function(){g&&v.classList.add(g)})}catch(e){return Promise.reject(e)}},l=function(n){try{if(e.transitioned)return Promise.resolve();e.transitioned=!0,y&&y(n);var r=Y("enter",t,d),i=Y("enterActive",t,d),o=Y("enterTo",t,d),l=Y("leaveTo",t,d);return g&&v.classList.remove(g),p||j(v,l),Promise.resolve(s(v,r,i,o,g,m,p)).then(function(){f>0&&setTimeout(function(){a(n),console.log("after")},f)})}catch(e){return Promise.reject(e)}};void 0===t&&(t={});var c,u=e.element.dataset.transitionTarget;u&&(c=e[u+"Target"]);var v=(null==(n=t)?void 0:n.element)||c||e.element;if(v instanceof HTMLElement||v instanceof SVGElement){var d=v.dataset,f=parseInt(d.leaveAfter||"")||t.leaveAfter||0,h=Object.assign(Q,t),b=h.transitioned,g=h.hiddenClass,m=h.preserveOriginalClass,p=h.removeToClasses,y=null==(r=e.enter)?void 0:r.bind(e),E=null==(i=e.leave)?void 0:i.bind(e),C=null==(o=e.toggleTransition)?void 0:o.bind(e);return e.transitioned=b,b?(g&&v.classList.remove(g),l()):(g&&v.classList.add(g),a()),Object.assign(e,{enter:l,leave:a,toggleTransition:O}),[l,a,O]}function O(t){C&&C(t),e.transitioned?a():l()}function w(e,t){var n;t.length>0&&(n=e.classList).add.apply(n,t)}function j(e,t){var n;t.length>0&&(n=e.classList).remove.apply(n,t)}};function Y(e,t,n){var r,i="transition"+e[0].toUpperCase()+e.substr(1),o=t[e]||n[i]||n[K[e]]||" ";return 0!==(r=o).length&&r.trim()?o.split(" "):[]}var Z=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){X(c(n),n.options)}),n}return l(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).transitioned=!1,t}return l(t,e),t}(t.Controller));e.ApplicationController=T,e.ClickOutsideController=y,e.HoverController=M,e.IdleController=L,e.IntersectionController=v,e.LazyLoadController=f,e.MutationController=z,e.ResizeController=g,e.TargetMutationController=B,e.TransitionController=Z,e.UseHover=S,e.UseMutation=U,e.UseTargetMutation=k,e.UseVisibility=I,e.VisibilityController=V,e.WindowResizeController=H,e.useApplication=j,e.useClickOutside=p,e.useDebounce=function(e,t){var n;null==(n=e.constructor.debounces)||n.forEach(function(n){if("string"==typeof n&&(e[n]=W(e[n],null==t?void 0:t.wait)),"object"==typeof n){var r=n.name;if(!r)return;e[r]=W(e[r],n.wait||(null==t?void 0:t.wait))}})},e.useDispatch=w,e.useHover=F,e.useIdle=A,e.useIntersection=s,e.useLazyLoad=d,e.useMemo=function(e){var t;null==(t=e.constructor.memos)||t.forEach(function(t){!function(e,t,n){Object.defineProperty(e,t,{value:n})}(e,t,e[t])})},e.useMeta=function(e,t){void 0===t&&(t={suffix:!0});var n=e.constructor.metaNames,r=t.suffix;null==n||n.forEach(function(t){!function(e,t,n){var r=n?$(t)+"Meta":$(t);Object.defineProperty(e,r,{get:function(){return J(G(t))}})}(e,t,r)}),Object.defineProperty(e,"metas",{get:function(){var e={};return null==n||n.forEach(function(t){var n=J(G(t));null!=n&&(e[$(t)]=n)}),e}})},e.useMutation=q,e.useResize=b,e.useTargetMutation=R,e.useThrottle=function(e,t){var n;void 0===t&&(t={}),null==(n=e.constructor.throttles)||n.forEach(function(n){var r;if("string"==typeof n&&(e[n]=_(e[n],null==(r=t)?void 0:r.wait)),"object"==typeof n){var i,o=n.name;if(!o)return;e[o]=_(e[o],n.wait||(null==(i=t)?void 0:i.wait))}})},e.useTransition=X,e.useVisibility=N,e.useWindowResize=D});
//# sourceMappingURL=index.umd.js.map
import { TransitionComposableController } from './transition-controller';
export interface TransitionOptions {
element?: Element;
dispatchEvent?: boolean;
transitioned?: boolean;
eventPrefix?: boolean | string;
enter?: string;

@@ -14,4 +12,7 @@ enterActive?: string;

hiddenClass?: string;
leaveAfter?: number;
preserveOriginalClass?: boolean;
removeToClasses?: boolean;
}
export declare const useTransition: (controller: TransitionComposableController, options?: TransitionOptions) => ((event: Event) => void)[] | undefined;
//# sourceMappingURL=use-transition.d.ts.map

@@ -10,6 +10,6 @@ const alpineNames = {

const defaultOptions = {
dispatchEvent: true,
eventPrefix: true,
transitioned: false,
hiddenClass: "hidden"
hiddenClass: "hidden",
preserveOriginalClass: true,
removeToClasses: true
};

@@ -28,3 +28,4 @@ export const useTransition = (controller, options = {}) => {

const dataset = targetElement.dataset;
const { transitioned, hiddenClass } = Object.assign(defaultOptions, options);
const leaveAfter = parseInt(dataset.leaveAfter || "") || options.leaveAfter || 0;
const { transitioned, hiddenClass, preserveOriginalClass, removeToClasses } = Object.assign(defaultOptions, options);
const controllerEnter = (_a = controller.enter) === null || _a === void 0 ? void 0 : _a.bind(controller);

@@ -38,9 +39,19 @@ const controllerLeave = (_b = controller.leave) === null || _b === void 0 ? void 0 : _b.bind(controller);

controllerEnter && controllerEnter(event);
const enterClass = getAttribute("enter", options, dataset);
const enterActiveClass = getAttribute("enterActive", options, dataset);
const enterToClass = getAttribute("enterTo", options, dataset);
const enterClasses = getAttribute("enter", options, dataset);
const enterActiveClasses = getAttribute("enterActive", options, dataset);
const enterToClasses = getAttribute("enterTo", options, dataset);
const leaveToClasses = getAttribute("leaveTo", options, dataset);
if (!!hiddenClass) {
targetElement.classList.remove(hiddenClass);
}
await transition(targetElement, enterClass, enterActiveClass, enterToClass);
if (!removeToClasses) {
removeClasses(targetElement, leaveToClasses);
}
await transition(targetElement, enterClasses, enterActiveClasses, enterToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
if (leaveAfter > 0) {
setTimeout(() => {
leave(event);
console.log("after");
}, leaveAfter);
}
}

@@ -52,6 +63,10 @@ async function leave(event) {

controllerLeave && controllerLeave(event);
const leaveClass = getAttribute("leave", options, dataset);
const leaveActiveClass = getAttribute("leaveActive", options, dataset);
const leaveToClass = getAttribute("leaveTo", options, dataset);
await transition(targetElement, leaveClass, leaveActiveClass, leaveToClass);
const leaveClasses = getAttribute("leave", options, dataset);
const leaveActiveClasses = getAttribute("leaveActive", options, dataset);
const leaveToClasses = getAttribute("leaveTo", options, dataset);
const enterToClasses = getAttribute("enterTo", options, dataset);
if (!removeToClasses) {
removeClasses(targetElement, enterToClasses);
}
await transition(targetElement, leaveClasses, leaveActiveClasses, leaveToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
if (!!hiddenClass) {

@@ -70,10 +85,31 @@ targetElement.classList.add(hiddenClass);

}
async function transition(element, initialClass, activeClass, toClass) {
element.classList.add(...initialClass);
element.classList.add(...activeClass);
await nextFrame();
element.classList.remove(...activeClass);
element.classList.add(...toClass);
async function transition(element, initialClasses, activeClasses, endClasses, hiddenClass, preserveOriginalClass, removeEndClasses) {
// if there's any overlap between the current set of classes and initialClasses/activeClasses/endClasses,
// we should remove them before we start and add them back at the end
const stashedClasses = [];
if (preserveOriginalClass) {
initialClasses.forEach(cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls));
activeClasses.forEach(cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls));
endClasses.forEach(cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls));
}
// Add initial class before element start transition
addClasses(element, initialClasses);
// remove the overlapping classes
removeClasses(element, stashedClasses);
// Add active class before element start transition and maitain it during the entire transition.
addClasses(element, activeClasses);
await nextAnimationFrame();
// remove the initial class on frame after the beginning of the transition
removeClasses(element, initialClasses);
// add the endClass on frame after the beginning of the transition
addClasses(element, endClasses);
// dynamically comput the duration of the transition from the style of the element
await afterTransition(element);
element.classList.remove(...initialClass);
// remove both activeClasses and endClasses
removeClasses(element, activeClasses);
if (removeEndClasses) {
removeClasses(element, endClasses);
}
// restore the overlaping classes
addClasses(element, stashedClasses);
}

@@ -95,2 +131,12 @@ function initialState() {

}
function addClasses(element, classes) {
if (classes.length > 0) {
element.classList.add(...classes);
}
}
function removeClasses(element, classes) {
if (classes.length > 0) {
element.classList.remove(...classes);
}
}
initialState();

@@ -103,4 +149,4 @@ Object.assign(controller, { enter, leave, toggleTransition });

const datasetAlpineName = alpineNames[name];
const classes = options[name] || dataset[datasetName] || dataset[datasetAlpineName] || "";
return classes.split(" ");
const classes = options[name] || dataset[datasetName] || dataset[datasetAlpineName] || " ";
return isEmpty(classes) ? [] : classes.split(" ");
}

@@ -118,3 +164,3 @@ async function afterTransition(element) {

}
async function nextFrame() {
async function nextAnimationFrame() {
return new Promise(resolve => {

@@ -126,2 +172,5 @@ requestAnimationFrame(() => {

}
function isEmpty(str) {
return (str.length === 0 || !str.trim());
}
//# sourceMappingURL=use-transition.js.map
{
"name": "stimulus-use",
"version": "0.23.0",
"version": "0.24.0-0",
"description": "A collection of standard controllers and utilities for Stimulus",

@@ -41,3 +41,3 @@ "main": "dist/index.umd.js",

"intersection-observer": "^0.11.0",
"karma": "^5.2.1",
"karma": "^6.1.0",
"karma-chai": "^0.1.0",

@@ -44,0 +44,0 @@ "karma-chrome-launcher": "^3.1.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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