@julseb-lib/react 1.0.18 → 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.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 = ({ children }) => {
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 (storedTheme) {
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 {
@@ -2831,7 +2837,7 @@ var Key = ({
2831
2837
  accentColor = "primary",
2832
2838
  ...rest
2833
2839
  }) => {
2834
- const theme = localStorage.getItem("theme") ?? "light";
2840
+ const { theme } = useLibTheme();
2835
2841
  const Element = element;
2836
2842
  const childrenArray = Children.toArray(
2837
2843
  children?.toString().replaceAll(",", "").split("")
@@ -67041,7 +67047,7 @@ var Toast = ({
67041
67047
  ...rest
67042
67048
  }) => {
67043
67049
  const Element = element;
67044
- const theme = localStorage.getItem("theme") ?? "light";
67050
+ const { theme } = useLibTheme();
67045
67051
  return /* @__PURE__ */ jsxs278(
67046
67052
  Element,
67047
67053
  {
@@ -67234,7 +67240,7 @@ var Alert = ({
67234
67240
  ...rest
67235
67241
  }) => {
67236
67242
  const Element = element;
67237
- const theme = localStorage.getItem("theme") ?? "light";
67243
+ const { theme } = useLibTheme();
67238
67244
  return /* @__PURE__ */ jsx335(
67239
67245
  Element,
67240
67246
  {