1
- import { Utils } from './utils' ;
2
- import { FormSelect } from './select ' ;
3
- import { BaseOptions , Component , I18nOptions , InitElements , MElement } from './component ' ;
4
- import { DockedDisplayPlugin } from './plugin /dockedDisplayPlugin' ;
1
+ import { Utils } from '../../src /utils' ;
2
+ import { BaseOptions , Component , I18nOptions , InitElements , MElement } from '../../src/component ' ;
3
+ import { FormSelect } from '../text-fields/select ' ;
4
+ import { DockedDisplayPlugin } from '../../src /dockedDisplayPlugin' ;
5
5
6
6
export interface DateI18nOptions extends I18nOptions {
7
7
previousMonth : string ;
@@ -293,7 +293,7 @@ const _defaults: DatepickerOptions = {
293
293
displayPlugin : null ,
294
294
displayPluginOptions : null ,
295
295
onConfirm : null ,
296
- onCancel : null ,
296
+ onCancel : null
297
297
} ;
298
298
299
299
export class Datepicker extends Component < DatepickerOptions > {
@@ -381,7 +381,12 @@ export class Datepicker extends Component<DatepickerOptions> {
381
381
this . dateEls . push ( el ) ;
382
382
}
383
383
if ( this . options . displayPlugin ) {
384
- if ( this . options . displayPlugin === 'docked' ) this . displayPlugin = DockedDisplayPlugin . init ( this . el , this . containerEl , this . options . displayPluginOptions ) ;
384
+ if ( this . options . displayPlugin === 'docked' )
385
+ this . displayPlugin = DockedDisplayPlugin . init (
386
+ this . el ,
387
+ this . containerEl ,
388
+ this . options . displayPluginOptions
389
+ ) ;
385
390
}
386
391
}
387
392
@@ -493,7 +498,9 @@ export class Datepicker extends Component<DatepickerOptions> {
493
498
if ( ! this . options . dateRangeEndEl ) {
494
499
this . endDateEl = this . createDateInput ( ) ;
495
500
this . endDateEl . classList . add ( 'datepicker-end-date' ) ;
496
- } else if ( document . querySelector ( this . options . dateRangeEndEl ) as HTMLInputElement === undefined ) {
501
+ } else if (
502
+ ( document . querySelector ( this . options . dateRangeEndEl ) as HTMLInputElement ) === undefined
503
+ ) {
497
504
console . warn ( 'Specified date range end input element in dateRangeEndEl not found' ) ;
498
505
} else {
499
506
this . endDateEl = document . querySelector ( this . options . dateRangeEndEl ) as HTMLInputElement ;
@@ -509,10 +516,22 @@ export class Datepicker extends Component<DatepickerOptions> {
509
516
}
510
517
this.doneBtn.innerText = this.options.i18n.done;
511
518
this.cancelBtn.innerText = this.options.i18n.cancel;*/
512
- Utils . createButton ( this . footer , this . options . i18n . clear , [ 'datepicker-clear' ] , this . options . showClearBtn , this . _handleClearClick ) ;
519
+ Utils . createButton (
520
+ this . footer ,
521
+ this . options . i18n . clear ,
522
+ [ 'datepicker-clear' ] ,
523
+ this . options . showClearBtn ,
524
+ this . _handleClearClick
525
+ ) ;
513
526
514
527
if ( ! this . options . autoSubmit ) {
515
- Utils . createConfirmationContainer ( this . footer , this . options . i18n . done , this . options . i18n . cancel , this . _confirm , this . _cancel ) ;
528
+ Utils . createConfirmationContainer (
529
+ this . footer ,
530
+ this . options . i18n . done ,
531
+ this . options . i18n . cancel ,
532
+ this . _confirm ,
533
+ this . _cancel
534
+ ) ;
516
535
}
517
536
518
537
if ( this . options . container ) {
@@ -523,7 +542,11 @@ export class Datepicker extends Component<DatepickerOptions> {
523
542
} else {
524
543
//this.containerEl.before(this.el);
525
544
const appendTo = ! this . endDateEl ? this . el : this . endDateEl ;
526
- if ( ! this . options . openByDefault ) ( this . containerEl as HTMLElement ) . setAttribute ( 'style' , 'display: none; visibility: hidden;' ) ;
545
+ if ( ! this . options . openByDefault )
546
+ ( this . containerEl as HTMLElement ) . setAttribute (
547
+ 'style' ,
548
+ 'display: none; visibility: hidden;'
549
+ ) ;
527
550
appendTo . parentElement . after ( this . containerEl ) ;
528
551
}
529
552
}
@@ -711,7 +734,10 @@ export class Datepicker extends Component<DatepickerOptions> {
711
734
this . dateTextEl . innerHTML = this . formatDate ( displayDate , 'ddd, mmm d' ) ;
712
735
} else {
713
736
const displayEndDate = Datepicker . _isDate ( endDate ) ? endDate : new Date ( ) ;
714
- this . dateTextEl . innerHTML = `${ this . formatDate ( displayDate , 'mmm d' ) } - ${ this . formatDate ( displayEndDate , 'mmm d' ) } ` ;
737
+ this . dateTextEl . innerHTML = `${ this . formatDate ( displayDate , 'mmm d' ) } - ${ this . formatDate (
738
+ displayEndDate ,
739
+ 'mmm d'
740
+ ) } `;
715
741
}
716
742
}
717
743
@@ -819,8 +845,13 @@ export class Datepicker extends Component<DatepickerOptions> {
819
845
( this . options . maxDate && day > this . options . maxDate ) ||
820
846
( this . options . disableWeekends && Datepicker . _isWeekend ( day ) ) ||
821
847
( this . options . disableDayFn && this . options . disableDayFn ( day ) ) ,
822
- isDateRangeStart = this . options . isDateRange && this . date && this . endDate && Datepicker . _compareDates ( this . date , day ) ,
823
- isDateRangeEnd = this . options . isDateRange && this . endDate && Datepicker . _compareDates ( this . endDate , day ) ,
848
+ isDateRangeStart =
849
+ this . options . isDateRange &&
850
+ this . date &&
851
+ this . endDate &&
852
+ Datepicker . _compareDates ( this . date , day ) ,
853
+ isDateRangeEnd =
854
+ this . options . isDateRange && this . endDate && Datepicker . _compareDates ( this . endDate , day ) ,
824
855
isDateRange =
825
856
this . options . isDateRange &&
826
857
Datepicker . _isDate ( this . endDate ) &&
@@ -900,7 +931,11 @@ export class Datepicker extends Component<DatepickerOptions> {
900
931
isDateRangeEnd : 'is-daterange-end' ,
901
932
isDateRange : 'is-daterange'
902
933
} ,
903
- ariaSelected = ! ( [ 'isSelected' , 'isDateRange' ] . filter ( ( prop ) => ! ! ( opts . hasOwnProperty ( prop ) && opts [ prop ] === true ) ) . length === 0 ) ,
934
+ ariaSelected = ! (
935
+ [ 'isSelected' , 'isDateRange' ] . filter (
936
+ ( prop ) => ! ! ( opts . hasOwnProperty ( prop ) && opts [ prop ] === true )
937
+ ) . length === 0
938
+ ) ,
904
939
arr = [ 'datepicker-day' ] ;
905
940
906
941
if ( opts . isEmpty ) {
@@ -1014,7 +1049,9 @@ export class Datepicker extends Component<DatepickerOptions> {
1014
1049
}
1015
1050
if ( opts . yearRangeReverse ) arr . reverse ( ) ;
1016
1051
1017
- const yearHtml = `<select class="datepicker-select orig-select-year" tabindex="-1">${ arr . join ( '' ) } </select>` ;
1052
+ const yearHtml = `<select class="datepicker-select orig-select-year" tabindex="-1">${ arr . join (
1053
+ ''
1054
+ ) } </select>`;
1018
1055
1019
1056
const leftArrow =
1020
1057
'<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/><path d="M0-.5h24v24H0z" fill="none"/></svg>' ;
@@ -1353,7 +1390,7 @@ export class Datepicker extends Component<DatepickerOptions> {
1353
1390
_confirm = ( ) => {
1354
1391
this . _finishSelection ( ) ;
1355
1392
if ( typeof this . options . onConfirm === 'function' ) this . options . onConfirm . call ( this ) ;
1356
- }
1393
+ } ;
1357
1394
1358
1395
_cancel = ( ) => {
1359
1396
if ( typeof this . options . onCancel === 'function' ) this . options . onCancel . call ( this ) ;
0 commit comments