vue2-excel-grid 2.6.4 → 2.6.6
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.
package/package.json
CHANGED
|
@@ -1273,10 +1273,13 @@ const ExcelGridComponent = {
|
|
|
1273
1273
|
* shrinking columns illegibly thin.
|
|
1274
1274
|
*
|
|
1275
1275
|
* Highest-priority width control: overrides `col.width` as an absolute
|
|
1276
|
-
* value, `autoWidth`,
|
|
1277
|
-
*
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1276
|
+
* value, `autoWidth`, and double-click auto-fit (still disabled while
|
|
1277
|
+
* this is on). Manual column resize (drag handle) IS allowed — dragging
|
|
1278
|
+
* a column's handle turns that column into a fixed px width, excluded
|
|
1279
|
+
* from the fit; the rest keep scaling proportionally to fill what's
|
|
1280
|
+
* left, which can reintroduce horizontal scroll if the fixed column(s)
|
|
1281
|
+
* alone exceed the viewport. Pinned columns count toward the fit too —
|
|
1282
|
+
* the goal is the whole row fitting, regardless of pin state.
|
|
1280
1283
|
* @type {Boolean}
|
|
1281
1284
|
* @default false
|
|
1282
1285
|
* @example
|
|
@@ -1648,6 +1651,13 @@ const ExcelGridComponent = {
|
|
|
1648
1651
|
// resized/auto-fit — see startColResize/autoFitColumn/_applyAutoWidth.
|
|
1649
1652
|
relativeColSpecs: {},
|
|
1650
1653
|
|
|
1654
|
+
// col.key → true, for columns manually resized while fitColumns is on.
|
|
1655
|
+
// Such a column becomes a fixed px width (excluded from the proportional
|
|
1656
|
+
// fit); the rest keep scaling among themselves to fill what's left — see
|
|
1657
|
+
// _applyFitColumns(). Keyed by col.key (not flat index) so it survives
|
|
1658
|
+
// column reorders, same convention as relativeColSpecs preservation.
|
|
1659
|
+
fitColumnsOverrides: {},
|
|
1660
|
+
|
|
1651
1661
|
// Row heights (row index → px)
|
|
1652
1662
|
rowHeights: {},
|
|
1653
1663
|
|
|
@@ -2438,6 +2448,7 @@ const ExcelGridComponent = {
|
|
|
2438
2448
|
|
|
2439
2449
|
fitColumns(v) {
|
|
2440
2450
|
if (v) {
|
|
2451
|
+
this.fitColumnsOverrides = {}
|
|
2441
2452
|
this._applyFitColumns()
|
|
2442
2453
|
} else {
|
|
2443
2454
|
// Back to normal per-column resolution (same as the columns
|
|
@@ -2452,6 +2463,7 @@ const ExcelGridComponent = {
|
|
|
2452
2463
|
})
|
|
2453
2464
|
this.colWidths = newColWidths
|
|
2454
2465
|
this.relativeColSpecs = newRelativeSpecs
|
|
2466
|
+
this.fitColumnsOverrides = {}
|
|
2455
2467
|
this._applyAutoWidth()
|
|
2456
2468
|
}
|
|
2457
2469
|
},
|
|
@@ -2482,8 +2494,17 @@ const ExcelGridComponent = {
|
|
|
2482
2494
|
// fitColumns is the highest-priority width control — it overrides
|
|
2483
2495
|
// even remembered manual-resize widths (keyToWidth above), so it
|
|
2484
2496
|
// deliberately does NOT participate in that preservation logic.
|
|
2497
|
+
// fitColumnsOverrides (per-column fixed-width overrides set by
|
|
2498
|
+
// manually resizing while fitColumns is on) IS preserved, by key,
|
|
2499
|
+
// dropping any keys that no longer exist in the new column set.
|
|
2485
2500
|
this.colWidths = {}
|
|
2486
2501
|
this.relativeColSpecs = {}
|
|
2502
|
+
const validKeys = new Set(this.leafCols.map(c => c.key))
|
|
2503
|
+
const newOverrides = {}
|
|
2504
|
+
Object.keys(this.fitColumnsOverrides).forEach(k => {
|
|
2505
|
+
if (validKeys.has(k)) newOverrides[k] = true
|
|
2506
|
+
})
|
|
2507
|
+
this.fitColumnsOverrides = newOverrides
|
|
2487
2508
|
this._applyFitColumns()
|
|
2488
2509
|
} else {
|
|
2489
2510
|
// Rebuild colWidths by new flat index, using col.key to look up saved widths
|
|
@@ -5921,9 +5942,12 @@ const ExcelGridComponent = {
|
|
|
5921
5942
|
// RESIZE (3.5)
|
|
5922
5943
|
// =========================================================
|
|
5923
5944
|
startColResize(e, ci) {
|
|
5924
|
-
// fitColumns
|
|
5925
|
-
//
|
|
5926
|
-
|
|
5945
|
+
// Under fitColumns, resizing a column turns IT into a fixed px
|
|
5946
|
+
// override (see commitResize/_applyFitColumns) — the rest keep
|
|
5947
|
+
// scaling proportionally to fill what's left, so this can reintroduce
|
|
5948
|
+
// horizontal scroll. That's an accepted tradeoff for letting a column
|
|
5949
|
+
// be pinned to an exact width while fitColumns is on.
|
|
5950
|
+
if (this.internalLocked) return
|
|
5927
5951
|
const rect = this.$refs.container.getBoundingClientRect()
|
|
5928
5952
|
this.resizing = {
|
|
5929
5953
|
active: true,
|
|
@@ -5995,6 +6019,11 @@ const ExcelGridComponent = {
|
|
|
5995
6019
|
if (this.resizing.type === 'col') {
|
|
5996
6020
|
this._cellStyleCache = Object.create(null)
|
|
5997
6021
|
const newSize = this.colWidths[this.resizing.index]
|
|
6022
|
+
if (this.fitColumns) {
|
|
6023
|
+
const col = this.leafCols[this.resizing.index]
|
|
6024
|
+
if (col) this.$set(this.fitColumnsOverrides, col.key, true)
|
|
6025
|
+
this._applyFitColumns()
|
|
6026
|
+
}
|
|
5998
6027
|
this.$emit('column-resize', { index: this.resizing.index, newSize })
|
|
5999
6028
|
} else {
|
|
6000
6029
|
this._rowStyleCache = Object.create(null)
|
|
@@ -6046,6 +6075,13 @@ const ExcelGridComponent = {
|
|
|
6046
6075
|
// naturalGridWidth's formula in reverse: that computed derives the
|
|
6047
6076
|
// grid's natural width FROM the column widths; this derives the column
|
|
6048
6077
|
// widths FROM the available width.
|
|
6078
|
+
//
|
|
6079
|
+
// Columns in fitColumnsOverrides (manually resized while fitColumns was
|
|
6080
|
+
// on — see commitResize) are excluded from the scaling pool and keep
|
|
6081
|
+
// their current colWidths px value untouched; the remaining columns
|
|
6082
|
+
// scale to fill whatever space is left after subtracting the overrides'
|
|
6083
|
+
// total width, which can go negative (horizontal scroll returns) if the
|
|
6084
|
+
// overrides alone exceed the available width.
|
|
6049
6085
|
_applyFitColumns() {
|
|
6050
6086
|
if (!this.fitColumns || !this.leafCols.length) return
|
|
6051
6087
|
const containerWidth = this._relativeWidthContainer
|
|
@@ -6056,15 +6092,22 @@ const ExcelGridComponent = {
|
|
|
6056
6092
|
|
|
6057
6093
|
const visible = []
|
|
6058
6094
|
let totalWeight = 0
|
|
6095
|
+
let overriddenWidth = 0
|
|
6059
6096
|
this.leafCols.forEach((col, ci) => {
|
|
6060
6097
|
if (this.isColHidden(ci)) return
|
|
6098
|
+
if (this.fitColumnsOverrides[col.key]) {
|
|
6099
|
+
const w = this.colWidths[ci] !== undefined ? this.colWidths[ci] : this.resolveColWidth(col.width, containerWidth)
|
|
6100
|
+
overriddenWidth += w
|
|
6101
|
+
return
|
|
6102
|
+
}
|
|
6061
6103
|
const w = this.resolveColWidth(col.width, containerWidth)
|
|
6062
6104
|
visible.push({ ci, weight: w })
|
|
6063
6105
|
totalWeight += w
|
|
6064
6106
|
})
|
|
6065
6107
|
if (!visible.length || totalWeight <= 0) return
|
|
6066
6108
|
|
|
6067
|
-
const
|
|
6109
|
+
const remaining = available - overriddenWidth
|
|
6110
|
+
const scale = remaining > 0 ? remaining / totalWeight : 0
|
|
6068
6111
|
visible.forEach(({ ci, weight }) => {
|
|
6069
6112
|
this.$set(this.colWidths, ci, Math.max(FIT_COLUMNS_MIN_WIDTH, weight * scale))
|
|
6070
6113
|
this.$delete(this.relativeColSpecs, ci)
|