@bysages/react 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/index.mjs +7 -4
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -3570,21 +3570,24 @@ function DataTable(rawProps) {
3570
3570
  const rows = table.getRowModel().rows;
3571
3571
  /** The declared row height is the density-scale baseline; the live
3572
3572
  * scale comes off the document so the virtual window matches what CSS
3573
- * actually renders. */
3574
- const densityScale = () => {
3573
+ * actually renders. It is read once and re-read only when the density
3574
+ * or scene attribute moves — estimateSize runs on every scroll frame. */
3575
+ let densityScale = 1;
3576
+ const readDensityScale = () => {
3575
3577
  const value = Number(getComputedStyle(document.documentElement).getPropertyValue("--bs-density-scale"));
3576
- return Number.isFinite(value) && value > 0 ? value : 1;
3578
+ densityScale = Number.isFinite(value) && value > 0 ? value : 1;
3577
3579
  };
3578
3580
  const virtualizer = useVirtualizer({
3579
3581
  count: rows.length,
3580
3582
  getScrollElement: () => viewport.current,
3581
- estimateSize: () => rowHeight * densityScale(),
3583
+ estimateSize: () => rowHeight * densityScale,
3582
3584
  getItemKey: (index) => rows[index]?.id ?? index,
3583
3585
  overscan: 8
3584
3586
  });
3585
3587
  const [, rerender] = useReducer((count) => count + 1, 0);
3586
3588
  useEffect(() => {
3587
3589
  if (!virtual) return;
3590
+ readDensityScale();
3588
3591
  const observer = new MutationObserver(rerender);
3589
3592
  observer.observe(document.documentElement, {
3590
3593
  attributes: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bysages/react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "By Sages Elements components for React — styled by the paper-and-ink design tokens",
5
5
  "keywords": [
6
6
  "accessible",
@@ -47,7 +47,7 @@
47
47
  "@tanstack/react-virtual": "3.14.13",
48
48
  "@zag-js/cascade-select": "1.44.0",
49
49
  "@zag-js/react": "1.44.0",
50
- "@bysages/core": "0.2.0"
50
+ "@bysages/core": "0.2.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@storybook/addon-a11y": "10.6.0",