@@ -21,8 +21,9 @@ function IntervalBox(props: {
2121 interval : Interval ;
2222 showLabel ?: boolean ;
2323 intervalStyle : IntervalStyleBuilder ;
24+ onClick : ( e : Event , interval : Interval ) => void ;
2425} ) {
25- const { interval, showLabel = true , intervalStyle } = props ;
26+ const { interval, showLabel = true , intervalStyle, onClick } = props ;
2627
2728 const [ labelText , setLabelText ] = useState < string > ( interval . nam ) ;
2829
@@ -52,15 +53,16 @@ function IntervalBox(props: {
5253 setLabelText ( labelText [ 0 ] ) ;
5354 }
5455 } ,
56+ onClick : ( e ) => onClick ( e , interval ) ,
5557 } ) ;
5658}
5759
58- function IntervalChildren ( { children, intervalStyle } ) {
60+ function IntervalChildren ( { children, intervalStyle, onClick } ) {
5961 if ( children == null || children . length == 0 ) return null ;
6062 return h (
6163 "div.children" ,
6264 children . map ( ( d ) => {
63- return h ( TimescaleBoxes , { interval : d , intervalStyle } ) ;
65+ return h ( TimescaleBoxes , { interval : d , intervalStyle, onClick } ) ;
6466 } )
6567 ) ;
6668}
@@ -72,8 +74,9 @@ function ensureIncreasingAgeRange(ageRange) {
7274function TimescaleBoxes ( props : {
7375 interval : NestedInterval ;
7476 intervalStyle : IntervalStyleBuilder ;
77+ onClick : ( e : Event , interval : Interval ) => void ;
7578} ) {
76- const { interval, intervalStyle } = props ;
79+ const { interval, intervalStyle, onClick } = props ;
7780 const { scale, orientation, levels, ageRange } = useTimescale ( ) ;
7881 const { eag, lag, lvl } = interval ;
7982
@@ -108,8 +111,8 @@ function TimescaleBoxes(props: {
108111 const className = slugify ( name ) ;
109112
110113 return h ( "div.interval" , { className, style } , [
111- h . if ( lvl >= minLevel ) ( IntervalBox , { interval, intervalStyle } ) ,
112- h . if ( lvl < maxLevel ) ( IntervalChildren , { children, intervalStyle } ) ,
114+ h . if ( lvl >= minLevel ) ( IntervalBox , { interval, intervalStyle, onClick } ) ,
115+ h . if ( lvl < maxLevel ) ( IntervalChildren , { children, intervalStyle, onClick } ) ,
113116 ] ) ;
114117}
115118
0 commit comments