@dynostack/react-grid 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -77,7 +77,28 @@ yarn add @dynostack/react-grid
77
77
 
78
78
  ## Tailwind setup
79
79
 
80
- The component ships Tailwind class names verbatim. Tell your Tailwind config to scan the package files:
80
+ The component ships Tailwind class names verbatim, so your Tailwind build needs to know two things:
81
+
82
+ 1. **Where to scan** for the class strings inside the bundle.
83
+ 2. **Which semantic color tokens** (`bg-popover`, `bg-card`, `text-foreground`, …) exist.
84
+
85
+ The package's `styles.css` registers the tokens for you via Tailwind v4's `@theme inline`. You only need to wire scanning.
86
+
87
+ ### Tailwind v4 — zero config
88
+
89
+ ```css
90
+ /* your global stylesheet (e.g. src/index.css) */
91
+ @import "tailwindcss";
92
+ @source "../node_modules/@dynostack/react-grid/dist";
93
+ @import "@dynostack/react-grid/styles.css";
94
+ @import "@dynostack/react-grid/page.css"; /* optional: extend tokens to <body> */
95
+ ```
96
+
97
+ That's the whole setup. No `tailwind.config.js`, no `@theme` block to copy-paste, no shadcn install required. Overlay surfaces (popovers, dropdowns, sheets, the row-actions menu) all render correctly out of the box.
98
+
99
+ ### Tailwind v3
100
+
101
+ v3 doesn't read CSS `@theme` directives, so the semantic-color mapping has to live in your `tailwind.config.js`. The shadcn install guide for v3 covers the exact `theme.extend.colors` block you need — copy that, plus add the package's `dist` to your `content` array:
81
102
 
82
103
  ```js
83
104
  // tailwind.config.{js,ts}
@@ -86,10 +107,28 @@ export default {
86
107
  "./src/**/*.{ts,tsx}",
87
108
  "./node_modules/@dynostack/react-grid/dist/**/*.{js,mjs,cjs}",
88
109
  ],
110
+ theme: {
111
+ extend: {
112
+ colors: {
113
+ // copy the shadcn v3 color mapping here
114
+ // (background, foreground, card, popover, primary, secondary,
115
+ // muted, accent, destructive, border, input, ring)
116
+ background: "hsl(var(--background))",
117
+ foreground: "hsl(var(--foreground))",
118
+ // … etc
119
+ },
120
+ },
121
+ },
89
122
  }
90
123
  ```
91
124
 
92
- > Tailwind v4? Add the same path to your `@source` directive instead.
125
+ Then import `styles.css` as usual:
126
+
127
+ ```ts
128
+ import "@dynostack/react-grid/styles.css"
129
+ ```
130
+
131
+ > Starting a new project? **Use Tailwind v4.** The v4 path above is meaningfully simpler — the package handles token registration for you.
93
132
 
94
133
  ## Theme tokens
95
134
 
@@ -104,15 +143,22 @@ The grid is built on **shadcn/ui CSS variables**. It auto-adjusts to whatever th
104
143
  | Custom theme with non-shadcn names | Pass [`theme` prop](#theming) | Per-instance override mapped to shadcn vars. |
105
144
  | Want one grid to ignore the app theme | Pass `isolate` | Grid uses bundled defaults regardless of `:root`. |
106
145
 
107
- **Why this just works.** The bundled `styles.css` declares its defaults inside the `dynostack-grid-defaults` cascade layer. Any unlayered consumer rule (which is where shadcn and most app CSS lives) automatically wins — import order doesn't matter, and you can't accidentally overwrite your app's theme by importing the grid's stylesheet.
146
+ **Why this just works.** The bundled `styles.css`:
108
147
 
109
- ### Minimal install
148
+ 1. **Registers Tailwind v4 utility tokens** via a top-level `@theme inline` block — so `bg-popover`, `text-foreground`, `border-border`, etc. resolve to your tokens without any consumer-side `@theme` block.
149
+ 2. **Declares variable values inside the `dynostack-grid-defaults` cascade layer** — any unlayered consumer rule (which is where shadcn and most app CSS lives) automatically wins, regardless of import order. You can't accidentally overwrite your app's theme by importing the grid's stylesheet.
110
150
 
111
- ```ts
112
- // main.tsx — once per app
113
- import "@dynostack/react-grid/styles.css"
151
+ ### Minimal install (Tailwind v4)
152
+
153
+ ```css
154
+ /* your global stylesheet */
155
+ @import "tailwindcss";
156
+ @source "../node_modules/@dynostack/react-grid/dist";
157
+ @import "@dynostack/react-grid/styles.css";
114
158
  ```
115
159
 
160
+ See the [Tailwind setup](#tailwind-setup) section for v3.
161
+
116
162
  ### Optional: extend the theme to the page
117
163
 
118
164
  By default the grid only styles itself, not the surrounding page. If you want `<body>` to use the same background/foreground as the grid:
package/dist/styles.css CHANGED
@@ -15,10 +15,12 @@
15
15
  * • shadcn-compatible: token names match shadcn/ui's CSS variables exactly,
16
16
  * so if you already have shadcn (or any compatible theme) defined on
17
17
  * :root, *that* takes precedence and the grid blends in automatically.
18
+ * • Tailwind v4 utility classes (`bg-popover`, `text-foreground`, etc.)
19
+ * resolve automatically — see the @theme block below.
18
20
  *
19
21
  * Cascade design
20
22
  * --------------
21
- * All declarations below live inside the `dynostack-grid-defaults` cascade
23
+ * All variable values live inside the `dynostack-grid-defaults` cascade
22
24
  * layer. Any *unlayered* declaration in the consumer app (which is where
23
25
  * shadcn and most app CSS lives) automatically wins, regardless of import
24
26
  * order. This makes import order non-fragile — you cannot accidentally
@@ -31,6 +33,54 @@
31
33
  * <lowest priority>
32
34
  */
33
35
 
36
+ /* ─── Tailwind v4 token registration ──────────────────────────────────
37
+ * Tells Tailwind v4 to generate `bg-popover`, `text-foreground`,
38
+ * `border-border`, `rounded-lg`, etc. utility classes that resolve to our
39
+ * CSS variables. Without this, the bundled `className` strings inside the
40
+ * grid have no corresponding CSS rules in zero-config v4 projects, and
41
+ * overlays render with transparent backgrounds.
42
+ *
43
+ * Must be declared at the top level — Tailwind v4 processes `@theme`
44
+ * before cascade layers apply, and `@theme` inside `@layer` is not valid.
45
+ *
46
+ * Safe across stacks:
47
+ * • Tailwind v4 → consumed normally, utilities generated.
48
+ * • Tailwind v3 → unknown at-rule, silently ignored. (v3 users still
49
+ * need to map semantic colors in tailwind.config.js;
50
+ * see README → Tailwind setup.)
51
+ * • Non-Tailwind → unknown at-rule, ignored.
52
+ * • shadcn consumer with their own @theme block → declarations merge.
53
+ * Since we use the same shadcn token names, the values are identical
54
+ * and there is no conflict.
55
+ * ─────────────────────────────────────────────────────────────────────── */
56
+ @theme inline {
57
+ --color-background: var(--background);
58
+ --color-foreground: var(--foreground);
59
+ --color-card: var(--card);
60
+ --color-card-foreground: var(--card-foreground);
61
+ --color-popover: var(--popover);
62
+ --color-popover-foreground: var(--popover-foreground);
63
+ --color-primary: var(--primary);
64
+ --color-primary-foreground: var(--primary-foreground);
65
+ --color-secondary: var(--secondary);
66
+ --color-secondary-foreground: var(--secondary-foreground);
67
+ --color-muted: var(--muted);
68
+ --color-muted-foreground: var(--muted-foreground);
69
+ --color-accent: var(--accent);
70
+ --color-accent-foreground: var(--accent-foreground);
71
+ --color-destructive: var(--destructive);
72
+ --color-destructive-foreground: var(--destructive-foreground);
73
+ --color-border: var(--border);
74
+ --color-input: var(--input);
75
+ --color-ring: var(--ring);
76
+
77
+ --radius-sm: calc(var(--radius) * 0.6);
78
+ --radius-md: calc(var(--radius) * 0.8);
79
+ --radius-lg: var(--radius);
80
+ --radius-xl: calc(var(--radius) * 1.4);
81
+ --radius-2xl: calc(var(--radius) * 1.8);
82
+ }
83
+
34
84
  @layer dynostack-grid-defaults {
35
85
  :root {
36
86
  color-scheme: light;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynostack/react-grid",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Enterprise-grade React DataGrid on TanStack + Radix + Tailwind, with operator-driven filters, inline editing, column pinning/resizing/reordering, CSV/Excel export, and full theme + i18n customization.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "wanted-coder-vijay <drop.at.vijay@gmail.com>",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "type": "module",
19
19
  "sideEffects": [
20
- "**/*.css"
20
+ "**/*.css"
21
21
  ],
22
22
  "main": "./dist/index.cjs",
23
23
  "module": "./dist/index.js",