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

@fremtind/jkl-react-hooks

Package Overview
Dependencies
Maintainers
2
Versions
212
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.1.12 to 1.2.0

build/useScrollIntoView/useScrollIntoView.d.ts

32

build/browser/index.js

@@ -400,2 +400,32 @@ import React, { useRef, useCallback, useLayoutEffect, useEffect, useReducer } from 'react';

export { initialState as initialScreenState, useAnimatedHeight, useClickOutside, useFocusOutside, useIntersectionObserver, useKeyListener, useMutationObserver, useScreen };
var useScrollIntoView = function useScrollIntoView(_ref) {
var ref = _ref.ref,
_ref$timeout = _ref.timeout,
timeout = _ref$timeout === void 0 ? 0 : _ref$timeout,
_ref$autoScroll = _ref.autoScroll,
autoScroll = _ref$autoScroll === void 0 ? true : _ref$autoScroll,
_ref$options = _ref.options,
options = _ref$options === void 0 ? {
behavior: "smooth"
} : _ref$options;
var scrollIntoView = function scrollIntoView() {
if (ref && ref.current) {
ref.current.scrollIntoView(options);
}
};
useEffect(function () {
if (!autoScroll) {
return;
}
var scrollFn = setTimeout(scrollIntoView, timeout);
return function () {
return clearTimeout(scrollFn);
};
}, [ref, timeout, autoScroll]);
return [scrollIntoView];
};
export { initialState as initialScreenState, useAnimatedHeight, useClickOutside, useFocusOutside, useIntersectionObserver, useKeyListener, useMutationObserver, useScreen, useScrollIntoView };

2

build/browser/index.min.js

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

