@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.
@@ -69,6 +69,32 @@ function buildUniformItems(
69
69
  return items
70
70
  }
71
71
 
72
+ /**
73
+ * The window to render when no DOM measurement exists yet.
74
+ *
75
+ * The virtualizer learns its real `count` from an effect, and effects do not
76
+ * run during SSR - so on a server it still thinks `count` is 0 and returns an
77
+ * empty window. That is why `<SvGrid>` used to emit an empty `<tbody>`: the
78
+ * rows were in the row model, but nothing asked for them. Crawlers and no-JS
79
+ * clients saw an empty shell.
80
+ *
81
+ * Deliberately deterministic - anchored at index 0 with no scroll offset - so
82
+ * the server and the first client render produce identical markup and
83
+ * hydration does not mismatch. The measuring effect replaces it a tick later.
84
+ */
85
+ export function buildPreMeasureItems(
86
+ count: number,
87
+ estimateSize: number,
88
+ viewportHeight: number,
89
+ overscan: number,
90
+ ): Array<VirtualItem> {
91
+ if (count <= 0) return []
92
+ const size = Math.max(estimateSize, 1)
93
+ const visible = Math.ceil(Math.max(viewportHeight, 0) / size)
94
+ const endIndex = Math.min(visible + Math.max(overscan, 0), count - 1)
95
+ return buildUniformItems(0, Math.max(endIndex, 0), size)
96
+ }
97
+
72
98
  function buildVariableItems(
73
99
  startIndex: number,
74
100
  endIndex: number,