Skip to content

Commit c662332

Browse files
authored
Merge pull request #20 from jacksonkasi1/dev
fix: @source CSS scanning + React dedupe + troubleshooting docs
2 parents e92e783 + efb2c99 commit c662332

File tree

7 files changed

+169
-115
lines changed

7 files changed

+169
-115
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ export function UsersPage() {
5656
}
5757
```
5858

59-
> **Tailwind CSS v4:** Add `@source "@tablecraft/table";` to your CSS file so Tailwind detects the utility classes used by the table components:
59+
> **Tailwind CSS v4:** Add the `@source` directive so Tailwind detects the utility classes used by the table components:
6060
> ```css
6161
> @import "tailwindcss";
62-
> @source "@tablecraft/table";
62+
> @source "../node_modules/@tablecraft/table/src";
6363
> ```
64+
> The path is relative to your CSS file — adjust if needed.
6465
6566
That's it! 🎉 No column definitions needed.
6667

apps/vite-web-example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@base-ui/react": "^1.1.0",
1414
"@fontsource-variable/inter": "^5.2.8",
1515
"@tablecraft/client": "^0.1.8",
16-
"@tablecraft/table": "^0.2.8",
16+
"@tablecraft/table": "^0.2.9",
1717
"@tailwindcss/vite": "^4.1.17",
1818
"@tanstack/react-query": "^5.62.8",
1919
"@tanstack/react-table": "^8.20.0",
@@ -50,4 +50,4 @@
5050
"typescript-eslint": "^8.46.4",
5151
"vite": "^7.2.4"
5252
}
53-
}
53+
}

apps/vite-web-example/src/index.css

Lines changed: 112 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,134 @@
11
@import "tailwindcss";
2-
@source "@tablecraft/table";
2+
@source "../node_modules/@tablecraft/table/src";
33
@import "tw-animate-css";
44
@import "shadcn/tailwind.css";
55
@import "@fontsource-variable/inter";
66

77
@custom-variant dark (&:is(.dark *));
88

99
:root {
10-
--background: oklch(1 0 0);
11-
--foreground: oklch(0.145 0 0);
12-
--card: oklch(1 0 0);
13-
--card-foreground: oklch(0.145 0 0);
14-
--popover: oklch(1 0 0);
15-
--popover-foreground: oklch(0.145 0 0);
16-
--primary: oklch(0.205 0 0);
17-
--primary-foreground: oklch(0.985 0 0);
18-
--secondary: oklch(0.97 0 0);
19-
--secondary-foreground: oklch(0.205 0 0);
20-
--muted: oklch(0.97 0 0);
21-
--muted-foreground: oklch(0.556 0 0);
22-
--accent: oklch(0.97 0 0);
23-
--accent-foreground: oklch(0.205 0 0);
24-
--destructive: oklch(0.58 0.22 27);
25-
--border: oklch(0.922 0 0);
26-
--input: oklch(0.922 0 0);
27-
--ring: oklch(0.708 0 0);
28-
--chart-1: oklch(0.809 0.105 251.813);
29-
--chart-2: oklch(0.623 0.214 259.815);
30-
--chart-3: oklch(0.546 0.245 262.881);
31-
--chart-4: oklch(0.488 0.243 264.376);
32-
--chart-5: oklch(0.424 0.199 265.638);
33-
--radius: 0.625rem;
34-
--sidebar: oklch(0.985 0 0);
35-
--sidebar-foreground: oklch(0.145 0 0);
36-
--sidebar-primary: oklch(0.205 0 0);
37-
--sidebar-primary-foreground: oklch(0.985 0 0);
38-
--sidebar-accent: oklch(0.97 0 0);
39-
--sidebar-accent-foreground: oklch(0.205 0 0);
40-
--sidebar-border: oklch(0.922 0 0);
41-
--sidebar-ring: oklch(0.708 0 0);
10+
--background: oklch(1 0 0);
11+
--foreground: oklch(0.145 0 0);
12+
--card: oklch(1 0 0);
13+
--card-foreground: oklch(0.145 0 0);
14+
--popover: oklch(1 0 0);
15+
--popover-foreground: oklch(0.145 0 0);
16+
--primary: oklch(0.205 0 0);
17+
--primary-foreground: oklch(0.985 0 0);
18+
--secondary: oklch(0.97 0 0);
19+
--secondary-foreground: oklch(0.205 0 0);
20+
--muted: oklch(0.97 0 0);
21+
--muted-foreground: oklch(0.556 0 0);
22+
--accent: oklch(0.97 0 0);
23+
--accent-foreground: oklch(0.205 0 0);
24+
--destructive: oklch(0.58 0.22 27);
25+
--border: oklch(0.922 0 0);
26+
--input: oklch(0.922 0 0);
27+
--ring: oklch(0.708 0 0);
28+
--chart-1: oklch(0.809 0.105 251.813);
29+
--chart-2: oklch(0.623 0.214 259.815);
30+
--chart-3: oklch(0.546 0.245 262.881);
31+
--chart-4: oklch(0.488 0.243 264.376);
32+
--chart-5: oklch(0.424 0.199 265.638);
33+
--radius: 0.625rem;
34+
--sidebar: oklch(0.985 0 0);
35+
--sidebar-foreground: oklch(0.145 0 0);
36+
--sidebar-primary: oklch(0.205 0 0);
37+
--sidebar-primary-foreground: oklch(0.985 0 0);
38+
--sidebar-accent: oklch(0.97 0 0);
39+
--sidebar-accent-foreground: oklch(0.205 0 0);
40+
--sidebar-border: oklch(0.922 0 0);
41+
--sidebar-ring: oklch(0.708 0 0);
4242
}
4343

4444
.dark {
45-
--background: oklch(0.145 0 0);
46-
--foreground: oklch(0.985 0 0);
47-
--card: oklch(0.205 0 0);
48-
--card-foreground: oklch(0.985 0 0);
49-
--popover: oklch(0.205 0 0);
50-
--popover-foreground: oklch(0.985 0 0);
51-
--primary: oklch(0.87 0.00 0);
52-
--primary-foreground: oklch(0.205 0 0);
53-
--secondary: oklch(0.269 0 0);
54-
--secondary-foreground: oklch(0.985 0 0);
55-
--muted: oklch(0.269 0 0);
56-
--muted-foreground: oklch(0.708 0 0);
57-
--accent: oklch(0.371 0 0);
58-
--accent-foreground: oklch(0.985 0 0);
59-
--destructive: oklch(0.704 0.191 22.216);
60-
--border: oklch(1 0 0 / 10%);
61-
--input: oklch(1 0 0 / 15%);
62-
--ring: oklch(0.556 0 0);
63-
--chart-1: oklch(0.809 0.105 251.813);
64-
--chart-2: oklch(0.623 0.214 259.815);
65-
--chart-3: oklch(0.546 0.245 262.881);
66-
--chart-4: oklch(0.488 0.243 264.376);
67-
--chart-5: oklch(0.424 0.199 265.638);
68-
--sidebar: oklch(0.205 0 0);
69-
--sidebar-foreground: oklch(0.985 0 0);
70-
--sidebar-primary: oklch(0.488 0.243 264.376);
71-
--sidebar-primary-foreground: oklch(0.985 0 0);
72-
--sidebar-accent: oklch(0.269 0 0);
73-
--sidebar-accent-foreground: oklch(0.985 0 0);
74-
--sidebar-border: oklch(1 0 0 / 10%);
75-
--sidebar-ring: oklch(0.556 0 0);
45+
--background: oklch(0.145 0 0);
46+
--foreground: oklch(0.985 0 0);
47+
--card: oklch(0.205 0 0);
48+
--card-foreground: oklch(0.985 0 0);
49+
--popover: oklch(0.205 0 0);
50+
--popover-foreground: oklch(0.985 0 0);
51+
--primary: oklch(0.87 0.00 0);
52+
--primary-foreground: oklch(0.205 0 0);
53+
--secondary: oklch(0.269 0 0);
54+
--secondary-foreground: oklch(0.985 0 0);
55+
--muted: oklch(0.269 0 0);
56+
--muted-foreground: oklch(0.708 0 0);
57+
--accent: oklch(0.371 0 0);
58+
--accent-foreground: oklch(0.985 0 0);
59+
--destructive: oklch(0.704 0.191 22.216);
60+
--border: oklch(1 0 0 / 10%);
61+
--input: oklch(1 0 0 / 15%);
62+
--ring: oklch(0.556 0 0);
63+
--chart-1: oklch(0.809 0.105 251.813);
64+
--chart-2: oklch(0.623 0.214 259.815);
65+
--chart-3: oklch(0.546 0.245 262.881);
66+
--chart-4: oklch(0.488 0.243 264.376);
67+
--chart-5: oklch(0.424 0.199 265.638);
68+
--sidebar: oklch(0.205 0 0);
69+
--sidebar-foreground: oklch(0.985 0 0);
70+
--sidebar-primary: oklch(0.488 0.243 264.376);
71+
--sidebar-primary-foreground: oklch(0.985 0 0);
72+
--sidebar-accent: oklch(0.269 0 0);
73+
--sidebar-accent-foreground: oklch(0.985 0 0);
74+
--sidebar-border: oklch(1 0 0 / 10%);
75+
--sidebar-ring: oklch(0.556 0 0);
7676
}
7777

7878
@theme inline {
79-
--font-sans: 'Inter Variable', sans-serif;
80-
--color-sidebar-ring: var(--sidebar-ring);
81-
--color-sidebar-border: var(--sidebar-border);
82-
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
83-
--color-sidebar-accent: var(--sidebar-accent);
84-
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
85-
--color-sidebar-primary: var(--sidebar-primary);
86-
--color-sidebar-foreground: var(--sidebar-foreground);
87-
--color-sidebar: var(--sidebar);
88-
--color-chart-5: var(--chart-5);
89-
--color-chart-4: var(--chart-4);
90-
--color-chart-3: var(--chart-3);
91-
--color-chart-2: var(--chart-2);
92-
--color-chart-1: var(--chart-1);
93-
--color-ring: var(--ring);
94-
--color-input: var(--input);
95-
--color-border: var(--border);
96-
--color-destructive: var(--destructive);
97-
--color-accent-foreground: var(--accent-foreground);
98-
--color-accent: var(--accent);
99-
--color-muted-foreground: var(--muted-foreground);
100-
--color-muted: var(--muted);
101-
--color-secondary-foreground: var(--secondary-foreground);
102-
--color-secondary: var(--secondary);
103-
--color-primary-foreground: var(--primary-foreground);
104-
--color-primary: var(--primary);
105-
--color-popover-foreground: var(--popover-foreground);
106-
--color-popover: var(--popover);
107-
--color-card-foreground: var(--card-foreground);
108-
--color-card: var(--card);
109-
--color-foreground: var(--foreground);
110-
--color-background: var(--background);
111-
--radius-sm: calc(var(--radius) - 4px);
112-
--radius-md: calc(var(--radius) - 2px);
113-
--radius-lg: var(--radius);
114-
--radius-xl: calc(var(--radius) + 4px);
115-
--radius-2xl: calc(var(--radius) + 8px);
116-
--radius-3xl: calc(var(--radius) + 12px);
117-
--radius-4xl: calc(var(--radius) + 16px);
79+
--font-sans: 'Inter Variable', sans-serif;
80+
--color-sidebar-ring: var(--sidebar-ring);
81+
--color-sidebar-border: var(--sidebar-border);
82+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
83+
--color-sidebar-accent: var(--sidebar-accent);
84+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
85+
--color-sidebar-primary: var(--sidebar-primary);
86+
--color-sidebar-foreground: var(--sidebar-foreground);
87+
--color-sidebar: var(--sidebar);
88+
--color-chart-5: var(--chart-5);
89+
--color-chart-4: var(--chart-4);
90+
--color-chart-3: var(--chart-3);
91+
--color-chart-2: var(--chart-2);
92+
--color-chart-1: var(--chart-1);
93+
--color-ring: var(--ring);
94+
--color-input: var(--input);
95+
--color-border: var(--border);
96+
--color-destructive: var(--destructive);
97+
--color-accent-foreground: var(--accent-foreground);
98+
--color-accent: var(--accent);
99+
--color-muted-foreground: var(--muted-foreground);
100+
--color-muted: var(--muted);
101+
--color-secondary-foreground: var(--secondary-foreground);
102+
--color-secondary: var(--secondary);
103+
--color-primary-foreground: var(--primary-foreground);
104+
--color-primary: var(--primary);
105+
--color-popover-foreground: var(--popover-foreground);
106+
--color-popover: var(--popover);
107+
--color-card-foreground: var(--card-foreground);
108+
--color-card: var(--card);
109+
--color-foreground: var(--foreground);
110+
--color-background: var(--background);
111+
--radius-sm: calc(var(--radius) - 4px);
112+
--radius-md: calc(var(--radius) - 2px);
113+
--radius-lg: var(--radius);
114+
--radius-xl: calc(var(--radius) + 4px);
115+
--radius-2xl: calc(var(--radius) + 8px);
116+
--radius-3xl: calc(var(--radius) + 12px);
117+
--radius-4xl: calc(var(--radius) + 16px);
118118
}
119119

120120
@layer base {
121121
* {
122122
@apply border-border outline-ring/50;
123-
}
123+
}
124+
124125
body {
125126
@apply font-sans bg-background text-foreground;
126-
}
127+
}
128+
127129
html {
128130
@apply font-sans;
129-
}
131+
}
130132
}
131133

132134
/* ------------------ TABLE STYLES ------------------ */
@@ -223,6 +225,7 @@ input[type="week"] {
223225

224226
/* Table column resizing styles - ENHANCED VERSION */
225227
@layer components {
228+
226229
/* Prevent layout shifts during resize */
227230
.resizable-table {
228231
table-layout: fixed;
@@ -271,6 +274,7 @@ input[type="week"] {
271274

272275
/* Custom cursor for column resizing */
273276
@layer components {
277+
274278
/* Better cursor for column resize */
275279
.cursor-col-resize {
276280
cursor: col-resize;
@@ -290,6 +294,7 @@ input[type="week"] {
290294

291295
/* Custom hover and interaction styles for the resizer */
292296
@layer components {
297+
293298
/* Resize handle hover effects */
294299
.resizable-table [data-resizing] {
295300
transition: opacity 0.15s ease, transform 0.1s ease;
@@ -314,4 +319,4 @@ input[type="week"] {
314319
opacity: 1 !important;
315320
color: var(--primary) !important;
316321
}
317-
}
322+
}

apps/vite-web-example/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export default defineConfig({
1010
alias: {
1111
"@": path.resolve(__dirname, "./src"),
1212
},
13+
dedupe: ["react", "react-dom"],
1314
},
1415
})

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/table/README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ If you're using **Tailwind CSS v4**, you need to add the `@source` directive so
4141

4242
```css
4343
@import "tailwindcss";
44-
@source "@tablecraft/table";
44+
@source "../node_modules/@tablecraft/table/src";
4545
```
4646

4747
This tells Tailwind to scan the package's source files for class names. Without it, the table component styles may not be generated correctly.
4848

49+
> **Note:** The path is relative to your CSS file. Adjust if your CSS file is in a different location.
50+
4951
## Features
5052

5153
- **Auto-generated columns** — Columns generated from your table config metadata
@@ -156,6 +158,51 @@ function UsersPage() {
156158
}
157159
```
158160

