vue2-excel-grid 2.11.1 → 2.11.2

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-excel-grid",
3
- "version": "2.11.1",
3
+ "version": "2.11.2",
4
4
  "description": "Excel-style grid component for Vue 2.6.14 with virtual scrolling",
5
5
  "license": "MIT",
6
6
  "author": "Fozilbek Raimberdiyev",
@@ -1172,7 +1172,7 @@ const ExcelGridComponent = {
1172
1172
  collapsedGroups: { type: Array, default: () => [] },
1173
1173
 
1174
1174
  /**
1175
- * Height of the grid container in px.
1175
+ * Height of the grid container in px (or a CSS length string like '100%').
1176
1176
  *
1177
1177
  * Omit it (or pass `null`) for auto-height: the grid sizes itself to fit
1178
1178
  * the header + filter row + all rows + footer for the current `data`
@@ -1182,9 +1182,9 @@ const ExcelGridComponent = {
1182
1182
  * window resize. Does not apply in fullscreen mode (already sized to the
1183
1183
  * viewport there) and does not include the toolbar's own height.
1184
1184
  *
1185
- * Pass an explicit `Number` to opt back into the old fixed-height behavior.
1185
+ * Pass an explicit `Number` or string to opt back into the fixed-height behavior.
1186
1186
  */
1187
- height: { type: Number, default: null },
1187
+ height: { type: [Number, String], default: null },
1188
1188
 
1189
1189
  /**
1190
1190
  * Width of the grid container (px or a CSS length string).
@@ -1692,6 +1692,10 @@ const ExcelGridComponent = {
1692
1692
  // macOS overlay scrollbars) — widthMode:'auto' adds it to the natural
1693
1693
  // width so the scrollbar never eats into the last column.
1694
1694
  vScrollbarW: 0,
1695
+ // Real horizontal-scrollbar height measured off the scroll body —
1696
+ // auto-height adds it to the content height so horizontal scroll never
1697
+ // eats into the row height.
1698
+ hScrollbarH: 0,
1695
1699
  // .eg-shell's horizontal border total (border-box). Measured at mount —
1696
1700
  // themes can restyle it — so widthMode:'auto' accounts for it instead
1697
1701
  // of shaving those pixels off the last column.
@@ -1978,18 +1982,26 @@ const ExcelGridComponent = {
1978
1982
  return buildCumulativeHeights(this.totalRows, this._rowH, this.rowHeights, this.hiddenRowSet, ROW_LIST_EDGE_PAD, ROW_LIST_EDGE_PAD)
1979
1983
  },
1980
1984
 
1981
- // height prop omitted → fit header + filter row + all (visible) rows + footer exactly.
1985
+ // height prop omitted → fit header + filter row + all (visible) rows + footer + horizontal scrollbar exactly.
1982
1986
  _autoContentHeight() {
1983
1987
  const headerH = this._headerRowH * this.headerDepth + this._filterRowH
1984
1988
  const bodyH = this.cumulativeHeights[this.totalRows] || 0
1985
1989
  const footerH = this.hasFooter ? this._footerRowH : 0
1986
- return headerH + bodyH + footerH
1990
+ const scrollH = this.hScrollbarH || 0
1991
+ return headerH + bodyH + footerH + scrollH
1987
1992
  },
1988
1993
 
1989
1994
  // Resolved grid-area height: explicit `height` prop wins as-is (old
1990
1995
  // behavior); omitted → auto-fit content, capped at 70% of the viewport.
1991
1996
  effectiveHeight() {
1992
- if (this.height != null) return this.height
1997
+ if (this.height != null) {
1998
+ if (typeof this.height === 'number') return this.height
1999
+ if (typeof this.height === 'string') {
2000
+ const parsed = parseFloat(this.height)
2001
+ if (!isNaN(parsed) && !this.height.endsWith('%')) return parsed
2002
+ return null
2003
+ }
2004
+ }
1993
2005
  return Math.min(this._autoContentHeight, this.windowInnerH * 0.7)
1994
2006
  },
1995
2007
 
@@ -2147,9 +2159,12 @@ const ExcelGridComponent = {
2147
2159
  userSelect: 'none'
2148
2160
  }
2149
2161
  }
2162
+ const isPercentHeight = typeof this.height === 'string' && this.height.endsWith('%')
2150
2163
  const style = {
2151
2164
  width: this._hostWidth,
2152
- height: this.effectiveHeight + 'px',
2165
+ height: isPercentHeight ? this.height : (this.effectiveHeight ? (this.effectiveHeight + 'px') : 'auto'),
2166
+ flex: '1 1 auto',
2167
+ minHeight: 0,
2153
2168
  position: 'relative',
2154
2169
  outline: 'none',
2155
2170
  userSelect: 'none'
@@ -2165,6 +2180,9 @@ const ExcelGridComponent = {
2165
2180
  display: 'flex',
2166
2181
  flexDirection: 'column'
2167
2182
  }
2183
+ if (typeof this.height === 'string' && this.height.endsWith('%')) {
2184
+ style.height = this.height
2185
+ }
2168
2186
  // The cap that keeps a too-wide column set at the host's edge
2169
2187
  // (internal horizontal scroll takes over from there).
2170
2188
  if (this.widthMode === 'auto') style.maxWidth = '100%'
@@ -2266,28 +2284,20 @@ const ExcelGridComponent = {
2266
2284
  position: 'relative'
2267
2285
  }
2268
2286
  }
2269
- // Fixed/auto height: an explicit px height (matching _containerH()'s
2270
- // non-fullscreen formula) instead of flex:1 growth. flex:1 here only
2271
- // ever has ONE sibling competing for space mathematically, so it
2272
- // should be exact — but nested flex cross-axis stretch (this box's
2273
- // height flows down to .eg-scroll-body/.eg-row-header-col via
2274
- // align-items:stretch) is vulnerable to sub-pixel rounding between
2275
- // browser-rendered header/footer row heights and the integer px
2276
- // this component assumes, occasionally landing 1px short. That 1px
2277
- // shortfall is enough to make .eg-scroll-body's overflow:auto show a
2278
- // vertical scrollbar even when content should fit exactly (reported
2279
- // with a single data row and no `height` prop — content height ==
2280
- // container height, so any shortfall trips overflow instantly).
2281
- // flex: '0 0 auto' overrides the .eg-body-area class rule's own
2282
- // `flex: 1` (flex-basis: 0%) — with a non-auto flex-basis, flexbox
2283
- // ignores this element's own `height` entirely for main-axis sizing,
2284
- // so basis must explicitly go back to `auto` for `height` to apply.
2285
- const h = this.effectiveHeight - (this._headerRowH * this.headerDepth) - this._filterRowH - (this.hasFooter ? this._footerRowH : 0)
2287
+ // Fixed/auto height: flex: '1 1 auto' with minHeight & height pinned to
2288
+ // the minimum content height. Setting minHeight prevents subpixel rounding
2289
+ // from ever landing 1px short (avoiding phantom vertical scrollbars on
2290
+ // single-row auto-height grids), while flex-grow: 1 allows the body area to
2291
+ // expand when the wrapper/shell provides additional vertical space (e.g.
2292
+ // on mobile or responsive layouts).
2293
+ const baseH = this.effectiveHeight || 0
2294
+ const h = Math.max(0, baseH - (this._headerRowH * this.headerDepth) - this._filterRowH - (this.hasFooter ? this._footerRowH : 0))
2286
2295
  return {
2287
2296
  display: 'flex',
2288
2297
  flexDirection: 'row',
2289
- flex: '0 0 auto',
2290
- height: Math.max(h, 0) + 'px',
2298
+ flex: '1 1 auto',
2299
+ minHeight: h + 'px',
2300
+ height: h + 'px',
2291
2301
  position: 'relative'
2292
2302
  }
2293
2303
  },
@@ -2403,6 +2413,7 @@ const ExcelGridComponent = {
2403
2413
  flexShrink: 0,
2404
2414
  position: 'sticky',
2405
2415
  bottom: 0,
2416
+ marginTop: 'auto',
2406
2417
  zIndex: 30,
2407
2418
  background: 'var(--eg-color-footer-bg, var(--eg-color-footer-bg-default))',
2408
2419
  // box-shadow (not a real border, like .eg-header-area's own
@@ -2924,25 +2935,20 @@ const ExcelGridComponent = {
2924
2935
  // =========================================================
2925
2936
  // VIRTUAL SCROLL
2926
2937
  // =========================================================
2927
- // In fullscreen, .eg-scroll-body's real height comes from flexbox filling
2928
- // the viewport (which can be far taller than the `height` prop the host
2929
- // originally passed for the fixed-size layout) — measure it directly
2930
- // instead of trusting `height`, otherwise virtual scroll only ever
2931
- // renders enough rows for the old fixed size, leaving the rest of the
2932
- // (visually stretched) container blank.
2933
2938
  _containerH() {
2934
- if (this.isFullscreen && this.$refs.scrollBody) return this.$refs.scrollBody.clientHeight
2939
+ if ((this.isFullscreen || this.height == null) && this.$refs.scrollBody && this.$refs.scrollBody.clientHeight > 0) {
2940
+ return this.$refs.scrollBody.clientHeight
2941
+ }
2935
2942
  const footerH = this.hasFooter ? this._footerRowH : 0
2936
- return this.effectiveHeight - (this._headerRowH * this.headerDepth) - this._filterRowH - footerH
2943
+ const baseH = this.effectiveHeight || 0
2944
+ return Math.max(0, baseH - (this._headerRowH * this.headerDepth) - this._filterRowH - footerH)
2937
2945
  },
2938
2946
 
2939
- // Same fullscreen-aware measurement as _containerH(), but mirrors PageUp/
2940
- // PageDown's pre-existing (footer-agnostic) row-span formula exactly for
2941
- // the non-fullscreen case, so normal-mode behavior is unchanged.
2947
+ // Same height measurement as _containerH() for accurate PageUp/PageDown paging.
2942
2948
  _pageRowSpan() {
2943
- const h = this.isFullscreen && this.$refs.scrollBody
2949
+ const h = (this.isFullscreen || this.height == null) && this.$refs.scrollBody && this.$refs.scrollBody.clientHeight > 0
2944
2950
  ? this.$refs.scrollBody.clientHeight
2945
- : (this.effectiveHeight - this._headerRowH * this.headerDepth - this._filterRowH)
2951
+ : ((this.effectiveHeight || 0) - this._headerRowH * this.headerDepth - this._filterRowH)
2946
2952
  return Math.floor(h / this._rowH)
2947
2953
  },
2948
2954
 
@@ -3037,6 +3043,8 @@ const ExcelGridComponent = {
3037
3043
  }
3038
3044
  const sbw = el.offsetWidth - el.clientWidth
3039
3045
  if (sbw >= 0 && sbw !== this.vScrollbarW) this.vScrollbarW = sbw
3046
+ const sbh = el.offsetHeight - el.clientHeight
3047
+ if (sbh >= 0 && sbh !== this.hScrollbarH) this.hScrollbarH = sbh
3040
3048
  // Shell border total (see naturalGridWidth) — offsetWidth-clientWidth
3041
3049
  // is exactly the horizontal borders here (the shell itself never scrolls).
3042
3050
  const shell = this.$el
@@ -3044,9 +3052,8 @@ const ExcelGridComponent = {
3044
3052
  const bw = shell.offsetWidth - shell.clientWidth
3045
3053
  if (bw >= 0 && bw !== this.shellBorderW) this.shellBorderW = bw
3046
3054
  }
3047
- // Window resize while fullscreen changes the real available row-viewport
3055
+ // Window resize while fullscreen or auto-height changes the real available row-viewport
3048
3056
  // height too (see _containerH()) — recompute which rows are rendered.
3049
- // Same for auto-height (height prop omitted): the 70vh cap just moved.
3050
3057
  if (this.isFullscreen || this.height == null) this.updateVirtualScroll()
3051
3058
  },
3052
3059