@stereopt/data-table 0.1.3 → 0.1.5

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
@@ -26,12 +26,57 @@ __export(index_exports, {
26
26
  module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/dataTable/DataTable.tsx
29
+ var import_react_table = require("@tanstack/react-table");
30
+
31
+ // src/lib/utils.ts
32
+ var import_clsx = require("clsx");
33
+ var import_tailwind_merge = require("tailwind-merge");
34
+ function cn(...inputs) {
35
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
36
+ }
37
+
38
+ // src/components/ui/table.tsx
29
39
  var import_jsx_runtime = require("react/jsx-runtime");
30
- function DataTable({ data }) {
31
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
32
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: "Data Table" }),
33
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { children: JSON.stringify(data, null, 2) })
34
- ] });
40
+ function Table({ className, ...props }) {
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
42
+ "div",
43
+ {
44
+ "data-slot": "table-container",
45
+ className: "relative w-full overflow-x-auto",
46
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47
+ "table",
48
+ {
49
+ "data-slot": "table",
50
+ className: cn("w-full caption-bottom text-sm", className),
51
+ ...props
52
+ }
53
+ )
54
+ }
55
+ );
56
+ }
57
+ function TableHeader({ className, ...props }) {
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
+ "thead",
60
+ {
61
+ "data-slot": "table-header",
62
+ className: cn("[&_tr]:border-b", className),
63
+ ...props
64
+ }
65
+ );
66
+ }
67
+
68
+ // src/dataTable/DataTable.tsx
69
+ var import_jsx_runtime2 = require("react/jsx-runtime");
70
+ function DataTable({ columns, data }) {
71
+ const table = (0, import_react_table.useReactTable)({
72
+ data,
73
+ columns,
74
+ getCoreRowModel: (0, import_react_table.getCoreRowModel)()
75
+ });
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) })
79
+ ] }) }) });
35
80
  }
36
81
  // Annotate the CommonJS export names for ESM import in node:
37
82
  0 && (module.exports = {
package/dist/index.d.cts CHANGED
@@ -1,8 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ColumnDef } from '@tanstack/react-table';
2
3
 
3
4
  interface DataTableProps<TData, TValue> {
5
+ columns: ColumnDef<TData, TValue>[];
4
6
  data: TData[];
5
7
  }
6
- declare function DataTable<TData, TValue>({ data }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
8
+ declare function DataTable<TData, TValue>({ columns, data }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
7
9
 
8
10
  export { DataTable, type DataTableProps, DataTable as default };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ColumnDef } from '@tanstack/react-table';
2
3
 
3
4
  interface DataTableProps<TData, TValue> {
5
+ columns: ColumnDef<TData, TValue>[];
4
6
  data: TData[];
5
7
  }
6
- declare function DataTable<TData, TValue>({ data }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
8
+ declare function DataTable<TData, TValue>({ columns, data }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
7
9
 
8
10
  export { DataTable, type DataTableProps, DataTable as default };
package/dist/index.js CHANGED
@@ -1,10 +1,58 @@
1
1
  // src/dataTable/DataTable.tsx
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- function DataTable({ data }) {
4
- return /* @__PURE__ */ jsxs("div", { children: [
5
- /* @__PURE__ */ jsx("h1", { children: "Data Table" }),
6
- /* @__PURE__ */ jsx("pre", { children: JSON.stringify(data, null, 2) })
7
- ] });
2
+ import {
3
+ getCoreRowModel,
4
+ useReactTable
5
+ } from "@tanstack/react-table";
6
+
7
+ // src/lib/utils.ts
8
+ import { clsx } from "clsx";
9
+ import { twMerge } from "tailwind-merge";
10
+ function cn(...inputs) {
11
+ return twMerge(clsx(inputs));
12
+ }
13
+
14
+ // src/components/ui/table.tsx
15
+ import { jsx } from "react/jsx-runtime";
16
+ function Table({ className, ...props }) {
17
+ return /* @__PURE__ */ jsx(
18
+ "div",
19
+ {
20
+ "data-slot": "table-container",
21
+ className: "relative w-full overflow-x-auto",
22
+ children: /* @__PURE__ */ jsx(
23
+ "table",
24
+ {
25
+ "data-slot": "table",
26
+ className: cn("w-full caption-bottom text-sm", className),
27
+ ...props
28
+ }
29
+ )
30
+ }
31
+ );
32
+ }
33
+ function TableHeader({ className, ...props }) {
34
+ return /* @__PURE__ */ jsx(
35
+ "thead",
36
+ {
37
+ "data-slot": "table-header",
38
+ className: cn("[&_tr]:border-b", className),
39
+ ...props
40
+ }
41
+ );
42
+ }
43
+
44
+ // src/dataTable/DataTable.tsx
45
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
46
+ function DataTable({ columns, data }) {
47
+ const table = useReactTable({
48
+ data,
49
+ columns,
50
+ getCoreRowModel: getCoreRowModel()
51
+ });
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) })
55
+ ] }) }) });
8
56
  }
