1
1
import { Utils } from './utils' ;
2
2
import { FormSelect } from './select' ;
3
3
import { BaseOptions , Component , I18nOptions , InitElements , MElement } from './component' ;
4
+ import { DockedDisplayPlugin } from './plugin/dockedDisplayPlugin' ;
4
5
5
6
export interface DateI18nOptions extends I18nOptions {
6
7
previousMonth : string ;
@@ -184,6 +185,14 @@ export interface DatepickerOptions extends BaseOptions {
184
185
startRange ?: Date ;
185
186
/** Field used for internal calculations DO NOT CHANGE IT */
186
187
endRange ?: Date ;
188
+ /**
189
+ * Display plugin
190
+ */
191
+ displayPlugin : string ;
192
+ /**
193
+ * Configurable display plugin options
194
+ */
195
+ displayPluginOptions : object ;
187
196
}
188
197
189
198
const _defaults : DatepickerOptions = {
@@ -281,6 +290,8 @@ const _defaults: DatepickerOptions = {
281
290
onSelect : null ,
282
291
onDraw : null ,
283
292
onInputInteraction : null ,
293
+ displayPlugin : null ,
294
+ displayPluginOptions : null ,
284
295
onConfirm : null ,
285
296
onCancel : null ,
286
297
} ;
@@ -310,6 +321,7 @@ export class Datepicker extends Component<DatepickerOptions> {
310
321
calendars : [ { month : number ; year : number } ] ;
311
322
private _y : number ;
312
323
private _m : number ;
324
+ private displayPlugin : DockedDisplayPlugin ;
313
325
private footer : HTMLElement ;
314
326
static _template : string ;
315
327
@@ -368,6 +380,9 @@ export class Datepicker extends Component<DatepickerOptions> {
368
380
this . dateEls = [ ] ;
369
381
this . dateEls . push ( el ) ;
370
382
}
383
+ if ( this . options . displayPlugin ) {
384
+ if ( this . options . displayPlugin === 'docked' ) this . displayPlugin = DockedDisplayPlugin . init ( this . el , this . containerEl , this . options . displayPluginOptions ) ;
385
+ }
371
386
}
372
387
373
388
static get defaults ( ) {
@@ -1191,6 +1206,7 @@ export class Datepicker extends Component<DatepickerOptions> {
1191
1206
this . setDateFromInput ( e . target as HTMLInputElement ) ;
1192
1207
this . draw ( ) ;
1193
1208
this . gotoDate ( < HTMLElement > e . target === this . el ? this . date : this . endDate ) ;
1209
+ if ( this . displayPlugin ) this . displayPlugin . show ( ) ;
1194
1210
if ( this . options . onInputInteraction ) this . options . onInputInteraction . call ( this ) ;
1195
1211
} ;
1196
1212
@@ -1199,6 +1215,7 @@ export class Datepicker extends Component<DatepickerOptions> {
1199
1215
e . preventDefault ( ) ;
1200
1216
this . setDateFromInput ( e . target as HTMLInputElement ) ;
1201
1217
this . draw ( ) ;
1218
+ if ( this . displayPlugin ) this . displayPlugin . show ( ) ;
1202
1219
if ( this . options . onInputInteraction ) this . options . onInputInteraction . call ( this ) ;
1203
1220
}
1204
1221
} ;
0 commit comments