1
- import React , { useEffect , useState , useMemo } from ' react' ;
2
- import Badge from ' @material-ui/core/Badge' ;
3
- import Menu from ' @material-ui/core/Menu' ;
4
- import MenuItem from ' @material-ui/core/MenuItem' ;
5
- import { get as getPandasCsv } from ' @wq/pandas' ;
6
- import { useComponents , useNav , useApp } from ' @wq/react' ;
7
- import PropTypes from ' prop-types' ;
1
+ import React , { useEffect , useState , useMemo } from " react" ;
2
+ import Badge from " @material-ui/core/Badge" ;
3
+ import Menu from " @material-ui/core/Menu" ;
4
+ import MenuItem from " @material-ui/core/MenuItem" ;
5
+ import { get as getPandasCsv } from " @wq/pandas" ;
6
+ import { useComponents , useNav , useApp } from " @wq/react" ;
7
+ import PropTypes from " prop-types" ;
8
8
9
9
export default function AnalystTable ( {
10
10
data : initialData ,
@@ -19,7 +19,7 @@ export default function AnalystTable({
19
19
[ columns , setColumns ] = useState ( ) ,
20
20
[ filters , setFilters ] = useState ( { } ) ,
21
21
[ orders , setOrders ] = useState ( initial_order || { } ) ,
22
- pagination = initial_rows !== ' all' ,
22
+ pagination = initial_rows !== " all" ,
23
23
[ rowsPerPage , setRowsPerPage ] = useState (
24
24
pagination ? initial_rows || 50 : null
25
25
) ,
@@ -82,7 +82,7 @@ export default function AnalystTable({
82
82
return ;
83
83
}
84
84
Object . entries ( dataset ) . forEach ( ( [ key , value ] ) => {
85
- if ( key === ' data' ) {
85
+ if ( key === " data" ) {
86
86
return ;
87
87
}
88
88
if ( ! metaKeys [ key ] ) {
@@ -149,11 +149,11 @@ export default function AnalystTable({
149
149
let nextOrders = { ...orders } ;
150
150
if ( ! orders [ name ] ) {
151
151
nextOrders = {
152
- [ name ] : ' asc' ,
152
+ [ name ] : " asc" ,
153
153
...nextOrders ,
154
154
} ;
155
- } else if ( orders [ name ] === ' asc' ) {
156
- nextOrders [ name ] = ' desc' ;
155
+ } else if ( orders [ name ] === " asc" ) {
156
+ nextOrders [ name ] = " desc" ;
157
157
} else {
158
158
delete nextOrders [ name ] ;
159
159
}
@@ -201,18 +201,18 @@ export default function AnalystTable({
201
201
< TableTitle key = { column . name } >
202
202
< div
203
203
style = { {
204
- display : ' flex' ,
205
- alignItems : ' center' ,
204
+ display : " flex" ,
205
+ alignItems : " center" ,
206
206
marginLeft : - 8 ,
207
- borderLeft : ' 2px solid #ccc' ,
207
+ borderLeft : " 2px solid #ccc" ,
208
208
paddingLeft : 8 ,
209
209
marginRight : - 16 ,
210
210
} }
211
211
>
212
212
< span
213
213
style = { {
214
214
flex : 1 ,
215
- fontWeight : ' bold' ,
215
+ fontWeight : " bold" ,
216
216
} }
217
217
>
218
218
{ column . name }
@@ -226,13 +226,13 @@ export default function AnalystTable({
226
226
< IconButton
227
227
size = "small"
228
228
icon = {
229
- orders [ column . name ] === ' desc'
230
- ? ' sort-desc'
229
+ orders [ column . name ] === " desc"
230
+ ? " sort-desc"
231
231
: orders [ column . name ]
232
- ? ' sort-asc'
233
- : ' sort-none'
232
+ ? " sort-asc"
233
+ : " sort-none"
234
234
}
235
- color = { orders [ column . name ] && ' secondary' }
235
+ color = { orders [ column . name ] && " secondary" }
236
236
onClick = { ( ) => toggleOrder ( column . name ) }
237
237
/>
238
238
</ Badge >
@@ -256,7 +256,7 @@ export default function AnalystTable({
256
256
return null ;
257
257
} else if ( column . values ) {
258
258
return (
259
- < TableTitle style = { { cursor : ' pointer' } } >
259
+ < TableTitle style = { { cursor : " pointer" } } >
260
260
< ColumnFilter
261
261
{ ...column }
262
262
textButton
@@ -271,15 +271,15 @@ export default function AnalystTable({
271
271
} else {
272
272
return (
273
273
< TableTitle
274
- style = { { cursor : ' pointer' } }
274
+ style = { { cursor : " pointer" } }
275
275
onClick = { ( ) => toggleOrder ( column . name ) }
276
276
>
277
- < span style = { { fontWeight : ' bold' } } > { column . name } </ span >
278
- { orders [ column . name ] === ' desc'
279
- ? ' ↓'
277
+ < span style = { { fontWeight : " bold" } } > { column . name } </ span >
278
+ { orders [ column . name ] === " desc"
279
+ ? " ↓"
280
280
: orders [ column . name ]
281
- ? ' ↑'
282
- : '' }
281
+ ? " ↑"
282
+ : "" }
283
283
</ TableTitle >
284
284
) ;
285
285
}
@@ -301,7 +301,7 @@ export default function AnalystTable({
301
301
const id = cell . row [ id_column ] ;
302
302
return (
303
303
< TableCell
304
- style = { { cursor : ' pointer' } }
304
+ style = { { cursor : " pointer" } }
305
305
onClick = { ( ) => nav ( id ) }
306
306
>
307
307
< CellValue { ...cell } />
@@ -385,7 +385,7 @@ function ColumnFilter({
385
385
onClick = { ( evt ) => setAnchorEl ( evt . target ) }
386
386
size = "small"
387
387
icon = "filter"
388
- color = { filter && ' secondary' }
388
+ color = { filter && " secondary" }
389
389
title = { name }
390
390
/>
391
391
< Menu
@@ -421,9 +421,9 @@ ColumnFilter.propTypes = {
421
421
422
422
function TextButton ( props ) {
423
423
return (
424
- < span { ...props } style = { { fontWeight : ' bold' } } >
424
+ < span { ...props } style = { { fontWeight : " bold" } } >
425
425
{ props . title }
426
- { props . color && ' *' }
426
+ { props . color && " *" }
427
427
</ span >
428
428
) ;
429
429
}
@@ -475,8 +475,8 @@ function matchFilters(obj, filters) {
475
475
return match ;
476
476
}
477
477
478
- function sort ( val1 , val2 , dir = ' asc' ) {
479
- if ( dir == ' desc' ) {
478
+ function sort ( val1 , val2 , dir = " asc" ) {
479
+ if ( dir == " desc" ) {
480
480
return sort ( val2 , val1 ) ;
481
481
}
482
482
if ( val1 < val2 ) {
0 commit comments