9
57
  export {
10
58
  DataTable,
@@ -0,0 +1,150 @@
1
+ /*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */
2
+ @layer properties;
3
+ .relative {
4
+ position: relative;
5
+ }
6
+ .table {
7
+ display: table;
8
+ }
9
+ .table-caption {
10
+ display: table-caption;
11
+ }
12
+ .table-cell {
13
+ display: table-cell;
14
+ }
15
+ .table-row {
16
+ display: table-row;
17
+ }
18
+ .w-full {
19
+ width: 100%;
20
+ }
21
+ .caption-bottom {
22
+ caption-side: bottom;
23
+ }
24
+ .overflow-hidden {
25
+ overflow: hidden;
26
+ }
27
+ .overflow-x-auto {
28
+ overflow-x: auto;
29
+ }
30
+ .border {
31
+ border-style: var(--tw-border-style);
32
+ border-width: 1px;
33
+ }
34
+ .border-t {
35
+ border-top-style: var(--tw-border-style);
36
+ border-top-width: 1px;
37
+ }
38
+ .border-b {
39
+ border-bottom-style: var(--tw-border-style);
40
+ border-bottom-width: 1px;
41
+ }
42
+ .bg-muted\/50 {
43
+ background-color: color-mix(in srgb, 0 0% 96.1% 50%, transparent);
44
+ @supports (color: color-mix(in lab, red, red)) {
45
+ background-color: color-mix(in oklab, var(--color-muted) 50%, transparent);
46
+ }
47
+ }
48
+ .text-left {
49
+ text-align: left;
50
+ }
51
+ .align-middle {
52
+ vertical-align: middle;
53
+ }
54
+ .whitespace-nowrap {
55
+ white-space: nowrap;
56
+ }
57
+ .text-foreground {
58
+ color: var(--color-foreground);
59
+ }
60
+ .text-muted-foreground {
61
+ color: var(--color-muted-foreground);
62
+ }
63
+ .transition-colors {
64
+ transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
65
+ transition-timing-function: var(--tw-ease, ease);
66
+ transition-duration: var(--tw-duration, 0s);
67
+ }
68
+ .hover\:bg-muted\/50 {
69
+ &:hover {
70
+ @media (hover: hover) {
71
+ background-color: color-mix(in srgb, 0 0% 96.1% 50%, transparent);
72
+ @supports (color: color-mix(in lab, red, red)) {
73
+ background-color: color-mix(in oklab, var(--color-muted) 50%, transparent);
74
+ }
75
+ }
76
+ }
77
+ }
78
+ .has-aria-expanded\:bg-muted\/50 {
79
+ &:has(*[aria-expanded="true"]) {
80
+ background-color: color-mix(in srgb, 0 0% 96.1% 50%, transparent);
81
+ @supports (color: color-mix(in lab, red, red)) {
82
+ background-color: color-mix(in oklab, var(--color-muted) 50%, transparent);
83
+ }
84
+ }
85
+ }
86
+ .data-\[state\=selected\]\:bg-muted {
87
+ &[data-state="selected"] {
88
+ background-color: var(--color-muted);
89
+ }
90
+ }
91
+ .\[\&_tr\]\:border-b {
92
+ & tr {
93
+ border-bottom-style: var(--tw-border-style);
94
+ border-bottom-width: 1px;
95
+ }
96
+ }
97
+ .\[\&_tr\:last-child\]\:border-0 {
98
+ & tr:last-child {
99
+ border-style: var(--tw-border-style);
100
+ border-width: 0px;
101
+ }
102
+ }
103
+ .\[\&\>tr\]\:last\:border-b-0 {
104
+ &>tr {
105
+ &:last-child {
106
+ border-bottom-style: var(--tw-border-style);
107
+ border-bottom-width: 0px;
108
+ }
109
+ }
110
+ }
111
+ :root, :host {
112
+ --color-foreground: 0 0% 3.6%;
113
+ --color-muted: 0 0% 96.1%;
114
+ --color-muted-foreground: 0 0% 45.1%;
115
+ }
116
+ @media (prefers-color-scheme: dark) {
117
+ :root {
118
+ --color-background: 0 0% 3.6%;
119
+ --color-foreground: 0 0% 98%;
120
+ --color-card: 0 0% 3.6%;
121
+ --color-card-foreground: 0 0% 98%;
122
+ --color-popover: 0 0% 3.6%;
123
+ --color-popover-foreground: 0 0% 98%;
124
+ --color-muted: 0 0% 14.9%;
125
+ --color-muted-foreground: 0 0% 63.9%;
126
+ --color-accent: 0 0% 98%;
127
+ --color-accent-foreground: 0 0% 9%;
128
+ --color-destructive: 0 62.8% 30.6%;
129
+ --color-destructive-foreground: 0 0% 98%;
130
+ --color-border: 0 0% 14.9%;
131
+ --color-input: 0 0% 14.9%;
132
+ --color-primary: 0 0% 98%;
133
+ --color-primary-foreground: 0 0% 9%;
134
+ --color-secondary: 0 0% 14.9%;
135
+ --color-secondary-foreground: 0 0% 98%;
136
+ --color-ring: 0 0% 83.1%;
137
+ }
138
+ }
139
+ @property --tw-border-style {
140
+ syntax: "*";
141
+ inherits: false;
142
+ initial-value: solid;
143
+ }
144
+ @layer properties {
145
+ @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
146
+ *, ::before, ::after, ::backdrop {
147
+ --tw-border-style: solid;
148
+ }
149
+ }
150
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stereopt/data-table",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Simple reusable React data table component",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -12,7 +12,8 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs",
14
14
  "default": "./dist/index.js"
15
- }
15
+ },
16
+ "./styles.css": "./dist/styles.css"
16
17
  },