161+
## Troubleshooting
162+
163+
### "Invalid hook call" Error (Duplicate React)
164+
165+
If you see this error:
166+
167+
```
168+
Invalid hook call. Hooks can only be called inside of the body of a function component.
169+
You might have more than one copy of React in the same app.
170+
```
171+
172+
**Why it happens:** `@tablecraft/table` depends on packages like `@radix-ui/react-popover` which also depend on React. Some package managers may install a separate copy of React inside the package's own `node_modules`, causing two React instances to run at the same time — which breaks React hooks.
173+
174+
**Fix for Vite:**
175+
176+
```ts
177+
// vite.config.ts
178+
import { defineConfig } from "vite";
179+
180+
export default defineConfig({
181+
resolve: {
182+
dedupe: ["react", "react-dom"],
183+
},
184+
});
185+
```
186+
187+
**Fix for Webpack / Next.js:**
188+
189+
```js
190+
// next.config.js or webpack.config.js
191+
module.exports = {
192+
webpack: (config) => {
193+
config.resolve.alias = {
194+
...config.resolve.alias,
195+
react: require.resolve("react"),
196+
"react-dom": require.resolve("react-dom"),
197+
};
198+
return config;
199+
},
200+
};
201+
```
202+
203+
This forces your bundler to use a single copy of React across all dependencies.
204+
159205
## License
160206

161207
MIT
208+

0 commit comments

Comments
 (0)