@omniviewdev/base-ui 0.2.1 → 0.2.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/dist/index.d.ts +9 -0
- package/dist/index.js +50 -30
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ import { Ref } from 'react';
|
|
|
69
69
|
import { RefAttributes } from 'react';
|
|
70
70
|
import { RefCallback } from 'react';
|
|
71
71
|
import { RefObject } from 'react';
|
|
72
|
+
import { Row } from '@tanstack/react-table';
|
|
72
73
|
import { RowSelectionState } from '@tanstack/react-table';
|
|
73
74
|
import { Select as Select_2 } from '@base-ui/react/select';
|
|
74
75
|
import { SelectArrowProps } from '@base-ui/react';
|
|
@@ -1482,6 +1483,14 @@ export declare interface DataTableVirtualBodyProps extends HTMLAttributes<HTMLTa
|
|
|
1482
1483
|
* to avoid forced reflow on mount — a significant perf win for large tables.
|
|
1483
1484
|
*/
|
|
1484
1485
|
fixedRowHeight?: boolean;
|
|
1486
|
+
/** Called when a row is clicked. Not called if a `getRowProps` onClick prevents default. */
|
|
1487
|
+
onRowClick?: (row: Row<any>, event: MouseEvent_2<HTMLTableRowElement>) => void;
|
|
1488
|
+
/**
|
|
1489
|
+
* Extra props for each `<tr>` (className, aria/data attributes, handlers).
|
|
1490
|
+
* Positioning styles and data attributes owned by the table take precedence.
|
|
1491
|
+
* Memoize it (e.g. `useCallback`): a new function re-renders every row.
|
|
1492
|
+
*/
|
|
1493
|
+
getRowProps?: (row: Row<any>) => HTMLAttributes<HTMLTableRowElement>;
|
|
1485
1494
|
}
|
|
1486
1495
|
|
|
1487
1496
|
/**
|
package/dist/index.js
CHANGED
|
@@ -31945,7 +31945,7 @@ const h1 = Gn(function({
|
|
|
31945
31945
|
...e,
|
|
31946
31946
|
...a
|
|
31947
31947
|
}, "data-ov-pinned": t.column.getIsPinned() || void 0, "data-ov-align": r, children: /* @__PURE__ */ h.jsx("span", { className: Me.CellContent, children: na(t.column.columnDef.cell, t.getContext()) }) });
|
|
31948
|
-
}, (n, t) => n.contentKey === t.contentKey);
|
|
31948
|
+
}, (n, t) => n.contentKey === t.contentKey && n.original === t.original && n.cell.column.columnDef.cell === t.cell.column.columnDef.cell);
|
|
31949
31949
|
h1.displayName = "DataTable.DataCell";
|
|
31950
31950
|
const Px = /* @__PURE__ */ new Set(["select"]);
|
|
31951
31951
|
function Bx({
|
|
@@ -31954,13 +31954,25 @@ function Bx({
|
|
|
31954
31954
|
stateRevision: a,
|
|
31955
31955
|
dataIndex: e,
|
|
31956
31956
|
rowHeight: o,
|
|
31957
|
-
measureRef: r
|
|
31957
|
+
measureRef: r,
|
|
31958
|
+
getRowProps: i,
|
|
31959
|
+
onRowClick: s
|
|
31958
31960
|
}) {
|
|
31959
31961
|
"use no memo";
|
|
31960
|
-
const
|
|
31961
|
-
|
|
31962
|
+
const l = n.getIsSelected(), c = n.getIsExpanded(), u = Y(null), d = (y) => {
|
|
31963
|
+
u.current = y, r?.(y);
|
|
31962
31964
|
};
|
|
31963
|
-
|
|
31965
|
+
u.current && (u.current.dataset.ovSelected = l ? "true" : "false", u.current.dataset.ovExpanded = c ? "true" : "false");
|
|
31966
|
+
const {
|
|
31967
|
+
className: p,
|
|
31968
|
+
style: g,
|
|
31969
|
+
onClick: f,
|
|
31970
|
+
...m
|
|
31971
|
+
} = i?.(n) ?? {}, b = f || s ? (y) => {
|
|
31972
|
+
f?.(y), y.defaultPrevented || s?.(n, y);
|
|
31973
|
+
} : void 0;
|
|
31974
|
+
return /* @__PURE__ */ h.jsx("tr", { ...m, "data-index": e, ref: d, className: j(Me.Row, p), "data-ov-selected": l ? "true" : "false", "data-ov-expanded": c ? "true" : "false", onClick: b, style: {
|
|
31975
|
+
...g,
|
|
31964
31976
|
display: "flex",
|
|
31965
31977
|
position: "absolute",
|
|
31966
31978
|
transform: `translateY(${t}px)`,
|
|
@@ -31969,47 +31981,55 @@ function Bx({
|
|
|
31969
31981
|
height: o,
|
|
31970
31982
|
overflow: "hidden"
|
|
31971
31983
|
}
|
|
31972
|
-
}, children: n.getVisibleCells().map((
|
|
31973
|
-
const
|
|
31974
|
-
return /* @__PURE__ */ h.jsx(h1, { cell:
|
|
31984
|
+
}, children: n.getVisibleCells().map((y) => {
|
|
31985
|
+
const v = Px.has(y.column.id) ? `${y.id}-${a}` : y.id;
|
|
31986
|
+
return /* @__PURE__ */ h.jsx(h1, { cell: y, contentKey: v, original: n.original }, y.id);
|
|
31975
31987
|
}) });
|
|
31976
31988
|
}
|
|
31977
|
-
const y1 = Gn(Bx, (n, t) => n.row === t.row && n.virtualStart === t.virtualStart && n.stateRevision === t.stateRevision && n.dataIndex === t.dataIndex && n.rowHeight === t.rowHeight);
|
|
31989
|
+
const y1 = Gn(Bx, (n, t) => n.row === t.row && n.virtualStart === t.virtualStart && n.stateRevision === t.stateRevision && n.dataIndex === t.dataIndex && n.rowHeight === t.rowHeight && n.columns === t.columns && n.getRowProps === t.getRowProps && n.onRowClick === t.onRowClick);
|
|
31978
31990
|
y1.displayName = "DataTable.VirtualRow";
|
|
31979
31991
|
const v1 = k(function({
|
|
31980
31992
|
className: t,
|
|
31981
31993
|
estimateRowSize: a = ZC,
|
|
31982
31994
|
overscan: e = QC,
|
|
31983
31995
|
fixedRowHeight: o = !1,
|
|
31984
|
-
|
|
31985
|
-
|
|
31996
|
+
onRowClick: r,
|
|
31997
|
+
getRowProps: i,
|
|
31998
|
+
...s
|
|
31999
|
+
}, l) {
|
|
31986
32000
|
"use no memo";
|
|
31987
32001
|
const {
|
|
31988
|
-
table:
|
|
31989
|
-
} = wn(),
|
|
31990
|
-
rows:
|
|
31991
|
-
} =
|
|
31992
|
-
|
|
32002
|
+
table: c
|
|
32003
|
+
} = wn(), u = nT(), {
|
|
32004
|
+
rows: d
|
|
32005
|
+
} = c.getRowModel(), p = Y(r);
|
|
32006
|
+
p.current = r;
|
|
32007
|
+
const g = r != null, f = ee(
|
|
32008
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32009
|
+
(v, S) => p.current?.(v, S),
|
|
32010
|
+
[]
|
|
32011
|
+
), m = Wm({
|
|
32012
|
+
count: d.length,
|
|
31993
32013
|
estimateSize: () => a,
|
|
31994
|
-
getScrollElement: () =>
|
|
31995
|
-
measureElement: o ? void 0 : typeof window < "u" && navigator.userAgent.indexOf("Firefox") === -1 ? (
|
|
32014
|
+
getScrollElement: () => u,
|
|
32015
|
+
measureElement: o ? void 0 : typeof window < "u" && navigator.userAgent.indexOf("Firefox") === -1 ? (v) => v.getBoundingClientRect().height : void 0,
|
|
31996
32016
|
overscan: e
|
|
31997
32017
|
});
|
|
31998
32018
|
pe(() => {
|
|
31999
|
-
|
|
32000
|
-
}, [
|
|
32001
|
-
const
|
|
32002
|
-
return
|
|
32019
|
+
m.measure();
|
|
32020
|
+
}, [d.length]);
|
|
32021
|
+
const b = c.getState().rowSelection, y = c.getState().expanded;
|
|
32022
|
+
return d.length === 0 ? null : /* @__PURE__ */ h.jsx("tbody", { ref: l, className: j(Me.Body, t), style: {
|
|
32003
32023
|
display: "grid",
|
|
32004
|
-
height: `${
|
|
32024
|
+
height: `${m.getTotalSize()}px`,
|
|
32005
32025
|
position: "relative"
|
|
32006
|
-
}, ...
|
|
32007
|
-
const
|
|
32008
|
-
if (!
|
|
32009
|
-
const
|
|
32010
|
-
return /* @__PURE__ */ h.jsx(y1, { row:
|
|
32011
|
-
|
|
32012
|
-
} },
|
|
32026
|
+
}, ...s, children: m.getVirtualItems().map((v) => {
|
|
32027
|
+
const S = d[v.index];
|
|
32028
|
+
if (!S) return null;
|
|
32029
|
+
const E = (b[S.id] ? 1 : 0) | (typeof y == "boolean" ? y ? 2 : 0 : y?.[S.id] ? 2 : 0);
|
|
32030
|
+
return /* @__PURE__ */ h.jsx(y1, { row: S, virtualStart: v.start, stateRevision: E, dataIndex: v.index, rowHeight: o ? a : void 0, columns: c.options.columns, getRowProps: i, onRowClick: g ? f : void 0, measureRef: o ? void 0 : (_) => {
|
|
32031
|
+
_ && m.measureElement(_);
|
|
32032
|
+
} }, S.id);
|
|
32013
32033
|
}) });
|
|
32014
32034
|
});
|
|
32015
32035
|
v1.displayName = "DataTable.VirtualBody";
|