This repository was archived by the owner on Jul 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +32
-10
lines changed
Expand file tree Collapse file tree 4 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -63,8 +63,6 @@ export interface TableColumn extends BaseColumn {
6363 id : string ;
6464 options ?: RowSelectOption [ ] ;
6565 Cell ?: any ;
66- getHeaderProps ?: any ;
67- getResizerProps ?: any ;
6866}
6967
7068export type RowDataType = {
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export interface ColumnsState {
3333 addOptionToColumn : ( column : TableColumn , option : string , backgroundColor : string ) => void ;
3434 alterColumnType : ( column : TableColumn , input : string , parsedRows ?: RowDataType [ ] ) => void ;
3535 alterColumnLabel : ( column : TableColumn , label : string ) => void ;
36+ alterColumnSize : ( columnSizing : Record < string , number > ) => void ;
3637}
3738export interface ColumnSortingState {
3839 state : SortingState ;
Original file line number Diff line number Diff line change @@ -57,7 +57,10 @@ const defaultColumn: Partial<ColumnDef<RowDataType>> = {
5757export function Table ( tableData : TableDataType ) {
5858 /** Main information about the table */
5959 const { view, tableStore } = tableData ;
60- const [ columns ] = tableStore . columns ( ( state ) => [ state . columns ] ) ;
60+ const [ columns , alterColumnSize ] = tableStore . columns ( ( state ) => [
61+ state . columns ,
62+ state . alterColumnSize ,
63+ ] ) ;
6164 const [ rows , addRow ] = tableStore . data ( ( state ) => [ state . rows , state . addRow ] ) ;
6265 LOGGER . debug (
6366 `=> Table. number of columns: ${ columns . length } . number of rows: ${ rows . length } `
@@ -197,13 +200,7 @@ export function Table(tableData: TableDataType) {
197200 // setting new timeout
198201 setPersistSizingTimeout (
199202 setTimeout ( ( ) => {
200- Object . keys ( list )
201- . filter ( ( key ) => list [ key ] !== undefined )
202- . map ( ( key ) => {
203- view . diskConfig . updateColumnProperties ( key , {
204- width : list [ key ] ,
205- } ) ;
206- } ) ;
203+ alterColumnSize ( list ) ;
207204 // timeout until event is triggered after user has stopped typing
208205 } , 1500 )
209206 ) ;
Original file line number Diff line number Diff line change @@ -156,6 +156,32 @@ const useColumnsStore = (view: DatabaseView) => {
156156 view . diskConfig . updateColumnKey ( column . id , newKey , label ) ;
157157 return { columns : updater . columns } ;
158158 } ) ,
159+ alterColumnSize : ( columnSizing : Record < string , number > ) =>
160+ set ( ( updater ) => {
161+ const alteredColumns = [ ...updater . columns ] ;
162+ console . log (
163+ "before" ,
164+ alteredColumns . map ( ( col ) => col . config . size )
165+ ) ;
166+ Object . keys ( columnSizing )
167+ . filter ( ( key ) => columnSizing [ key ] !== undefined )
168+ . map ( ( key ) => {
169+ // Persist on disk
170+ view . diskConfig . updateColumnProperties ( key , {
171+ width : columnSizing [ key ] ,
172+ } ) ;
173+ // Persist on memory
174+ const indexCol = alteredColumns . findIndex (
175+ ( col : TableColumn ) => col . id === key
176+ ) ;
177+ alteredColumns [ indexCol ] . config . size = columnSizing [ key ] ;
178+ } ) ;
179+ console . log (
180+ "after" ,
181+ alteredColumns . map ( ( col ) => col . config . size )
182+ ) ;
183+ return { columns : alteredColumns } ;
184+ } ) ,
159185 } ) ) ;
160186} ;
161187/**
You can’t perform that action at this time.
0 commit comments