@@ -130,7 +130,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
130
130
*
131
131
*/
132
132
@Input ( )
133
- public displayFormat : string ;
133
+ public displayFormat : string
134
134
135
135
/**
136
136
* The expected user input format and placeholder.
@@ -140,7 +140,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
140
140
*
141
141
* @example
142
142
* ```html
143
- * <igx-time-picker inputFormat="HH:mm tt "></igx-time-picker>
143
+ * <igx-time-picker inputFormat="HH:mm"></igx-time-picker>
144
144
* ```
145
145
*/
146
146
@Input ( )
@@ -246,38 +246,25 @@ export class IgxTimePickerComponent extends PickerBaseDirective
246
246
public selected = new EventEmitter < Date > ( ) ;
247
247
248
248
/**
249
- * Emitted when selection is made. The event contains the selected value. Returns {`oldValue`: `Date | string`, `newValue`: `Date |string`}.
250
- * ```typescript
251
- * @ViewChild ("toast")
252
- * private toast: IgxToastComponent;
253
- * public valueChange(timepicker){
254
- * this.toast.open()
255
- * }
256
- * //...
257
- * ```
258
- * ```html
259
- * <igx-time-picker (valueChange)="valueChange($event)"></igx-time-picker>
260
- * <igx-toast #toast message="The value has been changed!"></igx-toast>
249
+ * Emitted when the picker's value changes.
250
+ *
251
+ * @remarks
252
+ * Used for `two-way` bindings.
253
+ *
254
+ * @example
255
+ * ```html
256
+ * <igx-time-picker [(value)]="date"></igx-time-picker>
261
257
* ```
262
258
*/
263
259
@Output ( )
264
260
public valueChange = new EventEmitter < Date > ( ) ;
265
261
266
262
/**
267
- * It emits when the picker's value goes outside of a given min/max range. Returns {`timePicker`: `any`, `currentValue`: `Date | string`, `setThroughUI`: `boolean`}
268
- * ```typescript
269
- * public min: string = "09:00";
270
- * public max: string = "18:00";
271
- * @ViewChild ("toast")
272
- * private toast: IgxToastComponent;
273
- * public validationFailed(timepicker){
274
- * this.toast.open();
275
- * }
276
- * //...
277
- * ```
278
- * ```html
279
- * <igx-time-picker [minValue]="min" [maxValue]="max" (validationFailed)="validationFailed($event)"></igx-time-picker>
280
- * <igx-toast #toast message="Value must be between 09:00 and 18:00!"></igx-toast>
263
+ * Emitted when the user types/spins invalid time in the time-picker editor.
264
+ *
265
+ * @example
266
+ * ```html
267
+ * <igx-time-picker (validationFailed)="onValidationFailed($event)"></igx-time-picker>
281
268
* ```
282
269
*/
283
270
@Output ( )
@@ -467,6 +454,8 @@ export class IgxTimePickerComponent extends PickerBaseDirective
467
454
private _oldValue : Date | string ;
468
455
private _minDropdownValue : Date ;
469
456
private _maxDropdownValue : Date ;
457
+ private _inputFormat : string ;
458
+ private _displayFormat : string ;
470
459
private _resourceStrings = CurrentResourceStrings . TimePickerResStrings ;
471
460
private _okButtonLabel = null ;
472
461
private _cancelButtonLabel = null ;
@@ -702,6 +691,9 @@ export class IgxTimePickerComponent extends PickerBaseDirective
702
691
this . dateTimeEditor . displayFormat = this . displayFormat ;
703
692
}
704
693
if ( changes [ 'inputFormat' ] && this . dateTimeEditor ) {
694
+ if ( this . validateFormat ( this . inputFormat ) ) {
695
+ this . inputFormat = DateTimeUtil . DEFAULT_TIME_INPUT_FORMAT ;
696
+ }
705
697
this . dateTimeEditor . inputFormat = this . inputFormat ;
706
698
}
707
699
}
@@ -766,13 +758,13 @@ export class IgxTimePickerComponent extends PickerBaseDirective
766
758
}
767
759
}
768
760
769
- /**
770
- * Clears the time picker value if it is a `string` or resets the time to `00:00:00` if the value is a Date object.
771
- * @example
772
- * ```typescript
773
- * this.timePicker.clear();
774
- * ```
775
- */
761
+ /**
762
+ * Clears the time picker value if it is a `string` or resets the time to `00:00:00` if the value is a Date object.
763
+ * @example
764
+ * ```typescript
765
+ * this.timePicker.clear();
766
+ * ```
767
+ */
776
768
public clear ( ) : void {
777
769
if ( this . disabled ) {
778
770
return ;
@@ -1013,7 +1005,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1013
1005
this . value = this . _selectedDate ;
1014
1006
}
1015
1007
}
1016
-
1008
+
1017
1009
/** @hidden @internal */
1018
1010
public hoursInView ( ) : string [ ] {
1019
1011
return this . _hourView . filter ( ( hour ) => hour !== '' ) ;
@@ -1415,6 +1407,13 @@ export class IgxTimePickerComponent extends PickerBaseDirective
1415
1407
return hour ;
1416
1408
}
1417
1409
1410
+ private validateFormat ( format : string ) : boolean {
1411
+ return ( format . indexOf ( 'd' ) < 0 && format . indexOf ( 'M' ) < 0 &&
1412
+ format . indexOf ( 'Y' ) < 0 && format . indexOf ( 'y' ) < 0 &&
1413
+ format . indexOf ( 'L' ) < 0 && format . indexOf ( 'E' ) < 0 &&
1414
+ format . indexOf ( 'W' ) < 0 && format . indexOf ( 'w' ) < 0 ) ;
1415
+ }
1416
+
1418
1417
private attachOnKeydown ( ) : void {
1419
1418
fromEvent ( this . getEditElement ( ) , 'keydown' )
1420
1419
. pipe ( takeUntil ( this . _destroy$ ) )
0 commit comments