@vitus-labs/hooks 0.47.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@vitus-labs/core')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@vitus-labs/core'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vitusLabsHooks = {}, global.React, global.core));
5
- })(this, (function (exports, react, core) { 'use strict';
6
-
7
- const useHover = (initial = false) => {
8
- const [hover, handleHover] = react.useState(initial);
9
- const setHover = react.useCallback(() => handleHover(true), []);
10
- const unsetHover = react.useCallback(() => handleHover(false), []);
11
- return {
12
- hover,
13
- onMouseEnter: setHover,
14
- onMouseLeave: unsetHover,
15
- };
16
- };
17
-
18
- const useWindowResize = (throttleDelay = 200, { width = 0, height = 0 } = {}) => {
19
- const getSize = () => ({
20
- width: width,
21
- height: height,
22
- });
23
- const [windowSize, setWindowSize] = react.useState(getSize);
24
- core.throttle(() => {
25
- setWindowSize(getSize());
26
- }, throttleDelay);
27
- react.useEffect(() => {
28
- return undefined;
29
- }, []); // Empty array ensures that effect is only run on mount and unmount
30
- return windowSize;
31
- };
32
-
33
- exports.useHover = useHover;
34
- exports.useWindowResize = useWindowResize;
35
-
36
- Object.defineProperty(exports, '__esModule', { value: true });
37
-
38
- }));
39
- //# sourceMappingURL=vitus-labs-hooks.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vitus-labs-hooks.umd.js","sources":["../src/useHover.ts","../src/useWindowResize.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport type UseHover = (initialValue?: boolean) => {\n hover: boolean\n onMouseEnter: () => void\n onMouseLeave: () => void\n}\n\nconst useHover: UseHover = (initial = false) => {\n const [hover, handleHover] = useState(initial)\n\n const setHover = useCallback(() => handleHover(true), [])\n const unsetHover = useCallback(() => handleHover(false), [])\n\n return {\n hover,\n onMouseEnter: setHover,\n onMouseLeave: unsetHover,\n }\n}\n\nexport default useHover\n","import { useState, useEffect } from 'react'\nimport { throttle } from '@vitus-labs/core'\n\nexport type UseWindowResize = (\n throttleDelay?: number,\n defaultValues?: Partial<{\n width: number\n height: number\n }>\n) => {\n width: number\n height: number\n}\n\nconst useWindowResize: UseWindowResize = (\n throttleDelay = 200,\n { width = 0, height = 0 } = {}\n) => {\n const getSize = () => ({\n width: __CLIENT__ ? window.innerWidth : width,\n height: __CLIENT__ ? window.innerHeight : height,\n })\n\n const [windowSize, setWindowSize] = useState(getSize)\n\n const handleResize = throttle(() => {\n setWindowSize(getSize())\n }, throttleDelay)\n\n useEffect(() => {\n if (__SERVER__) return undefined\n\n window.addEventListener('resize', handleResize, false)\n\n return () => window.removeEventListener('resize', handleResize, false)\n }, []) // Empty array ensures that effect is only run on mount and unmount\n\n return windowSize\n}\n\nexport default useWindowResize\n"],"names":["useState","useCallback","throttle","useEffect"],"mappings":";;;;;;AAQA,QAAM,QAAQ,GAAa,CAAC,OAAO,GAAG,KAAK,KAAI;MAC7C,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,GAAGA,cAAQ,CAAC,OAAO,CAAC,CAAA;EAE9C,IAAA,MAAM,QAAQ,GAAGC,iBAAW,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;EACzD,IAAA,MAAM,UAAU,GAAGA,iBAAW,CAAC,MAAM,WAAW,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;MAE5D,OAAO;UACL,KAAK;EACL,QAAA,YAAY,EAAE,QAAQ;EACtB,QAAA,YAAY,EAAE,UAAU;OACzB,CAAA;EACH;;ACLA,QAAM,eAAe,GAAoB,CACvC,aAAa,GAAG,GAAG,EACnB,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,KAC5B;EACF,IAAA,MAAM,OAAO,GAAG,OAAO;UACrB,KAAK,EAAmC,KAAK;UAC7C,MAAM,EAAoC,MAAM;EACjD,KAAA,CAAC,CAAA;MAEF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGD,cAAQ,CAAC,OAAO,CAAC,CAAA;EAErD,IAAqBE,aAAQ,CAAC,MAAK;EACjC,QAAA,aAAa,CAAC,OAAO,EAAE,CAAC,CAAA;OACzB,EAAE,aAAa,EAAC;MAEjBC,eAAS,CAAC,MAAK;EACb,QAAgB,OAAO,SAAS,CAAA;EAKlC,KAAC,EAAE,EAAE,CAAC,CAAA;EAEN,IAAA,OAAO,UAAU,CAAA;EACnB;;;;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@vitus-labs/core")):"function"==typeof define&&define.amd?define(["exports","react","@vitus-labs/core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vitusLabsHooks={},e.React,e.core)}(this,(function(e,t,o){"use strict";e.useHover=(e=!1)=>{const[o,s]=t.useState(e);return{hover:o,onMouseEnter:t.useCallback((()=>s(!0)),[]),onMouseLeave:t.useCallback((()=>s(!1)),[])}},e.useWindowResize=(e=200,{width:s=0,height:u=0}={})=>{const i=()=>({width:s,height:u}),[r,n]=t.useState(i);return o.throttle((()=>{n(i())}),e),t.useEffect((()=>{}),[]),r},Object.defineProperty(e,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=vitus-labs-hooks.umd.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vitus-labs-hooks.umd.min.js","sources":["../src/useHover.ts","../src/useWindowResize.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport type UseHover = (initialValue?: boolean) => {\n hover: boolean\n onMouseEnter: () => void\n onMouseLeave: () => void\n}\n\nconst useHover: UseHover = (initial = false) => {\n const [hover, handleHover] = useState(initial)\n\n const setHover = useCallback(() => handleHover(true), [])\n const unsetHover = useCallback(() => handleHover(false), [])\n\n return {\n hover,\n onMouseEnter: setHover,\n onMouseLeave: unsetHover,\n }\n}\n\nexport default useHover\n","import { useState, useEffect } from 'react'\nimport { throttle } from '@vitus-labs/core'\n\nexport type UseWindowResize = (\n throttleDelay?: number,\n defaultValues?: Partial<{\n width: number\n height: number\n }>\n) => {\n width: number\n height: number\n}\n\nconst useWindowResize: UseWindowResize = (\n throttleDelay = 200,\n { width = 0, height = 0 } = {}\n) => {\n const getSize = () => ({\n width: __CLIENT__ ? window.innerWidth : width,\n height: __CLIENT__ ? window.innerHeight : height,\n })\n\n const [windowSize, setWindowSize] = useState(getSize)\n\n const handleResize = throttle(() => {\n setWindowSize(getSize())\n }, throttleDelay)\n\n useEffect(() => {\n if (__SERVER__) return undefined\n\n window.addEventListener('resize', handleResize, false)\n\n return () => window.removeEventListener('resize', handleResize, false)\n }, []) // Empty array ensures that effect is only run on mount and unmount\n\n return windowSize\n}\n\nexport default useWindowResize\n"],"names":["initial","hover","handleHover","useState","onMouseEnter","useCallback","onMouseLeave","throttleDelay","width","height","getSize","windowSize","setWindowSize","throttle","useEffect"],"mappings":"4VAQ2B,CAACA,GAAU,KACpC,MAAOC,EAAOC,GAAeC,EAAQA,SAACH,GAKtC,MAAO,CACLC,MAAAA,EACAG,aALeC,EAAAA,aAAY,IAAMH,GAAY,IAAO,IAMpDI,aALiBD,EAAAA,aAAY,IAAMH,GAAY,IAAQ,wBCElB,CACvCK,EAAgB,KACdC,MAAAA,EAAQ,EAAGC,OAAAA,EAAS,GAAM,MAE5B,MAAMC,EAAU,KAAO,CACrBF,MAAwCA,EACxCC,OAA0CA,KAGrCE,EAAYC,GAAiBT,EAAQA,SAACO,GAc7C,OAZqBG,EAAAA,UAAS,KAC5BD,EAAcF,OACbH,GAEHO,EAAAA,WAAU,QAMP,IAEIH"}