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.24.0-2 to 0.25.0

dist/use-hotkeys/index.d.ts

1

dist/index.d.ts

@@ -18,2 +18,3 @@ export { useIntersection, IntersectionController } from './use-intersection/index';

export { useTransition, TransitionOptions, TransitionController } from './use-transition/index';
export { useHotkeys } from './use-hotkeys';
//# sourceMappingURL=index.d.ts.map

@@ -18,2 +18,3 @@ export { useIntersection, IntersectionController } from './use-intersection/index';

export { useTransition, TransitionController } from './use-transition/index';
export { useHotkeys } from './use-hotkeys';
//# sourceMappingURL=index.js.map

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||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),c=a.dispatchEvent,l=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),c){var o=r("appear",e,l),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),c){var o=r("disappear",e,l),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 c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(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(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isVisible=!1,t}return c(t,e),t}(t.Controller)),f=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]},h=function(e){function t(t){var n;return(n=e.call(this,t)||this).options={rootMargin:"10%"},requestAnimationFrame(function(){var e=f(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isLoading=!1,t.isLoaded=!1,t}return c(t,e),t}(t.Controller)),b={dispatchEvent:!0,eventPrefix:!0},m=function(e,t){var o;void 0===t&&(t={});var s=Object.assign({},b,t),a=s.dispatchEvent,c=s.eventPrefix,l=(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,c),u=i(s,null,{controller:e,entry:o});l.dispatchEvent(u)}}),d=function(){v.observe(l)},f=function(){v.unobserve(l)};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=m(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(t.Controller)),p={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},y=function(e,t){void 0===t&&(t={});var n=Object.assign({},p,t),o=n.onlyVisible,s=n.dispatchEvent,a=n.events,c=n.eventPrefix,l=function(n){var a,l,u,v,d=(null==(a=t)?void 0:a.element)||e.element;if(!d.contains(n.target)&&(l=d.getBoundingClientRect(),u=window.innerHeight||document.documentElement.clientHeight,v=window.innerWidth||document.documentElement.clientWidth,l.top<=u&&l.top+l.height>=0&&l.left<=v&&l.left+l.width>=0||!o)&&(e.clickOutside&&e.clickOutside(n),s)){var f=r("click:outside",e,c),h=i(f,n,{controller:e});d.dispatchEvent(h)}},u=function(){null==a||a.forEach(function(e){window.addEventListener(e,l,!1)})},v=function(){null==a||a.forEach(function(e){window.removeEventListener(e,l,!1)})},d=e.disconnect.bind(e);return Object.assign(e,{disconnect:function(){v(),d()}}),u(),[u,v]},E=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=y(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(t.Controller)),C={debug:!1,logger:console,dispatchEvent:!0,eventPrefix:!0},O=function(e,t){var n,r,i,o,s,c,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.dispatch=function(e,t){if(void 0===t&&(t={}),l.dispatchEvent){var n=t.event,r=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(t,["event"]),i=l.extendedEvent(e,n||null,r);l.targetElement.dispatchEvent(i),l.log("dispatchEvent",a({eventName:i.type},r))}},this.call=function(e,t){void 0===t&&(t={});var n=l.controller[e];if("function"==typeof n)return n.call(l.controller,t)},this.extendedEvent=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(l.composeEventName(e),{bubbles:i,cancelable:o,composed:s,detail:n})},this.composeEventName=function(e){var t=e;return!0===l.eventPrefix?t=l.controller.identifier+":"+e:"string"==typeof l.eventPrefix&&(t=l.eventPrefix+":"+e),t},this.debug=null!=(n=null!=(r=null==(i=t)?void 0:i.debug)?r:e.application.stimulusUseDebug)?n:C.debug,this.logger=null!=(o=null==(s=t)?void 0:s.logger)?o:C.logger,this.controller=e,this.controllerId=e.element.id||e.element.dataset.id,this.targetElement=(null==(c=t)?void 0:c.element)||e.element;var u=Object.assign({},C,t);Object.assign(this,{dispatchEvent:u.dispatchEvent,eventPrefix:u.eventPrefix}),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,c;return void 0===n&&(n={}),(c=e.call(this,t,n)||this).dispatch=function(e,t){void 0===t&&(t={});var n=u(c),i=n.targetElement,o=n.eventPrefix,s=n.bubbles,a=n.cancelable,l=n.log;Object.assign(t,{controller:n.controller});var v=r(e,c.controller,o),d=new CustomEvent(v,{detail:t,bubbles:s,cancelable:a});return i.dispatchEvent(d),l("dispatch",{eventName:v,detail:t,bubbles:s,cancelable:a}),d},c.targetElement=null!=(i=n.element)?i:t.element,c.eventPrefix=null==(o=n.eventPrefix)||o,c.bubbles=null==(s=n.bubbles)||s,c.cancelable=null==(a=n.cancelable)||a,c.enhanceController(),c}return c(t,e),t.prototype.enhanceController=function(){Object.assign(this.controller,{dispatch:this.dispatch})},t}(O),j=function(e,t){return void 0===t&&(t={}),new w(e,t)},T=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")}}),j(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="",T(u(n),n.options),n}return c(t,e),t}(t.Controller),x={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({},x,t),s=o.ms,a=o.events,c=o.dispatchEvent,l=o.eventPrefix,u=o.initialState,v=setTimeout(function(){u=!0,d()},s),d=function(t){var o=r("away",e,l);if(e.isIdle=!0,n(e,"away").call(e,t),c){var s=i(o,t||null,{controller:e});e.element.dispatchEvent(s)}},f=function(t){var o=r("back",e,l);if(e.isIdle=!1,n(e,"back").call(e,t),c){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(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isIdle=!1,t}return c(t,e),t}(t.Controller)),N=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this,t,n)||this).observe=function(){r.controller.isVisible=!document.hidden,document.addEventListener("visibilitychange",r.handleVisibilityChange),r.handleVisibilityChange()},r.unobserve=function(){document.removeEventListener("visibilitychange",r.handleVisibilityChange)},r.becomesInvisible=function(e){r.controller.isVisible=!1,r.call("invisible",e),r.log("invisible",{isVisible:!1}),r.dispatch("invisible",{event:e,isVisible:!1})},r.becomesVisible=function(e){r.controller.isVisible=!0,r.call("visible",e),r.log("visible",{isVisible:!0}),r.dispatch("visible",{event:e,isVisible:!0})},r.handleVisibilityChange=function(e){document.hidden?r.becomesInvisible(e):r.becomesVisible(e)},r.controller=t,r.enhanceController(),r.observe(),r}return c(t,e),t.prototype.enhanceController=function(){var e=this,t=this.controllerDisconnect;Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(O),I=function(e,t){void 0===t&&(t={});var n=new N(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=I(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isVisible=!1,t}return c(t,e),t}(t.Controller)),F=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this,t,n)||this).observe=function(){r.targetElement.addEventListener("mouseenter",r.onEnter),r.targetElement.addEventListener("mouseleave",r.onLeave)},r.unobserve=function(){r.targetElement.removeEventListener("mouseenter",r.onEnter),r.targetElement.removeEventListener("mouseleave",r.onLeave)},r.onEnter=function(e){r.call("mouseEnter",e),r.log("mouseEnter",{hover:!0}),r.dispatch("mouseEnter",{hover:!1})},r.onLeave=function(e){r.call("mouseLeave",e),r.log("mouseLeave",{hover:!1}),r.dispatch("mouseLeave",{hover:!1})},r.controller=t,r.enhanceController(),r.observe(),r}return c(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}(O),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(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(t.Controller)),U=function(e){function t(t,n){var r,i;return void 0===n&&(n={}),(i=e.call(this,t,n)||this).observe=function(){try{i.observer.observe(i.targetElement,i.options)}catch(e){i.controller.application.handleError(e,"At a minimum, one of childList, attributes, and/or characterData must be true",{})}},i.unobserve=function(){i.observer.disconnect()},i.mutation=function(e){i.call("mutate",e),i.log("mutate",{entries:e}),i.dispatch("mutate",{entries:e})},i.targetElement=(null==(r=n)?void 0:r.element)||t.element,i.controller=t,i.options=n,i.observer=new MutationObserver(i.mutation),i.enhanceController(),i.observe(),i}return c(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}(O),k=function(e,t){void 0===t&&(t={});var n=new U(e,t);return[n.observe,n.unobserve]},q=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=k(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return c(t,e),t}(t.Controller)),z=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 c=r.findTargetInAncestry(e.target);if(null==c)return{v:void 0};r.targetsUsedByThisControllerFromNode(c).forEach(function(e){r.targetChanged(r.stripIdentifierPrefix(e),c,"domMutation")});break;case"childList":var l=e.removedNodes;e.addedNodes.forEach(function(e){return r.processNodeDOMMutation(e,r.targetAdded)}),l.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 v(e,t);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)?v(e,t):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}c(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||"#comment"==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}(O),R=function(e,t){void 0===t&&(t={});var n=new z(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(u(n),n.options),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return c(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(u(n)),t=e[0],r=e[1];Object.assign(u(n),{observe:t,unobserve:r})}),n}return c(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return c(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)}},c=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),c=Y("leaveTo",t,d);return m&&v.classList.remove(m),p||j(v,c),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 l,u=e.element.dataset.transitionTarget;u&&(l=e[u+"Target"]);var v=(null==(n=t)?void 0:n.element)||l||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),c()):(m&&v.classList.add(m),a()),Object.assign(e,{enter:c,leave:a,toggleTransition:O}),[c,a,O]}function O(t){C&&C(t),e.transitioned?a():c()}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(u(n),n.options)}),n}return c(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).transitioned=!1,t}return c(t,e),t}(t.Controller));e.ApplicationController=P,e.ClickOutsideController=E,e.HoverController=M,e.IdleController=L,e.IntersectionController=d,e.LazyLoadController=h,e.MutationController=q,e.ResizeController=g,e.TargetMutationController=B,e.TransitionController=Z,e.UseHover=F,e.UseMutation=U,e.UseTargetMutation=z,e.UseVisibility=N,e.VisibilityController=V,e.WindowResizeController=H,e.useApplication=T,e.useClickOutside=y,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=j,e.useHover=S,e.useIdle=A,e.useIntersection=s,e.useLazyLoad=f,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=k,e.useResize=m,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=I,e.useWindowResize=D});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("stimulus"),require("hotkeys-js")):"function"==typeof define&&define.amd?define(["exports","stimulus","hotkeys-js"],t):t((e||self).StimulusUse={},e.Stimulus,e.hotkeysJs)}(this,function(e,t,n){function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(n),o=function(e,t){var n=e[t];return"function"==typeof n?n:function(){}},s=function(e,t,n){var r=e;return!0===n?r=t.identifier+":"+e:"string"==typeof n&&(r=n+":"+e),r},a=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})},c={dispatchEvent:!0,eventPrefix:!0},l=function(e,t){var n;void 0===t&&(t={});var r=Object.assign({},c,t),i=r.dispatchEvent,l=r.eventPrefix,u=(null==(n=t)?void 0:n.element)||e.element,f=e.disconnect.bind(e),d=new IntersectionObserver(function(t){var n=t[0];n.isIntersecting?function(t){if(e.isVisible=!0,o(e,"appear").call(e,t),i){var n=s("appear",e,l),r=a(n,null,{controller:e,entry:t});u.dispatchEvent(r)}}(n):e.isVisible&&function(t){if(e.isVisible=!1,o(e,"disappear").call(e,t),i){var n=s("disappear",e,l),r=a(n,null,{controller:e,entry:t});u.dispatchEvent(r)}}(n)},t),v=function(){d.observe(u)},h=function(){d.unobserve(u)};return Object.assign(e,{isVisible:!1,disconnect:function(){h(),f()}}),v(),[v,h]};function u(){return(u=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 f(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(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 b=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=l(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isVisible=!1,t}return f(t,e),t}(t.Controller)),m=function(e,t){var n=e.disconnect.bind(e),r=new IntersectionObserver(function(t){t[0].isIntersecting&&!e.isLoaded&&function(t){var n=e.data.get("src");if(n){var r=e.element;e.isLoading=!0,o(e,"loading").call(e,n),r.onload=function(){!function(t){e.isLoading=!1,e.isLoaded=!0,o(e,"loaded").call(e,t)}(n)},r.src=n}}()},t),i=function(){r.observe(e.element)},s=function(){r.unobserve(e.element)};return Object.assign(e,{isVisible:!1,disconnect:function(){s(),n()}}),i(),[i,s]},g=function(e){function t(t){var n;return(n=e.call(this,t)||this).options={rootMargin:"10%"},requestAnimationFrame(function(){var e=m(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isLoading=!1,t.isLoaded=!1,t}return f(t,e),t}(t.Controller)),p={dispatchEvent:!0,eventPrefix:!0},y=function(e,t){var n;void 0===t&&(t={});var r=Object.assign({},p,t),i=r.dispatchEvent,c=r.eventPrefix,l=(null==(n=t)?void 0:n.element)||e.element,u=e.disconnect.bind(e),f=new ResizeObserver(function(t){var n=t[0];if(o(e,"resize").call(e,n.contentRect),i){var r=s("resize",e,c),u=a(r,null,{controller:e,entry:n});l.dispatchEvent(u)}}),d=function(){f.observe(l)},v=function(){f.unobserve(l)};return Object.assign(e,{disconnect:function(){v(),u()}}),d(),[d,v]},E=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=y(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(t.Controller)),C={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},O=function(e,t){void 0===t&&(t={});var n=Object.assign({},C,t),r=n.onlyVisible,i=n.dispatchEvent,o=n.events,c=n.eventPrefix,l=function(n){var o,l,u,f,d=(null==(o=t)?void 0:o.element)||e.element;if(!d.contains(n.target)&&(l=d.getBoundingClientRect(),u=window.innerHeight||document.documentElement.clientHeight,f=window.innerWidth||document.documentElement.clientWidth,l.top<=u&&l.top+l.height>=0&&l.left<=f&&l.left+l.width>=0||!r)&&(e.clickOutside&&e.clickOutside(n),i)){var v=s("click:outside",e,c),h=a(v,n,{controller:e});d.dispatchEvent(h)}},u=function(){null==o||o.forEach(function(e){window.addEventListener(e,l,!1)})},f=function(){null==o||o.forEach(function(e){window.removeEventListener(e,l,!1)})},d=e.disconnect.bind(e);return Object.assign(e,{disconnect:function(){f(),d()}}),u(),[u,f]},w=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=O(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(t.Controller)),j={debug:!1,logger:console,dispatchEvent:!0,eventPrefix:!0},T=function(e,t){var n,r,i,o,s,a,c=this;void 0===t&&(t={}),this.log=function(e,t){c.debug&&(c.logger.groupCollapsed("%c"+c.controller.identifier+" %c#"+e,"color: #3B82F6","color: unset"),c.logger.log(u({controllerId:c.controllerId},t)),c.logger.groupEnd())},this.dispatch=function(e,t){if(void 0===t&&(t={}),c.dispatchEvent){var n=t.event,r=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(t,["event"]),i=c.extendedEvent(e,n||null,r);c.targetElement.dispatchEvent(i),c.log("dispatchEvent",u({eventName:i.type},r))}},this.call=function(e,t){void 0===t&&(t={});var n=c.controller[e];if("function"==typeof n)return n.call(c.controller,t)},this.extendedEvent=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(c.composeEventName(e),{bubbles:i,cancelable:o,composed:s,detail:n})},this.composeEventName=function(e){var t=e;return!0===c.eventPrefix?t=c.controller.identifier+":"+e:"string"==typeof c.eventPrefix&&(t=c.eventPrefix+":"+e),t},this.debug=null!=(n=null!=(r=null==(i=t)?void 0:i.debug)?r:e.application.stimulusUseDebug)?n:j.debug,this.logger=null!=(o=null==(s=t)?void 0:s.logger)?o:j.logger,this.controller=e,this.controllerId=e.element.id||e.element.dataset.id,this.targetElement=(null==(a=t)?void 0:a.element)||e.element;var l=Object.assign({},j,t);Object.assign(this,{dispatchEvent:l.dispatchEvent,eventPrefix:l.eventPrefix}),this.controllerInitialize=e.initialize.bind(e),this.controllerConnect=e.connect.bind(e),this.controllerDisconnect=e.disconnect.bind(e)},P=function(e){function t(t,n){var r,i,o,a,c;return void 0===n&&(n={}),(c=e.call(this,t,n)||this).dispatch=function(e,t){void 0===t&&(t={});var n=v(c),r=n.targetElement,i=n.eventPrefix,o=n.bubbles,a=n.cancelable,l=n.log;Object.assign(t,{controller:n.controller});var u=s(e,c.controller,i),f=new CustomEvent(u,{detail:t,bubbles:o,cancelable:a});return r.dispatchEvent(f),l("dispatch",{eventName:u,detail:t,bubbles:o,cancelable:a}),f},c.targetElement=null!=(r=n.element)?r:t.element,c.eventPrefix=null==(i=n.eventPrefix)||i,c.bubbles=null==(o=n.bubbles)||o,c.cancelable=null==(a=n.cancelable)||a,c.enhanceController(),c}return f(t,e),t.prototype.enhanceController=function(){Object.assign(this.controller,{dispatch:this.dispatch})},t}(T),x=function(e,t){return void 0===t&&(t={}),new P(e,t)},A=function(e,t){void 0===t&&(t={}),Object.defineProperty(e,"isPreview",{get:function(){return document.documentElement.hasAttribute("data-turbolinks-preview")||document.documentElement.hasAttribute("data-turbo-preview")}}),Object.defineProperty(e,"isConnected",{get:function(){var e=this;return!!Array.from(this.context.module.connectedContexts).find(function(t){return t===e.context})}}),Object.defineProperty(e,"csrfToken",{get:function(){return this.metaValue("csrf-token")}}),x(e,t),Object.assign(e,{metaValue:function(e){var t=document.head.querySelector('meta[name="'+e+'"]');return t&&t.getAttribute("content")}})},L=function(e){function t(t){var n;return(n=e.call(this,t)||this).isPreview=!1,n.isConnected=!1,n.csrfToken="",A(v(n),n.options),n}return f(t,e),t}(t.Controller),N={ms:6e4,initialState:!1,events:["mousemove","mousedown","resize","keydown","touchstart","wheel"],dispatchEvent:!0,eventPrefix:!0},I=function(e,t){void 0===t&&(t={});var n=Object.assign({},N,t),r=n.ms,i=n.events,c=n.dispatchEvent,l=n.eventPrefix,u=n.initialState,f=setTimeout(function(){u=!0,d()},r),d=function(t){var n=s("away",e,l);if(e.isIdle=!0,o(e,"away").call(e,t),c){var r=a(n,t||null,{controller:e});e.element.dispatchEvent(r)}},v=function(t){var n=s("back",e,l);if(e.isIdle=!1,o(e,"back").call(e,t),c){var r=a(n,t||null,{controller:e});e.element.dispatchEvent(r)}},h=function(e){u&&v(e),u=!1,clearTimeout(f),f=setTimeout(function(){u=!0,d(e)},r)},b=function(e){document.hidden||h(e)};u?d():v();var m=e.disconnect.bind(e),g=function(){i.forEach(function(e){window.addEventListener(e,h)}),document.addEventListener("visibilitychange",b)},p=function(){i.forEach(function(e){window.removeEventListener(e,h)}),document.removeEventListener("visibilitychange",b)};return Object.assign(e,{disconnect:function(){p(),m()}}),g(),[g,p]},V=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=I(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isIdle=!1,t}return f(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.controller.isVisible=!document.hidden,document.addEventListener("visibilitychange",r.handleVisibilityChange),r.handleVisibilityChange()},r.unobserve=function(){document.removeEventListener("visibilitychange",r.handleVisibilityChange)},r.becomesInvisible=function(e){r.controller.isVisible=!1,r.call("invisible",e),r.log("invisible",{isVisible:!1}),r.dispatch("invisible",{event:e,isVisible:!1})},r.becomesVisible=function(e){r.controller.isVisible=!0,r.call("visible",e),r.log("visible",{isVisible:!0}),r.dispatch("visible",{event:e,isVisible:!0})},r.handleVisibilityChange=function(e){document.hidden?r.becomesInvisible(e):r.becomesVisible(e)},r.controller=t,r.enhanceController(),r.observe(),r}return f(t,e),t.prototype.enhanceController=function(){var e=this,t=this.controllerDisconnect;Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(T),F=function(e,t){void 0===t&&(t={});var n=new k(e,t);return[n.observe,n.unobserve]},S=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=F(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).isVisible=!1,t}return f(t,e),t}(t.Controller)),M=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this,t,n)||this).observe=function(){r.targetElement.addEventListener("mouseenter",r.onEnter),r.targetElement.addEventListener("mouseleave",r.onLeave)},r.unobserve=function(){r.targetElement.removeEventListener("mouseenter",r.onEnter),r.targetElement.removeEventListener("mouseleave",r.onLeave)},r.onEnter=function(e){r.call("mouseEnter",e),r.log("mouseEnter",{hover:!0}),r.dispatch("mouseEnter",{hover:!1})},r.onLeave=function(e){r.call("mouseLeave",e),r.log("mouseLeave",{hover:!1}),r.dispatch("mouseLeave",{hover:!1})},r.controller=t,r.enhanceController(),r.observe(),r}return f(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}(T),U=function(e,t){void 0===t&&(t={});var n=new M(e,t);return[n.observe,n.unobserve]},q=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=U(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(t.Controller)),z=function(e){function t(t,n){var r,i;return void 0===n&&(n={}),(i=e.call(this,t,n)||this).observe=function(){try{i.observer.observe(i.targetElement,i.options)}catch(e){i.controller.application.handleError(e,"At a minimum, one of childList, attributes, and/or characterData must be true",{})}},i.unobserve=function(){i.observer.disconnect()},i.mutation=function(e){i.call("mutate",e),i.log("mutate",{entries:e}),i.dispatch("mutate",{entries:e})},i.targetElement=(null==(r=n)?void 0:r.element)||t.element,i.controller=t,i.options=n,i.observer=new MutationObserver(i.mutation),i.enhanceController(),i.observe(),i}return f(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}(T),R=function(e,t){void 0===t&&(t={});var n=new z(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(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(t.Controller)),D=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 c=r.findTargetInAncestry(e.target);if(null==c)return{v:void 0};r.targetsUsedByThisControllerFromNode(c).forEach(function(e){r.targetChanged(r.stripIdentifierPrefix(e),c,"domMutation")});break;case"childList":var l=e.removedNodes;e.addedNodes.forEach(function(e){return r.processNodeDOMMutation(e,r.targetAdded)}),l.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 h(e,t);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)?h(e,t):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}f(t,e);var n=t.prototype;return n.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")}))},n.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},n.targetAdded=function(e,t,n){var r=e+"TargetAdded";this.controller[r]&&o(this.controller,r).call(this.controller,t),this.log("targetAdded",{target:e,node:t,trigger:n})},n.targetRemoved=function(e,t,n){var r=e+"TargetRemoved";this.controller[r]&&o(this.controller,r).call(this.controller,t),this.log("targetRemoved",{target:e,node:t,trigger:n})},n.targetChanged=function(e,t,n){var r=e+"TargetChanged";this.controller[r]&&o(this.controller,r).call(this.controller,t),this.log("targetChanged",{target:e,node:t,trigger:n})},n.targetsUsedByThisControllerFromNode=function(e){if("#text"==e.nodeName||"#comment"==e.nodeName)return[];var t=e;return this.targetsUsedByThisController(t.getAttribute(this.scopedTargetSelector)||t.getAttribute(this.targetSelector))},n.targetsUsedByThisController=function(e){var t=this.stripIdentifierPrefix(e=e||"").split(" ");return this.targets.filter(function(e){return-1!==t.indexOf(e)})},n.stripIdentifierPrefix=function(e){return e.replace(new RegExp(this.identifierPrefix,"g"),"")},n.enhanceController=function(){var e=this,t=this.controller.disconnect.bind(this.controller);Object.assign(this.controller,{disconnect:function(){e.unobserve(),t()}})},t}(T),H=function(e,t){void 0===t&&(t={});var n=new D(e,t);return[n.observe,n.unobserve]},W=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=H(v(n),n.options),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(t.Controller)),_=function(e){var t=function(t){var n=window,r={height:n.innerHeight||Infinity,width:n.innerWidth||Infinity,event:t};o(e,"windowResize").call(e,r)},n=e.disconnect.bind(e),r=function(){window.addEventListener("resize",t),t()},i=function(){window.removeEventListener("resize",t)};return Object.assign(e,{disconnect:function(){i(),n()}}),r(),[r,i]},J=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){var e=_(v(n)),t=e[0],r=e[1];Object.assign(v(n),{observe:t,unobserve:r})}),n}return f(t,e),t}(function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(t.Controller)),G=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 K(e){var t=document.head.querySelector('meta[name="'+e+'"]');return t&&t.getAttribute("content")}function Q(e){try{return JSON.parse(e)}catch(t){return e}}function X(e){return e.replace(/(?:[_-])([a-z0-9])/g,function(e,t){return t.toUpperCase()})}var Y={enterFromClass:"enter",enterActiveClass:"enterStart",enterToClass:"enterEnd",leaveFromClass:"leave",leaveActiveClass:"leaveStart",leaveToClass:"leaveEnd"},Z={transitioned:!1,hiddenClass:"hidden",preserveOriginalClass:!0,removeToClasses:!0},ee=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=te("leaveFrom",t,d),i=te("leaveActive",t,d),o=te("leaveTo",t,d),a=te("enterTo",t,d);return p||j(f,a),Promise.resolve(s(f,r,i,o,m,g,p)).then(function(){m&&f.classList.add(m)})}catch(e){return Promise.reject(e)}},c=function(n){try{if(e.transitioned)return Promise.resolve();e.transitioned=!0,y&&y(n);var r=te("enterFrom",t,d),i=te("enterActive",t,d),o=te("enterTo",t,d),c=te("leaveTo",t,d);return m&&f.classList.remove(m),p||j(f,c),Promise.resolve(s(f,r,i,o,m,g,p)).then(function(){v>0&&setTimeout(function(){a(n)},v)})}catch(e){return Promise.reject(e)}};void 0===t&&(t={});var l,u=e.element.dataset.transitionTarget;u&&(l=e[u+"Target"]);var f=(null==(n=t)?void 0:n.element)||l||e.element;if(f instanceof HTMLElement||f instanceof SVGElement){var d=f.dataset,v=parseInt(d.leaveAfter||"")||t.leaveAfter||0,h=Object.assign(Z,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&&f.classList.remove(m),c()):(m&&f.classList.add(m),a()),Object.assign(e,{enter:c,leave:a,toggleTransition:O}),[c,a,O]}function O(t){C&&C(t),e.transitioned?a():c()}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 te(e,t,n){var r,i="transition"+e[0].toUpperCase()+e.substr(1),o=t[e]||n[i]||n[Y[e]]||" ";return 0!==(r=o).length&&r.trim()?o.split(" "):[]}var ne=function(e){function t(t){var n;return n=e.call(this,t)||this,requestAnimationFrame(function(){ee(v(n),n.options)}),n}return f(t,e),t}(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).transitioned=!1,t}return f(t,e),t}(t.Controller)),re=function(e){function t(t,n){var r;return(r=e.call(this,t,n)||this).bind=function(){for(var e=function(){var e=n[t],o=e[0],s=e[1],a=s.handler.bind(r.controller);i.default(o,s.options,function(e){return a(e,e)})},t=0,n=Object.entries(r.hotkeysOptions.hotkeys);t<n.length;t++)e()},r.unbind=function(){for(var e in r.hotkeysOptions.hotkeys)i.default.unbind(e)},r.controller=t,r.hotkeysOptions=n,r.enhanceController(),r.bind(),r}return f(t,e),t.prototype.enhanceController=function(){var e=this;this.hotkeysOptions.filter&&(i.default.filter=this.hotkeysOptions.filter);var t=this.controller.disconnect.bind(this.controller);Object.assign(this.controller,{disconnect:function(){e.unbind(),t()}})},t}(T);e.ApplicationController=L,e.ClickOutsideController=w,e.HoverController=q,e.IdleController=V,e.IntersectionController=b,e.LazyLoadController=g,e.MutationController=B,e.ResizeController=E,e.TargetMutationController=W,e.TransitionController=ne,e.UseHover=M,e.UseMutation=z,e.UseTargetMutation=D,e.UseVisibility=k,e.VisibilityController=S,e.WindowResizeController=J,e.useApplication=A,e.useClickOutside=O,e.useDebounce=function(e,t){var n;null==(n=e.constructor.debounces)||n.forEach(function(n){if("string"==typeof n&&(e[n]=G(e[n],null==t?void 0:t.wait)),"object"==typeof n){var r=n.name;if(!r)return;e[r]=G(e[r],n.wait||(null==t?void 0:t.wait))}})},e.useDispatch=x,e.useHotkeys=function(e,t){return new re(e,function(e){if(!e.hotkeys){var t={};Object.entries(e).forEach(function(e){var n;Object.defineProperty(t,e[0],{value:(n=e[1],{handler:n[0],options:{element:n[1]}}),writable:!1,enumerable:!0})}),e={hotkeys:t}}return e}(t))},e.useHover=U,e.useIdle=I,e.useIntersection=l,e.useLazyLoad=m,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?X(t)+"Meta":X(t);Object.defineProperty(e,r,{get:function(){return Q(K(t))}})}(e,t,r)}),Object.defineProperty(e,"metas",{get:function(){var e={};return null==n||n.forEach(function(t){var n=Q(K(t));null!=n&&(e[X(t)]=n)}),e}})},e.useMutation=R,e.useResize=y,e.useTargetMutation=H,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=ee,e.useVisibility=F,e.useWindowResize=_});
//# sourceMappingURL=index.umd.js.map

