@dynostack/react-grid 0.2.0 → 0.3.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 CHANGED
@@ -51,6 +51,8 @@ A single `<DataTable />` component that gives you ag-grid–level functionality
51
51
  - [Selection & bulk actions](#selection--bulk-actions)
52
52
  - [Expandable rows](#expandable-rows)
53
53
  - [Export](#export)
54
+ - [View sheet](#view-sheet)
55
+ - [Delete confirmation](#delete-confirmation)
54
56
  - [Custom row actions](#custom-row-actions)
55
57
  - [Server-side data](#server-side-data)
56
58
  - [API reference](#api-reference)
@@ -610,6 +612,72 @@ Mark a column non-exportable via `meta.exportable: false`.
610
612
 
611
613
  ---
612
614
 
615
+ ## View sheet
616
+
617
+ Click the row action "View" → a right-side `Sheet` slides in showing every visible column as a `{Label}: {value}` card. The user can switch layout density inline (Compact 1 col / Relaxed 2 col / Comfy 3 col).
618
+
619
+ Works out of the box with no props. Customize via `viewSheet`:
620
+
621
+ ```tsx
622
+ <DataTable
623
+ viewSheet={{
624
+ side: "right", // or "left"
625
+ defaultDensity: "relaxed", // initial column count
626
+ hideDensityTabs: true, // hide the layout picker
627
+ fields: ["name", "email", "role"], // limit / reorder shown columns
628
+ renderField: ({ column, value, row }) => // override how a value renders
629
+ column.id === "phone" ? <a href={`tel:${value}`}>{String(value)}</a> : null,
630
+ renderHeader: (row) => <YourCustomHeader row={row} />,
631
+ labels: {
632
+ title: (row) => `${row.name} (${row.role})`,
633
+ description: (row) => `Joined ${row.joinedAt}`,
634
+ emptyValue: "—",
635
+ density: { compact: "1 col", relaxed: "2 cols", comfy: "3 cols" },
636
+ },
637
+ }}
638
+ onView={(row) => track("user.view", row)} // optional side-effect
639
+ />
640
+ ```
641
+
642
+ Disable the built-in sheet entirely:
643
+
644
+ ```tsx
645
+ <DataTable viewSheet={false} onView={(row) => router.push(`/users/${row.id}`)} />
646
+ ```
647
+
648
+ `onView` fires before the sheet opens, so you can navigate / log / fetch alongside it.
649
+
650
+ ---
651
+
652
+ ## Delete confirmation
653
+
654
+ Both the row-action "Delete" and the toolbar "Bulk delete" open a confirmation `AlertDialog` by default. The user must confirm before `onDelete` or `onBulkDelete` fires.
655
+
656
+ ```tsx
657
+ <DataTable
658
+ onDelete={(row) => api.deleteUser(row.id)}
659
+ onBulkDelete={(rows) => api.bulkDelete(rows.map(r => r.id))}
660
+ confirmDelete={{
661
+ title: ({ rows, source }) =>
662
+ source === "bulk"
663
+ ? `Delete ${rows.length} users?`
664
+ : `Delete ${rows[0].name}?`,
665
+ description: ({ rows }) =>
666
+ `${rows.length === 1 ? "This user" : "These users"} will be permanently removed. This cannot be undone.`,
667
+ confirmLabel: "Yes, delete",
668
+ cancelLabel: "Keep",
669
+ }}
670
+ />
671
+ ```
672
+
673
+ Skip the dialog (fire immediately):
674
+
675
+ ```tsx
676
+ <DataTable confirmDelete={false} onDelete={(row) => softDelete(row)} />
677
+ ```
678
+
679
+ ---
680
+
613
681
  ## Custom row actions
614
682
 
615
683
  ```tsx
@@ -731,6 +799,10 @@ operations and only renders the returned page.
731
799
  | `density` | `"compact" \| "default" \| "comfortable"` | `"default"` | Row density. |
732
800
  | `theme` | `DataTableTheme` | inherits `:root` | Per-instance CSS-variable overrides. Accepts flat tokens **or** `{ light, dark }`. |
733
801
  | `isolate` | `boolean` | `false` | Ignore the app's `:root` and render with bundled defaults. |
802
+ | `onView` | `(row: TData) => void` | — | Side-effect when "View" is clicked. Fires *before* the sheet opens. |
803
+ | `onDelete` | `(row: TData) => void` | — | Single-row delete handler. Fires *after* the confirm modal (or immediately if `confirmDelete={false}`). |
804
+ | `viewSheet` | `ViewSheetConfig<TData> \| false` | enabled | Configure or disable the built-in View sheet. |
805
+ | `confirmDelete` | `ConfirmDeleteConfig<TData> \| boolean` | `true` | Configure or disable the delete confirmation modal (applies to single + bulk). |
734
806
 
735
807
  `TData` must extend `{ id: string \| number }`.
736
808
 
@@ -801,6 +873,43 @@ import {
801
873
  } from "@dynostack/react-grid"
802
874
  ```
803
875
 
876
+ ```ts
877
+ // View sheet types
878
+ type ViewSheetDensity = "compact" | "relaxed" | "comfy"
879
+
880
+ type ViewSheetConfig<TData> = {
881
+ side?: "right" | "left" | "top" | "bottom"
882
+ defaultDensity?: ViewSheetDensity
883
+ hideDensityTabs?: boolean
884
+ fields?: string[]
885
+ renderField?: (args: {
886
+ column: Column<TData, unknown>
887
+ value: unknown
888
+ row: TData
889
+ }) => React.ReactNode
890
+ renderHeader?: (row: TData) => React.ReactNode
891
+ labels?: {
892
+ title?: (row: TData) => React.ReactNode
893
+ description?: (row: TData) => React.ReactNode
894
+ emptyValue?: string
895
+ density?: { compact?: string; relaxed?: string; comfy?: string }
896
+ }
897
+ }
898
+
899
+ // Confirm-delete types
900
+ type ConfirmDeleteContext<TData> = {
901
+ rows: TData[]
902
+ source: "single" | "bulk"
903
+ }
904
+
905
+ type ConfirmDeleteConfig<TData> = {
906
+ title?: (ctx: ConfirmDeleteContext<TData>) => React.ReactNode
907
+ description?: (ctx: ConfirmDeleteContext<TData>) => React.ReactNode
908
+ confirmLabel?: string
909
+ cancelLabel?: string
910
+ }
911
+ ```
912
+
804
913
  ---
805
914
 
806
915
  ## Compatibility