@gadeoli/rjs-hooks-library 0.0.21 → 0.2.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.
Files changed (46) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +42 -40
  3. package/dist/cjs/index.js +1 -1
  4. package/dist/cjs/types/hooks/index.d.ts +9 -9
  5. package/dist/cjs/types/hooks/useElementSize.d.ts +3 -3
  6. package/dist/cjs/types/hooks/useElementSize.types.d.ts +18 -18
  7. package/dist/cjs/types/hooks/useHover.d.ts +3 -3
  8. package/dist/cjs/types/hooks/useHover.types.d.ts +5 -5
  9. package/dist/cjs/types/hooks/useImagePreloader.d.ts +3 -3
  10. package/dist/cjs/types/hooks/useImagePreloader.types.d.ts +3 -3
  11. package/dist/cjs/types/hooks/useOnClickOutside.d.ts +3 -3
  12. package/dist/cjs/types/hooks/useOnClickOutside.types.d.ts +3 -3
  13. package/dist/cjs/types/hooks/useOnPressKey.d.ts +3 -3
  14. package/dist/cjs/types/hooks/useOnPressKey.types.d.ts +3 -3
  15. package/dist/cjs/types/hooks/usePersistedState.d.ts +3 -3
  16. package/dist/cjs/types/hooks/usePersistedState.types.d.ts +3 -3
  17. package/dist/cjs/types/hooks/usePrevious.d.ts +3 -3
  18. package/dist/cjs/types/hooks/usePrevious.types.d.ts +3 -3
  19. package/dist/cjs/types/hooks/useTimer.d.ts +3 -3
  20. package/dist/cjs/types/hooks/useTimer.types.d.ts +6 -6
  21. package/dist/cjs/types/hooks/useWindowSize.d.ts +3 -3
  22. package/dist/cjs/types/hooks/useWindowSize.props.d.ts +6 -6
  23. package/dist/cjs/types/index.d.ts +1 -1
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/types/hooks/index.d.ts +9 -9
  26. package/dist/esm/types/hooks/useElementSize.d.ts +3 -3
  27. package/dist/esm/types/hooks/useElementSize.types.d.ts +18 -18
  28. package/dist/esm/types/hooks/useHover.d.ts +3 -3
  29. package/dist/esm/types/hooks/useHover.types.d.ts +5 -5
  30. package/dist/esm/types/hooks/useImagePreloader.d.ts +3 -3
  31. package/dist/esm/types/hooks/useImagePreloader.types.d.ts +3 -3
  32. package/dist/esm/types/hooks/useOnClickOutside.d.ts +3 -3
  33. package/dist/esm/types/hooks/useOnClickOutside.types.d.ts +3 -3
  34. package/dist/esm/types/hooks/useOnPressKey.d.ts +3 -3
  35. package/dist/esm/types/hooks/useOnPressKey.types.d.ts +3 -3
  36. package/dist/esm/types/hooks/usePersistedState.d.ts +3 -3
  37. package/dist/esm/types/hooks/usePersistedState.types.d.ts +3 -3
  38. package/dist/esm/types/hooks/usePrevious.d.ts +3 -3
  39. package/dist/esm/types/hooks/usePrevious.types.d.ts +3 -3
  40. package/dist/esm/types/hooks/useTimer.d.ts +3 -3
  41. package/dist/esm/types/hooks/useTimer.types.d.ts +6 -6
  42. package/dist/esm/types/hooks/useWindowSize.d.ts +3 -3
  43. package/dist/esm/types/hooks/useWindowSize.props.d.ts +6 -6
  44. package/dist/esm/types/index.d.ts +1 -1
  45. package/dist/index.d.ts +41 -41
  46. package/package.json +54 -52
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Gabriel Morais
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Gabriel Morais
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,40 +1,42 @@
1
- # RJS Hook Library
2
-
3
- Some (almost all) hooks has been copied from internet foruns. If necessary look from source info to check who created the hook.
4
-
5
- ## How to maintain
6
-
7
- 1. Clone
8
- 2. NVM use 16.14.2 (node 16.14.2 / npm 8.5.0)
9
- 3. npm i
10
- 4. make changes
11
- 5. git add / git commit / git push
12
- 6. npm run publish (custom command)
13
-
14
- ## Hooks
15
-
16
- - useElementSize (Get element sizes using ref)
17
- - useHover (control when a element is hovererd using ref)
18
- - useOnClickOutside (Listen when clicked outside component using ref)
19
- - usePersistedState (An option to persist state in local storage)
20
- - usePrevious (Keep state value between current and previous render)
21
- - useWindowSize (Get window sizes)
22
- - useTimer (a count down minute / seconds)
23
- - useClickOutside (An event handler to trigger an action by outside-click-element using ref)
24
- - useOnPressKey (An event handler to trigger an action by key press using ref)
25
-
26
- ## Use
27
-
28
- ```
29
- import {useElementSize} from '@gadeoli/rjs-hooks-library';
30
- ```
31
-
32
- ## Sources
33
- [useElementSize](https://usehooks-ts.com/react-hook/use-element-size)
34
- [useOnClickOutside](https://usehooks.com/useOnClickOutside/)
35
- usePersistedState
36
- usePrevious
37
- [useTimer](https://www.codegrepper.com/code-examples/javascript/time+counter+in+react+js)
38
- useWindowSize
39
- useClickOutside
40
- useOnPressKey
1
+ # RJS Hooks Library
2
+
3
+ Some (almost all) hooks has been copied from internet foruns. If necessary look from source info to check who created the hook.
4
+
5
+ ## Hooks
6
+
7
+ - useElementSize (Get element sizes using ref)
8
+ - useHover (control when a element is hovererd using ref)
9
+ - useOnClickOutside (Listen when clicked outside component using ref)
10
+ - usePersistedState (An option to persist state in local storage)
11
+ - usePrevious (Keep state value between current and previous render)
12
+ - useWindowSize (Get window sizes)
13
+ - useTimer (a count down minute / seconds)
14
+ - useClickOutside (An event handler to trigger an action by outside-click-element using ref)
15
+ - useOnPressKey (An event handler to trigger an action by key press using ref)
16
+
17
+ ## Use
18
+
19
+ ```
20
+ import {useElementSize} from '@gadeoli/rjs-hooks-library';
21
+ ```
22
+
23
+ ## How to maintain
24
+
25
+ 1. Clone
26
+ 2. NVM use 22.13.1 (node 22.13.1 / npm 10.9.2)
27
+ 3. npm i
28
+ 4. make changes
29
+ 5. git add / git commit / git push
30
+ 6. npm run publish (custom command)
31
+
32
+ ## Sources
33
+ [useElementSize](https://usehooks-ts.com/react-hook/use-element-size)
34
+ useHover
35
+ [useOnClickOutside](https://usehooks.com/useOnClickOutside/)
36
+ usePersistedState
37
+ usePrevious
38
+ useWindowSize
39
+ [useTimer](https://www.codegrepper.com/code-examples/javascript/time+counter+in+react+js)
40
+ useClickOutside
41
+ useOnPressKey
42
+ some sources could be missing
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@gadeoli/js-helpers-library");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(e),o=function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function u(e,t,n,r){return new(n||(n=Promise))((function(o,u){function i(e){try{s(r.next(e))}catch(e){u(e)}}function c(e){try{s(r.throw(e))}catch(e){u(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))}function i(e,t){var n,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}var c={width:1,height:1},s=function(e){return new Promise((function(t,n){var r=new Image;r.onload=function(){t(r)},r.onerror=r.onabort=function(){n(e)},r.src=e}))};exports.useElementSize=function(t,n){void 0===n&&(n=0);var o=e.useState({width:1,height:2,position:{x:1,y:1,left:1,right:1,top:1,bottom:1},screen:{width:1,height:1}}),u=o[0],i=o[1];return r.default.useEffect((function(){if(t.current){var e=function(){var e=t.current.getBoundingClientRect();i({width:Math.round(e.width),height:Math.round(e.height),position:{x:Math.round(e.x),y:Math.round(e.y),left:Math.round(e.left),right:Math.round(e.right),top:Math.round(e.top),bottom:Math.round(e.bottom)},screen:{width:Math.round(window.screen.width),height:Math.round(window.screen.height)}})};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}}),[t,n]),u},exports.useHover=function(t){var n=e.useState(!1),r=n[0],o=n[1];return e.useEffect((function(){if(t&&t.current){var e=t.current,n=function(e){return o(!0)},r=function(e){return o(!1)};return e.addEventListener("mouseover",n),e.addEventListener("mouseout",r),function(){e.removeEventListener("mouseover",n),e.removeEventListener("mouseout",r)}}}),[t]),{show:r}},exports.useImagePreloader=function(t){var n=e.useState(!1),r=n[0],o=n[1];return e.useEffect((function(){var e=!1;return function(){u(this,void 0,void 0,(function(){var n,r,u,c;return i(this,(function(i){switch(i.label){case 0:if(e)return[2];for(n=[],r=0,u=t;r<u.length;r++)c=u[r],n.push(s(c));return[4,Promise.all(n)];case 1:return i.sent(),e?[2]:(o(!0),[2])}}))}))}(),function(){e=!0}}),[t]),{imagesPreloaded:r}},exports.useOnClickOutside=function(t,n){e.useEffect((function(){var e=function(e){t.current&&!t.current.contains(e.target)&&n(e)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[t,n])},exports.useOnPressKey=function(e,t){r.default.useEffect((function(){var n=function(n){n.keyCode===e&&t()};return document.addEventListener("keydown",n),function(){document.removeEventListener("keydown",n)}}),[t])},exports.usePersistedState=function(n,r){var o=e.useState((function(){var e=localStorage.getItem(n);return e?JSON.parse(e):r})),u=o[0],i=o[1];return e.useEffect((function(){localStorage.setItem(n,t.secureJSONStringify(u))}),[n,u]),[u,i]},exports.usePrevious=function(t){var n=e.useRef();return e.useEffect((function(){n.current=t})),n.current},exports.useTimer=function(t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1);var o=e.useState(t),u=o[0],i=o[1],c=e.useState(n),s=c[0],a=c[1];return e.useEffect((function(){i(t),a(n)}),[r]),e.useEffect((function(){})),e.useEffect((function(){var e=setInterval((function(){s>0&&a(s-1),0===s&&(0===u?clearInterval(e):(i(u-1),a(59)))}),1e3);return function(){clearInterval(e)}})),{minutes:u,seconds:s}},exports.useWindowSize=function(){var t=e.useState(o({},c)),n=t[0],r=t[1];return e.useEffect((function(){var e=function(){r({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}),[]),n};
1
+ "use strict";var e=require("react"),t=require("@gadeoli/js-helpers-library"),n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,u){function i(e){try{s(r.next(e))}catch(e){u(e)}}function c(e){try{s(r.throw(e))}catch(e){u(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}"function"==typeof SuppressedError&&SuppressedError;var u={width:1,height:1},i=function(e){return new Promise((function(t,n){var r=new Image;r.onload=function(){t(r)},r.onerror=r.onabort=function(){n(e)},r.src=e}))};exports.useElementSize=function(t,n){void 0===n&&(n=0);var r=e.useState({width:1,height:2,position:{x:1,y:1,left:1,right:1,top:1,bottom:1},screen:{width:1,height:1}}),o=r[0],u=r[1];return e.useEffect((function(){if(t.current){var e=function(){var e=t.current.getBoundingClientRect();u({width:Math.round(e.width),height:Math.round(e.height),position:{x:Math.round(e.x),y:Math.round(e.y),left:Math.round(e.left),right:Math.round(e.right),top:Math.round(e.top),bottom:Math.round(e.bottom)},screen:{width:Math.round(window.screen.width),height:Math.round(window.screen.height)}})};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}}),[t,n]),o},exports.useHover=function(t){var n=e.useState(!1),r=n[0],o=n[1];return e.useEffect((function(){if(t&&t.current){var e=t.current,n=function(e){return o(!0)},r=function(e){return o(!1)};return e.addEventListener("mouseover",n),e.addEventListener("mouseout",r),function(){e.removeEventListener("mouseover",n),e.removeEventListener("mouseout",r)}}}),[t]),{show:r}},exports.useImagePreloader=function(t){var n=e.useState(!1),u=n[0],c=n[1];return e.useEffect((function(){var e=!1;return function(){r(this,void 0,void 0,(function(){var n,r,u,s;return o(this,(function(o){switch(o.label){case 0:if(e)return[2];for(n=[],r=0,u=t;r<u.length;r++)s=u[r],n.push(i(s));return[4,Promise.all(n)];case 1:return o.sent(),e?[2]:(c(!0),[2])}}))}))}(),function(){e=!0}}),[t]),{imagesPreloaded:u}},exports.useOnClickOutside=function(t,n){e.useEffect((function(){var e=function(e){t.current&&!t.current.contains(e.target)&&n(e)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[t,n])},exports.useOnPressKey=function(t,n){e.useEffect((function(){var e=function(e){e.keyCode===t&&n()};return document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[n])},exports.usePersistedState=function(n,r){var o=e.useState((function(){var e=localStorage.getItem(n);return e?JSON.parse(e):r})),u=o[0],i=o[1];return e.useEffect((function(){localStorage.setItem(n,t.secureJSONStringify(u))}),[n,u]),[u,i]},exports.usePrevious=function(t){var n=e.useRef(null);return e.useEffect((function(){n.current=t})),n.current},exports.useTimer=function(t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1);var o=e.useState(t),u=o[0],i=o[1],c=e.useState(n),s=c[0],a=c[1];return e.useEffect((function(){i(t),a(n)}),[r]),e.useEffect((function(){})),e.useEffect((function(){var e=setInterval((function(){s>0&&a(s-1),0===s&&(0===u?clearInterval(e):(i(u-1),a(59)))}),1e3);return function(){clearInterval(e)}})),{minutes:u,seconds:s}},exports.useWindowSize=function(){var t=e.useState(n({},u)),r=t[0],o=t[1];return e.useEffect((function(){var e=function(){o({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}),[]),r};
@@ -1,9 +1,9 @@
1
- export { default as useElementSize } from "./useElementSize";
2
- export { default as useHover } from "./useHover";
3
- export { default as useOnClickOutside } from "./useOnClickOutside";
4
- export { default as usePersistedState } from "./usePersistedState";
5
- export { default as usePrevious } from "./usePrevious";
6
- export { default as useTimer } from "./useTimer";
7
- export { default as useWindowSize } from "./useWindowSize";
8
- export { default as useOnPressKey } from "./useOnPressKey";
9
- export { default as useImagePreloader } from "./useImagePreloader";
1
+ export { default as useElementSize } from "./useElementSize";
2
+ export { default as useHover } from "./useHover";
3
+ export { default as useOnClickOutside } from "./useOnClickOutside";
4
+ export { default as usePersistedState } from "./usePersistedState";
5
+ export { default as usePrevious } from "./usePrevious";
6
+ export { default as useTimer } from "./useTimer";
7
+ export { default as useWindowSize } from "./useWindowSize";
8
+ export { default as useOnPressKey } from "./useOnPressKey";
9
+ export { default as useImagePreloader } from "./useImagePreloader";
@@ -1,3 +1,3 @@
1
- import { useElementSizeProps } from './useElementSize.types';
2
- declare const useElementSize: useElementSizeProps;
3
- export default useElementSize;
1
+ import { useElementSizeProps } from './useElementSize.types';
2
+ declare const useElementSize: useElementSizeProps;
3
+ export default useElementSize;
@@ -1,18 +1,18 @@
1
- export interface useElementSizeProps {
2
- (ref: any, forceRefresh?: number): {
3
- width: number;
4
- height: number;
5
- position: {
6
- x: number;
7
- y: number;
8
- left: number;
9
- right: number;
10
- top: number;
11
- bottom: number;
12
- };
13
- screen: {
14
- width: number;
15
- height: number;
16
- };
17
- };
18
- }
1
+ export interface useElementSizeProps {
2
+ (ref: any, forceRefresh?: number): {
3
+ width: number;
4
+ height: number;
5
+ position: {
6
+ x: number;
7
+ y: number;
8
+ left: number;
9
+ right: number;
10
+ top: number;
11
+ bottom: number;
12
+ };
13
+ screen: {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ };
18
+ }
@@ -1,3 +1,3 @@
1
- import { useHoverProps } from './useHover.types';
2
- declare const useHover: useHoverProps;
3
- export default useHover;
1
+ import { useHoverProps } from './useHover.types';
2
+ declare const useHover: useHoverProps;
3
+ export default useHover;
@@ -1,5 +1,5 @@
1
- export interface useHoverProps {
2
- (ref: any): {
3
- show: boolean;
4
- };
5
- }
1
+ export interface useHoverProps {
2
+ (ref: any): {
3
+ show: boolean;
4
+ };
5
+ }
@@ -1,3 +1,3 @@
1
- import { useImagePreloaderProps } from './useImagePreloader.types';
2
- declare const useImagePreloader: useImagePreloaderProps;
3
- export default useImagePreloader;
1
+ import { useImagePreloaderProps } from './useImagePreloader.types';
2
+ declare const useImagePreloader: useImagePreloaderProps;
3
+ export default useImagePreloader;
@@ -1,3 +1,3 @@
1
- export interface useImagePreloaderProps {
2
- (srcImgs: Array<string>): object;
3
- }
1
+ export interface useImagePreloaderProps {
2
+ (srcImgs: Array<string>): object;
3
+ }
@@ -1,3 +1,3 @@
1
- import { useOnClickOutsideProps } from './useOnClickOutside.types';
2
- declare const useOnClickOutside: useOnClickOutsideProps;
3
- export default useOnClickOutside;
1
+ import { useOnClickOutsideProps } from './useOnClickOutside.types';
2
+ declare const useOnClickOutside: useOnClickOutsideProps;
3
+ export default useOnClickOutside;
@@ -1,3 +1,3 @@
1
- export interface useOnClickOutsideProps {
2
- (ref: any, handler: any): void;
3
- }
1
+ export interface useOnClickOutsideProps {
2
+ (ref: any, handler: any): void;
3
+ }
@@ -1,3 +1,3 @@
1
- import { useOnPressKeyProps } from './useOnPressKey.types';
2
- declare const useOnPressKey: useOnPressKeyProps;
3
- export default useOnPressKey;
1
+ import { useOnPressKeyProps } from './useOnPressKey.types';
2
+ declare const useOnPressKey: useOnPressKeyProps;
3
+ export default useOnPressKey;
@@ -1,3 +1,3 @@
1
- export interface useOnPressKeyProps {
2
- (keyAsc: number, action: any): void;
3
- }
1
+ export interface useOnPressKeyProps {
2
+ (keyAsc: number, action: any): void;
3
+ }
@@ -1,3 +1,3 @@
1
- import { usePersistedStateProps } from './usePersistedState.types';
2
- declare const usePersistedState: usePersistedStateProps;
3
- export default usePersistedState;
1
+ import { usePersistedStateProps } from './usePersistedState.types';
2
+ declare const usePersistedState: usePersistedStateProps;
3
+ export default usePersistedState;
@@ -1,3 +1,3 @@
1
- export interface usePersistedStateProps {
2
- (key: string, initialState: any): Array<any>;
3
- }
1
+ export interface usePersistedStateProps {
2
+ (key: string, initialState: any): Array<any>;
3
+ }
@@ -1,3 +1,3 @@
1
- import { usePreviousProps } from './usePrevious.types';
2
- declare const usePrevious: usePreviousProps;
3
- export default usePrevious;
1
+ import { usePreviousProps } from './usePrevious.types';
2
+ declare const usePrevious: usePreviousProps;
3
+ export default usePrevious;
@@ -1,3 +1,3 @@
1
- export interface usePreviousProps {
2
- (value: any): any;
3
- }
1
+ export interface usePreviousProps {
2
+ (value: any): any;
3
+ }
@@ -1,3 +1,3 @@
1
- import { useTimerProps } from './useTimer.types';
2
- declare const useTimer: useTimerProps;
3
- export default useTimer;
1
+ import { useTimerProps } from './useTimer.types';
2
+ declare const useTimer: useTimerProps;
3
+ export default useTimer;
@@ -1,6 +1,6 @@
1
- export interface useTimerProps {
2
- (initialMinutes: number, initialSeconds: number, reset: number): {
3
- minutes: number;
4
- seconds: number;
5
- };
6
- }
1
+ export interface useTimerProps {
2
+ (initialMinutes: number, initialSeconds: number, reset: number): {
3
+ minutes: number;
4
+ seconds: number;
5
+ };
6
+ }
@@ -1,3 +1,3 @@
1
- import { useWindowSizeProps } from "./useWindowSize.props";
2
- declare const useWindowSize: useWindowSizeProps;
3
- export default useWindowSize;
1
+ import { useWindowSizeProps } from "./useWindowSize.props";
2
+ declare const useWindowSize: useWindowSizeProps;
3
+ export default useWindowSize;
@@ -1,6 +1,6 @@
1
- export interface useWindowSizeProps {
2
- (): {
3
- width: number;
4
- height: number;
5
- };
6
- }
1
+ export interface useWindowSizeProps {
2
+ (): {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ }
@@ -1 +1 @@
1
- export * from './hooks';
1
+ export * from './hooks';
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import n,{useState as t,useEffect as e,useRef as r}from"react";import{secureJSONStringify as o}from"@gadeoli/js-helpers-library";var i=function(e,r){void 0===r&&(r=0);var o=t({width:1,height:2,position:{x:1,y:1,left:1,right:1,top:1,bottom:1},screen:{width:1,height:1}}),i=o[0],u=o[1];return n.useEffect((function(){if(e.current){var n=function(){var n=e.current.getBoundingClientRect();u({width:Math.round(n.width),height:Math.round(n.height),position:{x:Math.round(n.x),y:Math.round(n.y),left:Math.round(n.left),right:Math.round(n.right),top:Math.round(n.top),bottom:Math.round(n.bottom)},screen:{width:Math.round(window.screen.width),height:Math.round(window.screen.height)}})};return window.addEventListener("resize",n),n(),function(){return window.removeEventListener("resize",n)}}}),[e,r]),i},u=function(n){var r=t(!1),o=r[0],i=r[1];return e((function(){if(n&&n.current){var t=n.current,e=function(n){return i(!0)},r=function(n){return i(!1)};return t.addEventListener("mouseover",e),t.addEventListener("mouseout",r),function(){t.removeEventListener("mouseover",e),t.removeEventListener("mouseout",r)}}}),[n]),{show:o}},c=function(n,t){e((function(){var e=function(e){n.current&&!n.current.contains(e.target)&&t(e)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[n,t])},a=function(n,r){var i=t((function(){var t=localStorage.getItem(n);return t?JSON.parse(t):r})),u=i[0],c=i[1];return e((function(){localStorage.setItem(n,o(u))}),[n,u]),[u,c]},f=function(n){var t=r();return e((function(){t.current=n})),t.current},s=function(n,r,o){void 0===n&&(n=0),void 0===r&&(r=0),void 0===o&&(o=1);var i=t(n),u=i[0],c=i[1],a=t(r),f=a[0],s=a[1];return e((function(){c(n),s(r)}),[o]),e((function(){})),e((function(){var n=setInterval((function(){f>0&&s(f-1),0===f&&(0===u?clearInterval(n):(c(u-1),s(59)))}),1e3);return function(){clearInterval(n)}})),{minutes:u,seconds:f}},d=function(){return d=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n},d.apply(this,arguments)};function h(n,t,e,r){return new(e||(e=Promise))((function(o,i){function u(n){try{a(r.next(n))}catch(n){i(n)}}function c(n){try{a(r.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?o(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,c)}a((r=r.apply(n,t||[])).next())}))}function l(n,t){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(n,u)}catch(n){i=[6,n],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var v={width:1,height:1},w=function(){var n=t(d({},v)),r=n[0],o=n[1];return e((function(){var n=function(){o({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",n),n(),function(){return window.removeEventListener("resize",n)}}),[]),r},m=function(t,e){n.useEffect((function(){var n=function(n){n.keyCode===t&&e()};return document.addEventListener("keydown",n),function(){document.removeEventListener("keydown",n)}}),[e])},p=function(n){return new Promise((function(t,e){var r=new Image;r.onload=function(){t(r)},r.onerror=r.onabort=function(){e(n)},r.src=n}))},g=function(n){var r=t(!1),o=r[0],i=r[1];return e((function(){var t=!1;return function(){h(this,void 0,void 0,(function(){var e,r,o,u;return l(this,(function(c){switch(c.label){case 0:if(t)return[2];for(e=[],r=0,o=n;r<o.length;r++)u=o[r],e.push(p(u));return[4,Promise.all(e)];case 1:return c.sent(),t?[2]:(i(!0),[2])}}))}))}(),function(){t=!0}}),[n]),{imagesPreloaded:o}};export{i as useElementSize,u as useHover,g as useImagePreloader,c as useOnClickOutside,m as useOnPressKey,a as usePersistedState,f as usePrevious,s as useTimer,w as useWindowSize};
1
+ import n,{useState as t,useEffect as e,useRef as r}from"react";import{secureJSONStringify as o}from"@gadeoli/js-helpers-library";var i=function(e,r){void 0===r&&(r=0);var o=t({width:1,height:2,position:{x:1,y:1,left:1,right:1,top:1,bottom:1},screen:{width:1,height:1}}),i=o[0],u=o[1];return n.useEffect((function(){if(e.current){var n=function(){var n=e.current.getBoundingClientRect();u({width:Math.round(n.width),height:Math.round(n.height),position:{x:Math.round(n.x),y:Math.round(n.y),left:Math.round(n.left),right:Math.round(n.right),top:Math.round(n.top),bottom:Math.round(n.bottom)},screen:{width:Math.round(window.screen.width),height:Math.round(window.screen.height)}})};return window.addEventListener("resize",n),n(),function(){return window.removeEventListener("resize",n)}}}),[e,r]),i},u=function(n){var r=t(!1),o=r[0],i=r[1];return e((function(){if(n&&n.current){var t=n.current,e=function(n){return i(!0)},r=function(n){return i(!1)};return t.addEventListener("mouseover",e),t.addEventListener("mouseout",r),function(){t.removeEventListener("mouseover",e),t.removeEventListener("mouseout",r)}}}),[n]),{show:o}},c=function(n,t){e((function(){var e=function(e){n.current&&!n.current.contains(e.target)&&t(e)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[n,t])},a=function(n,r){var i=t((function(){var t=localStorage.getItem(n);return t?JSON.parse(t):r})),u=i[0],c=i[1];return e((function(){localStorage.setItem(n,o(u))}),[n,u]),[u,c]},f=function(n){var t=r(null);return e((function(){t.current=n})),t.current},s=function(n,r,o){void 0===n&&(n=0),void 0===r&&(r=0),void 0===o&&(o=1);var i=t(n),u=i[0],c=i[1],a=t(r),f=a[0],s=a[1];return e((function(){c(n),s(r)}),[o]),e((function(){})),e((function(){var n=setInterval((function(){f>0&&s(f-1),0===f&&(0===u?clearInterval(n):(c(u-1),s(59)))}),1e3);return function(){clearInterval(n)}})),{minutes:u,seconds:f}},d=function(){return d=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n},d.apply(this,arguments)};function h(n,t,e,r){return new(e||(e=Promise))((function(o,i){function u(n){try{a(r.next(n))}catch(n){i(n)}}function c(n){try{a(r.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?o(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,c)}a((r=r.apply(n,t||[])).next())}))}function l(n,t){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(n,i)}catch(n){c=[6,n],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}"function"==typeof SuppressedError&&SuppressedError;var v={width:1,height:1},w=function(){var n=t(d({},v)),r=n[0],o=n[1];return e((function(){var n=function(){o({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",n),n(),function(){return window.removeEventListener("resize",n)}}),[]),r},p=function(t,e){n.useEffect((function(){var n=function(n){n.keyCode===t&&e()};return document.addEventListener("keydown",n),function(){document.removeEventListener("keydown",n)}}),[e])},m=function(n){return new Promise((function(t,e){var r=new Image;r.onload=function(){t(r)},r.onerror=r.onabort=function(){e(n)},r.src=n}))},g=function(n){var r=t(!1),o=r[0],i=r[1];return e((function(){var t=!1;return function(){h(this,void 0,void 0,(function(){var e,r,o,u;return l(this,(function(c){switch(c.label){case 0:if(t)return[2];for(e=[],r=0,o=n;r<o.length;r++)u=o[r],e.push(m(u));return[4,Promise.all(e)];case 1:return c.sent(),t?[2]:(i(!0),[2])}}))}))}(),function(){t=!0}}),[n]),{imagesPreloaded:o}};export{i as useElementSize,u as useHover,g as useImagePreloader,c as useOnClickOutside,p as useOnPressKey,a as usePersistedState,f as usePrevious,s as useTimer,w as useWindowSize};
@@ -1,9 +1,9 @@
1
- export { default as useElementSize } from "./useElementSize";
2
- export { default as useHover } from "./useHover";
3
- export { default as useOnClickOutside } from "./useOnClickOutside";
4
- export { default as usePersistedState } from "./usePersistedState";
5
- export { default as usePrevious } from "./usePrevious";
6
- export { default as useTimer } from "./useTimer";
7
- export { default as useWindowSize } from "./useWindowSize";
8
- export { default as useOnPressKey } from "./useOnPressKey";
9
- export { default as useImagePreloader } from "./useImagePreloader";
1
+ export { default as useElementSize } from "./useElementSize";
2
+ export { default as useHover } from "./useHover";
3
+ export { default as useOnClickOutside } from "./useOnClickOutside";
4
+ export { default as usePersistedState } from "./usePersistedState";
5
+ export { default as usePrevious } from "./usePrevious";
6
+ export { default as useTimer } from "./useTimer";
7
+ export { default as useWindowSize } from "./useWindowSize";
8
+ export { default as useOnPressKey } from "./useOnPressKey";
9
+ export { default as useImagePreloader } from "./useImagePreloader";
@@ -1,3 +1,3 @@
1
- import { useElementSizeProps } from './useElementSize.types';
2
- declare const useElementSize: useElementSizeProps;
3
- export default useElementSize;
1
+ import { useElementSizeProps } from './useElementSize.types';
2
+ declare const useElementSize: useElementSizeProps;
3
+ export default useElementSize;
@@ -1,18 +1,18 @@
1
- export interface useElementSizeProps {
2
- (ref: any, forceRefresh?: number): {
3
- width: number;
4
- height: number;
5
- position: {
6
- x: number;
7
- y: number;
8
- left: number;
9
- right: number;
10
- top: number;
11
- bottom: number;
12
- };
13
- screen: {
14
- width: number;
15
- height: number;
16
- };
17
- };
18
- }
1
+ export interface useElementSizeProps {
2
+ (ref: any, forceRefresh?: number): {
3
+ width: number;
4
+ height: number;
5
+ position: {
6
+ x: number;
7
+ y: number;
8
+ left: number;
9
+ right: number;
10
+ top: number;
11
+ bottom: number;
12
+ };
13
+ screen: {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ };
18
+ }
@@ -1,3 +1,3 @@
1
- import { useHoverProps } from './useHover.types';
2
- declare const useHover: useHoverProps;
3
- export default useHover;
1
+ import { useHoverProps } from './useHover.types';
2
+ declare const useHover: useHoverProps;
3
+ export default useHover;
@@ -1,5 +1,5 @@
1
- export interface useHoverProps {
2
- (ref: any): {
3
- show: boolean;
4
- };
5
- }
1
+ export interface useHoverProps {
2
+ (ref: any): {
3
+ show: boolean;
4
+ };
5
+ }
@@ -1,3 +1,3 @@
1
- import { useImagePreloaderProps } from './useImagePreloader.types';
2
- declare const useImagePreloader: useImagePreloaderProps;
3
- export default useImagePreloader;
1
+ import { useImagePreloaderProps } from './useImagePreloader.types';
2
+ declare const useImagePreloader: useImagePreloaderProps;
3
+ export default useImagePreloader;
@@ -1,3 +1,3 @@
1
- export interface useImagePreloaderProps {
2
- (srcImgs: Array<string>): object;
3
- }
1
+ export interface useImagePreloaderProps {
2
+ (srcImgs: Array<string>): object;
3
+ }
@@ -1,3 +1,3 @@
1
- import { useOnClickOutsideProps } from './useOnClickOutside.types';
2
- declare const useOnClickOutside: useOnClickOutsideProps;
3
- export default useOnClickOutside;
1
+ import { useOnClickOutsideProps } from './useOnClickOutside.types';
2
+ declare const useOnClickOutside: useOnClickOutsideProps;
3
+ export default useOnClickOutside;
@@ -1,3 +1,3 @@
1
- export interface useOnClickOutsideProps {
2
- (ref: any, handler: any): void;
3
- }
1
+ export interface useOnClickOutsideProps {
2
+ (ref: any, handler: any): void;
3
+ }
@@ -1,3 +1,3 @@
1
- import { useOnPressKeyProps } from './useOnPressKey.types';
2
- declare const useOnPressKey: useOnPressKeyProps;
3
- export default useOnPressKey;
1
+ import { useOnPressKeyProps } from './useOnPressKey.types';
2
+ declare const useOnPressKey: useOnPressKeyProps;
3
+ export default useOnPressKey;
@@ -1,3 +1,3 @@
1
- export interface useOnPressKeyProps {
2
- (keyAsc: number, action: any): void;
3
- }
1
+ export interface useOnPressKeyProps {
2
+ (keyAsc: number, action: any): void;
3
+ }
@@ -1,3 +1,3 @@
1
- import { usePersistedStateProps } from './usePersistedState.types';
2
- declare const usePersistedState: usePersistedStateProps;
3
- export default usePersistedState;
1
+ import { usePersistedStateProps } from './usePersistedState.types';
2
+ declare const usePersistedState: usePersistedStateProps;
3
+ export default usePersistedState;
@@ -1,3 +1,3 @@
1
- export interface usePersistedStateProps {
2
- (key: string, initialState: any): Array<any>;
3
- }
1
+ export interface usePersistedStateProps {
2
+ (key: string, initialState: any): Array<any>;
3
+ }
@@ -1,3 +1,3 @@
1
- import { usePreviousProps } from './usePrevious.types';
2
- declare const usePrevious: usePreviousProps;
3
- export default usePrevious;
1
+ import { usePreviousProps } from './usePrevious.types';
2
+ declare const usePrevious: usePreviousProps;
3
+ export default usePrevious;
@@ -1,3 +1,3 @@
1
- export interface usePreviousProps {
2
- (value: any): any;
3
- }
1
+ export interface usePreviousProps {
2
+ (value: any): any;
3
+ }
@@ -1,3 +1,3 @@
1
- import { useTimerProps } from './useTimer.types';
2
- declare const useTimer: useTimerProps;
3
- export default useTimer;
1
+ import { useTimerProps } from './useTimer.types';
2
+ declare const useTimer: useTimerProps;
3
+ export default useTimer;
@@ -1,6 +1,6 @@
1
- export interface useTimerProps {
2
- (initialMinutes: number, initialSeconds: number, reset: number): {
3
- minutes: number;
4
- seconds: number;
5
- };
6
- }
1
+ export interface useTimerProps {
2
+ (initialMinutes: number, initialSeconds: number, reset: number): {
3
+ minutes: number;
4
+ seconds: number;
5
+ };
6
+ }
@@ -1,3 +1,3 @@
1
- import { useWindowSizeProps } from "./useWindowSize.props";
2
- declare const useWindowSize: useWindowSizeProps;
3
- export default useWindowSize;
1
+ import { useWindowSizeProps } from "./useWindowSize.props";
2
+ declare const useWindowSize: useWindowSizeProps;
3
+ export default useWindowSize;
@@ -1,6 +1,6 @@
1
- export interface useWindowSizeProps {
2
- (): {
3
- width: number;
4
- height: number;
5
- };
6
- }
1
+ export interface useWindowSizeProps {
2
+ (): {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ }
@@ -1 +1 @@
1
- export * from './hooks';
1
+ export * from './hooks';
package/dist/index.d.ts CHANGED
@@ -1,76 +1,76 @@
1
- interface useElementSizeProps {
2
- (ref: any, forceRefresh?: number): {
3
- width: number;
4
- height: number;
5
- position: {
6
- x: number;
7
- y: number;
8
- left: number;
9
- right: number;
10
- top: number;
11
- bottom: number;
12
- };
13
- screen: {
14
- width: number;
15
- height: number;
16
- };
17
- };
1
+ interface useElementSizeProps {
2
+ (ref: any, forceRefresh?: number): {
3
+ width: number;
4
+ height: number;
5
+ position: {
6
+ x: number;
7
+ y: number;
8
+ left: number;
9
+ right: number;
10
+ top: number;
11
+ bottom: number;
12
+ };
13
+ screen: {
14
+ width: number;
15
+ height: number;
16
+ };
17
+ };
18
18
  }
19
19
 
20
20
  declare const useElementSize: useElementSizeProps;
21
21
 
22
- interface useHoverProps {
23
- (ref: any): {
24
- show: boolean;
25
- };
22
+ interface useHoverProps {
23
+ (ref: any): {
24
+ show: boolean;
25
+ };
26
26
  }
27
27
 
28
28
  declare const useHover: useHoverProps;
29
29
 
30
- interface useOnClickOutsideProps {
31
- (ref: any, handler: any): void;
30
+ interface useOnClickOutsideProps {
31
+ (ref: any, handler: any): void;
32
32
  }
33
33
 
34
34
  declare const useOnClickOutside: useOnClickOutsideProps;
35
35
 
36
- interface usePersistedStateProps {
37
- (key: string, initialState: any): Array<any>;
36
+ interface usePersistedStateProps {
37
+ (key: string, initialState: any): Array<any>;
38
38
  }
39
39
 
40
40
  declare const usePersistedState: usePersistedStateProps;
41
41
 
42
- interface usePreviousProps {
43
- (value: any): any;
42
+ interface usePreviousProps {
43
+ (value: any): any;
44
44
  }
45
45
 
46
46
  declare const usePrevious: usePreviousProps;
47
47
 
48
- interface useTimerProps {
49
- (initialMinutes: number, initialSeconds: number, reset: number): {
50
- minutes: number;
51
- seconds: number;
52
- };
48
+ interface useTimerProps {
49
+ (initialMinutes: number, initialSeconds: number, reset: number): {
50
+ minutes: number;
51
+ seconds: number;
52
+ };
53
53
  }
54
54
 
55
55
  declare const useTimer: useTimerProps;
56
56
 
57
- interface useWindowSizeProps {
58
- (): {
59
- width: number;
60
- height: number;
61
- };
57
+ interface useWindowSizeProps {
58
+ (): {
59
+ width: number;
60
+ height: number;
61
+ };
62
62
  }
63
63
 
64
64
  declare const useWindowSize: useWindowSizeProps;
65
65
 
66
- interface useOnPressKeyProps {
67
- (keyAsc: number, action: any): void;
66
+ interface useOnPressKeyProps {
67
+ (keyAsc: number, action: any): void;
68
68
  }
69
69
 
70
70
  declare const useOnPressKey: useOnPressKeyProps;
71
71
 
72
- interface useImagePreloaderProps {
73
- (srcImgs: Array<string>): object;
72
+ interface useImagePreloaderProps {
73
+ (srcImgs: Array<string>): object;
74
74
  }
75
75
 
76
76
  declare const useImagePreloader: useImagePreloaderProps;
package/package.json CHANGED
@@ -1,52 +1,54 @@
1
- {
2
- "name": "@gadeoli/rjs-hooks-library",
3
- "version": "0.0.21",
4
- "description": "Some hooks for reactJS apps in one place",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "files": [
8
- "dist"
9
- ],
10
- "types": "dist/index.d.ts",
11
- "scripts": {
12
- "prebuild": "rm -rf dist",
13
- "publish": "npm run prebuild && rollup -c && npm publish",
14
- "rollup": "npm run prebuild && rollup -c"
15
- },
16
- "keywords": [
17
- "reactjs",
18
- "waterproofstone"
19
- ],
20
- "author": "gadeoli",
21
- "license": "MIT",
22
- "devDependencies": {
23
- "@rollup/plugin-commonjs": "^22.0.0",
24
- "@rollup/plugin-node-resolve": "^13.3.0",
25
- "@rollup/plugin-typescript": "^8.3.2",
26
- "@testing-library/react": "^13.2.0",
27
- "@types/jest": "^27.5.1",
28
- "@types/react": "^18.0.9",
29
- "identity-obj-proxy": "^3.0.0",
30
- "react": "^18.1.0",
31
- "rollup": "^2.74.1",
32
- "rollup-plugin-dts": "^4.2.1",
33
- "rollup-plugin-peer-deps-external": "^2.2.4",
34
- "rollup-plugin-terser": "^7.0.2",
35
- "typescript": "^4.6.4"
36
- },
37
- "peerDependencies": {
38
- "react": "^18.1.0",
39
- "@gadeoli/js-helpers-library": "~0.0.15"
40
- },
41
- "repository": {
42
- "type": "git",
43
- "url": "git+https://github.com/Gadeoli/rjs-hooks-library.git"
44
- },
45
- "bugs": {
46
- "url": "https://github.com/Gadeoli/rjs-hooks-library/issues"
47
- },
48
- "homepage": "https://github.com/Gadeoli/rjs-hooks-library#readme",
49
- "publishConfig": {
50
- "access": "public"
51
- }
52
- }
1
+ {
2
+ "name": "@gadeoli/rjs-hooks-library",
3
+ "version": "0.2.0",
4
+ "description": "Some hooks for reactJS apps in one place",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "type": "module",
11
+ "types": "dist/index.d.ts",
12
+ "scripts": {
13
+ "prebuild": "rm -rf dist",
14
+ "publish": "npm run prebuild && rollup -c && npm publish",
15
+ "rollup": "npm run prebuild && rollup -c"
16
+ },
17
+ "keywords": [
18
+ "reactjs",
19
+ "hooks",
20
+ "library"
21
+ ],
22
+ "author": "gadeoli",
23
+ "license": "MIT",
24
+ "devDependencies": {
25
+ "@rollup/plugin-commonjs": "^28.0.2",
26
+ "@rollup/plugin-node-resolve": "^16.0.0",
27
+ "@rollup/plugin-terser": "^0.4.4",
28
+ "@rollup/plugin-typescript": "^12.1.2",
29
+ "@testing-library/react": "^16.2.0",
30
+ "@types/jest": "^29.5.14",
31
+ "@types/react": ">=18.3.0",
32
+ "identity-obj-proxy": "^3.0.0",
33
+ "react": ">=18.3.0",
34
+ "rollup": "^4.34.6",
35
+ "rollup-plugin-dts": "^6.1.1",
36
+ "rollup-plugin-peer-deps-external": "^2.2.4",
37
+ "typescript": "^5.7.3"
38
+ },
39
+ "peerDependencies": {
40
+ "react": ">=18.3.0",
41
+ "@gadeoli/js-helpers-library": ">=0.2.0"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/Gadeoli/rjs-hooks-library.git"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/Gadeoli/rjs-hooks-library/issues"
49
+ },
50
+ "homepage": "https://github.com/Gadeoli/rjs-hooks-library#readme",
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }