@@ -120,12 +120,6 @@ export default class TerraDataAccess extends TerraElement {
120120 @state ( )
121121 cloudCoverPickerOpen = false
122122
123- @state ( )
124- datePickerOpen = false
125-
126- @state ( )
127- spatialPickerOpen = false
128-
129123 datePickerRef = createRef < TerraDatePicker > ( )
130124 spatialPickerRef = createRef < TerraSpatialPicker > ( )
131125 cloudCoverSliderRef = createRef < TerraSlider > ( )
@@ -304,6 +298,14 @@ export default class TerraDataAccess extends TerraElement {
304298 this . #gridApi?. purgeInfiniteCache ( )
305299 }
306300
301+ #handleSpatialDropdownShow( ) {
302+ // Trigger invalidateSize on the map when dropdown opens
303+ // This ensures the Leaflet map recalculates its size correctly
304+ setTimeout ( ( ) => {
305+ this . spatialPickerRef . value ?. invalidateSize ( )
306+ } , 0 )
307+ }
308+
307309 #handleDateRangeChange( event : CustomEvent ) {
308310 const detail = event . detail
309311 this . startDate = detail . startDate || ''
@@ -331,6 +333,24 @@ export default class TerraDataAccess extends TerraElement {
331333 return 'Date Range'
332334 }
333335
336+ #formatAvailableRangeDate( dateStr : string ) : string {
337+ if ( ! dateStr ) return ''
338+
339+ const date = new Date ( dateStr )
340+ const year = date . getUTCFullYear ( )
341+ const month = String ( date . getUTCMonth ( ) + 1 ) . padStart ( 2 , '0' )
342+ const day = String ( date . getUTCDate ( ) ) . padStart ( 2 , '0' )
343+
344+ if ( this . #controller. isSubDaily ) {
345+ const hours = String ( date . getUTCHours ( ) ) . padStart ( 2 , '0' )
346+ const minutes = String ( date . getUTCMinutes ( ) ) . padStart ( 2 , '0' )
347+ const seconds = String ( date . getUTCSeconds ( ) ) . padStart ( 2 , '0' )
348+ return `${ year } -${ month } -${ day } ${ hours } :${ minutes } :${ seconds } `
349+ }
350+
351+ return `${ year } -${ month } -${ day } `
352+ }
353+
334354 #getSpatialButtonText( ) : string {
335355 if ( ! this . location ) {
336356 return 'Spatial Area'
@@ -380,29 +400,16 @@ export default class TerraDataAccess extends TerraElement {
380400 return 'Spatial Area'
381401 }
382402
383- #toggleDatePicker( ) {
384- this . datePickerOpen = ! this . datePickerOpen
385- this . datePickerRef . value ?. setOpen ( this . datePickerOpen )
386- }
403+ // Date picker is now handled by dropdown component
387404
388405 #clearDateRange( ) {
389406 this . startDate = ''
390407 this . endDate = ''
391- this . datePickerOpen = false
392408 this . #gridApi?. purgeInfiniteCache ( )
393409 }
394410
395- #toggleSpatialPicker( ) {
396- // Use setTimeout to ensure the click event has been processed
397- setTimeout ( ( ) => {
398- this . spatialPickerOpen = ! this . spatialPickerOpen
399- this . spatialPickerRef . value ?. setOpen ( this . spatialPickerOpen )
400- } , 0 )
401- }
402-
403411 #clearSpatialFilter( ) {
404412 this . location = null
405- this . spatialPickerOpen = false
406413 this . #gridApi?. purgeInfiniteCache ( )
407414 }
408415
@@ -624,12 +631,12 @@ export default class TerraDataAccess extends TerraElement {
624631 </ div >
625632
626633 < div class ="toggle-row ">
627- < div class =" filter " >
634+ < terra-dropdown >
628635 < button
636+ slot ="trigger "
629637 class ="filter-btn ${ this . startDate && this . endDate
630638 ? 'active'
631639 : '' } "
632- @click =${ this . #toggleDatePicker}
633640 >
634641 < terra-icon
635642 name ="outline-calendar "
@@ -653,60 +660,97 @@ export default class TerraDataAccess extends TerraElement {
653660 : nothing }
654661 </ button >
655662
656- <!-- hidden date picker to show when clicking the filter -->
657- < terra-date-picker
658- ${ ref ( this . datePickerRef ) }
659- range
660- hide-label
661- enable-time
662- hide-input
663- show-presets
664- .startDate =${ this . startDate }
665- .endDate =${ this . endDate }
666- .minDate=${ this . #controller. granuleMinDate }
667- .maxDate=${ this . #controller. granuleMaxDate }
668- @terra-date-range-change=${ this . #handleDateRangeChange}
669- > </ terra-date-picker >
670- </ div >
671-
672- < div class ="filter ">
673- < button
674- class ="filter-btn ${ this . location ? 'active' : '' } "
675- @click =${ ( e : Event ) => {
676- e . stopPropagation ( )
677- this . #toggleSpatialPicker( )
678- } }
679- >
680- < terra-icon
681- name ="outline-globe-alt "
682- library ="heroicons "
683- font-size ="18px "
684- > </ terra-icon >
685- < span > ${ this . #getSpatialButtonText( ) } </ span >
686- ${ this . location
687- ? html `
688- < button
689- class ="clear-badge "
690- @click =${ ( e : Event ) => {
691- e . stopPropagation ( )
692- this . #clearSpatialFilter( )
693- } }
694- aria-label ="Clear spatial filter"
663+ < div class ="datepicker-container ">
664+ < terra-date-picker
665+ ${ ref ( this . datePickerRef ) }
666+ range
667+ ?enable-time =${ this . #controller. isSubDaily }
668+ show-presets
669+ split-inputs
670+ inline
671+ .startDate =${ this . startDate }
672+ .endDate =${ this . endDate }
673+ .startPlaceholder=${ this . #controller. isSubDaily
674+ ? 'YYYY-MM-DD HH:mm:ss'
675+ : 'YYYY-MM-DD' }
676+ .endPlaceholder=${ this . #controller. isSubDaily
677+ ? 'YYYY-MM-DD HH:mm:ss'
678+ : 'YYYY-MM-DD' }
679+ .minDate=${ this . #controller. granuleMinDate }
680+ .maxDate=${ this . #controller. granuleMaxDate }
681+ @terra-date-range-change=${ this
682+ . #handleDateRangeChange}
683+ >
684+ ${ this . #controller. granuleMinDate &&
685+ this . #controller. granuleMaxDate
686+ ? html ` < p
687+ slot ="additional-text "
688+ class ="available-range "
695689 >
696- ×
697- </ button >
698- `
699- : nothing }
700- </ button >
701-
702- <!-- hidden spatial picker to show when clicking the filter -->
703- < terra-spatial-picker
704- ${ ref ( this . spatialPickerRef ) }
705- has-shape-selector
706- hide-label
707- @terra-map-change =${ this . #handleMapChange}
708- > </ terra-spatial-picker >
709- </ div >
690+ < strong > Available Range:</ strong >
691+ ${ this . #formatAvailableRangeDate(
692+ this . #controller. granuleMinDate
693+ ) }
694+ -
695+ ${ this . #formatAvailableRangeDate(
696+ this . #controller. granuleMaxDate
697+ ) }
698+ </ p > `
699+ : nothing }
700+ </ terra-date-picker >
701+ </ div >
702+ </ terra-dropdown >
703+
704+ < terra-dropdown
705+ placement ="bottom-start "
706+ distance ="4 "
707+ hoist
708+ @terra-show =${ this . #handleSpatialDropdownShow}
709+ >
710+ < div slot ="trigger " class ="filter ">
711+ < button
712+ class ="filter-btn ${ this . location ? 'active' : '' } "
713+ >
714+ < terra-icon
715+ name ="outline-globe-alt "
716+ library ="heroicons "
717+ font-size ="18px "
718+ > </ terra-icon >
719+ < span > ${ this . #getSpatialButtonText( ) } </ span >
720+ ${ this . location
721+ ? html `
722+ < button
723+ class ="clear-badge "
724+ @click =${ ( e : Event ) => {
725+ e . stopPropagation ( )
726+ this . #clearSpatialFilter( )
727+ } }
728+ aria-label ="Clear spatial filter"
729+ >
730+ ×
731+ </ button >
732+ `
733+ : nothing }
734+ </ button >
735+ </ div >
736+
737+ < div class ="spatialpicker-container ">
738+ < terra-spatial-picker
739+ ${ ref ( this . spatialPickerRef ) }
740+ hide-label
741+ inline
742+ no-world-wrap
743+ .spatialConstraints =${ this . #controller
744+ . spatialConstraints || '-180, -90, 180, 90' }
745+ @terra-map-change =${ this . #handleMapChange}
746+ >
747+ < p class ="available-range " slot ="additional-text ">
748+ < strong > Available range:</ strong > ${ this
749+ . #controller. spatialConstraints }
750+ </ p >
751+ </ terra-spatial-picker >
752+ </ div >
753+ </ terra-dropdown >
710754
711755 ${ this . #controller. cloudCoverRange
712756 ? html `
0 commit comments