UNPKG

igniteui-angular-inputs

Version:

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

630 lines (627 loc) 23.5 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(); export let IgxXDatePickerComponent = /*@__PURE__*/ (() => { class IgxXDatePickerComponent { 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._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; } set height(value) { this._height = value; this.renderer.setStyle(this._elRef.element.nativeElement, "height", value); this._datePicker.notifySizeChanged(); } get height() { return this._height; } set width(value) { this._width = value; this.renderer.setStyle(this._elRef.element.nativeElement, "width", value); this._datePicker.notifySizeChanged(); } get width() { return this._width; } // supports angular themes or custom properties set in CSS updateStyle() { this._styling(this._root, this); } ngOnDestroy() { this._datePicker.destroy(); this._wrapper.destroy(); } ngAfterViewInit() { 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(() => { this._datePicker.notifySizeChanged(); }); } this._styling(this._root, this); this.i.notifySizeChanged(); this.updateStyle(); } createImplementation() { return new XDatePicker(); } get i() { return this._implementation; } /** * Gets or Sets the property name that contains the values. */ 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.bb; } set today(v) { this.i.bb = v; } /** * Gets or Sets the property name that contains the label. */ get label() { return this.i.b4; } set label(v) { this.i.b4 = v; } /** * Gets or sets the color to use for the text. */ get labelTextColor() { return brushToString(this.i.dx); } set labelTextColor(v) { this.i.dx = stringToBrush(v); } /** * Gets or sets the font to use for the combobox. */ get labelTextStyle() { if (this.i.ac == null) { return null; } return this.i.ac.fontString; } set labelTextStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.ac = fi; } /** * Gets or Sets the property name that contains the placeholder. */ get placeholder() { return this.i.cc; } set placeholder(v) { this.i.cc = v; } /** * Gets or Sets the property name that contains the MinDate. */ get minDate() { return this.i.ba; } set minDate(v) { this.i.ba = v; } /** * Gets or Sets the property name that contains the MaxDate. */ get maxDate() { return this.i.a9; } set maxDate(v) { this.i.a9 = v; } /** * Gets or sets the display density to use for the date pcicker. */ get density() { return this.i.y; } set density(v) { this.i.y = ensureEnum(ControlDisplayDensity_$type, v); } /** * Gets or sets the base built in theme to use for the date picker. */ get baseTheme() { return this.i.w; } set baseTheme(v) { this.i.w = ensureEnum(BaseControlTheme_$type, v); } /** * Gets or sets the font to use for the combobox. */ get textStyle() { if (this.i.ad == null) { return null; } return this.i.ad.fontString; } set textStyle(v) { let fi = new FontInfo(); fi.fontString = v; this.i.ad = fi; } /** * Gets or Sets the text color */ get textColor() { return brushToString(this.i.dy); } set textColor(v) { this.i.dy = stringToBrush(v); } /** * Gets or Sets the text color */ get iconColor() { return brushToString(this.i.dw); } set iconColor(v) { this.i.dw = stringToBrush(v); } /** * Gets or sets the ShowClearButton property to detirmine if the clear button is shown */ get showClearButton() { return this.i.a0; } set showClearButton(v) { this.i.a0 = ensureBool(v); } /** * Gets or sets the ShowTodayButton property to detirmine if the today button is shown */ get showTodayButton() { return this.i.a1; } set showTodayButton(v) { this.i.a1 = ensureBool(v); } /** * Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed */ get allowTextInput() { return this.i.au; } set allowTextInput(v) { this.i.au = ensureBool(v); } /** * Gets or sets the AllowTextInput property to detirmine if entering text into the input is allowed */ get openOnFocus() { return this.i.ay; } set openOnFocus(v) { this.i.ay = ensureBool(v); } /** * Gets or sets the FirstDayOfWeek property to detirmine first day of the week */ get firstDayOfWeek() { return this.i.j; } set firstDayOfWeek(v) { this.i.j = ensureEnum(DayOfWeek_$type, v); } /** * Gets or sets the FirstWeekOfYear property to detirmine first week of the year */ get firstWeekOfYear() { return this.i.l; } set firstWeekOfYear(v) { this.i.l = ensureEnum(FirstWeek_$type, v); } /** * Gets or sets the ShowWeekNumbers property to detirmine if the week numbers are shown */ get showWeekNumbers() { return this.i.a2; } set showWeekNumbers(v) { this.i.a2 = ensureBool(v); } /** * Gets or sets the date time format to use for this column. If FormatString is specificied this value is ignored. */ get dateFormat() { return this.i.e; } set dateFormat(v) { this.i.e = ensureEnum(DateFormats_$type, v); } /** * Gets or sets the Format property to detirmine the format of the date in the input */ get formatString() { return this.i.bz; } set formatString(v) { this.i.bz = v; } get isDisabled() { return this.i.av; } set isDisabled(v) { this.i.av = ensureBool(v); } /** * Indicates that the calendar dropdown will position itself relative to the window instead of the document. */ get isFixed() { return this.i.aw; } set isFixed(v) { this.i.aw = ensureBool(v); } /** * Indicates that the dropdown should open as a child of the date picker. */ get openAsChild() { return this.i.ax; } set openAsChild(v) { this.i.ax = ensureBool(v); } /** * Indicates that the dropdown will place itself into the browser top layer. */ get useTopLayer() { return this.i.a3; } set useTopLayer(v) { this.i.a3 = 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("XDatePickerComponent"); 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; } select() { this.i.dg(); } /** * Exports visual information about the current state of the grid. */ exportVisualModel() { let iv = this.i.bg(); return (iv); } /** * Returns a serialized copy of the exported visual model */ exportSerializedVisualModel() { let iv = this.i.bw(); 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 gotFocus() { if (this._gotFocus == null) { this._gotFocus = new EventEmitter(); this.i.gotFocus = delegateCombine(this.i.gotFocus, (o, e) => { this._runInZone(() => { let outerArgs = new IgxGotFocusEventArgs(); outerArgs._provideImplementation(e); if (this.beforeGotFocus) { this.beforeGotFocus(this, outerArgs); } this._gotFocus.emit({ sender: this, args: outerArgs }); }); }); } return this._gotFocus; } get lostFocus() { if (this._lostFocus == null) { this._lostFocus = new EventEmitter(); this.i.lostFocus = delegateCombine(this.i.lostFocus, (o, e) => { this._runInZone(() => { let outerArgs = new IgxLostFocusEventArgs(); outerArgs._provideImplementation(e); if (this.beforeLostFocus) { this.beforeLostFocus(this, outerArgs); } this._lostFocus.emit({ sender: this, args: outerArgs }); }); }); } return this._lostFocus; } get keyDown() { if (this._keyDown == null) { this._keyDown = new EventEmitter(); this.i.keyDown = delegateCombine(this.i.keyDown, (o, e) => { this._runInZone(() => { let outerArgs = new IgxKeyEventArgs(); outerArgs._provideImplementation(e); if (this.beforeKeyDown) { this.beforeKeyDown(this, outerArgs); } this._keyDown.emit({ sender: this, args: outerArgs }); }); }); } return this._keyDown; } get changing() { if (this._changing == null) { this._changing = new EventEmitter(); this.i.changing = delegateCombine(this.i.changing, (o, e) => { this._runInZone(() => { let outerArgs = new IgxInputChangeEventArgs(); outerArgs._provideImplementation(e); if (this.beforeChanging) { this.beforeChanging(this, outerArgs); } this._changing.emit({ sender: this, args: outerArgs }); }); }); } return this._changing; } 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(); } } } 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> <div #inputcontainer> </div> <div #popupContainer> </div> </div>`, isInline: true, styles: ["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); return 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> <div #inputcontainer> </div> <div #popupContainer> </div> </div>`, changeDetection: ChangeDetectionStrategy.OnPush, providers: [], host: { 'class': 'ig-x-date-picker igx-x-date-picker' }, styles: [` :host { display: block; } `] }] }], 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 }] } });