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

@mantine/hooks

Package Overview
Dependencies
Maintainers
1
Versions
380
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mantine/hooks - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

2

dist/lib.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("nanoid")):"function"==typeof define&&define.amd?define(["react","nanoid"],t):"object"==typeof exports?exports["@mantine/hooks"]=t(require("react"),require("nanoid")):e["@mantine/hooks"]=t(e.react,e.nanoid)}(this,(function(e,t){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useMediaQuery=void 0;var n=r(0);t.useMediaQuery=function(e){var t=n.useState(!1),r=t[0],u=t[1],o=n.useRef();return n.useEffect((function(){if("matchMedia"in window)return o.current=window.matchMedia(e),u(o.current.matches),function(e,t){try{return e.addEventListener("change",t),function(){return e.removeEventListener("change",t)}}catch(r){return e.addListener(t),function(){return e.removeListener(t)}}}(o.current,(function(e){return u(e.matches)}))}),[e]),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useScrollLock=t.useReducedMotion=t.useQueue=t.useMergedRef=t.useMediaQuery=t.useListState=t.useId=t.useForm=t.useDocumentTitle=t.useClipboard=t.useClickOutside=void 0;var n=r(3);Object.defineProperty(t,"useClickOutside",{enumerable:!0,get:function(){return n.useClickOutside}});var u=r(4);Object.defineProperty(t,"useClipboard",{enumerable:!0,get:function(){return u.useClipboard}});var o=r(5);Object.defineProperty(t,"useDocumentTitle",{enumerable:!0,get:function(){return o.useDocumentTitle}});var i=r(6);Object.defineProperty(t,"useForm",{enumerable:!0,get:function(){return i.useForm}});var c=r(7);Object.defineProperty(t,"useId",{enumerable:!0,get:function(){return c.useId}});var s=r(9);Object.defineProperty(t,"useListState",{enumerable:!0,get:function(){return s.useListState}});var a=r(1);Object.defineProperty(t,"useMediaQuery",{enumerable:!0,get:function(){return a.useMediaQuery}});var f=r(10);Object.defineProperty(t,"useMergedRef",{enumerable:!0,get:function(){return f.useMergedRef}});var d=r(11);Object.defineProperty(t,"useQueue",{enumerable:!0,get:function(){return d.useQueue}});var l=r(12);Object.defineProperty(t,"useReducedMotion",{enumerable:!0,get:function(){return l.useReducedMotion}});var v=r(13);Object.defineProperty(t,"useScrollLock",{enumerable:!0,get:function(){return v.useScrollLock}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useClickOutside=void 0;var n=r(0);t.useClickOutside=function(e,t){void 0===t&&(t=["mousedown","touchstart"]);var r=n.useRef();return n.useEffect((function(){var n=function(t){r.current&&!r.current.contains(t.target)&&e()};return t.forEach((function(e){return document.addEventListener(e,n)})),function(){t.forEach((function(e){return document.removeEventListener(e,n)}))}}),[r,e]),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useClipboard=void 0;var n=r(0);t.useClipboard=function(e){var t=(void 0===e?{}:e).timeout,r=void 0===t?2e3:t,u=n.useState(null),o=u[0],i=u[1],c=n.useState(!1),s=c[0],a=c[1],f=n.useState(null),d=f[0],l=f[1];return{copy:function(e){"clipboard"in navigator?navigator.clipboard.writeText(e).then((function(){return e=!0,clearTimeout(d),l(setTimeout((function(){return a(!1)}),r)),void a(e);var e})).catch((function(e){return i(e)})):i(new Error("useClipboard: navigator.clipboard is not supported"))},reset:function(){a(!1),i(null),clearTimeout(d)},error:o,copied:s}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useDocumentTitle=void 0;var n=r(0);t.useDocumentTitle=function(e){n.useLayoutEffect((function(){"string"==typeof e&&e.trim().length>0&&(document.title=e.trim())}),[e])}},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var u in t=arguments[r])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.useForm=void 0;var u=r(0);t.useForm=function(e){var t=e.initialValues,r=e.validationRules,o=void 0===r?{}:r,i=Object.keys(t).reduce((function(e,t){return e[t]=!1,e}),{}),c=u.useState(i),s=c[0],a=c[1],f=u.useState(t),d=f[0],l=f[1],v=function(){return a(i)},p=function(){var e=!0,t=Object.keys(d).reduce((function(t,r){return o&&"function"==typeof o[r]&&!o[r](d[r])?(t[r]=!0,e=!1):t[r]=!1,t}),{});return a(t),e},y=function(e,t){return a((function(r){var u;return n(n({},r),((u={})[e]=t,u))}))};return{values:d,errors:s,validate:p,reset:function(){l(t),v()},setErrors:a,setValues:l,setFieldValue:function(e,t){l((function(r){var u;return n(n({},r),((u={})[e]=t,u))})),y(e,!1)},setFieldError:y,validateField:function(e){return a((function(t){var r;return n(n({},t),((r={})[e]="function"==typeof o[e]&&!o[e](d[e]),r))}))},resetErrors:v,onSubmit:function(e){return function(t){t&&t.preventDefault(),p()&&e(d)}}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useId=void 0;var n=r(0),u=r(8);t.useId=function(e,t){void 0===t&&(t=u.nanoid);var r=n.useRef("mantine-"+t(5));return e||r.current}},function(e,r){e.exports=t},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var u in t=arguments[r])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)},u=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),u=0;for(t=0;t<r;t++)for(var o=arguments[t],i=0,c=o.length;i<c;i++,u++)n[u]=o[i];return n};Object.defineProperty(t,"__esModule",{value:!0}),t.useListState=void 0;var o=r(0);t.useListState=function(e){void 0===e&&(e=[]);var t=o.useState(e),r=t[0],i=t[1];return[r,{setState:i,append:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i((function(t){return u(t,e)}))},prepend:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i((function(t){return u(e,t)}))},insert:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return i((function(r){return u(r.slice(0,e),t,r.slice(e))}))},apply:function(e){return i((function(t){return t.map((function(t,r){return e(t,r)}))}))},remove:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i((function(t){return t.filter((function(t,r){return!e.includes(r)}))}))},reorder:function(e){var t=e.from,r=e.to;return i((function(e){var n=u(e),o=e[t];return n.splice(t,1),n.splice(r,0,o),n}))},setItem:function(e,t){return i((function(r){var n=u(r);return n[e]=t,n}))},setItemProp:function(e,t,r){return i((function(o){var i,c=u(o);return c[e]=n(n({},c[e]),((i={})[t]=r,i)),c}))}}]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useMergedRef=void 0,t.useMergedRef=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){e.forEach((function(e){"function"==typeof e?e(t):e.current=t}))}}},function(e,t,r){"use strict";var n=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),u=0;for(t=0;t<r;t++)for(var o=arguments[t],i=0,c=o.length;i<c;i++,u++)n[u]=o[i];return n};Object.defineProperty(t,"__esModule",{value:!0}),t.useQueue=void 0;var u=r(0);t.useQueue=function(e){var t=e.initialValues,r=void 0===t?[]:t,o=e.limit,i=u.useState({state:r.slice(0,o),queue:r.slice(o)}),c=i[0],s=c.state,a=c.queue,f=i[1];return{state:s,queue:a,add:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return f((function(t){var r=n(t.state,t.queue,e);return{state:r.slice(0,o),queue:r.slice(o)}}))},update:function(e){return f((function(t){var r=e(n(t.state,t.queue));return{state:r.slice(0,o),queue:r.slice(o)}}))},cleanQueue:function(){return f((function(e){return{state:e.state,queue:[]}}))}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useReducedMotion=void 0;var n=r(1);t.useReducedMotion=function(){return n.useMediaQuery("(prefers-reduced-motion: reduce)")}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useScrollLock=void 0;var n=r(0);t.useScrollLock=function(e){var t=n.useRef(null),r=n.useRef(!1),u=function(){r.current&&(r.current=!1,document.body.style.overflow=t.current||"")};n.useEffect((function(){return e?(r.current=!0,t.current=document.body.style.overflow,document.body.style.overflow="hidden"):u(),u}),[e])}}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("nanoid")):"function"==typeof define&&define.amd?define(["react","nanoid"],t):"object"==typeof exports?exports["@mantine/hooks"]=t(require("react"),require("nanoid")):e["@mantine/hooks"]=t(e.react,e.nanoid)}(this,(function(e,t){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useMediaQuery=void 0;var n=r(0);t.useMediaQuery=function(e){var t=n.useState(!1),r=t[0],u=t[1],o=n.useRef();return n.useEffect((function(){if("matchMedia"in window)return o.current=window.matchMedia(e),u(o.current.matches),function(e,t){try{return e.addEventListener("change",t),function(){return e.removeEventListener("change",t)}}catch(r){return e.addListener(t),function(){return e.removeListener(t)}}}(o.current,(function(e){return u(e.matches)}))}),[e]),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useScrollLock=t.useReducedMotion=t.useQueue=t.useMergedRef=t.useMediaQuery=t.useListState=t.useId=t.useForm=t.useDocumentTitle=t.useClipboard=t.useClickOutside=void 0;var n=r(3);Object.defineProperty(t,"useClickOutside",{enumerable:!0,get:function(){return n.useClickOutside}});var u=r(4);Object.defineProperty(t,"useClipboard",{enumerable:!0,get:function(){return u.useClipboard}});var o=r(5);Object.defineProperty(t,"useDocumentTitle",{enumerable:!0,get:function(){return o.useDocumentTitle}});var i=r(6);Object.defineProperty(t,"useForm",{enumerable:!0,get:function(){return i.useForm}});var c=r(7);Object.defineProperty(t,"useId",{enumerable:!0,get:function(){return c.useId}});var s=r(9);Object.defineProperty(t,"useListState",{enumerable:!0,get:function(){return s.useListState}});var a=r(1);Object.defineProperty(t,"useMediaQuery",{enumerable:!0,get:function(){return a.useMediaQuery}});var f=r(10);Object.defineProperty(t,"useMergedRef",{enumerable:!0,get:function(){return f.useMergedRef}});var d=r(11);Object.defineProperty(t,"useQueue",{enumerable:!0,get:function(){return d.useQueue}});var l=r(12);Object.defineProperty(t,"useReducedMotion",{enumerable:!0,get:function(){return l.useReducedMotion}});var v=r(13);Object.defineProperty(t,"useScrollLock",{enumerable:!0,get:function(){return v.useScrollLock}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useClickOutside=void 0;var n=r(0);t.useClickOutside=function(e,t){void 0===t&&(t=["mousedown","touchstart"]);var r=n.useRef();return n.useEffect((function(){var n=function(t){r.current&&!r.current.contains(t.target)&&e()};return t.forEach((function(e){return document.addEventListener(e,n)})),function(){t.forEach((function(e){return document.removeEventListener(e,n)}))}}),[r,e]),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useClipboard=void 0;var n=r(0);t.useClipboard=function(e){var t=(void 0===e?{}:e).timeout,r=void 0===t?2e3:t,u=n.useState(null),o=u[0],i=u[1],c=n.useState(!1),s=c[0],a=c[1],f=n.useState(null),d=f[0],l=f[1];return{copy:function(e){"clipboard"in navigator?navigator.clipboard.writeText(e).then((function(){return e=!0,clearTimeout(d),l(setTimeout((function(){return a(!1)}),r)),void a(e);var e})).catch((function(e){return i(e)})):i(new Error("useClipboard: navigator.clipboard is not supported"))},reset:function(){a(!1),i(null),clearTimeout(d)},error:o,copied:s}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useDocumentTitle=void 0;var n=r(0);t.useDocumentTitle=function(e){n.useLayoutEffect((function(){"string"==typeof e&&e.trim().length>0&&(document.title=e.trim())}),[e])}},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var u in t=arguments[r])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.useForm=void 0;var u=r(0);t.useForm=function(e){var t=e.initialValues,r=e.validationRules,o=void 0===r?{}:r,i=Object.keys(t).reduce((function(e,t){return e[t]=!1,e}),{}),c=u.useState(i),s=c[0],a=c[1],f=u.useState(t),d=f[0],l=f[1],v=function(){return a(i)},p=function(){var e=!0,t=Object.keys(d).reduce((function(t,r){return o&&"function"==typeof o[r]&&!o[r](d[r])?(t[r]=!0,e=!1):t[r]=!1,t}),{});return a(t),e},y=function(e,t){return a((function(r){var u;return n(n({},r),((u={})[e]=t,u))}))};return{values:d,errors:s,validate:p,reset:function(){l(t),v()},setErrors:a,setValues:l,setFieldValue:function(e,t){l((function(r){var u;return n(n({},r),((u={})[e]=t,u))})),y(e,!1)},setFieldError:y,validateField:function(e){return a((function(t){var r;return n(n({},t),((r={})[e]="function"==typeof o[e]&&!o[e](d[e]),r))}))},resetErrors:v,onSubmit:function(e){return function(t){t&&t.preventDefault(),p()&&e(d)}}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useId=void 0;var n=r(0),u=r(8);t.useId=function(e,t){void 0===t&&(t=u.nanoid);var r=n.useRef("mantine-"+t(5));return e||r.current}},function(e,r){e.exports=t},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var u in t=arguments[r])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)},u=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),u=0;for(t=0;t<r;t++)for(var o=arguments[t],i=0,c=o.length;i<c;i++,u++)n[u]=o[i];return n};Object.defineProperty(t,"__esModule",{value:!0}),t.useListState=void 0;var o=r(0);t.useListState=function(e){void 0===e&&(e=[]);var t=o.useState(e),r=t[0],i=t[1];return[r,{setState:i,append:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i((function(t){return u(t,e)}))},prepend:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i((function(t){return u(e,t)}))},insert:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return i((function(r){return u(r.slice(0,e),t,r.slice(e))}))},apply:function(e){return i((function(t){return t.map((function(t,r){return e(t,r)}))}))},remove:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i((function(t){return t.filter((function(t,r){return!e.includes(r)}))}))},reorder:function(e){var t=e.from,r=e.to;return i((function(e){var n=u(e),o=e[t];return n.splice(t,1),n.splice(r,0,o),n}))},setItem:function(e,t){return i((function(r){var n=u(r);return n[e]=t,n}))},setItemProp:function(e,t,r){return i((function(o){var i,c=u(o);return c[e]=n(n({},c[e]),((i={})[t]=r,i)),c}))}}]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useMergedRef=void 0,t.useMergedRef=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){e.forEach((function(e){"function"==typeof e?e(t):null!=e&&(e.current=t)}))}}},function(e,t,r){"use strict";var n=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),u=0;for(t=0;t<r;t++)for(var o=arguments[t],i=0,c=o.length;i<c;i++,u++)n[u]=o[i];return n};Object.defineProperty(t,"__esModule",{value:!0}),t.useQueue=void 0;var u=r(0);t.useQueue=function(e){var t=e.initialValues,r=void 0===t?[]:t,o=e.limit,i=u.useState({state:r.slice(0,o),queue:r.slice(o)}),c=i[0],s=c.state,a=c.queue,f=i[1];return{state:s,queue:a,add:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return f((function(t){var r=n(t.state,t.queue,e);return{state:r.slice(0,o),queue:r.slice(o)}}))},update:function(e){return f((function(t){var r=e(n(t.state,t.queue));return{state:r.slice(0,o),queue:r.slice(o)}}))},cleanQueue:function(){return f((function(e){return{state:e.state,queue:[]}}))}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useReducedMotion=void 0;var n=r(1);t.useReducedMotion=function(){return n.useMediaQuery("(prefers-reduced-motion: reduce)")}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useScrollLock=void 0;var n=r(0);t.useScrollLock=function(e){var t=n.useRef(null),r=n.useRef(!1),u=function(){r.current&&(r.current=!1,document.body.style.overflow=t.current||"")};n.useEffect((function(){return e?(r.current=!0,t.current=document.body.style.overflow,document.body.style.overflow="hidden"):u(),u}),[e])}}])}));
//# sourceMappingURL=lib.js.map
{
"name": "@mantine/hooks",
"version": "0.5.2",
"version": "0.5.3",
"main": "dist/lib.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

@@ -8,3 +8,3 @@ import React from 'react';

ref(node);
} else {
} else if (ref != null) {
// eslint-disable-next-line no-param-reassign

@@ -11,0 +11,0 @@ ref.current = node;

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