@oniratec/onira-react-ui 1.0.6 → 1.0.7

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.ts CHANGED
@@ -319,6 +319,18 @@ export declare interface ThemeColors {
319
319
  error: string;
320
320
  }
321
321
 
322
+ declare interface ThemeContextValue {
323
+ theme: Theme;
324
+ setMode: (mode: ColorMode) => void;
325
+ }
326
+
327
+ export declare function ThemeProvider({ mode, children }: ThemeProviderProps): JSX.Element;
328
+
329
+ declare interface ThemeProviderProps {
330
+ mode?: ColorMode;
331
+ children: ReactNode;
332
+ }
333
+
322
334
  export declare interface ThemeShadows {
323
335
  card: {
324
336
  sm: string;
@@ -354,4 +366,6 @@ export declare const TooltipTrigger: ComponentType<TooltipPrimitive.TooltipTrigg
354
366
 
355
367
  export declare function useField(): FieldContextValue;
356
368
 
369
+ export declare function useTheme(): ThemeContextValue;
370
+
357
371
  export { }
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import React__default, { forwardRef, useState, useEffect, useRef } from "react";
3
+ import React__default, { forwardRef, useState, useEffect, useRef, useMemo, createContext, useContext } from "react";
4
4
  import { Loader2, Check, Circle, ChevronRight, EyeOff, EyeIcon, ChevronDown } from "lucide-react";
5
5
  import { clsx } from "clsx";
6
6
  import { twMerge } from "tailwind-merge";
@@ -9060,6 +9060,51 @@ function createTheme(e) {
9060
9060
  };
9061
9061
  }
9062
9062
  const lightTheme = createTheme("light"), darkTheme = createTheme("dark"), defaultTheme = lightTheme;
9063
+ function themeToCssVars(e) {
9064
+ return {
9065
+ "--oniratec-brand": e.colors.brand,
9066
+ "--oniratec-fill-primary": e.colors.fill.primary,
9067
+ "--oniratec-fill-secondary": e.colors.fill.secondary,
9068
+ "--oniratec-fill-disabled": e.colors.fill.disabled,
9069
+ "--oniratec-label-primary": e.colors.label.primary,
9070
+ "--oniratec-label-secondary": e.colors.label.secondary,
9071
+ "--oniratec-label-disabled": e.colors.label.disabled,
9072
+ "--oniratec-border-primary": e.colors.border.primary,
9073
+ "--oniratec-border-secondary": e.colors.border.secondary,
9074
+ "--oniratec-border-disabled": e.colors.border.disabled,
9075
+ "--oniratec-focus": e.colors.focus,
9076
+ "--oniratec-error": e.colors.error,
9077
+ "--oniratec-shadow-card-sm": e.shadows.card.sm,
9078
+ "--oniratec-shadow-card-md": e.shadows.card.md,
9079
+ "--oniratec-shadow-card-lg": e.shadows.card.lg,
9080
+ "--oniratec-shadow-card-xl": e.shadows.card.xl
9081
+ };
9082
+ }
9083
+ const ThemeContext = createContext(null);
9084
+ function ThemeProvider({ mode: e = "light", children: t }) {
9085
+ const r = useMemo(() => e === "dark" ? darkTheme : defaultTheme, [e]);
9086
+ useEffect(() => {
9087
+ const s = document.documentElement, n = themeToCssVars(r);
9088
+ for (const [a, l] of Object.entries(n))
9089
+ s.style.setProperty(a, l);
9090
+ s.classList.toggle("dark", r.mode === "dark");
9091
+ }, [r]);
9092
+ const i = useMemo(
9093
+ () => ({
9094
+ theme: r,
9095
+ setMode: () => {
9096
+ }
9097
+ }),
9098
+ [r]
9099
+ );
9100
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: i, children: t });
9101
+ }
9102
+ function useTheme() {
9103
+ const e = useContext(ThemeContext);
9104
+ if (!e)
9105
+ throw new Error("useTheme must be used within ThemeProvider");
9106
+ return e;
9107
+ }
9063
9108
  function $constructor(e, t, r) {
9064
9109
  function i(l, h) {
9065
9110
  if (l._zod || Object.defineProperty(l, "_zod", {
@@ -11298,6 +11343,7 @@ export {
11298
11343
  SelectTrigger,
11299
11344
  SelectValue,
11300
11345
  Skeleton,
11346
+ ThemeProvider,
11301
11347
  Toggle,
11302
11348
  Tooltip,
11303
11349
  TooltipContent,
@@ -11308,6 +11354,7 @@ export {
11308
11354
  darkTheme,
11309
11355
  defaultTheme,
11310
11356
  lightTheme,
11311
- useField
11357
+ useField,
11358
+ useTheme
11312
11359
  };
11313
11360
  //# sourceMappingURL=index.js.map