@bjj/nuxt-layer-shadcn-ui 0.16.1 → 0.17.1

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.
@@ -92,7 +92,9 @@ const meta = {
92
92
  showPagination: { control: 'boolean' },
93
93
  selectable: { control: 'boolean' },
94
94
  rowSelectable: { control: false },
95
+ selectOnRowClick: { control: 'boolean' },
95
96
  clickable: { control: 'boolean' },
97
+ rowClickable: { control: false },
96
98
  hoverable: { control: 'boolean' },
97
99
  batchActions: { control: 'object' },
98
100
  selection: { control: 'object' },
@@ -109,7 +111,9 @@ const meta = {
109
111
  showPagination: true,
110
112
  selectable: false,
111
113
  rowSelectable: undefined,
114
+ selectOnRowClick: false,
112
115
  clickable: false,
116
+ rowClickable: undefined,
113
117
  hoverable: true,
114
118
  batchActions: [],
115
119
  selection: [],
@@ -173,6 +177,91 @@ export const WithBatchActions: Story = {
173
177
  }),
174
178
  }
175
179
 
180
+ /** `rowClickable` gates `rowClick` per row: inactive rows here neither emit it nor show the pointer cursor. A click that ends a text selection (e.g. copying an email) emits nothing either. */
181
+ export const RowClickable: Story = {
182
+ parameters: {
183
+ ...noControls,
184
+ docs: {
185
+ source: {
186
+ code: `
187
+ <template>
188
+ <AsyncDataTable
189
+ :columns="columns"
190
+ :fetchMethod="mockFetch"
191
+ clickable
192
+ :rowClickable="row => row.status === 'active'"
193
+ @rowClick="row => lastClicked = row"
194
+ />
195
+ </template>
196
+ `.trim(),
197
+ },
198
+ },
199
+ },
200
+ render: () => ({
201
+ components: { AsyncDataTable },
202
+ setup () {
203
+ const lastClicked = ref<User | null>(null)
204
+ const rowClickable = (row: User) => row.status === 'active'
205
+ return { columns, mockFetch, lastClicked, rowClickable }
206
+ },
207
+ template: `
208
+ <div class="w-full">
209
+ <AsyncDataTable
210
+ :columns="columns"
211
+ :fetchMethod="mockFetch"
212
+ clickable
213
+ :rowClickable="rowClickable"
214
+ @rowClick="row => lastClicked = row"
215
+ />
216
+ <div class="mt-2 text-sm text-muted-foreground">
217
+ Last clicked: {{ lastClicked?.name ?? 'none' }}
218
+ </div>
219
+ </div>
220
+ `,
221
+ }),
222
+ }
223
+
224
+ /** `selectOnRowClick` lets a click anywhere on a row toggle its selection, not just the checkbox cell. */
225
+ export const SelectOnRowClick: Story = {
226
+ parameters: {
227
+ ...noControls,
228
+ docs: {
229
+ source: {
230
+ code: `
231
+ <template>
232
+ <AsyncDataTable
233
+ :columns="columns"
234
+ :fetchMethod="mockFetch"
235
+ v-model:selection="selection"
236
+ selectable
237
+ selectOnRowClick
238
+ />
239
+ </template>
240
+ `.trim(),
241
+ },
242
+ },
243
+ },
244
+ render: () => ({
245
+ components: { AsyncDataTable },
246
+ setup () {
247
+ const selection = ref<User[]>([])
248
+ return { columns, mockFetch, selection }
249
+ },
250
+ template: `
251
+ <AsyncDataTable
252
+ :columns="columns"
253
+ :fetchMethod="mockFetch"
254
+ v-model:selection="selection"
255
+ selectable
256
+ selectOnRowClick
257
+ />
258
+ <div class="mt-2 text-sm text-muted-foreground">
259
+ Selected: {{ selection.length > 0 ? selection.map(r => r.name).join(', ') : 'none' }}
260
+ </div>
261
+ `,
262
+ }),
263
+ }
264
+
176
265
  /** `rowSelectable` locks individual rows out of selection: their checkbox is disabled and "select all" skips them. */
