@bjj/nuxt-layer-shadcn-ui 0.17.0 → 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.
@@ -94,6 +94,7 @@ const meta = {
94
94
  rowSelectable: { control: false },
95
95
  selectOnRowClick: { control: 'boolean' },
96
96
  clickable: { control: 'boolean' },
97
+ rowClickable: { control: false },
97
98
  hoverable: { control: 'boolean' },
98
99
  batchActions: { control: 'object' },
99
100
  selection: { control: 'object' },
@@ -112,6 +113,7 @@ const meta = {
112
113
  rowSelectable: undefined,
113
114
  selectOnRowClick: false,
114
115
  clickable: false,
116
+ rowClickable: undefined,
115
117
  hoverable: true,
116
118
  batchActions: [],
117
119
  selection: [],
@@ -175,6 +177,50 @@ export const WithBatchActions: Story = {
175
177
  }),
176
178
  }
177
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
+
178
224
  /** `selectOnRowClick` lets a click anywhere on a row toggle its selection, not just the checkbox cell. */
179
225
  export const SelectOnRowClick: Story = {
180
226
  parameters: {
@@ -20,6 +20,7 @@ const props = withDefaults(defineProps<AsyncDataTableProps<TData>>(), {
20
20
  rowSelectable: undefined,
21
21
  selectOnRowClick: false,
22
22
  clickable: false,
23
+ rowClickable: undefined,
23
24
  hoverable: true,
24
25
  batchActions: () => [],
25
26
  selection: () => [],
@@ -341,6 +342,7 @@ onMounted(() => {
341
342
  :rowSelectable
342
343
  :selectOnRowClick
343
344
  :clickable
345
+ :rowClickable
344
346
  :hoverable
345
347
  :sortBy="sortState.sortBy"
346
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>>
@@ -50,6 +50,8 @@ export interface AsyncDataTableProps<T = Record<string, any>> {
50
50
  selectOnRowClick?: boolean
51
51
  /** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
52
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>
53
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. */
54
56
  hoverable?: boolean
55
57
  /** Batch action definitions for selected rows */
@@ -82,6 +82,7 @@ const meta = {
82
82
  selectOnRowClick: { control: 'boolean' },
83
83
  loading: { control: 'boolean' },
84
84
  clickable: { control: 'boolean' },
85
+ rowClickable: { control: false },
85
86
  hoverable: { control: 'boolean' },
86
87
  height: { control: 'text' },
87
88
  },
@@ -91,6 +92,7 @@ const meta = {
91
92
  selectOnRowClick: false,
92
93
  loading: false,
93
94
  clickable: false,
95
+ rowClickable: undefined,
94
96
  hoverable: true,
95
97
  height: undefined,
96
98
  },
@@ -274,6 +276,50 @@ export const RowClick: Story = {
274
276
  }),
275
277
  }
276
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
+
277
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. */
278
324
  export const ActiveRow: Story = {
279
325
  parameters: {
@@ -28,6 +28,7 @@ const props = withDefaults(defineProps<DataTableProps<TData>>(), {
28
28
  sortOrder: undefined,
29
29
  loading: false,
30
30
  clickable: false,
31
+ rowClickable: undefined,
31
32
  hoverable: true,
32
33
  height: undefined,
33
34
  active: null,
@@ -104,9 +105,20 @@ function isRowSelected (row: TData): boolean {
104
105
  // Whether a click on the row body toggles the row's selection.
105
106
  const rowClickSelects = computed(() => showSelectionColumn.value && props.selectOnRowClick)
106
107
 
108
+ function emitsRowClick (row: TData, index: number): boolean {
109
+ return props.rowClickable ? props.rowClickable(row, index) : true
110
+ }
111
+
107
112
  // Both row-click selection and the `clickable` contract make a row respond to a click.
108
113
  function isRowClickable (row: TData, index: number): boolean {
109
- return props.clickable || (rowClickSelects.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)
110
122
  }
111
123
 
112
124
  function isRowActive (row: TData): boolean {
@@ -127,7 +139,10 @@ function toggleRow (row: TData, index: number) {
127
139
  }
128
140
 
129
141
  function onRowClick (row: TData, index: number, event: MouseEvent) {
130
- emit('rowClick', row, index, event)
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)
131
146
  if (rowClickSelects.value) toggleRow(row, index)
132
147
  }
133
148
 
@@ -456,6 +471,7 @@ defineExpose({
456
471
  isRowSelectable(row, index) && 'cursor-pointer',
457
472
  )"
458
473
  :style="selectionColumnStyle"
474
+ :data-hover-target="isSelectionCellHoverable(row, index) || undefined"
459
475
  :data-shadow="selectionColumnShadowDir"
460
476
  @click.stop="onSelectionCellClick(row, index, $event)"
461
477
  >
@@ -611,6 +627,13 @@ defineExpose({
611
627
 
612
628
  :deep(tbody tr) {
613
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);
614
637
  }
615
638
 
616
639
  :deep(tbody tr:not([data-virtual-row]):hover),
@@ -634,6 +657,7 @@ defineExpose({
634
657
  :deep(tbody td) {
635
658
  border-bottom: 1px solid var(--color-border);
636
659
  background:
660
+ linear-gradient(var(--cell-hover-overlay), var(--cell-hover-overlay)),
637
661
  linear-gradient(var(--cell-overlay), var(--cell-overlay))
638
662
  var(--color-card);
639
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
@@ -58,6 +61,8 @@ export interface DataTableProps<T = Record<string, any>> {
58
61
  loading?: boolean
59
62
  /** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
60
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>
61
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. */
62
67
  hoverable?: boolean
63
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
  }
@@ -80,6 +80,7 @@ const meta = {
80
80
  rowSelectable: { control: false },
81
81
  selectOnRowClick: { control: 'boolean' },
82
82
  clickable: { control: 'boolean' },
83
+ rowClickable: { control: false },
83
84
  hoverable: { control: 'boolean' },
84
85
  batchActions: { control: 'object' },
85
86
  selection: { control: 'object' },
@@ -97,6 +98,7 @@ const meta = {
97
98
  rowSelectable: undefined,
98
99
  selectOnRowClick: false,
99
100
  clickable: false,
101
+ rowClickable: undefined,
100
102
  hoverable: true,
101
103
  batchActions: [],
102
104
  selection: [],
@@ -157,6 +159,50 @@ export const WithBatchActions: Story = {
157
159
  }),
158
160
  }
159
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
+
160
206
  /** `selectOnRowClick` lets a click anywhere on a row toggle its selection, not just the checkbox cell. */
161
207
  export const SelectOnRowClick: Story = {
162
208
  parameters: {
@@ -19,6 +19,7 @@ const props = withDefaults(defineProps<StaticDataTableProps<TData>>(), {
19
19
  rowSelectable: undefined,
20
20
  selectOnRowClick: false,
21
21
  clickable: false,
22
+ rowClickable: undefined,
22
23
  hoverable: true,
23
24
  batchActions: () => [],
24
25
  selection: () => [],
@@ -208,6 +209,7 @@ function onSortOrderUpdate (value: number | null) {
208
209
  :rowSelectable="rowSelectable"
209
210
  :selectOnRowClick="selectOnRowClick"
210
211
  :clickable="clickable"
212
+ :rowClickable="rowClickable"
211
213
  :hoverable="hoverable"
212
214
  :sortBy="sortState.sortBy"
213
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>>
@@ -34,6 +34,8 @@ export interface StaticDataTableProps<T = Record<string, any>> {
34
34
  selectOnRowClick?: boolean
35
35
  /** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
36
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>
37
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. */
38
40
  hoverable?: boolean
39
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.17.0",
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": "baefb8dd7a1d57a9a3b34fe53bda45a845153b2c"
45
+ "gitHead": "f24a3b0af96291da9452cc2618bd57797120f3dd"
46
46
  }