Socket
Socket
Sign inDemoInstall

next-themes

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-themes - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13-beta.1

2

dist/index.js

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

function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("react"),n=e(t),r=e(require("next/head")),a=t.createContext({setTheme:function(e){},themes:[]}),o=t.memo(function(e){var t=e.forcedTheme,a=e.storageKey,o=e.attribute,i=e.enableSystem,s=e.defaultTheme,c=e.value,u="class"===o?"var d=document.documentElement.classList;d.remove("+e.attrs.map(function(e){return"'"+e+"'"}).join(",")+");":"var d=document.documentElement;",m=function(e,t){e=(null==c?void 0:c[e])||e;var n=t?e:"'"+e+"'";return"class"===o?"d.add("+n+")":"d.setAttribute('"+o+"', "+n+")"};return n.createElement(r,null,n.createElement("script",t?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){"+u+m(t)+"}()"}}:i?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try {"+u+"var e=localStorage.getItem('"+a+"');if(!e)return localStorage.setItem('"+a+"','"+s+"'),"+m(s)+';if("system"===e){var t="(prefers-color-scheme: dark)",m=window.matchMedia(t);m.media!==t||m.matches?'+m("dark")+":"+m("light")+"}else "+(c?"var x="+JSON.stringify(c)+";":"")+m(c?"x[e]":"e",!0)+"}catch(e){}}()"}}:{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try{"+u+'var t=localStorage.getItem("'+a+'");if(!t)return localStorage.setItem("'+a+'","'+s+'"),'+m(s)+";"+(c?"var x="+JSON.stringify(c)+";":"")+m(c?"x[t]":"t",!0)+"}catch(t){}}();"}}))},function(e,t){return e.forcedTheme===t.forcedTheme}),i=function(e){if("undefined"!=typeof window){var t;try{t=localStorage.getItem(e)||void 0}catch(e){}return t}};exports.ThemeProvider=function(e){var r=e.forcedTheme,s=e.disableTransitionOnChange,c=void 0!==s&&s,u=e.enableSystem,m=void 0===u||u,d=e.storageKey,l=void 0===d?"theme":d,f=e.themes,h=void 0===f?["light","dark"]:f,v=e.defaultTheme,y=void 0===v?"light":v,g=e.attribute,p=void 0===g?"data-theme":g,T=e.value,S=e.children,b=t.useState(function(){return i(l)}),w=b[0],k=b[1],x=t.useState(function(){return i(l)}),E=x[0],C=x[1],L=T?Object.values(T):h,I=t.useCallback(function(e,t){void 0===t&&(t=!0);var n,r=(null==T?void 0:T[e])||e,a=c?((n=document.createElement("style")).appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(n),function(){window.getComputedStyle(n),document.head.removeChild(n)}):null;if(t)try{localStorage.setItem(l,e)}catch(e){}var o,i=document.documentElement;"class"===p?((o=i.classList).remove.apply(o,L),i.classList.add(r)):i.setAttribute(p,r),null==a||a()},[]),_=t.useCallback(function(e){var t=e.matches?"dark":"light";C(t),"system"===w&&I(t,!1)},[w]);t.useEffect(function(){if(m){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addListener(_),_(e),function(){return e.removeListener(_)}}},[_]);var M=t.useCallback(function(e){r||(I(e),k(e))},[]);return t.useEffect(function(){var e=function(e){e.key===l&&M(e.newValue)};return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},[]),n.createElement(a.Provider,{value:{theme:w,setTheme:M,forcedTheme:r,resolvedTheme:"system"===w?E:w,themes:m?[].concat(h,["system"]):h,systemTheme:m?E:void 0}},n.createElement(o,{forcedTheme:r,storageKey:l,attribute:p,value:T,enableSystem:m,defaultTheme:y,attrs:L}),S)},exports.useTheme=function(){return t.useContext(a)};
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("react"),n=e(t),r=e(require("next/head")),o=t.createContext({setTheme:function(e){},themes:[]}),a=t.memo(function(e){var t=e.forcedTheme,o=e.storageKey,a=e.attribute,i=e.enableSystem,s=e.defaultTheme,c=e.value,m="class"===a?"var d=document.documentElement.classList;d.remove("+e.attrs.map(function(e){return"'"+e+"'"}).join(",")+");":"var d=document.documentElement;",u=function(e,t){e=(null==c?void 0:c[e])||e;var n=t?e:"'"+e+"'";return"class"===a?"d.add("+n+")":"d.setAttribute('"+a+"', "+n+")"},d="system"===s;return n.createElement(r,null,n.createElement("script",t?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){"+m+u(t)+"}()"}}:i?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try {"+m+"var e=localStorage.getItem('"+o+"');"+(d?"":u(s)+";")+'if("system"===e||(!e&&'+d+')){var t="(prefers-color-scheme: dark)",m=window.matchMedia(t);m.media!==t||m.matches?'+u("dark")+":"+u("light")+"}else "+(c?"var x="+JSON.stringify(c)+";":"")+u(c?"x[e]":"e",!0)+"}catch(e){}}()"}}:{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try{"+m+'var e=localStorage.getItem("'+o+'");'+(d?"":u(s))+";"+(c?"var x="+JSON.stringify(c)+";":"")+u(c?"x[e]":"e",!0)+"}catch(t){}}();"}}))},function(e,t){return e.forcedTheme===t.forcedTheme}),i=function(e,t){if("undefined"!=typeof window){var n;try{n=localStorage.getItem(e)||void 0}catch(e){}return n||t}};exports.ThemeProvider=function(e){var r=e.forcedTheme,s=e.disableTransitionOnChange,c=void 0!==s&&s,m=e.enableSystem,u=void 0===m||m,d=e.storageKey,l=void 0===d?"theme":d,h=e.themes,f=void 0===h?["light","dark"]:h,v=e.defaultTheme,y=void 0===v?u?"system":"light":v,p=e.attribute,g=void 0===p?"data-theme":p,T=e.value,b=e.children,E=t.useState(function(){return i(l,y)}),k=E[0],S=E[1],w=t.useState(function(){return i(l)}),x=w[0],C=w[1],L=T?Object.values(T):f,I=t.useCallback(function(e,t){void 0===t&&(t=!0);var n,r=(null==T?void 0:T[e])||e,o=c?((n=document.createElement("style")).appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(n),function(){window.getComputedStyle(document.body),setTimeout(function(){document.head.removeChild(n)},1)}):null;if(t)try{localStorage.setItem(l,e)}catch(e){}var a,i=document.documentElement;"class"===g?((a=i.classList).remove.apply(a,L),i.classList.add(r)):i.setAttribute(g,r),null==o||o()},[]),_=t.useCallback(function(e){var t=e.matches?"dark":"light";C(t),"system"===k&&I(t,!1)},[k]);t.useEffect(function(){if(u){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addListener(_),_(e),function(){return e.removeListener(_)}}},[_]);var M=t.useCallback(function(e){r||(I(e),S(e))},[]);return t.useEffect(function(){var e=function(e){e.key===l&&M(e.newValue)};return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},[]),t.useEffect(function(){"light"===k?document.documentElement.style.setProperty("color-scheme","light"):"dark"===k?document.documentElement.style.setProperty("color-scheme","dark"):"system"===k&&x&&document.documentElement.style.setProperty("color-scheme",x)},[k,x]),n.createElement(o.Provider,{value:{theme:k,setTheme:M,forcedTheme:r,resolvedTheme:"system"===k?x:k,themes:u?[].concat(f,["system"]):f,systemTheme:u?x:void 0}},n.createElement(a,{forcedTheme:r,storageKey:l,attribute:g,value:T,enableSystem:u,defaultTheme:y,attrs:L}),b)},exports.useTheme=function(){return t.useContext(o)};

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

import e,{createContext as t,useContext as n,useState as r,useCallback as o,useEffect as a,memo as i}from"react";import m from"next/head";var c=t({setTheme:function(e){},themes:[]}),s=function(){return n(c)},d=function(t){var n=t.forcedTheme,i=t.disableTransitionOnChange,m=void 0!==i&&i,s=t.enableSystem,d=void 0===s||s,f=t.storageKey,v=void 0===f?"theme":f,y=t.themes,g=void 0===y?["light","dark"]:y,p=t.defaultTheme,T=void 0===p?"light":p,S=t.attribute,w=void 0===S?"data-theme":S,b=t.value,k=t.children,x=r(function(){return l(v)}),E=x[0],L=x[1],I=r(function(){return l(v)}),_=I[0],C=I[1],M=b?Object.values(b):g,O=o(function(e,t){void 0===t&&(t=!0);var n=(null==b?void 0:b[e])||e,r=m?h():null;if(t)try{localStorage.setItem(v,e)}catch(e){}var o,a=document.documentElement;"class"===w?((o=a.classList).remove.apply(o,M),a.classList.add(n)):a.setAttribute(w,n),null==r||r()},[]),H=o(function(e){var t=e.matches?"dark":"light";C(t),"system"===E&&O(t,!1)},[E]);a(function(){if(d){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addListener(H),H(e),function(){return e.removeListener(H)}}},[H]);var K=o(function(e){n||(O(e),L(e))},[]);return a(function(){var e=function(e){e.key===v&&K(e.newValue)};return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},[]),e.createElement(c.Provider,{value:{theme:E,setTheme:K,forcedTheme:n,resolvedTheme:"system"===E?_:E,themes:d?[].concat(g,["system"]):g,systemTheme:d?_:void 0}},e.createElement(u,{forcedTheme:n,storageKey:v,attribute:w,value:b,enableSystem:d,defaultTheme:T,attrs:M}),k)},u=i(function(t){var n=t.forcedTheme,r=t.storageKey,o=t.attribute,a=t.enableSystem,i=t.defaultTheme,c=t.value,s="class"===o?"var d=document.documentElement.classList;d.remove("+t.attrs.map(function(e){return"'"+e+"'"}).join(",")+");":"var d=document.documentElement;",d=function(e,t){e=(null==c?void 0:c[e])||e;var n=t?e:"'"+e+"'";return"class"===o?"d.add("+n+")":"d.setAttribute('"+o+"', "+n+")"};return e.createElement(m,null,e.createElement("script",n?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){"+s+d(n)+"}()"}}:a?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try {"+s+"var e=localStorage.getItem('"+r+"');if(!e)return localStorage.setItem('"+r+"','"+i+"'),"+d(i)+';if("system"===e){var t="(prefers-color-scheme: dark)",m=window.matchMedia(t);m.media!==t||m.matches?'+d("dark")+":"+d("light")+"}else "+(c?"var x="+JSON.stringify(c)+";":"")+d(c?"x[e]":"e",!0)+"}catch(e){}}()"}}:{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try{"+s+'var t=localStorage.getItem("'+r+'");if(!t)return localStorage.setItem("'+r+'","'+i+'"),'+d(i)+";"+(c?"var x="+JSON.stringify(c)+";":"")+d(c?"x[t]":"t",!0)+"}catch(t){}}();"}}))},function(e,t){return e.forcedTheme===t.forcedTheme}),l=function(e){if("undefined"!=typeof window){var t;try{t=localStorage.getItem(e)||void 0}catch(e){}return t}},h=function(){var e=document.createElement("style");return e.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(e),function(){window.getComputedStyle(e),document.head.removeChild(e)}};export{d as ThemeProvider,s as useTheme};
import e,{createContext as t,useContext as n,useState as r,useCallback as o,useEffect as a,memo as i}from"react";import m from"next/head";var c=t({setTheme:function(e){},themes:[]}),s=function(){return n(c)},d=function(t){var n=t.forcedTheme,i=t.disableTransitionOnChange,m=void 0!==i&&i,s=t.enableSystem,d=void 0===s||s,f=t.storageKey,v=void 0===f?"theme":f,y=t.themes,p=void 0===y?["light","dark"]:y,g=t.defaultTheme,T=void 0===g?d?"system":"light":g,w=t.attribute,E=void 0===w?"data-theme":w,S=t.value,b=t.children,k=r(function(){return l(v,T)}),x=k[0],L=k[1],I=r(function(){return l(v)}),_=I[0],C=I[1],M=S?Object.values(S):p,O=o(function(e,t){void 0===t&&(t=!0);var n=(null==S?void 0:S[e])||e,r=m?h():null;if(t)try{localStorage.setItem(v,e)}catch(e){}var o,a=document.documentElement;"class"===E?((o=a.classList).remove.apply(o,M),a.classList.add(n)):a.setAttribute(E,n),null==r||r()},[]),P=o(function(e){var t=e.matches?"dark":"light";C(t),"system"===x&&O(t,!1)},[x]);a(function(){if(d){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addListener(P),P(e),function(){return e.removeListener(P)}}},[P]);var H=o(function(e){n||(O(e),L(e))},[]);return a(function(){var e=function(e){e.key===v&&H(e.newValue)};return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},[]),a(function(){"light"===x?document.documentElement.style.setProperty("color-scheme","light"):"dark"===x?document.documentElement.style.setProperty("color-scheme","dark"):"system"===x&&_&&document.documentElement.style.setProperty("color-scheme",_)},[x,_]),e.createElement(c.Provider,{value:{theme:x,setTheme:H,forcedTheme:n,resolvedTheme:"system"===x?_:x,themes:d?[].concat(p,["system"]):p,systemTheme:d?_:void 0}},e.createElement(u,{forcedTheme:n,storageKey:v,attribute:E,value:S,enableSystem:d,defaultTheme:T,attrs:M}),b)},u=i(function(t){var n=t.forcedTheme,r=t.storageKey,o=t.attribute,a=t.enableSystem,i=t.defaultTheme,c=t.value,s="class"===o?"var d=document.documentElement.classList;d.remove("+t.attrs.map(function(e){return"'"+e+"'"}).join(",")+");":"var d=document.documentElement;",d=function(e,t){e=(null==c?void 0:c[e])||e;var n=t?e:"'"+e+"'";return"class"===o?"d.add("+n+")":"d.setAttribute('"+o+"', "+n+")"},u="system"===i;return e.createElement(m,null,e.createElement("script",n?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){"+s+d(n)+"}()"}}:a?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try {"+s+"var e=localStorage.getItem('"+r+"');"+(u?"":d(i)+";")+'if("system"===e||(!e&&'+u+')){var t="(prefers-color-scheme: dark)",m=window.matchMedia(t);m.media!==t||m.matches?'+d("dark")+":"+d("light")+"}else "+(c?"var x="+JSON.stringify(c)+";":"")+d(c?"x[e]":"e",!0)+"}catch(e){}}()"}}:{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try{"+s+'var e=localStorage.getItem("'+r+'");'+(u?"":d(i))+";"+(c?"var x="+JSON.stringify(c)+";":"")+d(c?"x[e]":"e",!0)+"}catch(t){}}();"}}))},function(e,t){return e.forcedTheme===t.forcedTheme}),l=function(e,t){if("undefined"!=typeof window){var n;try{n=localStorage.getItem(e)||void 0}catch(e){}return n||t}},h=function(){var e=document.createElement("style");return e.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(e),function(){window.getComputedStyle(document.body),setTimeout(function(){document.head.removeChild(e)},1)}};export{d as ThemeProvider,s as useTheme};

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("next/head")):"function"==typeof define&&define.amd?define(["exports","react","next/head"],t):t((e=e||self).nextThemes={},e.react,e.NextHead)}(this,function(e,t,n){var r="default"in t?t.default:t;n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var a=t.createContext({setTheme:function(e){},themes:[]}),o=t.memo(function(e){var t=e.forcedTheme,a=e.storageKey,o=e.attribute,i=e.enableSystem,c=e.defaultTheme,s=e.value,d="class"===o?"var d=document.documentElement.classList;d.remove("+e.attrs.map(function(e){return"'"+e+"'"}).join(",")+");":"var d=document.documentElement;",u=function(e,t){e=(null==s?void 0:s[e])||e;var n=t?e:"'"+e+"'";return"class"===o?"d.add("+n+")":"d.setAttribute('"+o+"', "+n+")"};return r.createElement(n,null,r.createElement("script",t?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){"+d+u(t)+"}()"}}:i?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try {"+d+"var e=localStorage.getItem('"+a+"');if(!e)return localStorage.setItem('"+a+"','"+c+"'),"+u(c)+';if("system"===e){var t="(prefers-color-scheme: dark)",m=window.matchMedia(t);m.media!==t||m.matches?'+u("dark")+":"+u("light")+"}else "+(s?"var x="+JSON.stringify(s)+";":"")+u(s?"x[e]":"e",!0)+"}catch(e){}}()"}}:{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try{"+d+'var t=localStorage.getItem("'+a+'");if(!t)return localStorage.setItem("'+a+'","'+c+'"),'+u(c)+";"+(s?"var x="+JSON.stringify(s)+";":"")+u(s?"x[t]":"t",!0)+"}catch(t){}}();"}}))},function(e,t){return e.forcedTheme===t.forcedTheme}),i=function(e){if("undefined"!=typeof window){var t;try{t=localStorage.getItem(e)||void 0}catch(e){}return t}};e.ThemeProvider=function(e){var n=e.forcedTheme,c=e.disableTransitionOnChange,s=void 0!==c&&c,d=e.enableSystem,u=void 0===d||d,m=e.storageKey,l=void 0===m?"theme":m,f=e.themes,h=void 0===f?["light","dark"]:f,v=e.defaultTheme,y=void 0===v?"light":v,p=e.attribute,g=void 0===p?"data-theme":p,T=e.value,x=e.children,S=t.useState(function(){return i(l)}),b=S[0],w=S[1],k=t.useState(function(){return i(l)}),E=k[0],C=k[1],L=T?Object.values(T):h,I=t.useCallback(function(e,t){void 0===t&&(t=!0);var n,r=(null==T?void 0:T[e])||e,a=s?((n=document.createElement("style")).appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(n),function(){window.getComputedStyle(n),document.head.removeChild(n)}):null;if(t)try{localStorage.setItem(l,e)}catch(e){}var o,i=document.documentElement;"class"===g?((o=i.classList).remove.apply(o,L),i.classList.add(r)):i.setAttribute(g,r),null==a||a()},[]),O=t.useCallback(function(e){var t=e.matches?"dark":"light";C(t),"system"===b&&I(t,!1)},[b]);t.useEffect(function(){if(u){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addListener(O),O(e),function(){return e.removeListener(O)}}},[O]);var _=t.useCallback(function(e){n||(I(e),w(e))},[]);return t.useEffect(function(){var e=function(e){e.key===l&&_(e.newValue)};return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},[]),r.createElement(a.Provider,{value:{theme:b,setTheme:_,forcedTheme:n,resolvedTheme:"system"===b?E:b,themes:u?[].concat(h,["system"]):h,systemTheme:u?E:void 0}},r.createElement(o,{forcedTheme:n,storageKey:l,attribute:g,value:T,enableSystem:u,defaultTheme:y,attrs:L}),x)},e.useTheme=function(){return t.useContext(a)}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("next/head")):"function"==typeof define&&define.amd?define(["exports","react","next/head"],t):t((e=e||self).nextThemes={},e.react,e.NextHead)}(this,function(e,t,n){var r="default"in t?t.default:t;n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var o=t.createContext({setTheme:function(e){},themes:[]}),a=t.memo(function(e){var t=e.forcedTheme,o=e.storageKey,a=e.attribute,i=e.enableSystem,s=e.defaultTheme,c=e.value,m="class"===a?"var d=document.documentElement.classList;d.remove("+e.attrs.map(function(e){return"'"+e+"'"}).join(",")+");":"var d=document.documentElement;",d=function(e,t){e=(null==c?void 0:c[e])||e;var n=t?e:"'"+e+"'";return"class"===a?"d.add("+n+")":"d.setAttribute('"+a+"', "+n+")"},u="system"===s;return r.createElement(n,null,r.createElement("script",t?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){"+m+d(t)+"}()"}}:i?{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try {"+m+"var e=localStorage.getItem('"+o+"');"+(u?"":d(s)+";")+'if("system"===e||(!e&&'+u+')){var t="(prefers-color-scheme: dark)",m=window.matchMedia(t);m.media!==t||m.matches?'+d("dark")+":"+d("light")+"}else "+(c?"var x="+JSON.stringify(c)+";":"")+d(c?"x[e]":"e",!0)+"}catch(e){}}()"}}:{key:"next-themes-script",dangerouslySetInnerHTML:{__html:"!function(){try{"+m+'var e=localStorage.getItem("'+o+'");'+(u?"":d(s))+";"+(c?"var x="+JSON.stringify(c)+";":"")+d(c?"x[e]":"e",!0)+"}catch(t){}}();"}}))},function(e,t){return e.forcedTheme===t.forcedTheme}),i=function(e,t){if("undefined"!=typeof window){var n;try{n=localStorage.getItem(e)||void 0}catch(e){}return n||t}};e.ThemeProvider=function(e){var n=e.forcedTheme,s=e.disableTransitionOnChange,c=void 0!==s&&s,m=e.enableSystem,d=void 0===m||m,u=e.storageKey,l=void 0===u?"theme":u,f=e.themes,h=void 0===f?["light","dark"]:f,v=e.defaultTheme,y=void 0===v?d?"system":"light":v,p=e.attribute,g=void 0===p?"data-theme":p,T=e.value,b=e.children,x=t.useState(function(){return i(l,y)}),E=x[0],k=x[1],w=t.useState(function(){return i(l)}),S=w[0],C=w[1],L=T?Object.values(T):h,I=t.useCallback(function(e,t){void 0===t&&(t=!0);var n,r=(null==T?void 0:T[e])||e,o=c?((n=document.createElement("style")).appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(n),function(){window.getComputedStyle(document.body),setTimeout(function(){document.head.removeChild(n)},1)}):null;if(t)try{localStorage.setItem(l,e)}catch(e){}var a,i=document.documentElement;"class"===g?((a=i.classList).remove.apply(a,L),i.classList.add(r)):i.setAttribute(g,r),null==o||o()},[]),O=t.useCallback(function(e){var t=e.matches?"dark":"light";C(t),"system"===E&&I(t,!1)},[E]);t.useEffect(function(){if(d){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addListener(O),O(e),function(){return e.removeListener(O)}}},[O]);var P=t.useCallback(function(e){n||(I(e),k(e))},[]);return t.useEffect(function(){var e=function(e){e.key===l&&P(e.newValue)};return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},[]),t.useEffect(function(){"light"===E?document.documentElement.style.setProperty("color-scheme","light"):"dark"===E?document.documentElement.style.setProperty("color-scheme","dark"):"system"===E&&S&&document.documentElement.style.setProperty("color-scheme",S)},[E,S]),r.createElement(o.Provider,{value:{theme:E,setTheme:P,forcedTheme:n,resolvedTheme:"system"===E?S:E,themes:d?[].concat(h,["system"]):h,systemTheme:d?S:void 0}},r.createElement(a,{forcedTheme:n,storageKey:l,attribute:g,value:T,enableSystem:d,defaultTheme:y,attrs:L}),b)},e.useTheme=function(){return t.useContext(o)}});
{
"name": "next-themes",
"version": "0.0.12",
"version": "0.0.13-beta.1",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "module": "./dist/index.modern.js",

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