@sixbell-telco/sdk
Version:
A collection of reusable components designed for use in Sixbell Telco Angular projects
79 lines (78 loc) • 3.11 kB
TypeScript
/**
* Theme Utility Functions
* Pure, side-effect-free utilities for theme logic
*/
import { VALID_SCHEMES } from '../constants';
import { ThemeStateConfig } from '../models/theme';
/**
* Validates that a given value is a valid theme scheme
* @param value - The value to validate
* @returns True if the value is a valid scheme ('system', 'light', or 'dark')
*/
export declare function isValidScheme(value: unknown): value is (typeof VALID_SCHEMES)[number];
/**
* Builds the final theme identifier by combining theme name and scheme
* @param themeName - The name of the theme
* @param scheme - The scheme variant (light or dark)
* @returns Combined identifier (e.g., "sixbell_telco__light")
*/
export declare function buildThemeIdentifier(themeName: string, scheme: string): string;
/**
* Extracts theme name and scheme from a combined identifier
* @param identifier - The combined identifier (e.g., "sixbell_telco__light")
* @returns Object with extracted themeName and scheme
*/
export declare function parseThemeIdentifier(identifier: string): {
themeName: string;
scheme: string;
};
/**
* Determines the effective default theme from configuration
* Ensures the default theme is in the available themes list
* Falls back to first available theme if default is not available
* @param defaultTheme - Configured default theme
* @param availableThemes - List of available themes
* @returns The effective default theme to use
*/
export declare function resolveDefaultTheme(defaultTheme: string | undefined, availableThemes: string[]): string;
/**
* Validates that a given theme exists in the available themes
* @param theme - Theme name to validate
* @param availableThemes - List of available themes
* @returns True if theme is available
*/
export declare function isThemeAvailable(theme: string, availableThemes: string[]): boolean;
/**
* Validates the configuration and logs warnings for invalid states
* Returns true if configuration is valid for use
* @param config - Configuration to validate
* @param configName - Name of config for logging purposes
* @returns True if configuration is valid
*/
export declare function validateThemeConfig(config: ThemeStateConfig, configName?: string): boolean;
/**
* Formats a theme name for display to users
* Converts snake_case to Title Case
* @param theme - Theme name to format
* @returns Formatted theme name
*/
export declare function formatThemeName(theme: string): string;
/**
* Formats a scheme name for display to users
* Capitalizes first letter
* @param scheme - Scheme name to format
* @returns Formatted scheme name
*/
export declare function formatSchemeName(scheme: string): string;
/**
* Checks if the browser supports the matchMedia API
* Safe to call in non-browser environments
* @returns True if matchMedia is available
*/
export declare function supportsMediaQuery(): boolean;
/**
* Checks if localStorage is available in the current environment
* Safe to call in non-browser environments
* @returns True if localStorage is accessible
*/
export declare function hasLocalStorage(): boolean;