igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
587 lines (584 loc) • 21.7 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";
export let IgxXCheckboxComponent = /*@__PURE__*/ (() => {
class IgxXCheckboxComponent {
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._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
updateStyle() {
this._styling(this._root, this);
}
ngOnDestroy() {
this._checkbox.destroy();
this._wrapper.destroy();
}
ngAfterViewInit() {
this._portalManager.dynamicContent = this._dynamicContent;
this._portalManager.onChildContentChanged(this._childTemplateRef);
this._styling(this._root, this);
this.updateStyle();
this.i.onContentReady();
}
createImplementation() {
return new XCheckbox();
}
get i() {
return this._implementation;
}
/**
* Gets or sets the base built in theme to use for the checkbox.
*/
get baseTheme() {
return this.i.n;
}
set baseTheme(v) {
this.i.n = ensureEnum(BaseControlTheme_$type, v);
}
/**
* Gets or sets the color to use for the background when the checkbox is unchecked.
*/
get uncheckedBackgroundColor() {
return brushToString(this.i.dl);
}
set uncheckedBackgroundColor(v) {
this.i.dl = stringToBrush(v);
}
/**
* Gets or sets the color to use for the actual background when the checkbox is unchecked.
*/
get actualUncheckedBackgroundColor() {
return brushToString(this.i.db);
}
set actualUncheckedBackgroundColor(v) {
this.i.db = stringToBrush(v);
}
/**
* Gets or sets the color to use for the background when the checkbox is checked.
*/
get checkedBackgroundColor() {
return brushToString(this.i.dd);
}
set checkedBackgroundColor(v) {
this.i.dd = stringToBrush(v);
}
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get tickColor() {
return brushToString(this.i.dk);
}
set tickColor(v) {
this.i.dk = stringToBrush(v);
}
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get actualTickColor() {
return brushToString(this.i.da);
}
set actualTickColor(v) {
this.i.da = stringToBrush(v);
}
/**
* Gets or sets the color to use for the check mark when the checkbox is unchecked.
*/
get uncheckedBorderColor() {
return brushToString(this.i.dm);
}
set uncheckedBorderColor(v) {
this.i.dm = stringToBrush(v);
}
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get checkedBorderColor() {
return brushToString(this.i.de);
}
set checkedBorderColor(v) {
this.i.de = stringToBrush(v);
}
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get actualUncheckedBorderColor() {
return brushToString(this.i.dc);
}
set actualUncheckedBorderColor(v) {
this.i.dc = stringToBrush(v);
}
/**
* Gets or sets the color to use for the check mark when the checkbox is checked.
*/
get actualCheckedBorderColor() {
return brushToString(this.i.c9);
}
set actualCheckedBorderColor(v) {
this.i.c9 = stringToBrush(v);
}
/**
* Gets or sets the Width to use for the check mark when the checkbox is checked.
*/
get borderWidth() {
return this.i.aq;
}
set borderWidth(v) {
this.i.aq = +v;
}
/**
* Gets or sets the Width to use for the check mark when the checkbox is checked.
*/
get actualBorderWidth() {
return this.i.an;
}
set actualBorderWidth(v) {
this.i.an = +v;
}
/**
* Gets or sets the corner radius to use for the checkbox.
*/
get cornerRadius() {
return this.i.ar;
}
set cornerRadius(v) {
this.i.ar = +v;
}
/**
* Gets or sets the corner radius to use for the checkbox.
*/
get tickStrokeWidth() {
return this.i.av;
}
set tickStrokeWidth(v) {
this.i.av = +v;
}
/**
* Gets or sets the stroke width to use for the check mark.
*/
get actualTickStrokeWidth() {
return this.i.ap;
}
set actualTickStrokeWidth(v) {
this.i.ap = +v;
}
/**
* Gets the actual corner radius to use for the checkbox.
*/
get actualCornerRadius() {
return this.i.ao;
}
set actualCornerRadius(v) {
this.i.ao = +v;
}
/**
* Gets or sets the color to use for the actual background when the checkbox is checked.
*/
get actualCheckedBackgroundColor() {
return brushToString(this.i.c8);
}
set actualCheckedBackgroundColor(v) {
this.i.c8 = stringToBrush(v);
}
/**
* Gets or sets the id to use for the internal native checkbox.
*/
get inputId() {
return this.i.b1;
}
set inputId(v) {
this.i.b1 = v;
}
/**
* Gets or sets the id to use for the checkbox.
*/
get id() {
return this.i.bz;
}
set id(v) {
this.i.bz = v;
}
/**
* Gets or sets id to use for the checkbox label.
*/
get labelId() {
return this.i.labelId;
}
set labelId(v) {
this.i.labelId = v;
}
/**
* Gets or sets name to use for the checkbox.
*/
get name() {
return this.i.ca;
}
set name(v) {
this.i.ca = v;
}
/**
* Gets or sets TabIndex to use for the checkbox.
*/
get tabIndex() {
return this.i.az;
}
set tabIndex(v) {
this.i.az = +v;
}
/**
* Gets or sets if the checkbox is required.
*/
get required() {
return this.i.ay;
}
set required(v) {
this.i.ay = +v;
}
/**
* Gets or sets the value of the aria-labelledby attribute.
*/
get ariaLabelledBy() {
return this.i.bn;
}
set ariaLabelledBy(v) {
this.i.bn = v;
}
/**
* Gets or sets the value of the aria-label attribute.
*/
get ariaLabel() {
return this.i.bm;
}
set ariaLabel(v) {
this.i.bm = v;
}
/**
* Gets or sets value to use for the checkbox.
*/
get value() {
return this.i.a4;
}
set value(v) {
this.i.a4 = v;
}
/**
* Gets or sets if the checkbox is Focused.
*/
get focused() {
return this.i.focused;
}
set focused(v) {
this.i.focused = ensureBool(v);
}
/**
* Gets or sets LabelPosition to use for the checkbox.
*/
get labelPosition() {
return this.i.e;
}
set labelPosition(v) {
this.i.e = ensureEnum(CheckboxLabelPosition_$type, v);
}
/**
* Gets or sets whether to disable the ripple effect for the checkbox.
*/
get disableRipple() {
return this.i.y;
}
set disableRipple(v) {
this.i.y = ensureBool(v);
}
/**
* Gets or sets whether the checkbox is checked.
*/
get checked() {
return this.i.checked;
}
set checked(v) {
this.i.checked = ensureBool(v);
}
/**
* Gets or sets whether the checkbox is indeterminate.
*/
get indeterminate() {
return this.i.indeterminate;
}
set indeterminate(v) {
this.i.indeterminate = ensureBool(v);
}
/**
* 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 transitions are disabled.
*/
get disableTransitions() {
return this.i.z;
}
set disableTransitions(v) {
this.i.z = 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("XCheckboxComponent");
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.a3();
return (iv);
}
/**
* Returns a serialized copy of the exported visual model
*/
exportSerializedVisualModel() {
let iv = this.i.by();
return (iv);
}
get change() {
if (this._change == null) {
this._change = new EventEmitter();
this.i.change = delegateCombine(this.i.change, (o, e) => {
this._runInZone(() => {
let outerArgs = new IgxCheckboxChangeEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeChange) {
this.beforeChange(this, outerArgs);
}
this._change.emit({
sender: this,
args: outerArgs
});
});
});
}
return this._change;
}
_runInZone(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>
<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;
})();
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>
<ng-container #dynamicContent></ng-container>`,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-x-checkbox igx-x-checkbox' },
styles: [`
:host {
display: inline-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 }]
}], 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
}] } });