@dloizides/theme-web 1.0.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ Initial release. Redux-free `ThemeProvider` + `useTheme`, `useDarkMode` (localStorage +
6
+ `prefers-color-scheme`), the HSL `paletteGenerator`, `resolveTheme`, the packaged
7
+ `DEFAULT_THEME_CONFIG` (midnight-green — identical to erevna-web / katalogos-web today), the
8
+ `fromDesignTokens` adapter for `@dloizides/design-tokens`, and the full theme type system.
9
+ Promoted verbatim (shapes + palette algorithm unchanged) from the duplicated app `src/theme`,
10
+ with the app-store coupling removed so any app can mount it.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 dloizides
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # @dloizides/theme-web
2
+
3
+ Shared, **redux-free** RN-web theme system for the dloizides.com portfolio, promoted from
4
+ the palette + provider that erevna-web and katalogos-web duplicated (`src/theme`): a
5
+ `ThemeProvider` + `useTheme`, the HSL palette generator, the `resolveTheme` builder, and the
6
+ theme types.
7
+
8
+ The packaged default palette is the exact midnight-green both apps shipped, so migrating an
9
+ app is a **zero visual change**. Seed a custom palette from a single
10
+ `@dloizides/design-tokens` preset via `fromDesignTokens`. Any app (including kefi, which had
11
+ no theme system) can mount `ThemeProvider` and feed the resolved theme straight into a
12
+ `@dloizides/ui-feedback` `UiProvider` for the shared UI kit.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @dloizides/theme-web
18
+ # optional, only if you use fromDesignTokens():
19
+ npm install @dloizides/design-tokens
20
+ ```
21
+
22
+ Peer deps: `react >= 18` (+ optional `@dloizides/design-tokens >= 1.0.0`). No react-native
23
+ dependency — the theme is pure logic + React context; it works in RN-web and DOM-React alike.
24
+
25
+ ## Usage
26
+
27
+ ```tsx
28
+ import { ThemeProvider, useTheme, fromDesignTokens } from '@dloizides/theme-web';
29
+ import { UiProvider } from '@dloizides/ui-feedback';
30
+ import { EREVNA_TOKENS } from '@dloizides/design-tokens';
31
+
32
+ function Root() {
33
+ return (
34
+ <ThemeProvider tenantThemeConfig={tenantConfig} defaultThemeConfig={fromDesignTokens(EREVNA_TOKENS)}>
35
+ <UiBridge>{children}</UiBridge>
36
+ </ThemeProvider>
37
+ );
38
+ }
39
+
40
+ // Bridge the theme into the shared UI kit's context:
41
+ function UiBridge({ children }: { children: React.ReactNode }) {
42
+ const { theme } = useTheme();
43
+ return <UiProvider theme={theme} t={FM}>{children}</UiProvider>;
44
+ }
45
+ ```
46
+
47
+ `useTheme()` returns `{ theme, mode, toggleMode, setMode, setTenantConfig, setBrandingUrls,
48
+ darkModePreference, setDarkModePreference }`. `theme` is a fully-resolved `ResolvedTheme`
49
+ (`colors`, `palette`, `semantic`, `typography`, `mode`, `branding`).
50
+
51
+ Dark mode persists to `localStorage` (`DARK_MODE_PREFERENCE`, matching the apps) and follows
52
+ `prefers-color-scheme` when set to `system`.
53
+
54
+ ## License
55
+
56
+ MIT
@@ -0,0 +1,240 @@
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import { DesignTokens } from '@dloizides/design-tokens';
4
+
5
+ /**
6
+ * Light/dark appearance mode. Modelled as a const object + string union (not a
7
+ * `const enum`) so the value is safe to import across the package boundary from
8
+ * a bundled `dist` without declaration-inlining pitfalls.
9
+ */
10
+ declare const ThemeMode: {
11
+ readonly Light: "light";
12
+ readonly Dark: "dark";
13
+ };
14
+ type ThemeMode = (typeof ThemeMode)[keyof typeof ThemeMode];
15
+
16
+ /**
17
+ * Theme type system — promoted verbatim (shapes unchanged) from the duplicated
18
+ * erevna-web / katalogos-web `src/theme/types`, so a migrated app's
19
+ * `ResolvedTheme` / `TenantThemeConfig` are structurally identical.
20
+ */
21
+
22
+ /** Generated shade scale for a single color (50-900). */
23
+ interface ColorScale {
24
+ '50': string;
25
+ '100': string;
26
+ '200': string;
27
+ '300': string;
28
+ '400': string;
29
+ '500': string;
30
+ '600': string;
31
+ '700': string;
32
+ '800': string;
33
+ '900': string;
34
+ }
35
+ /** Mode-specific color tokens shared by both light and dark configurations. */
36
+ interface ThemeModeColors {
37
+ background: string;
38
+ surface: string;
39
+ surfaceElevated: string;
40
+ text: string;
41
+ textSecondary: string;
42
+ border: string;
43
+ divider: string;
44
+ }
45
+ /** Optional semantic/status color overrides. Omitted values fall back to defaults. */
46
+ interface SemanticColorOverrides {
47
+ success?: string;
48
+ warning?: string;
49
+ error?: string;
50
+ info?: string;
51
+ }
52
+ /** Optional typography overrides. */
53
+ interface TypographyConfig {
54
+ fontFamily?: string;
55
+ headingScale?: number;
56
+ }
57
+ /** Branding assets stored as ContentService references. */
58
+ interface BrandingConfig {
59
+ logoContentId: string | null;
60
+ faviconContentId: string | null;
61
+ presetId: string | null;
62
+ }
63
+ /** Per-tenant theme configuration (the stored JSON blob). */
64
+ interface TenantThemeConfig {
65
+ primary: string;
66
+ secondary: string;
67
+ accent: string;
68
+ semantic?: SemanticColorOverrides;
69
+ light: ThemeModeColors;
70
+ dark: ThemeModeColors;
71
+ typography?: TypographyConfig;
72
+ branding: BrandingConfig;
73
+ }
74
+ /** Full shade palettes for brand colors. */
75
+ interface ResolvedPalette {
76
+ primary: ColorScale;
77
+ secondary: ColorScale;
78
+ accent: ColorScale;
79
+ }
80
+ /** Full shade palettes for semantic/status colors. */
81
+ interface ResolvedSemanticColors {
82
+ success: ColorScale;
83
+ warning: ColorScale;
84
+ error: ColorScale;
85
+ info: ColorScale;
86
+ }
87
+ /** Resolved typography configuration. */
88
+ interface ResolvedTypography {
89
+ fontFamily: string;
90
+ headingScale: number;
91
+ }
92
+ /** Resolved branding with URLs instead of content IDs. */
93
+ interface ResolvedBranding {
94
+ logoUrl: string | null;
95
+ faviconUrl: string | null;
96
+ }
97
+ /** Fully resolved theme consumed by components via useTheme(). */
98
+ interface ResolvedTheme {
99
+ colors: ThemeModeColors;
100
+ palette: ResolvedPalette;
101
+ semantic: ResolvedSemanticColors;
102
+ typography: ResolvedTypography;
103
+ mode: ThemeMode;
104
+ branding: ResolvedBranding;
105
+ }
106
+
107
+ /**
108
+ * ThemeProvider — the shared, redux-free theme provider. Promoted from the twin
109
+ * erevna-web / katalogos-web `theme/components/ThemeProvider.tsx`, with the
110
+ * app-store sync removed so ANY app (including kefi, which had no theme system)
111
+ * can mount it.
112
+ *
113
+ * - Accepts an optional `tenantThemeConfig` (null → the packaged
114
+ * `DEFAULT_THEME_CONFIG`, or an app-supplied `defaultThemeConfig`).
115
+ * - Manages light/dark via `useDarkMode` (localStorage + `prefers-color-scheme`).
116
+ * - Resolves a `ResolvedTheme` via `resolveTheme` and memoizes it.
117
+ * - Exposes runtime setters for config, mode, and branding URLs.
118
+ */
119
+
120
+ interface ThemeProviderProps {
121
+ /** Tenant theme config; `null`/omitted → `defaultThemeConfig`. */
122
+ tenantThemeConfig?: TenantThemeConfig | null;
123
+ /** Fallback config when no tenant config is supplied. Defaults to the packaged midnight-green. */
124
+ defaultThemeConfig?: TenantThemeConfig;
125
+ /** Override the localStorage key for the dark-mode preference. */
126
+ storageKey?: string;
127
+ children: React__default.ReactNode;
128
+ }
129
+ declare const ThemeProvider: ({ tenantThemeConfig, defaultThemeConfig, storageKey, children, }: ThemeProviderProps) => React__default.ReactElement;
130
+
131
+ /**
132
+ * User dark-mode preference: an explicit `light`/`dark`, or `system` (follow the
133
+ * OS `prefers-color-scheme`). Const object + union — see `ThemeMode` for the why.
134
+ */
135
+ declare const DarkModePreference: {
136
+ readonly Light: "light";
137
+ readonly Dark: "dark";
138
+ readonly System: "system";
139
+ };
140
+ type DarkModePreference = (typeof DarkModePreference)[keyof typeof DarkModePreference];
141
+
142
+ interface ThemeContextValue {
143
+ /** Fully resolved theme for the current mode. */
144
+ theme: ResolvedTheme;
145
+ /** Current light/dark mode. */
146
+ mode: ThemeMode;
147
+ /** Toggle between light and dark mode. */
148
+ toggleMode: () => void;
149
+ /** Set a specific mode. */
150
+ setMode: (mode: ThemeMode) => void;
151
+ /** Replace the tenant theme config at runtime. */
152
+ setTenantConfig: (config: TenantThemeConfig | null) => void;
153
+ /** Set resolved branding URLs (logo/favicon) from ContentService. */
154
+ setBrandingUrls: (urls: Partial<ResolvedBranding>) => void;
155
+ /** Current dark mode preference (light/dark/system). */
156
+ darkModePreference: DarkModePreference;
157
+ /** Update the dark mode preference. */
158
+ setDarkModePreference: (preference: DarkModePreference) => void;
159
+ }
160
+ declare const ThemeContext: React.Context<ThemeContextValue | null>;
161
+
162
+ declare function useTheme(): ThemeContextValue;
163
+
164
+ /** Default localStorage key — matches erevna-web / katalogos-web. */
165
+ declare const DEFAULT_DARK_MODE_STORAGE_KEY = "DARK_MODE_PREFERENCE";
166
+ interface UseDarkModeReturn {
167
+ /** The user's stored preference (light/dark/system). */
168
+ preference: DarkModePreference;
169
+ /** The resolved ThemeMode to apply (light or dark). */
170
+ effectiveMode: ThemeMode;
171
+ /** Update the preference and persist to localStorage. */
172
+ setPreference: (next: DarkModePreference) => void;
173
+ }
174
+ declare function useDarkMode(storageKey?: string): UseDarkModeReturn;
175
+
176
+ declare function resolveTheme(config: TenantThemeConfig | null, mode: ThemeMode): ResolvedTheme;
177
+
178
+ /**
179
+ * The packaged default theme — the midnight-green palette that erevna-web and
180
+ * katalogos-web shipped byte-for-byte (`theme/presets/default.ts`). Used as the
181
+ * fallback when no tenant config is supplied, so a migrated app looks identical
182
+ * before any tenant customization. Apps may pass their own `TenantThemeConfig`
183
+ * (e.g. built from a `@dloizides/design-tokens` preset via `fromDesignTokens`).
184
+ */
185
+
186
+ declare const DEFAULT_THEME_CONFIG: TenantThemeConfig;
187
+
188
+ /**
189
+ * Adapter: `@dloizides/design-tokens` → this package's `TenantThemeConfig`.
190
+ *
191
+ * A `DesignTokens` preset is a superset of a `TenantThemeConfig` (it adds
192
+ * radii/shadows/extensions the RN theme has no slot for), and its
193
+ * `ModeColors`/`SemanticColors`/`Branding` shapes are structurally identical to
194
+ * ours. So this projects the core fields — letting any app seed the shared
195
+ * ThemeProvider from a single design-token source instead of a duplicated palette.
196
+ */
197
+
198
+ /** Project a design-token set onto a `TenantThemeConfig`. */
199
+ declare function fromDesignTokens(tokens: DesignTokens): TenantThemeConfig;
200
+
201
+ /**
202
+ * Palette Generator — promoted verbatim (algorithm + constants unchanged) from
203
+ * the duplicated erevna-web / katalogos-web `theme/utils/palette-generator.ts`.
204
+ *
205
+ * Generates full color palettes (50-900 shades) from single base hex colors via
206
+ * HSL interpolation. Pure functions, no side effects, no external dependencies.
207
+ */
208
+
209
+ interface Hsl {
210
+ h: number;
211
+ s: number;
212
+ l: number;
213
+ }
214
+ interface ThemePaletteResult {
215
+ primary: ColorScale;
216
+ secondary: ColorScale;
217
+ accent: ColorScale;
218
+ semantic: {
219
+ success: ColorScale;
220
+ warning: ColorScale;
221
+ error: ColorScale;
222
+ info: ColorScale;
223
+ };
224
+ }
225
+ /** Validate a hex color string (#RGB or #RRGGBB). */
226
+ declare function isValidHex(value: string): boolean;
227
+ /** Convert a hex color (#RGB or #RRGGBB) to HSL. */
228
+ declare function hexToHsl(hex: string): Hsl;
229
+ /** Convert HSL values to a hex color string (#rrggbb). */
230
+ declare function hslToHex(h: number, s: number, l: number): string;
231
+ /** Lighten a hex color by the given amount (0-1 range, where 1 = white). */
232
+ declare function lighten(hex: string, amount: number): string;
233
+ /** Darken a hex color by the given amount (0-1 range, where 1 = black). */
234
+ declare function darken(hex: string, amount: number): string;
235
+ /** Generate a full 50-900 shade scale from a single hex base color. */
236
+ declare function generateColorScale(baseColor: string): ColorScale;
237
+ /** Generate all palette scales from a TenantThemeConfig. */
238
+ declare function generateThemePalette(config: TenantThemeConfig): ThemePaletteResult;
239
+
240
+ export { type BrandingConfig, type ColorScale, DEFAULT_DARK_MODE_STORAGE_KEY, DEFAULT_THEME_CONFIG, DarkModePreference, type ResolvedBranding, type ResolvedPalette, type ResolvedSemanticColors, type ResolvedTheme, type ResolvedTypography, type SemanticColorOverrides, type TenantThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, type ThemeModeColors, ThemeProvider, type ThemeProviderProps, type TypographyConfig, type UseDarkModeReturn, darken, fromDesignTokens, generateColorScale, generateThemePalette, hexToHsl, hslToHex, isValidHex, lighten, resolveTheme, useDarkMode, useTheme };
@@ -0,0 +1,240 @@
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import { DesignTokens } from '@dloizides/design-tokens';
4
+
5
+ /**
6
+ * Light/dark appearance mode. Modelled as a const object + string union (not a
7
+ * `const enum`) so the value is safe to import across the package boundary from
8
+ * a bundled `dist` without declaration-inlining pitfalls.
9
+ */
10
+ declare const ThemeMode: {
11
+ readonly Light: "light";
12
+ readonly Dark: "dark";
13
+ };
14
+ type ThemeMode = (typeof ThemeMode)[keyof typeof ThemeMode];
15
+
16
+ /**
17
+ * Theme type system — promoted verbatim (shapes unchanged) from the duplicated
18
+ * erevna-web / katalogos-web `src/theme/types`, so a migrated app's
19
+ * `ResolvedTheme` / `TenantThemeConfig` are structurally identical.
20
+ */
21
+
22
+ /** Generated shade scale for a single color (50-900). */
23
+ interface ColorScale {
24
+ '50': string;
25
+ '100': string;
26
+ '200': string;
27
+ '300': string;
28
+ '400': string;
29
+ '500': string;
30
+ '600': string;
31
+ '700': string;
32
+ '800': string;
33
+ '900': string;
34
+ }
35
+ /** Mode-specific color tokens shared by both light and dark configurations. */
36
+ interface ThemeModeColors {
37
+ background: string;
38
+ surface: string;
39
+ surfaceElevated: string;
40
+ text: string;
41
+ textSecondary: string;
42
+ border: string;
43
+ divider: string;
44
+ }
45
+ /** Optional semantic/status color overrides. Omitted values fall back to defaults. */
46
+ interface SemanticColorOverrides {
47
+ success?: string;
48
+ warning?: string;
49
+ error?: string;
50
+ info?: string;
51
+ }
52
+ /** Optional typography overrides. */
53
+ interface TypographyConfig {
54
+ fontFamily?: string;
55
+ headingScale?: number;
56
+ }
57
+ /** Branding assets stored as ContentService references. */
58
+ interface BrandingConfig {
59
+ logoContentId: string | null;
60
+ faviconContentId: string | null;
61
+ presetId: string | null;
62
+ }
63
+ /** Per-tenant theme configuration (the stored JSON blob). */
64
+ interface TenantThemeConfig {
65
+ primary: string;
66
+ secondary: string;
67
+ accent: string;
68
+ semantic?: SemanticColorOverrides;
69
+ light: ThemeModeColors;
70
+ dark: ThemeModeColors;
71
+ typography?: TypographyConfig;
72
+ branding: BrandingConfig;
73
+ }
74
+ /** Full shade palettes for brand colors. */
75
+ interface ResolvedPalette {
76
+ primary: ColorScale;
77
+ secondary: ColorScale;
78
+ accent: ColorScale;
79
+ }
80
+ /** Full shade palettes for semantic/status colors. */
81
+ interface ResolvedSemanticColors {
82
+ success: ColorScale;
83
+ warning: ColorScale;
84
+ error: ColorScale;
85
+ info: ColorScale;
86
+ }
87
+ /** Resolved typography configuration. */
88
+ interface ResolvedTypography {
89
+ fontFamily: string;
90
+ headingScale: number;
91
+ }
92
+ /** Resolved branding with URLs instead of content IDs. */
93
+ interface ResolvedBranding {
94
+ logoUrl: string | null;
95
+ faviconUrl: string | null;
96
+ }
97
+ /** Fully resolved theme consumed by components via useTheme(). */
98
+ interface ResolvedTheme {
99
+ colors: ThemeModeColors;
100
+ palette: ResolvedPalette;
101
+ semantic: ResolvedSemanticColors;
102
+ typography: ResolvedTypography;
103
+ mode: ThemeMode;
104
+ branding: ResolvedBranding;
105
+ }
106
+
107
+ /**
108
+ * ThemeProvider — the shared, redux-free theme provider. Promoted from the twin
109
+ * erevna-web / katalogos-web `theme/components/ThemeProvider.tsx`, with the
110
+ * app-store sync removed so ANY app (including kefi, which had no theme system)
111
+ * can mount it.
112
+ *
113
+ * - Accepts an optional `tenantThemeConfig` (null → the packaged
114
+ * `DEFAULT_THEME_CONFIG`, or an app-supplied `defaultThemeConfig`).
115
+ * - Manages light/dark via `useDarkMode` (localStorage + `prefers-color-scheme`).
116
+ * - Resolves a `ResolvedTheme` via `resolveTheme` and memoizes it.
117
+ * - Exposes runtime setters for config, mode, and branding URLs.
118
+ */
119
+
120
+ interface ThemeProviderProps {
121
+ /** Tenant theme config; `null`/omitted → `defaultThemeConfig`. */
122
+ tenantThemeConfig?: TenantThemeConfig | null;
123
+ /** Fallback config when no tenant config is supplied. Defaults to the packaged midnight-green. */
124
+ defaultThemeConfig?: TenantThemeConfig;
125
+ /** Override the localStorage key for the dark-mode preference. */
126
+ storageKey?: string;
127
+ children: React__default.ReactNode;
128
+ }
129
+ declare const ThemeProvider: ({ tenantThemeConfig, defaultThemeConfig, storageKey, children, }: ThemeProviderProps) => React__default.ReactElement;
130
+
131
+ /**
132
+ * User dark-mode preference: an explicit `light`/`dark`, or `system` (follow the
133
+ * OS `prefers-color-scheme`). Const object + union — see `ThemeMode` for the why.
134
+ */
135
+ declare const DarkModePreference: {
136
+ readonly Light: "light";
137
+ readonly Dark: "dark";
138
+ readonly System: "system";
139
+ };
140
+ type DarkModePreference = (typeof DarkModePreference)[keyof typeof DarkModePreference];
141
+
142
+ interface ThemeContextValue {
143
+ /** Fully resolved theme for the current mode. */
144
+ theme: ResolvedTheme;
145
+ /** Current light/dark mode. */
146
+ mode: ThemeMode;
147
+ /** Toggle between light and dark mode. */
148
+ toggleMode: () => void;
149
+ /** Set a specific mode. */
150
+ setMode: (mode: ThemeMode) => void;
151
+ /** Replace the tenant theme config at runtime. */
152
+ setTenantConfig: (config: TenantThemeConfig | null) => void;
153
+ /** Set resolved branding URLs (logo/favicon) from ContentService. */
154
+ setBrandingUrls: (urls: Partial<ResolvedBranding>) => void;
155
+ /** Current dark mode preference (light/dark/system). */
156
+ darkModePreference: DarkModePreference;
157
+ /** Update the dark mode preference. */
158
+ setDarkModePreference: (preference: DarkModePreference) => void;
159
+ }
160
+ declare const ThemeContext: React.Context<ThemeContextValue | null>;
161
+
162
+ declare function useTheme(): ThemeContextValue;
163
+
164
+ /** Default localStorage key — matches erevna-web / katalogos-web. */
165
+ declare const DEFAULT_DARK_MODE_STORAGE_KEY = "DARK_MODE_PREFERENCE";
166
+ interface UseDarkModeReturn {
167
+ /** The user's stored preference (light/dark/system). */
168
+ preference: DarkModePreference;
169
+ /** The resolved ThemeMode to apply (light or dark). */
170
+ effectiveMode: ThemeMode;
171
+ /** Update the preference and persist to localStorage. */
172
+ setPreference: (next: DarkModePreference) => void;
173
+ }
174
+ declare function useDarkMode(storageKey?: string): UseDarkModeReturn;
175
+
176
+ declare function resolveTheme(config: TenantThemeConfig | null, mode: ThemeMode): ResolvedTheme;
177
+
178
+ /**
179
+ * The packaged default theme — the midnight-green palette that erevna-web and
180
+ * katalogos-web shipped byte-for-byte (`theme/presets/default.ts`). Used as the
181
+ * fallback when no tenant config is supplied, so a migrated app looks identical
182
+ * before any tenant customization. Apps may pass their own `TenantThemeConfig`
183
+ * (e.g. built from a `@dloizides/design-tokens` preset via `fromDesignTokens`).
184
+ */
185
+
186
+ declare const DEFAULT_THEME_CONFIG: TenantThemeConfig;
187
+
188
+ /**
189
+ * Adapter: `@dloizides/design-tokens` → this package's `TenantThemeConfig`.
190
+ *
191
+ * A `DesignTokens` preset is a superset of a `TenantThemeConfig` (it adds
192
+ * radii/shadows/extensions the RN theme has no slot for), and its
193
+ * `ModeColors`/`SemanticColors`/`Branding` shapes are structurally identical to
194
+ * ours. So this projects the core fields — letting any app seed the shared
195
+ * ThemeProvider from a single design-token source instead of a duplicated palette.
196
+ */
197
+
198
+ /** Project a design-token set onto a `TenantThemeConfig`. */
199
+ declare function fromDesignTokens(tokens: DesignTokens): TenantThemeConfig;
200
+
201
+ /**
202
+ * Palette Generator — promoted verbatim (algorithm + constants unchanged) from
203
+ * the duplicated erevna-web / katalogos-web `theme/utils/palette-generator.ts`.
204
+ *
205
+ * Generates full color palettes (50-900 shades) from single base hex colors via
206
+ * HSL interpolation. Pure functions, no side effects, no external dependencies.
207
+ */
208
+
209
+ interface Hsl {
210
+ h: number;
211
+ s: number;
212
+ l: number;
213
+ }
214
+ interface ThemePaletteResult {
215
+ primary: ColorScale;
216
+ secondary: ColorScale;
217
+ accent: ColorScale;
218
+ semantic: {
219
+ success: ColorScale;
220
+ warning: ColorScale;
221
+ error: ColorScale;
222
+ info: ColorScale;
223
+ };
224
+ }
225
+ /** Validate a hex color string (#RGB or #RRGGBB). */
226
+ declare function isValidHex(value: string): boolean;
227
+ /** Convert a hex color (#RGB or #RRGGBB) to HSL. */
228
+ declare function hexToHsl(hex: string): Hsl;
229
+ /** Convert HSL values to a hex color string (#rrggbb). */
230
+ declare function hslToHex(h: number, s: number, l: number): string;
231
+ /** Lighten a hex color by the given amount (0-1 range, where 1 = white). */
232
+ declare function lighten(hex: string, amount: number): string;
233
+ /** Darken a hex color by the given amount (0-1 range, where 1 = black). */
234
+ declare function darken(hex: string, amount: number): string;
235
+ /** Generate a full 50-900 shade scale from a single hex base color. */
236
+ declare function generateColorScale(baseColor: string): ColorScale;
237
+ /** Generate all palette scales from a TenantThemeConfig. */
238
+ declare function generateThemePalette(config: TenantThemeConfig): ThemePaletteResult;
239
+
240
+ export { type BrandingConfig, type ColorScale, DEFAULT_DARK_MODE_STORAGE_KEY, DEFAULT_THEME_CONFIG, DarkModePreference, type ResolvedBranding, type ResolvedPalette, type ResolvedSemanticColors, type ResolvedTheme, type ResolvedTypography, type SemanticColorOverrides, type TenantThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, type ThemeModeColors, ThemeProvider, type ThemeProviderProps, type TypographyConfig, type UseDarkModeReturn, darken, fromDesignTokens, generateColorScale, generateThemePalette, hexToHsl, hslToHex, isValidHex, lighten, resolveTheme, useDarkMode, useTheme };