igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
552 lines (548 loc) • 20.5 kB
JavaScript
import { Output, TemplateRef, EventEmitter, Component, ViewContainerRef, ViewChild, Input, ChangeDetectionStrategy, HostBinding } from '@angular/core';
import { XInput as Input_internal } from "./XInput";
import { ensureEnum, brushToString, stringToBrush, ensureBool, 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 { IgxXInputGroupItemComponent } from './igx-x-input-group-item-component';
import { IgxInputChangeEventArgs } from './igx-input-change-event-args';
import { ControlDisplayDensity_$type } from "igniteui-angular-core";
import { IgxKeyEventArgs } from "igniteui-angular-core";
import { BaseControlTheme_$type } from "igniteui-angular-core";
import { HorizontalAlignment_$type } from "igniteui-angular-core";
import * as i0 from "@angular/core";
export let IgxXInputComponent = /*@__PURE__*/ (() => {
class IgxXInputComponent extends IgxXInputGroupItemComponent {
constructor(renderer, _elRef, ngZone, injector, componentFactoryResolver) {
super();
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._keyDown = null;
this._keyUp = null;
this._keyPress = null;
this._change = null;
this._changing = null;
this._compositionEnd = 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 input = this.i;
this._input = input;
if (renderer) {
this._portalManager = new PortalManager("inputContent", componentFactoryResolver);
var ren = new AngularRenderer(root, this.renderer, window.document, this.ngZone, true, {}, this._portalManager);
this._wrapper = ren;
input.provideContainer(ren);
}
}
// supports angular themes or custom properties set in CSS
updateStyle() {
this._styling(this._root, this);
}
ngOnDestroy() {
this._input.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 Input_internal();
}
get i() {
return this._implementation;
}
/**
* Gets or sets the base built in theme to use for the button.
*/
get baseTheme() {
return this.i.w;
}
set baseTheme(v) {
this.i.w = ensureEnum(BaseControlTheme_$type, v);
}
/**
* Gets or sets the display density to use for the input.
*/
get density() {
return this.i.aa;
}
set density(v) {
this.i.aa = ensureEnum(ControlDisplayDensity_$type, v);
}
/**
* Gets the actual display density to use for the label.
*/
get actualDensity() {
return this.i.z;
}
set actualDensity(v) {
this.i.z = ensureEnum(ControlDisplayDensity_$type, v);
}
/**
* Gets/Sets the input mask for the input.
*/
get mask() {
return this.i.ce;
}
set mask(v) {
this.i.ce = v;
}
/**
* Gets/Sets the character representing a fillable spot in the input mask
*/
get promptChar() {
return this.i.ci;
}
set promptChar(v) {
this.i.ci = v;
}
/**
* Specifies if the bound value includes the formatting symbols.
*/
get includeLiterals() {
return this.i.au;
}
set includeLiterals(v) {
this.i.au = ensureBool(v);
}
get showSpinner() {
return this.i.a1;
}
set showSpinner(v) {
this.i.a1 = ensureBool(v);
}
/**
* Gets the actual color to use for the text color.
*/
get actualTextColor() {
return brushToString(this.i.d4);
}
set actualTextColor(v) {
this.i.d4 = stringToBrush(v);
}
/**
* Gets the actual hover color to use for the text.
*/
get actualHoverTextColor() {
return brushToString(this.i.d3);
}
set actualHoverTextColor(v) {
this.i.d3 = stringToBrush(v);
}
/**
* Gets or sets the color to use for the text.
*/
get textColor() {
return brushToString(this.i.d8);
}
set textColor(v) {
this.i.d8 = stringToBrush(v);
}
/**
* Gets or sets the use for the button.
*/
get textStyle() {
if (this.i.af == null) {
return null;
}
return this.i.af.fontString;
}
set textStyle(v) {
let fi = new FontInfo();
fi.fontString = v;
this.i.af = fi;
}
/**
* Gets or sets the type to use for the input.
*/
get inputType() {
return this.i.b8;
}
set inputType(v) {
this.i.b8 = v;
}
/**
* Gets or sets the placeholder to use for the input.
*/
get placeholder() {
return this.i.cg;
}
set placeholder(v) {
this.i.cg = v;
}
/**
* Gets or sets the color to use for the hovered text of the button regardless of type.
*/
get hoverTextColor() {
return brushToString(this.i.d7);
}
set hoverTextColor(v) {
this.i.d7 = stringToBrush(v);
}
/**
* Gets or sets the id to use for the checkbox.
*/
get id() {
return this.i.b5;
}
set id(v) {
this.i.b5 = v;
}
/**
* Gets or sets TabIndex to use for the checkbox.
*/
get tabIndex() {
return this.i.be;
}
set tabIndex(v) {
this.i.be = +v;
}
/**
* Gets or sets the for attribute to use for the input.
*/
get for() {
return this.i.b2;
}
set for(v) {
this.i.b2 = v;
}
/**
* Gets or sets the value of the aria-label attribute.
*/
get ariaLabel() {
return this.i.bx;
}
set ariaLabel(v) {
this.i.bx = v;
}
/**
* Gets or sets whether the input is hovered.
*/
get isHover() {
return this.i.aw;
}
set isHover(v) {
this.i.aw = ensureBool(v);
}
/**
* Gets or sets the value for the input.
*/
get value() {
return this.i.cq;
}
set value(v) {
this.i.cq = v;
}
get hasValue() {
return this.i.at;
}
/**
* Gets or sets whether the checkbox is disabled.
*/
get disabled() {
return this.i.disabled;
}
set disabled(v) {
this.i.disabled = ensureBool(v);
}
/**
* Gets or sets whether the checkbox is readonly.
*/
get readonly() {
return this.i.readonly;
}
set readonly(v) {
this.i.readonly = ensureBool(v);
}
/**
* Gets or sets the alignment of the text.
*/
get textAlignment() {
return this.i.dy;
}
set textAlignment(v) {
this.i.dy = ensureEnum(HorizontalAlignment_$type, v);
}
/**
* Returns / Sets the beginning index of the selected text. When nothing is selected, this returns the position of the text input cursor (caret) inside of the input.
*/
get selectionStart() {
return this.i.selectionStart;
}
set selectionStart(v) {
this.i.selectionStart = +v;
}
/**
* Returns / Sets the end index of the selected text. When nothing is selected, this returns the position of the text input cursor (caret) inside of the input.
*/
get selectionEnd() {
return this.i.selectionEnd;
}
set selectionEnd(v) {
this.i.selectionEnd = +v;
}
onDetachedFromUI() {
this.i.onDetachedFromUI();
}
onAttachedToUI() {
this.i.onAttachedToUI();
}
/**
* Exports visual information about the current state of the grid.
*/
exportVisualModel() {
let iv = this.i.bg();
return (iv);
}
/**
* Returns a serialized copy of the exported visual model
*/
exportSerializedVisualModel() {
let iv = this.i.b1();
return (iv);
}
setSelectionRange(selectionStart, selectionEnd) {
this.i.dr(selectionStart, selectionEnd);
}
blur() {
this.i.ct();
}
select() {
this.i.dp();
}
get keyDown() {
if (this._keyDown == null) {
this._keyDown = new EventEmitter();
this.i.keyDown = delegateCombine(this.i.keyDown, (o, e) => {
this._runInZone(() => {
let outerArgs = new IgxKeyEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeKeyDown) {
this.beforeKeyDown(this, outerArgs);
}
this._keyDown.emit({
sender: this,
args: outerArgs
});
});
});
}
return this._keyDown;
}
get keyUp() {
if (this._keyUp == null) {
this._keyUp = new EventEmitter();
this.i.keyUp = delegateCombine(this.i.keyUp, (o, e) => {
this._runInZone(() => {
let outerArgs = new IgxKeyEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeKeyUp) {
this.beforeKeyUp(this, outerArgs);
}
this._keyUp.emit({
sender: this,
args: outerArgs
});
});
});
}
return this._keyUp;
}
get keyPress() {
if (this._keyPress == null) {
this._keyPress = new EventEmitter();
this.i.keyPress = delegateCombine(this.i.keyPress, (o, e) => {
this._runInZone(() => {
let outerArgs = new IgxKeyEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeKeyPress) {
this.beforeKeyPress(this, outerArgs);
}
this._keyPress.emit({
sender: this,
args: outerArgs
});
});
});
}
return this._keyPress;
}
get change() {
if (this._change == null) {
this._change = new EventEmitter();
this.i.change = delegateCombine(this.i.change, (o, e) => {
this._runInZone(() => {
let outerArgs = new IgxInputChangeEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeChange) {
this.beforeChange(this, outerArgs);
}
this._change.emit({
sender: this,
args: outerArgs
});
});
});
}
return this._change;
}
get changing() {
if (this._changing == null) {
this._changing = new EventEmitter();
this.i.changing = delegateCombine(this.i.changing, (o, e) => {
this._runInZone(() => {
let outerArgs = new IgxInputChangeEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeChanging) {
this.beforeChanging(this, outerArgs);
}
this._changing.emit({
sender: this,
args: outerArgs
});
});
});
}
return this._changing;
}
get compositionEnd() {
if (this._compositionEnd == null) {
this._compositionEnd = new EventEmitter();
this.i.compositionEnd = delegateCombine(this.i.compositionEnd, (o, e) => {
this._runInZone(() => {
let outerArgs = new IgxInputChangeEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeCompositionEnd) {
this.beforeCompositionEnd(this, outerArgs);
}
this._compositionEnd.emit({
sender: this,
args: outerArgs
});
});
});
}
return this._compositionEnd;
}
}
IgxXInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXInputComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
IgxXInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxXInputComponent, selector: "igx-x-input", inputs: { baseTheme: "baseTheme", density: "density", actualDensity: "actualDensity", mask: "mask", promptChar: "promptChar", includeLiterals: "includeLiterals", showSpinner: "showSpinner", actualTextColor: "actualTextColor", actualHoverTextColor: "actualHoverTextColor", textColor: "textColor", textStyle: "textStyle", inputType: "inputType", placeholder: "placeholder", hoverTextColor: "hoverTextColor", id: "id", tabIndex: ["tabindex", "tabIndex"], for: "for", ariaLabel: ["aria-label", "ariaLabel"], isHover: "isHover", value: "value", disabled: "disabled", readonly: "readonly", textAlignment: "textAlignment", selectionStart: "selectionStart", selectionEnd: "selectionEnd" }, outputs: { keyDown: "keyDown", keyUp: "keyUp", keyPress: "keyPress", change: "change", changing: "changing", compositionEnd: "compositionEnd" }, host: { properties: { "attr.id": "this.id" }, classAttribute: "ig-x-input igx-x-input" }, providers: [], viewQueries: [{ propertyName: "_dynamicContent", first: true, predicate: ["dynamicContent"], descendants: true, read: ViewContainerRef, static: true }, { propertyName: "_childTemplateRef", first: true, predicate: ["childContent"], descendants: true, read: TemplateRef }], usesInheritance: true, 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 \n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
return IgxXInputComponent;
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXInputComponent, decorators: [{
type: Component,
args: [{
selector: 'igx-x-input',
template: `<ng-template #childContent><ng-content></ng-content></ng-template>
<ng-container #dynamicContent></ng-container>`,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-x-input igx-x-input' },
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
}], density: [{
type: Input
}], actualDensity: [{
type: Input
}], mask: [{
type: Input
}], promptChar: [{
type: Input
}], includeLiterals: [{
type: Input
}], showSpinner: [{
type: Input
}], actualTextColor: [{
type: Input
}], actualHoverTextColor: [{
type: Input
}], textColor: [{
type: Input
}], textStyle: [{
type: Input
}], inputType: [{
type: Input
}], placeholder: [{
type: Input
}], hoverTextColor: [{
type: Input
}], id: [{
type: HostBinding,
args: ['attr.id']
}, {
type: Input
}], tabIndex: [{
type: Input,
args: ['tabindex']
}], for: [{
type: Input
}], ariaLabel: [{
type: Input,
args: ['aria-label']
}], isHover: [{
type: Input
}], value: [{
type: Input
}], disabled: [{
type: Input
}], readonly: [{
type: Input
}], textAlignment: [{
type: Input
}], selectionStart: [{
type: Input
}], selectionEnd: [{
type: Input
}], keyDown: [{
type: Output
}], keyUp: [{
type: Output
}], keyPress: [{
type: Output
}], change: [{
type: Output
}], changing: [{
type: Output
}], compositionEnd: [{
type: Output
}] } });