11import {
22 Component , View , Host ,
33 EventEmitter ,
4- ControlValueAccessor ,
54 ElementRef , ViewContainerRef ,
6- NgIf , NgClass , FORM_DIRECTIVES , CORE_DIRECTIVES ,
7- Self , NgModel , Renderer ,
8- QueryList , Query
5+ Self , Renderer ,
6+ QueryList , Query ,
7+ Input
98} from 'angular2/core' ;
9+ import { CORE_DIRECTIVES , FORM_DIRECTIVES ,
10+ ControlValueAccessor , NgIf , NgClass , NgModel
11+ } from 'angular2/common' ;
1012
1113import * as moment from 'moment' ;
1214
@@ -18,79 +20,66 @@ import {YearPicker} from './yearpicker';
1820
1921@Component ( {
2022 selector : 'datepicker[ngModel], [datepicker][ng-model]' ,
21- properties : [
22- 'datepickerMode' ,
23- 'minDate' , 'maxDate' ,
24- 'dateDisabled' , 'activeDate' ,
25- 'showWeeks' , 'startingDay' ,
26- 'initDate' ,
27- 'minMode' , 'maxMode' ,
28- 'formatDay' , 'formatMonth' , 'formatYear' ,
29- 'formatDayHeader' , 'formatDayTitle' , 'formatMonthTitle' ,
30- 'yearRange' ,
31- 'shortcutPropagation'
32- ]
33- } )
34- @View ( {
3523 template : `
36- <datepicker-inner [active-date ]="activeDate"
24+ <datepicker-inner [activeDate ]="activeDate"
3725 (update)="onUpdate($event)"
38- [datepicker-mode ]="datepickerMode"
39- [init-date ]="initDate"
40- [min-date ]="minDate"
41- [max-date ]="maxDate"
42- [min-mode ]="minMode"
43- [max-mode ]="maxMode"
44- [show-weeks ]="showWeeks"
45- [format-day ]="formatDay"
46- [format-month ]="formatMonth"
47- [format-year ]="formatYear"
48- [format-day-header ]="formatDayHeader"
49- [format-day-title ]="formatDayTitle"
50- [format-month-title ]="formatMonthTitle"
51- [starting-day ]="startingDay"
52- [year-range ]="yearRange"
53- [custom-class ]="customClass"
54- [date-disabled ]="dateDisabled"
55- [template-url ]="templateUrl"
56- [shortcut-propagation ]="shortcutPropagation">
26+ [datepickerMode ]="datepickerMode"
27+ [initDate ]="initDate"
28+ [minDate ]="minDate"
29+ [maxDate ]="maxDate"
30+ [minMode ]="minMode"
31+ [maxMode ]="maxMode"
32+ [showWeeks ]="showWeeks"
33+ [formatDay ]="formatDay"
34+ [formatMonth ]="formatMonth"
35+ [formatYear ]="formatYear"
36+ [formatDayHeader ]="formatDayHeader"
37+ [formatDayTitle ]="formatDayTitle"
38+ [formatMonthTitle ]="formatMonthTitle"
39+ [startingDay ]="startingDay"
40+ [yearRange ]="yearRange"
41+ [customClass ]="customClass"
42+ [dateDisabled ]="dateDisabled"
43+ [templateUrl ]="templateUrl"
44+ [shortcutPropagation ]="shortcutPropagation">
5745 <daypicker tabindex="0"></daypicker>
5846 <monthpicker tabindex="0"></monthpicker>
5947 <yearpicker tabindex="0"></yearpicker>
6048 </datepicker-inner>
6149 ` ,
6250 directives : [ DatePickerInner , DayPicker , MonthPicker , YearPicker , FORM_DIRECTIVES , CORE_DIRECTIVES ]
6351} )
52+
6453export class DatePicker implements ControlValueAccessor {
6554 private _activeDate :Date ;
66- private datepickerMode :string ;
67- private initDate :Date ;
68- private minDate :Date ;
69- private maxDate :Date ;
70- private minMode :string ;
71- private maxMode :string ;
72- private showWeeks :boolean ;
73- private formatDay :string ;
74- private formatMonth :string ;
75- private formatYear :string ;
76- private formatDayHeader :string ;
77- private formatDayTitle :string ;
78- private formatMonthTitle :string ;
79- private startingDay :number ;
80- private yearRange :number ;
81- private shortcutPropagation :boolean ;
55+ @ Input ( ) private datepickerMode :string ;
56+ @ Input ( ) private initDate :Date ;
57+ @ Input ( ) private minDate :Date ;
58+ @ Input ( ) private maxDate :Date ;
59+ @ Input ( ) private minMode :string ;
60+ @ Input ( ) private maxMode :string ;
61+ @ Input ( ) private showWeeks :boolean ;
62+ @ Input ( ) private formatDay :string ;
63+ @ Input ( ) private formatMonth :string ;
64+ @ Input ( ) private formatYear :string ;
65+ @ Input ( ) private formatDayHeader :string ;
66+ @ Input ( ) private formatDayTitle :string ;
67+ @ Input ( ) private formatMonthTitle :string ;
68+ @ Input ( ) private startingDay :number ;
69+ @ Input ( ) private yearRange :number ;
70+ @ Input ( ) private shortcutPropagation :boolean ;
8271 // todo: change type during implementation
8372 private customClass :any ;
8473 // todo: change type during implementation
85- private dateDisabled :any ;
74+ @ Input ( ) private dateDisabled :any ;
8675 private templateUrl :string ;
8776
8877 constructor ( @Self ( ) public cd :NgModel ) {
8978 // hack
9079 cd . valueAccessor = this ;
9180 }
9281
93- public get activeDate ( ) :Date {
82+ @ Input ( ) public get activeDate ( ) :Date {
9483 return this . _activeDate ;
9584 }
9685
@@ -99,7 +88,7 @@ export class DatePicker implements ControlValueAccessor {
9988 this . cd . viewToModelUpdate ( moment ( this . activeDate ) . toDate ( ) ) ;
10089 }
10190
102- private onUpdate ( event ) {
91+ private onUpdate ( event : any ) {
10392 this . writeValue ( event ) ;
10493 }
10594
@@ -124,7 +113,7 @@ export class DatePicker implements ControlValueAccessor {
124113
125114 }
126115
127- onChange = ( _ ) => { } ;
116+ onChange = ( _ : any ) => { } ;
128117 onTouched = ( ) => { } ;
129118
130119 registerOnChange ( fn :( _ :any ) => { } ) :void {
0 commit comments