177
266
  export const DisabledRows: Story = {
178
267
  parameters: {
@@ -18,7 +18,9 @@ const props = withDefaults(defineProps<AsyncDataTableProps<TData>>(), {
18
18
  showPagination: true,
19
19
  selectable: false,
20
20
  rowSelectable: undefined,
21
+ selectOnRowClick: false,
21
22
  clickable: false,
23
+ rowClickable: undefined,
22
24
  hoverable: true,
23
25
  batchActions: () => [],
24
26
  selection: () => [],
@@ -338,7 +340,9 @@ onMounted(() => {
338
340
  :loading
339
341
  :selectionMode="showSelectionColumn ? 'multiple' : undefined"
340
342
  :rowSelectable
343
+ :selectOnRowClick
341
344
  :clickable
345
+ :rowClickable
342
346
  :hoverable
343
347
  :sortBy="sortState.sortBy"
344
348
  :sortOrder="sortState.sortOrder"
@@ -1,4 +1,4 @@
1
- import type { DataTableColumn, DataTableRowSelectable } from '../DataTable/types'
1
+ import type { DataTableColumn, DataTableRowClickable, DataTableRowSelectable } from '../DataTable/types'
2
2
  import type { DropdownActionItem, DropdownLabelItem, DropdownSeparatorItem } from '../Dropdown/types'
3
3
 
4
4
  export type AsyncDataTableBatchAction<T = Record<string, any>>
@@ -46,8 +46,12 @@ export interface AsyncDataTableProps<T = Record<string, any>> {
46
46
  selectable?: boolean
47
47
  /** Per-row selection gate; `index` is relative to the current page. Rows returning false get a disabled checkbox and are skipped by "select all". */
48
48
  rowSelectable?: DataTableRowSelectable<T>
49
+ /** Whether clicking anywhere on a row toggles its selection. Default: false — selection toggles only from the selection cell, leaving row clicks to `@rowClick`. */
50
+ selectOnRowClick?: boolean
49
51
  /** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
50
52
  clickable?: boolean
53
+ /** Per-row click gate: rows returning false neither emit `rowClick` nor show the pointer cursor. Selection is gated separately by `rowSelectable`. */
54
+ rowClickable?: DataTableRowClickable<T>
51
55
  /** Row hover highlight. Default: true. Turn it off where the cells hold form controls — a tinted row reads as "not editable" there. Selected and active rows keep their highlight either way. */
52
56
  hoverable?: boolean
53
57
  /** Batch action definitions for selected rows */
@@ -79,16 +79,20 @@ const meta = {
79
79
  argTypes: {
80
80
  selectionMode: { control: 'select', options: [ undefined, 'single', 'multiple' ]},
81
81
  rowSelectable: { control: false },
82
+ selectOnRowClick: { control: 'boolean' },
82
83
  loading: { control: 'boolean' },
83
84
  clickable: { control: 'boolean' },
85
+ rowClickable: { control: false },
84
86
  hoverable: { control: 'boolean' },
85
87
  height: { control: 'text' },
86
88
  },
87
89
  args: {
88
90
  selectionMode: undefined,
89
91
  rowSelectable: undefined,
92
+ selectOnRowClick: false,
90
93
  loading: false,
91
94
  clickable: false,
95
+ rowClickable: undefined,
92
96
  hoverable: true,
93
97
  height: undefined,
94
98
  },
@@ -272,6 +276,50 @@ export const RowClick: Story = {
272
276
  }),
273
277
  }
274
278
 
279
+ /** `rowClickable` gates `rowClick` per row: inactive rows here neither emit it nor show the pointer cursor. A click that ends a text selection (e.g. copying an email) emits nothing either. */
280
+ export const RowClickable: Story = {
281
+ parameters: {
282
+ ...noControls,
283
+ docs: {
284
+ source: {
285
+ code: `
286
+ <template>
287
+ <DataTable
288
+ :data="data"
289
+ :columns="columns"
290
+ clickable
291
+ :rowClickable="row => row.status === 'active'"
292
+ @rowClick="row => lastClicked = row"
293
+ />
294
+ </template>
295
+ `.trim(),
296
+ },
297
+ },
298
+ },
299
+ render: () => ({
300
+ components: { DataTable: DataTable as any },
301
+ setup () {
302
+ const lastClicked = ref<User | null>(null)
303
+ const rowClickable = (row: User) => row.status === 'active'
304
+ return { data: sampleData, columns: basicColumns, lastClicked, rowClickable }
305
+ },
306
+ template: `
307
+ <div class="w-full">
308
+ <DataTable
309
+ :data="data"
310
+ :columns="columns"
311
+ clickable
312
+ :rowClickable="rowClickable"
313
+ @rowClick="row => lastClicked = row"
314
+ />
315
+ <div class="mt-2 text-sm text-muted-foreground">
316
+ Last clicked: {{ lastClicked?.name ?? 'none' }}
317
+ </div>
318
+ </div>
319
+ `,
320
+ }),
321
+ }
322
+
275
323
  /** `active` highlights a specific row with the selected style. Independent from `selection` — typically paired with `@rowClick` to mark the row currently shown in a detail view. */
276
324
  export const ActiveRow: Story = {
277
325
  parameters: {
@@ -530,6 +578,50 @@ export const DisabledRows: Story = {
530
578
  }),
531
579
  }
532
580
 
581
+ /** `selectOnRowClick` lets a click anywhere on a row toggle its selection, not just the checkbox cell. */
582
+ export const SelectOnRowClick: Story = {
583
+ parameters: {
584
+ ...noControls,
585
+ docs: {
586
+ source: {
587
+ code: `
588
+ <template>
589
+ <DataTable
590
+ :data="data"
591
+ :columns="columns"
592
+ selectionMode="multiple"
593
+ selectOnRowClick
594
+ v-model:selection="selection"
595
+ />
596
+ </template>
597
+ `.trim(),
598
+ },
599
+ },
600
+ },
601
+ render: () => ({
602
+ components: { DataTable: DataTable as any },
603
+ setup () {
604
+ const selection = ref<User[]>([])
605
+ return { data: sampleData, basicColumns, selection }
606
+ },
607
+ template: `
608
+ <div class="w-full">
609
+ <DataTable
610
+ :data="data"
611
+ :columns="basicColumns"
612
+ selectionMode="multiple"
613
+ selectOnRowClick
614
+ v-model:selection="selection"
615
+ />
616
+ <div class="mt-2 text-sm text-muted-foreground">
617
+ Click anywhere on a row — Selected:
618
+ {{ selection.length > 0 ? selection.map(r => r.name).join(', ') : 'none' }}
619
+ </div>
620
+ </div>
621
+ `,
622
+ }),
623
+ }
624
+
533
625
  export const FrozenColumns: Story = {
534
626
  parameters: {
535
627
  ...noControls,
@@ -23,10 +23,12 @@ const props = withDefaults(defineProps<DataTableProps<TData>>(), {
23
23
  columns: () => [],
24
24
  selectionMode: undefined,
25
25
  rowSelectable: undefined,
26
+ selectOnRowClick: false,
26
27
  sortBy: undefined,
27
28
  sortOrder: undefined,
28
29
  loading: false,
29
30
  clickable: false,
31
+ rowClickable: undefined,
30
32
  hoverable: true,
31
33
  height: undefined,
32
34
  active: null,
@@ -100,9 +102,23 @@ function isRowSelected (row: TData): boolean {
100
102
  return toRaw(selection.value) === toRaw(row)
101
103
  }
102
104
 
103
- // Both selection and the `clickable` contract make a row respond to a click.
105
+ // Whether a click on the row body toggles the row's selection.
106
+ const rowClickSelects = computed(() => showSelectionColumn.value && props.selectOnRowClick)
107
+
108
+ function emitsRowClick (row: TData, index: number): boolean {
109
+ return props.rowClickable ? props.rowClickable(row, index) : true
110
+ }
111
+
112
+ // Both row-click selection and the `clickable` contract make a row respond to a click.
104
113
  function isRowClickable (row: TData, index: number): boolean {
105
- return props.clickable || (showSelectionColumn.value && isRowSelectable(row, index))
114
+ return (props.clickable && emitsRowClick(row, index))
115
+ || (rowClickSelects.value && isRowSelectable(row, index))
116
+ }
117
+
118
+ // With row-click selection off, the selection cell is the only toggle, so it
119
+ // takes its own hover tint to read as a target.
120
+ function isSelectionCellHoverable (row: TData, index: number): boolean {
121
+ return !props.selectOnRowClick && isRowSelectable(row, index)
106
122
  }
107
123
 
108
124
  function isRowActive (row: TData): boolean {
@@ -123,8 +139,17 @@ function toggleRow (row: TData, index: number) {
123
139
  }
124
140
 
125
141
  function onRowClick (row: TData, index: number, event: MouseEvent) {
126
- emit('rowClick', row, index, event)
127
- if (showSelectionColumn.value) toggleRow(row, index)
142
+ // A drag that selects text (e.g. to copy an ID) ends in a click on the row;
143
+ // it isn't meant as one.
144
+ if (window.getSelection()?.toString()) return
145
+ if (emitsRowClick(row, index)) emit('rowClick', row, index, event)
146
+ if (rowClickSelects.value) toggleRow(row, index)
147
+ }
148
+
149
+ // The whole selection cell is the hit target, not just the 16px checkbox.
150
+ // A click on the checkbox itself is already handled by its own update event.
151
+ function onSelectionCellClick (row: TData, index: number, event: MouseEvent) {
152
+ if (event.target === event.currentTarget) toggleRow(row, index)
128
153
  }
129
154
 
130
155
  // -- Sorting --
@@ -440,10 +465,15 @@ defineExpose({
440
465
  <!-- Selection cell: stop click to prevent double toggle with row click -->
441
466
  <TableCell
442
467
  v-if="showSelectionColumn"
443
- :class="cn(stickyLeftClass, selectionColumnClass)"
468
+ :class="cn(
469
+ stickyLeftClass,
470
+ selectionColumnClass,
471
+ isRowSelectable(row, index) && 'cursor-pointer',
472
+ )"
444
473
  :style="selectionColumnStyle"
474
+ :data-hover-target="isSelectionCellHoverable(row, index) || undefined"
445
475
  :data-shadow="selectionColumnShadowDir"
446
- @click.stop
476
+ @click.stop="onSelectionCellClick(row, index, $event)"
447
477
  >
448
478
  <Checkbox
449
479
  :modelValue="isRowSelected(row)"
@@ -597,6 +627,13 @@ defineExpose({
597
627
 
598
628
  :deep(tbody tr) {
599
629
  --cell-overlay: transparent;
630
+ --cell-hover-overlay: transparent;
631
+ }
632
+
633
+ /* Layered over the row's own state tint, so it stays visible on a hovered or
634
+ selected row. */
635
+ :deep(tbody td[data-hover-target]:hover) {
636
+ --cell-hover-overlay: color-mix(in oklab, var(--color-foreground) 6%, transparent);
600
637
  }
601
638
 
602
639
  :deep(tbody tr:not([data-virtual-row]):hover),
@@ -620,6 +657,7 @@ defineExpose({
620
657
  :deep(tbody td) {
621
658
  border-bottom: 1px solid var(--color-border);
622
659
  background:
660
+ linear-gradient(var(--cell-hover-overlay), var(--cell-hover-overlay)),
623
661
  linear-gradient(var(--cell-overlay), var(--cell-overlay))
624
662
  var(--color-card);
625
663
  }
@@ -6,6 +6,9 @@ export type DataTableSelectionMode = 'single' | 'multiple'
6
6
  /** Per-row selection gate: return false to lock a row out of selection */
7
7
  export type DataTableRowSelectable<T = Record<string, any>> = (row: T, index: number) => boolean
8
8
 
9
+ /** Per-row click gate: return false to keep a row from emitting `rowClick` */
10
+ export type DataTableRowClickable<T = Record<string, any>> = (row: T, index: number) => boolean
11
+
9
12
  export interface DataTableColumn {
10
13
  /** Column identifier - used for field binding and slot naming */
11
14
  field: string
@@ -46,6 +49,8 @@ export interface DataTableProps<T = Record<string, any>> {
46
49
  selectionMode?: DataTableSelectionMode
47
50
  /** Per-row selection gate. Rows returning false get a disabled checkbox and ignore row-click selection; a selection they already hold is left untouched. */
48
51
  rowSelectable?: DataTableRowSelectable<T>
52
+ /** Whether clicking anywhere on a row toggles its selection. Default: false — selection toggles only from the selection cell, leaving row clicks to `@rowClick`. */
53
+ selectOnRowClick?: boolean
49
54
  /** Row to highlight as active. Independent from selection; uses the same highlight style. */
50
55
  active?: T | null
51
56
  /** Current sort field */
@@ -56,6 +61,8 @@ export interface DataTableProps<T = Record<string, any>> {
56
61
  loading?: boolean
57
62
  /** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
58
63
  clickable?: boolean
64
+ /** Per-row click gate: rows returning false neither emit `rowClick` nor show the pointer cursor. Selection is gated separately by `rowSelectable`. */
65
+ rowClickable?: DataTableRowClickable<T>
59
66
  /** Whether rows take a hover highlight. Default: true — turn it off where the cells hold form controls, as a tinted row reads as "not editable" there. Selected and active rows keep their highlight either way. */
60
67
  hoverable?: boolean
61
68
  /** Fixed height for the inner scroll container (e.g. '400px'). Enables internal vertical scroll, with sticky header and footer. */
@@ -79,6 +79,7 @@ const meta = {
79
79
  pageSize: { control: 'number' },
80
80
  height: { control: 'text' },
81
81
  clickable: { control: 'boolean' },
82
+ rowClickable: { control: false },
82
83
  hoverable: { control: 'boolean' },
83
84
  },
84
85
  args: {
@@ -89,6 +90,7 @@ const meta = {
89
90
  pageSize: 30,
90
91
  height: '360px',
91
92
  clickable: false,
93
+ rowClickable: undefined,
92
94
  hoverable: true,
93
95
  },
94
96
  render: args => {
@@ -241,6 +243,52 @@ const filters = ref({ sortBy: null, sortOrder: null })
241
243
  }),
242
244
  }
243
245
 
246
+ /** `rowClickable` gates `rowClick` per row: inactive rows here neither emit it nor show the pointer cursor. A click that ends a text selection (e.g. copying an email) emits nothing either. */
247
+ export const RowClickable: Story = {
248
+ parameters: {
249
+ ...noControls,
250
+ docs: {
251
+ source: {
252
+ code: `
253
+ <template>
254
+ <InfiniteDataTable
255
+ :columns="columns"
256
+ :fetchMethod="mockFetch"
257
+ height="360px"
258
+ clickable
259
+ :rowClickable="row => row.status === 'active'"
260
+ @rowClick="row => lastClicked = row"
261
+ />
262
+ </template>
263
+ `.trim(),
264
+ },
265
+ },
266
+ },
267
+ render: () => ({
268
+ components: { InfiniteDataTable: InfiniteDataTable as any },
269
+ setup () {
270
+ const lastClicked = ref<User | null>(null)
271
+ const rowClickable = (row: User) => row.status === 'active'
272
+ return { columns, mockFetch, lastClicked, rowClickable }
273
+ },
274
+ template: `
275
+ <div class="w-full">
276
+ <InfiniteDataTable
277
+ :columns="columns"
278
+ :fetchMethod="mockFetch"
279
+ height="360px"
280
+ clickable
281
+ :rowClickable="rowClickable"
282
+ @rowClick="row => lastClicked = row"
283
+ />
284
+ <div class="mt-2 text-sm text-muted-foreground">
285
+ Last clicked: {{ lastClicked?.name ?? 'none' }}
286
+ </div>
287
+ </div>
288
+ `,
289
+ }),
290
+ }
291
+
244
292
  /** No fixed height — the page scrolls and triggers loading at the bottom */
245
293
  export const PageScroll: Story = {
246
294
  parameters: noControls,
@@ -9,6 +9,7 @@ const props = withDefaults(defineProps<InfiniteDataTableProps<TData>>(), {
9
9
  pageSize: 30,
10
10
  height: undefined,
11
11
  clickable: false,
12
+ rowClickable: undefined,
12
13
  hoverable: true,
13
14
  })
14
15
 
@@ -255,6 +256,7 @@ onMounted(() => {
255
256
  :height
256
257
  :loading="isInitialLoad"
257
258
  :clickable
259
+ :rowClickable
258
260
  :hoverable
259
261
  :sortBy="sortState.sortBy"
260
262
  :sortOrder="sortState.sortOrder"
@@ -1,4 +1,4 @@
1
- import type { DataTableColumn } from '../DataTable/types'
1
+ import type { DataTableColumn, DataTableRowClickable } from '../DataTable/types'
2
2
 
3
3
  export interface InfiniteDataTableFetchParams {
4
4
  /** Opaque cursor pointing at the next page; absent on the first page */
@@ -38,6 +38,8 @@ export interface InfiniteDataTableProps<T = Record<string, any>> {
38
38
  height?: string
39
39
  /** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
40
40
  clickable?: boolean
41
+ /** Per-row click gate: rows returning false neither emit `rowClick` nor show the pointer cursor. Selection is gated separately by `rowSelectable`. */
42
+ rowClickable?: DataTableRowClickable<T>
41
43
  /** Row hover highlight. Default: true. Turn it off where the cells hold form controls — a tinted row reads as "not editable" there. Selected and active rows keep their highlight either way. */
42
44
  hoverable?: boolean
43
45
  }
@@ -78,7 +78,9 @@ const meta = {
78
78
  showPagination: { control: 'boolean' },
79
79
  selectable: { control: 'boolean' },
80
80
  rowSelectable: { control: false },
81
+ selectOnRowClick: { control: 'boolean' },
81
82
  clickable: { control: 'boolean' },
83
+ rowClickable: { control: false },
82
84
  hoverable: { control: 'boolean' },
83
85
  batchActions: { control: 'object' },
84
86
  selection: { control: 'object' },
@@ -94,7 +96,9 @@ const meta = {
94
96
  showPagination: true,
95
97
  selectable: false,
96
98
  rowSelectable: undefined,
99
+ selectOnRowClick: false,
97
100
  clickable: false,
101
+ rowClickable: undefined,
98
102
  hoverable: true,
99
103
  batchActions: [],
100
104
  selection: [],
@@ -155,6 +159,91 @@ export const WithBatchActions: Story = {
155
159
  }),
156
160
  }
157
161
 
162
+ /** `rowClickable` gates `rowClick` per row: inactive rows here neither emit it nor show the pointer cursor. A click that ends a text selection (e.g. copying an email) emits nothing either. */
163
+ export const RowClickable: Story = {
164
+ parameters: {
165
+ ...noControls,
166
+ docs: {
167
+ source: {
168
+ code: `
169
+ <template>
170
+ <StaticDataTable
171
+ :data="users"
172
+ :columns="columns"
173
+ clickable
174
+ :rowClickable="row => row.status === 'active'"
175
+ @rowClick="row => lastClicked = row"
176
+ />
177
+ </template>
178
+ `.trim(),
179
+ },
180
+ },
181
+ },
182
+ render: () => ({
183
+ components: { StaticDataTable },
184
+ setup () {
185
+ const lastClicked = ref<User | null>(null)
186
+ const rowClickable = (row: User) => row.status === 'active'
187
+ return { users: allUsers, columns, lastClicked, rowClickable }
188
+ },
189
+ template: `
190
+ <div class="w-full">
191
+ <StaticDataTable
192
+ :data="users"
193
+ :columns="columns"
194
+ clickable
195
+ :rowClickable="rowClickable"
196
+ @rowClick="row => lastClicked = row"
197
+ />
198
+ <div class="mt-2 text-sm text-muted-foreground">
199
+ Last clicked: {{ lastClicked?.name ?? 'none' }}
200
+ </div>
201
+ </div>
202
+ `,
203
+ }),
204
+ }
205
+
206
+ /** `selectOnRowClick` lets a click anywhere on a row toggle its selection, not just the checkbox cell. */
207
+ export const SelectOnRowClick: Story = {
208
+ parameters: {
209
+ ...noControls,
210
+ docs: {
211
+ source: {
212
+ code: `
213
+ <template>
214
+ <StaticDataTable
215
+ :data="users"
216
+ :columns="columns"
217
+ v-model:selection="selection"
218
+ selectable
219
+ selectOnRowClick
220
+ />
221
+ </template>
222
+ `.trim(),
223
+ },
224
+ },
225
+ },
226
+ render: () => ({
227
+ components: { StaticDataTable },
228
+ setup () {
229
+ const selection = ref<User[]>([])
230
+ return { users: allUsers, columns, selection }
231
+ },
232
+ template: `
233
+ <StaticDataTable
234
+ :data="users"
235
+ :columns="columns"
236
+ v-model:selection="selection"
237
+ selectable
238
+ selectOnRowClick
239
+ />
240
+ <div class="mt-2 text-sm text-muted-foreground">
241
+ Selected: {{ selection.length > 0 ? selection.map(r => r.name).join(', ') : 'none' }}
242
+ </div>
243
+ `,
244
+ }),
245
+ }
246
+
158
247
  /** `rowSelectable` locks individual rows out of selection: their checkbox is disabled and "select all" skips them. */
159
248
  export const DisabledRows: Story = {
160
249
  parameters: {
@@ -17,7 +17,9 @@ const props = withDefaults(defineProps<StaticDataTableProps<TData>>(), {
17
17
  showPagination: true,
18
18
  selectable: false,
19
19
  rowSelectable: undefined,
20
+ selectOnRowClick: false,
20
21
  clickable: false,
22
+ rowClickable: undefined,
21
23
  hoverable: true,
22
24
  batchActions: () => [],
23
25
  selection: () => [],
@@ -205,7 +207,9 @@ function onSortOrderUpdate (value: number | null) {
205
207
  :columns="columns"
206
208
  :selectionMode="showSelectionColumn ? 'multiple' : undefined"
207
209
  :rowSelectable="rowSelectable"
210
+ :selectOnRowClick="selectOnRowClick"
208
211
  :clickable="clickable"
212
+ :rowClickable="rowClickable"
209
213
  :hoverable="hoverable"
210
214
  :sortBy="sortState.sortBy"
211
215
  :sortOrder="sortState.sortOrder"
@@ -1,4 +1,4 @@
1
- import type { DataTableColumn, DataTableRowSelectable } from '../DataTable/types'
1
+ import type { DataTableColumn, DataTableRowClickable, DataTableRowSelectable } from '../DataTable/types'
2
2
  import type { DropdownActionItem, DropdownLabelItem, DropdownSeparatorItem } from '../Dropdown/types'
3
3
 
4
4
  export type StaticDataTableBatchAction<T = Record<string, any>>
@@ -30,8 +30,12 @@ export interface StaticDataTableProps<T = Record<string, any>> {
30
30
  selectable?: boolean
31
31
  /** Per-row selection gate; `index` is relative to the current page. Rows returning false get a disabled checkbox and are skipped by "select all". */
32
32
  rowSelectable?: DataTableRowSelectable<T>
33
+ /** Whether clicking anywhere on a row toggles its selection. Default: false — selection toggles only from the selection cell, leaving row clicks to `@rowClick`. */
34
+ selectOnRowClick?: boolean
33
35
  /** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
34
36
  clickable?: boolean
37
+ /** Per-row click gate: rows returning false neither emit `rowClick` nor show the pointer cursor. Selection is gated separately by `rowSelectable`. */
38
+ rowClickable?: DataTableRowClickable<T>
35
39
  /** Row hover highlight. Default: true. Turn it off where the cells hold form controls — a tinted row reads as "not editable" there. Selected and active rows keep their highlight either way. */
36
40
  hoverable?: boolean
37
41
  /** Batch action definitions for selected rows */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bjj/nuxt-layer-shadcn-ui",
3
- "version": "0.16.1",
3
+ "version": "0.17.1",
4
4
  "description": "Nuxt layer providing shadcn-vue based UI components",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -42,5 +42,5 @@
42
42
  "vue-i18n": "^11",
43
43
  "vue-router": "^4 || ^5"
44
44
  },
45
- "gitHead": "50e38d338fe80994bb04b57f1d9865ab830fe289"
45
+ "gitHead": "f24a3b0af96291da9452cc2618bd57797120f3dd"
46
46
  }