igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
634 lines (631 loc) • 21.9 kB
JavaScript
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";
export let IgxXIconComponent = /*@__PURE__*/ (() => {
class IgxXIconComponent {
constructor(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
updateStyle() {
this._styling(this._root, this);
}
ngOnDestroy() {
this._icon.destroy();
this._wrapper.destroy();
}
ngAfterViewInit() {
this._portalManager.dynamicContent = this._dynamicContent;
this._portalManager.onChildContentChanged(this._childTemplateRef);
this._styling(this._root, this);
this.updateStyle();
}
createImplementation() {
return new XIcon();
}
get i() {
return this._implementation;
}
/**
* Gets or sets the base built in theme to use for the button.
*/
get baseTheme() {
return this.i.m;
}
set baseTheme(v) {
this.i.m = ensureEnum(BaseControlTheme_$type, v);
}
/**
* Gets the fill color currently used by the icon.
*/
get actualFill() {
return brushToString(this.i.c8);
}
set actualFill(v) {
this.i.c8 = stringToBrush(v);
}
/**
* Gets the stroke color currently used by the icon.
*/
get actualStroke() {
return brushToString(this.i.c9);
}
set actualStroke(v) {
this.i.c9 = stringToBrush(v);
}
/**
* Gets the text color currently used by the icon.
*/
get actualTextColor() {
return brushToString(this.i.da);
}
set actualTextColor(v) {
this.i.da = stringToBrush(v);
}
/**
* Gets the stroke width currently used by the icon.
*/
get actualStrokeWidth() {
return this.i.ai;
}
set actualStrokeWidth(v) {
this.i.ai = +v;
}
/**
* Gets or sets the fill color to use for the icon.
*/
get fill() {
return brushToString(this.i.fill);
}
set fill(v) {
this.i.fill = stringToBrush(v);
}
/**
* Gets or sets the stroke color to use for the icon.
*/
get stroke() {
return brushToString(this.i.dp);
}
set stroke(v) {
this.i.dp = stringToBrush(v);
}
/**
* Gets or sets the stroke thickness to use for the icon.
*/
get strokeWidth() {
return this.i.ao;
}
set strokeWidth(v) {
this.i.ao = +v;
}
/**
* Gets or sets the text color to use for the icon.
*/
get textColor() {
return brushToString(this.i.dq);
}
set textColor(v) {
this.i.dq = stringToBrush(v);
}
/**
* Gets or sets the fill color to use when the icon is hovered.
*/
get hoverFill() {
return brushToString(this.i.dh);
}
set hoverFill(v) {
this.i.dh = stringToBrush(v);
}
/**
* Gets or sets the stroke color to use when the icon is hovered.
*/
get hoverStroke() {
return brushToString(this.i.di);
}
set hoverStroke(v) {
this.i.di = stringToBrush(v);
}
/**
* Gets or sets the stroke thickness to use when the icon is hovered.
*/
get hoverStrokeThickness() {
return this.i.am;
}
set hoverStrokeThickness(v) {
this.i.am = +v;
}
/**
* Gets or sets the text color to use when the icon is hovered.
*/
get hoverTextColor() {
return brushToString(this.i.dj);
}
set hoverTextColor(v) {
this.i.dj = stringToBrush(v);
}
/**
* 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 fillColors() {
return fromBrushCollection(this.i.e);
}
set fillColors(v) {
this.i.e = toBrushCollection(v);
}
/**
* 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 strokeColors() {
return fromBrushCollection(this.i.f);
}
set strokeColors(v) {
this.i.f = toBrushCollection(v);
}
/**
* 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 primaryFillColor() {
return brushToString(this.i.dk);
}
set primaryFillColor(v) {
this.i.dk = stringToBrush(v);
}
/**
* 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 primaryStrokeColor() {
return brushToString(this.i.dl);
}
set primaryStrokeColor(v) {
this.i.dl = stringToBrush(v);
}
/**
* 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 secondaryFillColor() {
return brushToString(this.i.dm);
}
set secondaryFillColor(v) {
this.i.dm = stringToBrush(v);
}
/**
* 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 secondaryStrokeColor() {
return brushToString(this.i.dn);
}
set secondaryStrokeColor(v) {
this.i.dn = stringToBrush(v);
}
/**
* Gets or sets the image source for the icon. Used if none of the other icon types are not used.
*/
get source() {
return this.i.a1;
}
set source(v) {
this.i.a1 = v;
}
/**
* Gets or sets data url for the icon to use.
*/
get dataURL() {
return this.i.bg;
}
set dataURL(v) {
this.i.bg = v;
}
/**
* Gets or sets path data for the icon to use.
*/
get svgPath() {
return this.i.svgPath;
}
set svgPath(v) {
this.i.svgPath = v;
}
/**
* Gets or sets svg text for the icon to use.
*/
get svg() {
return this.i.svg;
}
set svg(v) {
this.i.svg = v;
}
/**
* Gets or sets an array of path data for the icon to use.
*/
get sVGPaths() {
return this.i.b;
}
set sVGPaths(v) {
if (v && !Array.isArray(v) && typeof (v) == "string") {
const re = /\s*(?:,|\s|$)\s*/gm;
v = v.split(re);
}
this.i.b = v;
}
/**
* Gets or sets the use for the button.
*/
get textStyle() {
if (this.i.o == null) {
return null;
}
return this.i.o.fontString;
}
set textStyle(v) {
let fi = new FontInfo();
fi.fontString = v;
this.i.o = fi;
}
/**
* Gets or sets the id to use for the checkbox.
*/
get id() {
return this.i.bq;
}
set id(v) {
this.i.bq = v;
}
/**
* Gets or sets TabIndex to use for the checkbox.
*/
get tabIndex() {
return this.i.av;
}
set tabIndex(v) {
this.i.av = +v;
}
/**
* Gets or sets the value of the aria-label attribute.
*/
get ariaLabel() {
return this.i.bb;
}
set ariaLabel(v) {
this.i.bb = v;
}
/**
* Gets or sets whether the icon is hovered.
*/
get isHover() {
return this.i.v;
}
set isHover(v) {
this.i.v = ensureBool(v);
}
/**
* Gets or sets whether the checkbox is disabled.
*/
get disabled() {
return this.i.disabled;
}
set disabled(v) {
this.i.disabled = ensureBool(v);
}
get opacity() {
return this.i.an;
}
set opacity(v) {
this.i.an = +v;
}
/**
* Gets or sets the viewbox left for the svg icon.
*/
get viewBoxLeft() {
return this.i.aq;
}
set viewBoxLeft(v) {
this.i.aq = +v;
}
/**
* Gets or sets the viewbox top for the svg icon.
*/
get viewBoxTop() {
return this.i.ar;
}
set viewBoxTop(v) {
this.i.ar = +v;
}
/**
* Gets or sets the viewbox width for the svg icon.
*/
get viewBoxWidth() {
return this.i.as;
}
set viewBoxWidth(v) {
this.i.as = +v;
}
/**
* Gets or sets the viewbox height for the svg icon.
*/
get viewBoxHeight() {
return this.i.ap;
}
set viewBoxHeight(v) {
this.i.ap = +v;
}
/**
* Gets or sets the width of the icon.
*/
get width() {
return this.i.at;
}
set width(v) {
this.i.at = +v;
}
/**
* Gets or sets the height of the icon.
*/
get height() {
return this.i.al;
}
set height(v) {
this.i.al = +v;
}
findByName(name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
}
get hasUserValues() {
return this._hasUserValues;
}
__m(propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
}
_styling(container, component, parent) {
if (this._inStyling) {
return;
}
this._inStyling = true;
this._stylingContainer = container;
this._stylingParent = component;
let genericPrefix = "";
let typeName = this.i.$type.name;
if (typeName.indexOf("Xam") === 0) {
typeName = typeName.substring(3);
}
genericPrefix = toSpinal("XIconComponent");
let additionalPrefixes = [];
let prefix = toSpinal(typeName);
additionalPrefixes.push(prefix + "-");
let 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);
}
let basePrefix = toSpinal(typeName);
additionalPrefixes.push(basePrefix + "-");
b = b.baseType;
}
if (parent) {
let parentTypeName = parent.i.$type.name;
if (parentTypeName.indexOf("Xam") === 0) {
parentTypeName = parentTypeName.substring(3);
}
let 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;
}
onDetachedFromUI() {
this.i.onDetachedFromUI();
}
onAttachedToUI() {
this.i.onAttachedToUI();
}
/**
* Exports visual information about the current state of the grid.
*/
exportVisualModel() {
let iv = this.i.a0();
return (iv);
}
/**
* Returns a serialized copy of the exported visual model
*/
exportSerializedVisualModel() {
let iv = this.i.bi();
return (iv);
}
_runInZone(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>
<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;
})();
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>
<ng-container #dynamicContent></ng-container>`,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-x-icon igx-x-icon' },
styles: [`
:host {
display: inline-block;
vertical-align: middle;
}
`]
}]
}], 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
}] } });