@soft-stech/bootsman-ui-shadcn 2.0.23 → 2.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ import { useEventListener } from '@vueuse/core'
6
6
  const MIN_CELL_WIDTH = 90
7
7
  const LAST_CELL_EXTRA_SPACE = 56
8
8
  const ACTIONS_CELL_MIN_WIDTH = 10
9
+ const TABLE_ID = 'table'
9
10
 
10
11
  export function useResizeColumns() {
11
12
  type CELL = {
@@ -14,12 +15,10 @@ export function useResizeColumns() {
14
15
  initialWidth: number
15
16
  minWidth: number
16
17
  baseWidth: number
17
- isLast: boolean
18
18
  }
19
19
  }
20
20
  const isResizing = ref<boolean>(false)
21
21
  const resizingCellId = ref<string>('')
22
- const neighborCellId = ref<string>('')
23
22
  const cells = ref<CELL | undefined>(undefined)
24
23
  const calculatedColumnSizing = ref<Record<string, number> | undefined>(undefined)
25
24
  const tableHeaderElement = ref<InstanceType<typeof BuiTableHeader> | null>(null)
@@ -27,156 +26,150 @@ export function useResizeColumns() {
27
26
  const initialTableWidth = ref<number>(0)
28
27
  const minTableWidth = ref<number>(0)
29
28
  const unregisterMouseMove = ref<(() => void) | undefined>(undefined)
29
+ const isMouseDownOnHandler = ref<boolean>(false)
30
+ const isMouseUpOnHandler = ref<boolean>(false)
30
31
 
31
32
  const setProvidedCellWidths = (columnSizing: Record<string, number> | undefined) => {
32
- if (tableHeaderElement.value && tableHeaderElement.value.headRef) {
33
- const headerCells = [...tableHeaderElement.value.headRef.querySelectorAll('th')]
34
-
35
- //установить заданные как модель изначальные размеры
36
- headerCells.forEach((cell) => {
37
- const cellId = getCellId(cell)
38
-
39
- cell.style.width =
40
- columnSizing && columnSizing[cellId] && columnSizing[cellId] !== 0
41
- ? columnSizing[cellId] + 'px'
42
- : ''
43
- })
44
- }
33
+ if (!tableHeaderElement.value?.headRef || !columnSizing) return
34
+
35
+ const headerCells = [...tableHeaderElement.value.headRef.querySelectorAll('th')]
36
+
37
+ //установить заданные как модель изначальные размеры
38
+ headerCells.forEach((cell) => {
39
+ const cellId = getCellId(cell)
40
+ const width = columnSizing[cellId]
41
+
42
+ cell.style.width = width && width !== 0 ? columnSizing[cellId] + 'px' : ''
43
+ })
45
44
  }
46
45
 
47
46
  const getCells = () => {
48
- if (
49
- tableHeaderElement.value &&
50
- tableHeaderElement.value.headRef &&
51
- tableElement.value &&
52
- tableElement.value?.tableRef
53
- ) {
54
- const headerCells = [...tableHeaderElement.value.headRef.querySelectorAll('th')]
55
-
56
- if (calculatedColumnSizing.value && calculatedColumnSizing.value['table'] === 0) {
57
- calculatedColumnSizing.value = {}
58
- tableElement.value.tableRef.style.width = ''
59
- }
47
+ const tableRef = tableElement.value?.tableRef
48
+ const headRef = tableHeaderElement.value?.headRef
60
49
 
61
- const tableInitialWidth = getTableWidth()
50
+ if (!headRef || !tableRef) return undefined
62
51
 
63
- tableElement.value.tableRef.style.width = 'min-content'
52
+ const headerCells = [...headRef.querySelectorAll('th')]
64
53
 
65
- const headerCellsWidths: CELL = headerCells.reduce((acc, cell, index, array) => {
66
- const cellId = getCellId(cell)
54
+ if (calculatedColumnSizing.value?.[TABLE_ID] === 0) {
55
+ calculatedColumnSizing.value = {}
56
+ tableRef.style.width = ''
57
+ }
67
58
 
68
- return {
69
- ...acc,
70
- [cellId]: {
71
- cell: cell,
72
- isLast: index === array.length - 1,
73
- initialWidth: Math.floor(cell.offsetWidth),
74
- baseWidth: Math.floor(cell.offsetWidth),
75
- minWidth:
76
- cellId === 'actions'
77
- ? ACTIONS_CELL_MIN_WIDTH
78
- : cell.offsetWidth < MIN_CELL_WIDTH
79
- ? MIN_CELL_WIDTH
80
- : cell.offsetWidth
81
- }
59
+ const tableInitialWidth = getTableWidth()
60
+
61
+ tableRef.style.width = 'min-content'
62
+
63
+ const headerCellsWidths: CELL = headerCells.reduce((acc, cell) => {
64
+ cell.style.width = ''
65
+
66
+ const cellId = getCellId(cell)
67
+ const offsetWidth = Math.floor(cell.offsetWidth)
68
+ const minWidth =
69
+ cellId === 'actions'
70
+ ? ACTIONS_CELL_MIN_WIDTH
71
+ : cell.offsetWidth < MIN_CELL_WIDTH
72
+ ? MIN_CELL_WIDTH
73
+ : cell.offsetWidth
74
+
75
+ return {
76
+ ...acc,
77
+ [cellId]: {
78
+ cell: cell,
79
+ initialWidth: offsetWidth,
80
+ baseWidth: offsetWidth,
81
+ minWidth: minWidth
82
82
  }
83
- }, {})
84
-
85
- tableElement.value.tableRef.style.width = ''
83
+ }
84
+ }, {})
86
85
 
87
- Object.values(headerCellsWidths).forEach((cellElement) => {
88
- cellElement.baseWidth = Math.floor(cellElement.cell.offsetWidth)
89
- })
86
+ tableRef.style.width = ''
90
87
 
91
- setProvidedCellWidths(calculatedColumnSizing.value)
92
- tableElement.value.tableRef.style.width =
93
- (calculatedColumnSizing.value?.['table'] || tableInitialWidth) + 'px'
88
+ Object.values(headerCellsWidths).forEach((cellElement) => {
89
+ cellElement.baseWidth = Math.floor(cellElement.cell.offsetWidth)
90
+ })
94
91
 
95
- Object.values(headerCellsWidths).forEach((cellElement) => {
96
- cellElement.initialWidth = Math.floor(cellElement.cell.offsetWidth)
97
- })
92
+ setProvidedCellWidths(calculatedColumnSizing.value)
93
+ tableRef.style.width = (calculatedColumnSizing.value?.[TABLE_ID] || tableInitialWidth) + 'px'
98
94
 
99
- return headerCellsWidths
100
- }
95
+ Object.values(headerCellsWidths).forEach((cellElement) => {
96
+ cellElement.initialWidth = Math.floor(cellElement.cell.offsetWidth)
97
+ })
101
98
 
102
- return undefined
99
+ return headerCellsWidths
103
100
  }
104
101
 
105
- const isMouseDownOnHandler = ref<boolean>(false)
106
- const isMouseUpOnHandler = ref<boolean>(false)
107
-
108
102
  const handleResizeControlMouseDown = (cellId: string, enableColumnResizing: boolean) => {
109
103
  if (!enableColumnResizing) return
110
104
 
111
105
  isResizing.value = true
112
106
  resizingCellId.value = cellId
113
-
114
- if (cells.value) {
115
- const resizingCell = cells.value[cellId].cell
116
- let neighborCell = resizingCell.nextElementSibling as HTMLTableCellElement
117
-
118
- if (!neighborCell) {
119
- neighborCell = resizingCell.previousElementSibling as HTMLTableCellElement
120
- }
121
-
122
- neighborCellId.value = neighborCell ? neighborCell.id.split('_')[0] : ''
123
-
124
- unregisterMouseMove.value = useEventListener(document, 'mousemove', handleCellResize)
125
- }
107
+ unregisterMouseMove.value = useEventListener(document, 'mousemove', handleCellResize)
126
108
  }
127
109
 
128
110
  const handleResizeControlMouseUp = (e: Event) => {
129
111
  const targetHTMLElement = e.target as HTMLElement
130
- isMouseUpOnHandler.value =
131
- targetHTMLElement.className.includes && targetHTMLElement.className.includes('resize-handler')
112
+ isMouseUpOnHandler.value = targetHTMLElement.className?.includes?.('resize-handler') || false
132
113
 
133
114
  if (!isResizing.value) return
134
115
 
116
+ cleanupResizeState()
117
+ updateColumnSizingAfterResize()
118
+ }
119
+
120
+ const cleanupResizeState = () => {
135
121
  isResizing.value = false
136
122
  resizingCellId.value = ''
137
- neighborCellId.value = ''
138
123
 
139
124
  if (unregisterMouseMove.value) {
140
125
  unregisterMouseMove.value()
126
+ unregisterMouseMove.value = undefined
141
127
  }
128
+ }
142
129
 
143
- if (cells.value) {
144
- const updatedColumnSizingValue: Record<string, number> = {}
145
-
146
- for (const cell in cells.value) {
147
- const currentCell = cells.value[cell]
148
- const newWidth = !currentCell.cell.hasAttribute('can-resize')
149
- ? currentCell.initialWidth
150
- : Math.floor(currentCell.cell.offsetWidth) <= currentCell.minWidth
151
- ? currentCell.minWidth
152
- : currentCell.cell.offsetWidth
130
+ const updateColumnSizingAfterResize = () => {
131
+ if (!cells.value || !tableElement.value?.tableRef) return
153
132
 
154
- currentCell.cell.style.width = newWidth + 'px'
155
- updatedColumnSizingValue[cell] = newWidth
156
- }
133
+ const updatedColumnSizingValue: Record<string, number> = {}
157
134
 
158
- if (tableElement.value && tableElement.value?.tableRef) {
159
- updatedColumnSizingValue['table'] = tableElement.value.tableRef.offsetWidth
160
- }
135
+ for (const cell in cells.value) {
136
+ const currentCell = cells.value[cell]
137
+ const newWidth = !currentCell.cell.hasAttribute('can-resize')
138
+ ? currentCell.initialWidth
139
+ : Math.floor(currentCell.cell.offsetWidth) <= currentCell.minWidth
140
+ ? currentCell.minWidth
141
+ : currentCell.cell.offsetWidth
161
142
 
162
- calculatedColumnSizing.value = updatedColumnSizingValue
143
+ currentCell.cell.style.width = newWidth + 'px'
144
+ updatedColumnSizingValue[cell] = newWidth
163
145
  }
164
- }
165
146
 
166
- const getLastCellOnTheRightExtraSpace = (cell: HTMLTableCellElement) => {
167
- if (getCellId(cell) === 'actions') {
168
- return LAST_CELL_EXTRA_SPACE
169
- }
147
+ updatedColumnSizingValue[TABLE_ID] = tableElement.value.tableRef.offsetWidth
148
+ calculatedColumnSizing.value = updatedColumnSizingValue
149
+ }
170
150
 
171
- return 0
151
+ const getLastCellOnTheRightExtraSpace = (cellId: string) => {
152
+ return cellId === 'actions' ? LAST_CELL_EXTRA_SPACE : 0
172
153
  }
173
154
 
174
155
  const lastCell = computed(() => {
175
- if (cells.value) {
176
- return Object.values(cells.value).find((cell) => cell.isLast)
177
- }
156
+ if (!cells.value || !tableHeaderElement.value?.headRef) return undefined
157
+
158
+ const headerCells = [...tableHeaderElement.value.headRef.querySelectorAll('th')]
159
+ if (headerCells.length === 0) return undefined
160
+
161
+ const lastCellElement = headerCells[headerCells.length - 1]
162
+ return cells.value[getCellId(lastCellElement)]
163
+ })
164
+
165
+ const secondToLastCell = computed(() => {
166
+ if (!cells.value || !tableHeaderElement.value?.headRef) return undefined
167
+
168
+ const headerCells = [...tableHeaderElement.value.headRef.querySelectorAll('th')]
169
+ if (headerCells.length < 2) return undefined
178
170
 
179
- return undefined
171
+ const secondToLastCellElement = headerCells[headerCells.length - 2]
172
+ return cells.value[getCellId(secondToLastCellElement)]
180
173
  })
181
174
 
182
175
  const getCellId = (cell: HTMLTableCellElement) => {
@@ -186,7 +179,6 @@ export function useResizeColumns() {
186
179
  const resizeCells = (cell: HTMLTableCellElement | null, e: MouseEvent) => {
187
180
  if (!cell || !tableElement.value?.tableRef || !lastCell.value) {
188
181
  resizingCellId.value = ''
189
- neighborCellId.value = ''
190
182
 
191
183
  return
192
184
  }
@@ -194,8 +186,8 @@ export function useResizeColumns() {
194
186
  const movementX = e.movementX
195
187
  const direction: 'left' | 'right' = movementX < 0 ? 'left' : 'right'
196
188
  const newCellWidth = Math.floor(parseInt(cell.style.width)) + movementX
197
- const newTableWidth =
198
- Math.floor(parseInt(tableElement.value?.tableRef?.style.width)) + movementX
189
+
190
+ const newTableWidth = Math.floor(parseInt(tableElement.value.tableRef.style.width)) + movementX
199
191
  const newLastCellWidth = Math.floor(parseInt(lastCell.value.cell.style.width)) - movementX
200
192
 
201
193
  if (direction === 'left') {
@@ -217,10 +209,10 @@ export function useResizeColumns() {
217
209
  return
218
210
  }
219
211
  } else {
212
+ const lastCellId = getCellId(lastCell.value.cell)
220
213
  const min =
221
- cells.value && cells.value[getCellId(lastCell.value.cell)]
222
- ? cells.value[getCellId(lastCell.value.cell)].minWidth +
223
- getLastCellOnTheRightExtraSpace(lastCell.value.cell)
214
+ cells.value && cells.value[lastCellId]
215
+ ? cells.value[lastCellId].minWidth + getLastCellOnTheRightExtraSpace(lastCellId)
224
216
  : MIN_CELL_WIDTH
225
217
 
226
218
  if (
@@ -239,104 +231,212 @@ export function useResizeColumns() {
239
231
  const handleCellResize = (e: MouseEvent) => {
240
232
  e.preventDefault()
241
233
 
242
- if (cells.value) {
243
- const resizingCell = cells.value[resizingCellId.value]?.cell
234
+ if (!cells.value) return
244
235
 
245
- resizeCells(resizingCell, e)
246
- }
236
+ const resizingCell = cells.value[resizingCellId.value]?.cell
237
+ resizeCells(resizingCell, e)
247
238
  }
248
239
 
249
240
  const resetCells = () => {
250
- if (cells.value && tableElement.value && tableElement.value?.tableRef) {
251
- tableElement.value.tableRef.style.width = ''
241
+ if (!cells.value || !tableElement.value?.tableRef) return
252
242
 
253
- calculatedColumnSizing.value = {}
254
- setInitialColumnWidths()
255
- }
243
+ tableElement.value.tableRef.style.width = ''
244
+ calculatedColumnSizing.value = {}
245
+ setInitialColumnWidths()
256
246
  }
257
247
 
258
248
  const resetCell = (cellId: string) => {
259
249
  if (
260
- cells.value &&
261
- calculatedColumnSizing.value &&
262
- lastCell.value &&
263
- tableElement.value &&
264
- tableElement.value?.tableRef
265
- ) {
266
- const thisCellBaseWidth = cells.value[cellId].baseWidth
267
- const thisCellCurrentWidth = calculatedColumnSizing.value[cellId]
268
- const diff = thisCellBaseWidth - thisCellCurrentWidth
269
-
270
- let newTableWidth = calculatedColumnSizing.value['table'] + diff
271
-
272
- if (newTableWidth < minTableWidth.value) {
273
- const tableWidthDiff = minTableWidth.value - newTableWidth
274
- const newLastCellWidth =
275
- calculatedColumnSizing.value[getCellId(lastCell.value.cell)] + tableWidthDiff
250
+ !cells.value ||
251
+ !calculatedColumnSizing.value ||
252
+ !lastCell.value ||
253
+ !tableElement.value?.tableRef
254
+ )
255
+ return
256
+
257
+ const updatedColumnSizingValue: Record<string, number> = { ...calculatedColumnSizing.value }
258
+
259
+ const cellData = cells.value[cellId]
260
+ const thisCellBaseWidth = cellData.baseWidth
261
+ const thisCellCurrentWidth = calculatedColumnSizing.value[cellId]
262
+ const diff = thisCellBaseWidth - thisCellCurrentWidth
263
+
264
+ let newTableWidth = calculatedColumnSizing.value[TABLE_ID] + diff
265
+ let lastCellId = getCellId(lastCell.value.cell)
276
266
 
267
+ if (newTableWidth < minTableWidth.value) {
268
+ const tableWidthDiff = minTableWidth.value - newTableWidth
269
+ let newLastCellWidth: number
270
+
271
+ if (cellId === lastCellId) {
272
+ //если ресетим последнюю колонку, то восстанавливаем ее ширину за счет соседней слева
273
+ if (!secondToLastCell.value) {
274
+ resetCells()
275
+ return
276
+ }
277
+
278
+ lastCellId = getCellId(secondToLastCell.value.cell)
279
+ newLastCellWidth = calculatedColumnSizing.value[lastCellId] + tableWidthDiff
280
+ secondToLastCell.value.cell.style.width = newLastCellWidth + 'px'
281
+ } else {
282
+ newLastCellWidth =
283
+ calculatedColumnSizing.value[getCellId(lastCell.value.cell)] + tableWidthDiff
277
284
  lastCell.value.cell.style.width = newLastCellWidth + 'px'
278
- newTableWidth = minTableWidth.value
279
285
  }
280
286
 
281
- cells.value[cellId].cell.style.width = thisCellBaseWidth + 'px'
282
- tableElement.value.tableRef.style.width = newTableWidth + 'px'
283
- calculatedColumnSizing.value[cellId] = thisCellBaseWidth
284
- calculatedColumnSizing.value['table'] = newTableWidth
287
+ newTableWidth = minTableWidth.value
288
+ updatedColumnSizingValue[lastCellId] = newLastCellWidth
285
289
  }
290
+
291
+ cells.value[cellId].cell.style.width = thisCellBaseWidth + 'px'
292
+ tableElement.value.tableRef.style.width = newTableWidth + 'px'
293
+ updatedColumnSizingValue[cellId] = thisCellBaseWidth
294
+ updatedColumnSizingValue[TABLE_ID] = newTableWidth
295
+
296
+ calculatedColumnSizing.value = updatedColumnSizingValue
286
297
  }
287
298
 
288
299
  const getTableWrapperWidth = () => {
289
- if (tableElement.value && tableElement.value.scrollAreaElementRef?.tableWrapperRef) {
290
- return tableElement.value.scrollAreaElementRef?.tableWrapperRef.$el.offsetWidth - 3
291
- }
292
-
293
- return 0
300
+ return tableElement.value?.scrollAreaElementRef?.tableWrapperRef?.$el.offsetWidth - 3 || 0
294
301
  }
295
302
 
296
303
  const getTableWidth = () => {
297
- if (tableElement.value && tableElement.value?.tableRef) {
298
- return tableElement.value.tableRef.offsetWidth
299
- }
300
-
301
- return 0
304
+ return tableElement.value?.tableRef?.offsetWidth || 0
302
305
  }
303
306
 
304
307
  const setInitialColumnWidths = () => {
305
308
  cells.value = getCells()
306
309
 
307
- if (cells.value) {
308
- const updatedColumnSizingValue: Record<string, number> = {}
310
+ if (!cells.value) return
309
311
 
310
- for (const cell in cells.value) {
311
- if (!cells.value[cell].cell.style.width) {
312
- cells.value[cell].cell.style.width = cells.value[cell].initialWidth + 'px'
313
- }
314
-
315
- cells.value[cell].cell.style.minWidth = cells.value[cell].minWidth + 'px'
312
+ const updatedColumnSizingValue: Record<string, number> = {}
316
313
 
317
- updatedColumnSizingValue[cell] = cells.value[cell].cell.offsetWidth
314
+ for (const cell in cells.value) {
315
+ if (!cells.value[cell].cell.style.width) {
316
+ cells.value[cell].cell.style.width = cells.value[cell].initialWidth + 'px'
318
317
  }
319
318
 
320
- if (tableElement.value && tableElement.value?.tableRef) {
321
- const tableOffsetWidth = getTableWidth()
319
+ cells.value[cell].cell.style.minWidth = cells.value[cell].minWidth + 'px'
320
+ updatedColumnSizingValue[cell] = cells.value[cell].cell.offsetWidth
321
+ }
322
+
323
+ if (tableElement.value?.tableRef) {
324
+ const tableOffsetWidth = getTableWidth()
325
+ const tableWrapperWidth = getTableWrapperWidth()
326
+ minTableWidth.value = tableWrapperWidth
327
+ tableElement.value.tableRef.setAttribute('initialResize', 'set')
322
328
 
323
- if (calculatedColumnSizing.value?.['table'] && !tableElement.value.tableRef.style.width) {
324
- tableElement.value.tableRef.style.width = calculatedColumnSizing.value['table'] + 'px'
329
+ if (calculatedColumnSizing.value?.[TABLE_ID] && !tableElement.value.tableRef.style.width) {
330
+ tableElement.value.tableRef.style.width = calculatedColumnSizing.value[TABLE_ID] + 'px'
331
+ } else {
332
+ if (tableOffsetWidth < minTableWidth.value) {
333
+ setTableFullScreen()
325
334
  } else {
326
335
  initialTableWidth.value = tableOffsetWidth
327
336
  tableElement.value.tableRef.style.width = tableOffsetWidth + 'px'
337
+ updatedColumnSizingValue[TABLE_ID] = tableOffsetWidth
338
+ }
339
+ }
340
+ }
341
+
342
+ calculatedColumnSizing.value = updatedColumnSizingValue
343
+ }
344
+
345
+ const setColumnWidthsOnColumnVisibilityChange = () => {
346
+ if (!tableHeaderElement.value?.headRef || !cells.value) return
347
+
348
+ const headerCells = [...tableHeaderElement.value.headRef.querySelectorAll('th')]
349
+ const updatedColumnSizingValue: Record<string, number> = {}
328
350
 
329
- tableElement.value.tableRef.setAttribute('initialResize', 'set')
330
- updatedColumnSizingValue['table'] = tableOffsetWidth
351
+ headerCells.forEach((cell, index, array) => {
352
+ const cellId = getCellId(cell)
353
+
354
+ if (cells.value) {
355
+ if (cells.value[cellId]) {
356
+ cells.value[cellId].cell = cell
357
+ } else {
358
+ const minWidth =
359
+ cellId === 'actions'
360
+ ? ACTIONS_CELL_MIN_WIDTH
361
+ : cell.offsetWidth < MIN_CELL_WIDTH
362
+ ? MIN_CELL_WIDTH
363
+ : cell.offsetWidth
364
+
365
+ cells.value[cellId] = {
366
+ cell: cell,
367
+ baseWidth: cell.offsetWidth,
368
+ minWidth: minWidth,
369
+ initialWidth: cell.offsetWidth
370
+ }
371
+ }
372
+ }
373
+
374
+ if (index < array.length - 1) {
375
+ const storedWidth = calculatedColumnSizing.value?.[cellId]
376
+
377
+ if (storedWidth) {
378
+ cell.style.width = storedWidth + 'px'
379
+ updatedColumnSizingValue[cellId] = storedWidth
380
+ } else {
381
+ cell.style.width = ''
382
+
383
+ const baseWidth = cells.value?.[cellId]?.baseWidth || cell.offsetWidth
384
+ const minWidth = cells.value?.[cellId]?.minWidth || MIN_CELL_WIDTH
385
+ cell.style.width = baseWidth + 'px'
386
+ cell.style.minWidth = minWidth + 'px'
387
+ updatedColumnSizingValue[cellId] = baseWidth
331
388
  }
389
+ } else {
390
+ const newLastCellWidth = cells.value?.[cellId]?.baseWidth || cell.offsetWidth
391
+ updatedColumnSizingValue[cellId] = newLastCellWidth
332
392
  }
393
+ })
394
+
395
+ const wouldBeTableWidth = Object.values(updatedColumnSizingValue).reduce(
396
+ (acc, value) => (acc += value),
397
+ 0
398
+ )
333
399
 
400
+ if (tableElement.value?.tableRef) {
334
401
  minTableWidth.value = getTableWrapperWidth()
402
+ const newTableWidth = Math.max(wouldBeTableWidth, minTableWidth.value)
403
+ tableElement.value.tableRef.style.width = newTableWidth + 'px'
404
+ updatedColumnSizingValue[TABLE_ID] = newTableWidth
405
+ }
406
+
407
+ if (lastCell.value) {
408
+ lastCell.value.cell.style.width = ''
409
+ const newLastCellWidth = Math.floor(lastCell.value.cell.offsetWidth)
410
+ updatedColumnSizingValue[getCellId(lastCell.value.cell)] = newLastCellWidth
411
+ lastCell.value.cell.style.width = newLastCellWidth + 'px'
412
+ }
413
+
414
+ calculatedColumnSizing.value = updatedColumnSizingValue
415
+ }
335
416
 
336
- calculatedColumnSizing.value = updatedColumnSizingValue
417
+ const setColumnWidthsOnWindowResize = () => {
418
+ const tableWidth = getTableWidth()
419
+ minTableWidth.value = getTableWrapperWidth()
420
+
421
+ if (tableWidth < minTableWidth.value) {
422
+ setTableFullScreen()
337
423
  }
338
424
  }
339
425
 
426
+ const setTableFullScreen = () => {
427
+ if (!lastCell.value || !calculatedColumnSizing.value || !tableElement.value?.tableRef) return
428
+
429
+ const lastCellId = getCellId(lastCell.value.cell)
430
+
431
+ calculatedColumnSizing.value[TABLE_ID] = minTableWidth.value
432
+ tableElement.value.tableRef.style.width = minTableWidth.value + 'px'
433
+ lastCell.value.cell.style.width = ''
434
+
435
+ const newLastCellWidth = Math.floor(lastCell.value.cell.offsetWidth)
436
+ calculatedColumnSizing.value[lastCellId] = newLastCellWidth
437
+ lastCell.value.cell.style.width = newLastCellWidth + 'px'
438
+ }
439
+
340
440
  return {
341
441
  cells,
342
442
  tableElement,
@@ -350,6 +450,8 @@ export function useResizeColumns() {
350
450
  resetCells,
351
451
  setInitialColumnWidths,
352
452
  setProvidedCellWidths,
453
+ setColumnWidthsOnColumnVisibilityChange,
454
+ setColumnWidthsOnWindowResize,
353
455
  isMouseDownOnHandler,
354
456
  isMouseUpOnHandler
355
457
  }