import { Observable } from 'rxjs';
import * as i0 from '@angular/core';
import { InjectionToken, EventEmitter, Signal } from '@angular/core';
/**
* Copyright (c) Siemens 2016 - 2026
* SPDX-License-Identifier: MIT
*/
/** */
interface ThemeDescription {
name: string;
groups: ThemePropertyGroup[];
}
interface ThemePropertyGroup {
name: string;
description?: string;
properties: ThemeProperty[];
}
interface ThemeProperty {
name: string;
usage: string;
type: ThemePropertyType;
}
type ThemePropertyType = 'color' | 'gradient' | 'font' | 'url' | 'text' | 'number';
interface Theme {
name: string;
schemes: ThemeColorSchemes;
/**
* A map of icons that overrides the default Element icons.
* The key must be the key of the original icon that should be overridden.
* The value has to be a data SVG string.
*
* @example
* ```ts
* {
* elementUser: "data:image/svg+xml;utf8,"
* }
* ```
*
* @experimental
*/
icons?: Record;
}
interface ThemeColorSchemes {
light?: ThemeColorScheme;
dark?: ThemeColorScheme;
}
type ThemeColorScheme = {
[key: string]: string;
};
type ColorScheme = 'light' | 'dark';
type ThemeType = ColorScheme | 'auto';
declare const ELEMENT_THEME_NAME = "element";
declare const elementTheme: ThemeDescription;
/**
* Copyright (c) Siemens 2016 - 2026
* SPDX-License-Identifier: MIT
*/
/**
* SiThemeStore object is used by the theme service to load and
* store the themes. You can inject your own implementation to provide
* a backend implementation. Otherwise a localStorage based implementation
* is used.
*/
declare abstract class SiThemeStore {
/**
* Load and return an alternative custom theme, other then
* the default element theme. This method is invoked initially
* to check for an alternative custom theme.
* @returns The active theme to be used, or undefined if the
* default element theme shall be used. All wrapped in an observable
* that can also emit errors.
*/
abstract loadActiveTheme(): Observable;
/**
* Sets the theme with the given name to active.
* @param name - The name of the theme to become active.
* @returns True on success, otherwise false.
*/
abstract activateTheme(name: string): Observable;
/**
* Deactivate any active theme and makes the element theme the default one.
* @returns True on success, otherwise false.
*/
abstract deactivateTheme(): Observable;
/**
* Load and return the available theme names.
* @returns An `Observable` of available theme names, other than the
* default element theme.
*/
abstract loadThemeNames(): Observable;
/**
* Load theme with the given `name`.
* @param name - The name of the theme to be returned.
* @returns Observable with the named theme or `undefined` if no such theme exist.
*/
abstract loadTheme(name: string): Observable;
/**
* Saves a theme to the store. The name shall not be empty. A theme with
* identical name gets overwritten.
* @param theme - The theme to be saved.
* @returns True on success, otherwise false. All nicely wrapped in
* an observable that may also emit errors.
*/
abstract saveTheme(theme: Theme): Observable;
/**
* Deletes the theme with the given name from the store.
* @param name - The name of the theme to be deleted.
* @returns True on success, otherwise false. All nicely wrapped in
* an observable that may also emit errors. Returns false,
* if the theme does not exist.
*/
abstract deleteTheme(name: string): Observable;
}
declare const SI_THEME_LOCAL_STORAGE_KEY = "si-themes";
interface ThemeStorage {
activeTheme: string | undefined;
themes: {
[key: string]: Theme;
};
}
declare class SiDefaultThemeStore extends SiThemeStore {
private isBrowser;
constructor(isBrowser: boolean);
loadActiveTheme(): Observable;
activateTheme(name: string): Observable;
deactivateTheme(): Observable;
loadThemeNames(): Observable;
saveTheme(theme: Theme): Observable;
loadTheme(name: string): Observable;
deleteTheme(name: string): Observable;
private loadStore;
private saveStore;
}
/**
* Copyright (c) Siemens 2016 - 2026
* SPDX-License-Identifier: MIT
*/
/**
* DOM boundary controlled by {@link SiThemeService}.
*/
interface SiThemeDomTarget {
/** Element that receives theme and color-scheme classes. */
readonly element: HTMLElement;
/** CSS selector used for runtime theme variables. */
readonly rootSelector: string;
/** Event target for the legacy `theme-switch` event. */
readonly eventTarget?: EventTarget;
forEachElement(callback: (element: HTMLElement) => void): void;
registerElement?(element: HTMLElement): () => void;
getStyleElement(id: string): HTMLStyleElement | null;
appendStyleElement(style: HTMLStyleElement): void;
updateColorScheme(colorScheme: ColorScheme): void;
}
/**
* Theme DOM target. The default implementation targets the current document.
*/
declare const SI_THEME_DOM_TARGET: InjectionToken;
declare class SiThemeService {
/**
* The current color scheme. (e.g. light or dark).
*/
private _resolvedColorScheme;
private resolvedColorSchemeSub;
/**
* Emits events when the color scheme changes.
*
* @defaultValue this.resolvedColorSchemeSub.asObservable()
*/
readonly resolvedColorScheme$: Observable;
/**
* The current color scheme. (e.g. light or dark).
*/
get resolvedColorScheme(): ThemeType | undefined;
/**
* All available theme names, including element theme name.
*/
private _themeNames;
private themeNamesSub;
/**
* Emits events when the list of available theme names changes.
*
* @defaultValue this.themeNamesSub.asObservable()
*/
readonly themeNames$: Observable;
/**
* All available theme names, including element theme name.
*/
get themeNames(): string[];
/**
* Emits events when the currently applied theme changes. Either by
* changing to another theme or by re-applying a theme with updated
* properties. When switching to default theme element, `undefined`
* is emitted.
*/
readonly themeChange: EventEmitter;
/**
* The name of the theme that is active. Theme name `element` is the default.
*/
activeThemeName?: string;
/**
* Icon overrides by the currently activeTheme.
* @defaultValue
* ```
* {}
* ```
*/
readonly themeIcons: i0.WritableSignal>;
private themes;
private themeStyles;
private darkMediaQuery?;
private mediaQueryListener?;
private isBrowser;
private previewTheme?;
private themeStore;
private document;
private themeTarget;
constructor();
/**
* Returns `true` if a theme with the given name is available.
*/
hasTheme(name: string): boolean;
/**
* Returns a clone of the theme with the given name or `undefined` if not
* available or name is `element`.
* @param name - The name of the theme to be returned.
* @returns The theme with the given name and `undefined` if name is `element`.
*/
getTheme(name: string): Observable;
/**
* Loads and returns the currently active theme. Returns undefined if no custom theme is used.
* @returns A custom theme or `undefined` if the default element theme is used.
*/
getActiveTheme(): Observable;
/**
* Adds or updates the given theme in the theme store.
* @param theme - The theme to be saved.
* @returns `true` if the theme was saved successfully.
*/
addOrUpdateTheme(theme: Theme): Observable;
/**
* Deletes the theme with the given name from the theme store.
*/
deleteTheme(name: string): Observable;
/**
* Resets the preview theme to the default element theme.
*/
resetPreview(): void;
/**
* Sets the active theme to the given name. If no name is given, the default element theme is used.
*/
setActiveTheme(name?: string, type?: ThemeType): Observable;
/**
* Apply `light` or `dark` theme to the configured theme target.
*/
applyThemeType(type: ThemeType): void;
/**
* Applies the given theme to the configured theme target. If no theme is given, the active theme is applied.
*/
applyTheme(theme?: Theme, type?: ThemeType, overwrite?: boolean): void;
/**
* Updates the given property of the preview theme.
*/
updateProperty(name: string, value: string, type: keyof ThemeColorSchemes): void;
/**
* Checks if the given theme JSON object is a valid theme.
*/
isThemeValid(data: unknown): boolean;
private isThemeTypeValid;
private applyThemeStyle;
private activateTheme;
private hasThemeCSS;
private createThemeCSS;
private createThemeSelector;
private createThemeVariantCSS;
private removeThemeCSS;
private toggleDark;
private cloneTheme;
private dispatchThemeSwitchEvent;
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵprov: i0.ɵɵInjectableDeclaration;
}
/**
* Returns a signal that reflects whether the current Element theme is dark (`true`) or light
* (`false`). The signal reacts to `theme-switch` events dispatched on `window`.
*
* @experimental
* @returns A boolean signal — `true` when the active theme is dark
* @throws When called outside of an Angular injection context
*/
declare const injectIsDarkTheme: () => Signal;
export { ELEMENT_THEME_NAME, SI_THEME_DOM_TARGET, SI_THEME_LOCAL_STORAGE_KEY, SiDefaultThemeStore, SiThemeService, SiThemeStore, elementTheme, injectIsDarkTheme };
export type { ColorScheme, SiThemeDomTarget, Theme, ThemeColorScheme, ThemeColorSchemes, ThemeDescription, ThemeProperty, ThemePropertyGroup, ThemePropertyType, ThemeStorage, ThemeType };