@@ -50,7 +50,9 @@ import { IgxDateTimeEditorEventArgs, DatePartInfo, DatePart } from './date-time-
50
50
} )
51
51
export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnChanges , Validator , ControlValueAccessor {
52
52
/**
53
- * An @Input property that allows you to set the locale settings used in `displayFormat`.
53
+ * Set the locale settings used in `displayFormat`.
54
+ *
55
+ * Uses Angular's `LOCALE_ID` for the default value.
54
56
* @example
55
57
* ```html
56
58
* <input igxDateTimeEditor [locale]="'en'">
@@ -60,7 +62,11 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
60
62
public locale : string ;
61
63
62
64
/**
63
- * An @Input property that allows you to set the minimum possible value the editor will allow.
65
+ * Set the minimum possible value the editor will allow.
66
+ *
67
+ * If a `string` value is passed in, it must be in the defined input format; if no input format is defined
68
+ * then the value's format must match the format based on the current locale.
69
+ *
64
70
* @example
65
71
* ```html
66
72
* <input igxDateTimeEditor [minValue]="minDate">
@@ -77,7 +83,10 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
77
83
}
78
84
79
85
/**
80
- * An @Input property that allows you to set the maximum possible value the editor will allow.
86
+ * Set the maximum possible value the editor will allow.
87
+ *
88
+ * If a `string` value is passed in, it must be in the defined input format; if no input format is defined
89
+ * then the value's format must match the format based on the current locale.
81
90
* @example
82
91
* ```html
83
92
* <input igxDateTimeEditor [maxValue]="maxDate">
@@ -94,7 +103,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
94
103
}
95
104
96
105
/**
97
- * An @Input property that allows you to specify if the currently spun date segment should loop over.
106
+ * Specify if the currently spun date segment should loop over.
98
107
* @example
99
108
* ```html
100
109
* <input igxDateTimeEditor [isSpinLoop]="false">
@@ -104,7 +113,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
104
113
public isSpinLoop = true ;
105
114
106
115
/**
107
- * An @Input property that allows you to set both pre-defined format options such as `shortDate` and `longDate`,
116
+ * Set both pre-defined format options such as `shortDate` and `longDate`,
108
117
* as well as constructed format string using characters supported by `DatePipe`, e.g. `EE/MM/yyyy`.
109
118
* @example
110
119
* ```html
@@ -115,8 +124,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
115
124
public displayFormat : string ;
116
125
117
126
/**
118
- * An @Input property that allows you to get/set the expected user input format(and placeholder).
119
- * for the editor.
127
+ * get/set the expected user input format (and placeholder).
120
128
* @example
121
129
* ```html
122
130
* <input [igxDateTimeEditor]="'dd/MM/yyyy'">
@@ -136,7 +144,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
136
144
}
137
145
138
146
/**
139
- * An @Input property that gets/sets the component date value.
147
+ * get/set the editor's value.
140
148
* @example
141
149
* ```html
142
150
* <input igxDateTimeEditor [value]="date">
@@ -163,7 +171,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
163
171
public valueChange = new EventEmitter < IgxDateTimeEditorEventArgs > ( ) ;
164
172
165
173
/**
166
- * Emitted when the editor is not within a specified range.
174
+ * Emitted when the editor is not within a specified range or when the editor's value is in an invalid state .
167
175
* @example
168
176
* ```html
169
177
* <input igxDateTimeEditor [minValue]="minDate" [maxValue]="maxDate" (validationFailed)="onValidationFailed($event)"/>
@@ -174,7 +182,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
174
182
175
183
private _value : Date ;
176
184
private _format : string ;
177
- private _document : Document ;
185
+ private document : Document ;
178
186
private _isFocused : boolean ;
179
187
private _minValue : string | Date ;
180
188
private _maxValue : string | Date ;
@@ -189,7 +197,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
189
197
}
190
198
191
199
private get targetDatePart ( ) : DatePart {
192
- if ( this . _document . activeElement === this . nativeElement ) {
200
+ if ( this . document . activeElement === this . nativeElement ) {
193
201
return this . _inputDateParts
194
202
. find ( p => p . start <= this . selectionStart && this . selectionStart <= p . end && p . type !== DatePart . Literal ) ?. type ;
195
203
} else {
@@ -205,20 +213,21 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
205
213
protected renderer : Renderer2 ,
206
214
protected elementRef : ElementRef ,
207
215
protected maskParser : MaskParsingService ,
208
- @Inject ( DOCUMENT ) private document : any ,
209
- @Inject ( LOCALE_ID ) private _locale ) {
216
+ @Inject ( DOCUMENT ) private _document : any ,
217
+ @Inject ( LOCALE_ID ) private _locale : any ) {
210
218
super ( elementRef , maskParser , renderer ) ;
211
- this . _document = this . document as Document ;
219
+ this . document = this . _document as Document ;
212
220
this . locale = this . locale || this . _locale ;
213
221
}
214
222
215
223
/** @hidden @internal */
216
224
public ngOnChanges ( changes : SimpleChanges ) {
217
225
if ( changes [ 'inputFormat' ] || changes [ 'locale' ] ) {
226
+ const defPlaceholder = this . inputFormat || DatePickerUtil . getDefaultInputFormat ( this . locale ) ;
218
227
this . _inputDateParts = DatePickerUtil . parseDateTimeFormat ( this . inputFormat ) ;
219
228
this . inputFormat = this . _inputDateParts . map ( p => p . format ) . join ( '' ) ;
220
229
if ( ! this . nativeElement . placeholder ) {
221
- this . renderer . setAttribute ( this . nativeElement , 'placeholder' , this . inputFormat ) ;
230
+ this . renderer . setAttribute ( this . nativeElement , 'placeholder' , defPlaceholder ) ;
222
231
}
223
232
this . updateMask ( ) ;
224
233
}
@@ -536,7 +545,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
536
545
* @param direction 0 is left, 1 is right. Default is 0.
537
546
*/
538
547
private getNewPosition ( value : string , direction = 0 ) : number {
539
- const literals = this . _inputDateParts . filter ( l => l . type === DatePart . Literal ) ;
548
+ const literals = this . _inputDateParts . filter ( p => p . type === DatePart . Literal ) ;
540
549
let cursorPos = this . selectionStart ;
541
550
if ( ! direction ) {
542
551
do {
0 commit comments