1- function  fpf ( ) { Alpine . data ( "flatpickrFilter" , ( e , t , a , n , l ) => ( { wireValues :e . entangle ( "appliedFilters." + t ) , flatpickrInstance :flatpickr ( n , { mode :"range" , altFormat :a . altFormat ?? "F j, Y" , altInput :a . altInput ?? ! 1 , allowInput :a . allowInput ?? ! 1 , allowInvalidPreload :a . allowInvalidPreload ?? ! 0 , ariaDateFormat :a . ariaDateFormat ?? "F j, Y" , clickOpens :! 0 , dateFormat :a . dateFormat ?? "Y-m-d" , defaultDate :a . defaultDate ?? null , defaultHour :a . defaultHour ?? 12 , defaultMinute :a . defaultMinute ?? 0 , enableTime :a . enableTime ?? ! 1 , enableSeconds :a . enableSeconds ?? ! 1 , hourIncrement :a . hourIncrement ?? 1 , locale :a . locale ?? "en" , minDate :a . earliestDate ?? null , maxDate :a . latestDate ?? null , minuteIncrement :a . minuteIncrement ?? 5 , shorthandCurrentMonth :a . shorthandCurrentMonth ?? ! 1 , time_24hr :a . time_24hr ?? ! 1 , weekNumbers :a . weekNumbers ?? ! 1 , onOpen :function ( ) { window . childElementOpen = ! 0 } , onChange :function ( a , n , l ) { if ( a . length > 1 ) { var  i = n . split ( " " ) , r = { } ; window . childElementOpen = ! 1 , window . filterPopoverOpen = ! 1 , r = { minDate :i [ 0 ] , maxDate :void  0 === i [ 2 ] ?i [ 0 ] :i [ 2 ] } , e . set ( "appliedFilters." + t , r ) } } } ) , setupWire ( ) { if ( void  0 !== this . wireValues ) { if ( void  0 !== this . wireValues . minDate && void  0 !== this . wireValues . maxDate ) { let  e = [ this . wireValues . minDate , this . wireValues . maxDate ] ; this . flatpickrInstance . setDate ( e ) } else  this . flatpickrInstance . setDate ( [ ] ) } else  this . flatpickrInstance . setDate ( [ ] ) } , init ( ) { this . setupWire ( ) , this . $watch ( "wireValues" , e => this . setupWire ( ) ) } } ) ) } export  default  fpf ; 
1+ /*jshint esversion: 6 */ 
2+ 
3+ function  fpf ( )  { 
4+     Alpine . data ( 'flatpickrFilter' ,  ( wire ,  filterKey ,  filterConfig ,  refLocation ,  locale )  =>  ( { 
5+         wireValues : wire . entangle ( 'availableFilters.'  +  filterKey ) , 
6+         flatpickrInstance : flatpickr ( refLocation ,  { 
7+             mode : 'range' , 
8+             altFormat : filterConfig [ 'altFormat' ]  ??  "F j, Y" , 
9+             altInput : filterConfig [ 'altInput' ]  ??  false , 
10+             allowInput : filterConfig [ 'allowInput' ]  ??  false , 
11+             allowInvalidPreload : filterConfig [ 'allowInvalidPreload' ]  ??  true , 
12+             ariaDateFormat : filterConfig [ 'ariaDateFormat' ]  ??  "F j, Y" , 
13+             clickOpens : true , 
14+             dateFormat : filterConfig [ 'dateFormat' ]  ??  "Y-m-d" , 
15+             defaultDate : filterConfig [ 'defaultDate' ]  ??  null , 
16+             defaultHour : filterConfig [ 'defaultHour' ]  ??  12 , 
17+             defaultMinute : filterConfig [ 'defaultMinute' ]  ??  0 , 
18+             enableTime : filterConfig [ 'enableTime' ]  ??  false , 
19+             enableSeconds : filterConfig [ 'enableSeconds' ]  ??  false , 
20+             hourIncrement : filterConfig [ 'hourIncrement' ]  ??  1 , 
21+             locale : filterConfig [ 'locale' ]  ??  'en' , 
22+             minDate : filterConfig [ 'earliestDate' ]  ??  null , 
23+             maxDate : filterConfig [ 'latestDate' ]  ??  null , 
24+             minuteIncrement : filterConfig [ 'minuteIncrement' ]  ??  5 , 
25+             shorthandCurrentMonth : filterConfig [ 'shorthandCurrentMonth' ]  ??  false , 
26+             time_24hr : filterConfig [ 'time_24hr' ]  ??  false , 
27+             weekNumbers : filterConfig [ 'weekNumbers' ]  ??  false , 
28+             onOpen : function  ( )  { 
29+                 window . childElementOpen  =  true ; 
30+             } , 
31+             onChange : function  ( selectedDates ,  dateStr ,  instance )  { 
32+                 if  ( selectedDates . length  >  1 )  { 
33+                     var  dates  =  dateStr . split ( ' ' ) ; 
34+ 
35+                     var  wireDateArray  =  { } ; 
36+                     window . childElementOpen  =  false ; 
37+                     window . filterPopoverOpen  =  false ; 
38+                     wireDateArray  =  {  'minDate' : dates [ 0 ] ,  'maxDate' : ( typeof  dates [ 2 ]  ===  "undefined" )  ? dates [ 0 ]  : dates [ 2 ]  } ; 
39+                     wire . set ( 'appliedFilters.'  +  filterKey ,  wireDateArray ) ; 
40+                 } 
41+ 
42+             } , 
43+         } ) , 
44+         setupWire ( )  { 
45+             if  ( this . wireValues  !==  undefined )  { 
46+                 if  ( this . wireValues . minDate  !==  undefined  &&  this . wireValues . maxDate  !==  undefined )  { 
47+                     let  initialDateArray  =  [ this . wireValues . minDate ,  this . wireValues . maxDate ] ; 
48+                     this . flatpickrInstance . setDate ( initialDateArray ) ; 
49+                 } 
50+                 else  { 
51+                     this . flatpickrInstance . setDate ( [ ] ) ; 
52+                 } 
53+             } 
54+             else  { 
55+                 this . flatpickrInstance . setDate ( [ ] ) ; 
56+             } 
57+         } , 
58+         init ( )  { 
59+             this . setupWire ( ) ; 
60+             this . $watch ( 'wireValues' ,  value  =>  this . setupWire ( ) ) ; 
61+         } 
62+     
63+     
64+     } ) ) ; 
65+ 
66+ } 
67+ 
68+ export  default  fpf ; 
0 commit comments