UNPKG

igniteui-angular-inputs

Version:

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

471 lines (470 loc) 18.6 kB
import { Output, TemplateRef, EventEmitter, Component, ViewContainerRef, ViewChild, Input, ChangeDetectionStrategy } from '@angular/core'; import { ColorEditor } from "./ColorEditor"; import { ensureEnum, brushToString, stringToBrush, ensureBool, toSpinal, initializePropertiesFromCss, NamePatcher } from "igniteui-angular-core"; import { FontInfo } from "igniteui-angular-core"; import { AngularRenderer, PortalManager } from "igniteui-angular-core"; import { delegateCombine } from "igniteui-angular-core"; import { TypeRegistrar } from "igniteui-angular-core"; import { ControlDisplayDensity_$type } from "igniteui-angular-core"; import { BaseControlTheme_$type } from "igniteui-angular-core"; import { IgxColorEditorPanelSelectedValueChangedEventArgs } from "./igx-color-editor-panel-selected-value-changed-event-args"; import { IgxColorEditorLostFocusEventArgs } from "./igx-color-editor-lost-focus-event-args"; import { IgxColorEditorGotFocusEventArgs } from "./igx-color-editor-got-focus-event-args"; import * as i0 from "@angular/core"; export let IgxColorEditorComponent = /*@__PURE__*/ (() => { class IgxColorEditorComponent { 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.__p = null; this._hasUserValues = new Set(); this._stylingContainer = null; this._stylingParent = null; this._inStyling = false; this._valueChanged = null; this._valueChanging = null; this._gotFocus = null; this._lostFocus = null; 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", "block"); } var root; root = this.container; if (this.container != null) { root = this.container; } if (root && root.nativeElement) { root = root.nativeElement; } this._root = root; var colorEditor = this.i; this._colorEditor = colorEditor; if (renderer) { this._portalManager = new PortalManager("colorEditorContent", componentFactoryResolver); var ren = new AngularRenderer(root, this.renderer, window.document, this.ngZone, true, {}, this._portalManager); this._wrapper = ren; colorEditor.provideContainer(ren); } } // supports angular themes or custom properties set in CSS updateStyle() { this._styling(this._root, this); } ngOnDestroy() { this._colorEditor.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 ColorEditor(); } /** * @hidden */ get i() { return this._implementation; } /** * @hidden */ static _createFromInternal(internal) { if (!internal) { return null; } if (!internal.$type) { return null; } let name = internal.$type.name; let externalName = "Igx" + name + "Component"; if (!TypeRegistrar.isRegistered(externalName)) { return null; } return TypeRegistrar.create(externalName); } /** * Gets or Sets color value of the editor. */ get value() { return brushToString(this.i.value); } set value(v) { this.i.value = stringToBrush(v); } /** * Gets or Sets the property name that contains the label. */ get label() { return this.i.az; } set label(v) { this.i.az = v; } /** * Gets or sets the color to use for the text. */ get labelTextColor() { return brushToString(this.i.cn); } set labelTextColor(v) { this.i.cn = stringToBrush(v); } /** * Gets or sets the font to use for the input. */ get labelTextStyle() { if (this.i.o == null) { return null; } return this.i.o.fontString; } set labelTextStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.o = fi; } /** * Gets or sets the display density to use for the date pcicker. */ get density() { return this.i.k; } set density(v) { this.i.k = ensureEnum(ControlDisplayDensity_$type, v); } /** * Gets or sets the base built in theme to use for the date picker. */ get baseTheme() { return this.i.i; } set baseTheme(v) { this.i.i = ensureEnum(BaseControlTheme_$type, v); } /** * Gets or sets the font to use for the combobox. */ get textStyle() { if (this.i.p == null) { return null; } return this.i.p.fontString; } set textStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.p = fi; } /** * Gets or Sets the text color */ get textColor() { return brushToString(this.i.co); } set textColor(v) { this.i.co = stringToBrush(v); } /** * Gets or Sets the text color */ get iconColor() { return brushToString(this.i.cm); } set iconColor(v) { this.i.cm = stringToBrush(v); } /** * Gets or sets the ShowClearButton property to detirmine if the clear button is shown */ get showClearButton() { return this.i.am; } set showClearButton(v) { this.i.am = ensureBool(v); } /** * Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed */ get allowTextInput() { return this.i.ag; } set allowTextInput(v) { this.i.ag = ensureBool(v); } /** * Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed */ get openOnFocus() { return this.i.ak; } set openOnFocus(v) { this.i.ak = ensureBool(v); } get isDisabled() { return this.i.ah; } set isDisabled(v) { this.i.ah = ensureBool(v); } /** * Indicates that the editor dropdown will position itself relative to the window instead of the document. */ get isFixed() { return this.i.ai; } set isFixed(v) { this.i.ai = ensureBool(v); } /** * Indicates that the dropdown should open as a child of the color editor. */ get openAsChild() { return this.i.aj; } set openAsChild(v) { this.i.aj = ensureBool(v); } /** * Indicates that the dropdown will place itself into the browser top layer. */ get useTopLayer() { return this.i.an; } set useTopLayer(v) { this.i.an = ensureBool(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("ColorEditorComponent"); 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; } select() { this.i.b8(); } /** * Called when color is selected. */ get valueChanged() { if (this._valueChanged == null) { this._valueChanged = new EventEmitter(); this.i.valueChanged = delegateCombine(this.i.valueChanged, (o, e) => { let outerArgs = new IgxColorEditorPanelSelectedValueChangedEventArgs(); outerArgs._provideImplementation(e); if (this.beforeValueChanged) { this.beforeValueChanged(this, outerArgs); } this._valueChanged.emit({ sender: this, args: outerArgs }); }); } return this._valueChanged; } /** * Called when color is selected. */ get valueChanging() { if (this._valueChanging == null) { this._valueChanging = new EventEmitter(); this.i.valueChanging = delegateCombine(this.i.valueChanging, (o, e) => { let outerArgs = new IgxColorEditorPanelSelectedValueChangedEventArgs(); outerArgs._provideImplementation(e); if (this.beforeValueChanging) { this.beforeValueChanging(this, outerArgs); } this._valueChanging.emit({ sender: this, args: outerArgs }); }); } return this._valueChanging; } get gotFocus() { if (this._gotFocus == null) { this._gotFocus = new EventEmitter(); this.i.gotFocus = delegateCombine(this.i.gotFocus, (o, e) => { this._runInZone(() => { let outerArgs = new IgxColorEditorGotFocusEventArgs(); outerArgs._provideImplementation(e); if (this.beforeGotFocus) { this.beforeGotFocus(this, outerArgs); } this._gotFocus.emit({ sender: this, args: outerArgs }); }); }); } return this._gotFocus; } get lostFocus() { if (this._lostFocus == null) { this._lostFocus = new EventEmitter(); this.i.lostFocus = delegateCombine(this.i.lostFocus, (o, e) => { this._runInZone(() => { let outerArgs = new IgxColorEditorLostFocusEventArgs(); outerArgs._provideImplementation(e); if (this.beforeLostFocus) { this.beforeLostFocus(this, outerArgs); } this._lostFocus.emit({ sender: this, args: outerArgs }); }); }); } return this._lostFocus; } _runInZone(act) { if (this._zoneRunner != null) { this._zoneRunner(act); } else { act(); } } } IgxColorEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxColorEditorComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component }); IgxColorEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxColorEditorComponent, selector: "igx-color-editor", inputs: { value: "value", label: "label", labelTextColor: "labelTextColor", labelTextStyle: "labelTextStyle", density: "density", baseTheme: "baseTheme", textStyle: "textStyle", textColor: "textColor", iconColor: "iconColor", showClearButton: "showClearButton", allowTextInput: "allowTextInput", openOnFocus: "openOnFocus", isDisabled: "isDisabled", isFixed: "isFixed", openAsChild: "openAsChild", useTopLayer: "useTopLayer" }, outputs: { valueChanged: "valueChanged", valueChanging: "valueChanging", gotFocus: "gotFocus", lostFocus: "lostFocus" }, host: { classAttribute: "ig-color-editor igx-color-editor" }, 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: block; \n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); return IgxColorEditorComponent; })(); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxColorEditorComponent, decorators: [{ type: Component, args: [{ selector: 'igx-color-editor', template: `<ng-template #childContent><ng-content></ng-content></ng-template> <ng-container #dynamicContent></ng-container>`, changeDetection: ChangeDetectionStrategy.OnPush, providers: [], host: { 'class': 'ig-color-editor igx-color-editor' }, styles: [` :host { display: block; } `] }] }], 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 }] }], value: [{ type: Input }], label: [{ type: Input }], labelTextColor: [{ type: Input }], labelTextStyle: [{ type: Input }], density: [{ type: Input }], baseTheme: [{ type: Input }], textStyle: [{ type: Input }], textColor: [{ type: Input }], iconColor: [{ type: Input }], showClearButton: [{ type: Input }], allowTextInput: [{ type: Input }], openOnFocus: [{ type: Input }], isDisabled: [{ type: Input }], isFixed: [{ type: Input }], openAsChild: [{ type: Input }], useTopLayer: [{ type: Input }], valueChanged: [{ type: Output }], valueChanging: [{ type: Output }], gotFocus: [{ type: Output }], lostFocus: [{ type: Output }] } });