@@ -60,23 +60,26 @@ const defaultColumn: Partial<ColumnDef<RowDataType>> = {
6060export function Table ( tableData : TableDataType ) {
6161 /** Main information about the table */
6262 const { view, tableStore } = tableData ;
63- const [ columns , columnActions , columnsInfo ] = tableStore . columns ( ( state ) => [
64- state . columns ,
65- state . actions ,
66- state . info ,
67- ] ) ;
68- const [ rows , dataActions ] = tableStore . data ( ( state ) => [
69- state . rows ,
70- state . actions ,
71- ] ) ;
63+ const columns = tableStore . columns ( ( state ) => state . columns ) ;
64+ const columnActions = tableStore . columns ( ( state ) => state . actions ) ;
65+ const columnsInfo = tableStore . columns ( ( state ) => state . info ) ;
66+ const rows = tableStore . data ( ( state ) => state . rows ) ;
67+ const dataActions = tableStore . data ( ( state ) => state . actions ) ;
68+
7269 LOGGER . debug (
7370 `=> Table. number of columns: ${ columns . length } . number of rows: ${ rows . length } `
7471 ) ;
7572
76- const [ ddbbConfig , globalConfig , configActions ] = tableStore . configState (
77- ( store ) => [ store . ddbbConfig , store . global , store . actions ]
73+ const cell_size_config = tableStore . configState (
74+ ( store ) => store . ddbbConfig . cell_size
75+ ) ;
76+ const sticky_first_column_config = tableStore . configState (
77+ ( store ) => store . ddbbConfig . sticky_first_column
7878 ) ;
7979
80+ const globalConfig = tableStore . configState ( ( store ) => store . global ) ;
81+ const configActions = tableStore . configState ( ( store ) => store . actions ) ;
82+ const configInfo = tableStore . configState ( ( store ) => store . info ) ;
8083 /** Plugin services */
8184 const stateManager : StateManager = tableData . stateManager ;
8285 const filePath = stateManager . file . path ;
@@ -186,7 +189,6 @@ export function Table(tableData: TableDataType) {
186189 } ,
187190 [ stateManager , filePath ]
188191 ) ;
189-
190192 const table : Table < RowDataType > = useReactTable ( {
191193 columns : columns ,
192194 data : rows ,
@@ -236,7 +238,7 @@ export function Table(tableData: TableDataType) {
236238 onColumnOrderChange : setColumnOrder ,
237239 // Hack to force react-table to use all columns when filtering
238240 getColumnCanGlobalFilter : ( column ) => true ,
239- globalFilterFn : globalDatabaseFilterFn ( ddbbConfig ) ,
241+ globalFilterFn : globalDatabaseFilterFn ( configInfo . getLocalSettings ( ) ) ,
240242 meta : {
241243 tableState : tableStore ,
242244 view : view ,
@@ -262,7 +264,7 @@ export function Table(tableData: TableDataType) {
262264 }
263265
264266 function handleAddNewRow ( ) {
265- dataActions . addRow ( inputNewRow , columns , ddbbConfig ) ;
267+ dataActions . addRow ( inputNewRow , columns , configInfo . getLocalSettings ( ) ) ;
266268 setInputNewRow ( "" ) ;
267269 newRowRef . current . value = "" ;
268270 }
@@ -303,8 +305,8 @@ export function Table(tableData: TableDataType) {
303305 key = { `div-table` }
304306 className = { `${ c (
305307 "table noselect cell_size_" +
306- ddbbConfig . cell_size +
307- ( ddbbConfig . sticky_first_column ? " sticky_first_column" : "" )
308+ cell_size_config +
309+ ( sticky_first_column_config ? " sticky_first_column" : "" )
308310 ) } `}
309311 onMouseOver = { onMouseOver }
310312 onClick = { onClick }
0 commit comments