@@ -356,6 +356,8 @@ function getInitialCustomDuration(period?: string): { value: string; unit: strin
356356 return { value : "" , unit : "m" } ;
357357}
358358
359+ type SectionType = "duration" | "dateRange" ;
360+
359361export function TimeDropdown ( {
360362 trigger,
361363 period,
@@ -366,6 +368,7 @@ export function TimeDropdown({
366368 applyShortcut,
367369 onApply,
368370 onValueChange,
371+ maxPeriodDays
369372} : {
370373 trigger : ReactNode ;
371374 period ?: string ;
@@ -377,14 +380,15 @@ export function TimeDropdown({
377380 onApply ?: ( values : TimeFilterApplyValues ) => void ;
378381 /** When provided, the component operates in controlled mode and skips URL navigation */
379382 onValueChange ?: ( values : TimeFilterApplyValues ) => void ;
383+ /** When set an upgrade message will be shown if you select a period further back than this number of days */
384+ maxPeriodDays ?: number ;
380385} ) {
381386 const [ open , setOpen ] = useState < boolean | undefined > ( ) ;
382387 const { replace } = useSearchParams ( ) ;
383388 const [ fromValue , setFromValue ] = useState ( from ) ;
384389 const [ toValue , setToValue ] = useState ( to ) ;
385390
386391 // Section selection state: "duration" or "dateRange"
387- type SectionType = "duration" | "dateRange" ;
388392 const initialSection : SectionType = from || to ? "dateRange" : "duration" ;
389393 const [ activeSection , setActiveSection ] = useState < SectionType > ( initialSection ) ;
390394 const [ validationError , setValidationError ] = useState < string | null > ( null ) ;
@@ -683,7 +687,7 @@ export function TimeDropdown({
683687 />
684688 </ div >
685689 { /* Quick select date ranges */ }
686- < div className = "mt-2 grid grid-cols-3 gap-2" onClick = { ( e ) => e . stopPropagation ( ) } >
690+ < div className = "mt-2 grid grid-cols-2 gap-2" onClick = { ( e ) => e . stopPropagation ( ) } >
687691 < QuickDateButton
688692 label = "Yesterday"
689693 isActive = { selectedQuickDate === "yesterday" }
@@ -708,6 +712,8 @@ export function TimeDropdown({
708712 setSelectedQuickDate ( "today" ) ;
709713 } }
710714 />
715+ </ div >
716+ < div className = "mt-2 grid grid-cols-3 gap-2" onClick = { ( e ) => e . stopPropagation ( ) } >
711717 < QuickDateButton
712718 label = "This week"
713719 isActive = { selectedQuickDate === "thisWeek" }
@@ -732,18 +738,6 @@ export function TimeDropdown({
732738 setSelectedQuickDate ( "lastWeek" ) ;
733739 } }
734740 />
735- < QuickDateButton
736- label = "Last month"
737- isActive = { selectedQuickDate === "lastMonth" }
738- onClick = { ( ) => {
739- const lastMonth = subMonths ( new Date ( ) , 1 ) ;
740- setFromValue ( startOfMonth ( lastMonth ) ) ;
741- setToValue ( endOfMonth ( lastMonth ) ) ;
742- setActiveSection ( "dateRange" ) ;
743- setValidationError ( null ) ;
744- setSelectedQuickDate ( "lastMonth" ) ;
745- } }
746- />
747741 < QuickDateButton
748742 label = "This month"
749743 isActive = { selectedQuickDate === "thisMonth" }
0 commit comments