@dynostack/react-grid 0.4.0 → 0.5.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
@@ -118,6 +118,54 @@ declare function tokensToCssBlock(tokens?: DataTableTokens): string;
118
118
  */
119
119
  declare const themePresets: {
120
120
  neutral: DataTableModedTheme;
121
+ graphite: {
122
+ light: {
123
+ background: string;
124
+ card: string;
125
+ border: string;
126
+ radius: string;
127
+ fontFamily: string;
128
+ foreground?: string;
129
+ cardForeground?: string;
130
+ popover?: string;
131
+ popoverForeground?: string;
132
+ primary?: string;
133
+ primaryForeground?: string;
134
+ secondary?: string;
135
+ secondaryForeground?: string;
136
+ muted?: string;
137
+ mutedForeground?: string;
138
+ accent?: string;
139
+ accentForeground?: string;
140
+ destructive?: string;
141
+ destructiveForeground?: string;
142
+ input?: string;
143
+ ring?: string;
144
+ };
145
+ dark: {
146
+ background: string;
147
+ card: string;
148
+ popover: string;
149
+ border: string;
150
+ input: string;
151
+ muted: string;
152
+ mutedForeground: string;
153
+ accent: string;
154
+ primary: string;
155
+ primaryForeground: string;
156
+ ring: string;
157
+ destructive: string;
158
+ radius: string;
159
+ fontFamily: string;
160
+ foreground?: string;
161
+ cardForeground?: string;
162
+ popoverForeground?: string;
163
+ secondary?: string;
164
+ secondaryForeground?: string;
165
+ accentForeground?: string;
166
+ destructiveForeground?: string;
167
+ };
168
+ };
121
169
  light: {
122
170
  light: DataTableTokens | undefined;
123
171
  };
package/dist/index.d.ts CHANGED
@@ -118,6 +118,54 @@ declare function tokensToCssBlock(tokens?: DataTableTokens): string;
118
118
  */
119
119
  declare const themePresets: {
120
120
  neutral: DataTableModedTheme;
121
+ graphite: {
122
+ light: {
123
+ background: string;
124
+ card: string;
125
+ border: string;
126
+ radius: string;
127
+ fontFamily: string;
128
+ foreground?: string;
129
+ cardForeground?: string;
130
+ popover?: string;
131
+ popoverForeground?: string;
132
+ primary?: string;
133
+ primaryForeground?: string;
134
+ secondary?: string;
135
+ secondaryForeground?: string;
136
+ muted?: string;
137
+ mutedForeground?: string;
138
+ accent?: string;
139
+ accentForeground?: string;
140
+ destructive?: string;
141
+ destructiveForeground?: string;
142
+ input?: string;
143
+ ring?: string;
144
+ };
145
+ dark: {
146
+ background: string;
147
+ card: string;
148
+ popover: string;
149
+ border: string;
150
+ input: string;
151
+ muted: string;
152
+ mutedForeground: string;
153
+ accent: string;
154
+ primary: string;
155
+ primaryForeground: string;
156
+ ring: string;
157
+ destructive: string;
158
+ radius: string;
159
+ fontFamily: string;
160
+ foreground?: string;
161
+ cardForeground?: string;
162
+ popoverForeground?: string;
163
+ secondary?: string;
164
+ secondaryForeground?: string;
165
+ accentForeground?: string;
166
+ destructiveForeground?: string;
167
+ };
168
+ };
121
169
  light: {
122
170
  light: DataTableTokens | undefined;
123
171
  };
package/dist/index.js CHANGED
@@ -2105,7 +2105,7 @@ function buildPreset(hue, chroma = 0.03) {
2105
2105
  border: `oklch(0.9 ${c * 0.8} ${hue})`,
2106
2106
  input: `oklch(0.9 ${c * 0.8} ${hue})`,
2107
2107
  ring: `oklch(0.55 0.2 ${hue} / 0.5)`,
2108
- radius: "0.625rem"
2108
+ radius: "0.375rem"
2109
2109
  },
2110
2110
  dark: {
2111
2111
  background: `oklch(0.16 ${c * 0.6} ${hue})`,
@@ -2127,7 +2127,7 @@ function buildPreset(hue, chroma = 0.03) {
2127
2127
  border: `oklch(0.27 ${c * 0.8} ${hue})`,
2128
2128
  input: `oklch(0.27 ${c * 0.8} ${hue})`,
2129
2129
  ring: `oklch(0.7 0.18 ${hue} / 0.5)`,
2130
- radius: "0.625rem"
2130
+ radius: "0.375rem"
2131
2131
  }
2132
2132
  };
2133
2133
  }
@@ -2167,7 +2167,7 @@ var neutral = {
2167
2167
  border: "oklch(0.922 0 0)",
2168
2168
  input: "oklch(0.922 0 0)",
2169
2169
  ring: "oklch(0.708 0 0)",
2170
- radius: "0.625rem"
2170
+ radius: "0.375rem"
2171
2171
  },
2172
2172
  dark: {
2173
2173
  background: "oklch(0.145 0 0)",
@@ -2189,11 +2189,38 @@ var neutral = {
2189
2189
  border: "oklch(0.269 0 0)",
2190
2190
  input: "oklch(0.269 0 0)",
2191
2191
  ring: "oklch(0.439 0 0)",
2192
- radius: "0.625rem"
2192
+ radius: "0.375rem"
2193
2193
  }
2194
2194
  };
2195
2195
  var themePresets = {
2196
2196
  neutral,
2197
+ graphite: {
2198
+ light: {
2199
+ ...neutral.light,
2200
+ background: "#fafafa",
2201
+ card: "#ffffff",
2202
+ border: "#e5e5e5",
2203
+ radius: "0.375rem",
2204
+ fontFamily: "'Geist', sans-serif"
2205
+ },
2206
+ dark: {
2207
+ ...neutral.dark,
2208
+ background: "#101112",
2209
+ card: "#101112",
2210
+ popover: "#17191b",
2211
+ border: "#292c2f",
2212
+ input: "#303438",
2213
+ muted: "#1b1e21",
2214
+ mutedForeground: "#9ba2aa",
2215
+ accent: "#24282d",
2216
+ primary: "#edf0f3",
2217
+ primaryForeground: "#101112",
2218
+ ring: "#84b8ff",
2219
+ destructive: "#fb7185",
2220
+ radius: "0.375rem",
2221
+ fontFamily: "'Geist', sans-serif"
2222
+ }
2223
+ },
2197
2224
  light: { light: neutral.light },
2198
2225
  dark: { light: neutral.dark },
2199
2226
  violet: buildPreset(285),
@@ -2557,9 +2584,7 @@ function getPinningStyles(column) {
2557
2584
  boxShadow: isLast ? "1px 0 0 0 var(--border)" : isFirst ? "-1px 0 0 0 var(--border)" : void 0
2558
2585
  };
2559
2586
  }
2560
- var DataTableEditingContext = createContext(
2561
- null
2562
- );
2587
+ var DataTableEditingContext = createContext(null);
2563
2588
  function useEditingContext() {
2564
2589
  const ctx = useContext(DataTableEditingContext);
2565
2590
  if (!ctx) throw new Error("DataTable editing context missing");
@@ -2570,13 +2595,7 @@ function DefaultCellHost(ctx) {
2570
2595
  return value == null ? null : String(value);
2571
2596
  }
2572
2597
  function EditableCellHost(ctx) {
2573
- const {
2574
- editingCell,
2575
- editingRowId,
2576
- setEditingCell,
2577
- setRowDraft,
2578
- onCellEdit
2579
- } = useEditingContext();
2598
+ const { editingCell, editingRowId, setEditingCell, setRowDraft, onCellEdit } = useEditingContext();
2580
2599
  const colId = ctx.column.id;
2581
2600
  const rowId = ctx.row.id;
2582
2601
  const isCellEdit = editingCell?.rowId === rowId && editingCell.colId === colId;
@@ -2753,12 +2772,13 @@ function DataTable({
2753
2772
  () => `dyno-grid-${rawInstanceId.replace(/[^a-zA-Z0-9]/g, "")}`,
2754
2773
  [rawInstanceId]
2755
2774
  );
2756
- const { lightStyle, darkCss } = useMemo(() => {
2775
+ const { lightStyle, lightCss, darkCss } = useMemo(() => {
2757
2776
  const { light, dark } = splitTheme(theme);
2758
2777
  const lightTokens = isolate ? { ...ISOLATE_LIGHT_TOKENS, ...light ?? {} } : light;
2759
2778
  const darkTokens = isolate ? { ...ISOLATE_DARK_TOKENS, ...dark ?? light ?? {} } : dark;
2760
2779
  return {
2761
2780
  lightStyle: tokensToStyle(lightTokens),
2781
+ lightCss: tokensToCssBlock(lightTokens),
2762
2782
  darkCss: darkTokens ? tokensToCssBlock(darkTokens) : null
2763
2783
  };
2764
2784
  }, [theme, isolate]);
@@ -2808,19 +2828,17 @@ function DataTable({
2808
2828
  const [columnVisibility, setColumnVisibility] = useState(
2809
2829
  initialColumnVisibility ?? {}
2810
2830
  );
2811
- const [columnPinning, setColumnPinning] = useState(
2812
- () => {
2813
- const base = initialColumnPinning ?? { left: [], right: [] };
2814
- const left = [...base.left ?? []];
2815
- const right = [...base.right ?? []];
2816
- const hasExpandColumn = !!(renderSubRow || getSubRows);
2817
- if (hasExpandColumn && left.includes("__select") && !left.includes("__expand")) {
2818
- const idx = left.indexOf("__select");
2819
- left.splice(idx + 1, 0, "__expand");
2820
- }
2821
- return { left, right };
2831
+ const [columnPinning, setColumnPinning] = useState(() => {
2832
+ const base = initialColumnPinning ?? { left: [], right: [] };
2833
+ const left = [...base.left ?? []];
2834
+ const right = [...base.right ?? []];
2835
+ const hasExpandColumn = !!(renderSubRow || getSubRows);
2836
+ if (hasExpandColumn && left.includes("__select") && !left.includes("__expand")) {
2837
+ const idx = left.indexOf("__select");
2838
+ left.splice(idx + 1, 0, "__expand");
2822
2839
  }
2823
- );
2840
+ return { left, right };
2841
+ });
2824
2842
  const [columnSizing, setColumnSizing] = useState({});
2825
2843
  const [rowSelection, setRowSelection] = useState({});
2826
2844
  const [expanded, setExpanded] = useState({});
@@ -3006,7 +3024,9 @@ function DataTable({
3006
3024
  customRowActions?.length
3007
3025
  ]);
3008
3026
  const [columnOrder, setColumnOrder] = useState(
3009
- () => augmentedColumns.map((c) => c.id ?? c.accessorKey ?? "")
3027
+ () => augmentedColumns.map(
3028
+ (c) => c.id ?? c.accessorKey ?? ""
3029
+ )
3010
3030
  );
3011
3031
  useEffect(() => {
3012
3032
  const next = augmentedColumns.map(
@@ -3144,7 +3164,9 @@ function DataTable({
3144
3164
  const selectionCallback = useRef(onSelectionChange);
3145
3165
  selectionCallback.current = onSelectionChange;
3146
3166
  useEffect(() => {
3147
- selectionCallback.current?.(table.getSelectedRowModel().flatRows.map((row) => row.original));
3167
+ selectionCallback.current?.(
3168
+ table.getSelectedRowModel().flatRows.map((row) => row.original)
3169
+ );
3148
3170
  }, [rowSelection, mergedData, table]);
3149
3171
  const visibleLeafCount = table.getVisibleLeafColumns().length;
3150
3172
  const editingContextValue = useMemo(
@@ -3196,12 +3218,15 @@ function DataTable({
3196
3218
  DENSITY_CLASS[density],
3197
3219
  className
3198
3220
  ),
3199
- style: lightStyle,
3221
+ style: darkCss ? void 0 : lightStyle,
3200
3222
  children: [
3201
3223
  darkCss && /* @__PURE__ */ jsxs("style", { children: [
3224
+ `[data-dyno-grid="${instanceId}"]{${lightCss}}`,
3202
3225
  `@media (prefers-color-scheme: dark){[data-dyno-grid="${instanceId}"]{${darkCss}}}`,
3203
3226
  `.dark [data-dyno-grid="${instanceId}"]{${darkCss}}`,
3204
- `[data-dyno-grid="${instanceId}"].dark{${darkCss}}`
3227
+ `.light [data-dyno-grid="${instanceId}"]{${lightCss}}`,
3228
+ `[data-dyno-grid="${instanceId}"].dark{${darkCss}}`,
3229
+ `[data-dyno-grid="${instanceId}"].light{${lightCss}}`
3205
3230
  ] }),
3206
3231
  /* @__PURE__ */ jsx(
3207
3232
  DataTableToolbar,
@@ -3228,71 +3253,83 @@ function DataTable({
3228
3253
  "table",
3229
3254
  {
3230
3255
  "aria-label": ariaLabel,
3231
- className: cn("w-full caption-bottom text-sm", striped && "[&_tbody>tr:nth-child(even)]:bg-muted/25"),
3256
+ className: cn(
3257
+ "w-full caption-bottom text-sm",
3258
+ striped && "[&_tbody>tr:nth-child(even)]:bg-muted/25"
3259
+ ),
3232
3260
  style: {
3233
3261
  width: table.getCenterTotalSize() ? void 0 : "100%",
3234
3262
  minWidth: "100%"
3235
3263
  },
3236
3264
  children: [
3237
- /* @__PURE__ */ jsx("thead", { className: cn("bg-card", stickyHeader && "sticky top-0 z-10"), children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ jsx("tr", { className: "border-b", children: hg.headers.map((header) => {
3238
- const meta = header.column.columnDef.meta;
3239
- const isUtility = header.column.id === "__select" || header.column.id === "__expand" || header.column.id === "__actions";
3240
- const isPinned = !!header.column.getIsPinned();
3241
- const canReorder = !isUtility && f.reordering;
3242
- const isDropTarget = canReorder && dragOverColId === header.column.id;
3243
- const isBeingDragged = canReorder && activeReorderId === header.column.id;
3244
- return /* @__PURE__ */ jsxs(
3245
- "th",
3246
- {
3247
- colSpan: header.colSpan,
3248
- "data-col-id": header.column.id,
3249
- onPointerDown: canReorder ? onHeaderPointerDown(header.column.id) : void 0,
3250
- onPointerMove: canReorder ? onHeaderPointerMove : void 0,
3251
- onPointerUp: canReorder ? onHeaderPointerUp : void 0,
3252
- onPointerCancel: canReorder ? onHeaderPointerUp : void 0,
3253
- style: {
3254
- width: header.getSize(),
3255
- ...getPinningStyles(header.column),
3256
- ...isPinned ? { zIndex: 2 } : {}
3257
- },
3258
- className: cn(
3259
- "group/th relative h-9 px-2 text-left align-middle text-xs font-medium text-muted-foreground select-none",
3260
- canReorder && "cursor-grab active:cursor-grabbing",
3261
- isPinned && "bg-card",
3262
- isBeingDragged && "opacity-50",
3263
- isDropTarget && "bg-primary/10 ring-2 ring-inset ring-primary/40",
3264
- meta?.headerClassName
3265
- ),
3266
- children: [
3267
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
3268
- canReorder && /* @__PURE__ */ jsx(
3269
- GripVerticalIcon,
3270
- {
3271
- className: "-ml-1 size-3 shrink-0 text-muted-foreground/40 opacity-0 transition group-hover/th:opacity-100",
3272
- "aria-hidden": "true"
3273
- }
3265
+ /* @__PURE__ */ jsx(
3266
+ "thead",
3267
+ {
3268
+ className: cn("bg-card", stickyHeader && "sticky top-0 z-10"),
3269
+ children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ jsx("tr", { className: "border-b", children: hg.headers.map((header) => {
3270
+ const meta = header.column.columnDef.meta;
3271
+ const isUtility = header.column.id === "__select" || header.column.id === "__expand" || header.column.id === "__actions";
3272
+ const isPinned = !!header.column.getIsPinned();
3273
+ const canReorder = !isUtility && f.reordering;
3274
+ const isDropTarget = canReorder && dragOverColId === header.column.id;
3275
+ const isBeingDragged = canReorder && activeReorderId === header.column.id;
3276
+ return /* @__PURE__ */ jsxs(
3277
+ "th",
3278
+ {
3279
+ colSpan: header.colSpan,
3280
+ "data-col-id": header.column.id,
3281
+ onPointerDown: canReorder ? onHeaderPointerDown(header.column.id) : void 0,
3282
+ onPointerMove: canReorder ? onHeaderPointerMove : void 0,
3283
+ onPointerUp: canReorder ? onHeaderPointerUp : void 0,
3284
+ onPointerCancel: canReorder ? onHeaderPointerUp : void 0,
3285
+ style: {
3286
+ width: header.getSize(),
3287
+ ...getPinningStyles(header.column),
3288
+ ...isPinned ? { zIndex: 2 } : {}
3289
+ },
3290
+ className: cn(
3291
+ "group/th relative h-9 px-2 text-left align-middle text-xs font-medium text-muted-foreground select-none",
3292
+ canReorder && "cursor-grab active:cursor-grabbing",
3293
+ isPinned && "bg-card",
3294
+ isBeingDragged && "opacity-50",
3295
+ isDropTarget && "bg-primary/10 ring-2 ring-primary/40 ring-inset",
3296
+ meta?.headerClassName
3274
3297
  ),
3275
- /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) })
3276
- ] }),
3277
- header.column.getCanResize() && /* @__PURE__ */ jsx(
3278
- "span",
3279
- {
3280
- "data-no-drag": true,
3281
- onPointerDown: (e) => e.stopPropagation(),
3282
- onMouseDown: header.getResizeHandler(),
3283
- onTouchStart: header.getResizeHandler(),
3284
- onDoubleClick: () => header.column.resetSize(),
3285
- className: cn(
3286
- "absolute top-0 right-0 h-full w-1 cursor-col-resize touch-none select-none bg-transparent transition-colors hover:bg-primary/40",
3287
- header.column.getIsResizing() && "bg-primary"
3298
+ children: [
3299
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
3300
+ canReorder && /* @__PURE__ */ jsx(
3301
+ GripVerticalIcon,
3302
+ {
3303
+ className: "-ml-1 size-3 shrink-0 text-muted-foreground/40 opacity-0 transition group-hover/th:opacity-100",
3304
+ "aria-hidden": "true"
3305
+ }
3306
+ ),
3307
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: header.isPlaceholder ? null : flexRender(
3308
+ header.column.columnDef.header,
3309
+ header.getContext()
3310
+ ) })
3311
+ ] }),
3312
+ header.column.getCanResize() && /* @__PURE__ */ jsx(
3313
+ "span",
3314
+ {
3315
+ "data-no-drag": true,
3316
+ onPointerDown: (e) => e.stopPropagation(),
3317
+ onMouseDown: header.getResizeHandler(),
3318
+ onTouchStart: header.getResizeHandler(),
3319
+ onDoubleClick: () => header.column.resetSize(),
3320
+ className: cn(
3321
+ "absolute top-0 right-0 h-full w-1 cursor-col-resize touch-none bg-transparent transition-colors select-none hover:bg-primary/40",
3322
+ header.column.getIsResizing() && "bg-primary"
3323
+ )
3324
+ }
3288
3325
  )
3289
- }
3290
- )
3291
- ]
3292
- },
3293
- header.id
3294
- );
3295
- }) }, hg.id)) }),
3326
+ ]
3327
+ },
3328
+ header.id
3329
+ );
3330
+ }) }, hg.id))
3331
+ }
3332
+ ),
3296
3333
  /* @__PURE__ */ jsx("tbody", { children: effectiveIsLoading ? renderSkeleton(visibleLeafCount, pagination.pageSize) : sourceError && rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
3297
3334
  "td",
3298
3335
  {
@@ -3336,7 +3373,13 @@ function DataTable({
3336
3373
  labels.refreshing
3337
3374
  ] })
3338
3375
  ] }),
3339
- f.pagination && /* @__PURE__ */ jsx(DataTablePagination, { table, pageSizeOptions }),
3376
+ f.pagination && /* @__PURE__ */ jsx(
3377
+ DataTablePagination,
3378
+ {
3379
+ table,
3380
+ pageSizeOptions
3381
+ }
3382
+ ),
3340
3383
  /* @__PURE__ */ jsx(
3341
3384
  DataTableViewSheet,
3342
3385
  {