@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/dist/index.d.cts CHANGED
@@ -30,7 +30,7 @@ declare function DataTableRowActions<TData>({ row, actions, customActions, onAct
30
30
  * values are emitted as inline CSS variables on the table root, scoped
31
31
  * through CSS cascade to that instance only.
32
32
  */
33
- type DataTableTheme = {
33
+ type DataTableTokens = {
34
34
  background?: string;
35
35
  foreground?: string;
36
36
  card?: string;
@@ -55,51 +55,90 @@ type DataTableTheme = {
55
55
  /** Font family for the table body. */
56
56
  fontFamily?: string;
57
57
  };
58
- /** Convert a DataTableTheme into a `style` object of CSS variables. */
58
+ /**
59
+ * A theme passed to `<DataTable theme={…}>`.
60
+ *
61
+ * Two accepted shapes:
62
+ *
63
+ * 1. A flat token map (`DataTableTokens`) — applied as-is, no dark variant.
64
+ * 2. A moded map (`DataTableModedTheme`) — `light` is applied by default,
65
+ * `dark` is swapped in automatically inside `@media (prefers-color-scheme: dark)`
66
+ * *and* inside any `.dark` ancestor.
67
+ */
68
+ type DataTableModedTheme = {
69
+ light?: DataTableTokens;
70
+ dark?: DataTableTokens;
71
+ };
72
+ type DataTableTheme = DataTableTokens | DataTableModedTheme;
73
+ /** Convert a DataTableTokens map into a CSS `style` object. */
74
+ declare function tokensToStyle(tokens?: DataTableTokens): CSSProperties;
75
+ /**
76
+ * Back-compat: original API accepted a flat `DataTableTheme`. Still works,
77
+ * but if a moded theme is passed it returns the `light` variant only — use
78
+ * `splitTheme` if you need both variants.
79
+ */
59
80
  declare function themeToStyle(theme?: DataTableTheme): CSSProperties;
60
- /** A handful of ready-to-use theme presets. */
81
+ /**
82
+ * Split a theme into its `light` (always applied) and optional `dark` (applied
83
+ * via `@media (prefers-color-scheme: dark)` and `.dark` ancestor) variants.
84
+ *
85
+ * For flat themes, returns `{ light: theme, dark: undefined }`.
86
+ */
87
+ declare function splitTheme(theme?: DataTableTheme): {
88
+ light: DataTableTokens | undefined;
89
+ dark: DataTableTokens | undefined;
90
+ };
91
+ /**
92
+ * Build a full light+dark token set from a single OKLCH hue.
93
+ *
94
+ * @param hue Hue angle 0–360 (e.g. 285 for violet, 162 for emerald).
95
+ * @param chroma Optional base chroma for tinted neutrals (default 0.03).
96
+ */
97
+ declare function buildPreset(hue: number, chroma?: number): DataTableModedTheme;
98
+ /**
99
+ * Convert a tokens map into a CSS declaration string (no selector, no braces),
100
+ * e.g. `--background:oklch(1 0 0);--foreground:oklch(0.145 0 0)`.
101
+ *
102
+ * Used internally to inject scoped <style> blocks for moded themes.
103
+ */
104
+ declare function tokensToCssBlock(tokens?: DataTableTokens): string;
105
+ /**
106
+ * Ready-to-use theme presets.
107
+ *
108
+ * Each preset is a full light + dark token set — passing one to
109
+ * `<DataTable theme={…}>` repaints the entire table and auto-flips on OS
110
+ * dark mode (or when a `.dark` ancestor is added).
111
+ *
112
+ * Custom hues:
113
+ *
114
+ * ```ts
115
+ * import { buildPreset } from "@dynostack/react-grid"
116
+ * const tealPreset = buildPreset(180)
117
+ * ```
118
+ */
61
119
  declare const themePresets: {
120
+ neutral: DataTableModedTheme;
62
121
  light: {
63
- background: string;
64
- foreground: string;
65
- card: string;
66
- cardForeground: string;
67
- primary: string;
68
- primaryForeground: string;
69
- border: string;
122
+ light: DataTableTokens | undefined;
70
123
  };
71
124
  dark: {
72
- background: string;
73
- foreground: string;
74
- card: string;
75
- cardForeground: string;
76
- primary: string;
77
- primaryForeground: string;
78
- border: string;
79
- };
80
- emerald: {
81
- primary: string;
82
- primaryForeground: string;
83
- accent: string;
84
- accentForeground: string;
85
- ring: string;
86
- };
87
- violet: {
88
- primary: string;
89
- primaryForeground: string;
90
- accent: string;
91
- accentForeground: string;
92
- ring: string;
93
- };
94
- amber: {
95
- primary: string;
96
- primaryForeground: string;
97
- accent: string;
98
- accentForeground: string;
99
- ring: string;
125
+ light: DataTableTokens | undefined;
100
126
  };
127
+ violet: DataTableModedTheme;
128
+ emerald: DataTableModedTheme;
129
+ amber: DataTableModedTheme;
130
+ rose: DataTableModedTheme;
131
+ sky: DataTableModedTheme;
132
+ slate: DataTableModedTheme;
101
133
  };
102
134
  type DataTableThemeName = keyof typeof themePresets;
135
+ /**
136
+ * Bundled fallback tokens used when `<DataTable isolate>` is set. These let
137
+ * the grid render correctly even when the consumer hasn't imported
138
+ * `styles.css` or provided any theme of their own.
139
+ */
140
+ declare const ISOLATE_LIGHT_TOKENS: DataTableTokens;
141
+ declare const ISOLATE_DARK_TOKENS: DataTableTokens;
103
142
 
104
143
  type CellEditorType = "text" | "number" | "currency" | "date" | "select" | "switch" | "checkbox";
105
144
  type FilterType = "text" | "number" | "select" | "multi-select" | "boolean" | "date";
@@ -253,12 +292,35 @@ type DataTableProps<TData extends {
253
292
  labels?: DataTableLabels;
254
293
  /** Row + cell padding density. Defaults to "default". */
255
294
  density?: DataTableDensity;
256
- /** CSS-variable overrides (shadcn-compatible) scoped to this instance. */
295
+ /**
296
+ * CSS-variable overrides (shadcn-compatible) scoped to this instance.
297
+ *
298
+ * Two accepted shapes:
299
+ *
300
+ * theme={{ primary: "...", accent: "..." }} // flat tokens
301
+ * theme={{ light: { ... }, dark: { ... } }} // moded — auto-flips
302
+ *
303
+ * Moded themes apply `light` always and swap to `dark` inside
304
+ * `@media (prefers-color-scheme: dark)` *and* inside any `.dark` ancestor.
305
+ *
306
+ * Use `themePresets.violet` (or any preset) for a ready-made moded theme.
307
+ */
257
308
  theme?: DataTableTheme;
309
+ /**
310
+ * When `true`, the grid does NOT inherit CSS variables from the app's
311
+ * `:root` (shadcn, custom theme, etc.). Instead it renders with the
312
+ * package's bundled defaults (or whatever you pass via `theme`).
313
+ *
314
+ * Useful when embedding the grid inside a heavily-themed shell where you
315
+ * want the table to keep its own look regardless of surrounding context.
316
+ *
317
+ * Defaults to `false` (inherit app theme).
318
+ */
319
+ isolate?: boolean;
258
320
  };
259
321
  declare function DataTable<TData extends {
260
322
  id: string | number;
261
- }>({ data, columns, dataSource, isLoading, isFetching, onRefresh, totalRecords, exportFileName, enableSelection, renderSubRow, getSubRows, rowActions, customRowActions, onRowAction, onCellEdit, onRowSave, onAddRow, onBulkDelete, initialPageSize, pageSizeOptions, initialColumnPinning, initialColumnVisibility, globalFilter: globalFilterProp, onGlobalFilterChange, className, toolbarSlot, features, labels: labelsProp, density, theme, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
323
+ }>({ data, columns, dataSource, isLoading, isFetching, onRefresh, totalRecords, exportFileName, enableSelection, renderSubRow, getSubRows, rowActions, customRowActions, onRowAction, onCellEdit, onRowSave, onAddRow, onBulkDelete, initialPageSize, pageSizeOptions, initialColumnPinning, initialColumnVisibility, globalFilter: globalFilterProp, onGlobalFilterChange, className, toolbarSlot, features, labels: labelsProp, density, theme, isolate, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
262
324
 
263
325
  type Props$2<TData, TValue> = {
264
326
  column: Column<TData, TValue>;
@@ -350,4 +412,4 @@ declare function ColumnFilterPanel<TData, TValue>(props: CommonProps<TData, TVal
350
412
  declare function exportToCsv<TData>(table: Table<TData>, fileName?: string): void;
351
413
  declare function exportToExcel<TData>(table: Table<TData>, fileName?: string): void;
352
414
 
353
- export { type AdvFilter, type CellEditorType, ColumnFilterPanel, type Combine, type Condition, type CustomRowAction, DataTable, type DataTableColumn, DataTableColumnHeader, type DataTableDataSource, type DataTableDataSourceResult, type DataTableDensity, type DataTableErrorContext, type DataTableFeatures, type DataTableFetchParams, type DataTableLabels, DataTablePagination, type DataTableProps, DataTableRowActions, type DataTableRowActionsProps, type DataTableTheme, type DataTableThemeName, DataTableToolbar, type DateOp, EditableCell, type FilterType, type NumberOp, type RowAction, type RowActionId, type SelectOption, type SetFilter, type TextOp, booleanFilterFn, dateFilterFn, exportToCsv, exportToExcel, isFilterActive, numberFilterFn, setFilterFn, textFilterFn, themePresets, themeToStyle };
415
+ export { type AdvFilter, type CellEditorType, ColumnFilterPanel, type Combine, type Condition, type CustomRowAction, DataTable, type DataTableColumn, DataTableColumnHeader, type DataTableDataSource, type DataTableDataSourceResult, type DataTableDensity, type DataTableErrorContext, type DataTableFeatures, type DataTableFetchParams, type DataTableLabels, type DataTableModedTheme, DataTablePagination, type DataTableProps, DataTableRowActions, type DataTableRowActionsProps, type DataTableTheme, type DataTableThemeName, type DataTableTokens, DataTableToolbar, type DateOp, EditableCell, type FilterType, ISOLATE_DARK_TOKENS, ISOLATE_LIGHT_TOKENS, type NumberOp, type RowAction, type RowActionId, type SelectOption, type SetFilter, type TextOp, booleanFilterFn, buildPreset, dateFilterFn, exportToCsv, exportToExcel, isFilterActive, numberFilterFn, setFilterFn, splitTheme, textFilterFn, themePresets, themeToStyle, tokensToCssBlock, tokensToStyle };
package/dist/index.d.ts CHANGED
@@ -30,7 +30,7 @@ declare function DataTableRowActions<TData>({ row, actions, customActions, onAct
30
30
  * values are emitted as inline CSS variables on the table root, scoped
31
31
  * through CSS cascade to that instance only.
32
32
  */
33
- type DataTableTheme = {
33
+ type DataTableTokens = {
34
34
  background?: string;
35
35
  foreground?: string;
36
36
  card?: string;
@@ -55,51 +55,90 @@ type DataTableTheme = {
55
55
  /** Font family for the table body. */
56
56
  fontFamily?: string;
57
57
  };
58
- /** Convert a DataTableTheme into a `style` object of CSS variables. */
58
+ /**
59
+ * A theme passed to `<DataTable theme={…}>`.
60
+ *
61
+ * Two accepted shapes:
62
+ *
63
+ * 1. A flat token map (`DataTableTokens`) — applied as-is, no dark variant.
64
+ * 2. A moded map (`DataTableModedTheme`) — `light` is applied by default,
65
+ * `dark` is swapped in automatically inside `@media (prefers-color-scheme: dark)`
66
+ * *and* inside any `.dark` ancestor.
67
+ */
68
+ type DataTableModedTheme = {
69
+ light?: DataTableTokens;
70
+ dark?: DataTableTokens;
71
+ };
72
+ type DataTableTheme = DataTableTokens | DataTableModedTheme;
73
+ /** Convert a DataTableTokens map into a CSS `style` object. */
74
+ declare function tokensToStyle(tokens?: DataTableTokens): CSSProperties;
75
+ /**
76
+ * Back-compat: original API accepted a flat `DataTableTheme`. Still works,
77
+ * but if a moded theme is passed it returns the `light` variant only — use
78
+ * `splitTheme` if you need both variants.
79
+ */
59
80
  declare function themeToStyle(theme?: DataTableTheme): CSSProperties;
60
- /** A handful of ready-to-use theme presets. */
81
+ /**
82
+ * Split a theme into its `light` (always applied) and optional `dark` (applied
83
+ * via `@media (prefers-color-scheme: dark)` and `.dark` ancestor) variants.
84
+ *
85
+ * For flat themes, returns `{ light: theme, dark: undefined }`.
86
+ */
87
+ declare function splitTheme(theme?: DataTableTheme): {
88
+ light: DataTableTokens | undefined;
89
+ dark: DataTableTokens | undefined;
90
+ };
91
+ /**
92
+ * Build a full light+dark token set from a single OKLCH hue.
93
+ *
94
+ * @param hue Hue angle 0–360 (e.g. 285 for violet, 162 for emerald).
95
+ * @param chroma Optional base chroma for tinted neutrals (default 0.03).
96
+ */
97
+ declare function buildPreset(hue: number, chroma?: number): DataTableModedTheme;
98
+ /**
99
+ * Convert a tokens map into a CSS declaration string (no selector, no braces),
100
+ * e.g. `--background:oklch(1 0 0);--foreground:oklch(0.145 0 0)`.
101
+ *
102
+ * Used internally to inject scoped <style> blocks for moded themes.
103
+ */
104
+ declare function tokensToCssBlock(tokens?: DataTableTokens): string;
105
+ /**
106
+ * Ready-to-use theme presets.
107
+ *
108
+ * Each preset is a full light + dark token set — passing one to
109
+ * `<DataTable theme={…}>` repaints the entire table and auto-flips on OS
110
+ * dark mode (or when a `.dark` ancestor is added).
111
+ *
112
+ * Custom hues:
113
+ *
114
+ * ```ts
115
+ * import { buildPreset } from "@dynostack/react-grid"
116
+ * const tealPreset = buildPreset(180)
117
+ * ```
118
+ */
61
119
  declare const themePresets: {
120
+ neutral: DataTableModedTheme;
62
121
  light: {
63
- background: string;
64
- foreground: string;
65
- card: string;
66
- cardForeground: string;
67
- primary: string;
68
- primaryForeground: string;
69
- border: string;
122
+ light: DataTableTokens | undefined;
70
123
  };
71
124
  dark: {
72
- background: string;
73
- foreground: string;
74
- card: string;
75
- cardForeground: string;
76
- primary: string;
77
- primaryForeground: string;
78
- border: string;
79
- };
80
- emerald: {
81
- primary: string;
82
- primaryForeground: string;
83
- accent: string;
84
- accentForeground: string;
85
- ring: string;
86
- };
87
- violet: {
88
- primary: string;
89
- primaryForeground: string;
90
- accent: string;
91
- accentForeground: string;
92
- ring: string;
93
- };
94
- amber: {
95
- primary: string;
96
- primaryForeground: string;
97
- accent: string;
98
- accentForeground: string;
99
- ring: string;
125
+ light: DataTableTokens | undefined;
100
126
  };
127
+ violet: DataTableModedTheme;
128
+ emerald: DataTableModedTheme;
129
+ amber: DataTableModedTheme;
130
+ rose: DataTableModedTheme;
131
+ sky: DataTableModedTheme;
132
+ slate: DataTableModedTheme;
101
133
  };
102
134
  type DataTableThemeName = keyof typeof themePresets;
135
+ /**
136
+ * Bundled fallback tokens used when `<DataTable isolate>` is set. These let
137
+ * the grid render correctly even when the consumer hasn't imported
138
+ * `styles.css` or provided any theme of their own.
139
+ */
140
+ declare const ISOLATE_LIGHT_TOKENS: DataTableTokens;
141
+ declare const ISOLATE_DARK_TOKENS: DataTableTokens;
103
142
 
104
143
  type CellEditorType = "text" | "number" | "currency" | "date" | "select" | "switch" | "checkbox";
105
144
  type FilterType = "text" | "number" | "select" | "multi-select" | "boolean" | "date";
@@ -253,12 +292,35 @@ type DataTableProps<TData extends {
253
292
  labels?: DataTableLabels;
254
293
  /** Row + cell padding density. Defaults to "default". */
255
294
  density?: DataTableDensity;
256
- /** CSS-variable overrides (shadcn-compatible) scoped to this instance. */
295
+ /**
296
+ * CSS-variable overrides (shadcn-compatible) scoped to this instance.
297
+ *
298
+ * Two accepted shapes:
299
+ *
300
+ * theme={{ primary: "...", accent: "..." }} // flat tokens
301
+ * theme={{ light: { ... }, dark: { ... } }} // moded — auto-flips
302
+ *
303
+ * Moded themes apply `light` always and swap to `dark` inside
304
+ * `@media (prefers-color-scheme: dark)` *and* inside any `.dark` ancestor.
305
+ *
306
+ * Use `themePresets.violet` (or any preset) for a ready-made moded theme.
307
+ */
257
308
  theme?: DataTableTheme;
309
+ /**
310
+ * When `true`, the grid does NOT inherit CSS variables from the app's
311
+ * `:root` (shadcn, custom theme, etc.). Instead it renders with the
312
+ * package's bundled defaults (or whatever you pass via `theme`).
313
+ *
314
+ * Useful when embedding the grid inside a heavily-themed shell where you
315
+ * want the table to keep its own look regardless of surrounding context.
316
+ *
317
+ * Defaults to `false` (inherit app theme).
318
+ */
319
+ isolate?: boolean;
258
320
  };
259
321
  declare function DataTable<TData extends {
260
322
  id: string | number;
261
- }>({ data, columns, dataSource, isLoading, isFetching, onRefresh, totalRecords, exportFileName, enableSelection, renderSubRow, getSubRows, rowActions, customRowActions, onRowAction, onCellEdit, onRowSave, onAddRow, onBulkDelete, initialPageSize, pageSizeOptions, initialColumnPinning, initialColumnVisibility, globalFilter: globalFilterProp, onGlobalFilterChange, className, toolbarSlot, features, labels: labelsProp, density, theme, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
323
+ }>({ data, columns, dataSource, isLoading, isFetching, onRefresh, totalRecords, exportFileName, enableSelection, renderSubRow, getSubRows, rowActions, customRowActions, onRowAction, onCellEdit, onRowSave, onAddRow, onBulkDelete, initialPageSize, pageSizeOptions, initialColumnPinning, initialColumnVisibility, globalFilter: globalFilterProp, onGlobalFilterChange, className, toolbarSlot, features, labels: labelsProp, density, theme, isolate, }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
262
324
 
263
325
  type Props$2<TData, TValue> = {
264
326
  column: Column<TData, TValue>;
@@ -350,4 +412,4 @@ declare function ColumnFilterPanel<TData, TValue>(props: CommonProps<TData, TVal
350
412
  declare function exportToCsv<TData>(table: Table<TData>, fileName?: string): void;
351
413
  declare function exportToExcel<TData>(table: Table<TData>, fileName?: string): void;
352
414
 
353
- export { type AdvFilter, type CellEditorType, ColumnFilterPanel, type Combine, type Condition, type CustomRowAction, DataTable, type DataTableColumn, DataTableColumnHeader, type DataTableDataSource, type DataTableDataSourceResult, type DataTableDensity, type DataTableErrorContext, type DataTableFeatures, type DataTableFetchParams, type DataTableLabels, DataTablePagination, type DataTableProps, DataTableRowActions, type DataTableRowActionsProps, type DataTableTheme, type DataTableThemeName, DataTableToolbar, type DateOp, EditableCell, type FilterType, type NumberOp, type RowAction, type RowActionId, type SelectOption, type SetFilter, type TextOp, booleanFilterFn, dateFilterFn, exportToCsv, exportToExcel, isFilterActive, numberFilterFn, setFilterFn, textFilterFn, themePresets, themeToStyle };
415
+ export { type AdvFilter, type CellEditorType, ColumnFilterPanel, type Combine, type Condition, type CustomRowAction, DataTable, type DataTableColumn, DataTableColumnHeader, type DataTableDataSource, type DataTableDataSourceResult, type DataTableDensity, type DataTableErrorContext, type DataTableFeatures, type DataTableFetchParams, type DataTableLabels, type DataTableModedTheme, DataTablePagination, type DataTableProps, DataTableRowActions, type DataTableRowActionsProps, type DataTableTheme, type DataTableThemeName, type DataTableTokens, DataTableToolbar, type DateOp, EditableCell, type FilterType, ISOLATE_DARK_TOKENS, ISOLATE_LIGHT_TOKENS, type NumberOp, type RowAction, type RowActionId, type SelectOption, type SetFilter, type TextOp, booleanFilterFn, buildPreset, dateFilterFn, exportToCsv, exportToExcel, isFilterActive, numberFilterFn, setFilterFn, splitTheme, textFilterFn, themePresets, themeToStyle, tokensToCssBlock, tokensToStyle };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createContext, useState, useRef, useEffect, useMemo, useLayoutEffect, useContext } from 'react';
1
+ import { createContext, useState, useRef, useEffect, useMemo, useLayoutEffect, useId, useContext } from 'react';
2
2
  import { useReactTable, getPaginationRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
3
3
  import { Trash2Icon, XIcon, SearchIcon, RefreshCwIcon, ColumnsIcon, DownloadIcon, FileTextIcon, FileSpreadsheetIcon, PlusIcon, ChevronsLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronsRightIcon, ArrowDownIcon, ArrowUpIcon, ChevronsUpDownIcon, PinOffIcon, PinIcon, EyeOffIcon, FilterIcon, CheckIcon, MoreHorizontalIcon, ChevronDownIcon, GripVerticalIcon, Loader2Icon, MinusIcon, CopyIcon, PencilIcon, EyeIcon, ChevronUpIcon } from 'lucide-react';
4
4
  import { clsx } from 'clsx';
@@ -2024,57 +2024,148 @@ var TOKEN_TO_VAR = {
2024
2024
  radius: "--radius",
2025
2025
  fontFamily: "--font-family"
2026
2026
  };
2027
- function themeToStyle(theme) {
2028
- if (!theme) return {};
2027
+ function isModed(theme) {
2028
+ if (!theme) return false;
2029
+ return "light" in theme || "dark" in theme;
2030
+ }
2031
+ function tokensToStyle(tokens) {
2032
+ if (!tokens) return {};
2029
2033
  const out = {};
2030
- for (const [k, v] of Object.entries(theme)) {
2034
+ for (const [k, v] of Object.entries(tokens)) {
2031
2035
  if (v == null) continue;
2032
2036
  const cssVar = TOKEN_TO_VAR[k];
2033
2037
  if (cssVar) out[cssVar] = v;
2034
2038
  }
2035
2039
  return out;
2036
2040
  }
2037
- var themePresets = {
2041
+ function themeToStyle(theme) {
2042
+ if (!theme) return {};
2043
+ if (isModed(theme)) return tokensToStyle(theme.light);
2044
+ return tokensToStyle(theme);
2045
+ }
2046
+ function splitTheme(theme) {
2047
+ if (!theme) return { light: void 0, dark: void 0 };
2048
+ if (isModed(theme)) return { light: theme.light, dark: theme.dark };
2049
+ return { light: theme, dark: void 0 };
2050
+ }
2051
+ function buildPreset(hue, chroma = 0.03) {
2052
+ const c = chroma;
2053
+ return {
2054
+ light: {
2055
+ background: `oklch(0.99 ${c * 0.2} ${hue})`,
2056
+ foreground: `oklch(0.18 ${c * 1.2} ${hue})`,
2057
+ card: `oklch(1 0 0)`,
2058
+ cardForeground: `oklch(0.18 ${c * 1.2} ${hue})`,
2059
+ popover: `oklch(1 0 0)`,
2060
+ popoverForeground: `oklch(0.18 ${c * 1.2} ${hue})`,
2061
+ primary: `oklch(0.55 0.2 ${hue})`,
2062
+ primaryForeground: `oklch(0.99 0 0)`,
2063
+ secondary: `oklch(0.96 ${c} ${hue})`,
2064
+ secondaryForeground: `oklch(0.25 ${c * 2} ${hue})`,
2065
+ muted: `oklch(0.96 ${c} ${hue})`,
2066
+ mutedForeground: `oklch(0.5 ${c * 1.5} ${hue})`,
2067
+ accent: `oklch(0.94 ${c * 1.2} ${hue})`,
2068
+ accentForeground: `oklch(0.3 ${c * 3} ${hue})`,
2069
+ destructive: `oklch(0.577 0.245 27.325)`,
2070
+ destructiveForeground: `oklch(0.985 0 0)`,
2071
+ border: `oklch(0.9 ${c * 0.8} ${hue})`,
2072
+ input: `oklch(0.9 ${c * 0.8} ${hue})`,
2073
+ ring: `oklch(0.55 0.2 ${hue} / 0.5)`,
2074
+ radius: "0.625rem"
2075
+ },
2076
+ dark: {
2077
+ background: `oklch(0.16 ${c * 0.6} ${hue})`,
2078
+ foreground: `oklch(0.97 ${c * 0.2} ${hue})`,
2079
+ card: `oklch(0.21 ${c * 0.8} ${hue})`,
2080
+ cardForeground: `oklch(0.97 ${c * 0.2} ${hue})`,
2081
+ popover: `oklch(0.21 ${c * 0.8} ${hue})`,
2082
+ popoverForeground: `oklch(0.97 ${c * 0.2} ${hue})`,
2083
+ primary: `oklch(0.7 0.18 ${hue})`,
2084
+ primaryForeground: `oklch(0.16 ${c * 0.6} ${hue})`,
2085
+ secondary: `oklch(0.27 ${c * 0.8} ${hue})`,
2086
+ secondaryForeground: `oklch(0.97 ${c * 0.2} ${hue})`,
2087
+ muted: `oklch(0.27 ${c * 0.8} ${hue})`,
2088
+ mutedForeground: `oklch(0.7 ${c * 0.5} ${hue})`,
2089
+ accent: `oklch(0.3 ${c * 1.5} ${hue})`,
2090
+ accentForeground: `oklch(0.97 ${c * 0.2} ${hue})`,
2091
+ destructive: `oklch(0.577 0.245 27.325 / 0.6)`,
2092
+ destructiveForeground: `oklch(0.985 0 0)`,
2093
+ border: `oklch(0.27 ${c * 0.8} ${hue})`,
2094
+ input: `oklch(0.27 ${c * 0.8} ${hue})`,
2095
+ ring: `oklch(0.7 0.18 ${hue} / 0.5)`,
2096
+ radius: "0.625rem"
2097
+ }
2098
+ };
2099
+ }
2100
+ function tokensToCssBlock(tokens) {
2101
+ if (!tokens) return "";
2102
+ const parts = [];
2103
+ for (const [k, v] of Object.entries(tokens)) {
2104
+ if (v == null) continue;
2105
+ const cssVar = TOKEN_TO_VAR[k];
2106
+ if (cssVar) parts.push(`${cssVar}:${v}`);
2107
+ }
2108
+ return parts.join(";");
2109
+ }
2110
+ var neutral = {
2038
2111
  light: {
2039
2112
  background: "oklch(1 0 0)",
2040
2113
  foreground: "oklch(0.145 0 0)",
2041
2114
  card: "oklch(1 0 0)",
2042
2115
  cardForeground: "oklch(0.145 0 0)",
2116
+ popover: "oklch(1 0 0)",
2117
+ popoverForeground: "oklch(0.145 0 0)",
2043
2118
  primary: "oklch(0.205 0 0)",
2044
2119
  primaryForeground: "oklch(0.985 0 0)",
2045
- border: "oklch(0.922 0 0)"
2120
+ secondary: "oklch(0.97 0 0)",
2121
+ secondaryForeground: "oklch(0.205 0 0)",
2122
+ muted: "oklch(0.97 0 0)",
2123
+ mutedForeground: "oklch(0.556 0 0)",
2124
+ accent: "oklch(0.97 0 0)",
2125
+ accentForeground: "oklch(0.205 0 0)",
2126
+ destructive: "oklch(0.577 0.245 27.325)",
2127
+ destructiveForeground: "oklch(0.985 0 0)",
2128
+ border: "oklch(0.922 0 0)",
2129
+ input: "oklch(0.922 0 0)",
2130
+ ring: "oklch(0.708 0 0)",
2131
+ radius: "0.625rem"
2046
2132
  },
2047
2133
  dark: {
2048
2134
  background: "oklch(0.145 0 0)",
2049
2135
  foreground: "oklch(0.985 0 0)",
2050
2136
  card: "oklch(0.205 0 0)",
2051
2137
  cardForeground: "oklch(0.985 0 0)",
2138
+ popover: "oklch(0.205 0 0)",
2139
+ popoverForeground: "oklch(0.985 0 0)",
2052
2140
  primary: "oklch(0.985 0 0)",
2053
2141
  primaryForeground: "oklch(0.205 0 0)",
2054
- border: "oklch(0.269 0 0)"
2055
- },
2056
- emerald: {
2057
- primary: "oklch(0.66 0.15 162)",
2058
- primaryForeground: "oklch(1 0 0)",
2059
- accent: "oklch(0.94 0.04 162)",
2060
- accentForeground: "oklch(0.3 0.1 162)",
2061
- ring: "oklch(0.66 0.15 162 / 0.5)"
2062
- },
2063
- violet: {
2064
- primary: "oklch(0.55 0.22 285)",
2065
- primaryForeground: "oklch(1 0 0)",
2066
- accent: "oklch(0.94 0.04 285)",
2067
- accentForeground: "oklch(0.3 0.12 285)",
2068
- ring: "oklch(0.55 0.22 285 / 0.5)"
2069
- },
2070
- amber: {
2071
- primary: "oklch(0.7 0.18 65)",
2072
- primaryForeground: "oklch(0.2 0 0)",
2073
- accent: "oklch(0.94 0.05 65)",
2074
- accentForeground: "oklch(0.3 0.12 65)",
2075
- ring: "oklch(0.7 0.18 65 / 0.5)"
2142
+ secondary: "oklch(0.269 0 0)",
2143
+ secondaryForeground: "oklch(0.985 0 0)",
2144
+ muted: "oklch(0.269 0 0)",
2145
+ mutedForeground: "oklch(0.708 0 0)",
2146
+ accent: "oklch(0.269 0 0)",
2147
+ accentForeground: "oklch(0.985 0 0)",
2148
+ destructive: "oklch(0.577 0.245 27.325 / 0.6)",
2149
+ destructiveForeground: "oklch(0.985 0 0)",
2150
+ border: "oklch(0.269 0 0)",
2151
+ input: "oklch(0.269 0 0)",
2152
+ ring: "oklch(0.439 0 0)",
2153
+ radius: "0.625rem"
2076
2154
  }
2077
2155
  };
2156
+ var themePresets = {
2157
+ neutral,
2158
+ light: { light: neutral.light },
2159
+ dark: { light: neutral.dark },
2160
+ violet: buildPreset(285),
2161
+ emerald: buildPreset(162),
2162
+ amber: buildPreset(65),
2163
+ rose: buildPreset(15),
2164
+ sky: buildPreset(235),
2165
+ slate: buildPreset(240, 0.015)
2166
+ };
2167
+ var ISOLATE_LIGHT_TOKENS = neutral.light;
2168
+ var ISOLATE_DARK_TOKENS = neutral.dark;
2078
2169
  function getPinningStyles(column) {
2079
2170
  const isPinned = column.getIsPinned();
2080
2171
  if (!isPinned) return {};
@@ -2239,7 +2330,8 @@ function DataTable({
2239
2330
  features,
2240
2331
  labels: labelsProp,
2241
2332
  density = "default",
2242
- theme
2333
+ theme,
2334
+ isolate = false
2243
2335
  }) {
2244
2336
  const labels = { ...DEFAULT_LABELS, ...labelsProp };
2245
2337
  const f = {
@@ -2255,7 +2347,20 @@ function DataTable({
2255
2347
  reordering: features?.reordering ?? true,
2256
2348
  pinning: features?.pinning ?? true
2257
2349
  };
2258
- const themeStyle = themeToStyle(theme);
2350
+ const rawInstanceId = useId();
2351
+ const instanceId = useMemo(
2352
+ () => `dyno-grid-${rawInstanceId.replace(/[^a-zA-Z0-9]/g, "")}`,
2353
+ [rawInstanceId]
2354
+ );
2355
+ const { lightStyle, darkCss } = useMemo(() => {
2356
+ const { light, dark } = splitTheme(theme);
2357
+ const lightTokens = isolate ? { ...ISOLATE_LIGHT_TOKENS, ...light ?? {} } : light;
2358
+ const darkTokens = isolate ? { ...ISOLATE_DARK_TOKENS, ...dark ?? light ?? {} } : dark;
2359
+ return {
2360
+ lightStyle: tokensToStyle(lightTokens),
2361
+ darkCss: darkTokens ? tokensToCssBlock(darkTokens) : null
2362
+ };
2363
+ }, [theme, isolate]);
2259
2364
  const [sorting, setSorting] = useState([]);
2260
2365
  const [columnFilters, setColumnFilters] = useState([]);
2261
2366
  const [internalGlobalFilter, setInternalGlobalFilter] = useState("");
@@ -2634,13 +2739,19 @@ function DataTable({
2634
2739
  children: /* @__PURE__ */ jsxs(
2635
2740
  "div",
2636
2741
  {
2742
+ "data-dyno-grid": instanceId,
2637
2743
  className: cn(
2638
2744
  "flex flex-col rounded-lg border bg-card text-card-foreground shadow-sm",
2639
2745
  DENSITY_CLASS[density],
2640
2746
  className
2641
2747
  ),
2642
- style: themeStyle,
2748
+ style: lightStyle,
2643
2749
  children: [
2750
+ darkCss && /* @__PURE__ */ jsxs("style", { children: [
2751
+ `@media (prefers-color-scheme: dark){[data-dyno-grid="${instanceId}"]{${darkCss}}}`,
2752
+ `.dark [data-dyno-grid="${instanceId}"]{${darkCss}}`,
2753
+ `[data-dyno-grid="${instanceId}"].dark{${darkCss}}`
2754
+ ] }),
2644
2755
  /* @__PURE__ */ jsx(
2645
2756
  DataTableToolbar,
2646
2757
  {
@@ -2827,6 +2938,6 @@ function renderSkeleton(cols, rows) {
2827
2938
  return Array.from({ length: rows }).map((_, r) => /* @__PURE__ */ jsx("tr", { className: "border-b", children: Array.from({ length: cols }).map((__, c) => /* @__PURE__ */ jsx("td", { className: "px-2 py-2", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }) }, c)) }, r));
2828
2939
  }
2829
2940
 
2830
- export { ColumnFilterPanel, DataTable, DataTableColumnHeader, DataTablePagination, DataTableRowActions, DataTableToolbar, EditableCell, booleanFilterFn, dateFilterFn, exportToCsv, exportToExcel, isFilterActive, numberFilterFn, setFilterFn, textFilterFn, themePresets, themeToStyle };
2941
+ export { ColumnFilterPanel, DataTable, DataTableColumnHeader, DataTablePagination, DataTableRowActions, DataTableToolbar, EditableCell, ISOLATE_DARK_TOKENS, ISOLATE_LIGHT_TOKENS, booleanFilterFn, buildPreset, dateFilterFn, exportToCsv, exportToExcel, isFilterActive, numberFilterFn, setFilterFn, splitTheme, textFilterFn, themePresets, themeToStyle, tokensToCssBlock, tokensToStyle };
2831
2942
  //# sourceMappingURL=index.js.map
2832
2943
  //# sourceMappingURL=index.js.map