UNPKG

igniteui-angular-inputs

Version:

Ignite UI Angular input components for building rich data visualizations for modern web apps.

782 lines (779 loc) 27.1 kB
import { TemplateRef, Component, ViewContainerRef, ViewChild, Input, ChangeDetectionStrategy, HostBinding } from '@angular/core'; import { XIcon } from "./XIcon"; import { ensureEnum, brushToString, stringToBrush, ensureBool, toSpinal, initializePropertiesFromCss, NamePatcher, fromBrushCollection, toBrushCollection } from "igniteui-angular-core"; import { FontInfo } from "igniteui-angular-core"; import { AngularRenderer, PortalManager } from "igniteui-angular-core"; import { BaseControlTheme_$type } from "igniteui-angular-core"; import * as i0 from "@angular/core"; var IgxXIconComponent = /** @class */ /*@__PURE__*/ (function () { function IgxXIconComponent(renderer, _elRef, ngZone, injector, componentFactoryResolver) { this.renderer = renderer; this._elRef = _elRef; this.ngZone = ngZone; this.injector = injector; this.componentFactoryResolver = componentFactoryResolver; this._wrapper = null; this._portalManager = null; this._root = null; this._implementation = null; this.__p = null; this._hasUserValues = new Set(); this._stylingContainer = null; this._stylingParent = null; this._inStyling = false; this._zoneRunner = null; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._implementation = this.createImplementation(); this._implementation.externalObject = this; if (renderer) { this.container = renderer.createElement("div"); renderer.appendChild(_elRef.element.nativeElement, this.container); renderer.setStyle(this.container, "display", "inline-block"); } var root; root = this.container; if (this.container != null) { root = this.container; } if (root && root.nativeElement) { root = root.nativeElement; } this._root = root; var icon = this.i; this._icon = icon; if (renderer) { this._portalManager = new PortalManager("iconContent", componentFactoryResolver); var ren = new AngularRenderer(root, this.renderer, window.document, this.ngZone, true, {}, this._portalManager); this._wrapper = ren; icon.provideContainer(ren); } } // supports angular themes or custom properties set in CSS IgxXIconComponent.prototype.updateStyle = function () { this._styling(this._root, this); }; IgxXIconComponent.prototype.ngOnDestroy = function () { this._icon.destroy(); this._wrapper.destroy(); }; IgxXIconComponent.prototype.ngAfterViewInit = function () { this._portalManager.dynamicContent = this._dynamicContent; this._portalManager.onChildContentChanged(this._childTemplateRef); this._styling(this._root, this); this.updateStyle(); }; IgxXIconComponent.prototype.createImplementation = function () { return new XIcon(); }; Object.defineProperty(IgxXIconComponent.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "baseTheme", { /** * Gets or sets the base built in theme to use for the button. */ get: function () { return this.i.m; }, set: function (v) { this.i.m = ensureEnum(BaseControlTheme_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "actualFill", { /** * Gets the fill color currently used by the icon. */ get: function () { return brushToString(this.i.c8); }, set: function (v) { this.i.c8 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "actualStroke", { /** * Gets the stroke color currently used by the icon. */ get: function () { return brushToString(this.i.c9); }, set: function (v) { this.i.c9 = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "actualTextColor", { /** * Gets the text color currently used by the icon. */ get: function () { return brushToString(this.i.da); }, set: function (v) { this.i.da = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "actualStrokeWidth", { /** * Gets the stroke width currently used by the icon. */ get: function () { return this.i.ai; }, set: function (v) { this.i.ai = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "fill", { /** * Gets or sets the fill color to use for the icon. */ get: function () { return brushToString(this.i.fill); }, set: function (v) { this.i.fill = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "stroke", { /** * Gets or sets the stroke color to use for the icon. */ get: function () { return brushToString(this.i.dp); }, set: function (v) { this.i.dp = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "strokeWidth", { /** * Gets or sets the stroke thickness to use for the icon. */ get: function () { return this.i.ao; }, set: function (v) { this.i.ao = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "textColor", { /** * Gets or sets the text color to use for the icon. */ get: function () { return brushToString(this.i.dq); }, set: function (v) { this.i.dq = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "hoverFill", { /** * Gets or sets the fill color to use when the icon is hovered. */ get: function () { return brushToString(this.i.dh); }, set: function (v) { this.i.dh = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "hoverStroke", { /** * Gets or sets the stroke color to use when the icon is hovered. */ get: function () { return brushToString(this.i.di); }, set: function (v) { this.i.di = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "hoverStrokeThickness", { /** * Gets or sets the stroke thickness to use when the icon is hovered. */ get: function () { return this.i.am; }, set: function (v) { this.i.am = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "hoverTextColor", { /** * Gets or sets the text color to use when the icon is hovered. */ get: function () { return brushToString(this.i.dj); }, set: function (v) { this.i.dj = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "fillColors", { /** * Gets or sets a collection of fill colors to use in the icon. * These colors can be used by SVG elements that have been marked with the * ig-icon-fill-# * class where # is a number from 0 to count - 1. */ get: function () { return fromBrushCollection(this.i.e); }, set: function (v) { this.i.e = toBrushCollection(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "strokeColors", { /** * Gets or sets a collection of stroke colors to use in the icon. * These colors can be used by SVG elements that have been marked with the * ig-icon-stroke-# * class where # is a number from 0 to count - 1. */ get: function () { return fromBrushCollection(this.i.f); }, set: function (v) { this.i.f = toBrushCollection(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "primaryFillColor", { /** * Gets or sets a primary fill color for the icon. * This color is used by SVG elements that have been marked * with the * ig-icon-primary-fill * class. */ get: function () { return brushToString(this.i.dk); }, set: function (v) { this.i.dk = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "primaryStrokeColor", { /** * Gets or sets a primary stroke color for the icon. * This color is used by SVG elements that have been marked * with the * ig-icon-primary-stroke * class. */ get: function () { return brushToString(this.i.dl); }, set: function (v) { this.i.dl = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "secondaryFillColor", { /** * Gets or sets a secondary fill color for the icon. * This color is used by SVG elements that have been marked * with the * ig-icon-secondary-fill * class. */ get: function () { return brushToString(this.i.dm); }, set: function (v) { this.i.dm = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "secondaryStrokeColor", { /** * Gets or sets a secondary stroke color for the icon. * This color is used by SVG elements that have been marked * with the * ig-icon-secondary-stroke * class. */ get: function () { return brushToString(this.i.dn); }, set: function (v) { this.i.dn = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "source", { /** * Gets or sets the image source for the icon. Used if none of the other icon types are not used. */ get: function () { return this.i.a1; }, set: function (v) { this.i.a1 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "dataURL", { /** * Gets or sets data url for the icon to use. */ get: function () { return this.i.bg; }, set: function (v) { this.i.bg = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "svgPath", { /** * Gets or sets path data for the icon to use. */ get: function () { return this.i.svgPath; }, set: function (v) { this.i.svgPath = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "svg", { /** * Gets or sets svg text for the icon to use. */ get: function () { return this.i.svg; }, set: function (v) { this.i.svg = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "sVGPaths", { /** * Gets or sets an array of path data for the icon to use. */ get: function () { return this.i.b; }, set: function (v) { if (v && !Array.isArray(v) && typeof (v) == "string") { var re = /\s*(?:,|\s|$)\s*/gm; v = v.split(re); } this.i.b = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "textStyle", { /** * Gets or sets the use for the button. */ get: function () { if (this.i.o == null) { return null; } return this.i.o.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.o = fi; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "id", { /** * Gets or sets the id to use for the checkbox. */ get: function () { return this.i.bq; }, set: function (v) { this.i.bq = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "tabIndex", { /** * Gets or sets TabIndex to use for the checkbox. */ get: function () { return this.i.av; }, set: function (v) { this.i.av = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "ariaLabel", { /** * Gets or sets the value of the aria-label attribute. */ get: function () { return this.i.bb; }, set: function (v) { this.i.bb = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "isHover", { /** * Gets or sets whether the icon is hovered. */ get: function () { return this.i.v; }, set: function (v) { this.i.v = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "disabled", { /** * Gets or sets whether the checkbox is disabled. */ get: function () { return this.i.disabled; }, set: function (v) { this.i.disabled = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "opacity", { get: function () { return this.i.an; }, set: function (v) { this.i.an = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "viewBoxLeft", { /** * Gets or sets the viewbox left for the svg icon. */ get: function () { return this.i.aq; }, set: function (v) { this.i.aq = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "viewBoxTop", { /** * Gets or sets the viewbox top for the svg icon. */ get: function () { return this.i.ar; }, set: function (v) { this.i.ar = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "viewBoxWidth", { /** * Gets or sets the viewbox width for the svg icon. */ get: function () { return this.i.as; }, set: function (v) { this.i.as = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "viewBoxHeight", { /** * Gets or sets the viewbox height for the svg icon. */ get: function () { return this.i.ap; }, set: function (v) { this.i.ap = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "width", { /** * Gets or sets the width of the icon. */ get: function () { return this.i.at; }, set: function (v) { this.i.at = +v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXIconComponent.prototype, "height", { /** * Gets or sets the height of the icon. */ get: function () { return this.i.al; }, set: function (v) { this.i.al = +v; }, enumerable: false, configurable: true }); IgxXIconComponent.prototype.findByName = function (name) { if (this.findEphemera) { if (name && name.indexOf("@@e:") == 0) { return this.findEphemera(name); } } return null; }; Object.defineProperty(IgxXIconComponent.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgxXIconComponent.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgxXIconComponent.prototype._styling = function (container, component, parent) { if (this._inStyling) { return; } this._inStyling = true; this._stylingContainer = container; this._stylingParent = component; var genericPrefix = ""; var typeName = this.i.$type.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } genericPrefix = toSpinal("XIconComponent"); var additionalPrefixes = []; var prefix = toSpinal(typeName); additionalPrefixes.push(prefix + "-"); var b = this.i.$type.baseType; while (b && b.name != "Object" && b.name != "Base" && b.name != "Control" && b.Name != "DependencyObject" && b.Name != "FrameworkElement") { typeName = b.name; if (typeName.indexOf("Xam") === 0) { typeName = typeName.substring(3); } var basePrefix = toSpinal(typeName); additionalPrefixes.push(basePrefix + "-"); b = b.baseType; } if (parent) { var parentTypeName = parent.i.$type.name; if (parentTypeName.indexOf("Xam") === 0) { parentTypeName = parentTypeName.substring(3); } var parentPrefix = toSpinal(parentTypeName); additionalPrefixes.push(parentPrefix + "-" + genericPrefix + "-"); additionalPrefixes.push(parentPrefix + "-" + prefix + "-"); } initializePropertiesFromCss(container, this, genericPrefix + "-", this.hasUserValues, false, additionalPrefixes); if (this._otherStyling) { this._otherStyling(container, component, parent); } this._inStyling = false; }; IgxXIconComponent.prototype.onDetachedFromUI = function () { this.i.onDetachedFromUI(); }; IgxXIconComponent.prototype.onAttachedToUI = function () { this.i.onAttachedToUI(); }; /** * Exports visual information about the current state of the grid. */ IgxXIconComponent.prototype.exportVisualModel = function () { var iv = this.i.a0(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgxXIconComponent.prototype.exportSerializedVisualModel = function () { var iv = this.i.bi(); return (iv); }; IgxXIconComponent.prototype._runInZone = function (act) { if (this._zoneRunner != null) { this._zoneRunner(act); } else { act(); } }; IgxXIconComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXIconComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component }); IgxXIconComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxXIconComponent, selector: "igx-x-icon", inputs: { baseTheme: "baseTheme", actualFill: "actualFill", actualStroke: "actualStroke", actualTextColor: "actualTextColor", actualStrokeWidth: "actualStrokeWidth", fill: "fill", stroke: "stroke", strokeWidth: "strokeWidth", textColor: "textColor", hoverFill: "hoverFill", hoverStroke: "hoverStroke", hoverStrokeThickness: "hoverStrokeThickness", hoverTextColor: "hoverTextColor", fillColors: "fillColors", strokeColors: "strokeColors", primaryFillColor: "primaryFillColor", primaryStrokeColor: "primaryStrokeColor", secondaryFillColor: "secondaryFillColor", secondaryStrokeColor: "secondaryStrokeColor", source: "source", dataURL: "dataURL", svgPath: "svgPath", svg: "svg", sVGPaths: "sVGPaths", textStyle: "textStyle", id: "id", tabIndex: ["tabindex", "tabIndex"], ariaLabel: ["aria-label", "ariaLabel"], isHover: "isHover", disabled: "disabled", opacity: "opacity", viewBoxLeft: "viewBoxLeft", viewBoxTop: "viewBoxTop", viewBoxWidth: "viewBoxWidth", viewBoxHeight: "viewBoxHeight", width: "width", height: "height" }, host: { properties: { "attr.id": "this.id" }, classAttribute: "ig-x-icon igx-x-icon" }, providers: [], viewQueries: [{ propertyName: "_dynamicContent", first: true, predicate: ["dynamicContent"], descendants: true, read: ViewContainerRef, static: true }, { propertyName: "_childTemplateRef", first: true, predicate: ["childContent"], descendants: true, read: TemplateRef }], ngImport: i0, template: "<ng-template #childContent><ng-content></ng-content></ng-template>\n<ng-container #dynamicContent></ng-container>", isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: inline-block; \n vertical-align: middle; \n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); return IgxXIconComponent; }()); export { IgxXIconComponent }; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXIconComponent, decorators: [{ type: Component, args: [{ selector: 'igx-x-icon', template: "<ng-template #childContent><ng-content></ng-content></ng-template>\n<ng-container #dynamicContent></ng-container>", changeDetection: ChangeDetectionStrategy.OnPush, providers: [], host: { 'class': 'ig-x-icon igx-x-icon' }, styles: ["\n\t\t:host {\n\t\t\tdisplay: inline-block; \n vertical-align: middle; \n\t\t}\n\t"] }] }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ViewContainerRef }, { type: i0.NgZone }, { type: i0.Injector }, { type: i0.ComponentFactoryResolver }]; }, propDecorators: { _dynamicContent: [{ type: ViewChild, args: ["dynamicContent", { read: ViewContainerRef, static: true }] }], _childTemplateRef: [{ type: ViewChild, args: ["childContent", { read: TemplateRef, static: false }] }], baseTheme: [{ type: Input }], actualFill: [{ type: Input }], actualStroke: [{ type: Input }], actualTextColor: [{ type: Input }], actualStrokeWidth: [{ type: Input }], fill: [{ type: Input }], stroke: [{ type: Input }], strokeWidth: [{ type: Input }], textColor: [{ type: Input }], hoverFill: [{ type: Input }], hoverStroke: [{ type: Input }], hoverStrokeThickness: [{ type: Input }], hoverTextColor: [{ type: Input }], fillColors: [{ type: Input }], strokeColors: [{ type: Input }], primaryFillColor: [{ type: Input }], primaryStrokeColor: [{ type: Input }], secondaryFillColor: [{ type: Input }], secondaryStrokeColor: [{ type: Input }], source: [{ type: Input }], dataURL: [{ type: Input }], svgPath: [{ type: Input }], svg: [{ type: Input }], sVGPaths: [{ type: Input }], textStyle: [{ type: Input }], id: [{ type: HostBinding, args: ['attr.id'] }, { type: Input }], tabIndex: [{ type: Input, args: ['tabindex'] }], ariaLabel: [{ type: Input, args: ['aria-label'] }], isHover: [{ type: Input }], disabled: [{ type: Input }], opacity: [{ type: Input }], viewBoxLeft: [{ type: Input }], viewBoxTop: [{ type: Input }], viewBoxWidth: [{ type: Input }], viewBoxHeight: [{ type: Input }], width: [{ type: Input }], height: [{ type: Input }] } });