igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
573 lines (570 loc) • 21.5 kB
JavaScript
import { Output, EventEmitter, Component, ViewChild, ElementRef, Input, ChangeDetectionStrategy } from '@angular/core';
import { AngularRenderer } from "igniteui-angular-core";
import { ensureEnum, brushToString, stringToBrush, ensureBool, initializePropertiesFromCss, NamePatcher, toSpinal } from "igniteui-angular-core";
import { FontInfo } from "igniteui-angular-core";
import { delegateCombine } from "igniteui-angular-core";
import { XCalendar } from './XCalendar';
import { IgxSelectedValueChangedEventArgs } from "./igx-selected-value-changed-event-args";
import { ControlDisplayDensity_$type } from "igniteui-angular-core";
import { BaseControlTheme_$type } from "igniteui-angular-core";
import { DayOfWeek_$type } from "./DayOfWeek";
import { FirstWeek_$type } from "./FirstWeek";
import * as i0 from "@angular/core";
// IgxDataGridModule.register();
var IgxXCalendarComponent = /** @class */ /*@__PURE__*/ (function () {
function IgxXCalendarComponent(renderer, _elRef, ngZone, injector, componentFactoryResolver) {
this.renderer = renderer;
this._elRef = _elRef;
this.ngZone = ngZone;
this.injector = injector;
this.componentFactoryResolver = componentFactoryResolver;
this._dataSource = null;
this._wrapper = null;
this._root = null;
this._implementation = null;
this.__p = null;
this._hasUserValues = new Set();
this._stylingContainer = null;
this._stylingParent = null;
this._inStyling = false;
this._selectedValueChanged = null;
this._valueChange = null;
this._zoneRunner = null;
if (this._styling) {
NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this));
}
this._implementation = this.createImplementation();
var calendar = this.i;
this._calendar = calendar;
}
Object.defineProperty(IgxXCalendarComponent.prototype, "height", {
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
this.renderer.setStyle(this._elRef.element.nativeElement, "height", value);
this._calendar.notifySizeChanged();
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "width", {
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
this.renderer.setStyle(this._elRef.element.nativeElement, "width", value);
this._calendar.notifySizeChanged();
},
enumerable: false,
configurable: true
});
// supports angular themes or custom properties set in CSS
IgxXCalendarComponent.prototype.updateStyle = function () {
this._styling(this._root, this);
};
IgxXCalendarComponent.prototype.ngOnDestroy = function () {
this._calendar.destroy();
this._wrapper.destroy();
};
IgxXCalendarComponent.prototype.ngAfterViewInit = function () {
var _this = this;
if (this.renderer && this._calendarContainer != null) {
this.container = this._calendarContainer.nativeElement;
this._root = this.container;
var ren = new AngularRenderer(this.container, this.renderer, window.document, this.ngZone, true, null);
this._wrapper = ren;
this._calendar.provideContainer(ren);
this._calendar.notifySizeChanged();
ren.addSizeWatcher(function () {
_this._calendar.notifySizeChanged();
});
}
this._styling(this._root, this);
this.i.notifySizeChanged();
this.updateStyle();
};
IgxXCalendarComponent.prototype.createImplementation = function () {
return new XCalendar();
};
Object.defineProperty(IgxXCalendarComponent.prototype, "i", {
get: function () {
return this._implementation;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "value", {
/**
* Gets or Sets the value for the calendar.
*/
get: function () {
return this.i.value;
},
set: function (v) {
this.i.value = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "today", {
/**
* Gets or Sets the property name that contains the values.
*/
get: function () {
return this.i.av;
},
set: function (v) {
this.i.av = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "minDate", {
/**
* Gets or Sets the property name that contains the MinDate.
*/
get: function () {
return this.i.au;
},
set: function (v) {
this.i.au = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "maxDate", {
/**
* Gets or Sets the property name that contains the MaxDate.
*/
get: function () {
return this.i.at;
},
set: function (v) {
this.i.at = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "density", {
/**
* Gets or sets the display density to use for the calendar.
*/
get: function () {
return this.i.t;
},
set: function (v) {
this.i.t = ensureEnum(ControlDisplayDensity_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "baseTheme", {
/**
* Gets or sets the base built in theme to use for the calendar.
*/
get: function () {
return this.i.r;
},
set: function (v) {
this.i.r = ensureEnum(BaseControlTheme_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "backgroundColor", {
/**
* Gets or Sets the selected date background color
*/
get: function () {
return brushToString(this.i.dg);
},
set: function (v) {
this.i.dg = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "selectedDateBackgroundColor", {
/**
* Gets or Sets the selected date background color
*/
get: function () {
return brushToString(this.i.dm);
},
set: function (v) {
this.i.dm = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "selectedFocusDateBackgroundColor", {
/**
* Gets or Sets the selected date background color
*/
get: function () {
return brushToString(this.i.dp);
},
set: function (v) {
this.i.dp = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "focusDateBackgroundColor", {
/**
* Gets or Sets the focus date background color
*/
get: function () {
return brushToString(this.i.dj);
},
set: function (v) {
this.i.dj = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "hoverBackgroundColor", {
/**
* Gets or Sets the focus date background color
*/
get: function () {
return brushToString(this.i.dl);
},
set: function (v) {
this.i.dl = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "textColor", {
/**
* Gets or Sets the selected date text color
*/
get: function () {
return brushToString(this.i.dq);
},
set: function (v) {
this.i.dq = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "selectedDateTextColor", {
/**
* Gets or Sets the selected date text color
*/
get: function () {
return brushToString(this.i.dn);
},
set: function (v) {
this.i.dn = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "focusDateTextColor", {
/**
* Gets or Sets the focus date text color
*/
get: function () {
return brushToString(this.i.dk);
},
set: function (v) {
this.i.dk = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "currentDateTextColor", {
/**
* Gets or Sets the current date text color
*/
get: function () {
return brushToString(this.i.di);
},
set: function (v) {
this.i.di = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "currentDateBorderColor", {
/**
* Gets or Sets the current date text color
*/
get: function () {
return brushToString(this.i.dh);
},
set: function (v) {
this.i.dh = stringToBrush(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "showTodayButton", {
/**
* Gets or sets the ShowTodayButton property to detirmine if the today button is shown
*/
get: function () {
return this.i.ae;
},
set: function (v) {
this.i.ae = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "textStyle", {
/**
* Gets or sets the font to use for the combobox.
*/
get: function () {
if (this.i.v == null) {
return null;
}
return this.i.v.fontString;
},
set: function (v) {
var fi = new FontInfo();
fi.fontString = v;
this.i.v = fi;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "firstDayOfWeek", {
/**
* Gets or sets the FirstDayOfWeek property to detirmine first day of the week
*/
get: function () {
return this.i.l;
},
set: function (v) {
this.i.l = ensureEnum(DayOfWeek_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "firstWeekOfYear", {
/**
* Gets or sets the FirstWeekOfYear property to detirmine first week of the year
*/
get: function () {
return this.i.o;
},
set: function (v) {
this.i.o = ensureEnum(FirstWeek_$type, v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "showWeekNumbers", {
/**
* Gets or sets the ShowWeekNumbers property to detirmine if the week numbers are shown
*/
get: function () {
return this.i.af;
},
set: function (v) {
this.i.af = ensureBool(v);
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "hasUserValues", {
get: function () {
return this._hasUserValues;
},
enumerable: false,
configurable: true
});
IgxXCalendarComponent.prototype.__m = function (propertyName) {
if (!this._inStyling) {
this._hasUserValues.add(propertyName);
}
};
IgxXCalendarComponent.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("XCalendarComponent");
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;
};
/**
* Exports visual information about the current state of the grid.
*/
IgxXCalendarComponent.prototype.exportVisualModel = function () {
var iv = this.i.bj();
return (iv);
};
/**
* Returns a serialized copy of the exported visual model
*/
IgxXCalendarComponent.prototype.exportSerializedVisualModel = function () {
var iv = this.i.bs();
return (iv);
};
Object.defineProperty(IgxXCalendarComponent.prototype, "selectedValueChanged", {
/**
* Called when date is selected.
*/
get: function () {
var _this = this;
if (this._selectedValueChanged == null) {
this._selectedValueChanged = new EventEmitter();
this.i.selectedValueChanged = delegateCombine(this.i.selectedValueChanged, function (o, e) {
var outerArgs = new IgxSelectedValueChangedEventArgs();
outerArgs._provideImplementation(e);
if (_this.beforeSelectedValueChanged) {
_this.beforeSelectedValueChanged(_this, outerArgs);
}
_this._selectedValueChanged.emit({
sender: _this,
args: outerArgs
});
});
}
return this._selectedValueChanged;
},
enumerable: false,
configurable: true
});
Object.defineProperty(IgxXCalendarComponent.prototype, "valueChange", {
get: function () {
var _this = this;
if (this._valueChange == null) {
this._valueChange = new EventEmitter();
this.i.propertyChanged = delegateCombine(this.i.propertyChanged, function (o, e) {
_this._runInZone(function () {
var iv = e;
var ext = _this.value;
if (_this.beforeValueChange) {
_this.beforeValueChange(_this, ext);
}
_this._valueChange.emit(ext);
});
});
}
return this._valueChange;
},
enumerable: false,
configurable: true
});
IgxXCalendarComponent.prototype._runInZone = function (act) {
if (this._zoneRunner != null) {
this._zoneRunner(act);
}
else {
act();
}
};
IgxXCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXCalendarComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
IgxXCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxXCalendarComponent, selector: "igx-x-calendar", inputs: { height: "height", width: "width", value: "value", today: "today", minDate: "minDate", maxDate: "maxDate", density: "density", baseTheme: "baseTheme", backgroundColor: "backgroundColor", selectedDateBackgroundColor: "selectedDateBackgroundColor", selectedFocusDateBackgroundColor: "selectedFocusDateBackgroundColor", focusDateBackgroundColor: "focusDateBackgroundColor", hoverBackgroundColor: "hoverBackgroundColor", textColor: "textColor", selectedDateTextColor: "selectedDateTextColor", focusDateTextColor: "focusDateTextColor", currentDateTextColor: "currentDateTextColor", currentDateBorderColor: "currentDateBorderColor", showTodayButton: "showTodayButton", textStyle: "textStyle", firstDayOfWeek: "firstDayOfWeek", firstWeekOfYear: "firstWeekOfYear", showWeekNumbers: "showWeekNumbers" }, outputs: { selectedValueChanged: "selectedValueChanged", valueChange: "valueChange" }, host: { classAttribute: "ig-x-calendar igx-x-calendar" }, providers: [], viewQueries: [{ propertyName: "_calendarContainer", first: true, predicate: ["calendarContainer"], descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div #calendarContainer>\n </div>", isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
return IgxXCalendarComponent;
}());
export { IgxXCalendarComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXCalendarComponent, decorators: [{
type: Component,
args: [{
selector: 'igx-x-calendar',
template: "<div #calendarContainer>\n </div>",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-x-calendar igx-x-calendar' },
styles: ["\n\t\t:host {\n\t\t\tdisplay: 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: { _calendarContainer: [{
type: ViewChild,
args: ["calendarContainer", { read: ElementRef, static: true }]
}], height: [{
type: Input
}], width: [{
type: Input
}], value: [{
type: Input
}], today: [{
type: Input
}], minDate: [{
type: Input
}], maxDate: [{
type: Input
}], density: [{
type: Input
}], baseTheme: [{
type: Input
}], backgroundColor: [{
type: Input
}], selectedDateBackgroundColor: [{
type: Input
}], selectedFocusDateBackgroundColor: [{
type: Input
}], focusDateBackgroundColor: [{
type: Input
}], hoverBackgroundColor: [{
type: Input
}], textColor: [{
type: Input
}], selectedDateTextColor: [{
type: Input
}], focusDateTextColor: [{
type: Input
}], currentDateTextColor: [{
type: Input
}], currentDateBorderColor: [{
type: Input
}], showTodayButton: [{
type: Input
}], textStyle: [{
type: Input
}], firstDayOfWeek: [{
type: Input
}], firstWeekOfYear: [{
type: Input
}], showWeekNumbers: [{
type: Input
}], selectedValueChanged: [{
type: Output
}], valueChange: [{
type: Output
}] } });