@@ -104,16 +104,24 @@ function Sheet(props) {
104
104
} /ws`;
105
105
106
106
const getCellContent = useCallback (
107
- ( [ row , column ] ) => {
108
- const cell = cells [ row ] ?. [ column ] ;
107
+ ( [ column , row ] ) => {
108
+ // Find the column in cells
109
+ const col = columns [ column ] . col ;
110
+ const cell = cells [ row ] ?. [ col ] ;
111
+
109
112
return {
110
- kind : cell ?. kind || GridCellKind . Text ,
113
+ kind :
114
+ ( cell ?. kind === "app_run" ? GridCellKind . Text : cell ?. kind ) ||
115
+ columns [ column ] . kind ,
111
116
displayData : cell ?. displayData || cell ?. data || "" ,
112
117
data : cell ?. data || "" ,
113
118
allowOverlay : true ,
119
+ allowWrapping : true ,
120
+ skeletonWidth : 80 ,
121
+ skeletonWidthVariability : 25 ,
114
122
} ;
115
123
} ,
116
- [ cells ] ,
124
+ [ cells , columns ] ,
117
125
) ;
118
126
119
127
const parseSheetColumnsIntoGridColumns = ( columns ) => {
@@ -129,6 +137,7 @@ function Sheet(props) {
129
137
data : column . data ,
130
138
hasMenu : true ,
131
139
icon : GridColumnIcon . HeaderString ,
140
+ width : column . width || 200 ,
132
141
} ;
133
142
} ) ;
134
143
} ;
@@ -194,26 +203,53 @@ function Sheet(props) {
194
203
if ( event . type === "cell.update" ) {
195
204
const cell = event . cell ;
196
205
const [ row , col ] = cell . id . split ( "-" ) ;
206
+ const column = columns . find ( ( c ) => c . col === col ) ;
197
207
198
208
setCells ( ( cells ) => ( {
199
209
...cells ,
200
210
[ row ] : {
201
211
...cells [ row ] ,
202
212
[ col ] : {
203
213
...cells [ row ] ?. [ col ] ,
204
- ...cell ,
214
+ ...{
215
+ kind : column ?. kind || GridCellKind . Text ,
216
+ data : cell . data ,
217
+ displayData : cell . data ,
218
+ } ,
205
219
} ,
206
220
} ,
207
221
} ) ) ;
208
222
209
- sheetRef . current ?. updateCells ( [ { cell : [ row , col ] } ] ) ;
223
+ sheetRef . current ?. updateCells ( [
224
+ { cell : [ columns . findIndex ( ( c ) => c . col === col ) , row ] } ,
225
+ ] ) ;
226
+ } else if ( event . type === "cell.updating" ) {
227
+ const cell = event . cell ;
228
+ const [ row , col ] = cell . id . split ( "-" ) ;
229
+
230
+ setCells ( ( cells ) => ( {
231
+ ...cells ,
232
+ [ row ] : {
233
+ ...cells [ row ] ,
234
+ [ col ] : {
235
+ ...cells [ row ] ?. [ col ] ,
236
+ ...{
237
+ kind : GridCellKind . Loading ,
238
+ } ,
239
+ } ,
240
+ } ,
241
+ } ) ) ;
242
+
243
+ sheetRef . current ?. updateCells ( [
244
+ { cell : [ columns . findIndex ( ( c ) => c . col === col ) , row ] } ,
245
+ ] ) ;
210
246
}
211
247
} ) ;
212
248
213
249
ws . send ( JSON . stringify ( { event : "run" } ) ) ;
214
250
}
215
251
}
216
- } , [ runId , sheet ?. uuid , wsUrlPrefix ] ) ;
252
+ } , [ runId , sheet ?. uuid , wsUrlPrefix , columns ] ) ;
217
253
218
254
return sheet ? (
219
255
< Stack >
@@ -261,11 +297,13 @@ function Sheet(props) {
261
297
onCellEdited = { ( cell , value ) => {
262
298
setCells ( ( cells ) => ( {
263
299
...cells ,
264
- [ cell [ 0 ] ] : {
265
- ...cells [ cell [ 0 ] ] ,
266
- [ cell [ 1 ] ] : {
267
- ...( cells [ cell [ 0 ] ] ?. [ cell [ 1 ] ] || { } ) ,
300
+ [ cell [ 1 ] ] : {
301
+ ...cells [ cell [ 1 ] ] ,
302
+ [ cell [ 0 ] ] : {
303
+ ...( cells [ cell [ 1 ] ] ?. [ cell [ 0 ] ] || { } ) ,
268
304
...value ,
305
+ kind : columns [ cell [ 0 ] ] . kind ,
306
+ data : value . data ,
269
307
displayData : value . displayData || value . data ,
270
308
} ,
271
309
} ,
@@ -279,6 +317,16 @@ function Sheet(props) {
279
317
} ;
280
318
setShowEditColumnMenu ( true ) ;
281
319
} }
320
+ onColumnResize = { ( column , width ) => {
321
+ setColumns ( ( columns ) => {
322
+ const newColumns = [ ...columns ] ;
323
+ const columnIndex = newColumns . findIndex (
324
+ ( c ) => c . col === column . col ,
325
+ ) ;
326
+ newColumns [ columnIndex ] . width = width ;
327
+ return newColumns ;
328
+ } ) ;
329
+ } }
282
330
rows = { numRows }
283
331
/>
284
332
</ Box >
0 commit comments