@@ -4,68 +4,66 @@ function fpf() {
44    Alpine . data ( 'flatpickrFilter' ,  ( wire ,  filterKey ,  filterConfig ,  refLocation ,  locale )  =>  ( { 
55        wireValues : wire . get ( 'appliedFilters.'  +  filterKey )  ? wire . entangle ( 'appliedFilters.'  +  filterKey )  : wire . entangle ( 'availableFilters.'  +  filterKey ) , 
66        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-                 var  wireDateArray  =  { } ; 
35-                 window . childElementOpen  =  false ; 
36-                 window . filterPopoverOpen  =  false ; 
37-                 wireDateArray  =  {  'minDate' : dates [ 0 ] ,  'maxDate' : ( typeof  dates [ 2 ]  ===  "undefined" )  ? dates [ 0 ]  : dates [ 2 ]  } ; 
38-                 wire . set ( 'appliedFilters.'  +  filterKey ,  wireDateArray ) ; 
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+                     var  wireDateArray  =  { } ; 
35+                     window . childElementOpen  =  false ; 
36+                     window . filterPopoverOpen  =  false ; 
37+                     wireDateArray  =  {  'minDate' : dates [ 0 ] ,  'maxDate' : ( typeof  dates [ 2 ]  ===  "undefined" )  ? dates [ 0 ]  : dates [ 2 ]  } ; 
38+                     wire . set ( 'appliedFilters.'  +  filterKey ,  wireDateArray ) ; 
39+                 } 
40+             } , 
41+         } ) , 
42+         changedValue : function ( value )  { 
43+             if  ( value . length  <  5 ) 
44+             { 
45+                 this . flatpickrInstance . setDate ( [ ] ) ;    
46+                 wire . set ( 'appliedFilters.'  +  filterKey ,  { } ) ; 
3947            } 
4048        } , 
41-     } ) , 
42-     changedValue : function ( value )  { 
43-         if  ( value . length  <  5 ) 
44-         { 
45-             this . flatpickrInstance . setDate ( [ ] ) ;    
46-             wire . set ( 'appliedFilters.'  +  filterKey ,  { } ) ; 
47-         } 
48-     } , 
49-     setupWire ( )  { 
50-         if  ( this . wireValues  !==  undefined )  { 
51-             if  ( this . wireValues . minDate  !==  undefined  &&  this . wireValues . maxDate  !==  undefined )  { 
52-                 let  initialDateArray  =  [ this . wireValues . minDate ,  this . wireValues . maxDate ] ; 
53-                 this . flatpickrInstance . setDate ( initialDateArray ) ; 
49+         setupWire ( )  { 
50+             if  ( this . wireValues  !==  undefined )  { 
51+                 if  ( this . wireValues . minDate  !==  undefined  &&  this . wireValues . maxDate  !==  undefined )  { 
52+                     let  initialDateArray  =  [ this . wireValues . minDate ,  this . wireValues . maxDate ] ; 
53+                     this . flatpickrInstance . setDate ( initialDateArray ) ; 
54+                 } 
55+                 else  { 
56+                     this . flatpickrInstance . setDate ( [ ] ) ; 
57+                 } 
5458            } 
5559            else  { 
5660                this . flatpickrInstance . setDate ( [ ] ) ; 
5761            } 
62+         } , 
63+         init ( )  { 
64+             this . setupWire ( ) ; 
65+             this . $watch ( 'wireValues' ,  value  =>  this . setupWire ( ) ) ; 
5866        } 
59-         else  { 
60-             this . flatpickrInstance . setDate ( [ ] ) ; 
61-         } 
62-     } , 
63-     init ( )  { 
64-         this . setupWire ( ) ; 
65-         this . $watch ( 'wireValues' ,  value  =>  this . setupWire ( ) ) ; 
66-     } 
67- 
68- 
6967    } ) ) ; 
7068} 
7169
0 commit comments