@spark-web/data-table 5.2.1 → 5.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @spark-web/data-table
2
2
 
3
+ ## 5.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#798](https://github.com/brighte-labs/spark-web/pull/798)
8
+ [`a8425fd`](https://github.com/brighte-labs/spark-web/commit/a8425fd4c279ce5df76467b40aa114c14ef5e069)
9
+ Thanks [@jacobporci-brighte](https://github.com/jacobporci-brighte)! -
10
+ `DataTable` now automatically zeroes the `<td>` padding on cells whose direct
11
+ child is an `<a>`, so consumers using the row-as-link pattern can let the link
12
+ itself provide the cell padding. Without this, the cell's 16px padding ring
13
+ was unclickable. Nested anchors (deeper than direct child) are unaffected. See
14
+ the package's `CLAUDE.md` for the full pattern.
15
+
3
16
  ## 5.2.1
4
17
 
5
18
  ### Patch Changes
package/CLAUDE.md CHANGED
@@ -80,6 +80,48 @@ Tailwind.
80
80
  `theme.border.color.standard`
81
81
  - Vertical align: `middle` (inline CSS)
82
82
  - Text align: `left` (inline CSS)
83
+ - **Padding auto-zero for link cells**: when a cell's direct child is an `<a>`
84
+ (the "row-as-link" pattern), `DataTable` automatically zeroes the `<td>`
85
+ padding via `&:has(> a)`. The link is expected to provide the visible padding
86
+ itself, which extends the clickable area over the cell's would-be padding
87
+ ring. Nested anchors (`<a>` deeper than direct child) do NOT trigger the rule.
88
+ See "Row-as-link navigation" below.
89
+
90
+ ### Row-as-link navigation
91
+
92
+ When a row's purpose is to navigate to a URL, `onRowClick` is the wrong tool —
93
+ it gives the row no `href`, so right-click → "Open link in new tab",
94
+ cmd/ctrl-click, and middle-click don't work.
95
+
96
+ Use anchor semantics instead:
97
+
98
+ - Wrap each cell's content in your router's `<Link>` component (TanStack Router,
99
+ React Router, Next.js, etc.) with the row's destination. The `<Link>` must be
100
+ the **direct child** of the cell so the auto-padding-zero rule (see "Cell")
101
+ picks it up.
102
+ - Style the link as a block that supplies the cell padding itself:
103
+ `display: block; padding: {theme.spacing.large}; color: inherit; text-decoration: none;`.
104
+ With the `<td>`'s built-in padding zeroed out under the `:has(> a)` rule and
105
+ the link's own padding filling that space, the link covers the entire cell —
106
+ including what would have been the dead 16px padding ring — so clicks anywhere
107
+ in the cell hit the anchor. Row height and text wrapping stay identical to the
108
+ default layout. Do NOT add `width: 100%` / `box-sizing: border-box` / negative
109
+ margins: any of these alters the cell's effective content width and causes
110
+ visible row-spacing or wrap differences.
111
+ - Make only the **first** cell's link keyboard-focusable (`tabIndex={0}`); set
112
+ all other cell links to `tabIndex={-1}` so one row = one tab stop. N cells per
113
+ row should not produce N tab stops to the same destination.
114
+ - Action-only cells (meatball menus, inline buttons) must NOT be wrapped in the
115
+ row link. Since they don't render an `<a>` as a direct child, the
116
+ auto-padding-zero rule won't fire on them and they keep their normal padding
117
+ (unless you've separately zeroed the action column via a `className` rule).
118
+ - Drop `onRowClick` and `enableClickableRow` for that table — the anchors take
119
+ over navigation. Replicate the hover affordance with a `rowClassName` that
120
+ applies `theme.color.background.inputPressed` on hover (mirroring the
121
+ `:hover:not(:has(button:hover))` rule documented in "Row states").
122
+
123
+ Reference implementation: `apps/admin-portal/src/components/RowLink` in the
124
+ portal-hub repo (uses TanStack Router).
83
125
 
84
126
  ### Sort icons
85
127
 
@@ -208,6 +250,9 @@ The distinction:
208
250
  `enableClickableRow` get hover
209
251
  - NEVER let row hover fire when the cursor is over a button inside the row — use
210
252
  `:hover:not(:has(button:hover))` to suppress it
253
+ - NEVER use `onRowClick` for URL-destination navigation — it breaks "Open in new
254
+ tab", cmd/ctrl-click, and middle-click. Wrap cell content in your router's
255
+ `<Link>` instead. See "Row-as-link navigation".
211
256
  - NEVER put pagination inside `DataTable` — caller handles it externally
212
257
  - NEVER render an external `<Spinner>` alongside a mounted `DataTable` — use the
213
258
  `isLoading` prop instead. An external Spinner is only correct before the table
@@ -167,7 +167,11 @@ function DataTable(_ref) {
167
167
  borderBottomStyle: 'solid',
168
168
  borderColor: theme$1.border.color.standard,
169
169
  verticalAlign: 'middle',
170
- textAlign: 'left'
170
+ textAlign: 'left',
171
+ // row-as-link: the anchor supplies its own padding
172
+ '&:has(> a)': {
173
+ padding: 0
174
+ }
171
175
  }),
172
176
  children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
173
177
  }, cell.id);
@@ -167,7 +167,11 @@ function DataTable(_ref) {
167
167
  borderBottomStyle: 'solid',
168
168
  borderColor: theme$1.border.color.standard,
169
169
  verticalAlign: 'middle',
170
- textAlign: 'left'
170
+ textAlign: 'left',
171
+ // row-as-link: the anchor supplies its own padding
172
+ '&:has(> a)': {
173
+ padding: 0
174
+ }
171
175
  }),
172
176
  children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
173
177
  }, cell.id);
@@ -160,7 +160,11 @@ function DataTable(_ref) {
160
160
  borderBottomStyle: 'solid',
161
161
  borderColor: theme.border.color.standard,
162
162
  verticalAlign: 'middle',
163
- textAlign: 'left'
163
+ textAlign: 'left',
164
+ // row-as-link: the anchor supplies its own padding
165
+ '&:has(> a)': {
166
+ padding: 0
167
+ }
164
168
  }),
165
169
  children: flexRender(cell.column.columnDef.cell, cell.getContext())
166
170
  }, cell.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-web/data-table",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "homepage": "https://github.com/brighte-labs/spark-web#readme",
5
5
  "repository": {
6
6
  "type": "git",