UNPKG

@angular-mdc/web

Version:
93 lines (92 loc) 3.81 kB
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { AfterViewChecked, ElementRef, InjectionToken, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; import { MdcIconRegistry } from './icon-registry'; export interface MdcIconLocation { getPathname: () => string; } export declare function MDC_ICON_LOCATION_FACTORY(): MdcIconLocation; /** * Injection token used to provide the current location to `MdcIcon`. * Used to handle server-side rendering and to stub out during unit tests. */ export declare const MDC_ICON_LOCATION: InjectionToken<MdcIconLocation>; export declare class MdcIcon implements AfterViewChecked, OnDestroy, OnChanges, OnInit { elementRef: ElementRef<HTMLElement>; private _iconRegistry; private _location?; private _previousFontSetClass?; private _previousFontIconClass?; /** Keeps track of the current page path. */ private _previousPath?; /** Keeps track of the elements and attributes that we've prefixed with the current path. */ private _elementsWithExternalReferences?; /** * Whether the icon should be inlined, automatically sizing the icon to match the font size of * the element the icon is contained in. */ get inline(): boolean; set inline(inline: boolean); private _inline; /** Name of the icon in the SVG icon set. */ svgIcon?: string; role: string | null; /** Font set that the icon is a part of. */ get fontSet(): string; set fontSet(value: string); private _fontSet; /** Name of an icon within a font set. */ get fontIcon(): string; set fontIcon(value: string); private _fontIcon; get clickable(): boolean; set clickable(value: boolean); private _clickable; constructor(elementRef: ElementRef<HTMLElement>, _iconRegistry: MdcIconRegistry, ariaHidden: string, _location?: MdcIconLocation | undefined); ngAfterViewChecked(): void; ngOnDestroy(): void; /** * Splits an svgIcon binding value into its icon set and icon name components. * Returns a 2-element array of [(icon set), (icon name)]. * The separator for the two fields is ':'. If there is no separator, an empty * string is returned for the icon set and the entire value is returned for * the icon name. If the argument is falsy, returns an array of two empty strings. * Throws an error if the name contains two or more ':' separators. * Examples: * `'social:cake' -> ['social', 'cake'] * 'penguin' -> ['', 'penguin'] * null -> ['', ''] * 'a:b:c' -> (throws Error)` */ private _splitIconName; ngOnChanges(changes: SimpleChanges): void; ngOnInit(): void; private _usingFontIcon; private _setSvgElement; private _clearSvgElement; private _updateFontIconClasses; /** * Cleans up a value to be used as a fontIcon or fontSet. * Since the value ends up being assigned as a CSS class, we * have to trim the value and omit space-separated values. */ private _cleanupFontValue; /** * Prepends the current path to all elements that have an attribute pointing to a `FuncIRI` * reference. This is required because WebKit browsers require references to be prefixed with * the current path, if the page has a `base` tag. */ private _prependPathToReferences; /** * Caches the children of an SVG element that have `url()` * references that we need to prefix with the current path. */ private _cacheChildrenWithExternalReferences; /** Retrieves the DOM element of the component host. */ protected _getHostElement(): HTMLElement; }