@@ -36,12 +36,13 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit,
3636 private sub : Subscription ;
3737 private onChange : ( value : Date ) => void ;
3838 private onTouch : ( ) => void ;
39- private _format : string ;
39+ private _format = 'HH:mm:ss' ;
4040 private _disabledHours : ( ) => number [ ] ;
4141 private _disabledMinutes : ( hour : number ) => number [ ] ;
4242 private _disabledSeconds : ( hour : number , minute : number ) => number [ ] ;
4343 private _defaultOpenValue = new Date ( ) ;
4444 private _opened = false ;
45+ private _allowEmpty = true ;
4546 time = new TimeHolder ( ) ;
4647 hourEnabled = true ;
4748 minuteEnabled = true ;
@@ -58,9 +59,19 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit,
5859 @Input ( ) nzHideDisabledOptions = false ;
5960 @Input ( ) nzClearText : string ;
6061 @Input ( ) nzPlaceHolder : string ;
61- @Input ( ) nzAllowEmpty = true ;
6262 @Output ( ) timeClear = new EventEmitter < void > ( ) ;
6363
64+ @Input ( )
65+ set nzAllowEmpty ( value : boolean ) {
66+ if ( isNotNil ( value ) ) {
67+ this . _allowEmpty = value ;
68+ }
69+ }
70+
71+ get nzAllowEmpty ( ) : boolean {
72+ return this . _allowEmpty ;
73+ }
74+
6475 @Input ( )
6576 set opened ( value : boolean ) {
6677 this . _opened = value ;
@@ -98,8 +109,8 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit,
98109
99110 @Input ( )
100111 set nzDisabledMinutes ( value : ( hour : number ) => number [ ] ) {
101- this . _disabledMinutes = value ;
102- if ( this . _disabledMinutes ) {
112+ if ( isNotNil ( value ) ) {
113+ this . _disabledMinutes = value ;
103114 this . buildMinutes ( ) ;
104115 }
105116 }
@@ -110,8 +121,8 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit,
110121
111122 @Input ( )
112123 set nzDisabledSeconds ( value : ( hour : number , minute : number ) => number [ ] ) {
113- this . _disabledSeconds = value ;
114- if ( this . _disabledSeconds ) {
124+ if ( isNotNil ( value ) ) {
125+ this . _disabledSeconds = value ;
115126 this . buildSeconds ( ) ;
116127 }
117128 }
@@ -122,28 +133,21 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit,
122133
123134 @Input ( )
124135 set format ( value : string ) {
125- if ( value !== this . _format ) {
136+ if ( isNotNil ( value ) ) {
126137 this . _format = value ;
127- if ( isNotNil ( value ) ) {
128- this . enabledColumns = 0 ;
129- const charSet = new Set ( value ) ;
130- this . hourEnabled = charSet . has ( 'H' ) || charSet . has ( 'h' ) ;
131- this . minuteEnabled = charSet . has ( 'm' ) ;
132- this . secondEnabled = charSet . has ( 's' ) ;
133- if ( this . hourEnabled ) {
134- this . enabledColumns ++ ;
135- }
136- if ( this . minuteEnabled ) {
137- this . enabledColumns ++ ;
138- }
139- if ( this . secondEnabled ) {
140- this . enabledColumns ++ ;
141- }
142- } else {
143- this . hourEnabled = true ;
144- this . minuteEnabled = true ;
145- this . secondEnabled = true ;
146- this . enabledColumns = 3 ;
138+ this . enabledColumns = 0 ;
139+ const charSet = new Set ( value ) ;
140+ this . hourEnabled = charSet . has ( 'H' ) || charSet . has ( 'h' ) ;
141+ this . minuteEnabled = charSet . has ( 'm' ) ;
142+ this . secondEnabled = charSet . has ( 's' ) ;
143+ if ( this . hourEnabled ) {
144+ this . enabledColumns ++ ;
145+ }
146+ if ( this . minuteEnabled ) {
147+ this . enabledColumns ++ ;
148+ }
149+ if ( this . secondEnabled ) {
150+ this . enabledColumns ++ ;
147151 }
148152 }
149153 }
@@ -154,7 +158,7 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit,
154158
155159 @Input ( )
156160 set nzHourStep ( value : number ) {
157- if ( this . _nzHourStep !== value ) {
161+ if ( isNotNil ( value ) ) {
158162 this . _nzHourStep = value ;
159163 this . buildHours ( ) ;
160164 }
@@ -166,7 +170,7 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit,
166170
167171 @Input ( )
168172 set nzMinuteStep ( value : number ) {
169- if ( this . _nzMinuteStep !== value ) {
173+ if ( isNotNil ( value ) ) {
170174 this . _nzMinuteStep = value ;
171175 this . buildMinutes ( ) ;
172176 }
@@ -178,7 +182,7 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit,
178182
179183 @Input ( )
180184 set nzSecondStep ( value : number ) {
181- if ( this . _nzSecondStep !== value ) {
185+ if ( isNotNil ( value ) ) {
182186 this . _nzSecondStep = value ;
183187 this . buildSeconds ( ) ;
184188 }
0 commit comments