@julseb-lib/react 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +8 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -709,8 +709,9 @@ type ILibThemeContext = {
|
|
|
709
709
|
};
|
|
710
710
|
interface ILibThemeProvider {
|
|
711
711
|
children?: ReactChildren;
|
|
712
|
+
defaultTheme?: LibThemeNames;
|
|
712
713
|
}
|
|
713
|
-
declare const ThemeProviderWrapper: ({ children }: ILibThemeProvider) => react_jsx_runtime.JSX.Element;
|
|
714
|
+
declare const ThemeProviderWrapper: ({ children, defaultTheme, }: ILibThemeProvider) => react_jsx_runtime.JSX.Element;
|
|
714
715
|
/**
|
|
715
716
|
* Custom hook to access the theme context.
|
|
716
717
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -709,8 +709,9 @@ type ILibThemeContext = {
|
|
|
709
709
|
};
|
|
710
710
|
interface ILibThemeProvider {
|
|
711
711
|
children?: ReactChildren;
|
|
712
|
+
defaultTheme?: LibThemeNames;
|
|
712
713
|
}
|
|
713
|
-
declare const ThemeProviderWrapper: ({ children }: ILibThemeProvider) => react_jsx_runtime.JSX.Element;
|
|
714
|
+
declare const ThemeProviderWrapper: ({ children, defaultTheme, }: ILibThemeProvider) => react_jsx_runtime.JSX.Element;
|
|
714
715
|
/**
|
|
715
716
|
* Custom hook to access the theme context.
|
|
716
717
|
*
|
package/dist/index.js
CHANGED
|
@@ -2519,7 +2519,10 @@ var INPUT_HEIGHT = 32;
|
|
|
2519
2519
|
import { useState as useState10, useEffect as useEffect8, createContext, useContext } from "react";
|
|
2520
2520
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
2521
2521
|
var ThemeContext = createContext(null);
|
|
2522
|
-
var ThemeProviderWrapper = ({
|
|
2522
|
+
var ThemeProviderWrapper = ({
|
|
2523
|
+
children,
|
|
2524
|
+
defaultTheme
|
|
2525
|
+
}) => {
|
|
2523
2526
|
const [theme, setTheme] = useState10("light");
|
|
2524
2527
|
const switchToLight = () => {
|
|
2525
2528
|
if (typeof window !== "undefined") {
|
|
@@ -2540,7 +2543,10 @@ var ThemeProviderWrapper = ({ children }) => {
|
|
|
2540
2543
|
useEffect8(() => {
|
|
2541
2544
|
if (typeof window !== "undefined") {
|
|
2542
2545
|
const storedTheme = localStorage.getItem("theme");
|
|
2543
|
-
if (
|
|
2546
|
+
if (defaultTheme) {
|
|
2547
|
+
if (defaultTheme === "light") switchToLight();
|
|
2548
|
+
else switchToDark();
|
|
2549
|
+
} else if (storedTheme) {
|
|
2544
2550
|
if (storedTheme === "light") switchToLight();
|
|
2545
2551
|
else switchToDark();
|
|
2546
2552
|
} else {
|