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

@fremtind/jkl-react-hooks

Package Overview
Dependencies
Maintainers
2
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fremtind/jkl-react-hooks - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

8

build/browser/index.js

@@ -81,2 +81,10 @@ import React, { useState, useEffect, useRef, useCallback, useLayoutEffect, useReducer } from 'react';

} else {
// If the scrollHeight is 0 it means that we are transitioning from height 0 -> 0.
// This causes the "transitionend"-event to never fire and the element gets stuck with
// style: height: 0; display: block; overflow:hidden
if (element.scrollHeight === 0) {
element.removeAttribute("style");
return;
}
element.style.height = "".concat(element.scrollHeight, "px");

@@ -83,0 +91,0 @@ raf1.current = requestAnimationFrame(function () {

2

build/browser/index.min.js

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

import e,{useState as n,useEffect as t,useRef as r,useCallback as i,useLayoutEffect as o,useReducer as c}from"react";import u from"@babel/runtime/helpers/slicedToArray";import f from"@babel/runtime/helpers/defineProperty";import{breakpoints as d}from"@fremtind/jkl-core";var s=function(){var e=n(!("undefined"==typeof window||!window.matchMedia||window.matchMedia("(prefers-reduced-motion: no-preference)").matches)),r=u(e,2),i=r[0],o=r[1];return t((function(){var e,n,t;"undefined"!=typeof window&&window.matchMedia&&(e=window.matchMedia("(prefers-reduced-motion: no-preference)"),n=function(e){return o(!e.matches)},null===(t=e)||void 0===t||t.addListener(n));return function(){var t;null===(t=e)||void 0===t||t.removeListener(n)}}),[]),i};function a(e){var n=r(),c=r(),u=r(null),f=r(!0),d=s();function a(){var e=l(u);e&&e.removeAttribute("style")}var v=i((function(){if(!d&&!f.current){var t=l(u);t&&(t.style.display="block",t.style.overflow="hidden",e?(t.style.height="0",t.style.height="".concat(t.scrollHeight,"px")):(t.style.height="".concat(t.scrollHeight,"px"),n.current=requestAnimationFrame((function(){c.current=requestAnimationFrame((function(){t.style.height="".concat(0,"px")}))}))))}}),[e]);return o((function(){v()}),[e,v]),t((function(){var e=l(u);return e&&e.addEventListener("transitionend",a),function(){e&&e.removeEventListener("transitionend",a)}}),[e]),t((function(){var e=n.current,t=c.current;return f.current=!1,function(){e&&cancelAnimationFrame(e),t&&cancelAnimationFrame(t)}}),[n,c]),[u,v]}function l(e){return e.current&&(e.current.el||e.current)}function v(n,t){function r(e){n&&n.current&&!n.current.contains(e.target)&&t()}e.useEffect((function(){return n&&document&&document.addEventListener("click",r),function(){n&&document&&document.removeEventListener("click",r)}}))}function m(n,t){function r(e){n&&n.current&&!n.current.contains(e.target)&&t()}e.useEffect((function(){return n&&document&&document.addEventListener("focusin",r),function(){n&&document&&document.removeEventListener("focusin",r)}}))}function p(e,n,r){function i(e){n&&!n.includes(e.key)||r(e)}"string"==typeof n&&(n=[n]),t((function(){var n=e&&e.current;return n&&n.addEventListener("keydown",i),function(){n&&n.removeEventListener("keydown",i)}}))}var w,y=function(){return"undefined"!=typeof window&&"undefined"!=typeof MutationObserver},h=function(e,n,i){var o=r(null);t((function(){var t=o.current;if(y()){var r=e.current;t&&t.disconnect(),t=new MutationObserver(n),r&&t.observe(r,i)}return function(){y()&&t&&t.disconnect()}}),[e,n,i])},b=function(){return"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver},O=function(e,n,i,o){var c=r(null);t((function(){var t=c.current;if(b()){var r=e.current;t&&t.disconnect(),t=new IntersectionObserver(n,o),r&&t.observe(r)}else i();return function(){b()&&t&&t.disconnect()}}),[e,n,i,o])};function g(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function j(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?g(Object(t),!0).forEach((function(n){f(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):g(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}!function(e){e.resized="WINDOW_RESIZED"}(w||(w={}));var P={resized:w.resized},D=function(e,n){return{isSmallDevice:e<d.small,isMediumDevice:e>d.small&&e<d.medium,isLargeDevice:e>d.medium&&e<d.large,isXlDevice:e>d.large,isPortrait:n>=e,isLandscape:n<e,inner:{height:n,width:e}}},E={isSmallDevice:!1,isMediumDevice:!1,isLargeDevice:!1,isXlDevice:!1,isLandscape:!1,isPortrait:!1,inner:{height:0,width:0}},L=function(){var e="undefined"!=typeof window?window.innerWidth:0,n="undefined"!=typeof window?window.innerHeight:0;return D(e,n)},S=function(e,n){var t=n.type,r=n.width,i=n.height;switch(t){case P.resized:return j(j({},e),D(r,i))}};function k(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}var M=function(){var e=c(S,E,L),n=u(e,2),r=n[0],i=n[1],o=function(){return requestAnimationFrame((function(){return i({type:P.resized,width:window.innerWidth,height:window.innerHeight})}))};return t((function(){return"undefined"!=typeof window&&window.addEventListener("resize",o),function(){"undefined"!=typeof window&&window.removeEventListener("resize",o)}}),[]),function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?k(Object(t),!0).forEach((function(n){f(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):k(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},r)},z=function(e){var n=e.ref,r=e.timeout,i=void 0===r?0:r,o=e.autoScroll,c=void 0===o||o,u=e.options,f=void 0===u?{behavior:"smooth"}:u,d=function(){n&&n.current&&n.current.scrollIntoView(f)};return t((function(){if(c){var e=setTimeout(d,i);return function(){return clearTimeout(e)}}}),[n,i,c]),[d]};export{E as initialScreenState,a as useAnimatedHeight,v as useClickOutside,m as useFocusOutside,O as useIntersectionObserver,p as useKeyListener,h as useMutationObserver,s as useReducedMotion,M as useScreen,z as useScrollIntoView};
import e,{useState as n,useEffect as t,useRef as r,useCallback as i,useLayoutEffect as o,useReducer as c}from"react";import u from"@babel/runtime/helpers/slicedToArray";import f from"@babel/runtime/helpers/defineProperty";import{breakpoints as s}from"@fremtind/jkl-core";var d=function(){var e=n(!("undefined"==typeof window||!window.matchMedia||window.matchMedia("(prefers-reduced-motion: no-preference)").matches)),r=u(e,2),i=r[0],o=r[1];return t((function(){var e,n,t;"undefined"!=typeof window&&window.matchMedia&&(e=window.matchMedia("(prefers-reduced-motion: no-preference)"),n=function(e){return o(!e.matches)},null===(t=e)||void 0===t||t.addListener(n));return function(){var t;null===(t=e)||void 0===t||t.removeListener(n)}}),[]),i};function a(e){var n=r(),c=r(),u=r(null),f=r(!0),s=d();function a(){var e=l(u);e&&e.removeAttribute("style")}var v=i((function(){if(!s&&!f.current){var t=l(u);if(t)if(t.style.display="block",t.style.overflow="hidden",e)t.style.height="0",t.style.height="".concat(t.scrollHeight,"px");else{if(0===t.scrollHeight)return void t.removeAttribute("style");t.style.height="".concat(t.scrollHeight,"px"),n.current=requestAnimationFrame((function(){c.current=requestAnimationFrame((function(){t.style.height="".concat(0,"px")}))}))}}}),[e]);return o((function(){v()}),[e,v]),t((function(){var e=l(u);return e&&e.addEventListener("transitionend",a),function(){e&&e.removeEventListener("transitionend",a)}}),[e]),t((function(){var e=n.current,t=c.current;return f.current=!1,function(){e&&cancelAnimationFrame(e),t&&cancelAnimationFrame(t)}}),[n,c]),[u,v]}function l(e){return e.current&&(e.current.el||e.current)}function v(n,t){function r(e){n&&n.current&&!n.current.contains(e.target)&&t()}e.useEffect((function(){return n&&document&&document.addEventListener("click",r),function(){n&&document&&document.removeEventListener("click",r)}}))}function m(n,t){function r(e){n&&n.current&&!n.current.contains(e.target)&&t()}e.useEffect((function(){return n&&document&&document.addEventListener("focusin",r),function(){n&&document&&document.removeEventListener("focusin",r)}}))}function p(e,n,r){function i(e){n&&!n.includes(e.key)||r(e)}"string"==typeof n&&(n=[n]),t((function(){var n=e&&e.current;return n&&n.addEventListener("keydown",i),function(){n&&n.removeEventListener("keydown",i)}}))}var w,y=function(){return"undefined"!=typeof window&&"undefined"!=typeof MutationObserver},h=function(e,n,i){var o=r(null);t((function(){var t=o.current;if(y()){var r=e.current;t&&t.disconnect(),t=new MutationObserver(n),r&&t.observe(r,i)}return function(){y()&&t&&t.disconnect()}}),[e,n,i])},b=function(){return"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver},O=function(e,n,i,o){var c=r(null);t((function(){var t=c.current;if(b()){var r=e.current;t&&t.disconnect(),t=new IntersectionObserver(n,o),r&&t.observe(r)}else i();return function(){b()&&t&&t.disconnect()}}),[e,n,i,o])};function g(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function j(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?g(Object(t),!0).forEach((function(n){f(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):g(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}!function(e){e.resized="WINDOW_RESIZED"}(w||(w={}));var P={resized:w.resized},D=function(e,n){return{isSmallDevice:e<s.small,isMediumDevice:e>s.small&&e<s.medium,isLargeDevice:e>s.medium&&e<s.large,isXlDevice:e>s.large,isPortrait:n>=e,isLandscape:n<e,inner:{height:n,width:e}}},E={isSmallDevice:!1,isMediumDevice:!1,isLargeDevice:!1,isXlDevice:!1,isLandscape:!1,isPortrait:!1,inner:{height:0,width:0}},L=function(){var e="undefined"!=typeof window?window.innerWidth:0,n="undefined"!=typeof window?window.innerHeight:0;return D(e,n)},S=function(e,n){var t=n.type,r=n.width,i=n.height;switch(t){case P.resized:return j(j({},e),D(r,i))}};function k(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}var A=function(){var e=c(S,E,L),n=u(e,2),r=n[0],i=n[1],o=function(){return requestAnimationFrame((function(){return i({type:P.resized,width:window.innerWidth,height:window.innerHeight})}))};return t((function(){return"undefined"!=typeof window&&window.addEventListener("resize",o),function(){"undefined"!=typeof window&&window.removeEventListener("resize",o)}}),[]),function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?k(Object(t),!0).forEach((function(n){f(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):k(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},r)},M=function(e){var n=e.ref,r=e.timeout,i=void 0===r?0:r,o=e.autoScroll,c=void 0===o||o,u=e.options,f=void 0===u?{behavior:"smooth"}:u,s=function(){n&&n.current&&n.current.scrollIntoView(f)};return t((function(){if(c){var e=setTimeout(s,i);return function(){return clearTimeout(e)}}}),[n,i,c]),[s]};export{E as initialScreenState,a as useAnimatedHeight,v as useClickOutside,m as useFocusOutside,O as useIntersectionObserver,p as useKeyListener,h as useMutationObserver,d as useReducedMotion,A as useScreen,M as useScrollIntoView};

@@ -88,2 +88,10 @@ 'use strict';

} else {
// If the scrollHeight is 0 it means that we are transitioning from height 0 -> 0.
// This causes the "transitionend"-event to never fire and the element gets stuck with
// style: height: 0; display: block; overflow:hidden
if (element.scrollHeight === 0) {
element.removeAttribute("style");
return;
}
element.style.height = "".concat(element.scrollHeight, "px");

@@ -90,0 +98,0 @@ raf1.current = requestAnimationFrame(function () {

@@ -81,2 +81,10 @@ import React, { useState, useEffect, useRef, useCallback, useLayoutEffect, useReducer } from 'react';

} else {
// If the scrollHeight is 0 it means that we are transitioning from height 0 -> 0.
// This causes the "transitionend"-event to never fire and the element gets stuck with
// style: height: 0; display: block; overflow:hidden
if (element.scrollHeight === 0) {
element.removeAttribute("style");
return;
}
element.style.height = "".concat(element.scrollHeight, "px");

@@ -83,0 +91,0 @@ raf1.current = requestAnimationFrame(function () {

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

import e,{useState as n,useEffect as t,useRef as r,useCallback as i,useLayoutEffect as o,useReducer as c}from"react";import u from"@babel/runtime/helpers/slicedToArray";import f from"@babel/runtime/helpers/defineProperty";import{breakpoints as d}from"@fremtind/jkl-core";var s=function(){var e=n(!("undefined"==typeof window||!window.matchMedia||window.matchMedia("(prefers-reduced-motion: no-preference)").matches)),r=u(e,2),i=r[0],o=r[1];return t((function(){var e,n,t;"undefined"!=typeof window&&window.matchMedia&&(e=window.matchMedia("(prefers-reduced-motion: no-preference)"),n=function(e){return o(!e.matches)},null===(t=e)||void 0===t||t.addListener(n));return function(){var t;null===(t=e)||void 0===t||t.removeListener(n)}}),[]),i};function a(e){var n=r(),c=r(),u=r(null),f=r(!0),d=s();function a(){var e=l(u);e&&e.removeAttribute("style")}var v=i((function(){if(!d&&!f.current){var t=l(u);t&&(t.style.display="block",t.style.overflow="hidden",e?(t.style.height="0",t.style.height="".concat(t.scrollHeight,"px")):(t.style.height="".concat(t.scrollHeight,"px"),n.current=requestAnimationFrame((function(){c.current=requestAnimationFrame((function(){t.style.height="".concat(0,"px")}))}))))}}),[e]);return o((function(){v()}),[e,v]),t((function(){var e=l(u);return e&&e.addEventListener("transitionend",a),function(){e&&e.removeEventListener("transitionend",a)}}),[e]),t((function(){var e=n.current,t=c.current;return f.current=!1,function(){e&&cancelAnimationFrame(e),t&&cancelAnimationFrame(t)}}),[n,c]),[u,v]}function l(e){return e.current&&(e.current.el||e.current)}function v(n,t){function r(e){n&&n.current&&!n.current.contains(e.target)&&t()}e.useEffect((function(){return n&&document&&document.addEventListener("click",r),function(){n&&document&&document.removeEventListener("click",r)}}))}function m(n,t){function r(e){n&&n.current&&!n.current.contains(e.target)&&t()}e.useEffect((function(){return n&&document&&document.addEventListener("focusin",r),function(){n&&document&&document.removeEventListener("focusin",r)}}))}function p(e,n,r){function i(e){n&&!n.includes(e.key)||r(e)}"string"==typeof n&&(n=[n]),t((function(){var n=e&&e.current;return n&&n.addEventListener("keydown",i),function(){n&&n.removeEventListener("keydown",i)}}))}var w,y=function(){return"undefined"!=typeof window&&"undefined"!=typeof MutationObserver},h=function(e,n,i){var o=r(null);t((function(){var t=o.current;if(y()){var r=e.current;t&&t.disconnect(),t=new MutationObserver(n),r&&t.observe(r,i)}return function(){y()&&t&&t.disconnect()}}),[e,n,i])},b=function(){return"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver},O=function(e,n,i,o){var c=r(null);t((function(){var t=c.current;if(b()){var r=e.current;t&&t.disconnect(),t=new IntersectionObserver(n,o),r&&t.observe(r)}else i();return function(){b()&&t&&t.disconnect()}}),[e,n,i,o])};function g(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function j(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?g(Object(t),!0).forEach((function(n){f(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):g(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}!function(e){e.resized="WINDOW_RESIZED"}(w||(w={}));var P={resized:w.resized},D=function(e,n){return{isSmallDevice:e<d.small,isMediumDevice:e>d.small&&e<d.medium,isLargeDevice:e>d.medium&&e<d.large,isXlDevice:e>d.large,isPortrait:n>=e,isLandscape:n<e,inner:{height:n,width:e}}},E={isSmallDevice:!1,isMediumDevice:!1,isLargeDevice:!1,isXlDevice:!1,isLandscape:!1,isPortrait:!1,inner:{height:0,width:0}},L=function(){var e="undefined"!=typeof window?window.innerWidth:0,n="undefined"!=typeof window?window.innerHeight:0;return D(e,n)},S=function(e,n){var t=n.type,r=n.width,i=n.height;switch(t){case P.resized:return j(j({},e),D(r,i))}};function k(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}var M=function(){var e=c(S,E,L),n=u(e,2),r=n[0],i=n[1],o=function(){return requestAnimationFrame((function(){return i({type:P.resized,width:window.innerWidth,height:window.innerHeight})}))};return t((function(){return"undefined"!=typeof window&&window.addEventListener("resize",o),function(){"undefined"!=typeof window&&window.removeEventListener("resize",o)}}),[]),function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?k(Object(t),!0).forEach((function(n){f(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):k(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},r)},z=function(e){var n=e.ref,r=e.timeout,i=void 0===r?0:r,o=e.autoScroll,c=void 0===o||o,u=e.options,f=void 0===u?{behavior:"smooth"}:u,d=function(){n&&n.current&&n.current.scrollIntoView(f)};return t((function(){if(c){var e=setTimeout(d,i);return function(){return clearTimeout(e)}}}),[n,i,c]),[d]};export{E as initialScreenState,a as useAnimatedHeight,v as useClickOutside,m as useFocusOutside,O as useIntersectionObserver,p as useKeyListener,h as useMutationObserver,s as useReducedMotion,M as useScreen,z as useScrollIntoView};
import e,{useState as n,useEffect as t,useRef as r,useCallback as i,useLayoutEffect as o,useReducer as c}from"react";import u from"@babel/runtime/helpers/slicedToArray";import f from"@babel/runtime/helpers/defineProperty";import{breakpoints as s}from"@fremtind/jkl-core";var d=function(){var e=n(!("undefined"==typeof window||!window.matchMedia||window.matchMedia("(prefers-reduced-motion: no-preference)").matches)),r=u(e,2),i=r[0],o=r[1];return t((function(){var e,n,t;"undefined"!=typeof window&&window.matchMedia&&(e=window.matchMedia("(prefers-reduced-motion: no-preference)"),n=function(e){return o(!e.matches)},null===(t=e)||void 0===t||t.addListener(n));return function(){var t;null===(t=e)||void 0===t||t.removeListener(n)}}),[]),i};function a(e){var n=r(),c=r(),u=r(null),f=r(!0),s=d();function a(){var e=l(u);e&&e.removeAttribute("style")}var v=i((function(){if(!s&&!f.current){var t=l(u);if(t)if(t.style.display="block",t.style.overflow="hidden",e)t.style.height="0",t.style.height="".concat(t.scrollHeight,"px");else{if(0===t.scrollHeight)return void t.removeAttribute("style");t.style.height="".concat(t.scrollHeight,"px"),n.current=requestAnimationFrame((function(){c.current=requestAnimationFrame((function(){t.style.height="".concat(0,"px")}))}))}}}),[e]);return o((function(){v()}),[e,v]),t((function(){var e=l(u);return e&&e.addEventListener("transitionend",a),function(){e&&e.removeEventListener("transitionend",a)}}),[e]),t((function(){var e=n.current,t=c.current;return f.current=!1,function(){e&&cancelAnimationFrame(e),t&&cancelAnimationFrame(t)}}),[n,c]),[u,v]}function l(e){return e.current&&(e.current.el||e.current)}function v(n,t){function r(e){n&&n.current&&!n.current.contains(e.target)&&t()}e.useEffect((function(){return n&&document&&document.addEventListener("click",r),function(){n&&document&&document.removeEventListener("click",r)}}))}function m(n,t){function r(e){n&&n.current&&!n.current.contains(e.target)&&t()}e.useEffect((function(){return n&&document&&document.addEventListener("focusin",r),function(){n&&document&&document.removeEventListener("focusin",r)}}))}function p(e,n,r){function i(e){n&&!n.includes(e.key)||r(e)}"string"==typeof n&&(n=[n]),t((function(){var n=e&&e.current;return n&&n.addEventListener("keydown",i),function(){n&&n.removeEventListener("keydown",i)}}))}var w,y=function(){return"undefined"!=typeof window&&"undefined"!=typeof MutationObserver},h=function(e,n,i){var o=r(null);t((function(){var t=o.current;if(y()){var r=e.current;t&&t.disconnect(),t=new MutationObserver(n),r&&t.observe(r,i)}return function(){y()&&t&&t.disconnect()}}),[e,n,i])},b=function(){return"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver},O=function(e,n,i,o){var c=r(null);t((function(){var t=c.current;if(b()){var r=e.current;t&&t.disconnect(),t=new IntersectionObserver(n,o),r&&t.observe(r)}else i();return function(){b()&&t&&t.disconnect()}}),[e,n,i,o])};function g(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function j(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?g(Object(t),!0).forEach((function(n){f(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):g(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}!function(e){e.resized="WINDOW_RESIZED"}(w||(w={}));var P={resized:w.resized},D=function(e,n){return{isSmallDevice:e<s.small,isMediumDevice:e>s.small&&e<s.medium,isLargeDevice:e>s.medium&&e<s.large,isXlDevice:e>s.large,isPortrait:n>=e,isLandscape:n<e,inner:{height:n,width:e}}},E={isSmallDevice:!1,isMediumDevice:!1,isLargeDevice:!1,isXlDevice:!1,isLandscape:!1,isPortrait:!1,inner:{height:0,width:0}},L=function(){var e="undefined"!=typeof window?window.innerWidth:0,n="undefined"!=typeof window?window.innerHeight:0;return D(e,n)},S=function(e,n){var t=n.type,r=n.width,i=n.height;switch(t){case P.resized:return j(j({},e),D(r,i))}};function k(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}var A=function(){var e=c(S,E,L),n=u(e,2),r=n[0],i=n[1],o=function(){return requestAnimationFrame((function(){return i({type:P.resized,width:window.innerWidth,height:window.innerHeight})}))};return t((function(){return"undefined"!=typeof window&&window.addEventListener("resize",o),function(){"undefined"!=typeof window&&window.removeEventListener("resize",o)}}),[]),function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?k(Object(t),!0).forEach((function(n){f(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):k(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},r)},M=function(e){var n=e.ref,r=e.timeout,i=void 0===r?0:r,o=e.autoScroll,c=void 0===o||o,u=e.options,f=void 0===u?{behavior:"smooth"}:u,s=function(){n&&n.current&&n.current.scrollIntoView(f)};return t((function(){if(c){var e=setTimeout(s,i);return function(){return clearTimeout(e)}}}),[n,i,c]),[s]};export{E as initialScreenState,a as useAnimatedHeight,v as useClickOutside,m as useFocusOutside,O as useIntersectionObserver,p as useKeyListener,h as useMutationObserver,d as useReducedMotion,A as useScreen,M as useScrollIntoView};

@@ -6,2 +6,13 @@ # Change Log

## 1.6.0 (2020-08-13)
### Bug Fixes
- **use-anitmated-height:** fix bug when transitioning element with height 0 ([4231345](https://github.com/fremtind/jokul/commit/42313457a9eee18f4aa06a3096506dd8b15e3f56))
- handle reduced motion in animation ([86b5509](https://github.com/fremtind/jokul/commit/86b55093413c5a1c5afcbe81a4d43e31f194a7ca)), closes [#1121](https://github.com/fremtind/jokul/issues/1121)
### Features
- **hook:** add prefer reduced motion hook ([aec7494](https://github.com/fremtind/jokul/commit/aec7494ea94363bc4941212b4d37fe8e1ac66b7a)), closes [#1067](https://github.com/fremtind/jokul/issues/1067)
## 1.5.0 (2020-08-11)

@@ -8,0 +19,0 @@

{
"name": "@fremtind/jkl-react-hooks",
"version": "1.5.1",
"version": "1.6.0",
"publishConfig": {

@@ -56,3 +56,3 @@ "access": "public"

},
"gitHead": "0b2f0cd078d122cd01e67dc5ddbf3970b4d4580d"
"gitHead": "1136a75116550025d8c46a52461d5918af6e967f"
}
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