@sixbell-telco/sdk 1.4.0 → 1.6.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 +76 -0
- package/README.md +410 -472
- package/_index.css +26 -0
- package/components/dropdown/dropdown-chevron/dropdown-chevron.component.d.ts +6 -1
- package/components/dropdown/dropdown-content/dropdown-content.component.d.ts +1 -1
- package/components/dropdown/dropdown-item/dropdown-item.component.d.ts +6 -1
- package/components/dropdown/dropdown-item-checkbox/dropdown-item-checkbox.component.d.ts +7 -1
- package/components/dropdown/dropdown-item-radio/dropdown-item-radio.component.d.ts +7 -1
- package/components/dropdown/dropdown-trigger/dropdown-trigger.component.d.ts +30 -0
- package/components/dropdown/public-api.d.ts +0 -1
- package/components/dropdown/src/dropdown.component.d.ts +31 -7
- package/components/forms/combobox/src/combobox.component.d.ts +24 -0
- package/components/forms/select/src/select.component.d.ts +24 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs +472 -341
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +58 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +52 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-logger.mjs +578 -0
- package/fesm2022/sixbell-telco-sdk-utils-logger.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs +1222 -0
- package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +1434 -180
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +734 -182
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
- package/package.json +54 -46
- package/utils/logger/README.md +539 -0
- package/utils/logger/index.d.ts +5 -0
- package/utils/logger/public-api.d.ts +3 -0
- package/utils/logger/src/constants.d.ts +15 -0
- package/utils/logger/src/logger.service.d.ts +123 -0
- package/utils/logger/src/models/logger.d.ts +25 -0
- package/utils/logger/src/providers/logger.provider.d.ts +3 -0
- package/utils/resource-loader/README.md +460 -0
- package/utils/resource-loader/index.d.ts +5 -0
- package/utils/resource-loader/public-api.d.ts +1 -0
- package/utils/resource-loader/src/cache/index.d.ts +2 -0
- package/utils/resource-loader/src/cache/layers/factory.d.ts +38 -0
- package/utils/resource-loader/src/cache/layers/index.d.ts +3 -0
- package/utils/resource-loader/src/cache/layers/indexed-db-cache.d.ts +118 -0
- package/utils/resource-loader/src/cache/layers/local-storage-cache.d.ts +86 -0
- package/utils/resource-loader/src/cache/layers/memory-cache.d.ts +76 -0
- package/utils/resource-loader/src/cache/types.d.ts +107 -0
- package/utils/resource-loader/src/config/index.d.ts +1 -0
- package/utils/resource-loader/src/config/load-config.d.ts +32 -0
- package/utils/resource-loader/src/constants.d.ts +38 -0
- package/utils/resource-loader/src/http/index.d.ts +1 -0
- package/utils/resource-loader/src/http/retryable-client.d.ts +43 -0
- package/utils/resource-loader/src/index.d.ts +1 -0
- package/utils/resource-loader/src/resource-loader.d.ts +67 -0
- package/utils/resource-loader/src/types.d.ts +152 -0
- package/utils/resource-loader/src/utils/cache-validator.d.ts +72 -0
- package/utils/resource-loader/src/utils/helpers.d.ts +15 -0
- package/utils/resource-loader/src/utils/index.d.ts +2 -0
- package/utils/theme/README.md +1054 -109
- package/utils/theme/public-api.d.ts +9 -1
- package/utils/theme/src/constants.d.ts +74 -0
- package/utils/theme/src/models/theme.d.ts +288 -0
- package/utils/theme/src/providers/constants.d.ts +7 -0
- package/utils/theme/src/providers/theme.provider.d.ts +13 -0
- package/utils/theme/src/providers/theme.provider.types.d.ts +29 -0
- package/utils/theme/src/theme-assets/theme-assets.service.d.ts +214 -0
- package/utils/theme/src/theme-assets/theme-assets.types.d.ts +10 -0
- package/utils/theme/src/theme-dom/theme-dom.service.d.ts +87 -0
- package/utils/theme/src/theme-scheme/theme-scheme.service.d.ts +44 -0
- package/utils/theme/src/theme-storage/theme-storage.service.d.ts +47 -0
- package/utils/theme/src/theme.service.d.ts +40 -186
- package/utils/theme/src/utils/utils.d.ts +86 -0
- package/utils/translation/README.md +1414 -176
- package/utils/translation/public-api.d.ts +6 -0
- package/utils/translation/src/constants.d.ts +52 -0
- package/utils/translation/src/models/translation.d.ts +59 -0
- package/utils/translation/src/providers/constants.d.ts +11 -0
- package/utils/translation/src/providers/translation.provider.d.ts +73 -0
- package/utils/translation/src/providers/translation.provider.types.d.ts +26 -0
- package/utils/translation/src/translation-dom/translation-dom.service.d.ts +26 -0
- package/utils/translation/src/translation-storage/translation-storage.service.d.ts +34 -0
- package/utils/translation/src/translation.service.d.ts +19 -166
- package/components/dropdown/src/services/dropdown.service.d.ts +0 -22
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { RendererFactory2 } from '@angular/core';
|
|
2
|
+
import { FontDefinition, ThemeVariants } from '../models/theme';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Service responsible for all DOM manipulation and CSS injection
|
|
6
|
+
* Decouples DOM operations from business logic
|
|
7
|
+
*/
|
|
8
|
+
export declare class ThemeDomService {
|
|
9
|
+
private readonly rendererFactory;
|
|
10
|
+
private readonly document;
|
|
11
|
+
private readonly renderer;
|
|
12
|
+
constructor(rendererFactory: RendererFactory2, document: Document);
|
|
13
|
+
/**
|
|
14
|
+
* Injects font-face declarations into the document head
|
|
15
|
+
* Creates a single style tag containing all font face definitions
|
|
16
|
+
* @param fonts - Array of font definitions with faces
|
|
17
|
+
*/
|
|
18
|
+
injectFonts(fonts: FontDefinition[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Injects global CSS variables as root-level custom properties
|
|
21
|
+
* Sets variables directly on the document element
|
|
22
|
+
* @param variables - Record of CSS variable names to values
|
|
23
|
+
*/
|
|
24
|
+
injectGlobalVariables(variables: Record<string, string>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Injects theme-specific CSS variables as data-theme selectors
|
|
27
|
+
* Creates styles for each theme variant (light/dark)
|
|
28
|
+
* @param themes - Theme definitions with variants
|
|
29
|
+
*/
|
|
30
|
+
injectThemeStyles(themes: Record<string, ThemeVariants>): void;
|
|
31
|
+
/**
|
|
32
|
+
* Sets the active theme on the document body
|
|
33
|
+
* Uses data-theme attribute for CSS theme targeting
|
|
34
|
+
* @param themeIdentifier - Theme identifier (e.g., "sixbell_telco__light")
|
|
35
|
+
*/
|
|
36
|
+
setActiveTheme(themeIdentifier: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Builds @font-face CSS rules from font definitions
|
|
39
|
+
* Private helper to construct font-face declarations
|
|
40
|
+
* @param fonts - Array of font definitions
|
|
41
|
+
* @returns CSS content string with @font-face rules
|
|
42
|
+
*/
|
|
43
|
+
private buildFontFaceStyles;
|
|
44
|
+
/**
|
|
45
|
+
* Builds @font-face rules for a single font family
|
|
46
|
+
* @param font - Font definition with faces
|
|
47
|
+
* @returns CSS content string with all faces for this family
|
|
48
|
+
*/
|
|
49
|
+
private buildFontFaceForFamily;
|
|
50
|
+
/**
|
|
51
|
+
* Builds a single @font-face rule
|
|
52
|
+
* @param fontFamily - Font family name
|
|
53
|
+
* @param face - Font face definition
|
|
54
|
+
* @returns @font-face CSS rule
|
|
55
|
+
*/
|
|
56
|
+
private buildFontFaceRule;
|
|
57
|
+
/**
|
|
58
|
+
* Builds theme style definitions as CSS custom properties
|
|
59
|
+
* Creates selectors for each theme variant
|
|
60
|
+
* @param themes - Theme definitions mapped by theme code
|
|
61
|
+
* @returns CSS content string with theme definitions
|
|
62
|
+
*/
|
|
63
|
+
private buildThemeStyles;
|
|
64
|
+
/**
|
|
65
|
+
* Builds CSS rules for light and dark variants of a theme
|
|
66
|
+
* @param themeName - Name of the theme
|
|
67
|
+
* @param variants - Light and dark variants
|
|
68
|
+
* @returns Array of CSS rules for each variant
|
|
69
|
+
*/
|
|
70
|
+
private buildThemeVariantStyles;
|
|
71
|
+
/**
|
|
72
|
+
* Builds a single theme variant CSS rule
|
|
73
|
+
* @param themeName - Name of the theme
|
|
74
|
+
* @param scheme - Scheme variant ('light' or 'dark')
|
|
75
|
+
* @param variables - CSS variables for this variant
|
|
76
|
+
* @returns CSS rule string
|
|
77
|
+
*/
|
|
78
|
+
private buildThemeVariantRule;
|
|
79
|
+
/**
|
|
80
|
+
* Appends a style tag to the document head
|
|
81
|
+
* Helper to inject CSS into the document
|
|
82
|
+
* @param content - CSS content to inject
|
|
83
|
+
*/
|
|
84
|
+
private appendStyleToHead;
|
|
85
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ThemeDomService, never>;
|
|
86
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ThemeDomService>;
|
|
87
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ResolvedThemeScheme, ThemeScheme } from '../models/theme';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Service for resolving and detecting color schemes
|
|
5
|
+
* Handles system preference detection and scheme validation
|
|
6
|
+
* Separates scheme logic from the main service
|
|
7
|
+
*/
|
|
8
|
+
export declare class ThemeSchemeService {
|
|
9
|
+
/**
|
|
10
|
+
* Media query list for detecting dark mode preference
|
|
11
|
+
* Cached to avoid repeated queries
|
|
12
|
+
*/
|
|
13
|
+
private darkModeMediaQuery;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a theme scheme to its actual light/dark value
|
|
16
|
+
* If scheme is 'system', detects the OS preference
|
|
17
|
+
* If scheme is already 'light' or 'dark', returns it as-is
|
|
18
|
+
* @param scheme - The scheme to resolve
|
|
19
|
+
* @returns Resolved scheme ('light' or 'dark')
|
|
20
|
+
*/
|
|
21
|
+
resolveScheme(scheme: ThemeScheme): ResolvedThemeScheme;
|
|
22
|
+
/**
|
|
23
|
+
* Detects the system's preferred color scheme
|
|
24
|
+
* Uses CSS media query (prefers-color-scheme: dark)
|
|
25
|
+
* Safely handles environments where matchMedia is not available
|
|
26
|
+
* @returns 'dark' if system prefers dark, 'light' otherwise
|
|
27
|
+
*/
|
|
28
|
+
detectSystemScheme(): ResolvedThemeScheme;
|
|
29
|
+
/**
|
|
30
|
+
* Listens for changes in system color scheme preference
|
|
31
|
+
* Allows components to react to OS theme changes
|
|
32
|
+
* @param listener - Callback function when scheme changes
|
|
33
|
+
* @returns Unsubscribe function to remove listener
|
|
34
|
+
*/
|
|
35
|
+
listenToSystemSchemeChanges(listener: (scheme: ResolvedThemeScheme) => void): () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a media query for detecting dark mode
|
|
38
|
+
* Extracted method to make testing easier
|
|
39
|
+
* @returns MediaQueryList for dark mode preference
|
|
40
|
+
*/
|
|
41
|
+
private createMediaQuery;
|
|
42
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ThemeSchemeService, never>;
|
|
43
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ThemeSchemeService>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ThemeScheme } from '../models/theme';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Service for managing theme preferences in local storage
|
|
5
|
+
* Provides safe access to localStorage with error handling
|
|
6
|
+
* Works gracefully in non-browser environments (SSR)
|
|
7
|
+
*/
|
|
8
|
+
export declare class ThemeStorageService {
|
|
9
|
+
private readonly logger;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the saved theme preference from localStorage
|
|
12
|
+
* Returns null if no saved preference or storage unavailable
|
|
13
|
+
* @returns Saved theme name or null
|
|
14
|
+
*/
|
|
15
|
+
getSavedTheme(): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Saves the current theme preference to localStorage
|
|
18
|
+
* Fails silently if storage is unavailable
|
|
19
|
+
* @param theme - Theme name to save
|
|
20
|
+
*/
|
|
21
|
+
saveTheme(theme: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the saved scheme preference from localStorage
|
|
24
|
+
* Returns null if no saved preference or storage unavailable
|
|
25
|
+
* @returns Saved scheme ('system', 'light', 'dark') or null
|
|
26
|
+
*/
|
|
27
|
+
getSavedScheme(): ThemeScheme | null;
|
|
28
|
+
/**
|
|
29
|
+
* Saves the current scheme preference to localStorage
|
|
30
|
+
* Fails silently if storage is unavailable
|
|
31
|
+
* @param scheme - Scheme to save
|
|
32
|
+
*/
|
|
33
|
+
saveScheme(scheme: ThemeScheme): void;
|
|
34
|
+
/**
|
|
35
|
+
* Clears all saved theme preferences from localStorage
|
|
36
|
+
* Useful for resetting to defaults
|
|
37
|
+
*/
|
|
38
|
+
clear(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Constructs a namespaced storage key to avoid collisions
|
|
41
|
+
* @param key - The base storage key
|
|
42
|
+
* @returns Namespaced key (e.g., "theme:selectedTheme")
|
|
43
|
+
*/
|
|
44
|
+
private getStorageKey;
|
|
45
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ThemeStorageService, never>;
|
|
46
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ThemeStorageService>;
|
|
47
|
+
}
|
|
@@ -1,206 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ResourceLoader, ResourceLoaderRequestOptions } from '@sixbell-telco/sdk/utils/resource-loader';
|
|
2
|
+
import { FontDefinition, ResolvedThemeScheme, RuntimeThemeConfig, ThemeConfig, ThemeConfigWithAdditionalThemes, ThemeConfigWithoutAdditionalThemes, ThemeScheme, ThemeStyleDefinition } from './models/theme';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
export
|
|
5
|
-
export type ResolvedThemeScheme
|
|
6
|
-
export declare const DEFAULT_BASE_THEME = "sixbell_telco";
|
|
7
|
-
export declare const DEFAULT_THEMES: readonly ["sixbell_telco"];
|
|
8
|
-
export declare const DEFAULT_THEME_CODES: readonly ["sixbell_telco"];
|
|
9
|
-
export type DefaultThemeCode = (typeof DEFAULT_THEME_CODES)[number];
|
|
10
|
-
type ExtractThemeCode<T> = T extends readonly (infer U)[] ? U : never;
|
|
11
|
-
/**
|
|
12
|
-
* Base theme configuration interface without additional themes
|
|
13
|
-
* Provides IntelliSense for the default base theme (sixbell_telco)
|
|
14
|
-
*/
|
|
15
|
-
export interface ThemeConfigWithoutAdditionalThemes {
|
|
16
|
-
/**
|
|
17
|
-
* Default theme code (base theme: sixbell_telco)
|
|
18
|
-
* @example 'sixbell_telco'
|
|
19
|
-
*/
|
|
20
|
-
defaultTheme?: DefaultThemeCode;
|
|
21
|
-
/**
|
|
22
|
-
* Themes to exclude from the available set (base theme: sixbell_telco)
|
|
23
|
-
* @example ['sixbell_telco'] to exclude the default theme
|
|
24
|
-
*/
|
|
25
|
-
excludeThemes?: readonly DefaultThemeCode[];
|
|
26
|
-
/**
|
|
27
|
-
* Default color scheme preference
|
|
28
|
-
* @example 'system' | 'light' | 'dark'
|
|
29
|
-
*/
|
|
30
|
-
defaultScheme?: ThemeScheme;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Theme configuration interface with additional themes providing IntelliSense
|
|
34
|
-
*/
|
|
35
|
-
export interface ThemeConfigWithAdditionalThemes<T extends readonly string[]> {
|
|
36
|
-
/**
|
|
37
|
-
* Additional themes to make available beyond the default base theme (sixbell_telco)
|
|
38
|
-
* When you add themes here, they become available in defaultTheme and excludeThemes
|
|
39
|
-
* @example ['custom', 'dark_mode', 'high_contrast']
|
|
40
|
-
*/
|
|
41
|
-
additionalThemes: T;
|
|
42
|
-
/**
|
|
43
|
-
* Default theme code
|
|
44
|
-
* IntelliSense includes: base theme (sixbell_telco) + any additionalThemes you specified above
|
|
45
|
-
* @example 'sixbell_telco'
|
|
46
|
-
*/
|
|
47
|
-
defaultTheme?: DefaultThemeCode | ExtractThemeCode<T>;
|
|
48
|
-
/**
|
|
49
|
-
* Themes to exclude from the available set
|
|
50
|
-
* IntelliSense includes: base theme (sixbell_telco) + any additionalThemes you specified above
|
|
51
|
-
* @example ['sixbell_telco'] to exclude the default theme
|
|
52
|
-
*/
|
|
53
|
-
excludeThemes?: readonly (DefaultThemeCode | ExtractThemeCode<T>)[];
|
|
54
|
-
/**
|
|
55
|
-
* Default color scheme preference
|
|
56
|
-
* @example 'system' | 'light' | 'dark'
|
|
57
|
-
*/
|
|
58
|
-
defaultScheme?: ThemeScheme;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Main theme configuration interface (generic version)
|
|
62
|
-
* Always provides IntelliSense for at least the base theme (sixbell_telco)
|
|
63
|
-
*/
|
|
64
|
-
export interface ThemeConfig {
|
|
65
|
-
/**
|
|
66
|
-
* Additional themes to make available beyond the default base theme (sixbell_telco)
|
|
67
|
-
* When you add themes here, they become available in defaultTheme and excludeThemes
|
|
68
|
-
* @example ['custom', 'dark_mode', 'high_contrast']
|
|
69
|
-
*/
|
|
70
|
-
additionalThemes?: readonly string[];
|
|
71
|
-
/**
|
|
72
|
-
* Default theme code
|
|
73
|
-
* Always includes base theme (sixbell_telco), plus any additionalThemes you specify
|
|
74
|
-
* @example 'sixbell_telco'
|
|
75
|
-
*/
|
|
76
|
-
defaultTheme?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Themes to exclude from the available set
|
|
79
|
-
* Always includes base theme (sixbell_telco), plus any additionalThemes you specify
|
|
80
|
-
* @example ['sixbell_telco'] to exclude the default theme
|
|
81
|
-
*/
|
|
82
|
-
excludeThemes?: readonly string[];
|
|
83
|
-
/**
|
|
84
|
-
* Default color scheme preference
|
|
85
|
-
* @example 'system' | 'light' | 'dark'
|
|
86
|
-
*/
|
|
87
|
-
defaultScheme?: ThemeScheme;
|
|
88
|
-
}
|
|
89
|
-
export declare const THEME_CONFIG_TOKEN: InjectionToken<ThemeConfig>;
|
|
4
|
+
export { DEFAULT_BASE_THEME, FALLBACK_RUNTIME_THEME_CONFIG, RUNTIME_THEME_CONFIG_TOKEN, THEME_CONFIG_TOKEN } from './constants';
|
|
5
|
+
export type { FontDefinition, ResolvedThemeScheme, RuntimeThemeConfig, ThemeConfig, ThemeConfigWithAdditionalThemes, ThemeConfigWithoutAdditionalThemes, ThemeScheme, ThemeStyleDefinition, };
|
|
90
6
|
export declare class ThemeService {
|
|
91
|
-
private readonly rendererFactory;
|
|
92
|
-
private readonly document;
|
|
93
7
|
private readonly themeConfig?;
|
|
94
|
-
readonly
|
|
95
|
-
private readonly
|
|
96
|
-
private
|
|
8
|
+
private readonly runtimeThemeConfig?;
|
|
9
|
+
private readonly translationService;
|
|
10
|
+
private readonly domService;
|
|
11
|
+
private readonly storageService;
|
|
12
|
+
private readonly schemeResolver;
|
|
13
|
+
private readonly assetsService;
|
|
14
|
+
private readonly router;
|
|
15
|
+
private readonly logger;
|
|
16
|
+
private runtimeConfigPath?;
|
|
17
|
+
private runtimeLoader?;
|
|
18
|
+
private runtimeLoaderOptions?;
|
|
19
|
+
private navigationSubscription?;
|
|
20
|
+
private skipFirstNavigation;
|
|
21
|
+
private isUsingFallbackConfig;
|
|
97
22
|
private config;
|
|
98
|
-
selectedTheme: import("@angular/core").WritableSignal<string>;
|
|
99
|
-
selectedScheme: import("@angular/core").WritableSignal<ThemeScheme>;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*/
|
|
105
|
-
resolvedScheme: import("@angular/core").Signal<"light" | "dark">;
|
|
106
|
-
/**
|
|
107
|
-
* Convenient computed signal that returns true when the current resolved scheme is 'dark'.
|
|
108
|
-
*/
|
|
109
|
-
isDarkTheme: import("@angular/core").Signal<boolean>;
|
|
110
|
-
finalTheme: import("@angular/core").Signal<string>;
|
|
111
|
-
constructor(rendererFactory: RendererFactory2, document: Document, themeConfig?: ThemeConfig | undefined);
|
|
112
|
-
/**
|
|
113
|
-
* Configure and initialize the theme service (used by provider)
|
|
114
|
-
*/
|
|
23
|
+
readonly selectedTheme: import("@angular/core").WritableSignal<string>;
|
|
24
|
+
readonly selectedScheme: import("@angular/core").WritableSignal<ThemeScheme>;
|
|
25
|
+
readonly resolvedScheme: import("@angular/core").Signal<ResolvedThemeScheme>;
|
|
26
|
+
readonly isDarkTheme: import("@angular/core").Signal<boolean>;
|
|
27
|
+
readonly finalTheme: import("@angular/core").Signal<string>;
|
|
28
|
+
constructor(themeConfig?: ThemeConfig | undefined, runtimeThemeConfig?: RuntimeThemeConfig | undefined);
|
|
115
29
|
configure(config?: ThemeConfig): void;
|
|
116
|
-
|
|
117
|
-
* Initialize theme from localStorage and apply it immediately
|
|
118
|
-
*/
|
|
119
|
-
private initializeFromStorage;
|
|
120
|
-
/**
|
|
121
|
-
* Apply the current theme to the document
|
|
122
|
-
*/
|
|
123
|
-
private applyTheme;
|
|
124
|
-
/**
|
|
125
|
-
* Set the current theme
|
|
126
|
-
*/
|
|
30
|
+
configureRuntime(config: RuntimeThemeConfig): void;
|
|
127
31
|
setTheme(theme: string): void;
|
|
128
|
-
/**
|
|
129
|
-
* Set the current color scheme
|
|
130
|
-
*/
|
|
131
32
|
setScheme(scheme: ThemeScheme): void;
|
|
132
|
-
/**
|
|
133
|
-
* Get available themes
|
|
134
|
-
*/
|
|
135
33
|
getAvailableThemes(): string[];
|
|
136
|
-
/**
|
|
137
|
-
* Get available schemes
|
|
138
|
-
*/
|
|
139
34
|
getAvailableSchemes(): ThemeScheme[];
|
|
140
|
-
/**
|
|
141
|
-
* Get default theme
|
|
142
|
-
*/
|
|
143
35
|
getDefaultTheme(): string;
|
|
144
|
-
/**
|
|
145
|
-
* Get default scheme
|
|
146
|
-
*/
|
|
147
36
|
getDefaultScheme(): ThemeScheme;
|
|
37
|
+
getLocalizedSchemeName(scheme: string): string;
|
|
38
|
+
getLocalizedThemeName(theme: string): string;
|
|
39
|
+
private initializeFromStorage;
|
|
40
|
+
private applyTheme;
|
|
148
41
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
42
|
+
* Internal method to set runtime loader and enable navigation-based reloading.
|
|
43
|
+
* Called by provideRuntimeTheme.
|
|
44
|
+
* @internal
|
|
151
45
|
*/
|
|
152
|
-
|
|
46
|
+
setRuntimeLoader(configPath: string, loader: ResourceLoader, loaderOptions?: ResourceLoaderRequestOptions<RuntimeThemeConfig>): void;
|
|
153
47
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
48
|
+
* Internal method to configure runtime theme with config source information.
|
|
49
|
+
* @internal
|
|
156
50
|
*/
|
|
157
|
-
|
|
51
|
+
configureRuntimeWithSource(config: RuntimeThemeConfig, source: 'network' | 'cache' | 'fallback'): void;
|
|
158
52
|
/**
|
|
159
|
-
*
|
|
53
|
+
* Manually reload the runtime theme configuration from the configured path.
|
|
54
|
+
* Useful for hot-reload scenarios or programmatic refresh.
|
|
160
55
|
*/
|
|
56
|
+
reloadRuntimeConfig(): Promise<void>;
|
|
161
57
|
init(): void;
|
|
162
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, [
|
|
58
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, [{ optional: true; }, { optional: true; }]>;
|
|
163
59
|
static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
|
|
164
60
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Provider function for theme configuration in Angular applications
|
|
167
|
-
* This provides the theme configuration through dependency injection
|
|
168
|
-
*
|
|
169
|
-
* @param config Optional theme configuration
|
|
170
|
-
* @returns Provider array that configures theme service
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```typescript
|
|
174
|
-
* // app.config.ts
|
|
175
|
-
* import { provideTheme } from '@sixbell-telco/sdk/utils/theme';
|
|
176
|
-
*
|
|
177
|
-
* export const appConfig: ApplicationConfig = {
|
|
178
|
-
* providers: [
|
|
179
|
-
* provideRouter(routes),
|
|
180
|
-
*
|
|
181
|
-
* // Basic usage - sixbell_telco always available
|
|
182
|
-
* provideTheme({
|
|
183
|
-
* defaultScheme: 'light',
|
|
184
|
-
* defaultTheme: 'sixbell_telco' // IntelliSense: 'sixbell_telco'
|
|
185
|
-
* }),
|
|
186
|
-
*
|
|
187
|
-
* // With additional themes
|
|
188
|
-
* provideTheme({
|
|
189
|
-
* additionalThemes: ['wom', 'custom'] as const,
|
|
190
|
-
* defaultTheme: 'custom', // IntelliSense: 'sixbell_telco' | string
|
|
191
|
-
* excludeThemes: ['wom'] as const, // IntelliSense: 'sixbell_telco' | string
|
|
192
|
-
* defaultScheme: 'system'
|
|
193
|
-
* }),
|
|
194
|
-
*
|
|
195
|
-
* // ... other providers
|
|
196
|
-
* ],
|
|
197
|
-
* };
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
export declare function provideTheme<const T extends readonly string[] = []>(config?: {
|
|
201
|
-
additionalThemes?: T;
|
|
202
|
-
defaultTheme?: T extends readonly [string, ...string[]] ? DefaultThemeCode | ExtractThemeCode<T> : DefaultThemeCode;
|
|
203
|
-
excludeThemes?: T extends readonly [string, ...string[]] ? readonly (DefaultThemeCode | ExtractThemeCode<T>)[] : readonly DefaultThemeCode[];
|
|
204
|
-
defaultScheme?: ThemeScheme;
|
|
205
|
-
}): (Provider | EnvironmentProviders)[];
|
|
206
|
-
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Utility Functions
|
|
3
|
+
* Pure, side-effect-free utilities for theme logic
|
|
4
|
+
*/
|
|
5
|
+
import { ThemeStateConfig } from '../models/theme';
|
|
6
|
+
/**
|
|
7
|
+
* Validates that a given value is a valid theme scheme
|
|
8
|
+
* @param value - The value to validate
|
|
9
|
+
* @returns True if the value is a valid scheme ('system', 'light', or 'dark')
|
|
10
|
+
*/
|
|
11
|
+
export declare function isValidScheme(value: unknown): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Builds the final theme identifier by combining theme name and scheme
|
|
14
|
+
* @param themeName - The name of the theme
|
|
15
|
+
* @param scheme - The scheme variant (light or dark)
|
|
16
|
+
* @returns Combined identifier (e.g., "sixbell_telco__light")
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildThemeIdentifier(themeName: string, scheme: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Extracts theme name and scheme from a combined identifier
|
|
21
|
+
* @param identifier - The combined identifier (e.g., "sixbell_telco__light")
|
|
22
|
+
* @returns Object with extracted themeName and scheme
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseThemeIdentifier(identifier: string): {
|
|
25
|
+
themeName: string;
|
|
26
|
+
scheme: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Builds the list of available themes from configuration
|
|
30
|
+
* Starts with default base theme, adds additional themes, and filters exclusions
|
|
31
|
+
* Removes duplicates and returns sorted list
|
|
32
|
+
* @param additionalThemes - Additional themes to include
|
|
33
|
+
* @param excludeThemes - Themes to exclude
|
|
34
|
+
* @returns Deduplicated list of available themes
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildAvailableThemes(additionalThemes?: readonly string[], excludeThemes?: readonly string[]): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Determines the effective default theme from configuration
|
|
39
|
+
* Ensures the default theme is in the available themes list
|
|
40
|
+
* Falls back to first available theme if default is not available
|
|
41
|
+
* @param defaultTheme - Configured default theme
|
|
42
|
+
* @param availableThemes - List of available themes
|
|
43
|
+
* @returns The effective default theme to use
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveDefaultTheme(defaultTheme: string | undefined, availableThemes: string[]): string;
|
|
46
|
+
/**
|
|
47
|
+
* Validates that a given theme exists in the available themes
|
|
48
|
+
* @param theme - Theme name to validate
|
|
49
|
+
* @param availableThemes - List of available themes
|
|
50
|
+
* @returns True if theme is available
|
|
51
|
+
*/
|
|
52
|
+
export declare function isThemeAvailable(theme: string, availableThemes: string[]): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Validates the configuration and logs warnings for invalid states
|
|
55
|
+
* Returns true if configuration is valid for use
|
|
56
|
+
* @param config - Configuration to validate
|
|
57
|
+
* @param configName - Name of config for logging purposes
|
|
58
|
+
* @returns True if configuration is valid
|
|
59
|
+
*/
|
|
60
|
+
export declare function validateThemeConfig(config: ThemeStateConfig, configName?: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Formats a theme name for display to users
|
|
63
|
+
* Converts snake_case to Title Case
|
|
64
|
+
* @param theme - Theme name to format
|
|
65
|
+
* @returns Formatted theme name
|
|
66
|
+
*/
|
|
67
|
+
export declare function formatThemeName(theme: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Formats a scheme name for display to users
|
|
70
|
+
* Capitalizes first letter
|
|
71
|
+
* @param scheme - Scheme name to format
|
|
72
|
+
* @returns Formatted scheme name
|
|
73
|
+
*/
|
|
74
|
+
export declare function formatSchemeName(scheme: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if the browser supports the matchMedia API
|
|
77
|
+
* Safe to call in non-browser environments
|
|
78
|
+
* @returns True if matchMedia is available
|
|
79
|
+
*/
|
|
80
|
+
export declare function supportsMediaQuery(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if localStorage is available in the current environment
|
|
83
|
+
* Safe to call in non-browser environments
|
|
84
|
+
* @returns True if localStorage is accessible
|
|
85
|
+
*/
|
|
86
|
+
export declare function hasLocalStorage(): boolean;
|