@stereopt/data-table 0.1.5 → 0.1.7

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.cjs CHANGED
@@ -64,6 +64,55 @@ function TableHeader({ className, ...props }) {
64
64
  }
65
65
  );
66
66
  }
67
+ function TableBody({ className, ...props }) {
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ "tbody",
70
+ {
71
+ "data-slot": "table-body",
72
+ className: cn("[&_tr:last-child]:border-0", className),
73
+ ...props
74
+ }
75
+ );
76
+ }
77
+ function TableRow({ className, ...props }) {
78
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
+ "tr",
80
+ {
81
+ "data-slot": "table-row",
82
+ className: cn(
83
+ "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
84
+ className
85
+ ),
86
+ ...props
87
+ }
88
+ );
89
+ }
90
+ function TableHead({ className, ...props }) {
91
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ "th",
93
+ {
94
+ "data-slot": "table-head",
95
+ className: cn(
96
+ "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
97
+ className
98
+ ),
99
+ ...props
100
+ }
101
+ );
102
+ }
103
+ function TableCell({ className, ...props }) {
104
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
105
+ "td",
106
+ {
107
+ "data-slot": "table-cell",
108
+ className: cn(
109
+ "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
110
+ className
111
+ ),
112
+ ...props
113
+ }
114
+ );
115
+ }
67
116
 
68
117
  // src/dataTable/DataTable.tsx
69
118
  var import_jsx_runtime2 = require("react/jsx-runtime");
@@ -73,9 +122,22 @@ function DataTable({ columns, data }) {
73
122
  columns,
74
123
  getCoreRowModel: (0, import_react_table.getCoreRowModel)()
75
124
  });
76
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "rounded-md border overflow-hidden bg-red-500", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Table, { children: [
77
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableHeader, { children: "Header Here" }),
78
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { children: JSON.stringify(table, null, 2) })
125
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "rounded-md border overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Table, { children: [
126
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableRow, { children: headerGroup.headers.map((header) => {
127
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
128
+ TableHead,
129
+ {
130
+ colSpan: header.colSpan,
131
+ style: { width: header.getSize() },
132
+ children: header.isPlaceholder ? null : (0, import_react_table.flexRender)(
133
+ header.column.columnDef.header,
134
+ header.getContext()
135
+ )
136
+ },
137
+ header.id
138
+ );
139
+ }) }, headerGroup.id)) }),
140
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableBody, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableCell, { children: "Cell" }) }) })
79
141
  ] }) }) });
80
142
  }
81
143
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/dataTable/DataTable.tsx
2
2
  import {
3
+ flexRender,
3
4
  getCoreRowModel,
4
5
  useReactTable
5
6
  } from "@tanstack/react-table";
@@ -40,6 +41,55 @@ function TableHeader({ className, ...props }) {
40
41
  }
41
42
  );
42
43
  }
44
+ function TableBody({ className, ...props }) {
45
+ return /* @__PURE__ */ jsx(
46
+ "tbody",
47
+ {
48
+ "data-slot": "table-body",
49
+ className: cn("[&_tr:last-child]:border-0", className),
50
+ ...props
51
+ }
52
+ );
53
+ }
54
+ function TableRow({ className, ...props }) {
55
+ return /* @__PURE__ */ jsx(
56
+ "tr",
57
+ {
58
+ "data-slot": "table-row",
59
+ className: cn(
60
+ "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
61
+ className
62
+ ),
63
+ ...props
64
+ }
65
+ );
66
+ }
67
+ function TableHead({ className, ...props }) {
68
+ return /* @__PURE__ */ jsx(
69
+ "th",
70
+ {
71
+ "data-slot": "table-head",
72
+ className: cn(
73
+ "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
74
+ className
75
+ ),
76
+ ...props
77
+ }
78
+ );
79
+ }
80
+ function TableCell({ className, ...props }) {
81
+ return /* @__PURE__ */ jsx(
82
+ "td",
83
+ {
84
+ "data-slot": "table-cell",
85
+ className: cn(
86
+ "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
87
+ className
88
+ ),
89
+ ...props
90
+ }
91
+ );
92
+ }
43
93
 
44
94
  // src/dataTable/DataTable.tsx
45
95
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
@@ -49,9 +99,22 @@ function DataTable({ columns, data }) {
49
99
  columns,
50
100
  getCoreRowModel: getCoreRowModel()
51
101
  });
52
- return /* @__PURE__ */ jsx2("div", { className: "w-full", children: /* @__PURE__ */ jsx2("div", { className: "rounded-md border overflow-hidden bg-red-500", children: /* @__PURE__ */ jsxs(Table, { children: [
53
- /* @__PURE__ */ jsx2(TableHeader, { children: "Header Here" }),
54
- /* @__PURE__ */ jsx2("pre", { children: JSON.stringify(table, null, 2) })
102
+ return /* @__PURE__ */ jsx2("div", { className: "w-full", children: /* @__PURE__ */ jsx2("div", { className: "rounded-md border overflow-hidden", children: /* @__PURE__ */ jsxs(Table, { children: [
103
+ /* @__PURE__ */ jsx2(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx2(TableRow, { children: headerGroup.headers.map((header) => {
104
+ return /* @__PURE__ */ jsx2(
105
+ TableHead,
106
+ {
107
+ colSpan: header.colSpan,
108
+ style: { width: header.getSize() },
109
+ children: header.isPlaceholder ? null : flexRender(
110
+ header.column.columnDef.header,
111
+ header.getContext()
112
+ )
113
+ },
114
+ header.id
115
+ );
116
+ }) }, headerGroup.id)) }),
117
+ /* @__PURE__ */ jsx2(TableBody, { children: /* @__PURE__ */ jsx2(TableRow, { children: /* @__PURE__ */ jsx2(TableCell, { children: "Cell" }) }) })
55
118
  ] }) }) });
56
119
  }
57
120
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stereopt/data-table",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Simple reusable React data table component",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",