import e,{useRef as n,useCallback as t,useLayoutEffect as r,useEffect as i,useReducer as o}from"react";import{breakpoints as c}from"@fremtind/jkl-core";function u(e){var o=n(),c=n(),u=n(null),f=n(!0);function s(){var e=a(u);e&&e.removeAttribute("style")}var d=t((function(){if(!f.current){var n=a(u);n&&(n.style.display="block",n.style.overflow="hidden",e?(n.style.height="0",n.style.height="".concat(n.scrollHeight,"px")):(n.style.height="".concat(n.scrollHeight,"px"),o.current=requestAnimationFrame((function(){c.current=requestAnimationFrame((function(){n.style.height="".concat(0,"px")}))}))))}}),[e]);return r((function(){d()}),[e,d]),i((function(){var e=a(u);return e&&e.addEventListener("transitionend",s),function(){e&&e.removeEventListener("transitionend",s)}}),[e]),i((function(){var e=o.current,n=c.current;return f.current=!1,function(){e&&cancelAnimationFrame(e),n&&cancelAnimationFrame(n)}}),[o,c]),[u,d]}function a(e){return e.current&&(e.current.el||e.current)}function f(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 s(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 d(e,n,t){function r(e){n&&!n.includes(e.key)||t(e)}"string"==typeof n&&(n=[n]),i((function(){var n=e&&e.current;return n&&n.addEventListener("keydown",r),function(){n&&n.removeEventListener("keydown",r)}}))}var l,v=function(){return"undefined"!=typeof window&&"undefined"!=typeof MutationObserver},m=function(e,t,r){var o=n(null);i((function(){var n=o.current;if(v()){var i=e.current;n&&n.disconnect(),n=new MutationObserver(t),i&&n.observe(i,r)}return function(){v()&&n&&n.disconnect()}}),[e,t,r])},y=function(){return"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver},p=function(e,t,r,o){var c=n(null);i((function(){var n=c.current;if(y()){var i=e.current;n&&n.disconnect(),n=new IntersectionObserver(t,o),i&&n.observe(i)}else r();return function(){y()&&n&&n.disconnect()}}),[e,t,r,o])};function w(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function h(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 b(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?h(Object(t),!0).forEach((function(n){w(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function g(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,i=!1,o=void 0;try{for(var c,u=e[Symbol.iterator]();!(r=(c=u.next()).done)&&(t.push(c.value),!n||t.length!==n);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(i)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return O(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}!function(e){e.resized="WINDOW_RESIZED"}(l||(l={}));var j={resized:l.resized},E=function(e,n){return{isSmallDevice:e<c.small,isMediumDevice:e>c.small&&e<c.medium,isLargeDevice:e>c.medium&&e<c.large,isXlDevice:e>c.large,isPortrait:n>=e,isLandscape:n<e,inner:{height:n,width:e}}},D={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 E(e,n)},S=function(e,n){var t=n.type,r=n.width,i=n.height;switch(t){case j.resized:return b(b({},e),E(r,i))}},A=function(){var e=g(o(S,D,L),2),n=e[0],t=e[1],r=function(){return requestAnimationFrame((function(){return t({type:j.resized,width:window.innerWidth,height:window.innerHeight})}))};return i((function(){return"undefined"!=typeof window&&window.addEventListener("resize",r),function(){"undefined"!=typeof window&&window.removeEventListener("resize",r)}}),[]),b({},n)};export{D as initialScreenState,u as useAnimatedHeight,f as useClickOutside,s as useFocusOutside,p as useIntersectionObserver,d as useKeyListener,m as useMutationObserver,A as useScreen};
import e,{useRef as n,useCallback as t,useLayoutEffect as r,useEffect as i,useReducer as o}from"react";import{breakpoints as c}from"@fremtind/jkl-core";function u(e){var o=n(),c=n(),u=n(null),f=n(!0);function s(){var e=a(u);e&&e.removeAttribute("style")}var d=t((function(){if(!f.current){var n=a(u);n&&(n.style.display="block",n.style.overflow="hidden",e?(n.style.height="0",n.style.height="".concat(n.scrollHeight,"px")):(n.style.height="".concat(n.scrollHeight,"px"),o.current=requestAnimationFrame((function(){c.current=requestAnimationFrame((function(){n.style.height="".concat(0,"px")}))}))))}}),[e]);return r((function(){d()}),[e,d]),i((function(){var e=a(u);return e&&e.addEventListener("transitionend",s),function(){e&&e.removeEventListener("transitionend",s)}}),[e]),i((function(){var e=o.current,n=c.current;return f.current=!1,function(){e&&cancelAnimationFrame(e),n&&cancelAnimationFrame(n)}}),[o,c]),[u,d]}function a(e){return e.current&&(e.current.el||e.current)}function f(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 s(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 d(e,n,t){function r(e){n&&!n.includes(e.key)||t(e)}"string"==typeof n&&(n=[n]),i((function(){var n=e&&e.current;return n&&n.addEventListener("keydown",r),function(){n&&n.removeEventListener("keydown",r)}}))}var l,v=function(){return"undefined"!=typeof window&&"undefined"!=typeof MutationObserver},m=function(e,t,r){var o=n(null);i((function(){var n=o.current;if(v()){var i=e.current;n&&n.disconnect(),n=new MutationObserver(t),i&&n.observe(i,r)}return function(){v()&&n&&n.disconnect()}}),[e,t,r])},y=function(){return"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver},p=function(e,t,r,o){var c=n(null);i((function(){var n=c.current;if(y()){var i=e.current;n&&n.disconnect(),n=new IntersectionObserver(t,o),i&&n.observe(i)}else r();return function(){y()&&n&&n.disconnect()}}),[e,t,r,o])};function w(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function h(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 b(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?h(Object(t),!0).forEach((function(n){w(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function g(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,i=!1,o=void 0;try{for(var c,u=e[Symbol.iterator]();!(r=(c=u.next()).done)&&(t.push(c.value),!n||t.length!==n);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(i)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return O(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}!function(e){e.resized="WINDOW_RESIZED"}(l||(l={}));var j={resized:l.resized},E=function(e,n){return{isSmallDevice:e<c.small,isMediumDevice:e>c.small&&e<c.medium,isLargeDevice:e>c.medium&&e<c.large,isXlDevice:e>c.large,isPortrait:n>=e,isLandscape:n<e,inner:{height:n,width:e}}},D={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 E(e,n)},S=function(e,n){var t=n.type,r=n.width,i=n.height;switch(t){case j.resized:return b(b({},e),E(r,i))}},A=function(){var e=g(o(S,D,L),2),n=e[0],t=e[1],r=function(){return requestAnimationFrame((function(){return t({type:j.resized,width:window.innerWidth,height:window.innerHeight})}))};return i((function(){return"undefined"!=typeof window&&window.addEventListener("resize",r),function(){"undefined"!=typeof window&&window.removeEventListener("resize",r)}}),[]),b({},n)},P=function(e){var n=e.ref,t=e.timeout,r=void 0===t?0:t,o=e.autoScroll,c=void 0===o||o,u=e.options,a=void 0===u?{behavior:"smooth"}:u,f=function(){n&&n.current&&n.current.scrollIntoView(a)};return i((function(){if(c){var e=setTimeout(f,r);return function(){return clearTimeout(e)}}}),[n,r,c]),[f]};export{D as initialScreenState,u as useAnimatedHeight,f as useClickOutside,s as useFocusOutside,p as useIntersectionObserver,d as useKeyListener,m as useMutationObserver,A as useScreen,P as useScrollIntoView};

@@ -407,2 +407,32 @@ 'use strict';

var useScrollIntoView = function useScrollIntoView(_ref) {
var ref = _ref.ref,
_ref$timeout = _ref.timeout,
timeout = _ref$timeout === void 0 ? 0 : _ref$timeout,
_ref$autoScroll = _ref.autoScroll,
autoScroll = _ref$autoScroll === void 0 ? true : _ref$autoScroll,
_ref$options = _ref.options,
options = _ref$options === void 0 ? {
behavior: "smooth"
} : _ref$options;
var scrollIntoView = function scrollIntoView() {
if (ref && ref.current) {
ref.current.scrollIntoView(options);
}
};
React.useEffect(function () {
if (!autoScroll) {
return;
}
var scrollFn = setTimeout(scrollIntoView, timeout);
return function () {
return clearTimeout(scrollFn);
};
}, [ref, timeout, autoScroll]);
return [scrollIntoView];
};
exports.initialScreenState = initialState;

@@ -416,1 +446,2 @@ exports.useAnimatedHeight = useAnimatedHeight;

exports.useScreen = useScreen;
exports.useScrollIntoView = useScrollIntoView;

@@ -400,2 +400,32 @@ import React, { useRef, useCallback, useLayoutEffect, useEffect, useReducer } from 'react';

export { initialState as initialScreenState, useAnimatedHeight, useClickOutside, useFocusOutside, useIntersectionObserver, useKeyListener, useMutationObserver, useScreen };
var useScrollIntoView = function useScrollIntoView(_ref) {
var ref = _ref.ref,
_ref$timeout = _ref.timeout,
timeout = _ref$timeout === void 0 ? 0 : _ref$timeout,
_ref$autoScroll = _ref.autoScroll,
autoScroll = _ref$autoScroll === void 0 ? true : _ref$autoScroll,
_ref$options = _ref.options,
options = _ref$options === void 0 ? {
behavior: "smooth"
} : _ref$options;
var scrollIntoView = function scrollIntoView() {
if (ref && ref.current) {
ref.current.scrollIntoView(options);
}
};
useEffect(function () {
if (!autoScroll) {
return;
}
var scrollFn = setTimeout(scrollIntoView, timeout);
return function () {
return clearTimeout(scrollFn);
};
}, [ref, timeout, autoScroll]);
return [scrollIntoView];
};
export { initialState as initialScreenState, useAnimatedHeight, useClickOutside, useFocusOutside, useIntersectionObserver, useKeyListener, useMutationObserver, useScreen, useScrollIntoView };

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

import e,{useRef as n,useCallback as t,useLayoutEffect as r,useEffect as i,useReducer as o}from"react";import{breakpoints as c}from"@fremtind/jkl-core";function u(e){var o=n(),c=n(),u=n(null),f=n(!0);function s(){var e=a(u);e&&e.removeAttribute("style")}var d=t((function(){if(!f.current){var n=a(u);n&&(n.style.display="block",n.style.overflow="hidden",e?(n.style.height="0",n.style.height="".concat(n.scrollHeight,"px")):(n.style.height="".concat(n.scrollHeight,"px"),o.current=requestAnimationFrame((function(){c.current=requestAnimationFrame((function(){n.style.height="".concat(0,"px")}))}))))}}),[e]);return r((function(){d()}),[e,d]),i((function(){var e=a(u);return e&&e.addEventListener("transitionend",s),function(){e&&e.removeEventListener("transitionend",s)}}),[e]),i((function(){var e=o.current,n=c.current;return f.current=!1,function(){e&&cancelAnimationFrame(e),n&&cancelAnimationFrame(n)}}),[o,c]),[u,d]}function a(e){return e.current&&(e.current.el||e.current)}function f(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 s(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 d(e,n,t){function r(e){n&&!n.includes(e.key)||t(e)}"string"==typeof n&&(n=[n]),i((function(){var n=e&&e.current;return n&&n.addEventListener("keydown",r),function(){n&&n.removeEventListener("keydown",r)}}))}var l,v=function(){return"undefined"!=typeof window&&"undefined"!=typeof MutationObserver},m=function(e,t,r){var o=n(null);i((function(){var n=o.current;if(v()){var i=e.current;n&&n.disconnect(),n=new MutationObserver(t),i&&n.observe(i,r)}return function(){v()&&n&&n.disconnect()}}),[e,t,r])},y=function(){return"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver},p=function(e,t,r,o){var c=n(null);i((function(){var n=c.current;if(y()){var i=e.current;n&&n.disconnect(),n=new IntersectionObserver(t,o),i&&n.observe(i)}else r();return function(){y()&&n&&n.disconnect()}}),[e,t,r,o])};function w(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function h(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 b(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?h(Object(t),!0).forEach((function(n){w(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function g(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,i=!1,o=void 0;try{for(var c,u=e[Symbol.iterator]();!(r=(c=u.next()).done)&&(t.push(c.value),!n||t.length!==n);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(i)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return O(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}!function(e){e.resized="WINDOW_RESIZED"}(l||(l={}));var j={resized:l.resized},E=function(e,n){return{isSmallDevice:e<c.small,isMediumDevice:e>c.small&&e<c.medium,isLargeDevice:e>c.medium&&e<c.large,isXlDevice:e>c.large,isPortrait:n>=e,isLandscape:n<e,inner:{height:n,width:e}}},D={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 E(e,n)},S=function(e,n){var t=n.type,r=n.width,i=n.height;switch(t){case j.resized:return b(b({},e),E(r,i))}},A=function(){var e=g(o(S,D,L),2),n=e[0],t=e[1],r=function(){return requestAnimationFrame((function(){return t({type:j.resized,width:window.innerWidth,height:window.innerHeight})}))};return i((function(){return"undefined"!=typeof window&&window.addEventListener("resize",r),function(){"undefined"!=typeof window&&window.removeEventListener("resize",r)}}),[]),b({},n)};export{D as initialScreenState,u as useAnimatedHeight,f as useClickOutside,s as useFocusOutside,p as useIntersectionObserver,d as useKeyListener,m as useMutationObserver,A as useScreen};
import e,{useRef as n,useCallback as t,useLayoutEffect as r,useEffect as i,useReducer as o}from"react";import{breakpoints as c}from"@fremtind/jkl-core";function u(e){var o=n(),c=n(),u=n(null),f=n(!0);function s(){var e=a(u);e&&e.removeAttribute("style")}var d=t((function(){if(!f.current){var n=a(u);n&&(n.style.display="block",n.style.overflow="hidden",e?(n.style.height="0",n.style.height="".concat(n.scrollHeight,"px")):(n.style.height="".concat(n.scrollHeight,"px"),o.current=requestAnimationFrame((function(){c.current=requestAnimationFrame((function(){n.style.height="".concat(0,"px")}))}))))}}),[e]);return r((function(){d()}),[e,d]),i((function(){var e=a(u);return e&&e.addEventListener("transitionend",s),function(){e&&e.removeEventListener("transitionend",s)}}),[e]),i((function(){var e=o.current,n=c.current;return f.current=!1,function(){e&&cancelAnimationFrame(e),n&&cancelAnimationFrame(n)}}),[o,c]),[u,d]}function a(e){return e.current&&(e.current.el||e.current)}function f(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 s(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 d(e,n,t){function r(e){n&&!n.includes(e.key)||t(e)}"string"==typeof n&&(n=[n]),i((function(){var n=e&&e.current;return n&&n.addEventListener("keydown",r),function(){n&&n.removeEventListener("keydown",r)}}))}var l,v=function(){return"undefined"!=typeof window&&"undefined"!=typeof MutationObserver},m=function(e,t,r){var o=n(null);i((function(){var n=o.current;if(v()){var i=e.current;n&&n.disconnect(),n=new MutationObserver(t),i&&n.observe(i,r)}return function(){v()&&n&&n.disconnect()}}),[e,t,r])},y=function(){return"undefined"!=typeof window&&"undefined"!=typeof IntersectionObserver},p=function(e,t,r,o){var c=n(null);i((function(){var n=c.current;if(y()){var i=e.current;n&&n.disconnect(),n=new IntersectionObserver(t,o),i&&n.observe(i)}else r();return function(){y()&&n&&n.disconnect()}}),[e,t,r,o])};function w(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function h(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 b(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?h(Object(t),!0).forEach((function(n){w(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function g(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,i=!1,o=void 0;try{for(var c,u=e[Symbol.iterator]();!(r=(c=u.next()).done)&&(t.push(c.value),!n||t.length!==n);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(i)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return O(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}!function(e){e.resized="WINDOW_RESIZED"}(l||(l={}));var j={resized:l.resized},E=function(e,n){return{isSmallDevice:e<c.small,isMediumDevice:e>c.small&&e<c.medium,isLargeDevice:e>c.medium&&e<c.large,isXlDevice:e>c.large,isPortrait:n>=e,isLandscape:n<e,inner:{height:n,width:e}}},D={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 E(e,n)},S=function(e,n){var t=n.type,r=n.width,i=n.height;switch(t){case j.resized:return b(b({},e),E(r,i))}},A=function(){var e=g(o(S,D,L),2),n=e[0],t=e[1],r=function(){return requestAnimationFrame((function(){return t({type:j.resized,width:window.innerWidth,height:window.innerHeight})}))};return i((function(){return"undefined"!=typeof window&&window.addEventListener("resize",r),function(){"undefined"!=typeof window&&window.removeEventListener("resize",r)}}),[]),b({},n)},P=function(e){var n=e.ref,t=e.timeout,r=void 0===t?0:t,o=e.autoScroll,c=void 0===o||o,u=e.options,a=void 0===u?{behavior:"smooth"}:u,f=function(){n&&n.current&&n.current.scrollIntoView(a)};return i((function(){if(c){var e=setTimeout(f,r);return function(){return clearTimeout(e)}}}),[n,r,c]),[f]};export{D as initialScreenState,u as useAnimatedHeight,f as useClickOutside,s as useFocusOutside,p as useIntersectionObserver,d as useKeyListener,m as useMutationObserver,A as useScreen,P as useScrollIntoView};

@@ -8,2 +8,3 @@ export { useAnimatedHeight } from "./animation";

export { useScreen } from "./useScreen/useScreen";
export { useScrollIntoView } from "./useScrollIntoView/useScrollIntoView";
export { initialState as initialScreenState } from "./useScreen/state";

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

# 1.2.0 (2020-05-28)
### Features
* add hook to wrap scrollintoview ([dcde26a](https://github.com/fremtind/jokul/commit/dcde26a888833ecf1ba6646ea9c7e6086d13e57c)), closes [#967](https://github.com/fremtind/jokul/issues/967)
## 1.1.12 (2020-05-20)

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

{
"name": "@fremtind/jkl-react-hooks",
"version": "1.1.12",
"version": "1.2.0",
"publishConfig": {

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

"devDependencies": {
"@fremtind/jkl-portal-components": "^0.2.12"
"@fremtind/jkl-portal-components": "^0.3.0"
},

@@ -56,3 +56,3 @@ "dependencies": {

},
"gitHead": "87c7bd62f88b55a87c6c8c87c3d34d45ed232a2b"
"gitHead": "3885a9c7b58b57d008418bcd1b7536915917c7d1"
}
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