UNPKG

@alyle/ui

Version:

Minimal Design, a set of components for Angular

140 lines (139 loc) 5.71 kB
import { Renderer2, NgZone } from '@angular/core'; import { ThemeVariables, ThemeConfig } from './theme-config'; import { CoreTheme } from './core-theme.service'; import { DataStyle } from '../theme.service'; import { Dir } from '../style-utils'; import { TypeStyle, StyleContainer, Styles, StyleDeclarationsBlock, LyClasses, LyStyles, LySelectors } from './style'; import { StyleTemplate, StringIdGenerator } from '../parse'; import { Platform } from '@angular/cdk/platform'; import * as i0 from "@angular/core"; export declare const keyframesUniqueId: StringIdGenerator; export declare class StylesInDocument { styles: { [themeName: string]: Map<string | Styles, HTMLStyleElement>; }; styleContainers: Map<number, HTMLElement>; styleElementGlobalMap: Map<string | Styles, HTMLStyleElement>; static ɵfac: i0.ɵɵFactoryDeclaration<StylesInDocument, never>; static ɵprov: i0.ɵɵInjectableDeclaration<StylesInDocument>; } export declare class LyTheme2 { private stylesInDocument; core: CoreTheme; private _ngZone; private _platform; /** * @deprecated use `themeVariables` instead */ config: ThemeVariables; _styleMap: Map<string, DataStyle>; initialTheme: string; elements: Map<string | Styles, HTMLStyleElement>; _elementsMap: Map<any, HTMLStyleElement>; /** Event emitted when the direction has changed. */ private _directionChanged; get directionChanged(): import("rxjs").Observable<void>; /** Event emitted when the theme has changed. */ private _themeChanged; readonly themeChanged: import("rxjs").Observable<void>; /** Get Theme Variables */ get variables(): ThemeVariables; private themeMap; /** ssr or hmr */ private isDevOrServer; protected _document: Document; constructor(stylesInDocument: StylesInDocument, core: CoreTheme, themeName: any, themeConfig: ThemeConfig[] | ThemeConfig, globalVariables: ThemeConfig, _document: any, _ngZone: NgZone, _platform: Platform); setUpTheme(themeName: string): void; /** * Build multiple styles and render them in the DOM */ renderStyleSheet<T>(styles: T & LyStyles): LyClasses<T>; renderStyle<THEME_VARIABLES>(id: string, style: (theme: THEME_VARIABLES, ref: ThemeRef) => StyleTemplate, priority?: number): string; renderStyle<THEME_VARIABLES>(style: (theme: THEME_VARIABLES, ref: ThemeRef) => StyleTemplate, priority?: number): string; /** * Add a new dynamic style, use only within @Input() * @param id Unique id * @param style Styles * @param el Element * @param instance The instance of this, this replaces the existing style with a new one when it changes * @param parentStyle Parent Style */ addStyle(id: string, style?: StyleDeclarationsBlock, el?: any, instance?: string | null, priority?: number | null, parentStyle?: Styles): string; /** * Create basic style * @param style Styles. * Note: Use only with immutable variable. * @param priority Priority of style * @param parentStyle */ style(style: StyleDeclarationsBlock, priority?: number | null, parentStyle?: Styles): string; private updateClassName; updateClass(element: any, renderer: Renderer2, newClass: string, oldClass?: string): string; /** * Change the current theme for another. * @param themeName theme name */ setTheme(themeName: string): void; /** Toggle right-to-left/left-to-right */ toggleDirection(): void; setDirection(dir: Dir | `${Dir}`): void; private _updateAllStyles; /** * Create a simple style * return className * @param id id of style * @param css style object or string * @param priority style priority(default: 0) */ addSimpleStyle(id: string, css: StyleContainer | ((theme: any) => StyleContainer), priority?: number, parentStyle?: Styles): string; /** * Add new add a new style sheet * @param styles styles * @param priority priority for style */ addStyleSheet<T>(styles: T & Styles, priority?: number): LyClasses<T>; /** * Check if a style exist * @param stylesOrId Style or Id of a style */ existStyle(stylesOrId: string | Styles | StyleDeclarationsBlock): boolean; /** * return selectors if exists * * e.g. * * ```ts * { * root: '.c' * } * ``` * @param styles id */ selectorsOf<T>(styles: T): LySelectors<T>; selectorOf(styles: string | StyleTemplate): string; /** * For internal use only * @docs-private */ _createStyleContent2(styles: Styles | StyleDeclarationsBlock | ((theme: any, ref: ThemeRef) => StyleTemplate), id: string | null, priority: number | undefined | null, type: TypeStyle, forChangeTheme?: boolean, parentStyle?: Styles): any; private _createStyleContainer; private _getRefFromAPriority; private _createStyleElement; private _renderCss; requestAnimationFrame(fn: (...args: any[]) => void): void; static ɵfac: i0.ɵɵFactoryDeclaration<LyTheme2, [null, null, null, { optional: true; }, { optional: true; }, null, null, null]>; static ɵprov: i0.ɵɵInjectableDeclaration<LyTheme2>; } export declare function converterToCssKeyAndStyle(str: string, themeVariables: ThemeVariables): string; export declare function capitalizeFirstLetter(str: string): string; /** * Create next class id from key * @private */ export declare const ck: (_key: string) => string; /** * Create next selector id from key */ export declare const dot: (key: string) => string; export interface ThemeRef extends Pick<LyTheme2, 'selectorsOf' | 'renderStyleSheet'> { }