igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
725 lines (722 loc) • 26.6 kB
JavaScript
import { Output, TemplateRef, EventEmitter, Component, ViewContainerRef, ViewChild, Input, ChangeDetectionStrategy, HostBinding } from '@angular/core';
import { XCheckbox } from "./XCheckbox";
import { ensureEnum, brushToString, stringToBrush, ensureBool, toSpinal, initializePropertiesFromCss, NamePatcher } from "igniteui-angular-core";
import { AngularRenderer, PortalManager } from "igniteui-angular-core";
import { delegateCombine } from "igniteui-angular-core";
import { IgxCheckboxChangeEventArgs } from './igx-checkbox-change-event-args';
import { CheckboxLabelPosition_$type } from './CheckboxLabelPosition';
import { BaseControlTheme_$type } from "igniteui-angular-core";
import * as i0 from "@angular/core";
var IgxXCheckboxComponent = /** @class */ /*@__PURE__*/ (function () {
function IgxXCheckboxComponent(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._change = 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", "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 checkbox = this.i;
this._checkbox = checkbox;
if (renderer) {
this._portalManager = new PortalManager("checkboxLabel", componentFactoryResolver);
var ren = new AngularRenderer(root, this.renderer, window.document, this.ngZone, true, {}, this._portalManager);
this._wrapper = ren;
checkbox.provideContainer(ren);
}
}
// supports angular themes or custom properties set in CSS
IgxXCheckboxComponent.prototype.updateStyle = function () {
this._styling(this._root, this);
};
IgxXCheckboxComponent.prototype.ngOnDestroy = function () {
this._checkbox.destroy();
this._wrapper.destroy();
};
IgxXCheckboxComponent.prototype.ngAfterViewInit = function () {
this._portalManager.dynamicContent = this._dynamicContent;
this._portalManager.onChildContentChanged(this._childTemplateRef);
this._styling(this._root, this);
this.updateStyle();
this.i.onContentReady();
};
IgxXCheckboxComponent.prototype.createImplementation = function () {
return new XCheckbox();
};
Object.defineProperty(IgxXCheckboxComponent.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "baseTheme", {
/**
* Gets or sets the base built in theme to use for the checkbox.
*/
get: function () {
return this.i.n;
},
set: function (v) {
this.i.n = ensureEnum(BaseControlTheme_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "uncheckedBackgroundColor", {
/**
* Gets or sets the color to use for the background when the checkbox is unchecked.
*/
get: function () {
return brushToString(this.i.dl);
},
set: function (v) {
this.i.dl = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "actualUncheckedBackgroundColor", {
/**
* Gets or sets the color to use for the actual background when the checkbox is unchecked.
*/
get: function () {
return brushToString(this.i.db);
},
set: function (v) {
this.i.db = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "checkedBackgroundColor", {
/**
* Gets or sets the color to use for the background when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.dd);
},
set: function (v) {
this.i.dd = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "tickColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.dk);
},
set: function (v) {
this.i.dk = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "actualTickColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.da);
},
set: function (v) {
this.i.da = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "uncheckedBorderColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is unchecked.
*/
get: function () {
return brushToString(this.i.dm);
},
set: function (v) {
this.i.dm = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "checkedBorderColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.de);
},
set: function (v) {
this.i.de = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "actualUncheckedBorderColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.dc);
},
set: function (v) {
this.i.dc = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "actualCheckedBorderColor", {
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.c9);
},
set: function (v) {
this.i.c9 = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "borderWidth", {
/**
* Gets or sets the Width to use for the check mark when the checkbox is checked.
*/
get: function () {
return this.i.aq;
},
set: function (v) {
this.i.aq = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "actualBorderWidth", {
/**
* Gets or sets the Width to use for the check mark when the checkbox is checked.
*/
get: function () {
return this.i.an;
},
set: function (v) {
this.i.an = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "cornerRadius", {
/**
* Gets or sets the corner radius to use for the checkbox.
*/
get: function () {
return this.i.ar;
},
set: function (v) {
this.i.ar = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "tickStrokeWidth", {
/**
* Gets or sets the corner radius to use for the checkbox.
*/
get: function () {
return this.i.av;
},
set: function (v) {
this.i.av = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "actualTickStrokeWidth", {
/**
* Gets or sets the stroke width to use for the check mark.
*/
get: function () {
return this.i.ap;
},
set: function (v) {
this.i.ap = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "actualCornerRadius", {
/**
* Gets the actual corner radius to use for the checkbox.
*/
get: function () {
return this.i.ao;
},
set: function (v) {
this.i.ao = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "actualCheckedBackgroundColor", {
/**
* Gets or sets the color to use for the actual background when the checkbox is checked.
*/
get: function () {
return brushToString(this.i.c8);
},
set: function (v) {
this.i.c8 = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "inputId", {
/**
* Gets or sets the id to use for the internal native checkbox.
*/
get: function () {
return this.i.b1;
},
set: function (v) {
this.i.b1 = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "id", {
/**
* Gets or sets the id to use for the checkbox.
*/
get: function () {
return this.i.bz;
},
set: function (v) {
this.i.bz = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "labelId", {
/**
* Gets or sets id to use for the checkbox label.
*/
get: function () {
return this.i.labelId;
},
set: function (v) {
this.i.labelId = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "name", {
/**
* Gets or sets name to use for the checkbox.
*/
get: function () {
return this.i.ca;
},
set: function (v) {
this.i.ca = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "tabIndex", {
/**
* Gets or sets TabIndex to use for the checkbox.
*/
get: function () {
return this.i.az;
},
set: function (v) {
this.i.az = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "required", {
/**
* Gets or sets if the checkbox is required.
*/
get: function () {
return this.i.ay;
},
set: function (v) {
this.i.ay = +v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "ariaLabelledBy", {
/**
* Gets or sets the value of the aria-labelledby attribute.
*/
get: function () {
return this.i.bn;
},
set: function (v) {
this.i.bn = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "ariaLabel", {
/**
* Gets or sets the value of the aria-label attribute.
*/
get: function () {
return this.i.bm;
},
set: function (v) {
this.i.bm = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "value", {
/**
* Gets or sets value to use for the checkbox.
*/
get: function () {
return this.i.a4;
},
set: function (v) {
this.i.a4 = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "focused", {
/**
* Gets or sets if the checkbox is Focused.
*/
get: function () {
return this.i.focused;
},
set: function (v) {
this.i.focused = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "labelPosition", {
/**
* Gets or sets LabelPosition to use for the checkbox.
*/
get: function () {
return this.i.e;
},
set: function (v) {
this.i.e = ensureEnum(CheckboxLabelPosition_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "disableRipple", {
/**
* Gets or sets whether to disable the ripple effect for the checkbox.
*/
get: function () {
return this.i.y;
},
set: function (v) {
this.i.y = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "checked", {
/**
* Gets or sets whether the checkbox is checked.
*/
get: function () {
return this.i.checked;
},
set: function (v) {
this.i.checked = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.prototype, "indeterminate", {
/**
* Gets or sets whether the checkbox is indeterminate.
*/
get: function () {
return this.i.indeterminate;
},
set: function (v) {
this.i.indeterminate = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCheckboxComponent.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(IgxXCheckboxComponent.prototype, "disableTransitions", {
/**
* Gets or sets whether the checkbox transitions are disabled.
*/
get: function () {
return this.i.z;
},
set: function (v) {
this.i.z = ensureBool(v);
},
enumerable: false,
configurable: true
});
IgxXCheckboxComponent.prototype.findByName = function (name) {
if (this.findEphemera) {
if (name && name.indexOf("@@e:") == 0) {
return this.findEphemera(name);
}
}
return null;
};
Object.defineProperty(IgxXCheckboxComponent.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgxXCheckboxComponent.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgxXCheckboxComponent.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("XCheckboxComponent");
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;
};
IgxXCheckboxComponent.prototype.onDetachedFromUI = function () {
this.i.onDetachedFromUI();
};
IgxXCheckboxComponent.prototype.onAttachedToUI = function () {
this.i.onAttachedToUI();
};
/**
* Exports visual information about the current state of the grid.
*/
IgxXCheckboxComponent.prototype.exportVisualModel = function () {
var iv = this.i.a3();
return (iv);
};
/**
* Returns a serialized copy of the exported visual model
*/
IgxXCheckboxComponent.prototype.exportSerializedVisualModel = function () {
var iv = this.i.by();
return (iv);
};
Object.defineProperty(IgxXCheckboxComponent.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 IgxCheckboxChangeEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeChange) {
_this.beforeChange(_this, outerArgs);
}
_this._change.emit({
sender: _this,
args: outerArgs
});
});
});
}
return this._change;
},
enumerable: false,
configurable: true
});
IgxXCheckboxComponent.prototype._runInZone = function (act) {
if (this._zoneRunner != null) {
this._zoneRunner(act);
}
else {
act();
}
};
IgxXCheckboxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXCheckboxComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
IgxXCheckboxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxXCheckboxComponent, selector: "igx-x-checkbox", inputs: { baseTheme: "baseTheme", uncheckedBackgroundColor: "uncheckedBackgroundColor", actualUncheckedBackgroundColor: "actualUncheckedBackgroundColor", checkedBackgroundColor: "checkedBackgroundColor", tickColor: "tickColor", actualTickColor: "actualTickColor", uncheckedBorderColor: "uncheckedBorderColor", checkedBorderColor: "checkedBorderColor", actualUncheckedBorderColor: "actualUncheckedBorderColor", actualCheckedBorderColor: "actualCheckedBorderColor", borderWidth: "borderWidth", actualBorderWidth: "actualBorderWidth", cornerRadius: "cornerRadius", tickStrokeWidth: "tickStrokeWidth", actualTickStrokeWidth: "actualTickStrokeWidth", actualCornerRadius: "actualCornerRadius", actualCheckedBackgroundColor: "actualCheckedBackgroundColor", inputId: "inputId", id: "id", labelId: "labelId", name: "name", tabIndex: ["tabindex", "tabIndex"], required: "required", ariaLabelledBy: ["aria-labelledby", "ariaLabelledBy"], ariaLabel: ["aria-label", "ariaLabel"], value: "value", focused: "focused", labelPosition: "labelPosition", disableRipple: "disableRipple", checked: "checked", indeterminate: "indeterminate", disabled: "disabled", disableTransitions: "disableTransitions" }, outputs: { change: "change" }, host: { properties: { "attr.id": "this.id" }, classAttribute: "ig-x-checkbox igx-x-checkbox" }, 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\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
return IgxXCheckboxComponent;
}());
export { IgxXCheckboxComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXCheckboxComponent, decorators: [{
type: Component,
args: [{
selector: 'igx-x-checkbox',
template: "<ng-template #childContent><ng-content></ng-content></ng-template>\n<ng-container #dynamicContent></ng-container>",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-x-checkbox igx-x-checkbox' },
styles: ["\n\t\t:host {\n\t\t\tdisplay: inline-block; \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
}], uncheckedBackgroundColor: [{
type: Input
}], actualUncheckedBackgroundColor: [{
type: Input
}], checkedBackgroundColor: [{
type: Input
}], tickColor: [{
type: Input
}], actualTickColor: [{
type: Input
}], uncheckedBorderColor: [{
type: Input
}], checkedBorderColor: [{
type: Input
}], actualUncheckedBorderColor: [{
type: Input
}], actualCheckedBorderColor: [{
type: Input
}], borderWidth: [{
type: Input
}], actualBorderWidth: [{
type: Input
}], cornerRadius: [{
type: Input
}], tickStrokeWidth: [{
type: Input
}], actualTickStrokeWidth: [{
type: Input
}], actualCornerRadius: [{
type: Input
}], actualCheckedBackgroundColor: [{
type: Input
}], inputId: [{
type: Input
}], id: [{
type: HostBinding,
args: ['attr.id']
}, {
type: Input
}], labelId: [{
type: Input
}], name: [{
type: Input
}], tabIndex: [{
type: Input,
args: ['tabindex']
}], required: [{
type: Input
}], ariaLabelledBy: [{
type: Input,
args: ['aria-labelledby']
}], ariaLabel: [{
type: Input,
args: ['aria-label']
}], value: [{
type: Input
}], focused: [{
type: Input
}], labelPosition: [{
type: Input
}], disableRipple: [{
type: Input
}], checked: [{
type: Input
}], indeterminate: [{
type: Input
}], disabled: [{
type: Input
}], disableTransitions: [{
type: Input
}], change: [{
type: Output
}] } });