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

stimulus-use

Package Overview
Dependencies
Maintainers
1
Versions
65
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.21.3 to 0.21.4

2

dist/index.umd.js

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("stimulus")):"function"==typeof define&&define.amd?define(["exports","stimulus"],n):n((e=e||self).StimulusUse={},e.Stimulus)}(this,function(e,n){var t=function(e,n){var t=e[n];if("function"==typeof t)return t;throw new Error('undefined method "'+n+'"')},i=function(e,n,t){var i=e;return!0===t?i=n.identifier+":"+e:"string"==typeof t&&(i=t+":"+e),i},o=function(e,n,t){var i=n||{bubbles:!0,cancelable:!0,composed:!0},o=i.bubbles,r=i.cancelable,c=i.composed;return n&&Object.assign(t,{originalEvent:n}),new CustomEvent(e,{bubbles:o,cancelable:r,composed:c,detail:t})},r={dispatchEvent:!0,eventPrefix:!0},c=function(e,n){var c;void 0===n&&(n={});var l=Object.assign({},r,n),s=l.dispatchEvent,u=l.eventPrefix,a=(null==(c=n)?void 0:c.element)||e.element,d=e.disconnect.bind(e),v=new IntersectionObserver(function(n){var r=n[0];r.isIntersecting?function(n){if(e.isVisible=!0,e.appear&&t(e,"appear").call(e,n),s){var r=i("appear",e,u),c=o(r,null,{controller:e,entry:n});a.dispatchEvent(c)}}(r):e.isVisible&&function(n){if(e.isVisible=!1,e.disappear&&t(e,"disappear").call(e,n),s){var r=i("disappear",e,u),c=o(r,null,{controller:e,entry:n});a.dispatchEvent(c)}}(r)},n),f=function(){v.observe(a)},b=function(){v.unobserve(a)};return Object.assign(e,{isVisible:!1,disconnect:function(){b(),d()}}),f(),[f,b]};function l(){return(l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function s(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var a=function(e){function n(n){var t;return(t=e.call(this,n)||this).isVisible=!1,requestAnimationFrame(function(){var e=c(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n}(n.Controller),d=function(e,n){var i=e.disconnect.bind(e),o=new IntersectionObserver(function(n){n[0].isIntersecting&&!e.isLoaded&&function(n){var i=e.data.get("src");if(i){var o=e.element;e.isLoading=!0,e.loading&&t(e,"loading").call(e,i),o.onload=function(){!function(n){e.isLoading=!1,e.isLoaded=!0,e.loading&&t(e,"loaded").call(e,n)}(i)},o.src=i}}()},n),r=function(){o.observe(e.element)},c=function(){o.unobserve(e.element)};return Object.assign(e,{isVisible:!1,disconnect:function(){c(),i()}}),r(),[r,c]},v=function(e){function n(n){var t;return(t=e.call(this,n)||this).isLoading=!1,t.isLoaded=!1,t.options={rootMargin:"10%"},requestAnimationFrame(function(){var e=d(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}s(n,e);var t=n.prototype;return t.loading=function(e){},t.loaded=function(e){},n}(n.Controller),f={dispatchEvent:!0,eventPrefix:!0},b=function(e,n){var r;void 0===n&&(n={});var c=Object.assign({},f,n),l=c.dispatchEvent,s=c.eventPrefix,u=(null==(r=n)?void 0:r.element)||e.element,a=e.disconnect.bind(e),d=new ResizeObserver(function(n){var r=n[0];if(e.resize&&t(e,"resize").call(e,r.contentRect),l){var c=i("resize",e,s),a=o(c,null,{controller:e,entry:r});u.dispatchEvent(a)}}),v=function(){d.observe(u)},b=function(){d.unobserve(u)};return Object.assign(e,{disconnect:function(){b(),a()}}),v(),[v,b]},h=function(e){function n(n){var t;return t=e.call(this,n)||this,requestAnimationFrame(function(){var e=b(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n.prototype.resize=function(e){},n}(n.Controller),p={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},m=function(e,n){void 0===n&&(n={});var r=Object.assign({},p,n),c=r.onlyVisible,l=r.dispatchEvent,s=r.events,u=r.eventPrefix,a=function(r){var s,a,d=(null==(s=n)?void 0:s.element)||e.element;if(!d.contains(r.target)&&((a=d.getBoundingClientRect()).top>=0&&a.left>=0&&a.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&a.right<=(window.innerWidth||document.documentElement.clientWidth)||!c)&&(e.clickOutside&&t(e,"clickOutside").call(e,r),l)){var v=i("click:outside",e,u),f=o(v,r,{controller:e});d.dispatchEvent(f)}},d=function(){null==s||s.forEach(function(e){window.addEventListener(e,a,!1)})},v=function(){null==s||s.forEach(function(e){window.removeEventListener(e,a,!1)})},f=e.disconnect.bind(e);return Object.assign(e,{disconnect:function(){v(),f()}}),d(),[d,v]},g=function(e){function n(n){var t;return t=e.call(this,n)||this,requestAnimationFrame(function(){var e=m(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n.prototype.clickOutside=function(e){},n}(n.Controller),y={debug:!1,logger:console},w=function(e,n){var t,i,o=this;void 0===n&&(n={}),this.log=function(e,n){o.debug&&(o.logger.groupCollapsed("%c"+o.controller.identifier+"#%c"+e,"color: #3B82F6","color: unset"),o.logger.log(l({controllerId:o.controllerId},n)),o.logger.groupEnd())},this.debug=(null==(t=n)?void 0:t.debug)||e.application.stimulusUseDebug||y.debug,this.logger=(null==(i=n)?void 0:i.logger)||y.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)},E=function(e){function n(n,t){var o,r,c,l,s;return void 0===t&&(t={}),(s=e.call(this,n,t)||this).dispatch=function(e,n){void 0===n&&(n={});var t=u(s),o=t.targetElement,r=t.eventPrefix,c=t.bubbles,l=t.cancelable,a=t.log;Object.assign(n,{controller:t.controller});var d=i(e,s.controller,r),v=new CustomEvent(d,{detail:n,bubbles:c,cancelable:l});return o.dispatchEvent(v),a("dispatch",{eventName:d,detail:n,bubbles:c,cancelable:l}),v},s.targetElement=(null==(o=t)?void 0:o.element)||n.element,s.eventPrefix=(null==(r=t)?void 0:r.eventPrefix)||!0,s.bubbles=(null==(c=t)?void 0:c.bubbles)||!0,s.cancelable=(null==(l=t)?void 0:l.cancelable)||!0,s.enhanceController(),s}return s(n,e),n.prototype.enhanceController=function(){Object.assign(this.controller,{dispatch:this.dispatch})},n}(w),O=function(e,n){return void 0===n&&(n={}),new E(e,n)},j=function(e,n){Object.defineProperty(e,"isPreview",{get:function(){return document.documentElement.hasAttribute("data-turbolinks-preview")}}),Object.defineProperty(e,"csrfToken",{get:function(){return this.metaValue("csrf-token")}}),O(e,n),Object.assign(e,{metaValue:function(e){var n=document.head.querySelector('meta[name="'+e+'"]');return n&&n.getAttribute("content")}})},C=function(e){function n(n){var t;return(t=e.call(this,n)||this).isPreview=!1,t.csrfToken="",j(u(t),t.options),t}return s(n,e),n}(n.Controller),V={ms:6e4,initialState:!1,events:["mousemove","mousedown","resize","keydown","touchstart","wheel"],dispatchEvent:!0,eventPrefix:!0},P=function(e,n){void 0===n&&(n={});var r=Object.assign({},V,n),c=r.ms,l=r.events,s=r.dispatchEvent,u=r.eventPrefix,a=r.initialState,d=setTimeout(function(){a=!0,v()},c),v=function(n){var r=i("away",e,u);if(e.isIdle=!0,e.away&&t(e,"away").call(e,n),s){var c=o(r,n||null,{controller:e});e.element.dispatchEvent(c)}},f=function(n){var r=i("back",e,u);if(e.isIdle=!1,e.back&&t(e,"back").call(e,n),s){var c=o(r,n||null,{controller:e});e.element.dispatchEvent(c)}},b=function(e){a&&f(e),a=!1,clearTimeout(d),d=setTimeout(function(){a=!0,v(e)},c)},h=function(e){document.hidden||b(e)};a?v():f();var p=e.disconnect.bind(e),m=function(){l.forEach(function(e){window.addEventListener(e,b)}),document.addEventListener("visibilitychange",h)},g=function(){l.forEach(function(e){window.removeEventListener(e,b)}),document.removeEventListener("visibilitychange",h)};return Object.assign(e,{disconnect:function(){g(),p()}}),m(),[m,g]},x=function(e){function n(n){var t;return(t=e.call(this,n)||this).isIdle=!1,requestAnimationFrame(function(){var e=P(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}s(n,e);var t=n.prototype;return t.away=function(){},t.back=function(){},n}(n.Controller),z={dispatchEvent:!0,eventPrefix:!0},L=function(e){function n(n,r){var c;void 0===r&&(r={}),(c=e.call(this,n,r)||this).observe=function(){c.controller.isVisible=!document.hidden,document.addEventListener("visibilitychange",c.handleVisibilityChange)},c.unobserve=function(){document.removeEventListener("visibilitychange",c.handleVisibilityChange)},c.becomesInvisible=function(e){var n=i("invisible",c.controller,c.eventPrefix);c.controller.isVisible=!1,c.controller.invisible&&t(c.controller,"invisible").call(c.controller,e),c.log("invisible",{isVisible:!1}),c.dispatch(n,e)},c.becomesVisible=function(e){var n=i("visible",c.controller,c.eventPrefix);c.controller.isVisible=!0,c.controller.visible&&t(c.controller,"visible").call(c.controller,e),c.log("visible",{isVisible:!0}),c.dispatch(n,e)},c.dispatch=function(e,n){if(c.dispatchEvent){var t={controller:c.controller,isVisible:c.controller.isVisible},i=o(e,n||null,t);c.controller.element.dispatchEvent(i),c.log("dispatchEvent",l({eventName:e},t))}},c.handleVisibilityChange=function(e){document.hidden?c.becomesInvisible(e):c.becomesVisible(e)};var s=Object.assign({},z,r),a=s.dispatchEvent,d=s.eventPrefix;return Object.assign(u(c),{dispatchEvent:a,eventPrefix:d}),c.controller=n,Object.assign(n,{disconnect:function(){c.unobserve(),c.controllerDisconnect()}}),c.handleVisibilityChange(),c.observe(),c}return s(n,e),n}(w),I=function(e,n){void 0===n&&(n={});var t=new L(e,n);return[t.observe,t.unobserve]},k=function(e){function n(n){var t;return t=e.call(this,n)||this,requestAnimationFrame(function(){var e=I(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n}(n.Controller),A=function(e){var n=function(n){var i=window,o={height:i.innerHeight||Infinity,width:i.innerWidth||Infinity,event:n};e.windowResize&&t(e,"windowResize").call(e,o)},i=e.disconnect.bind(e),o=function(){window.addEventListener("resize",n),n()},r=function(){window.removeEventListener("resize",n)};return Object.assign(e,{disconnect:function(){r(),i()}}),o(),[o,r]},R=function(e){function n(n){var t;return t=e.call(this,n)||this,requestAnimationFrame(function(){var e=A(u(t)),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n.prototype.windowResize=function(e){},n}(n.Controller),q=function(e,n){void 0===n&&(n=200);var t=null;return function(){var i=arguments,o=this,r=function(){return e.apply(o,i)};clearTimeout(t),t=setTimeout(r,n)}};function T(e,n){var t;return void 0===n&&(n=200),function(){var i=arguments,o=this;t||(t=!0,e.apply(o,i),setTimeout(function(){return t=!1},n))}}function F(e){var n=document.head.querySelector('meta[name="'+e+'"]');return n&&n.getAttribute("content")}function S(e){try{return JSON.parse(e)}catch(n){return e}}function D(e){return e.replace(/(?:[_-])([a-z0-9])/g,function(e,n){return n.toUpperCase()})}e.ApplicationController=C,e.ClickOutsideController=g,e.IdleController=x,e.IntersectionController=a,e.LazyLoadController=v,e.ResizeController=h,e.UseVisibility=L,e.VisibilityController=k,e.WindowResizeController=R,e.useApplication=j,e.useClickOutside=m,e.useDebounce=function(e,n){var t;null==(t=e.constructor.debounces)||t.forEach(function(t){if("string"==typeof t&&(e[t]=q(e[t],null==n?void 0:n.wait)),"object"==typeof t){var i=t.name;if(!i)return;e[i]=q(e[i],t.wait||(null==n?void 0:n.wait))}})},e.useDispatch=O,e.useIdle=P,e.useIntersection=c,e.useLazyLoad=d,e.useMemo=function(e){var n;null==(n=e.constructor.memos)||n.forEach(function(n){!function(e,n,t){Object.defineProperty(e,n,{value:t})}(e,n,e[n])})},e.useMeta=function(e,n){void 0===n&&(n={suffix:!0});var t=e.constructor.metaNames,i=n.suffix;null==t||t.forEach(function(n){!function(e,n,t){var i=t?D(n)+"Meta":D(n);Object.defineProperty(e,i,{get:function(){return S(F(n))}})}(e,n,i)}),Object.defineProperty(e,"metas",{get:function(){var e={};return null==t||t.forEach(function(n){var t=S(F(n));null!=t&&(e[D(n)]=t)}),e}})},e.useResize=b,e.useThrottle=function(e,n){var t;null==(t=e.constructor.throttles)||t.forEach(function(t){if("string"==typeof t&&(e[t]=T(e[t],null==n?void 0:n.wait)),"object"==typeof t){var i=t.name;if(!i)return;e[i]=T(e[i],t.wait||(null==n?void 0:n.wait))}})},e.useVisibility=I,e.useWindowResize=A});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("stimulus")):"function"==typeof define&&define.amd?define(["exports","stimulus"],n):n((e=e||self).StimulusUse={},e.Stimulus)}(this,function(e,n){var t=function(e,n){var t=e[n];if("function"==typeof t)return t;throw new Error('undefined method "'+n+'"')},i=function(e,n,t){var i=e;return!0===t?i=n.identifier+":"+e:"string"==typeof t&&(i=t+":"+e),i},o=function(e,n,t){var i=n||{bubbles:!0,cancelable:!0,composed:!0},o=i.bubbles,r=i.cancelable,c=i.composed;return n&&Object.assign(t,{originalEvent:n}),new CustomEvent(e,{bubbles:o,cancelable:r,composed:c,detail:t})},r={dispatchEvent:!0,eventPrefix:!0},c=function(e,n){var c;void 0===n&&(n={});var l=Object.assign({},r,n),s=l.dispatchEvent,u=l.eventPrefix,a=(null==(c=n)?void 0:c.element)||e.element,d=e.disconnect.bind(e),v=new IntersectionObserver(function(n){var r=n[0];r.isIntersecting?function(n){if(e.isVisible=!0,e.appear&&t(e,"appear").call(e,n),s){var r=i("appear",e,u),c=o(r,null,{controller:e,entry:n});a.dispatchEvent(c)}}(r):e.isVisible&&function(n){if(e.isVisible=!1,e.disappear&&t(e,"disappear").call(e,n),s){var r=i("disappear",e,u),c=o(r,null,{controller:e,entry:n});a.dispatchEvent(c)}}(r)},n),f=function(){v.observe(a)},b=function(){v.unobserve(a)};return Object.assign(e,{isVisible:!1,disconnect:function(){b(),d()}}),f(),[f,b]};function l(){return(l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function s(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var a=function(e){function n(n){var t;return(t=e.call(this,n)||this).isVisible=!1,requestAnimationFrame(function(){var e=c(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n}(n.Controller),d=function(e,n){var i=e.disconnect.bind(e),o=new IntersectionObserver(function(n){n[0].isIntersecting&&!e.isLoaded&&function(n){var i=e.data.get("src");if(i){var o=e.element;e.isLoading=!0,e.loading&&t(e,"loading").call(e,i),o.onload=function(){!function(n){e.isLoading=!1,e.isLoaded=!0,e.loading&&t(e,"loaded").call(e,n)}(i)},o.src=i}}()},n),r=function(){o.observe(e.element)},c=function(){o.unobserve(e.element)};return Object.assign(e,{isVisible:!1,disconnect:function(){c(),i()}}),r(),[r,c]},v=function(e){function n(n){var t;return(t=e.call(this,n)||this).isLoading=!1,t.isLoaded=!1,t.options={rootMargin:"10%"},requestAnimationFrame(function(){var e=d(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}s(n,e);var t=n.prototype;return t.loading=function(e){},t.loaded=function(e){},n}(n.Controller),f={dispatchEvent:!0,eventPrefix:!0},b=function(e,n){var r;void 0===n&&(n={});var c=Object.assign({},f,n),l=c.dispatchEvent,s=c.eventPrefix,u=(null==(r=n)?void 0:r.element)||e.element,a=e.disconnect.bind(e),d=new ResizeObserver(function(n){var r=n[0];if(e.resize&&t(e,"resize").call(e,r.contentRect),l){var c=i("resize",e,s),a=o(c,null,{controller:e,entry:r});u.dispatchEvent(a)}}),v=function(){d.observe(u)},b=function(){d.unobserve(u)};return Object.assign(e,{disconnect:function(){b(),a()}}),v(),[v,b]},h=function(e){function n(n){var t;return t=e.call(this,n)||this,requestAnimationFrame(function(){var e=b(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n.prototype.resize=function(e){},n}(n.Controller),p={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},m=function(e,n){void 0===n&&(n={});var r=Object.assign({},p,n),c=r.onlyVisible,l=r.dispatchEvent,s=r.events,u=r.eventPrefix,a=function(r){var s,a,d=(null==(s=n)?void 0:s.element)||e.element;if(!d.contains(r.target)&&((a=d.getBoundingClientRect()).top>=0&&a.left>=0&&a.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&a.right<=(window.innerWidth||document.documentElement.clientWidth)||!c)&&(e.clickOutside&&t(e,"clickOutside").call(e,r),l)){var v=i("click:outside",e,u),f=o(v,r,{controller:e});d.dispatchEvent(f)}},d=function(){null==s||s.forEach(function(e){window.addEventListener(e,a,!1)})},v=function(){null==s||s.forEach(function(e){window.removeEventListener(e,a,!1)})},f=e.disconnect.bind(e);return Object.assign(e,{disconnect:function(){v(),f()}}),d(),[d,v]},g=function(e){function n(n){var t;return t=e.call(this,n)||this,requestAnimationFrame(function(){var e=m(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n.prototype.clickOutside=function(e){},n}(n.Controller),y={debug:!1,logger:console},w=function(e,n){var t,i,o=this;void 0===n&&(n={}),this.log=function(e,n){o.debug&&(o.logger.groupCollapsed("%c"+o.controller.identifier+"#%c"+e,"color: #3B82F6","color: unset"),o.logger.log(l({controllerId:o.controllerId},n)),o.logger.groupEnd())},this.debug=(null==(t=n)?void 0:t.debug)||e.application.stimulusUseDebug||y.debug,this.logger=(null==(i=n)?void 0:i.logger)||y.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)},E=function(e){function n(n,t){var o,r,c,l,s;return void 0===t&&(t={}),(s=e.call(this,n,t)||this).dispatch=function(e,n){void 0===n&&(n={});var t=u(s),o=t.targetElement,r=t.eventPrefix,c=t.bubbles,l=t.cancelable,a=t.log;Object.assign(n,{controller:t.controller});var d=i(e,s.controller,r),v=new CustomEvent(d,{detail:n,bubbles:c,cancelable:l});return o.dispatchEvent(v),a("dispatch",{eventName:d,detail:n,bubbles:c,cancelable:l}),v},s.targetElement=null!=(o=t.element)?o:n.element,s.eventPrefix=null==(r=t.eventPrefix)||r,s.bubbles=null==(c=t.bubbles)||c,s.cancelable=null==(l=t.cancelable)||l,s.enhanceController(),s}return s(n,e),n.prototype.enhanceController=function(){Object.assign(this.controller,{dispatch:this.dispatch})},n}(w),O=function(e,n){return void 0===n&&(n={}),new E(e,n)},j=function(e,n){Object.defineProperty(e,"isPreview",{get:function(){return document.documentElement.hasAttribute("data-turbolinks-preview")}}),Object.defineProperty(e,"csrfToken",{get:function(){return this.metaValue("csrf-token")}}),O(e,n),Object.assign(e,{metaValue:function(e){var n=document.head.querySelector('meta[name="'+e+'"]');return n&&n.getAttribute("content")}})},C=function(e){function n(n){var t;return(t=e.call(this,n)||this).isPreview=!1,t.csrfToken="",j(u(t),t.options),t}return s(n,e),n}(n.Controller),V={ms:6e4,initialState:!1,events:["mousemove","mousedown","resize","keydown","touchstart","wheel"],dispatchEvent:!0,eventPrefix:!0},P=function(e,n){void 0===n&&(n={});var r=Object.assign({},V,n),c=r.ms,l=r.events,s=r.dispatchEvent,u=r.eventPrefix,a=r.initialState,d=setTimeout(function(){a=!0,v()},c),v=function(n){var r=i("away",e,u);if(e.isIdle=!0,e.away&&t(e,"away").call(e,n),s){var c=o(r,n||null,{controller:e});e.element.dispatchEvent(c)}},f=function(n){var r=i("back",e,u);if(e.isIdle=!1,e.back&&t(e,"back").call(e,n),s){var c=o(r,n||null,{controller:e});e.element.dispatchEvent(c)}},b=function(e){a&&f(e),a=!1,clearTimeout(d),d=setTimeout(function(){a=!0,v(e)},c)},h=function(e){document.hidden||b(e)};a?v():f();var p=e.disconnect.bind(e),m=function(){l.forEach(function(e){window.addEventListener(e,b)}),document.addEventListener("visibilitychange",h)},g=function(){l.forEach(function(e){window.removeEventListener(e,b)}),document.removeEventListener("visibilitychange",h)};return Object.assign(e,{disconnect:function(){g(),p()}}),m(),[m,g]},x=function(e){function n(n){var t;return(t=e.call(this,n)||this).isIdle=!1,requestAnimationFrame(function(){var e=P(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}s(n,e);var t=n.prototype;return t.away=function(){},t.back=function(){},n}(n.Controller),z={dispatchEvent:!0,eventPrefix:!0},L=function(e){function n(n,r){var c;void 0===r&&(r={}),(c=e.call(this,n,r)||this).observe=function(){c.controller.isVisible=!document.hidden,document.addEventListener("visibilitychange",c.handleVisibilityChange)},c.unobserve=function(){document.removeEventListener("visibilitychange",c.handleVisibilityChange)},c.becomesInvisible=function(e){var n=i("invisible",c.controller,c.eventPrefix);c.controller.isVisible=!1,c.controller.invisible&&t(c.controller,"invisible").call(c.controller,e),c.log("invisible",{isVisible:!1}),c.dispatch(n,e)},c.becomesVisible=function(e){var n=i("visible",c.controller,c.eventPrefix);c.controller.isVisible=!0,c.controller.visible&&t(c.controller,"visible").call(c.controller,e),c.log("visible",{isVisible:!0}),c.dispatch(n,e)},c.dispatch=function(e,n){if(c.dispatchEvent){var t={controller:c.controller,isVisible:c.controller.isVisible},i=o(e,n||null,t);c.controller.element.dispatchEvent(i),c.log("dispatchEvent",l({eventName:e},t))}},c.handleVisibilityChange=function(e){document.hidden?c.becomesInvisible(e):c.becomesVisible(e)};var s=Object.assign({},z,r),a=s.dispatchEvent,d=s.eventPrefix;return Object.assign(u(c),{dispatchEvent:a,eventPrefix:d}),c.controller=n,Object.assign(n,{disconnect:function(){c.unobserve(),c.controllerDisconnect()}}),c.handleVisibilityChange(),c.observe(),c}return s(n,e),n}(w),I=function(e,n){void 0===n&&(n={});var t=new L(e,n);return[t.observe,t.unobserve]},k=function(e){function n(n){var t;return t=e.call(this,n)||this,requestAnimationFrame(function(){var e=I(u(t),t.options),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n}(n.Controller),A=function(e){var n=function(n){var i=window,o={height:i.innerHeight||Infinity,width:i.innerWidth||Infinity,event:n};e.windowResize&&t(e,"windowResize").call(e,o)},i=e.disconnect.bind(e),o=function(){window.addEventListener("resize",n),n()},r=function(){window.removeEventListener("resize",n)};return Object.assign(e,{disconnect:function(){r(),i()}}),o(),[o,r]},R=function(e){function n(n){var t;return t=e.call(this,n)||this,requestAnimationFrame(function(){var e=A(u(t)),n=e[0],i=e[1];Object.assign(u(t),{observe:n,unobserve:i})}),t}return s(n,e),n.prototype.windowResize=function(e){},n}(n.Controller),q=function(e,n){void 0===n&&(n=200);var t=null;return function(){var i=arguments,o=this,r=function(){return e.apply(o,i)};clearTimeout(t),t=setTimeout(r,n)}};function T(e,n){var t;return void 0===n&&(n=200),function(){var i=arguments,o=this;t||(t=!0,e.apply(o,i),setTimeout(function(){return t=!1},n))}}function F(e){var n=document.head.querySelector('meta[name="'+e+'"]');return n&&n.getAttribute("content")}function S(e){try{return JSON.parse(e)}catch(n){return e}}function D(e){return e.replace(/(?:[_-])([a-z0-9])/g,function(e,n){return n.toUpperCase()})}e.ApplicationController=C,e.ClickOutsideController=g,e.IdleController=x,e.IntersectionController=a,e.LazyLoadController=v,e.ResizeController=h,e.UseVisibility=L,e.VisibilityController=k,e.WindowResizeController=R,e.useApplication=j,e.useClickOutside=m,e.useDebounce=function(e,n){var t;null==(t=e.constructor.debounces)||t.forEach(function(t){if("string"==typeof t&&(e[t]=q(e[t],null==n?void 0:n.wait)),"object"==typeof t){var i=t.name;if(!i)return;e[i]=q(e[i],t.wait||(null==n?void 0:n.wait))}})},e.useDispatch=O,e.useIdle=P,e.useIntersection=c,e.useLazyLoad=d,e.useMemo=function(e){var n;null==(n=e.constructor.memos)||n.forEach(function(n){!function(e,n,t){Object.defineProperty(e,n,{value:t})}(e,n,e[n])})},e.useMeta=function(e,n){void 0===n&&(n={suffix:!0});var t=e.constructor.metaNames,i=n.suffix;null==t||t.forEach(function(n){!function(e,n,t){var i=t?D(n)+"Meta":D(n);Object.defineProperty(e,i,{get:function(){return S(F(n))}})}(e,n,i)}),Object.defineProperty(e,"metas",{get:function(){var e={};return null==t||t.forEach(function(n){var t=S(F(n));null!=t&&(e[D(n)]=t)}),e}})},e.useResize=b,e.useThrottle=function(e,n){var t;null==(t=e.constructor.throttles)||t.forEach(function(t){if("string"==typeof t&&(e[t]=T(e[t],null==n?void 0:n.wait)),"object"==typeof t){var i=t.name;if(!i)return;e[i]=T(e[i],t.wait||(null==n?void 0:n.wait))}})},e.useVisibility=I,e.useWindowResize=A});
//# sourceMappingURL=index.umd.js.map

@@ -10,2 +10,3 @@ import { composeEventName } from '../support/index';

constructor(controller, options = {}) {
var _a, _b, _c, _d;
super(controller, options);

@@ -28,6 +29,6 @@ this.dispatch = (eventName, detail = {}) => {

};
this.targetElement = (options === null || options === void 0 ? void 0 : options.element) || controller.element;
this.eventPrefix = (options === null || options === void 0 ? void 0 : options.eventPrefix) || defaultOptions.eventPrefix;
this.bubbles = (options === null || options === void 0 ? void 0 : options.bubbles) || defaultOptions.bubbles;
this.cancelable = (options === null || options === void 0 ? void 0 : options.cancelable) || defaultOptions.cancelable;
this.targetElement = (_a = options.element) !== null && _a !== void 0 ? _a : controller.element;
this.eventPrefix = (_b = options.eventPrefix) !== null && _b !== void 0 ? _b : defaultOptions.eventPrefix;
this.bubbles = (_c = options.bubbles) !== null && _c !== void 0 ? _c : defaultOptions.bubbles;
this.cancelable = (_d = options.cancelable) !== null && _d !== void 0 ? _d : defaultOptions.cancelable;
this.enhanceController();

@@ -34,0 +35,0 @@ }

{
"name": "stimulus-use",
"version": "0.21.3",
"version": "0.21.4",
"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

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