11import HighTable , { DataFrame , rowCache } from 'hightable'
22import { asyncBufferFromUrl , parquetMetadataAsync } from 'hyparquet'
33import React , { useCallback , useEffect , useState } from 'react'
4- import { RoutesConfig , appendSearchParams } from '../../lib/routes.js'
4+ import { useConfig } from '../../hooks/useConfig.js'
5+ import { appendSearchParams } from '../../lib/routes.js'
56import { FileSource } from '../../lib/sources/types.js'
67import { parquetDataFrame } from '../../lib/tableProvider.js'
78import { cn } from '../../lib/utils.js'
89import styles from '../../styles/ParquetView.module.css'
910import { Spinner } from '../Layout.js'
1011import CellPanel from './CellPanel.js'
1112import ContentHeader , { ContentSize } from './ContentHeader.js'
12- import SlidePanel , { SlidePanelConfig } from './SlidePanel.js'
13-
14- interface HighTableConfig {
15- hightable ?: {
16- className ?: string ;
17- }
18- }
19- export type ParquetViewConfig = SlidePanelConfig & RoutesConfig & HighTableConfig
13+ import SlidePanel from './SlidePanel.js'
2014
2115interface ViewerProps {
2216 source : FileSource
2317 setProgress : ( progress : number | undefined ) => void
2418 setError : ( error : Error | undefined ) => void
25- config ?: ParquetViewConfig
2619}
2720
2821interface Content extends ContentSize {
@@ -32,10 +25,11 @@ interface Content extends ContentSize {
3225/**
3326 * Parquet file viewer
3427 */
35- export default function ParquetView ( { source, setProgress, setError, config } : ViewerProps ) {
28+ export default function ParquetView ( { source, setProgress, setError } : ViewerProps ) {
3629 const [ isLoading , setIsLoading ] = useState < boolean > ( true )
3730 const [ content , setContent ] = useState < Content > ( )
3831 const [ cell , setCell ] = useState < { row : number , col : number } | undefined > ( )
32+ const { highTable, routes } = useConfig ( )
3933
4034 useEffect ( ( ) => {
4135 async function loadParquetDataFrame ( ) {
@@ -77,12 +71,12 @@ export default function ParquetView({ source, setProgress, setError, config }: V
7771
7872 const { sourceId } = source
7973 const getCellRouteUrl = useCallback ( ( { col, row } : { col : number , row : number } ) => {
80- const url = config ?. routes ?. getCellRouteUrl ?.( { sourceId, col, row } )
74+ const url = routes ?. getCellRouteUrl ?.( { sourceId, col, row } )
8175 if ( url ) {
8276 return url
8377 }
8478 return appendSearchParams ( { col : col . toString ( ) , row : row . toString ( ) } )
85- } , [ config , sourceId ] )
79+ } , [ routes , sourceId ] )
8680
8781 const onDoubleClickCell = useCallback ( ( _event : React . MouseEvent , col : number , row : number ) => {
8882 if ( cell ?. col === col && cell . row === row ) {
@@ -108,7 +102,7 @@ export default function ParquetView({ source, setProgress, setError, config }: V
108102 onDoubleClickCell = { onDoubleClickCell }
109103 onMouseDownCell = { onMouseDownCell }
110104 onError = { setError }
111- className = { cn ( styles . hightable , config ?. hightable ?. className ) }
105+ className = { cn ( styles . hightable , highTable ?. className ) }
112106 /> }
113107
114108 { isLoading && < div className = 'center' > < Spinner /> </ div > }
@@ -132,7 +126,6 @@ export default function ParquetView({ source, setProgress, setError, config }: V
132126 isPanelOpen = { ! ! ( content ?. dataframe && cell ) }
133127 mainContent = { mainContent }
134128 panelContent = { panelContent }
135- config = { config }
136129 />
137130 )
138131}
0 commit comments