igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
684 lines (681 loc) • 25.6 kB
JavaScript
import { __extends } from "tslib";
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";
var IgxXInputComponent = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(IgxXInputComponent, _super);
function IgxXInputComponent(renderer, _elRef, ngZone, injector, componentFactoryResolver) {
var _this = _super.call(this) || this;
_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);
}
return _this;
}
// supports angular themes or custom properties set in CSS
IgxXInputComponent.prototype.updateStyle = function () {
this._styling(this._root, this);
};
IgxXInputComponent.prototype.ngOnDestroy = function () {
this._input.destroy();
this._wrapper.destroy();
};
IgxXInputComponent.prototype.ngAfterViewInit = function () {
this._portalManager.dynamicContent = this._dynamicContent;
this._portalManager.onChildContentChanged(this._childTemplateRef);
this._styling(this._root, this);
this.updateStyle();
};
IgxXInputComponent.prototype.createImplementation = function () {
return new Input_internal();
};
Object.defineProperty(IgxXInputComponent.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "baseTheme", {
/**
* Gets or sets the base built in theme to use for the button.
*/
get: function () {
return this.i.w;
},
set: function (v) {
this.i.w = ensureEnum(BaseControlTheme_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "density", {
/**
* Gets or sets the display density to use for the input.
*/
get: function () {
return this.i.aa;
},
set: function (v) {
this.i.aa = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "actualDensity", {
/**
* Gets the actual display density to use for the label.
*/
get: function () {
return this.i.z;
},
set: function (v) {
this.i.z = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "mask", {
/**
* Gets/Sets the input mask for the input.
*/
get: function () {
return this.i.ce;
},
set: function (v) {
this.i.ce = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "promptChar", {
/**
* Gets/Sets the character representing a fillable spot in the input mask
*/
get: function () {
return this.i.ci;
},
set: function (v) {
this.i.ci = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "includeLiterals", {
/**
* Specifies if the bound value includes the formatting symbols.
*/
get: function () {
return this.i.au;
},
set: function (v) {
this.i.au = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "showSpinner", {
get: function () {
return this.i.a1;
},
set: function (v) {
this.i.a1 = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "actualTextColor", {
/**
* Gets the actual color to use for the text color.
*/
get: function () {
return brushToString(this.i.d4);
},
set: function (v) {
this.i.d4 = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "actualHoverTextColor", {
/**
* Gets the actual hover color to use for the text.
*/
get: function () {
return brushToString(this.i.d3);
},
set: function (v) {
this.i.d3 = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "textColor", {
/**
* Gets or sets the color to use for the text.
*/
get: function () {
return brushToString(this.i.d8);
},
set: function (v) {
this.i.d8 = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "textStyle", {
/**
* Gets or sets the use for the button.
*/
get: function () {
if (this.i.af == null) {
return null;
}
return this.i.af.fontString;
},
set: function (v) {
var fi = new FontInfo();
fi.fontString = v;
this.i.af = fi;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "inputType", {
/**
* Gets or sets the type to use for the input.
*/
get: function () {
return this.i.b8;
},
set: function (v) {
this.i.b8 = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "placeholder", {
/**
* Gets or sets the placeholder to use for the input.
*/
get: function () {
return this.i.cg;
},
set: function (v) {
this.i.cg = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "hoverTextColor", {
/**
* Gets or sets the color to use for the hovered text of the button regardless of type.
*/
get: function () {
return brushToString(this.i.d7);
},
set: function (v) {
this.i.d7 = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "id", {
/**
* Gets or sets the id to use for the checkbox.
*/
get: function () {
return this.i.b5;
},
set: function (v) {
this.i.b5 = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "tabIndex", {
/**
* Gets or sets TabIndex to use for the checkbox.
*/
get: function () {
return this.i.be;
},
set: function (v) {
this.i.be = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "for", {
/**
* Gets or sets the for attribute to use for the input.
*/
get: function () {
return this.i.b2;
},
set: function (v) {
this.i.b2 = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "ariaLabel", {
/**
* Gets or sets the value of the aria-label attribute.
*/
get: function () {
return this.i.bx;
},
set: function (v) {
this.i.bx = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "isHover", {
/**
* Gets or sets whether the input is hovered.
*/
get: function () {
return this.i.aw;
},
set: function (v) {
this.i.aw = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "value", {
/**
* Gets or sets the value for the input.
*/
get: function () {
return this.i.cq;
},
set: function (v) {
this.i.cq = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "hasValue", {
get: function () {
return this.i.at;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.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(IgxXInputComponent.prototype, "readonly", {
/**
* Gets or sets whether the checkbox is readonly.
*/
get: function () {
return this.i.readonly;
},
set: function (v) {
this.i.readonly = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "textAlignment", {
/**
* Gets or sets the alignment of the text.
*/
get: function () {
return this.i.dy;
},
set: function (v) {
this.i.dy = ensureEnum(HorizontalAlignment_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "selectionStart", {
/**
* 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: function () {
return this.i.selectionStart;
},
set: function (v) {
this.i.selectionStart = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "selectionEnd", {
/**
* 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: function () {
return this.i.selectionEnd;
},
set: function (v) {
this.i.selectionEnd = +v;
},
enumerable: false,
configurable: true
});
IgxXInputComponent.prototype.onDetachedFromUI = function () {
this.i.onDetachedFromUI();
};
IgxXInputComponent.prototype.onAttachedToUI = function () {
this.i.onAttachedToUI();
};
/**
* Exports visual information about the current state of the grid.
*/
IgxXInputComponent.prototype.exportVisualModel = function () {
var iv = this.i.bg();
return (iv);
};
/**
* Returns a serialized copy of the exported visual model
*/
IgxXInputComponent.prototype.exportSerializedVisualModel = function () {
var iv = this.i.b1();
return (iv);
};
IgxXInputComponent.prototype.setSelectionRange = function (selectionStart, selectionEnd) {
this.i.dr(selectionStart, selectionEnd);
};
IgxXInputComponent.prototype.blur = function () {
this.i.ct();
};
IgxXInputComponent.prototype.select = function () {
this.i.dp();
};
Object.defineProperty(IgxXInputComponent.prototype, "keyDown", {
get: function () {
var _this = this;
if (this._keyDown == null) {
this._keyDown = new EventEmitter();
this.i.keyDown = delegateCombine(this.i.keyDown, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxKeyEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeKeyDown) {
_this.beforeKeyDown(_this, outerArgs);
}
_this._keyDown.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._keyDown;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "keyUp", {
get: function () {
var _this = this;
if (this._keyUp == null) {
this._keyUp = new EventEmitter();
this.i.keyUp = delegateCombine(this.i.keyUp, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxKeyEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeKeyUp) {
_this.beforeKeyUp(_this, outerArgs);
}
_this._keyUp.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._keyUp;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "keyPress", {
get: function () {
var _this = this;
if (this._keyPress == null) {
this._keyPress = new EventEmitter();
this.i.keyPress = delegateCombine(this.i.keyPress, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxKeyEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeKeyPress) {
_this.beforeKeyPress(_this, outerArgs);
}
_this._keyPress.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._keyPress;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "change", {
get: function () {
var _this = this;
if (this._change == null) {
this._change = new EventEmitter();
this.i.change = delegateCombine(this.i.change, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxInputChangeEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeChange) {
_this.beforeChange(_this, outerArgs);
}
_this._change.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._change;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "changing", {
get: function () {
var _this = this;
if (this._changing == null) {
this._changing = new EventEmitter();
this.i.changing = delegateCombine(this.i.changing, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxInputChangeEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeChanging) {
_this.beforeChanging(_this, outerArgs);
}
_this._changing.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._changing;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXInputComponent.prototype, "compositionEnd", {
get: function () {
var _this = this;
if (this._compositionEnd == null) {
this._compositionEnd = new EventEmitter();
this.i.compositionEnd = delegateCombine(this.i.compositionEnd, function (o, e) {
_this._runInZone(function () {
var outerArgs = new IgxInputChangeEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeCompositionEnd) {
_this.beforeCompositionEnd(_this, outerArgs);
}
_this._compositionEnd.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._compositionEnd;
},
enumerable: false,
configurable: true
});
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>\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 \n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
return IgxXInputComponent;
}(IgxXInputGroupItemComponent));
export { 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>\n<ng-container #dynamicContent></ng-container>",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-x-input igx-x-input' },
styles: ["\n\t\t:host {\n\t\t\tdisplay: inline-block; \n vertical-align: middle; \n\t\t}\n \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
}], 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
}] } });