Skip to content

Commit 4500d8d

Browse files
chore(date-time-editor): update comments on public members
refactor: set default placeholder
1 parent 3c75b5d commit 4500d8d

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.directive.ts

+25-16
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ import { IgxDateTimeEditorEventArgs, DatePartInfo, DatePart } from './date-time-
5050
})
5151
export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnChanges, Validator, ControlValueAccessor {
5252
/**
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.
5456
* @example
5557
* ```html
5658
* <input igxDateTimeEditor [locale]="'en'">
@@ -60,7 +62,11 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
6062
public locale: string;
6163

6264
/**
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+
*
6470
* @example
6571
* ```html
6672
* <input igxDateTimeEditor [minValue]="minDate">
@@ -77,7 +83,10 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
7783
}
7884

7985
/**
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.
8190
* @example
8291
* ```html
8392
* <input igxDateTimeEditor [maxValue]="maxDate">
@@ -94,7 +103,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
94103
}
95104

96105
/**
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.
98107
* @example
99108
* ```html
100109
* <input igxDateTimeEditor [isSpinLoop]="false">
@@ -104,7 +113,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
104113
public isSpinLoop = true;
105114

106115
/**
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`,
108117
* as well as constructed format string using characters supported by `DatePipe`, e.g. `EE/MM/yyyy`.
109118
* @example
110119
* ```html
@@ -115,8 +124,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
115124
public displayFormat: string;
116125

117126
/**
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).
120128
* @example
121129
* ```html
122130
* <input [igxDateTimeEditor]="'dd/MM/yyyy'">
@@ -136,7 +144,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
136144
}
137145

138146
/**
139-
* An @Input property that gets/sets the component date value.
147+
* get/set the editor's value.
140148
* @example
141149
* ```html
142150
* <input igxDateTimeEditor [value]="date">
@@ -163,7 +171,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
163171
public valueChange = new EventEmitter<IgxDateTimeEditorEventArgs>();
164172

165173
/**
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.
167175
* @example
168176
* ```html
169177
* <input igxDateTimeEditor [minValue]="minDate" [maxValue]="maxDate" (validationFailed)="onValidationFailed($event)"/>
@@ -174,7 +182,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
174182

175183
private _value: Date;
176184
private _format: string;
177-
private _document: Document;
185+
private document: Document;
178186
private _isFocused: boolean;
179187
private _minValue: string | Date;
180188
private _maxValue: string | Date;
@@ -189,7 +197,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
189197
}
190198

191199
private get targetDatePart(): DatePart {
192-
if (this._document.activeElement === this.nativeElement) {
200+
if (this.document.activeElement === this.nativeElement) {
193201
return this._inputDateParts
194202
.find(p => p.start <= this.selectionStart && this.selectionStart <= p.end && p.type !== DatePart.Literal)?.type;
195203
} else {
@@ -205,20 +213,21 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
205213
protected renderer: Renderer2,
206214
protected elementRef: ElementRef,
207215
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) {
210218
super(elementRef, maskParser, renderer);
211-
this._document = this.document as Document;
219+
this.document = this._document as Document;
212220
this.locale = this.locale || this._locale;
213221
}
214222

215223
/** @hidden @internal */
216224
public ngOnChanges(changes: SimpleChanges) {
217225
if (changes['inputFormat'] || changes['locale']) {
226+
const defPlaceholder = this.inputFormat || DatePickerUtil.getDefaultInputFormat(this.locale);
218227
this._inputDateParts = DatePickerUtil.parseDateTimeFormat(this.inputFormat);
219228
this.inputFormat = this._inputDateParts.map(p => p.format).join('');
220229
if (!this.nativeElement.placeholder) {
221-
this.renderer.setAttribute(this.nativeElement, 'placeholder', this.inputFormat);
230+
this.renderer.setAttribute(this.nativeElement, 'placeholder', defPlaceholder);
222231
}
223232
this.updateMask();
224233
}
@@ -536,7 +545,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
536545
* @param direction 0 is left, 1 is right. Default is 0.
537546
*/
538547
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);
540549
let cursorPos = this.selectionStart;
541550
if (!direction) {
542551
do {

0 commit comments

Comments
 (0)