@serendie/ui
Version:
Adaptive UI component library as part of Serendie Design System by Mitsubishi Electric
58 lines (57 loc) • 1.54 kB
JavaScript
import { jsxs as p, jsx as l } from "react/jsx-runtime";
import { useReactTable as M } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
import { useState as f } from "react";
import { DataTable as r } from "./index.js";
import { getSortedRowModel as T, getCoreRowModel as S } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
function g({
className: s,
enableRowSelection: t = !0,
onRowSelectionChange: d,
onSortingChange: i,
state: e,
...c
}) {
const [R, n] = f({}), [u, b] = f([]), m = M({
getCoreRowModel: S(),
getSortedRowModel: T(),
enableRowSelection: t,
...c,
defaultColumn: {
size: void 0,
...c.defaultColumn
},
state: {
rowSelection: (e == null ? void 0 : e.rowSelection) ?? R,
sorting: (e == null ? void 0 : e.sorting) ?? u,
...e
},
onRowSelectionChange: (o) => {
n(o), d == null || d(o);
},
onSortingChange: (o) => {
b(o), i == null || i(o);
}
}), w = t !== !1;
return /* @__PURE__ */ p(r.Root, { className: s, children: [
/* @__PURE__ */ l(r.Thead, { children: m.getHeaderGroups().map((o) => /* @__PURE__ */ l(
r.HeaderRow,
{
headerGroup: o,
enableRowSelection: w,
table: m
},
o.id
)) }),
/* @__PURE__ */ l(r.Tbody, { children: m.getRowModel().rows.map((o) => /* @__PURE__ */ l(
r.Row,
{
row: o,
enableRowSelection: w
},
o.id
)) })
] });
}
export {
g as DataTableComponent
};