UNPKG

@serendie/ui

Version:

Adaptive UI component library as part of Serendie Design System by Mitsubishi Electric

54 lines (53 loc) 1.47 kB
import { jsxs as M, jsx as l } from "react/jsx-runtime"; import { useReactTable as T } from "../../node_modules/@tanstack/react-table/build/lib/index.js"; import { useState as w } from "react"; import { DataTable as r } from "./index.js"; import { getSortedRowModel as S, getCoreRowModel as u } from "../../node_modules/@tanstack/table-core/build/lib/index.js"; function y({ className: s, enableRowSelection: m = !0, onRowSelectionChange: i, onSortingChange: t, state: e, ...R }) { const [b, f] = w({}), [p, n] = w([]), d = T({ getCoreRowModel: u(), getSortedRowModel: S(), enableRowSelection: m, ...R, state: { rowSelection: (e == null ? void 0 : e.rowSelection) ?? b, sorting: (e == null ? void 0 : e.sorting) ?? p, ...e }, onRowSelectionChange: (o) => { f(o), i == null || i(o); }, onSortingChange: (o) => { n(o), t == null || t(o); } }), c = m !== !1; return /* @__PURE__ */ M(r.Root, { className: s, children: [ /* @__PURE__ */ l(r.Thead, { children: d.getHeaderGroups().map((o) => /* @__PURE__ */ l( r.HeaderRow, { headerGroup: o, enableRowSelection: c, table: d }, o.id )) }), /* @__PURE__ */ l(r.Tbody, { children: d.getRowModel().rows.map((o) => /* @__PURE__ */ l( r.Row, { row: o, enableRowSelection: c }, o.id )) }) ] }); } export { y as DataTableComponent };