@svgrid/grid 2.6.7 → 2.6.8
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/dist/SvGrid.controller.svelte.js +42 -11
- package/dist/cdn/{GridMenus-C7SFm3Dp.js → GridMenus-D3JbtKWp.js} +1 -1
- package/dist/cdn/{GridMenus-0i2QnChI.js → GridMenus-g9aHrUhs.js} +1 -1
- package/dist/cdn/{src-BkucJd50.js → src-B76QPix7.js} +2624 -2611
- package/dist/cdn/{src-V2_KUw2j.js → src-cKs_0jXV.js} +2726 -2713
- package/dist/cdn/svgrid.js +2 -2
- package/dist/cdn/svgrid.svelte-external.js +2 -2
- package/dist/virtualization/virtualizer.d.ts +14 -0
- package/dist/virtualization/virtualizer.js +21 -0
- package/package.json +1 -1
- package/src/SvGrid.controller.svelte.ts +50 -11
- package/src/virtualization/pre-measure.test.ts +65 -0
- package/src/virtualization/virtualizer.ts +26 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { applyGroupAggregate, applyRowPredicate, compileExcelFilter, getAdvancedFilterEngine, normalizeForFilter, createColumnVirtualizer, createCoreRowModel, createExpandedRowModel, createFilteredRowModel, createGroupedRowModel, createTreeRowModel, createSvelteVirtualizer, createSortedRowModel, createSvGrid, getGridCellDomId, sortFns, } from "./index";
|
|
2
2
|
import { createRowScrollScaling, resolveMaxDomHeight, } from "./virtualization/scroll-scaling";
|
|
3
|
+
import { buildPreMeasureItems } from "./virtualization/virtualizer";
|
|
3
4
|
import "./sv-grid-scrollbar";
|
|
4
5
|
import { computeColumnStat, formatsNeedingStats, formatNeedsStats, } from "./conditional-formatting";
|
|
5
6
|
import { rawToNumber, } from "./SvGrid.helpers";
|
|
@@ -1952,13 +1953,31 @@ export function createSvGridController(rawProps, domIdBase) {
|
|
|
1952
1953
|
});
|
|
1953
1954
|
const rowVirtualizationEnabled = $derived((props.virtualization ?? true) && allRows.length > 0);
|
|
1954
1955
|
const columnVirtualizationEnabled = $derived((props.columnVirtualization ?? true) && allColumns.length > 0);
|
|
1956
|
+
// Row height / viewport as they can be known WITHOUT measuring the DOM. Used
|
|
1957
|
+
// only for the pre-measurement window below; once the measuring effect runs,
|
|
1958
|
+
// the virtualizer's own (real) numbers take over.
|
|
1959
|
+
const preMeasureRowHeight = $derived(typeof props.rowHeight === "number" ? props.rowHeight : 30);
|
|
1960
|
+
const preMeasureViewport = $derived(typeof props.containerHeight === "number" ? props.containerHeight : 520);
|
|
1955
1961
|
const virtualRows = $derived.by(() => {
|
|
1956
1962
|
virtualizer.version;
|
|
1957
|
-
|
|
1963
|
+
const items = virtualizer.getVirtualItems();
|
|
1964
|
+
if (items.length || allRows.length === 0)
|
|
1965
|
+
return items;
|
|
1966
|
+
// No measurement yet. On a server that is permanent (effects never run), so
|
|
1967
|
+
// without this the grid emits an empty <tbody> and its content is invisible
|
|
1968
|
+
// to crawlers and no-JS clients. On the client this is the first render
|
|
1969
|
+
// only, and it matches what the server produced, so hydration is clean.
|
|
1970
|
+
return buildPreMeasureItems(allRows.length, preMeasureRowHeight, preMeasureViewport, props.overscan ?? 8);
|
|
1958
1971
|
});
|
|
1959
1972
|
const virtualRowTotalSize = $derived.by(() => {
|
|
1960
1973
|
virtualizer.version;
|
|
1961
|
-
|
|
1974
|
+
const size = virtualizer.getTotalSize();
|
|
1975
|
+
// Keep the scroll height honest during the pre-measurement render, so the
|
|
1976
|
+
// spacers below do not collapse the body to the height of one window.
|
|
1977
|
+
if (size === 0 && allRows.length > 0) {
|
|
1978
|
+
return allRows.length * preMeasureRowHeight;
|
|
1979
|
+
}
|
|
1980
|
+
return size;
|
|
1962
1981
|
});
|
|
1963
1982
|
const virtualRowStart = $derived.by(() => virtualRows[0]?.start ?? 0);
|
|
1964
1983
|
const virtualRowEnd = $derived.by(() => virtualRows[virtualRows.length - 1]?.end ?? 0);
|
|
@@ -2017,16 +2036,28 @@ export function createSvGridController(rawProps, domIdBase) {
|
|
|
2017
2036
|
columnVirtualizerVersion;
|
|
2018
2037
|
return columnVirtualizer.getTotalSize();
|
|
2019
2038
|
});
|
|
2039
|
+
/** Every column, laid out left to right. The non-virtualized layout, and the
|
|
2040
|
+
* fallback while no measurement exists. */
|
|
2041
|
+
const allColumnItems = () => {
|
|
2042
|
+
let start = 0;
|
|
2043
|
+
return allColumns.map((column, index) => {
|
|
2044
|
+
const size = getColumnWidth(column.id);
|
|
2045
|
+
const item = { index, key: index, size, start, end: start + size };
|
|
2046
|
+
start += size;
|
|
2047
|
+
return item;
|
|
2048
|
+
});
|
|
2049
|
+
};
|
|
2020
2050
|
const renderedColumnItems = $derived.by(() => {
|
|
2021
|
-
if (!columnVirtualizationEnabled)
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2051
|
+
if (!columnVirtualizationEnabled)
|
|
2052
|
+
return allColumnItems();
|
|
2053
|
+
// Column virtualization is ON by default and its virtualizer, like the row
|
|
2054
|
+
// one, only learns `count` from an effect - which never runs on a server.
|
|
2055
|
+
// Without this the server emitted rows containing no data cells. Render the
|
|
2056
|
+
// full set pre-measurement: it is what a crawler should see, it matches the
|
|
2057
|
+
// first client render so hydration is clean, and the real window replaces
|
|
2058
|
+
// it as soon as the measuring effect lands.
|
|
2059
|
+
if (virtualColumns.length === 0 && allColumns.length > 0)
|
|
2060
|
+
return allColumnItems();
|
|
2030
2061
|
// Pinned columns are position:sticky, so they only stay pinned while their
|
|
2031
2062
|
// cell is in the DOM. Plain column virtualization drops them once they leave
|
|
2032
2063
|
// the scroll window, and the pinned column vanishes. Because allColumns is
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kn as e, co as t, so as n } from "./src-
|
|
1
|
+
import { Kn as e, co as t, so as n } from "./src-cKs_0jXV.js";
|
|
2
2
|
import { b as r } from "./editor-registry-CiI0xlKg.js";
|
|
3
3
|
import { l as i } from "./SvDateTimePicker-DSUhIta8.js";
|
|
4
4
|
import * as a from "svelte/internal/client";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kn as e, co as t, so as n } from "./src-
|
|
1
|
+
import { Kn as e, co as t, so as n } from "./src-B76QPix7.js";
|
|
2
2
|
import { E as r, F as i, G as a, H as o, I as s, L as c, N as l, Q as u, U as d, V as f, X as p, Y as m, Z as h, _ as g, d as _, et as v, f as y, ft as b, g as x, h as S, j as C, k as w, lt as T, m as E, mt as D, nt as O, o as k, pt as A, st as j, t as M, tt as N, u as P, ut as F, v as I } from "./disclose-version-Dr7rEVv-.js";
|
|
3
3
|
import { b as ee } from "./editor-registry-CiI0xlKg.js";
|
|
4
4
|
import { l as te } from "./SvDateTimePicker-h9kPyszT.js";
|