1 | import { Component, EventEmitter, Input, Output, ViewChild, forwardRef } from '@angular/core';
|
2 | import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
3 | import { DatePickerInnerComponent } from './datepicker-inner.component';
|
4 | import { DatepickerConfig } from './datepicker.config';
|
5 | export var DATEPICKER_CONTROL_VALUE_ACCESSOR = {
|
6 | provide: NG_VALUE_ACCESSOR,
|
7 | useExisting: forwardRef(function () { return DatePickerComponent; }),
|
8 | multi: true
|
9 | };
|
10 |
|
11 |
|
12 | export var DatePickerComponent = (function () {
|
13 | function DatePickerComponent(config) {
|
14 |
|
15 | this.datepickerMode = 'day';
|
16 |
|
17 | this.showWeeks = true;
|
18 | this.selectionDone = new EventEmitter(undefined);
|
19 |
|
20 | this.activeDateChange = new EventEmitter(undefined);
|
21 | this.onChange = Function.prototype;
|
22 | this.onTouched = Function.prototype;
|
23 | this._now = new Date();
|
24 | this.config = config;
|
25 | this.configureOptions();
|
26 | }
|
27 | Object.defineProperty(DatePickerComponent.prototype, "activeDate", {
|
28 |
|
29 | get: function () {
|
30 | return this._activeDate || this._now;
|
31 | },
|
32 | set: function (value) {
|
33 | this._activeDate = value;
|
34 | },
|
35 | enumerable: true,
|
36 | configurable: true
|
37 | });
|
38 | DatePickerComponent.prototype.configureOptions = function () {
|
39 | Object.assign(this, this.config);
|
40 | };
|
41 | DatePickerComponent.prototype.onUpdate = function (event) {
|
42 | this.activeDate = event;
|
43 | this.onChange(event);
|
44 | };
|
45 | DatePickerComponent.prototype.onSelectionDone = function (event) {
|
46 | this.selectionDone.emit(event);
|
47 | };
|
48 | DatePickerComponent.prototype.onActiveDateChange = function (event) {
|
49 | this.activeDateChange.emit(event);
|
50 | };
|
51 |
|
52 | DatePickerComponent.prototype.writeValue = function (value) {
|
53 | if (this._datePicker.compare(value, this._activeDate) === 0) {
|
54 | return;
|
55 | }
|
56 | if (value && value instanceof Date) {
|
57 | this.activeDate = value;
|
58 | this._datePicker.select(value, false);
|
59 | return;
|
60 | }
|
61 | this.activeDate = value ? new Date(value) : void 0;
|
62 | };
|
63 | DatePickerComponent.prototype.registerOnChange = function (fn) {
|
64 | this.onChange = fn;
|
65 | };
|
66 | DatePickerComponent.prototype.registerOnTouched = function (fn) {
|
67 | this.onTouched = fn;
|
68 | };
|
69 | DatePickerComponent.decorators = [
|
70 | { type: Component, args: [{
|
71 | selector: 'datepicker',
|
72 | template: "\n <datepicker-inner [activeDate]=\"activeDate\"\n (update)=\"onUpdate($event)\"\n [datepickerMode]=\"datepickerMode\"\n [initDate]=\"initDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [minMode]=\"minMode\"\n [maxMode]=\"maxMode\"\n [showWeeks]=\"showWeeks\"\n [formatDay]=\"formatDay\"\n [formatMonth]=\"formatMonth\"\n [formatYear]=\"formatYear\"\n [formatDayHeader]=\"formatDayHeader\"\n [formatDayTitle]=\"formatDayTitle\"\n [formatMonthTitle]=\"formatMonthTitle\"\n [startingDay]=\"startingDay\"\n [yearRange]=\"yearRange\"\n [customClass]=\"customClass\"\n [dateDisabled]=\"dateDisabled\"\n [onlyCurrentMonth]=\"onlyCurrentMonth\"\n [shortcutPropagation]=\"shortcutPropagation\"\n [monthColLimit]=\"monthColLimit\"\n [yearColLimit]=\"yearColLimit\"\n (selectionDone)=\"onSelectionDone($event)\"\n (activeDateChange)=\"onActiveDateChange($event)\">\n <daypicker tabindex=\"0\"></daypicker>\n <monthpicker tabindex=\"0\"></monthpicker>\n <yearpicker tabindex=\"0\"></yearpicker>\n </datepicker-inner>\n ",
|
73 | providers: [DATEPICKER_CONTROL_VALUE_ACCESSOR]
|
74 | },] },
|
75 | ];
|
76 |
|
77 | DatePickerComponent.ctorParameters = function () { return [
|
78 | { type: DatepickerConfig, },
|
79 | ]; };
|
80 | DatePickerComponent.propDecorators = {
|
81 | 'datepickerMode': [{ type: Input },],
|
82 | 'initDate': [{ type: Input },],
|
83 | 'minDate': [{ type: Input },],
|
84 | 'maxDate': [{ type: Input },],
|
85 | 'minMode': [{ type: Input },],
|
86 | 'maxMode': [{ type: Input },],
|
87 | 'showWeeks': [{ type: Input },],
|
88 | 'formatDay': [{ type: Input },],
|
89 | 'formatMonth': [{ type: Input },],
|
90 | 'formatYear': [{ type: Input },],
|
91 | 'formatDayHeader': [{ type: Input },],
|
92 | 'formatDayTitle': [{ type: Input },],
|
93 | 'formatMonthTitle': [{ type: Input },],
|
94 | 'startingDay': [{ type: Input },],
|
95 | 'yearRange': [{ type: Input },],
|
96 | 'onlyCurrentMonth': [{ type: Input },],
|
97 | 'shortcutPropagation': [{ type: Input },],
|
98 | 'monthColLimit': [{ type: Input },],
|
99 | 'yearColLimit': [{ type: Input },],
|
100 | 'customClass': [{ type: Input },],
|
101 | 'dateDisabled': [{ type: Input },],
|
102 | 'activeDate': [{ type: Input },],
|
103 | 'selectionDone': [{ type: Output },],
|
104 | 'activeDateChange': [{ type: Output },],
|
105 | '_datePicker': [{ type: ViewChild, args: [DatePickerInnerComponent,] },],
|
106 | };
|
107 | return DatePickerComponent;
|
108 | }());
|
109 |
|
\ | No newline at end of file |