stimulus-use
Advanced tools
Comparing version 0.24.0-0 to 0.24.0-1
@@ -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,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}); | ||
!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]},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,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 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]},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)),F=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),S=function(e,t){void 0===t&&(t={});var n=new F(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=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(){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={enterFromClass:"enter",enterActiveClass:"enterStart",enterToClass:"enterEnd",leaveFromClass:"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("leaveFrom",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,m,g,p)).then(function(){m&&v.classList.add(m)})}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("enterFrom",t,d),i=Y("enterActive",t,d),o=Y("enterTo",t,d),l=Y("leaveTo",t,d);return m&&v.classList.remove(m),p||j(v,l),Promise.resolve(s(v,r,i,o,m,g,p)).then(function(){f>0&&setTimeout(function(){a(n)},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,m=h.hiddenClass,g=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?(m&&v.classList.remove(m),l()):(m&&v.classList.add(m),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=m,e.TargetMutationController=B,e.TransitionController=Z,e.UseHover=F,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=S,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 |
@@ -5,7 +5,7 @@ import { TransitionComposableController } from './transition-controller'; | ||
transitioned?: boolean; | ||
enter?: string; | ||
enterActive?: string; | ||
enterFrom?: string; | ||
enterTo?: string; | ||
leave?: string; | ||
leaveActive?: string; | ||
leaveFrom?: string; | ||
leaveTo?: string; | ||
@@ -12,0 +12,0 @@ hiddenClass?: string; |
const alpineNames = { | ||
enterClass: "enter", | ||
enterFromClass: "enter", | ||
enterActiveClass: "enterStart", | ||
enterToClass: "enterEnd", | ||
leaveClass: "leave", | ||
leaveFromClass: "leave", | ||
leaveActiveClass: "leaveStart", | ||
@@ -37,3 +37,3 @@ leaveToClass: "leaveEnd", | ||
controllerEnter && controllerEnter(event); | ||
const enterClasses = getAttribute("enter", options, dataset); | ||
const enterFromClasses = getAttribute("enterFrom", options, dataset); | ||
const enterActiveClasses = getAttribute("enterActive", options, dataset); | ||
@@ -48,7 +48,6 @@ const enterToClasses = getAttribute("enterTo", options, dataset); | ||
} | ||
await transition(targetElement, enterClasses, enterActiveClasses, enterToClasses, hiddenClass, preserveOriginalClass, removeToClasses); | ||
await transition(targetElement, enterFromClasses, enterActiveClasses, enterToClasses, hiddenClass, preserveOriginalClass, removeToClasses); | ||
if (leaveAfter > 0) { | ||
setTimeout(() => { | ||
leave(event); | ||
console.log("after"); | ||
}, leaveAfter); | ||
@@ -62,3 +61,3 @@ } | ||
controllerLeave && controllerLeave(event); | ||
const leaveClasses = getAttribute("leave", options, dataset); | ||
const leaveFromClasses = getAttribute("leaveFrom", options, dataset); | ||
const leaveActiveClasses = getAttribute("leaveActive", options, dataset); | ||
@@ -70,3 +69,3 @@ const leaveToClasses = getAttribute("leaveTo", options, dataset); | ||
} | ||
await transition(targetElement, leaveClasses, leaveActiveClasses, leaveToClasses, hiddenClass, preserveOriginalClass, removeToClasses); | ||
await transition(targetElement, leaveFromClasses, leaveActiveClasses, leaveToClasses, hiddenClass, preserveOriginalClass, removeToClasses); | ||
if (!!hiddenClass) { | ||
@@ -73,0 +72,0 @@ targetElement.classList.add(hiddenClass); |
{ | ||
"name": "stimulus-use", | ||
"version": "0.24.0-0", | ||
"version": "0.24.0-1", | ||
"description": "A collection of standard controllers and utilities for Stimulus", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.umd.js", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
261424
1735