UNPKG

igniteui-angular-inputs

Version:

Ignite UI Angular input components for building rich data visualizations for modern web apps.

766 lines (763 loc) 28.8 kB
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 { XDatePicker } from './XDatePicker'; import { IgxSelectedValueChangedEventArgs } from "./igx-selected-value-changed-event-args"; import { IgxGotFocusEventArgs } from "./igx-got-focus-event-args"; import { IgxLostFocusEventArgs } from "./igx-lost-focus-event-args"; import { IgxInputChangeEventArgs } from "./igx-input-change-event-args"; import { IgxKeyEventArgs } from "igniteui-angular-core"; import { ControlDisplayDensity_$type } from "igniteui-angular-core"; import { BaseControlTheme_$type } from "igniteui-angular-core"; import { DateFormats_$type } from "./DateFormats"; import { DayOfWeek_$type } from "./DayOfWeek"; import { FirstWeek_$type } from "./FirstWeek"; import * as i0 from "@angular/core"; // IgxDataGridModule.register(); var IgxXDatePickerComponent = /** @class */ /*@__PURE__*/ (function () { function IgxXDatePickerComponent(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._gotFocus = null; this._lostFocus = null; this._keyDown = null; this._changing = null; this._valueChange = null; this._zoneRunner = null; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._implementation = this.createImplementation(); var datePicker = this.i; this._datePicker = datePicker; } Object.defineProperty(IgxXDatePickerComponent.prototype, "height", { get: function () { return this._height; }, set: function (value) { this._height = value; this.renderer.setStyle(this._elRef.element.nativeElement, "height", value); this._datePicker.notifySizeChanged(); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "width", { get: function () { return this._width; }, set: function (value) { this._width = value; this.renderer.setStyle(this._elRef.element.nativeElement, "width", value); this._datePicker.notifySizeChanged(); }, enumerable: false, configurable: true }); // supports angular themes or custom properties set in CSS IgxXDatePickerComponent.prototype.updateStyle = function () { this._styling(this._root, this); }; IgxXDatePickerComponent.prototype.ngOnDestroy = function () { this._datePicker.destroy(); this._wrapper.destroy(); }; IgxXDatePickerComponent.prototype.ngAfterViewInit = function () { var _this = this; if (this.renderer && this._datePickerContainer != null) { this.container = this._datePickerContainer.nativeElement; this._root = this.container; var ren = new AngularRenderer(this.container, this.renderer, window.document, this.ngZone, true, null); this._wrapper = ren; this._datePicker.provideContainer(ren); this._datePicker.notifySizeChanged(); ren.addSizeWatcher(function () { _this._datePicker.notifySizeChanged(); }); } this._styling(this._root, this); this.i.notifySizeChanged(); this.updateStyle(); }; IgxXDatePickerComponent.prototype.createImplementation = function () { return new XDatePicker(); }; Object.defineProperty(IgxXDatePickerComponent.prototype, "i", { get: function () { return this._implementation; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "value", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.value; }, set: function (v) { this.i.value = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "today", { /** * Gets or Sets the property name that contains the values. */ get: function () { return this.i.bb; }, set: function (v) { this.i.bb = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "label", { /** * Gets or Sets the property name that contains the label. */ get: function () { return this.i.b4; }, set: function (v) { this.i.b4 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "labelTextColor", { /** * Gets or sets the color to use for the text. */ get: function () { return brushToString(this.i.dx); }, set: function (v) { this.i.dx = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "labelTextStyle", { /** * Gets or sets the font to use for the combobox. */ get: function () { if (this.i.ac == null) { return null; } return this.i.ac.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.ac = fi; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "placeholder", { /** * Gets or Sets the property name that contains the placeholder. */ get: function () { return this.i.cc; }, set: function (v) { this.i.cc = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "minDate", { /** * Gets or Sets the property name that contains the MinDate. */ get: function () { return this.i.ba; }, set: function (v) { this.i.ba = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "maxDate", { /** * Gets or Sets the property name that contains the MaxDate. */ get: function () { return this.i.a9; }, set: function (v) { this.i.a9 = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "density", { /** * Gets or sets the display density to use for the date pcicker. */ get: function () { return this.i.y; }, set: function (v) { this.i.y = ensureEnum(ControlDisplayDensity_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "baseTheme", { /** * Gets or sets the base built in theme to use for the date picker. */ get: function () { return this.i.w; }, set: function (v) { this.i.w = ensureEnum(BaseControlTheme_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "textStyle", { /** * Gets or sets the font to use for the combobox. */ get: function () { if (this.i.ad == null) { return null; } return this.i.ad.fontString; }, set: function (v) { var fi = new FontInfo(); fi.fontString = v; this.i.ad = fi; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "textColor", { /** * Gets or Sets the text color */ get: function () { return brushToString(this.i.dy); }, set: function (v) { this.i.dy = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "iconColor", { /** * Gets or Sets the text color */ get: function () { return brushToString(this.i.dw); }, set: function (v) { this.i.dw = stringToBrush(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "showClearButton", { /** * Gets or sets the ShowClearButton property to detirmine if the clear button is shown */ get: function () { return this.i.a0; }, set: function (v) { this.i.a0 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "showTodayButton", { /** * Gets or sets the ShowTodayButton property to detirmine if the today button is shown */ get: function () { return this.i.a1; }, set: function (v) { this.i.a1 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "allowTextInput", { /** * Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed */ get: function () { return this.i.au; }, set: function (v) { this.i.au = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "openOnFocus", { /** * Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed */ get: function () { return this.i.ay; }, set: function (v) { this.i.ay = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "firstDayOfWeek", { /** * Gets or sets the FirstDayOfWeek property to detirmine first day of the week */ get: function () { return this.i.j; }, set: function (v) { this.i.j = ensureEnum(DayOfWeek_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "firstWeekOfYear", { /** * Gets or sets the FirstWeekOfYear property to detirmine first week of the year */ get: function () { return this.i.l; }, set: function (v) { this.i.l = ensureEnum(FirstWeek_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "showWeekNumbers", { /** * Gets or sets the ShowWeekNumbers property to detirmine if the week numbers are shown */ get: function () { return this.i.a2; }, set: function (v) { this.i.a2 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "dateFormat", { /** * Gets or sets the date time format to use for this column. If FormatString is specificied this value is ignored. */ get: function () { return this.i.e; }, set: function (v) { this.i.e = ensureEnum(DateFormats_$type, v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "formatString", { /** * Gets or sets the Format property to detirmine the format of the date in the input */ get: function () { return this.i.bz; }, set: function (v) { this.i.bz = v; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "isDisabled", { get: function () { return this.i.av; }, set: function (v) { this.i.av = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "isFixed", { /** * Indicates that the calendar dropdown will position itself relative to the window instead of the document. */ get: function () { return this.i.aw; }, set: function (v) { this.i.aw = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "openAsChild", { /** * Indicates that the dropdown should open as a child of the date picker. */ get: function () { return this.i.ax; }, set: function (v) { this.i.ax = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "useTopLayer", { /** * Indicates that the dropdown will place itself into the browser top layer. */ get: function () { return this.i.a3; }, set: function (v) { this.i.a3 = ensureBool(v); }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "hasUserValues", { get: function () { return this._hasUserValues; }, enumerable: false, configurable: true }); IgxXDatePickerComponent.prototype.__m = function (propertyName) { if (!this._inStyling) { this._hasUserValues.add(propertyName); } }; IgxXDatePickerComponent.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("XDatePickerComponent"); 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; }; IgxXDatePickerComponent.prototype.select = function () { this.i.dg(); }; /** * Exports visual information about the current state of the grid. */ IgxXDatePickerComponent.prototype.exportVisualModel = function () { var iv = this.i.bg(); return (iv); }; /** * Returns a serialized copy of the exported visual model */ IgxXDatePickerComponent.prototype.exportSerializedVisualModel = function () { var iv = this.i.bw(); return (iv); }; Object.defineProperty(IgxXDatePickerComponent.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(IgxXDatePickerComponent.prototype, "gotFocus", { get: function () { var _this = this; if (this._gotFocus == null) { this._gotFocus = new EventEmitter(); this.i.gotFocus = delegateCombine(this.i.gotFocus, function (o, e) { _this._runInZone(function () { var outerArgs = new IgxGotFocusEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeGotFocus) { _this.beforeGotFocus(_this, outerArgs); } _this._gotFocus.emit({ sender: _this, args: outerArgs }); }); }); } return this._gotFocus; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.prototype, "lostFocus", { get: function () { var _this = this; if (this._lostFocus == null) { this._lostFocus = new EventEmitter(); this.i.lostFocus = delegateCombine(this.i.lostFocus, function (o, e) { _this._runInZone(function () { var outerArgs = new IgxLostFocusEventArgs(); outerArgs._provideImplementation(e); if (_this.beforeLostFocus) { _this.beforeLostFocus(_this, outerArgs); } _this._lostFocus.emit({ sender: _this, args: outerArgs }); }); }); } return this._lostFocus; }, enumerable: false, configurable: true }); Object.defineProperty(IgxXDatePickerComponent.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(IgxXDatePickerComponent.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(IgxXDatePickerComponent.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 }); IgxXDatePickerComponent.prototype._runInZone = function (act) { if (this._zoneRunner != null) { this._zoneRunner(act); } else { act(); } }; IgxXDatePickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXDatePickerComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component }); IgxXDatePickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: IgxXDatePickerComponent, selector: "igx-x-date-picker", inputs: { height: "height", width: "width", value: "value", today: "today", label: "label", labelTextColor: "labelTextColor", labelTextStyle: "labelTextStyle", placeholder: "placeholder", minDate: "minDate", maxDate: "maxDate", density: "density", baseTheme: "baseTheme", textStyle: "textStyle", textColor: "textColor", iconColor: "iconColor", showClearButton: "showClearButton", showTodayButton: "showTodayButton", allowTextInput: "allowTextInput", openOnFocus: "openOnFocus", firstDayOfWeek: "firstDayOfWeek", firstWeekOfYear: "firstWeekOfYear", showWeekNumbers: "showWeekNumbers", dateFormat: "dateFormat", formatString: "formatString", isDisabled: "isDisabled", isFixed: "isFixed", openAsChild: "openAsChild", useTopLayer: "useTopLayer" }, outputs: { selectedValueChanged: "selectedValueChanged", gotFocus: "gotFocus", lostFocus: "lostFocus", keyDown: "keyDown", changing: "changing", valueChange: "valueChange" }, host: { classAttribute: "ig-x-date-picker igx-x-date-picker" }, providers: [], viewQueries: [{ propertyName: "_datePickerContainer", first: true, predicate: ["datePickerContainer"], descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div #datePickerContainer>\n <div #inputcontainer>\n </div>\n <div #popupContainer>\n </div>\n </div>", isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); return IgxXDatePickerComponent; }()); export { IgxXDatePickerComponent }; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: IgxXDatePickerComponent, decorators: [{ type: Component, args: [{ selector: 'igx-x-date-picker', template: "<div #datePickerContainer>\n <div #inputcontainer>\n </div>\n <div #popupContainer>\n </div>\n </div>", changeDetection: ChangeDetectionStrategy.OnPush, providers: [], host: { 'class': 'ig-x-date-picker igx-x-date-picker' }, 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: { _datePickerContainer: [{ type: ViewChild, args: ["datePickerContainer", { read: ElementRef, static: true }] }], height: [{ type: Input }], width: [{ type: Input }], value: [{ type: Input }], today: [{ type: Input }], label: [{ type: Input }], labelTextColor: [{ type: Input }], labelTextStyle: [{ type: Input }], placeholder: [{ type: Input }], minDate: [{ type: Input }], maxDate: [{ type: Input }], density: [{ type: Input }], baseTheme: [{ type: Input }], textStyle: [{ type: Input }], textColor: [{ type: Input }], iconColor: [{ type: Input }], showClearButton: [{ type: Input }], showTodayButton: [{ type: Input }], allowTextInput: [{ type: Input }], openOnFocus: [{ type: Input }], firstDayOfWeek: [{ type: Input }], firstWeekOfYear: [{ type: Input }], showWeekNumbers: [{ type: Input }], dateFormat: [{ type: Input }], formatString: [{ type: Input }], isDisabled: [{ type: Input }], isFixed: [{ type: Input }], openAsChild: [{ type: Input }], useTopLayer: [{ type: Input }], selectedValueChanged: [{ type: Output }], gotFocus: [{ type: Output }], lostFocus: [{ type: Output }], keyDown: [{ type: Output }], changing: [{ type: Output }], valueChange: [{ type: Output }] } });