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

@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.10.2 to 0.10.3

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)},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(o){var i=void 0===o?{}:o,c=i.totalItems,a=void 0===c?0:c,l=i.pageSize,f=void 0===l?20:l,s=i.page,d=void 0===s?1:s,v=i.queryCallback,p=void 0===v?function(){}:v,g=n(a),m=g[0],h=g[1],y=n(Math.max(f,1)),S=y[0],w=y[1],k=n(Math.max(d,1)),x=k[0],b=k[1],E=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}}(m,S,x)},[x,S,m]),I=E.totalPages,P=E.startIndex,N=E.endIndex,M=E.isNextDisabled,O=E.isPreviousDisabled,T=u(function(n){h(Math.max(0,n))},[]),C=u(function(n){w(Math.max(1,n))},[]),D=u(function(n){b(Math.max(1,Math.min(n,I)))},[I]),j=u(function(){D(x+1)},[x,D]),A=u(function(){D(x-1)},[x,D]);r(function(){return function(){T(a)}},[a,T]),r(function(){return function(){C(f)}},[f,C]),r(function(){b(function(n){return Math.max(1,Math.min(n,I))})},[I]);var z=e(p);r(function(){z.current=p},[p]);var L=t(function(){return(0,z.current)({page:x,pageSize:S,totalPages:I,startIndex:P,endIndex:N,isNextDisabled:M,isPreviousDisabled:O})},[x,S,I,P,N,M,O]);return{page:x,pageSize:S,totalPages:I,startIndex:P,endIndex:N,isNextDisabled:M,isPreviousDisabled:O,query:L,setPage:D,setNextPage:j,setPreviousPage:A,setPageSize:C,setTotalItems:T}}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};
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 S(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 y(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"],I={alt:"Alt",ctrl:"Control",control:"Control",shift:"Shift",meta:"Meta",option:"Alt"},x={plus:"+",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",space:" ",esc:"Escape"};function b(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=I[n.toLowerCase()])?r:n;return!!e.getModifierState(o)||e.key===n||e.key===x[n.toLowerCase()]||e.key.length>1&&e.key.toLowerCase()===n.toLowerCase()||e.code===n||!t.ignoreKey&&e.code==="Key"+n.toUpperCase()})}}function E(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 b(n,t)}).some(function(n){return n(e)})}:b(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 z(n){void 0===n&&(n=!1);var t=i(n),e=t[1];return[t[0],e.setTrue,e.setFalse,e.setValue]}function M(o){var i=void 0===o?{}:o,c=i.queryCallback,a=i.totalItems,l=void 0===a?0:a,f=i.pageSize,d=void 0===f?20:f,v=n(1),p=v[0],g=v[1],m=n({totalItems:Math.max(l,0),pageSize:Math.max(d,1)}),h=m[0],S=m[1],y=u(function(n){S(function(t){var e,r;return{pageSize:Math.max(1,null!=(e=n.pageSize)?e:t.pageSize),totalItems:Math.max(0,null!=(r=n.totalItems)?r:t.totalItems)}})},[S]),w=u(function(n){y({totalItems:n})},[y]),k=u(function(n){y({pageSize:n})},[y]),I=e(null!=c?c:function(){});r(function(){y({totalItems:l,pageSize:d})},[l,d,y]),r(function(){I.current=null!=c?c:function(){}},[c]);var x=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}}(h.totalItems,h.pageSize,p)},[p,h]),b=x.totalPages,E=x.startIndex,P=x.endIndex,N=x.isNextDisabled,z=x.isPreviousDisabled,M=u(function(n){g(Math.max(1,Math.min(n,b)))},[b]),O=u(function(){M(p+1)},[p,M]),T=u(function(){M(p-1)},[p,M]);r(function(){g(function(n){return Math.max(1,Math.min(n,b))})},[b]);var C=t(function(){return(0,I.current)(s({page:p},h,{totalPages:b,startIndex:E,endIndex:P,isNextDisabled:N,isPreviousDisabled:z}))},[p,h,b,E,P,N,z]);return{page:p,pageSize:h.pageSize,totalItems:h.totalItems,totalPages:b,startIndex:E,endIndex:P,isNextDisabled:N,isPreviousDisabled:z,query:C,setPage:M,setNextPage:O,setPreviousPage:T,setPageSize:k,setTotalItems:w}}function O(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 T(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 C(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 D(n){return"function"==typeof n}function j(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:D(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,S as useFavicon,y as useHover,w as useInterval,E as useKeyboard,P as useLocalState,N as useMergedRefs,z as useModal,M as usePagination,O as usePoll,T as useTimeout,C as useTitle,j 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)},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]),E=k.totalPages,x=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,E)))},[E]),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,E))})},[E]);var T=e.useRef(f);e.useEffect(function(){T.current=f},[f]);var N=e.useMemo(function(){return(0,T.current)({page:h,pageSize:g,totalPages:E,startIndex:x,endIndex:b,isNextDisabled:w,isPreviousDisabled:C})},[h,g,E,x,b,w,C]);return{page:h,pageSize:g,totalPages:E,startIndex:x,endIndex:b,isNextDisabled:w,isPreviousDisabled:C,query:N,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}]};
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"],l={alt:"Alt",ctrl:"Control",control:"Control",shift:"Shift",meta:"Meta",option:"Alt"},f={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=l[e.toLowerCase()])?r:e;return!!n.getModifierState(o)||n.key===e||n.key===f[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],l=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);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),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],l=n;return"production"!==process.env.NODE_ENV&&(l=function(){u!==i&&console.warn("Components should not switch from uncontrolled to controlled (or vice versa)")}),e.useEffect(l,[l,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,l=r.ignoreKey,f=void 0!==l&&l,v=r.ignoreRepeat,p=void 0!==v&&v,g=e.useMemo(function(){var e={ignoreKey:f,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,f,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],l=e.useRef(t);e.useEffect(function(){var e=l.current;e!==t&&window.localStorage.removeItem(e),l.current=t,null==a?window.localStorage.removeItem(t):window.localStorage.setItem(t,u(a))},[t,a,u]);var f=e.useCallback(function(){window.localStorage.removeItem(t)},[t]);return[a,s,f]},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,o=n.queryCallback,u=n.totalItems,i=void 0===u?0:u,c=n.pageSize,a=void 0===c?20:c,s=e.useState(1),l=s[0],f=s[1],d=e.useState({totalItems:Math.max(i,0),pageSize:Math.max(a,1)}),v=d[0],p=d[1],g=e.useCallback(function(e){p(function(t){var n,r;return{pageSize:Math.max(1,null!=(n=e.pageSize)?n:t.pageSize),totalItems:Math.max(0,null!=(r=e.totalItems)?r:t.totalItems)}})},[p]),m=e.useCallback(function(e){g({totalItems:e})},[g]),S=e.useCallback(function(e){g({pageSize:e})},[g]),h=e.useRef(null!=o?o:function(){});e.useEffect(function(){g({totalItems:i,pageSize:a})},[i,a,g]),e.useEffect(function(){h.current=null!=o?o:function(){}},[o]);var y=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}}(v.totalItems,v.pageSize,l)},[l,v]),k=y.totalPages,x=y.startIndex,E=y.endIndex,b=y.isNextDisabled,w=y.isPreviousDisabled,I=e.useCallback(function(e){f(Math.max(1,Math.min(e,k)))},[k]),C=e.useCallback(function(){I(l+1)},[l,I]),M=e.useCallback(function(){I(l-1)},[l,I]);e.useEffect(function(){f(function(e){return Math.max(1,Math.min(e,k))})},[k]);var P=e.useMemo(function(){return(0,h.current)(r({page:l},v,{totalPages:k,startIndex:x,endIndex:E,isNextDisabled:b,isPreviousDisabled:w}))},[l,v,k,x,E,b,w]);return{page:l,pageSize:v.pageSize,totalItems:v.totalItems,totalPages:k,startIndex:x,endIndex:E,isNextDisabled:b,isPreviousDisabled:w,query:P,setPage:I,setNextPage:C,setPreviousPage:M,setPageSize:S,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)},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.useRef(s);t.useEffect(function(){D.current=s},[s]);var N=t.useMemo(function(){return(0,D.current)({page:S,pageSize:g,totalPages:E,startIndex:b,endIndex:w,isNextDisabled:x,isPreviousDisabled:C})},[S,g,E,b,w,x,C]);return{page:S,pageSize:g,totalPages:E,startIndex:b,endIndex:w,isNextDisabled:x,isPreviousDisabled:C,query:N,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}]}});
!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 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,u=null!=(r=s[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=l,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],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&&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],l=r;return"production"!==process.env.NODE_ENV&&(l=function(){o!==i&&console.warn("Components should not switch from uncontrolled to controlled (or vice versa)")}),t.useEffect(l,[l,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,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!=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],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,o(a))},[e,a,o]);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,r.setValue]},e.usePagination=function(e){var n=void 0===e?{}:e,r=n.queryCallback,o=n.totalItems,i=void 0===o?0:o,c=n.pageSize,a=void 0===c?20:c,f=t.useState(1),l=f[0],s=f[1],d=t.useState({totalItems:Math.max(i,0),pageSize:Math.max(a,1)}),v=d[0],p=d[1],g=t.useCallback(function(e){p(function(t){var n,r;return{pageSize:Math.max(1,null!=(n=e.pageSize)?n:t.pageSize),totalItems:Math.max(0,null!=(r=e.totalItems)?r:t.totalItems)}})},[p]),m=t.useCallback(function(e){g({totalItems:e})},[g]),S=t.useCallback(function(e){g({pageSize:e})},[g]),h=t.useRef(null!=r?r:function(){});t.useEffect(function(){g({totalItems:i,pageSize:a})},[i,a,g]),t.useEffect(function(){h.current=null!=r?r:function(){}},[r]);var y=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}}(v.totalItems,v.pageSize,l)},[l,v]),k=y.totalPages,b=y.startIndex,E=y.endIndex,w=y.isNextDisabled,I=y.isPreviousDisabled,C=t.useCallback(function(e){s(Math.max(1,Math.min(e,k)))},[k]),x=t.useCallback(function(){C(l+1)},[l,C]),M=t.useCallback(function(){C(l-1)},[l,C]);t.useEffect(function(){s(function(e){return Math.max(1,Math.min(e,k))})},[k]);var P=t.useMemo(function(){return(0,h.current)(u({page:l},v,{totalPages:k,startIndex:b,endIndex:E,isNextDisabled:w,isPreviousDisabled:I}))},[l,v,k,b,E,w,I]);return{page:l,pageSize:v.pageSize,totalItems:v.totalItems,totalPages:k,startIndex:b,endIndex:E,isNextDisabled:w,isPreviousDisabled:I,query:P,setPage:C,setNextPage:x,setPreviousPage:M,setPageSize:S,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

@@ -16,2 +16,4 @@ export interface PaginationData {

pageSize: number;
/** The total items */
totalItems: number;
}

@@ -24,6 +26,5 @@ /**

*/
export declare function usePagination<T = void>({ totalItems: startTotalItems, pageSize: startPageSize, page: startPage, queryCallback, }?: Partial<{
export declare function usePagination<T = void>({ queryCallback, totalItems: propTotalItems, pageSize: propPageSize, }?: Partial<{
totalItems: number;
pageSize: number;
page: number;
queryCallback: (data: PaginationData) => T;

@@ -30,0 +31,0 @@ }>): PaginationData & {

{
"version": "0.10.2",
"version": "0.10.3",
"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