@@ -12,6 +12,34 @@ import {
12
12
} from '../../date-picker/date-picker.utils' ;
13
13
import { IgxDateTimeEditorEventArgs , DatePartInfo , DatePart } from './date-time-editor.common' ;
14
14
15
+ /**
16
+ * Date Time Editor provides a functionality to input, edit and format date and time.
17
+ *
18
+ * @igxModule IgxDateTimeEditorModule
19
+ *
20
+ * @igxParent IgxInputGroup
21
+ *
22
+ * @igxTheme igx-input-theme
23
+ *
24
+ * @igxKeywords date, time, editor
25
+ *
26
+ * @igxGroup Scheduling
27
+ *
28
+ * @remarks
29
+ *
30
+ * The Ignite UI Date Time Editor Directive makes it easy for developers to manipulate date/time user input.
31
+ * It requires input in a specified or default input format which is visible in the input element as a placeholder.
32
+ * It allows to input only date(ex: 'dd/MM/yyyy'), only time(ex:'HH:mm tt') or both at once, if needed.
33
+ * Supports display format that may differ from the input format.
34
+ * Provides methods to increment and decrement any specific/targeted `DatePart`.
35
+ *
36
+ * @example
37
+ * ```html
38
+ * <igx-input-group>
39
+ * <input type="text" igxInput [igxDateTimeEditor]="'dd/MM/yyyy'" [displayFormat]="'shortDate'" [(ngModel)]="date"/>
40
+ * </igx-input-group>
41
+ * ```
42
+ */
15
43
@Directive ( {
16
44
selector : '[igxDateTimeEditor]' ,
17
45
exportAs : 'igxDateTimeEditor' ,
@@ -20,25 +48,65 @@ import { IgxDateTimeEditorEventArgs, DatePartInfo, DatePart } from './date-time-
20
48
]
21
49
} )
22
50
export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnInit , ControlValueAccessor {
51
+ /**
52
+ * An @Input property that allows you to set the locale settings used in `displayFormat`.
53
+ * @example
54
+ *```html
55
+ * <input igxDateTimeEditor [locale]="'en'">
56
+ *```
57
+ */
23
58
@Input ( )
24
59
public locale = 'en' ;
25
60
61
+ /**
62
+ * An @Input property that allows you to set the minimum possible value the editor will allow.
63
+ * @example
64
+ *```html
65
+ * <input igxDateTimeEditor [minValue]="minDate">
66
+ *```
67
+ */
26
68
@Input ( )
27
69
public minValue : string | Date ;
28
70
71
+ /**
72
+ * An @Input property that allows you to set the maximum possible value the editor will allow.
73
+ * @example
74
+ *```html
75
+ * <input igxDateTimeEditor [maxValue]="maxDate">
76
+ *```
77
+ */
29
78
@Input ( )
30
79
public maxValue : string | Date ;
31
80
81
+ /**
82
+ * An @Input property that allows you to specify if the currently spun date segment should loop over.
83
+ * @example
84
+ *```html
85
+ * <input igxDateTimeEditor [isSpinLoop]="false">
86
+ *```
87
+ */
32
88
@Input ( )
33
89
public isSpinLoop = true ;
34
90
91
+ /**
92
+ * An @Input property that allows you to set both pre-defined format options such as `shortDate` and `longDate`,
93
+ * as well as constructed format string using characters supported by `DatePipe`, e.g. `EE/MM/yyyy`.
94
+ * @example
95
+ *```html
96
+ * <input igxDateTimeEditor [displayFormat]="'shortDate'">
97
+ *```
98
+ */
35
99
@Input ( )
36
100
public displayFormat : string ;
37
101
38
- public get inputFormat ( ) : string {
39
- return this . _format ;
40
- }
41
-
102
+ /**
103
+ * An @Input property that allows you to get/set the expected user input format(and placeholder).
104
+ * for the editor.
105
+ * @example
106
+ *```html
107
+ * <input [igxDateTimeEditor]="'dd/MM/yyyy'">
108
+ *```
109
+ */
42
110
@Input ( `igxDateTimeEditor` )
43
111
public set inputFormat ( value : string ) {
44
112
if ( value ) {
@@ -48,19 +116,44 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
48
116
this . mask = value . indexOf ( 'tt' ) !== - 1 ? mask . substring ( 0 , mask . length - 2 ) + 'LL' : mask ;
49
117
}
50
118
51
- public get value ( ) {
52
- return this . _value ;
119
+ public get inputFormat ( ) : string {
120
+ return this . _format ;
53
121
}
54
122
123
+ /**
124
+ * An @Input property that gets/sets the component date value.
125
+ * @example
126
+ * ```html
127
+ * <input igxDateTimeEditor [value]="date">
128
+ * ```
129
+ */
55
130
@Input ( )
56
131
public set value ( value : Date ) {
57
132
this . _value = value ;
58
133
this . updateMask ( ) ;
59
134
}
60
135
136
+ public get value ( ) {
137
+ return this . _value ;
138
+ }
139
+
140
+ /**
141
+ * Emitted when the editor's value has changed.
142
+ * @example
143
+ * ```html
144
+ * <input igxDateTimeEditor (valueChanged)="onValueChanged($event)"/>
145
+ * ```
146
+ */
61
147
@Output ( )
62
148
public valueChanged = new EventEmitter < IgxDateTimeEditorEventArgs > ( ) ;
63
149
150
+ /**
151
+ * Emitted when the editor is not within a specified range.
152
+ * @example
153
+ * ```html
154
+ * <input igxDateTimeEditor [minValue]="minDate" [maxValue]="maxDate" (validationFailed)="onValidationFailed($event)"/>
155
+ * ```
156
+ */
64
157
@Output ( )
65
158
public validationFailed = new EventEmitter < IgxDateTimeEditorEventArgs > ( ) ;
66
159
@@ -107,18 +200,25 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
107
200
this . _document = this . document as Document ;
108
201
}
109
202
110
- /** @hidden */
203
+ /** @hidden @internal */
111
204
public ngOnInit ( ) : void {
112
205
this . _dateTimeFormatParts = DatePickerUtil . parseDateTimeFormat ( this . inputFormat ) ;
113
206
this . renderer . setAttribute ( this . nativeElement , 'placeholder' , this . inputFormat ) ;
114
207
this . updateMask ( ) ;
115
208
}
116
209
210
+ /**
211
+ * Clear the input element value.
212
+ */
117
213
public clear ( ) : void {
118
214
this . updateValue ( null ) ;
119
215
this . updateMask ( ) ;
120
216
}
121
217
218
+ /**
219
+ * Increment specified DatePart.
220
+ * @param datePart The optional DatePart to increment. Defaults to Date or Hours(when Date is absent from the inputFormat - ex:'HH:mm').
221
+ */
122
222
public increment ( datePart ?: DatePart ) : void {
123
223
const newValue = datePart
124
224
? this . calculateValueOnSpin ( datePart , 1 )
@@ -127,6 +227,11 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
127
227
this . updateMask ( ) ;
128
228
}
129
229
230
+ /**
231
+ * Decrement specified DatePart.
232
+ *
233
+ * @param datePart The optional DatePart to decrement. Defaults to Date or Hours(when Date is absent from the inputFormat - ex:'HH:mm').
234
+ */
130
235
public decrement ( datePart ?: DatePart ) : void {
131
236
const newValue = datePart
132
237
? this . calculateValueOnSpin ( datePart , - 1 )
@@ -135,21 +240,21 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
135
240
this . updateMask ( ) ;
136
241
}
137
242
138
- /** @hidden */
243
+ /** @hidden @internal */
139
244
public writeValue ( value : any ) : void {
140
245
this . value = value ;
141
246
}
142
247
143
- /** @hidden */
248
+ /** @hidden @internal */
144
249
public registerOnChange ( fn : any ) : void { this . onChangeCallback = fn ; }
145
250
146
- /** @hidden */
251
+ /** @hidden @internal */
147
252
public registerOnTouched ( fn : any ) : void { this . onTouchCallback = fn ; }
148
253
149
- /** @hidden */
254
+ /** @hidden @internal */
150
255
public setDisabledState ?( isDisabled : boolean ) : void { }
151
256
152
- /** @hidden */
257
+ /** @hidden @internal */
153
258
public onKeyDown ( event : KeyboardEvent ) {
154
259
super . onKeyDown ( event ) ;
155
260
if ( event . key === KEYS . UP_ARROW || event . key === KEYS . UP_ARROW_IE ||
@@ -166,15 +271,15 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
166
271
this . moveCursor ( event ) ;
167
272
}
168
273
169
- /** @hidden */
274
+ /** @hidden @internal */
170
275
public onFocus ( ) : void {
171
276
this . _isFocused = true ;
172
277
this . onTouchCallback ( ) ;
173
278
this . updateMask ( ) ;
174
279
super . onFocus ( ) ;
175
280
}
176
281
177
- /** @hidden */
282
+ /** @hidden @internal */
178
283
public onBlur ( event ) : void {
179
284
this . _isFocused = false ;
180
285
@@ -197,7 +302,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnIn
197
302
super . onBlur ( event ) ;
198
303
}
199
304
200
- /** @hidden */
305
+ /** @hidden @internal */
201
306
public updateMask ( ) {
202
307
if ( ! this . value || ! this . isValidDate ( this . value ) ) {
203
308
this . inputValue = this . emptyMask ;
0 commit comments