igniteui-angular-inputs
Version:
Ignite UI Angular input components for building rich data visualizations for modern web apps.
469 lines (466 loc) • 17.8 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();
export let IgxXCalendarComponent = /*@__PURE__*/ (() => {
class IgxXCalendarComponent {
constructor(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;
}
set height(value) {
this._height = value;
this.renderer.setStyle(this._elRef.element.nativeElement, "height", value);
this._calendar.notifySizeChanged();
}
get height() {
return this._height;
}
set width(value) {
this._width = value;
this.renderer.setStyle(this._elRef.element.nativeElement, "width", value);
this._calendar.notifySizeChanged();
}
get width() {
return this._width;
}
// supports angular themes or custom properties set in CSS
updateStyle() {
this._styling(this._root, this);
}
ngOnDestroy() {
this._calendar.destroy();
this._wrapper.destroy();
}
ngAfterViewInit() {
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(() => {
this._calendar.notifySizeChanged();
});
}
this._styling(this._root, this);
this.i.notifySizeChanged();
this.updateStyle();
}
createImplementation() {
return new XCalendar();
}
get i() {
return this._implementation;
}
/**
* Gets or Sets the value for the calendar.
*/
get value() {
return this.i.value;
}
set value(v) {
this.i.value = v;
}
/**
* Gets or Sets the property name that contains the values.
*/
get today() {
return this.i.av;
}
set today(v) {
this.i.av = v;
}
/**
* Gets or Sets the property name that contains the MinDate.
*/
get minDate() {
return this.i.au;
}
set minDate(v) {
this.i.au = v;
}
/**
* Gets or Sets the property name that contains the MaxDate.
*/
get maxDate() {
return this.i.at;
}
set maxDate(v) {
this.i.at = v;
}
/**
* Gets or sets the display density to use for the calendar.
*/
get density() {
return this.i.t;
}
set density(v) {
this.i.t = ensureEnum(ControlDisplayDensity_$type, v);
}
/**
* Gets or sets the base built in theme to use for the calendar.
*/
get baseTheme() {
return this.i.r;
}
set baseTheme(v) {
this.i.r = ensureEnum(BaseControlTheme_$type, v);
}
/**
* Gets or Sets the selected date background color
*/
get backgroundColor() {
return brushToString(this.i.dg);
}
set backgroundColor(v) {
this.i.dg = stringToBrush(v);
}
/**
* Gets or Sets the selected date background color
*/
get selectedDateBackgroundColor() {
return brushToString(this.i.dm);
}
set selectedDateBackgroundColor(v) {
this.i.dm = stringToBrush(v);
}
/**
* Gets or Sets the selected date background color
*/
get selectedFocusDateBackgroundColor() {
return brushToString(this.i.dp);
}
set selectedFocusDateBackgroundColor(v) {
this.i.dp = stringToBrush(v);
}
/**
* Gets or Sets the focus date background color
*/
get focusDateBackgroundColor() {
return brushToString(this.i.dj);
}
set focusDateBackgroundColor(v) {
this.i.dj = stringToBrush(v);
}
/**
* Gets or Sets the focus date background color
*/
get hoverBackgroundColor() {
return brushToString(this.i.dl);
}
set hoverBackgroundColor(v) {
this.i.dl = stringToBrush(v);
}
/**
* Gets or Sets the selected date text color
*/
get textColor() {
return brushToString(this.i.dq);
}
set textColor(v) {
this.i.dq = stringToBrush(v);
}
/**
* Gets or Sets the selected date text color
*/
get selectedDateTextColor() {
return brushToString(this.i.dn);
}
set selectedDateTextColor(v) {
this.i.dn = stringToBrush(v);
}
/**
* Gets or Sets the focus date text color
*/
get focusDateTextColor() {
return brushToString(this.i.dk);
}
set focusDateTextColor(v) {
this.i.dk = stringToBrush(v);
}
/**
* Gets or Sets the current date text color
*/
get currentDateTextColor() {
return brushToString(this.i.di);
}
set currentDateTextColor(v) {
this.i.di = stringToBrush(v);
}
/**
* Gets or Sets the current date text color
*/
get currentDateBorderColor() {
return brushToString(this.i.dh);
}
set currentDateBorderColor(v) {
this.i.dh = stringToBrush(v);
}
/**
* Gets or sets the ShowTodayButton property to detirmine if the today button is shown
*/
get showTodayButton() {
return this.i.ae;
}
set showTodayButton(v) {
this.i.ae = ensureBool(v);
}
/**
* Gets or sets the font to use for the combobox.
*/
get textStyle() {
if (this.i.v == null) {
return null;
}
return this.i.v.fontString;
}
set textStyle(v) {
let fi = new FontInfo();
fi.fontString = v;
this.i.v = fi;
}
/**
* Gets or sets the FirstDayOfWeek property to detirmine first day of the week
*/
get firstDayOfWeek() {
return this.i.l;
}
set firstDayOfWeek(v) {
this.i.l = ensureEnum(DayOfWeek_$type, v);
}
/**
* Gets or sets the FirstWeekOfYear property to detirmine first week of the year
*/
get firstWeekOfYear() {
return this.i.o;
}
set firstWeekOfYear(v) {
this.i.o = ensureEnum(FirstWeek_$type, v);
}
/**
* Gets or sets the ShowWeekNumbers property to detirmine if the week numbers are shown
*/
get showWeekNumbers() {
return this.i.af;
}
set showWeekNumbers(v) {
this.i.af = ensureBool(v);
}
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("XCalendarComponent");
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;
}
/**
* Exports visual information about the current state of the grid.
*/
exportVisualModel() {
let iv = this.i.bj();
return (iv);
}
/**
* Returns a serialized copy of the exported visual model
*/
exportSerializedVisualModel() {
let iv = this.i.bs();
return (iv);
}
/**
* Called when date is selected.
*/
get selectedValueChanged() {
if (this._selectedValueChanged == null) {
this._selectedValueChanged = new EventEmitter();
this.i.selectedValueChanged = delegateCombine(this.i.selectedValueChanged, (o, e) => {
let outerArgs = new IgxSelectedValueChangedEventArgs();
outerArgs._provideImplementation(e);
if (this.beforeSelectedValueChanged) {
this.beforeSelectedValueChanged(this, outerArgs);
}
this._selectedValueChanged.emit({
sender: this,
args: outerArgs
});
});
}
return this._selectedValueChanged;
}
get valueChange() {
if (this._valueChange == null) {
this._valueChange = new EventEmitter();
this.i.propertyChanged = delegateCombine(this.i.propertyChanged, (o, e) => {
this._runInZone(() => {
let iv = e;
let ext = this.value;
if (this.beforeValueChange) {
this.beforeValueChange(this, ext);
}
this._valueChange.emit(ext);
});
});
}
return this._valueChange;
}
_runInZone(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>
</div>`, isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
return 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>
</div>`,
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [],
host: { 'class': 'ig-x-calendar igx-x-calendar' },
styles: [`
:host {
display: block;
}
`]
}]
}], 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
}] } });