Socket
Socket
Sign inDemoInstall

@committed/hooks

Package Overview
Dependencies
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@committed/hooks - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

2

dist/hooks.esm.js

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

import{useState as n,useMemo as t,useRef as e,useEffect as r,useLayoutEffect as o,useCallback as u}from"react";function i(e){void 0===e&&(e=!1);var r=n(e),o=r[1];return[r[0],t(function(){return{toggle:function(){return o(function(n){return!n})},setTrue:function(){return o(!0)},setFalse:function(){return o(!1)}}},[o])]}function c(t){void 0===t&&(t=2e3);var e=n(),r=e[0],o=e[1],u=n(!1),i=u[0],c=u[1],a=n(),l=a[0],f=a[1];return{copy:function(n){try{return"clipboard"in navigator?Promise.resolve(navigator.clipboard.writeText(n).then(function(){return function(n){l&&clearTimeout(l);var e=setTimeout(function(){return c(!1)},t);f(e),c(!0)}()}).catch(function(n){n instanceof Error&&o(n)})):(o(new Error("useClipboard: clipboard is not supported")),Promise.resolve())}catch(n){return Promise.reject(n)}},reset:function(){c(!1),o(void 0),l&&clearTimeout(l)},error:r,copied:i}}function a(){}function l(t,o,u){var i=e(void 0!==t).current,c=void 0!==t,l=n(function(){if(void 0===t&&void 0!==u)return"function"!=typeof u?u:u()}),f=l[0],s=l[1],d=a;return"production"!==process.env.NODE_ENV&&(d=function(){i!==c&&console.warn("Components should not switch from uncontrolled to controlled (or vice versa)")}),r(d,[d,c]),[i?t:f,i?o:s]}function f(t,e){var o=n(t),u=o[0],i=o[1];return r(function(){if(null!==e){var n=setTimeout(function(){i(t)},e);return function(){clearTimeout(n)}}i(t)},[t,e]),[u,function(){return i(t)}]}function s(){return s=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},s.apply(this,arguments)}function d(n,t){var e=Object.keys(s({},n,t)),r={};return e.forEach(function(e){n[""+e]!==t[""+e]&&(r[""+e]={from:n[""+e],to:t[""+e]})}),r}function v(n,t,o){void 0===t&&(t={}),void 0===o&&(o={});var u=e(t),i=e(o);r(function(){if("production"!==process.env.NODE_ENV){var e=d(u.current,t),r=d(i.current,o);Object.keys(s({},e,r)).length&&console.log(n+" updated:","props",e,"state",r),u.current=t,i.current=o}})}function p(n,t,o,u){var i=e();r(function(){i.current=t},[t]),r(function(){var t;if(!0!==u||"production"!==process.env.NODE_ENV){var e=null!=(t=null==o?void 0:o.current)?t:window;return e.addEventListener(n,r),function(){e.removeEventListener(n,r)}}function r(n){var t=i.current;null!=t&&t(n)}},[n,o])}var g={gif:"image/gif",ico:"image/x-icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"};function m(n){var t=n.querySelector("link[rel*='icon']");return null!==t?{type:t.getAttribute("type"),href:t.getAttribute("href")}:null}function h(n,t){if(null===t||null===t.href||null===t.type){var e;null==(e=n.querySelector("link[rel*='icon']"))||e.remove()}else{var r,o=null!=(r=n.querySelector("link[rel*='icon']"))?r:n.createElement("link");o.type=t.type,o.href=t.href,o.rel="shortcut icon",n.getElementsByTagName("head")[0].appendChild(o)}}function y(n,t){void 0===t&&(t={});var r=e(m(document)),u=t.retain,i=void 0!==u&&u;o(function(){return r.current=m(document),i?void 0:function(){h(document,r.current)}},[i]),o(function(){var t,e=n.toLowerCase().split(".").pop();void 0!==(t=e)&&Object.keys(g).includes(t)?h(document,{type:g[e],href:n}):"production"!==process.env.NODE_ENV&&console.warn("Unrecognised image type href: "+n)},[n])}function S(t){var e=n(!1),r=e[0],o=e[1];return p("mouseover",function(){return o(!0)},t),p("mouseout",function(){return o(!1)},t),[r]}function w(n,t){var o=e();r(function(){o.current=n},[n]),r(function(){if(null!==t){var n=setInterval(function(){var n=o.current;null!=n&&n()},t);return function(){return clearInterval(n)}}},[t])}var k=["Alt","Control","Meta","OS","Shift"],x={alt:"Alt",ctrl:"Control",control:"Control",shift:"Shift",meta:"Meta",option:"Alt"},b={plus:"+",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",space:" ",esc:"Escape"};function E(n,t){return""===n?function(){return!0}:function(e){if(t.ignoreRepeat&&e.repeat)return!1;var r=n.split("+").filter(function(n){return n.length>0});return r.length===function(n){var t=0;return k.forEach(function(e){n.getModifierState(e)&&t++}),k.includes(n.key)||t++,t}(e)&&r.every(function(n){var r,o=null!=(r=x[n.toLowerCase()])?r:n;return!!e.getModifierState(o)||e.key===n||e.key===b[n.toLowerCase()]||e.key.length>1&&e.key.toLowerCase()===n.toLowerCase()||e.code===n||!t.ignoreKey&&e.code==="Key"+n.toUpperCase()})}}function I(n,o,i){void 0===i&&(i={});var c=e();r(function(){c.current=o},[o]);var a=i.element,l=i.event,f=void 0===l?"keydown":l,s=i.development,d=i.ignoreKey,v=void 0!==d&&d,g=i.ignoreRepeat,m=void 0!==g&&g,h=t(function(){var t={ignoreKey:v,ignoreRepeat:m};return"function"==typeof n?n:Array.isArray(n)?function(e){return n.map(function(n){return E(n,t)}).some(function(n){return n(e)})}:E(n,t)},[n,v,m]);p(f,u(function(n){null!=c.current&&h(n)&&c.current(n)},[h]),a,s)}function P(t,o,i){var c=void 0===i?{serialize:JSON.stringify,deserialize:JSON.parse}:i,a=c.serialize,l=c.deserialize,f=n(function(){var n=window.localStorage.getItem(t);if(null!=n)try{return l(n)}catch(n){window.localStorage.removeItem(t)}return function(n){return"function"==typeof n}(o)?o():o}),s=f[0],d=f[1],v=e(t);r(function(){var n=v.current;n!==t&&window.localStorage.removeItem(n),v.current=t,null==s?window.localStorage.removeItem(t):window.localStorage.setItem(t,a(s))},[t,s,a]);var p=u(function(){window.localStorage.removeItem(t)},[t]);return[s,d,p]}function N(){var n=[].slice.call(arguments);return t(function(){return n.every(function(n){return null==n})?null:function(t){n.forEach(function(n){"function"==typeof n?n(t):null!=n&&"current"in n&&(n.current=t)})}},n)}function M(n){void 0===n&&(n=!1);var t=i(n),e=t[1];return[t[0],e.setTrue,e.setFalse]}function O(e){var o=void 0===e?{}:e,i=o.totalItems,c=o.page,a=void 0===c?1:c,l=o.pageSize,f=void 0===l?20:l,s=n(void 0===i?0:i),d=s[0],v=s[1],p=n(Math.max(f,1)),g=p[0],m=p[1],h=n(Math.max(a,1)),y=h[0],S=h[1],w=t(function(){return function(n,t,e){var r=Math.ceil(n/t);return{totalPages:r,startIndex:t*(e-1),endIndex:Math.min(n,t*e),isNextDisabled:e===r,isPreviousDisabled:1===e}}(d,g,y)},[y,g,d]),k=w.totalPages,x=w.startIndex,b=w.endIndex,E=w.isNextDisabled,I=w.isPreviousDisabled,P=u(function(n){v(Math.max(0,n))},[]),N=u(function(n){m(Math.max(1,n))},[]),M=u(function(n){S(Math.max(1,Math.min(n,k)))},[k]),O=u(function(){M(y+1)},[y,M]),T=u(function(){M(y-1)},[y,M]);return r(function(){S(function(n){return Math.max(1,Math.min(n,k))})},[k]),{page:y,pageSize:g,totalPages:k,startIndex:x,endIndex:b,isNextDisabled:E,isPreviousDisabled:I,setPage:M,setNextPage:O,setPreviousPage:T,setPageSize:N,setTotalItems:P}}function T(n,t){var o=e();r(function(){o.current=n},[n]),r(function(){var n=null;function e(){null!==t&&(n=setTimeout(r,t))}function r(){var n=function(){var n=o.current,t=void 0;return null!=n&&(t=n()),t}();n instanceof Promise?n.then(e):e()}return r(),function(){n&&clearTimeout(n),n=null}},[t])}function C(n,t){var o=e();r(function(){o.current=n},[n]),r(function(){if(null!==t){var n=setTimeout(function(){var n=o.current;null!=n&&n()},t);return function(){return clearTimeout(n)}}},[t])}function j(n,t){void 0===t&&(t={});var r=t.append,u=void 0!==r&&r,i=t.retain,c=void 0!==i&&i,a=t.separator,l=void 0===a?"":a,f=e(document.title);o(function(){return f.current=document.title,c?void 0:function(){document.title=f.current}},[c]),o(function(){document.title=u?f.current+l+n:n},[n,l,u])}function A(n){return"function"==typeof n}function D(t){var e,r=n({current:(e=t,"function"==typeof e?t():t),undoStack:[],redoStack:[]}),o=r[0],i=r[1],c=u(function(){i(function(n){if(0===n.undoStack.length)return n;var t=n.current,e=n.undoStack,r=n.redoStack;return{current:e[e.length-1],undoStack:e.slice(0,e.length-1),redoStack:[].concat(r,[t])}})},[]),a=u(function(){i(function(n){if(0===n.redoStack.length)return n;var t=n.redoStack;return{current:t[t.length-1],undoStack:[].concat(n.undoStack,[n.current]),redoStack:t.slice(0,t.length-1)}})},[]),l=u(function(n){i(function(t){var e=t.current,r=t.undoStack;return{current:A(n)?n(e):n,undoStack:[].concat(r,[e]),redoStack:[]}})},[]);return[o.current,l,{undo:c,redo:a,canUndo:o.undoStack.length>0,canRedo:o.redoStack.length>0}]}export{k as KEYBOARD_MODIFIERS,i as useBoolean,c as useClipboard,l as useControllableState,f as useDebounce,v as useDebug,p as useEventListener,y as useFavicon,S as useHover,w as useInterval,I as useKeyboard,P as useLocalState,N as useMergedRefs,M as useModal,O as usePagination,T as usePoll,C as useTimeout,j as useTitle,D as useTrackedState};
import{useState as n,useMemo as t,useRef as e,useEffect as r,useLayoutEffect as o,useCallback as u}from"react";function i(e){void 0===e&&(e=!1);var r=n(e),o=r[1];return[r[0],t(function(){return{toggle:function(){return o(function(n){return!n})},setTrue:function(){return o(!0)},setFalse:function(){return o(!1)},setValue:o}},[o])]}function c(t){void 0===t&&(t=2e3);var e=n(),r=e[0],o=e[1],u=n(!1),i=u[0],c=u[1],a=n(),l=a[0],f=a[1];return{copy:function(n){try{return"clipboard"in navigator?Promise.resolve(navigator.clipboard.writeText(n).then(function(){return function(n){l&&clearTimeout(l);var e=setTimeout(function(){return c(!1)},t);f(e),c(!0)}()}).catch(function(n){n instanceof Error&&o(n)})):(o(new Error("useClipboard: clipboard is not supported")),Promise.resolve())}catch(n){return Promise.reject(n)}},reset:function(){c(!1),o(void 0),l&&clearTimeout(l)},error:r,copied:i}}function a(){}function l(t,o,u){var i=e(void 0!==t).current,c=void 0!==t,l=n(function(){if(void 0===t&&void 0!==u)return"function"!=typeof u?u:u()}),f=l[0],s=l[1],d=a;return"production"!==process.env.NODE_ENV&&(d=function(){i!==c&&console.warn("Components should not switch from uncontrolled to controlled (or vice versa)")}),r(d,[d,c]),[i?t:f,i?o:s]}function f(t,e){var o=n(t),u=o[0],i=o[1];return r(function(){if(null!==e){var n=setTimeout(function(){i(t)},e);return function(){clearTimeout(n)}}i(t)},[t,e]),[u,function(){return i(t)}]}function s(){return s=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},s.apply(this,arguments)}function d(n,t){var e=Object.keys(s({},n,t)),r={};return e.forEach(function(e){n[""+e]!==t[""+e]&&(r[""+e]={from:n[""+e],to:t[""+e]})}),r}function v(n,t,o){void 0===t&&(t={}),void 0===o&&(o={});var u=e(t),i=e(o);r(function(){if("production"!==process.env.NODE_ENV){var e=d(u.current,t),r=d(i.current,o);Object.keys(s({},e,r)).length&&console.log(n+" updated:","props",e,"state",r),u.current=t,i.current=o}})}function p(n,t,o,u){var i=e();r(function(){i.current=t},[t]),r(function(){var t;if(!0!==u||"production"!==process.env.NODE_ENV){var e=null!=(t=null==o?void 0:o.current)?t:window;return e.addEventListener(n,r),function(){e.removeEventListener(n,r)}}function r(n){var t=i.current;null!=t&&t(n)}},[n,o])}var g={gif:"image/gif",ico:"image/x-icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"};function m(n){var t=n.querySelector("link[rel*='icon']");return null!==t?{type:t.getAttribute("type"),href:t.getAttribute("href")}:null}function h(n,t){if(null===t||null===t.href||null===t.type){var e;null==(e=n.querySelector("link[rel*='icon']"))||e.remove()}else{var r,o=null!=(r=n.querySelector("link[rel*='icon']"))?r:n.createElement("link");o.type=t.type,o.href=t.href,o.rel="shortcut icon",n.getElementsByTagName("head")[0].appendChild(o)}}function y(n,t){void 0===t&&(t={});var r=e(m(document)),u=t.retain,i=void 0!==u&&u;o(function(){return r.current=m(document),i?void 0:function(){h(document,r.current)}},[i]),o(function(){var t,e=n.toLowerCase().split(".").pop();void 0!==(t=e)&&Object.keys(g).includes(t)?h(document,{type:g[e],href:n}):"production"!==process.env.NODE_ENV&&console.warn("Unrecognised image type href: "+n)},[n])}function S(t){var e=n(!1),r=e[0],o=e[1];return p("mouseover",function(){return o(!0)},t),p("mouseout",function(){return o(!1)},t),[r]}function w(n,t){var o=e();r(function(){o.current=n},[n]),r(function(){if(null!==t){var n=setInterval(function(){var n=o.current;null!=n&&n()},t);return function(){return clearInterval(n)}}},[t])}var k=["Alt","Control","Meta","OS","Shift"],x={alt:"Alt",ctrl:"Control",control:"Control",shift:"Shift",meta:"Meta",option:"Alt"},b={plus:"+",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",space:" ",esc:"Escape"};function E(n,t){return""===n?function(){return!0}:function(e){if(t.ignoreRepeat&&e.repeat)return!1;var r=n.split("+").filter(function(n){return n.length>0});return r.length===function(n){var t=0;return k.forEach(function(e){n.getModifierState(e)&&t++}),k.includes(n.key)||t++,t}(e)&&r.every(function(n){var r,o=null!=(r=x[n.toLowerCase()])?r:n;return!!e.getModifierState(o)||e.key===n||e.key===b[n.toLowerCase()]||e.key.length>1&&e.key.toLowerCase()===n.toLowerCase()||e.code===n||!t.ignoreKey&&e.code==="Key"+n.toUpperCase()})}}function I(n,o,i){void 0===i&&(i={});var c=e();r(function(){c.current=o},[o]);var a=i.element,l=i.event,f=void 0===l?"keydown":l,s=i.development,d=i.ignoreKey,v=void 0!==d&&d,g=i.ignoreRepeat,m=void 0!==g&&g,h=t(function(){var t={ignoreKey:v,ignoreRepeat:m};return"function"==typeof n?n:Array.isArray(n)?function(e){return n.map(function(n){return E(n,t)}).some(function(n){return n(e)})}:E(n,t)},[n,v,m]);p(f,u(function(n){null!=c.current&&h(n)&&c.current(n)},[h]),a,s)}function P(t,o,i){var c=void 0===i?{serialize:JSON.stringify,deserialize:JSON.parse}:i,a=c.serialize,l=c.deserialize,f=n(function(){var n=window.localStorage.getItem(t);if(null!=n)try{return l(n)}catch(n){window.localStorage.removeItem(t)}return function(n){return"function"==typeof n}(o)?o():o}),s=f[0],d=f[1],v=e(t);r(function(){var n=v.current;n!==t&&window.localStorage.removeItem(n),v.current=t,null==s?window.localStorage.removeItem(t):window.localStorage.setItem(t,a(s))},[t,s,a]);var p=u(function(){window.localStorage.removeItem(t)},[t]);return[s,d,p]}function N(){var n=[].slice.call(arguments);return t(function(){return n.every(function(n){return null==n})?null:function(t){n.forEach(function(n){"function"==typeof n?n(t):null!=n&&"current"in n&&(n.current=t)})}},n)}function M(n){void 0===n&&(n=!1);var t=i(n),e=t[1];return[t[0],e.setTrue,e.setFalse,e.setValue]}function O(e){var o=void 0===e?{}:e,i=o.totalItems,c=void 0===i?0:i,a=o.pageSize,l=void 0===a?20:a,f=o.page,s=void 0===f?1:f,d=o.queryCallback,v=void 0===d?function(){}:d,p=n(c),g=p[0],m=p[1],h=n(Math.max(l,1)),y=h[0],S=h[1],w=n(Math.max(s,1)),k=w[0],x=w[1],b=t(function(){return function(n,t,e){var r=Math.ceil(n/t);return{totalPages:r,startIndex:t*(e-1),endIndex:Math.min(n,t*e),isNextDisabled:e===r,isPreviousDisabled:1===e}}(g,y,k)},[k,y,g]),E=b.totalPages,I=b.startIndex,P=b.endIndex,N=b.isNextDisabled,M=b.isPreviousDisabled,O=u(function(n){m(Math.max(0,n))},[]),T=u(function(n){S(Math.max(1,n))},[]),C=u(function(n){x(Math.max(1,Math.min(n,E)))},[E]),D=u(function(){C(k+1)},[k,C]),j=u(function(){C(k-1)},[k,C]);r(function(){return function(){O(c)}},[c,O]),r(function(){return function(){T(l)}},[l,T]),r(function(){x(function(n){return Math.max(1,Math.min(n,E))})},[E]);var A=t(function(){return v({page:k,pageSize:y,totalPages:E,startIndex:I,endIndex:P,isNextDisabled:N,isPreviousDisabled:M})},[v,k,y,E,I,P,N,M]);return{page:k,pageSize:y,totalPages:E,startIndex:I,endIndex:P,isNextDisabled:N,isPreviousDisabled:M,query:A,setPage:C,setNextPage:D,setPreviousPage:j,setPageSize:T,setTotalItems:O}}function T(n,t){var o=e();r(function(){o.current=n},[n]),r(function(){var n=null;function e(){null!==t&&(n=setTimeout(r,t))}function r(){var n=function(){var n=o.current,t=void 0;return null!=n&&(t=n()),t}();n instanceof Promise?n.then(e):e()}return r(),function(){n&&clearTimeout(n),n=null}},[t])}function C(n,t){var o=e();r(function(){o.current=n},[n]),r(function(){if(null!==t){var n=setTimeout(function(){var n=o.current;null!=n&&n()},t);return function(){return clearTimeout(n)}}},[t])}function D(n,t){void 0===t&&(t={});var r=t.append,u=void 0!==r&&r,i=t.retain,c=void 0!==i&&i,a=t.separator,l=void 0===a?"":a,f=e(document.title);o(function(){return f.current=document.title,c?void 0:function(){document.title=f.current}},[c]),o(function(){document.title=u?f.current+l+n:n},[n,l,u])}function j(n){return"function"==typeof n}function A(t){var e,r=n({current:(e=t,"function"==typeof e?t():t),undoStack:[],redoStack:[]}),o=r[0],i=r[1],c=u(function(){i(function(n){if(0===n.undoStack.length)return n;var t=n.current,e=n.undoStack,r=n.redoStack;return{current:e[e.length-1],undoStack:e.slice(0,e.length-1),redoStack:[].concat(r,[t])}})},[]),a=u(function(){i(function(n){if(0===n.redoStack.length)return n;var t=n.redoStack;return{current:t[t.length-1],undoStack:[].concat(n.undoStack,[n.current]),redoStack:t.slice(0,t.length-1)}})},[]),l=u(function(n){i(function(t){var e=t.current,r=t.undoStack;return{current:j(n)?n(e):n,undoStack:[].concat(r,[e]),redoStack:[]}})},[]);return[o.current,l,{undo:c,redo:a,canUndo:o.undoStack.length>0,canRedo:o.redoStack.length>0}]}export{k as KEYBOARD_MODIFIERS,i as useBoolean,c as useClipboard,l as useControllableState,f as useDebounce,v as useDebug,p as useEventListener,y as useFavicon,S as useHover,w as useInterval,I as useKeyboard,P as useLocalState,N as useMergedRefs,M as useModal,O as usePagination,T as usePoll,C as useTimeout,D as useTitle,A as useTrackedState};
//# sourceMappingURL=hooks.esm.js.map

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

var e=require("react");function t(t){void 0===t&&(t=!1);var n=e.useState(t),r=n[1];return[n[0],e.useMemo(function(){return{toggle:function(){return r(function(e){return!e})},setTrue:function(){return r(!0)},setFalse:function(){return r(!1)}}},[r])]}function n(){}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r.apply(this,arguments)}function o(e,t){var n=Object.keys(r({},e,t)),o={};return n.forEach(function(n){e[""+n]!==t[""+n]&&(o[""+n]={from:e[""+n],to:t[""+n]})}),o}function u(t,n,r,o){var u=e.useRef();e.useEffect(function(){u.current=n},[n]),e.useEffect(function(){var e;if(!0!==o||"production"!==process.env.NODE_ENV){var n=null!=(e=null==r?void 0:r.current)?e:window;return n.addEventListener(t,i),function(){n.removeEventListener(t,i)}}function i(e){var t=u.current;null!=t&&t(e)}},[t,r])}var i={gif:"image/gif",ico:"image/x-icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"};function c(e){var t=e.querySelector("link[rel*='icon']");return null!==t?{type:t.getAttribute("type"),href:t.getAttribute("href")}:null}function a(e,t){if(null===t||null===t.href||null===t.type){var n;null==(n=e.querySelector("link[rel*='icon']"))||n.remove()}else{var r,o=null!=(r=e.querySelector("link[rel*='icon']"))?r:e.createElement("link");o.type=t.type,o.href=t.href,o.rel="shortcut icon",e.getElementsByTagName("head")[0].appendChild(o)}}var s=["Alt","Control","Meta","OS","Shift"],f={alt:"Alt",ctrl:"Control",control:"Control",shift:"Shift",meta:"Meta",option:"Alt"},l={plus:"+",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",space:" ",esc:"Escape"};function d(e,t){return""===e?function(){return!0}:function(n){if(t.ignoreRepeat&&n.repeat)return!1;var r=e.split("+").filter(function(e){return e.length>0});return r.length===function(e){var t=0;return s.forEach(function(n){e.getModifierState(n)&&t++}),s.includes(e.key)||t++,t}(n)&&r.every(function(e){var r,o=null!=(r=f[e.toLowerCase()])?r:e;return!!n.getModifierState(o)||n.key===e||n.key===l[e.toLowerCase()]||n.key.length>1&&n.key.toLowerCase()===e.toLowerCase()||n.code===e||!t.ignoreKey&&n.code==="Key"+e.toUpperCase()})}}function v(e){return"function"==typeof e}exports.KEYBOARD_MODIFIERS=s,exports.useBoolean=t,exports.useClipboard=function(t){void 0===t&&(t=2e3);var n=e.useState(),r=n[0],o=n[1],u=e.useState(!1),i=u[0],c=u[1],a=e.useState(),s=a[0],f=a[1];return{copy:function(e){try{return"clipboard"in navigator?Promise.resolve(navigator.clipboard.writeText(e).then(function(){return function(e){s&&clearTimeout(s);var n=setTimeout(function(){return c(!1)},t);f(n),c(!0)}()}).catch(function(e){e instanceof Error&&o(e)})):(o(new Error("useClipboard: clipboard is not supported")),Promise.resolve())}catch(e){return Promise.reject(e)}},reset:function(){c(!1),o(void 0),s&&clearTimeout(s)},error:r,copied:i}},exports.useControllableState=function(t,r,o){var u=e.useRef(void 0!==t).current,i=void 0!==t,c=e.useState(function(){if(void 0===t&&void 0!==o)return"function"!=typeof o?o:o()}),a=c[0],s=c[1],f=n;return"production"!==process.env.NODE_ENV&&(f=function(){u!==i&&console.warn("Components should not switch from uncontrolled to controlled (or vice versa)")}),e.useEffect(f,[f,i]),[u?t:a,u?r:s]},exports.useDebounce=function(t,n){var r=e.useState(t),o=r[0],u=r[1];return e.useEffect(function(){if(null!==n){var e=setTimeout(function(){u(t)},n);return function(){clearTimeout(e)}}u(t)},[t,n]),[o,function(){return u(t)}]},exports.useDebug=function(t,n,u){void 0===n&&(n={}),void 0===u&&(u={});var i=e.useRef(n),c=e.useRef(u);e.useEffect(function(){if("production"!==process.env.NODE_ENV){var e=o(i.current,n),a=o(c.current,u);Object.keys(r({},e,a)).length&&console.log(t+" updated:","props",e,"state",a),i.current=n,c.current=u}})},exports.useEventListener=u,exports.useFavicon=function(t,n){void 0===n&&(n={});var r=e.useRef(c(document)),o=n.retain,u=void 0!==o&&o;e.useLayoutEffect(function(){return r.current=c(document),u?void 0:function(){a(document,r.current)}},[u]),e.useLayoutEffect(function(){var e,n=t.toLowerCase().split(".").pop();void 0!==(e=n)&&Object.keys(i).includes(e)?a(document,{type:i[n],href:t}):"production"!==process.env.NODE_ENV&&console.warn("Unrecognised image type href: "+t)},[t])},exports.useHover=function(t){var n=e.useState(!1),r=n[0],o=n[1];return u("mouseover",function(){return o(!0)},t),u("mouseout",function(){return o(!1)},t),[r]},exports.useInterval=function(t,n){var r=e.useRef();e.useEffect(function(){r.current=t},[t]),e.useEffect(function(){if(null!==n){var e=setInterval(function(){var e=r.current;null!=e&&e()},n);return function(){return clearInterval(e)}}},[n])},exports.useKeyboard=function(t,n,r){void 0===r&&(r={});var o=e.useRef();e.useEffect(function(){o.current=n},[n]);var i=r.element,c=r.event,a=void 0===c?"keydown":c,s=r.development,f=r.ignoreKey,l=void 0!==f&&f,v=r.ignoreRepeat,p=void 0!==v&&v,g=e.useMemo(function(){var e={ignoreKey:l,ignoreRepeat:p};return"function"==typeof t?t:Array.isArray(t)?function(n){return t.map(function(t){return d(t,e)}).some(function(e){return e(n)})}:d(t,e)},[t,l,p]);u(a,e.useCallback(function(e){null!=o.current&&g(e)&&o.current(e)},[g]),i,s)},exports.useLocalState=function(t,n,r){var o=void 0===r?{serialize:JSON.stringify,deserialize:JSON.parse}:r,u=o.serialize,i=o.deserialize,c=e.useState(function(){var e=window.localStorage.getItem(t);if(null!=e)try{return i(e)}catch(e){window.localStorage.removeItem(t)}return function(e){return"function"==typeof e}(n)?n():n}),a=c[0],s=c[1],f=e.useRef(t);e.useEffect(function(){var e=f.current;e!==t&&window.localStorage.removeItem(e),f.current=t,null==a?window.localStorage.removeItem(t):window.localStorage.setItem(t,u(a))},[t,a,u]);var l=e.useCallback(function(){window.localStorage.removeItem(t)},[t]);return[a,s,l]},exports.useMergedRefs=function(){var t=[].slice.call(arguments);return e.useMemo(function(){return t.every(function(e){return null==e})?null:function(e){t.forEach(function(t){"function"==typeof t?t(e):null!=t&&"current"in t&&(t.current=e)})}},t)},exports.useModal=function(e){void 0===e&&(e=!1);var n=t(e),r=n[1];return[n[0],r.setTrue,r.setFalse]},exports.usePagination=function(t){var n=void 0===t?{}:t,r=n.totalItems,o=n.page,u=void 0===o?1:o,i=n.pageSize,c=void 0===i?20:i,a=e.useState(void 0===r?0:r),s=a[0],f=a[1],l=e.useState(Math.max(c,1)),d=l[0],v=l[1],p=e.useState(Math.max(u,1)),g=p[0],m=p[1],S=e.useMemo(function(){return function(e,t,n){var r=Math.ceil(e/t);return{totalPages:r,startIndex:t*(n-1),endIndex:Math.min(e,t*n),isNextDisabled:n===r,isPreviousDisabled:1===n}}(s,d,g)},[g,d,s]),h=S.totalPages,y=S.startIndex,k=S.endIndex,E=S.isNextDisabled,x=S.isPreviousDisabled,b=e.useCallback(function(e){f(Math.max(0,e))},[]),w=e.useCallback(function(e){v(Math.max(1,e))},[]),C=e.useCallback(function(e){m(Math.max(1,Math.min(e,h)))},[h]),M=e.useCallback(function(){C(g+1)},[g,C]),I=e.useCallback(function(){C(g-1)},[g,C]);return e.useEffect(function(){m(function(e){return Math.max(1,Math.min(e,h))})},[h]),{page:g,pageSize:d,totalPages:h,startIndex:y,endIndex:k,isNextDisabled:E,isPreviousDisabled:x,setPage:C,setNextPage:M,setPreviousPage:I,setPageSize:w,setTotalItems:b}},exports.usePoll=function(t,n){var r=e.useRef();e.useEffect(function(){r.current=t},[t]),e.useEffect(function(){var e=null;function t(){null!==n&&(e=setTimeout(o,n))}function o(){var e=function(){var e=r.current,t=void 0;return null!=e&&(t=e()),t}();e instanceof Promise?e.then(t):t()}return o(),function(){e&&clearTimeout(e),e=null}},[n])},exports.useTimeout=function(t,n){var r=e.useRef();e.useEffect(function(){r.current=t},[t]),e.useEffect(function(){if(null!==n){var e=setTimeout(function(){var e=r.current;null!=e&&e()},n);return function(){return clearTimeout(e)}}},[n])},exports.useTitle=function(t,n){void 0===n&&(n={});var r=n.append,o=void 0!==r&&r,u=n.retain,i=void 0!==u&&u,c=n.separator,a=void 0===c?"":c,s=e.useRef(document.title);e.useLayoutEffect(function(){return s.current=document.title,i?void 0:function(){document.title=s.current}},[i]),e.useLayoutEffect(function(){document.title=o?s.current+a+t:t},[t,a,o])},exports.useTrackedState=function(t){var n,r=e.useState({current:(n=t,"function"==typeof n?t():t),undoStack:[],redoStack:[]}),o=r[0],u=r[1],i=e.useCallback(function(){u(function(e){if(0===e.undoStack.length)return e;var t=e.current,n=e.undoStack,r=e.redoStack;return{current:n[n.length-1],undoStack:n.slice(0,n.length-1),redoStack:[].concat(r,[t])}})},[]),c=e.useCallback(function(){u(function(e){if(0===e.redoStack.length)return e;var t=e.redoStack;return{current:t[t.length-1],undoStack:[].concat(e.undoStack,[e.current]),redoStack:t.slice(0,t.length-1)}})},[]),a=e.useCallback(function(e){u(function(t){var n=t.current,r=t.undoStack;return{current:v(e)?e(n):e,undoStack:[].concat(r,[n]),redoStack:[]}})},[]);return[o.current,a,{undo:i,redo:c,canUndo:o.undoStack.length>0,canRedo:o.redoStack.length>0}]};
var e=require("react");function t(t){void 0===t&&(t=!1);var n=e.useState(t),r=n[1];return[n[0],e.useMemo(function(){return{toggle:function(){return r(function(e){return!e})},setTrue:function(){return r(!0)},setFalse:function(){return r(!1)},setValue:r}},[r])]}function n(){}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r.apply(this,arguments)}function o(e,t){var n=Object.keys(r({},e,t)),o={};return n.forEach(function(n){e[""+n]!==t[""+n]&&(o[""+n]={from:e[""+n],to:t[""+n]})}),o}function u(t,n,r,o){var u=e.useRef();e.useEffect(function(){u.current=n},[n]),e.useEffect(function(){var e;if(!0!==o||"production"!==process.env.NODE_ENV){var n=null!=(e=null==r?void 0:r.current)?e:window;return n.addEventListener(t,i),function(){n.removeEventListener(t,i)}}function i(e){var t=u.current;null!=t&&t(e)}},[t,r])}var i={gif:"image/gif",ico:"image/x-icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"};function c(e){var t=e.querySelector("link[rel*='icon']");return null!==t?{type:t.getAttribute("type"),href:t.getAttribute("href")}:null}function a(e,t){if(null===t||null===t.href||null===t.type){var n;null==(n=e.querySelector("link[rel*='icon']"))||n.remove()}else{var r,o=null!=(r=e.querySelector("link[rel*='icon']"))?r:e.createElement("link");o.type=t.type,o.href=t.href,o.rel="shortcut icon",e.getElementsByTagName("head")[0].appendChild(o)}}var s=["Alt","Control","Meta","OS","Shift"],f={alt:"Alt",ctrl:"Control",control:"Control",shift:"Shift",meta:"Meta",option:"Alt"},l={plus:"+",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",space:" ",esc:"Escape"};function d(e,t){return""===e?function(){return!0}:function(n){if(t.ignoreRepeat&&n.repeat)return!1;var r=e.split("+").filter(function(e){return e.length>0});return r.length===function(e){var t=0;return s.forEach(function(n){e.getModifierState(n)&&t++}),s.includes(e.key)||t++,t}(n)&&r.every(function(e){var r,o=null!=(r=f[e.toLowerCase()])?r:e;return!!n.getModifierState(o)||n.key===e||n.key===l[e.toLowerCase()]||n.key.length>1&&n.key.toLowerCase()===e.toLowerCase()||n.code===e||!t.ignoreKey&&n.code==="Key"+e.toUpperCase()})}}function v(e){return"function"==typeof e}exports.KEYBOARD_MODIFIERS=s,exports.useBoolean=t,exports.useClipboard=function(t){void 0===t&&(t=2e3);var n=e.useState(),r=n[0],o=n[1],u=e.useState(!1),i=u[0],c=u[1],a=e.useState(),s=a[0],f=a[1];return{copy:function(e){try{return"clipboard"in navigator?Promise.resolve(navigator.clipboard.writeText(e).then(function(){return function(e){s&&clearTimeout(s);var n=setTimeout(function(){return c(!1)},t);f(n),c(!0)}()}).catch(function(e){e instanceof Error&&o(e)})):(o(new Error("useClipboard: clipboard is not supported")),Promise.resolve())}catch(e){return Promise.reject(e)}},reset:function(){c(!1),o(void 0),s&&clearTimeout(s)},error:r,copied:i}},exports.useControllableState=function(t,r,o){var u=e.useRef(void 0!==t).current,i=void 0!==t,c=e.useState(function(){if(void 0===t&&void 0!==o)return"function"!=typeof o?o:o()}),a=c[0],s=c[1],f=n;return"production"!==process.env.NODE_ENV&&(f=function(){u!==i&&console.warn("Components should not switch from uncontrolled to controlled (or vice versa)")}),e.useEffect(f,[f,i]),[u?t:a,u?r:s]},exports.useDebounce=function(t,n){var r=e.useState(t),o=r[0],u=r[1];return e.useEffect(function(){if(null!==n){var e=setTimeout(function(){u(t)},n);return function(){clearTimeout(e)}}u(t)},[t,n]),[o,function(){return u(t)}]},exports.useDebug=function(t,n,u){void 0===n&&(n={}),void 0===u&&(u={});var i=e.useRef(n),c=e.useRef(u);e.useEffect(function(){if("production"!==process.env.NODE_ENV){var e=o(i.current,n),a=o(c.current,u);Object.keys(r({},e,a)).length&&console.log(t+" updated:","props",e,"state",a),i.current=n,c.current=u}})},exports.useEventListener=u,exports.useFavicon=function(t,n){void 0===n&&(n={});var r=e.useRef(c(document)),o=n.retain,u=void 0!==o&&o;e.useLayoutEffect(function(){return r.current=c(document),u?void 0:function(){a(document,r.current)}},[u]),e.useLayoutEffect(function(){var e,n=t.toLowerCase().split(".").pop();void 0!==(e=n)&&Object.keys(i).includes(e)?a(document,{type:i[n],href:t}):"production"!==process.env.NODE_ENV&&console.warn("Unrecognised image type href: "+t)},[t])},exports.useHover=function(t){var n=e.useState(!1),r=n[0],o=n[1];return u("mouseover",function(){return o(!0)},t),u("mouseout",function(){return o(!1)},t),[r]},exports.useInterval=function(t,n){var r=e.useRef();e.useEffect(function(){r.current=t},[t]),e.useEffect(function(){if(null!==n){var e=setInterval(function(){var e=r.current;null!=e&&e()},n);return function(){return clearInterval(e)}}},[n])},exports.useKeyboard=function(t,n,r){void 0===r&&(r={});var o=e.useRef();e.useEffect(function(){o.current=n},[n]);var i=r.element,c=r.event,a=void 0===c?"keydown":c,s=r.development,f=r.ignoreKey,l=void 0!==f&&f,v=r.ignoreRepeat,p=void 0!==v&&v,g=e.useMemo(function(){var e={ignoreKey:l,ignoreRepeat:p};return"function"==typeof t?t:Array.isArray(t)?function(n){return t.map(function(t){return d(t,e)}).some(function(e){return e(n)})}:d(t,e)},[t,l,p]);u(a,e.useCallback(function(e){null!=o.current&&g(e)&&o.current(e)},[g]),i,s)},exports.useLocalState=function(t,n,r){var o=void 0===r?{serialize:JSON.stringify,deserialize:JSON.parse}:r,u=o.serialize,i=o.deserialize,c=e.useState(function(){var e=window.localStorage.getItem(t);if(null!=e)try{return i(e)}catch(e){window.localStorage.removeItem(t)}return function(e){return"function"==typeof e}(n)?n():n}),a=c[0],s=c[1],f=e.useRef(t);e.useEffect(function(){var e=f.current;e!==t&&window.localStorage.removeItem(e),f.current=t,null==a?window.localStorage.removeItem(t):window.localStorage.setItem(t,u(a))},[t,a,u]);var l=e.useCallback(function(){window.localStorage.removeItem(t)},[t]);return[a,s,l]},exports.useMergedRefs=function(){var t=[].slice.call(arguments);return e.useMemo(function(){return t.every(function(e){return null==e})?null:function(e){t.forEach(function(t){"function"==typeof t?t(e):null!=t&&"current"in t&&(t.current=e)})}},t)},exports.useModal=function(e){void 0===e&&(e=!1);var n=t(e),r=n[1];return[n[0],r.setTrue,r.setFalse,r.setValue]},exports.usePagination=function(t){var n=void 0===t?{}:t,r=n.totalItems,o=void 0===r?0:r,u=n.pageSize,i=void 0===u?20:u,c=n.page,a=void 0===c?1:c,s=n.queryCallback,f=void 0===s?function(){}:s,l=e.useState(o),d=l[0],v=l[1],p=e.useState(Math.max(i,1)),g=p[0],m=p[1],S=e.useState(Math.max(a,1)),h=S[0],y=S[1],k=e.useMemo(function(){return function(e,t,n){var r=Math.ceil(e/t);return{totalPages:r,startIndex:t*(n-1),endIndex:Math.min(e,t*n),isNextDisabled:n===r,isPreviousDisabled:1===n}}(d,g,h)},[h,g,d]),x=k.totalPages,E=k.startIndex,b=k.endIndex,w=k.isNextDisabled,C=k.isPreviousDisabled,M=e.useCallback(function(e){v(Math.max(0,e))},[]),I=e.useCallback(function(e){m(Math.max(1,e))},[]),P=e.useCallback(function(e){y(Math.max(1,Math.min(e,x)))},[x]),R=e.useCallback(function(){P(h+1)},[h,P]),D=e.useCallback(function(){P(h-1)},[h,P]);e.useEffect(function(){return function(){M(o)}},[o,M]),e.useEffect(function(){return function(){I(i)}},[i,I]),e.useEffect(function(){y(function(e){return Math.max(1,Math.min(e,x))})},[x]);var T=e.useMemo(function(){return f({page:h,pageSize:g,totalPages:x,startIndex:E,endIndex:b,isNextDisabled:w,isPreviousDisabled:C})},[f,h,g,x,E,b,w,C]);return{page:h,pageSize:g,totalPages:x,startIndex:E,endIndex:b,isNextDisabled:w,isPreviousDisabled:C,query:T,setPage:P,setNextPage:R,setPreviousPage:D,setPageSize:I,setTotalItems:M}},exports.usePoll=function(t,n){var r=e.useRef();e.useEffect(function(){r.current=t},[t]),e.useEffect(function(){var e=null;function t(){null!==n&&(e=setTimeout(o,n))}function o(){var e=function(){var e=r.current,t=void 0;return null!=e&&(t=e()),t}();e instanceof Promise?e.then(t):t()}return o(),function(){e&&clearTimeout(e),e=null}},[n])},exports.useTimeout=function(t,n){var r=e.useRef();e.useEffect(function(){r.current=t},[t]),e.useEffect(function(){if(null!==n){var e=setTimeout(function(){var e=r.current;null!=e&&e()},n);return function(){return clearTimeout(e)}}},[n])},exports.useTitle=function(t,n){void 0===n&&(n={});var r=n.append,o=void 0!==r&&r,u=n.retain,i=void 0!==u&&u,c=n.separator,a=void 0===c?"":c,s=e.useRef(document.title);e.useLayoutEffect(function(){return s.current=document.title,i?void 0:function(){document.title=s.current}},[i]),e.useLayoutEffect(function(){document.title=o?s.current+a+t:t},[t,a,o])},exports.useTrackedState=function(t){var n,r=e.useState({current:(n=t,"function"==typeof n?t():t),undoStack:[],redoStack:[]}),o=r[0],u=r[1],i=e.useCallback(function(){u(function(e){if(0===e.undoStack.length)return e;var t=e.current,n=e.undoStack,r=e.redoStack;return{current:n[n.length-1],undoStack:n.slice(0,n.length-1),redoStack:[].concat(r,[t])}})},[]),c=e.useCallback(function(){u(function(e){if(0===e.redoStack.length)return e;var t=e.redoStack;return{current:t[t.length-1],undoStack:[].concat(e.undoStack,[e.current]),redoStack:t.slice(0,t.length-1)}})},[]),a=e.useCallback(function(e){u(function(t){var n=t.current,r=t.undoStack;return{current:v(e)?e(n):e,undoStack:[].concat(r,[n]),redoStack:[]}})},[]);return[o.current,a,{undo:i,redo:c,canUndo:o.undoStack.length>0,canRedo:o.redoStack.length>0}]};
//# sourceMappingURL=hooks.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e||self).hooks={},e.react)}(this,function(e,t){function n(e){void 0===e&&(e=!1);var n=t.useState(e),r=n[1];return[n[0],t.useMemo(function(){return{toggle:function(){return r(function(e){return!e})},setTrue:function(){return r(!0)},setFalse:function(){return r(!1)}}},[r])]}function r(){}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function u(e,t){var n=Object.keys(o({},e,t)),r={};return n.forEach(function(n){e[""+n]!==t[""+n]&&(r[""+n]={from:e[""+n],to:t[""+n]})}),r}function i(e,n,r,o){var u=t.useRef();t.useEffect(function(){u.current=n},[n]),t.useEffect(function(){var t;if(!0!==o||"production"!==process.env.NODE_ENV){var n=null!=(t=null==r?void 0:r.current)?t:window;return n.addEventListener(e,i),function(){n.removeEventListener(e,i)}}function i(e){var t=u.current;null!=t&&t(e)}},[e,r])}var c={gif:"image/gif",ico:"image/x-icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"};function a(e){var t=e.querySelector("link[rel*='icon']");return null!==t?{type:t.getAttribute("type"),href:t.getAttribute("href")}:null}function f(e,t){if(null===t||null===t.href||null===t.type){var n;null==(n=e.querySelector("link[rel*='icon']"))||n.remove()}else{var r,o=null!=(r=e.querySelector("link[rel*='icon']"))?r:e.createElement("link");o.type=t.type,o.href=t.href,o.rel="shortcut icon",e.getElementsByTagName("head")[0].appendChild(o)}}var l=["Alt","Control","Meta","OS","Shift"],s={alt:"Alt",ctrl:"Control",control:"Control",shift:"Shift",meta:"Meta",option:"Alt"},d={plus:"+",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",space:" ",esc:"Escape"};function v(e,t){return""===e?function(){return!0}:function(n){if(t.ignoreRepeat&&n.repeat)return!1;var r=e.split("+").filter(function(e){return e.length>0});return r.length===function(e){var t=0;return l.forEach(function(n){e.getModifierState(n)&&t++}),l.includes(e.key)||t++,t}(n)&&r.every(function(e){var r,o=null!=(r=s[e.toLowerCase()])?r:e;return!!n.getModifierState(o)||n.key===e||n.key===d[e.toLowerCase()]||n.key.length>1&&n.key.toLowerCase()===e.toLowerCase()||n.code===e||!t.ignoreKey&&n.code==="Key"+e.toUpperCase()})}}function p(e){return"function"==typeof e}e.KEYBOARD_MODIFIERS=l,e.useBoolean=n,e.useClipboard=function(e){void 0===e&&(e=2e3);var n=t.useState(),r=n[0],o=n[1],u=t.useState(!1),i=u[0],c=u[1],a=t.useState(),f=a[0],l=a[1];return{copy:function(t){try{return"clipboard"in navigator?Promise.resolve(navigator.clipboard.writeText(t).then(function(){return function(t){f&&clearTimeout(f);var n=setTimeout(function(){return c(!1)},e);l(n),c(!0)}()}).catch(function(e){e instanceof Error&&o(e)})):(o(new Error("useClipboard: clipboard is not supported")),Promise.resolve())}catch(e){return Promise.reject(e)}},reset:function(){c(!1),o(void 0),f&&clearTimeout(f)},error:r,copied:i}},e.useControllableState=function(e,n,o){var u=t.useRef(void 0!==e).current,i=void 0!==e,c=t.useState(function(){if(void 0===e&&void 0!==o)return"function"!=typeof o?o:o()}),a=c[0],f=c[1],l=r;return"production"!==process.env.NODE_ENV&&(l=function(){u!==i&&console.warn("Components should not switch from uncontrolled to controlled (or vice versa)")}),t.useEffect(l,[l,i]),[u?e:a,u?n:f]},e.useDebounce=function(e,n){var r=t.useState(e),o=r[0],u=r[1];return t.useEffect(function(){if(null!==n){var t=setTimeout(function(){u(e)},n);return function(){clearTimeout(t)}}u(e)},[e,n]),[o,function(){return u(e)}]},e.useDebug=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r={});var i=t.useRef(n),c=t.useRef(r);t.useEffect(function(){if("production"!==process.env.NODE_ENV){var t=u(i.current,n),a=u(c.current,r);Object.keys(o({},t,a)).length&&console.log(e+" updated:","props",t,"state",a),i.current=n,c.current=r}})},e.useEventListener=i,e.useFavicon=function(e,n){void 0===n&&(n={});var r=t.useRef(a(document)),o=n.retain,u=void 0!==o&&o;t.useLayoutEffect(function(){return r.current=a(document),u?void 0:function(){f(document,r.current)}},[u]),t.useLayoutEffect(function(){var t,n=e.toLowerCase().split(".").pop();void 0!==(t=n)&&Object.keys(c).includes(t)?f(document,{type:c[n],href:e}):"production"!==process.env.NODE_ENV&&console.warn("Unrecognised image type href: "+e)},[e])},e.useHover=function(e){var n=t.useState(!1),r=n[0],o=n[1];return i("mouseover",function(){return o(!0)},e),i("mouseout",function(){return o(!1)},e),[r]},e.useInterval=function(e,n){var r=t.useRef();t.useEffect(function(){r.current=e},[e]),t.useEffect(function(){if(null!==n){var e=setInterval(function(){var e=r.current;null!=e&&e()},n);return function(){return clearInterval(e)}}},[n])},e.useKeyboard=function(e,n,r){void 0===r&&(r={});var o=t.useRef();t.useEffect(function(){o.current=n},[n]);var u=r.element,c=r.event,a=void 0===c?"keydown":c,f=r.development,l=r.ignoreKey,s=void 0!==l&&l,d=r.ignoreRepeat,p=void 0!==d&&d,g=t.useMemo(function(){var t={ignoreKey:s,ignoreRepeat:p};return"function"==typeof e?e:Array.isArray(e)?function(n){return e.map(function(e){return v(e,t)}).some(function(e){return e(n)})}:v(e,t)},[e,s,p]);i(a,t.useCallback(function(e){null!=o.current&&g(e)&&o.current(e)},[g]),u,f)},e.useLocalState=function(e,n,r){var o=void 0===r?{serialize:JSON.stringify,deserialize:JSON.parse}:r,u=o.serialize,i=o.deserialize,c=t.useState(function(){var t=window.localStorage.getItem(e);if(null!=t)try{return i(t)}catch(t){window.localStorage.removeItem(e)}return function(e){return"function"==typeof e}(n)?n():n}),a=c[0],f=c[1],l=t.useRef(e);t.useEffect(function(){var t=l.current;t!==e&&window.localStorage.removeItem(t),l.current=e,null==a?window.localStorage.removeItem(e):window.localStorage.setItem(e,u(a))},[e,a,u]);var s=t.useCallback(function(){window.localStorage.removeItem(e)},[e]);return[a,f,s]},e.useMergedRefs=function(){var e=[].slice.call(arguments);return t.useMemo(function(){return e.every(function(e){return null==e})?null:function(t){e.forEach(function(e){"function"==typeof e?e(t):null!=e&&"current"in e&&(e.current=t)})}},e)},e.useModal=function(e){void 0===e&&(e=!1);var t=n(e),r=t[1];return[t[0],r.setTrue,r.setFalse]},e.usePagination=function(e){var n=void 0===e?{}:e,r=n.totalItems,o=n.page,u=void 0===o?1:o,i=n.pageSize,c=void 0===i?20:i,a=t.useState(void 0===r?0:r),f=a[0],l=a[1],s=t.useState(Math.max(c,1)),d=s[0],v=s[1],p=t.useState(Math.max(u,1)),g=p[0],m=p[1],h=t.useMemo(function(){return function(e,t,n){var r=Math.ceil(e/t);return{totalPages:r,startIndex:t*(n-1),endIndex:Math.min(e,t*n),isNextDisabled:n===r,isPreviousDisabled:1===n}}(f,d,g)},[g,d,f]),S=h.totalPages,y=h.startIndex,k=h.endIndex,E=h.isNextDisabled,b=h.isPreviousDisabled,w=t.useCallback(function(e){l(Math.max(0,e))},[]),C=t.useCallback(function(e){v(Math.max(1,e))},[]),x=t.useCallback(function(e){m(Math.max(1,Math.min(e,S)))},[S]),M=t.useCallback(function(){x(g+1)},[g,x]),I=t.useCallback(function(){x(g-1)},[g,x]);return t.useEffect(function(){m(function(e){return Math.max(1,Math.min(e,S))})},[S]),{page:g,pageSize:d,totalPages:S,startIndex:y,endIndex:k,isNextDisabled:E,isPreviousDisabled:b,setPage:x,setNextPage:M,setPreviousPage:I,setPageSize:C,setTotalItems:w}},e.usePoll=function(e,n){var r=t.useRef();t.useEffect(function(){r.current=e},[e]),t.useEffect(function(){var e=null;function t(){null!==n&&(e=setTimeout(o,n))}function o(){var e=function(){var e=r.current,t=void 0;return null!=e&&(t=e()),t}();e instanceof Promise?e.then(t):t()}return o(),function(){e&&clearTimeout(e),e=null}},[n])},e.useTimeout=function(e,n){var r=t.useRef();t.useEffect(function(){r.current=e},[e]),t.useEffect(function(){if(null!==n){var e=setTimeout(function(){var e=r.current;null!=e&&e()},n);return function(){return clearTimeout(e)}}},[n])},e.useTitle=function(e,n){void 0===n&&(n={});var r=n.append,o=void 0!==r&&r,u=n.retain,i=void 0!==u&&u,c=n.separator,a=void 0===c?"":c,f=t.useRef(document.title);t.useLayoutEffect(function(){return f.current=document.title,i?void 0:function(){document.title=f.current}},[i]),t.useLayoutEffect(function(){document.title=o?f.current+a+e:e},[e,a,o])},e.useTrackedState=function(e){var n,r=t.useState({current:(n=e,"function"==typeof n?e():e),undoStack:[],redoStack:[]}),o=r[0],u=r[1],i=t.useCallback(function(){u(function(e){if(0===e.undoStack.length)return e;var t=e.current,n=e.undoStack,r=e.redoStack;return{current:n[n.length-1],undoStack:n.slice(0,n.length-1),redoStack:[].concat(r,[t])}})},[]),c=t.useCallback(function(){u(function(e){if(0===e.redoStack.length)return e;var t=e.redoStack;return{current:t[t.length-1],undoStack:[].concat(e.undoStack,[e.current]),redoStack:t.slice(0,t.length-1)}})},[]),a=t.useCallback(function(e){u(function(t){var n=t.current,r=t.undoStack;return{current:p(e)?e(n):e,undoStack:[].concat(r,[n]),redoStack:[]}})},[]);return[o.current,a,{undo:i,redo:c,canUndo:o.undoStack.length>0,canRedo:o.redoStack.length>0}]}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e||self).hooks={},e.react)}(this,function(e,t){function n(e){void 0===e&&(e=!1);var n=t.useState(e),r=n[1];return[n[0],t.useMemo(function(){return{toggle:function(){return r(function(e){return!e})},setTrue:function(){return r(!0)},setFalse:function(){return r(!1)},setValue:r}},[r])]}function r(){}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u.apply(this,arguments)}function o(e,t){var n=Object.keys(u({},e,t)),r={};return n.forEach(function(n){e[""+n]!==t[""+n]&&(r[""+n]={from:e[""+n],to:t[""+n]})}),r}function i(e,n,r,u){var o=t.useRef();t.useEffect(function(){o.current=n},[n]),t.useEffect(function(){var t;if(!0!==u||"production"!==process.env.NODE_ENV){var n=null!=(t=null==r?void 0:r.current)?t:window;return n.addEventListener(e,i),function(){n.removeEventListener(e,i)}}function i(e){var t=o.current;null!=t&&t(e)}},[e,r])}var c={gif:"image/gif",ico:"image/x-icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"};function a(e){var t=e.querySelector("link[rel*='icon']");return null!==t?{type:t.getAttribute("type"),href:t.getAttribute("href")}:null}function f(e,t){if(null===t||null===t.href||null===t.type){var n;null==(n=e.querySelector("link[rel*='icon']"))||n.remove()}else{var r,u=null!=(r=e.querySelector("link[rel*='icon']"))?r:e.createElement("link");u.type=t.type,u.href=t.href,u.rel="shortcut icon",e.getElementsByTagName("head")[0].appendChild(u)}}var s=["Alt","Control","Meta","OS","Shift"],l={alt:"Alt",ctrl:"Control",control:"Control",shift:"Shift",meta:"Meta",option:"Alt"},d={plus:"+",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",space:" ",esc:"Escape"};function v(e,t){return""===e?function(){return!0}:function(n){if(t.ignoreRepeat&&n.repeat)return!1;var r=e.split("+").filter(function(e){return e.length>0});return r.length===function(e){var t=0;return s.forEach(function(n){e.getModifierState(n)&&t++}),s.includes(e.key)||t++,t}(n)&&r.every(function(e){var r,u=null!=(r=l[e.toLowerCase()])?r:e;return!!n.getModifierState(u)||n.key===e||n.key===d[e.toLowerCase()]||n.key.length>1&&n.key.toLowerCase()===e.toLowerCase()||n.code===e||!t.ignoreKey&&n.code==="Key"+e.toUpperCase()})}}function p(e){return"function"==typeof e}e.KEYBOARD_MODIFIERS=s,e.useBoolean=n,e.useClipboard=function(e){void 0===e&&(e=2e3);var n=t.useState(),r=n[0],u=n[1],o=t.useState(!1),i=o[0],c=o[1],a=t.useState(),f=a[0],s=a[1];return{copy:function(t){try{return"clipboard"in navigator?Promise.resolve(navigator.clipboard.writeText(t).then(function(){return function(t){f&&clearTimeout(f);var n=setTimeout(function(){return c(!1)},e);s(n),c(!0)}()}).catch(function(e){e instanceof Error&&u(e)})):(u(new Error("useClipboard: clipboard is not supported")),Promise.resolve())}catch(e){return Promise.reject(e)}},reset:function(){c(!1),u(void 0),f&&clearTimeout(f)},error:r,copied:i}},e.useControllableState=function(e,n,u){var o=t.useRef(void 0!==e).current,i=void 0!==e,c=t.useState(function(){if(void 0===e&&void 0!==u)return"function"!=typeof u?u:u()}),a=c[0],f=c[1],s=r;return"production"!==process.env.NODE_ENV&&(s=function(){o!==i&&console.warn("Components should not switch from uncontrolled to controlled (or vice versa)")}),t.useEffect(s,[s,i]),[o?e:a,o?n:f]},e.useDebounce=function(e,n){var r=t.useState(e),u=r[0],o=r[1];return t.useEffect(function(){if(null!==n){var t=setTimeout(function(){o(e)},n);return function(){clearTimeout(t)}}o(e)},[e,n]),[u,function(){return o(e)}]},e.useDebug=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r={});var i=t.useRef(n),c=t.useRef(r);t.useEffect(function(){if("production"!==process.env.NODE_ENV){var t=o(i.current,n),a=o(c.current,r);Object.keys(u({},t,a)).length&&console.log(e+" updated:","props",t,"state",a),i.current=n,c.current=r}})},e.useEventListener=i,e.useFavicon=function(e,n){void 0===n&&(n={});var r=t.useRef(a(document)),u=n.retain,o=void 0!==u&&u;t.useLayoutEffect(function(){return r.current=a(document),o?void 0:function(){f(document,r.current)}},[o]),t.useLayoutEffect(function(){var t,n=e.toLowerCase().split(".").pop();void 0!==(t=n)&&Object.keys(c).includes(t)?f(document,{type:c[n],href:e}):"production"!==process.env.NODE_ENV&&console.warn("Unrecognised image type href: "+e)},[e])},e.useHover=function(e){var n=t.useState(!1),r=n[0],u=n[1];return i("mouseover",function(){return u(!0)},e),i("mouseout",function(){return u(!1)},e),[r]},e.useInterval=function(e,n){var r=t.useRef();t.useEffect(function(){r.current=e},[e]),t.useEffect(function(){if(null!==n){var e=setInterval(function(){var e=r.current;null!=e&&e()},n);return function(){return clearInterval(e)}}},[n])},e.useKeyboard=function(e,n,r){void 0===r&&(r={});var u=t.useRef();t.useEffect(function(){u.current=n},[n]);var o=r.element,c=r.event,a=void 0===c?"keydown":c,f=r.development,s=r.ignoreKey,l=void 0!==s&&s,d=r.ignoreRepeat,p=void 0!==d&&d,g=t.useMemo(function(){var t={ignoreKey:l,ignoreRepeat:p};return"function"==typeof e?e:Array.isArray(e)?function(n){return e.map(function(e){return v(e,t)}).some(function(e){return e(n)})}:v(e,t)},[e,l,p]);i(a,t.useCallback(function(e){null!=u.current&&g(e)&&u.current(e)},[g]),o,f)},e.useLocalState=function(e,n,r){var u=void 0===r?{serialize:JSON.stringify,deserialize:JSON.parse}:r,o=u.serialize,i=u.deserialize,c=t.useState(function(){var t=window.localStorage.getItem(e);if(null!=t)try{return i(t)}catch(t){window.localStorage.removeItem(e)}return function(e){return"function"==typeof e}(n)?n():n}),a=c[0],f=c[1],s=t.useRef(e);t.useEffect(function(){var t=s.current;t!==e&&window.localStorage.removeItem(t),s.current=e,null==a?window.localStorage.removeItem(e):window.localStorage.setItem(e,o(a))},[e,a,o]);var l=t.useCallback(function(){window.localStorage.removeItem(e)},[e]);return[a,f,l]},e.useMergedRefs=function(){var e=[].slice.call(arguments);return t.useMemo(function(){return e.every(function(e){return null==e})?null:function(t){e.forEach(function(e){"function"==typeof e?e(t):null!=e&&"current"in e&&(e.current=t)})}},e)},e.useModal=function(e){void 0===e&&(e=!1);var t=n(e),r=t[1];return[t[0],r.setTrue,r.setFalse,r.setValue]},e.usePagination=function(e){var n=void 0===e?{}:e,r=n.totalItems,u=void 0===r?0:r,o=n.pageSize,i=void 0===o?20:o,c=n.page,a=void 0===c?1:c,f=n.queryCallback,s=void 0===f?function(){}:f,l=t.useState(u),d=l[0],v=l[1],p=t.useState(Math.max(i,1)),g=p[0],m=p[1],h=t.useState(Math.max(a,1)),S=h[0],y=h[1],k=t.useMemo(function(){return function(e,t,n){var r=Math.ceil(e/t);return{totalPages:r,startIndex:t*(n-1),endIndex:Math.min(e,t*n),isNextDisabled:n===r,isPreviousDisabled:1===n}}(d,g,S)},[S,g,d]),E=k.totalPages,b=k.startIndex,w=k.endIndex,x=k.isNextDisabled,C=k.isPreviousDisabled,M=t.useCallback(function(e){v(Math.max(0,e))},[]),I=t.useCallback(function(e){m(Math.max(1,e))},[]),P=t.useCallback(function(e){y(Math.max(1,Math.min(e,E)))},[E]),R=t.useCallback(function(){P(S+1)},[S,P]),T=t.useCallback(function(){P(S-1)},[S,P]);t.useEffect(function(){return function(){M(u)}},[u,M]),t.useEffect(function(){return function(){I(i)}},[i,I]),t.useEffect(function(){y(function(e){return Math.max(1,Math.min(e,E))})},[E]);var D=t.useMemo(function(){return s({page:S,pageSize:g,totalPages:E,startIndex:b,endIndex:w,isNextDisabled:x,isPreviousDisabled:C})},[s,S,g,E,b,w,x,C]);return{page:S,pageSize:g,totalPages:E,startIndex:b,endIndex:w,isNextDisabled:x,isPreviousDisabled:C,query:D,setPage:P,setNextPage:R,setPreviousPage:T,setPageSize:I,setTotalItems:M}},e.usePoll=function(e,n){var r=t.useRef();t.useEffect(function(){r.current=e},[e]),t.useEffect(function(){var e=null;function t(){null!==n&&(e=setTimeout(u,n))}function u(){var e=function(){var e=r.current,t=void 0;return null!=e&&(t=e()),t}();e instanceof Promise?e.then(t):t()}return u(),function(){e&&clearTimeout(e),e=null}},[n])},e.useTimeout=function(e,n){var r=t.useRef();t.useEffect(function(){r.current=e},[e]),t.useEffect(function(){if(null!==n){var e=setTimeout(function(){var e=r.current;null!=e&&e()},n);return function(){return clearTimeout(e)}}},[n])},e.useTitle=function(e,n){void 0===n&&(n={});var r=n.append,u=void 0!==r&&r,o=n.retain,i=void 0!==o&&o,c=n.separator,a=void 0===c?"":c,f=t.useRef(document.title);t.useLayoutEffect(function(){return f.current=document.title,i?void 0:function(){document.title=f.current}},[i]),t.useLayoutEffect(function(){document.title=u?f.current+a+e:e},[e,a,u])},e.useTrackedState=function(e){var n,r=t.useState({current:(n=e,"function"==typeof n?e():e),undoStack:[],redoStack:[]}),u=r[0],o=r[1],i=t.useCallback(function(){o(function(e){if(0===e.undoStack.length)return e;var t=e.current,n=e.undoStack,r=e.redoStack;return{current:n[n.length-1],undoStack:n.slice(0,n.length-1),redoStack:[].concat(r,[t])}})},[]),c=t.useCallback(function(){o(function(e){if(0===e.redoStack.length)return e;var t=e.redoStack;return{current:t[t.length-1],undoStack:[].concat(e.undoStack,[e.current]),redoStack:t.slice(0,t.length-1)}})},[]),a=t.useCallback(function(e){o(function(t){var n=t.current,r=t.undoStack;return{current:p(e)?e(n):e,undoStack:[].concat(r,[n]),redoStack:[]}})},[]);return[u.current,a,{undo:i,redo:c,canUndo:u.undoStack.length>0,canRedo:u.redoStack.length>0}]}});
//# sourceMappingURL=hooks.umd.js.map

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

/// <reference types="react" />
/**

@@ -15,3 +16,4 @@ * Utility hook for boolean state

setFalse: () => void;
setValue: React.Dispatch<React.SetStateAction<boolean>>;
}
];

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

/// <reference types="react" />
/**

@@ -8,2 +9,7 @@ * Utility hook for modal state

*/
export declare function useModal(startState?: boolean): [visible: boolean, show: () => void, hide: () => void];
export declare function useModal(startState?: boolean): [
visible: boolean,
show: () => void,
hide: () => void,
set: React.Dispatch<React.SetStateAction<boolean>>
];

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

/**
* Utility hook for handling pagination state
*
* returns the current page and functions to manipulate.
*
*/
export declare function usePagination({ totalItems: startTotalItems, page: startPage, pageSize: startPageSize, }?: Partial<{
totalItems: number;
page: number;
pageSize: number;
}>): {
export interface PaginationData {
/** The current page */

@@ -26,2 +16,16 @@ page: number;

pageSize: number;
}
/**
* Utility hook for handling pagination state
*
* returns the current page and functions to manipulate.
*
*/
export declare function usePagination<T = void>({ totalItems: startTotalItems, pageSize: startPageSize, page: startPage, queryCallback, }?: Partial<{
totalItems: number;
pageSize: number;
page: number;
queryCallback: (data: PaginationData) => T;
}>): PaginationData & {
query: T;
/** Set the page */

@@ -28,0 +32,0 @@ setPage: (page: number) => void;

{
"version": "0.9.0",
"version": "0.10.0",
"name": "@committed/hooks",

@@ -4,0 +4,0 @@ "description": "Committed hooks library",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc