@dynostack/react-grid 0.1.3 → 0.2.0
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 +172 -20
- package/dist/index.cjs +147 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -41
- package/dist/index.d.ts +103 -41
- package/dist/index.js +143 -32
- package/dist/index.js.map +1 -1
- package/dist/page.css +24 -0
- package/dist/styles.css +145 -46
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ A single `<DataTable />` component that gives you ag-grid–level functionality
|
|
|
26
26
|
- **Selection + bulk actions** — pinned `__select` column with select-all, clear, bulk delete
|
|
27
27
|
- **Expandable rows** — provide a `renderSubRow` panel or use TanStack's nested `getSubRows`
|
|
28
28
|
- **CSV / Excel export** — selection-aware (export selected vs. all)
|
|
29
|
-
- **Theming** —
|
|
29
|
+
- **Theming that just works** — shadcn-compatible CSS variables, automatic OS dark-mode follow, cascade-layered defaults that never overwrite your app theme, full-repaint moded presets (`violet`, `emerald`, `amber`, `rose`, `sky`, `slate`, …), `buildPreset(hue)` for custom hues, and `isolate` to opt out of inheriting the app theme
|
|
30
30
|
- **Density** — `compact` · `default` · `comfortable`
|
|
31
31
|
- **i18n / labels** — every visible string is overridable
|
|
32
32
|
- **Feature flags** — turn off any toolbar control or table capability with a single boolean
|
|
@@ -91,14 +91,44 @@ export default {
|
|
|
91
91
|
|
|
92
92
|
## Theme tokens
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
The grid is built on **shadcn/ui CSS variables**. It auto-adjusts to whatever theme your app already has:
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
| Your app has… | What you do | What you get |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| Nothing (bare React) | `import "@dynostack/react-grid/styles.css"` | Clean light theme, auto-switches to dark on OS preference. |
|
|
99
|
+
| shadcn/ui (default theme) | Nothing | Grid inherits your `:root` tokens automatically. |
|
|
100
|
+
| shadcn/ui with a custom theme (Stone / Zinc / your own hue) | Nothing | Grid picks up your custom tokens automatically. |
|
|
101
|
+
| Custom theme using shadcn token names | Nothing | Same as above. |
|
|
102
|
+
| Custom theme with non-shadcn names | Pass [`theme` prop](#theming) | Per-instance override mapped to shadcn vars. |
|
|
103
|
+
| Want one grid to ignore the app theme | Pass `isolate` | Grid uses bundled defaults regardless of `:root`. |
|
|
104
|
+
|
|
105
|
+
**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.
|
|
106
|
+
|
|
107
|
+
### Minimal install
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
// main.tsx — once per app
|
|
111
|
+
import "@dynostack/react-grid/styles.css"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Optional: extend the theme to the page
|
|
115
|
+
|
|
116
|
+
By default the grid only styles itself, not the surrounding page. If you want `<body>` to use the same background/foreground as the grid:
|
|
97
117
|
|
|
98
118
|
```ts
|
|
99
119
|
import "@dynostack/react-grid/styles.css"
|
|
120
|
+
import "@dynostack/react-grid/page.css" // optional
|
|
100
121
|
```
|
|
101
122
|
|
|
123
|
+
### Dark mode
|
|
124
|
+
|
|
125
|
+
| Mode | How to enable | Behavior |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| Follow OS | Default — no action required | Light by day, dark by night via `prefers-color-scheme`. |
|
|
128
|
+
| Force light | Add `class="light"` to `<html>` | Stays light regardless of OS. |
|
|
129
|
+
| Force dark | Add `class="dark"` to `<html>` | Stays dark regardless of OS. |
|
|
130
|
+
| Per-instance | `<DataTable theme={themePresets.violet}>` | Grid auto-flips light/dark inside the moded preset. |
|
|
131
|
+
|
|
102
132
|
Either way you can still override any token per-instance via the [`theme`](#theming) prop.
|
|
103
133
|
|
|
104
134
|
---
|
|
@@ -248,24 +278,12 @@ rollback, toast notifications, and validation.
|
|
|
248
278
|
|
|
249
279
|
## Theming
|
|
250
280
|
|
|
251
|
-
|
|
281
|
+
The `theme` prop accepts **two shapes**. Pick whichever fits your use case.
|
|
252
282
|
|
|
253
|
-
###
|
|
254
|
-
|
|
255
|
-
```tsx
|
|
256
|
-
import { DataTable, themePresets } from "@dynostack/react-grid"
|
|
257
|
-
|
|
258
|
-
<DataTable data={data} columns={columns} theme={themePresets.violet} />
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
Available presets: `light` · `dark` · `emerald` · `violet` · `amber`.
|
|
262
|
-
|
|
263
|
-
### Custom tokens
|
|
283
|
+
### Shape 1 — Flat tokens
|
|
264
284
|
|
|
265
285
|
```tsx
|
|
266
286
|
<DataTable
|
|
267
|
-
data={data}
|
|
268
|
-
columns={columns}
|
|
269
287
|
theme={{
|
|
270
288
|
primary: "oklch(0.6 0.2 200)",
|
|
271
289
|
primaryForeground: "oklch(1 0 0)",
|
|
@@ -276,16 +294,102 @@ Available presets: `light` · `dark` · `emerald` · `violet` · `amber`.
|
|
|
276
294
|
/>
|
|
277
295
|
```
|
|
278
296
|
|
|
279
|
-
|
|
297
|
+
All shadcn tokens are supported plus `radius` and `fontFamily`. Anything you omit falls through to whatever your app's `:root` provides.
|
|
298
|
+
|
|
299
|
+
### Shape 2 — Moded `{ light, dark }`
|
|
300
|
+
|
|
301
|
+
A moded theme repaints the whole table **and** auto-flips on dark mode (OS preference *or* a `.dark` ancestor):
|
|
302
|
+
|
|
303
|
+
```tsx
|
|
304
|
+
<DataTable
|
|
305
|
+
theme={{
|
|
306
|
+
light: { background: "oklch(0.99 0.005 285)", primary: "oklch(0.55 0.22 285)", /* … */ },
|
|
307
|
+
dark: { background: "oklch(0.16 0.012 285)", primary: "oklch(0.7 0.18 285)", /* … */ },
|
|
308
|
+
}}
|
|
309
|
+
/>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
The grid emits a tiny scoped `<style>` block that targets only this instance — multiple grids on the same page can wear different moded themes without interfering.
|
|
313
|
+
|
|
314
|
+
### Use a preset
|
|
315
|
+
|
|
316
|
+
Presets ship in **moded shape** — passing one repaints the entire table and follows dark mode automatically:
|
|
317
|
+
|
|
318
|
+
```tsx
|
|
319
|
+
import { DataTable, themePresets } from "@dynostack/react-grid"
|
|
320
|
+
|
|
321
|
+
<DataTable theme={themePresets.violet} />
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Available presets:
|
|
325
|
+
|
|
326
|
+
| Preset | Hue |
|
|
327
|
+
|---|---|
|
|
328
|
+
| `neutral` | Grayscale (default appearance) |
|
|
329
|
+
| `light` | Force light, no dark variant |
|
|
330
|
+
| `dark` | Force dark, no light variant |
|
|
331
|
+
| `violet` | 285° |
|
|
332
|
+
| `emerald` | 162° |
|
|
333
|
+
| `amber` | 65° |
|
|
334
|
+
| `rose` | 15° |
|
|
335
|
+
| `sky` | 235° |
|
|
336
|
+
| `slate` | 240° (low chroma) |
|
|
337
|
+
|
|
338
|
+
### Build a custom preset from a single hue
|
|
339
|
+
|
|
340
|
+
```tsx
|
|
341
|
+
import { DataTable, buildPreset } from "@dynostack/react-grid"
|
|
342
|
+
|
|
343
|
+
const teal = buildPreset(180) // hue only
|
|
344
|
+
const subtleTeal = buildPreset(180, 0.015) // hue + custom chroma
|
|
345
|
+
|
|
346
|
+
<DataTable theme={teal} />
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
`buildPreset(hue, chroma?)` returns a full `{ light, dark }` token set tinted around the given OKLCH hue.
|
|
280
350
|
|
|
281
351
|
### Compose with a preset
|
|
282
352
|
|
|
283
353
|
```tsx
|
|
284
354
|
<DataTable
|
|
285
|
-
theme={{
|
|
355
|
+
theme={{
|
|
356
|
+
...themePresets.violet,
|
|
357
|
+
light: { ...themePresets.violet.light, primary: "oklch(0.7 0.18 250)" },
|
|
358
|
+
}}
|
|
286
359
|
/>
|
|
287
360
|
```
|
|
288
361
|
|
|
362
|
+
### Isolate a grid from the app theme
|
|
363
|
+
|
|
364
|
+
When embedding inside a heavily-themed shell where you want the table to keep its own look:
|
|
365
|
+
|
|
366
|
+
```tsx
|
|
367
|
+
<DataTable isolate /* uses bundled neutral tokens, ignores app :root */ />
|
|
368
|
+
<DataTable isolate theme={themePresets.violet} /* isolated AND violet */ />
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Multiple grids, different themes
|
|
372
|
+
|
|
373
|
+
CSS variables are emitted on each table root, so this works:
|
|
374
|
+
|
|
375
|
+
```tsx
|
|
376
|
+
<DataTable theme={themePresets.violet} />
|
|
377
|
+
<DataTable theme={themePresets.emerald} />
|
|
378
|
+
<DataTable theme={{ primary: "oklch(0.6 0.2 200)" }} />
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Precedence summary
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
┌──────────────────────────────────────────────────────────┐
|
|
385
|
+
│ Inline style on the grid root (per-instance `theme`) │ ← highest
|
|
386
|
+
├──────────────────────────────────────────────────────────┤
|
|
387
|
+
│ Consumer's :root rules (shadcn, custom app CSS) │
|
|
388
|
+
├──────────────────────────────────────────────────────────┤
|
|
389
|
+
│ @layer dynostack-grid-defaults (bundled styles.css) │ ← lowest
|
|
390
|
+
└──────────────────────────────────────────────────────────┘
|
|
391
|
+
```
|
|
392
|
+
|
|
289
393
|
---
|
|
290
394
|
|
|
291
395
|
## Density
|
|
@@ -625,7 +729,8 @@ operations and only renders the returned page.
|
|
|
625
729
|
| `features` | `DataTableFeatures` | all on | Feature flags. |
|
|
626
730
|
| `labels` | `DataTableLabels` | English defaults | i18n labels. |
|
|
627
731
|
| `density` | `"compact" \| "default" \| "comfortable"` | `"default"` | Row density. |
|
|
628
|
-
| `theme` | `DataTableTheme` | inherits `:root` | Per-instance CSS-variable overrides.
|
|
732
|
+
| `theme` | `DataTableTheme` | inherits `:root` | Per-instance CSS-variable overrides. Accepts flat tokens **or** `{ light, dark }`. |
|
|
733
|
+
| `isolate` | `boolean` | `false` | Ignore the app's `:root` and render with bundled defaults. |
|
|
629
734
|
|
|
630
735
|
`TData` must extend `{ id: string \| number }`.
|
|
631
736
|
|
|
@@ -649,6 +754,53 @@ type DataTableDataSource<TData> = {
|
|
|
649
754
|
}
|
|
650
755
|
```
|
|
651
756
|
|
|
757
|
+
```ts
|
|
758
|
+
// Theme types
|
|
759
|
+
type DataTableTokens = {
|
|
760
|
+
background?: string
|
|
761
|
+
foreground?: string
|
|
762
|
+
card?: string
|
|
763
|
+
cardForeground?: string
|
|
764
|
+
popover?: string
|
|
765
|
+
popoverForeground?: string
|
|
766
|
+
primary?: string
|
|
767
|
+
primaryForeground?: string
|
|
768
|
+
secondary?: string
|
|
769
|
+
secondaryForeground?: string
|
|
770
|
+
muted?: string
|
|
771
|
+
mutedForeground?: string
|
|
772
|
+
accent?: string
|
|
773
|
+
accentForeground?: string
|
|
774
|
+
destructive?: string
|
|
775
|
+
destructiveForeground?: string
|
|
776
|
+
border?: string
|
|
777
|
+
input?: string
|
|
778
|
+
ring?: string
|
|
779
|
+
radius?: string
|
|
780
|
+
fontFamily?: string
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
type DataTableModedTheme = {
|
|
784
|
+
light?: DataTableTokens
|
|
785
|
+
dark?: DataTableTokens
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
type DataTableTheme = DataTableTokens | DataTableModedTheme
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
```ts
|
|
792
|
+
// Theme exports
|
|
793
|
+
import {
|
|
794
|
+
themePresets, // ready-made moded presets
|
|
795
|
+
buildPreset, // (hue, chroma?) => DataTableModedTheme
|
|
796
|
+
splitTheme, // (theme) => { light, dark }
|
|
797
|
+
tokensToStyle, // (tokens) => React.CSSProperties
|
|
798
|
+
tokensToCssBlock, // (tokens) => "var:val;var:val" string
|
|
799
|
+
ISOLATE_LIGHT_TOKENS,
|
|
800
|
+
ISOLATE_DARK_TOKENS,
|
|
801
|
+
} from "@dynostack/react-grid"
|
|
802
|
+
```
|
|
803
|
+
|
|
652
804
|
---
|
|
653
805
|
|
|
654
806
|
## Compatibility
|
package/dist/index.cjs
CHANGED
|
@@ -2026,57 +2026,148 @@ var TOKEN_TO_VAR = {
|
|
|
2026
2026
|
radius: "--radius",
|
|
2027
2027
|
fontFamily: "--font-family"
|
|
2028
2028
|
};
|
|
2029
|
-
function
|
|
2030
|
-
if (!theme) return
|
|
2029
|
+
function isModed(theme) {
|
|
2030
|
+
if (!theme) return false;
|
|
2031
|
+
return "light" in theme || "dark" in theme;
|
|
2032
|
+
}
|
|
2033
|
+
function tokensToStyle(tokens) {
|
|
2034
|
+
if (!tokens) return {};
|
|
2031
2035
|
const out = {};
|
|
2032
|
-
for (const [k, v] of Object.entries(
|
|
2036
|
+
for (const [k, v] of Object.entries(tokens)) {
|
|
2033
2037
|
if (v == null) continue;
|
|
2034
2038
|
const cssVar = TOKEN_TO_VAR[k];
|
|
2035
2039
|
if (cssVar) out[cssVar] = v;
|
|
2036
2040
|
}
|
|
2037
2041
|
return out;
|
|
2038
2042
|
}
|
|
2039
|
-
|
|
2043
|
+
function themeToStyle(theme) {
|
|
2044
|
+
if (!theme) return {};
|
|
2045
|
+
if (isModed(theme)) return tokensToStyle(theme.light);
|
|
2046
|
+
return tokensToStyle(theme);
|
|
2047
|
+
}
|
|
2048
|
+
function splitTheme(theme) {
|
|
2049
|
+
if (!theme) return { light: void 0, dark: void 0 };
|
|
2050
|
+
if (isModed(theme)) return { light: theme.light, dark: theme.dark };
|
|
2051
|
+
return { light: theme, dark: void 0 };
|
|
2052
|
+
}
|
|
2053
|
+
function buildPreset(hue, chroma = 0.03) {
|
|
2054
|
+
const c = chroma;
|
|
2055
|
+
return {
|
|
2056
|
+
light: {
|
|
2057
|
+
background: `oklch(0.99 ${c * 0.2} ${hue})`,
|
|
2058
|
+
foreground: `oklch(0.18 ${c * 1.2} ${hue})`,
|
|
2059
|
+
card: `oklch(1 0 0)`,
|
|
2060
|
+
cardForeground: `oklch(0.18 ${c * 1.2} ${hue})`,
|
|
2061
|
+
popover: `oklch(1 0 0)`,
|
|
2062
|
+
popoverForeground: `oklch(0.18 ${c * 1.2} ${hue})`,
|
|
2063
|
+
primary: `oklch(0.55 0.2 ${hue})`,
|
|
2064
|
+
primaryForeground: `oklch(0.99 0 0)`,
|
|
2065
|
+
secondary: `oklch(0.96 ${c} ${hue})`,
|
|
2066
|
+
secondaryForeground: `oklch(0.25 ${c * 2} ${hue})`,
|
|
2067
|
+
muted: `oklch(0.96 ${c} ${hue})`,
|
|
2068
|
+
mutedForeground: `oklch(0.5 ${c * 1.5} ${hue})`,
|
|
2069
|
+
accent: `oklch(0.94 ${c * 1.2} ${hue})`,
|
|
2070
|
+
accentForeground: `oklch(0.3 ${c * 3} ${hue})`,
|
|
2071
|
+
destructive: `oklch(0.577 0.245 27.325)`,
|
|
2072
|
+
destructiveForeground: `oklch(0.985 0 0)`,
|
|
2073
|
+
border: `oklch(0.9 ${c * 0.8} ${hue})`,
|
|
2074
|
+
input: `oklch(0.9 ${c * 0.8} ${hue})`,
|
|
2075
|
+
ring: `oklch(0.55 0.2 ${hue} / 0.5)`,
|
|
2076
|
+
radius: "0.625rem"
|
|
2077
|
+
},
|
|
2078
|
+
dark: {
|
|
2079
|
+
background: `oklch(0.16 ${c * 0.6} ${hue})`,
|
|
2080
|
+
foreground: `oklch(0.97 ${c * 0.2} ${hue})`,
|
|
2081
|
+
card: `oklch(0.21 ${c * 0.8} ${hue})`,
|
|
2082
|
+
cardForeground: `oklch(0.97 ${c * 0.2} ${hue})`,
|
|
2083
|
+
popover: `oklch(0.21 ${c * 0.8} ${hue})`,
|
|
2084
|
+
popoverForeground: `oklch(0.97 ${c * 0.2} ${hue})`,
|
|
2085
|
+
primary: `oklch(0.7 0.18 ${hue})`,
|
|
2086
|
+
primaryForeground: `oklch(0.16 ${c * 0.6} ${hue})`,
|
|
2087
|
+
secondary: `oklch(0.27 ${c * 0.8} ${hue})`,
|
|
2088
|
+
secondaryForeground: `oklch(0.97 ${c * 0.2} ${hue})`,
|
|
2089
|
+
muted: `oklch(0.27 ${c * 0.8} ${hue})`,
|
|
2090
|
+
mutedForeground: `oklch(0.7 ${c * 0.5} ${hue})`,
|
|
2091
|
+
accent: `oklch(0.3 ${c * 1.5} ${hue})`,
|
|
2092
|
+
accentForeground: `oklch(0.97 ${c * 0.2} ${hue})`,
|
|
2093
|
+
destructive: `oklch(0.577 0.245 27.325 / 0.6)`,
|
|
2094
|
+
destructiveForeground: `oklch(0.985 0 0)`,
|
|
2095
|
+
border: `oklch(0.27 ${c * 0.8} ${hue})`,
|
|
2096
|
+
input: `oklch(0.27 ${c * 0.8} ${hue})`,
|
|
2097
|
+
ring: `oklch(0.7 0.18 ${hue} / 0.5)`,
|
|
2098
|
+
radius: "0.625rem"
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
function tokensToCssBlock(tokens) {
|
|
2103
|
+
if (!tokens) return "";
|
|
2104
|
+
const parts = [];
|
|
2105
|
+
for (const [k, v] of Object.entries(tokens)) {
|
|
2106
|
+
if (v == null) continue;
|
|
2107
|
+
const cssVar = TOKEN_TO_VAR[k];
|
|
2108
|
+
if (cssVar) parts.push(`${cssVar}:${v}`);
|
|
2109
|
+
}
|
|
2110
|
+
return parts.join(";");
|
|
2111
|
+
}
|
|
2112
|
+
var neutral = {
|
|
2040
2113
|
light: {
|
|
2041
2114
|
background: "oklch(1 0 0)",
|
|
2042
2115
|
foreground: "oklch(0.145 0 0)",
|
|
2043
2116
|
card: "oklch(1 0 0)",
|
|
2044
2117
|
cardForeground: "oklch(0.145 0 0)",
|
|
2118
|
+
popover: "oklch(1 0 0)",
|
|
2119
|
+
popoverForeground: "oklch(0.145 0 0)",
|
|
2045
2120
|
primary: "oklch(0.205 0 0)",
|
|
2046
2121
|
primaryForeground: "oklch(0.985 0 0)",
|
|
2047
|
-
|
|
2122
|
+
secondary: "oklch(0.97 0 0)",
|
|
2123
|
+
secondaryForeground: "oklch(0.205 0 0)",
|
|
2124
|
+
muted: "oklch(0.97 0 0)",
|
|
2125
|
+
mutedForeground: "oklch(0.556 0 0)",
|
|
2126
|
+
accent: "oklch(0.97 0 0)",
|
|
2127
|
+
accentForeground: "oklch(0.205 0 0)",
|
|
2128
|
+
destructive: "oklch(0.577 0.245 27.325)",
|
|
2129
|
+
destructiveForeground: "oklch(0.985 0 0)",
|
|
2130
|
+
border: "oklch(0.922 0 0)",
|
|
2131
|
+
input: "oklch(0.922 0 0)",
|
|
2132
|
+
ring: "oklch(0.708 0 0)",
|
|
2133
|
+
radius: "0.625rem"
|
|
2048
2134
|
},
|
|
2049
2135
|
dark: {
|
|
2050
2136
|
background: "oklch(0.145 0 0)",
|
|
2051
2137
|
foreground: "oklch(0.985 0 0)",
|
|
2052
2138
|
card: "oklch(0.205 0 0)",
|
|
2053
2139
|
cardForeground: "oklch(0.985 0 0)",
|
|
2140
|
+
popover: "oklch(0.205 0 0)",
|
|
2141
|
+
popoverForeground: "oklch(0.985 0 0)",
|
|
2054
2142
|
primary: "oklch(0.985 0 0)",
|
|
2055
2143
|
primaryForeground: "oklch(0.205 0 0)",
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
accent: "oklch(0.94 0.04 285)",
|
|
2069
|
-
accentForeground: "oklch(0.3 0.12 285)",
|
|
2070
|
-
ring: "oklch(0.55 0.22 285 / 0.5)"
|
|
2071
|
-
},
|
|
2072
|
-
amber: {
|
|
2073
|
-
primary: "oklch(0.7 0.18 65)",
|
|
2074
|
-
primaryForeground: "oklch(0.2 0 0)",
|
|
2075
|
-
accent: "oklch(0.94 0.05 65)",
|
|
2076
|
-
accentForeground: "oklch(0.3 0.12 65)",
|
|
2077
|
-
ring: "oklch(0.7 0.18 65 / 0.5)"
|
|
2144
|
+
secondary: "oklch(0.269 0 0)",
|
|
2145
|
+
secondaryForeground: "oklch(0.985 0 0)",
|
|
2146
|
+
muted: "oklch(0.269 0 0)",
|
|
2147
|
+
mutedForeground: "oklch(0.708 0 0)",
|
|
2148
|
+
accent: "oklch(0.269 0 0)",
|
|
2149
|
+
accentForeground: "oklch(0.985 0 0)",
|
|
2150
|
+
destructive: "oklch(0.577 0.245 27.325 / 0.6)",
|
|
2151
|
+
destructiveForeground: "oklch(0.985 0 0)",
|
|
2152
|
+
border: "oklch(0.269 0 0)",
|
|
2153
|
+
input: "oklch(0.269 0 0)",
|
|
2154
|
+
ring: "oklch(0.439 0 0)",
|
|
2155
|
+
radius: "0.625rem"
|
|
2078
2156
|
}
|
|
2079
2157
|
};
|
|
2158
|
+
var themePresets = {
|
|
2159
|
+
neutral,
|
|
2160
|
+
light: { light: neutral.light },
|
|
2161
|
+
dark: { light: neutral.dark },
|
|
2162
|
+
violet: buildPreset(285),
|
|
2163
|
+
emerald: buildPreset(162),
|
|
2164
|
+
amber: buildPreset(65),
|
|
2165
|
+
rose: buildPreset(15),
|
|
2166
|
+
sky: buildPreset(235),
|
|
2167
|
+
slate: buildPreset(240, 0.015)
|
|
2168
|
+
};
|
|
2169
|
+
var ISOLATE_LIGHT_TOKENS = neutral.light;
|
|
2170
|
+
var ISOLATE_DARK_TOKENS = neutral.dark;
|
|
2080
2171
|
function getPinningStyles(column) {
|
|
2081
2172
|
const isPinned = column.getIsPinned();
|
|
2082
2173
|
if (!isPinned) return {};
|
|
@@ -2241,7 +2332,8 @@ function DataTable({
|
|
|
2241
2332
|
features,
|
|
2242
2333
|
labels: labelsProp,
|
|
2243
2334
|
density = "default",
|
|
2244
|
-
theme
|
|
2335
|
+
theme,
|
|
2336
|
+
isolate = false
|
|
2245
2337
|
}) {
|
|
2246
2338
|
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
2247
2339
|
const f = {
|
|
@@ -2257,7 +2349,20 @@ function DataTable({
|
|
|
2257
2349
|
reordering: features?.reordering ?? true,
|
|
2258
2350
|
pinning: features?.pinning ?? true
|
|
2259
2351
|
};
|
|
2260
|
-
const
|
|
2352
|
+
const rawInstanceId = react.useId();
|
|
2353
|
+
const instanceId = react.useMemo(
|
|
2354
|
+
() => `dyno-grid-${rawInstanceId.replace(/[^a-zA-Z0-9]/g, "")}`,
|
|
2355
|
+
[rawInstanceId]
|
|
2356
|
+
);
|
|
2357
|
+
const { lightStyle, darkCss } = react.useMemo(() => {
|
|
2358
|
+
const { light, dark } = splitTheme(theme);
|
|
2359
|
+
const lightTokens = isolate ? { ...ISOLATE_LIGHT_TOKENS, ...light ?? {} } : light;
|
|
2360
|
+
const darkTokens = isolate ? { ...ISOLATE_DARK_TOKENS, ...dark ?? light ?? {} } : dark;
|
|
2361
|
+
return {
|
|
2362
|
+
lightStyle: tokensToStyle(lightTokens),
|
|
2363
|
+
darkCss: darkTokens ? tokensToCssBlock(darkTokens) : null
|
|
2364
|
+
};
|
|
2365
|
+
}, [theme, isolate]);
|
|
2261
2366
|
const [sorting, setSorting] = react.useState([]);
|
|
2262
2367
|
const [columnFilters, setColumnFilters] = react.useState([]);
|
|
2263
2368
|
const [internalGlobalFilter, setInternalGlobalFilter] = react.useState("");
|
|
@@ -2636,13 +2741,19 @@ function DataTable({
|
|
|
2636
2741
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2637
2742
|
"div",
|
|
2638
2743
|
{
|
|
2744
|
+
"data-dyno-grid": instanceId,
|
|
2639
2745
|
className: cn(
|
|
2640
2746
|
"flex flex-col rounded-lg border bg-card text-card-foreground shadow-sm",
|
|
2641
2747
|
DENSITY_CLASS[density],
|
|
2642
2748
|
className
|
|
2643
2749
|
),
|
|
2644
|
-
style:
|
|
2750
|
+
style: lightStyle,
|
|
2645
2751
|
children: [
|
|
2752
|
+
darkCss && /* @__PURE__ */ jsxRuntime.jsxs("style", { children: [
|
|
2753
|
+
`@media (prefers-color-scheme: dark){[data-dyno-grid="${instanceId}"]{${darkCss}}}`,
|
|
2754
|
+
`.dark [data-dyno-grid="${instanceId}"]{${darkCss}}`,
|
|
2755
|
+
`[data-dyno-grid="${instanceId}"].dark{${darkCss}}`
|
|
2756
|
+
] }),
|
|
2646
2757
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2647
2758
|
DataTableToolbar,
|
|
2648
2759
|
{
|
|
@@ -2836,15 +2947,21 @@ exports.DataTablePagination = DataTablePagination;
|
|
|
2836
2947
|
exports.DataTableRowActions = DataTableRowActions;
|
|
2837
2948
|
exports.DataTableToolbar = DataTableToolbar;
|
|
2838
2949
|
exports.EditableCell = EditableCell;
|
|
2950
|
+
exports.ISOLATE_DARK_TOKENS = ISOLATE_DARK_TOKENS;
|
|
2951
|
+
exports.ISOLATE_LIGHT_TOKENS = ISOLATE_LIGHT_TOKENS;
|
|
2839
2952
|
exports.booleanFilterFn = booleanFilterFn;
|
|
2953
|
+
exports.buildPreset = buildPreset;
|
|
2840
2954
|
exports.dateFilterFn = dateFilterFn;
|
|
2841
2955
|
exports.exportToCsv = exportToCsv;
|
|
2842
2956
|
exports.exportToExcel = exportToExcel;
|
|
2843
2957
|
exports.isFilterActive = isFilterActive;
|
|
2844
2958
|
exports.numberFilterFn = numberFilterFn;
|
|
2845
2959
|
exports.setFilterFn = setFilterFn;
|
|
2960
|
+
exports.splitTheme = splitTheme;
|
|
2846
2961
|
exports.textFilterFn = textFilterFn;
|
|
2847
2962
|
exports.themePresets = themePresets;
|
|
2848
2963
|
exports.themeToStyle = themeToStyle;
|
|
2964
|
+
exports.tokensToCssBlock = tokensToCssBlock;
|
|
2965
|
+
exports.tokensToStyle = tokensToStyle;
|
|
2849
2966
|
//# sourceMappingURL=index.cjs.map
|
|
2850
2967
|
//# sourceMappingURL=index.cjs.map
|