@trii/components 3.1.4 → 3.1.5

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.
@@ -0,0 +1,14 @@
1
+ export type ThemePreference = 'light' | 'dark' | 'system';
2
+ export type ResolvedTheme = 'light' | 'dark';
3
+ export declare const THEME_PREFERENCES: readonly ThemePreference[];
4
+ export declare const LEGACY_THEME_NAMES: readonly ["lightBlueIndigo", "lightBlue", "lightRed", "lightGreen", "lightPink", "lightPurple", "lightTeal", "lightLime", "lightYellow", "lightAmber", "lightOrange", "lightBrown", "lightGray", "darkBlue", "darkBlack"];
5
+ export type LegacyThemeName = typeof LEGACY_THEME_NAMES[number];
6
+ export type ThemeName = ThemePreference | LegacyThemeName;
7
+ export declare const isValidThemeName: (name: string) => name is ThemeName;
8
+ /** Missing/unknown preferences follow the OS. Existing choices keep their mode. */
9
+ export declare const normalizeThemePreference: (name?: string | null) => ThemePreference;
10
+ export declare const resolveThemePreference: (preference: ThemePreference, systemDark?: boolean) => ResolvedTheme;
11
+ /** Emits immediately; caller must unsubscribe on unmount/preference change.
12
+ * Does not persist or call an API when the OS appearance changes.
13
+ */
14
+ export declare const observeThemePreference: (preference: ThemePreference, listener: (mode: ResolvedTheme) => void) => (() => void);
@@ -0,0 +1 @@
1
+ export {};
@@ -57,18 +57,35 @@ declare module '@mui/material/styles' {
57
57
  name?: string;
58
58
  }
59
59
  }
60
+ export declare const lightTheme: Theme;
61
+ export declare const darkTheme: Theme;
62
+ /** @deprecated Use lightTheme. */
60
63
  export declare const lightBlueIndigo: Theme;
64
+ /** @deprecated Use lightTheme. */
61
65
  export declare const lightBlue: Theme;
66
+ /** @deprecated Use lightTheme. */
62
67
  export declare const lightRed: Theme;
68
+ /** @deprecated Use lightTheme. */
63
69
  export declare const lightGreen: Theme;
70
+ /** @deprecated Use lightTheme. */
64
71
  export declare const lightPink: Theme;
72
+ /** @deprecated Use lightTheme. */
65
73
  export declare const lightPurple: Theme;
74
+ /** @deprecated Use lightTheme. */
66
75
  export declare const lightTeal: Theme;
76
+ /** @deprecated Use lightTheme. */
67
77
  export declare const lightLime: Theme;
78
+ /** @deprecated Use lightTheme. */
68
79
  export declare const lightYellow: Theme;
80
+ /** @deprecated Use lightTheme. */
69
81
  export declare const lightAmber: Theme;
82
+ /** @deprecated Use lightTheme. */
70
83
  export declare const lightOrange: Theme;
84
+ /** @deprecated Use lightTheme. */
71
85
  export declare const lightBrown: Theme;
86
+ /** @deprecated Use lightTheme. */
72
87
  export declare const lightGray: Theme;
88
+ /** @deprecated Use darkTheme. */
73
89
  export declare const darkBlue: Theme;
90
+ /** @deprecated Use darkTheme. */
74
91
  export declare const darkBlack: Theme;
@@ -1,4 +1,7 @@
1
1
  import { Theme } from '@mui/material';
2
+ import { ThemeName, ThemePreference, ResolvedTheme } from './themePreference';
3
+ export { isValidThemeName } from './themePreference';
4
+ export type { ThemeName } from './themePreference';
2
5
  /**
3
6
  * Forma mínima del store que necesita este slice: la app que lo use tiene que
4
7
  * tener `Theme` y `User.user.uid`.
@@ -13,11 +16,10 @@ export interface ThemeRootState {
13
16
  };
14
17
  Theme: ThemeState;
15
18
  }
16
- /** Nombres de tema disponibles. */
17
- export type ThemeName = 'lightBlueIndigo' | 'darkBlack' | 'darkBlue' | 'lightAmber' | 'lightBlue' | 'lightBrown' | 'lightGray' | 'lightGreen' | 'lightLime' | 'lightOrange' | 'lightPink' | 'lightPurple' | 'lightRed' | 'lightTeal' | 'lightYellow';
18
19
  /** Estado del slice. */
19
20
  export interface ThemeState {
20
21
  themeSelected: Theme;
22
+ preference: ThemePreference;
21
23
  darkMode: boolean;
22
24
  toggleStatus: 'idle' | 'toggled';
23
25
  }
@@ -34,9 +36,8 @@ export declare const updateTheme: import("@reduxjs/toolkit").AsyncThunk<{
34
36
  fulfilledMeta?: unknown;
35
37
  rejectedMeta?: unknown;
36
38
  }>;
37
- /** Valida que el string sea un `ThemeName`. */
38
- export declare const isValidThemeName: (theme: string) => theme is ThemeName;
39
- export declare const toggleTheme: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<ThemeName, "Theme/toggleTheme">, toggleModeTheme: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"Theme/toggleModeTheme">;
39
+ export declare const selectThemePreference: (state: ThemeRootState) => ThemePreference;
40
+ export declare const toggleTheme: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<ThemeName, "Theme/toggleTheme">, toggleModeTheme: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"Theme/toggleModeTheme">, systemThemeChanged: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<ResolvedTheme, "Theme/systemThemeChanged">;
40
41
  export declare const selectThemeToggleStatus: (state: ThemeRootState) => "idle" | "toggled";
41
42
  export declare const selectTheme: (state: ThemeRootState) => Theme;
42
43
  export declare const selectDarkTheme: (state: ThemeRootState) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trii/components",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "description": "Trii components package",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",