@@ -6,2 +6,3 @@ import { Controller, Context } from 'stimulus';

readonly isPreview: boolean;
readonly isConnected: boolean;
readonly csrfToken: string;

@@ -8,0 +9,0 @@ constructor(context: Context);

@@ -7,2 +7,3 @@ import { Controller } from 'stimulus';

this.isPreview = false;
this.isConnected = false;
this.csrfToken = '';

@@ -9,0 +10,0 @@ useApplication(this, this.options);

import { useDispatch } from '../use-dispatch/index';
export const useApplication = (controller, options = {}) => {
// getter to detect Turbolink preview
// getter to detect Turbolinks preview
Object.defineProperty(controller, 'isPreview', {
get() {
return document.documentElement.hasAttribute('data-turbolinks-preview');
return document.documentElement.hasAttribute('data-turbolinks-preview') || document.documentElement.hasAttribute('data-turbo-preview');
},
});
// getter to detect if a Stimulus controller is connected
Object.defineProperty(controller, 'isConnected', {
get() {
return !!Array.from(this.context.module.connectedContexts).find(c => c === this.context);
},
});
// getter to get the csrf token

@@ -10,0 +16,0 @@ Object.defineProperty(controller, 'csrfToken', {

{
"name": "stimulus-use",
"version": "0.24.0-2",
"version": "0.25.0",
"description": "A collection of standard controllers and utilities for Stimulus",

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

"cypress": "^5.4.0",
"hotkeys-js": "^3.8.5",
"html2js": "^0.2.0",

@@ -80,2 +81,3 @@ "intersection-observer": "^0.11.0",

"peerDependencies": {
"hotkeys-js": ">3",
"stimulus": ">=1.1.1 <3"

@@ -82,0 +84,0 @@ },

@@ -55,2 +55,3 @@ <p align="center">

|[`useClickOutside`](./docs/use-click-outside.md)|Tracks the clicks outside of the element and adds a new lifecycle callback **clickOutside**.|`clickOutside`|
|[`useHotkeys`](./docs/use-hotkeys.md)|Registers hotkeys using the [hotkeys-js](https://wangchujiang.com/hotkeys/) library and binds them to handler methods||
|[`useHover`](./docs/use-hover.md)|Tracks the user's mouse movements over an element and adds **mouseEnter** and **mouseLeave** callbacks to your controller.|`mouseEnter` `mouseLeave`|

@@ -57,0 +58,0 @@ |[`useIdle`](./docs/use-idle.md)| Tracks if the user is idle on your page and adds **away** and **back** callbacks to your controller.|`away`</br> `back`|

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

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

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