17
18
  "files": [
18
19
  "dist"
@@ -22,7 +23,7 @@
22
23
  },
23
24
  "sideEffects": false,
24
25
  "scripts": {
25
- "build": "tsup src/index.ts --format esm,cjs --dts --external react,react-dom",
26
+ "build": "tsup src/index.ts --format esm,cjs --dts --external react,react-dom && postcss src/styles/globals.css -o dist/styles.css --minify",
26
27
  "clean": "rm -rf dist",
27
28
  "dev": "tsup src/index.ts --format esm,cjs --dts --watch --external react,react-dom",
28
29
  "prepare": "npm run clean && npm run build",
@@ -50,7 +51,17 @@
50
51
  "devDependencies": {
51
52
  "@types/react": "^19.2.14",
52
53
  "@types/react-dom": "^19.2.3",
54
+ "postcss-cli": "^11.0.1",
55
+ "tailwindcss": "^4.2.2",
53
56
  "tsup": "^8.5.1",
54
57
  "typescript": "^5.9.3"
58
+ },
59
+ "dependencies": {
60
+ "@tailwindcss/postcss": "^4.2.2",
61
+ "@tanstack/react-table": "^8.21.3",
62
+ "class-variance-authority": "^0.7.1",
63
+ "clsx": "^2.1.1",
64
+ "postcss": "^8.5.9",
65
+ "tailwind-merge": "^3.5.0"
55
66
  }
56
67
  }