@stereopt/data-table 0.1.4 → 0.1.6

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
@@ -27,14 +27,105 @@ module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/dataTable/DataTable.tsx
29
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
30
39
  var import_jsx_runtime = require("react/jsx-runtime");
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
+ 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
+ }
116
+
117
+ // src/dataTable/DataTable.tsx
118
+ var import_jsx_runtime2 = require("react/jsx-runtime");
31
119
  function DataTable({ columns, data }) {
32
120
  const table = (0, import_react_table.useReactTable)({
33
121
  data,
34
122
  columns,
35
123
  getCoreRowModel: (0, import_react_table.getCoreRowModel)()
36
124
  });
37
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.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 bg-red-500", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Table, { children: [
126
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableHead, { children: "Head" }) }) }),
127
+ /* @__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" }) }) })
128
+ ] }) }) });
38
129
  }
39
130
  // Annotate the CommonJS export names for ESM import in node:
40
131
  0 && (module.exports = {
package/dist/index.js CHANGED
@@ -3,14 +3,105 @@ import {
3
3
  getCoreRowModel,
4
4
  useReactTable
5
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
6
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
+ function TableBody({ className, ...props }) {
44
+ return /* @__PURE__ */ jsx(
45
+ "tbody",
46
+ {
47
+ "data-slot": "table-body",
48
+ className: cn("[&_tr:last-child]:border-0", className),
49
+ ...props
50
+ }
51
+ );
52
+ }
53
+ function TableRow({ className, ...props }) {
54
+ return /* @__PURE__ */ jsx(
55
+ "tr",
56
+ {
57
+ "data-slot": "table-row",
58
+ className: cn(
59
+ "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
60
+ className
61
+ ),
62
+ ...props
63
+ }
64
+ );
65
+ }
66
+ function TableHead({ className, ...props }) {
67
+ return /* @__PURE__ */ jsx(
68
+ "th",
69
+ {
70
+ "data-slot": "table-head",
71
+ className: cn(
72
+ "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
73
+ className
74
+ ),
75
+ ...props
76
+ }
77
+ );
78
+ }
79
+ function TableCell({ className, ...props }) {
80
+ return /* @__PURE__ */ jsx(
81
+ "td",
82
+ {
83
+ "data-slot": "table-cell",
84
+ className: cn(
85
+ "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
86
+ className
87
+ ),
88
+ ...props
89
+ }
90
+ );
91
+ }
92
+
93
+ // src/dataTable/DataTable.tsx
94
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
7
95
  function DataTable({ columns, data }) {
8
96
  const table = useReactTable({
9
97
  data,
10
98
  columns,
11
99
  getCoreRowModel: getCoreRowModel()
12
100
  });
13
- return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(table, null, 2) }) }) });
101
+ 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: [
102
+ /* @__PURE__ */ jsx2(TableHeader, { children: /* @__PURE__ */ jsx2(TableRow, { children: /* @__PURE__ */ jsx2(TableHead, { children: "Head" }) }) }),
103
+ /* @__PURE__ */ jsx2(TableBody, { children: /* @__PURE__ */ jsx2(TableRow, { children: /* @__PURE__ */ jsx2(TableCell, { children: "Cell" }) }) })
104
+ ] }) }) });
14
105
  }
15
106
  export {
16
107
  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.4",
3
+ "version": "0.1.6",
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,10 +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"
55
58
  },
56
59
  "dependencies": {
57
- "@tanstack/react-table": "^8.21.3"
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"
58
66
  }
59
67
  }