@bjj/nuxt-layer-shadcn-ui 0.15.9 → 0.15.11
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/app/assets/styles/globals.css +2 -1
- package/app/assets/styles/menu-icon.css +40 -0
- package/app/components/ui/AsyncDataTable/index.stories.ts +44 -0
- package/app/components/ui/AsyncDataTable/index.vue +2 -0
- package/app/components/ui/AsyncDataTable/types.ts +3 -1
- package/app/components/ui/DataTable/index.stories.ts +46 -0
- package/app/components/ui/DataTable/index.vue +37 -11
- package/app/components/ui/DataTable/types.ts +5 -0
- package/app/components/ui/Dropdown/MenuItems.vue +9 -0
- package/app/components/ui/StaticDataTable/index.stories.ts +44 -0
- package/app/components/ui/StaticDataTable/index.vue +2 -0
- package/app/components/ui/StaticDataTable/types.ts +3 -1
- package/package.json +2 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
* Menu row icons — foreground step
|
|
3
|
+
* -------------------------------------------------------------------------
|
|
4
|
+
* An icon inside a menu row is muted relative to the row's own label:
|
|
5
|
+
* label `--foreground`, icon `--foreground-muted` — the step the trailing
|
|
6
|
+
* icons already used.
|
|
7
|
+
*
|
|
8
|
+
* The vendored shadcn rows declare this themselves, but through a class name
|
|
9
|
+
* whose quoting survives neither Tailwind's scanner nor the DOM, so the rule
|
|
10
|
+
* never matches; those files are regenerated rather than edited, so the step
|
|
11
|
+
* is restored here instead.
|
|
12
|
+
*
|
|
13
|
+
* Unlayered CSS outranks the whole Tailwind utilities layer, which is what
|
|
14
|
+
* makes this win without `!important` — and also means no utility can
|
|
15
|
+
* override it: the only way out is the `:not()` guard below, or another
|
|
16
|
+
* unlayered rule.
|
|
17
|
+
*
|
|
18
|
+
* A row that carries a status color opts its icons back out, so they follow
|
|
19
|
+
* the label the way they do without any rule at all.
|
|
20
|
+
*
|
|
21
|
+
* Two consequences worth knowing before touching a menu row:
|
|
22
|
+
* - The rule takes over every svg in the row, including icons inside nested
|
|
23
|
+
* components that would otherwise inherit their own color. Such an icon
|
|
24
|
+
* needs an explicit `text-*` class to keep it.
|
|
25
|
+
* - `[class*='text-']` matches a substring, so `text-xs` and the like opt an
|
|
26
|
+
* icon out just as `text-primary` does.
|
|
27
|
+
* ========================================================================= */
|
|
28
|
+
|
|
29
|
+
[data-slot='dropdown-menu-item'] svg:not([class*='text-']),
|
|
30
|
+
[data-slot='dropdown-menu-checkbox-item'] svg:not([class*='text-']),
|
|
31
|
+
[data-slot='dropdown-menu-radio-item'] svg:not([class*='text-']),
|
|
32
|
+
[data-slot='dropdown-menu-sub-trigger'] svg:not([class*='text-']),
|
|
33
|
+
[data-slot='dropdown-menu-label'] svg:not([class*='text-']) {
|
|
34
|
+
color: var(--foreground-muted);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[data-slot='dropdown-menu-item'][data-status-color] svg:not([class*='text-']),
|
|
38
|
+
[data-slot='dropdown-menu-sub-trigger'][data-status-color] svg:not([class*='text-']) {
|
|
39
|
+
color: inherit;
|
|
40
|
+
}
|
|
@@ -91,6 +91,7 @@ const meta = {
|
|
|
91
91
|
pageSizeOptions: { control: 'object' },
|
|
92
92
|
showPagination: { control: 'boolean' },
|
|
93
93
|
selectable: { control: 'boolean' },
|
|
94
|
+
rowSelectable: { control: false },
|
|
94
95
|
clickable: { control: 'boolean' },
|
|
95
96
|
batchActions: { control: 'object' },
|
|
96
97
|
selection: { control: 'object' },
|
|
@@ -106,6 +107,7 @@ const meta = {
|
|
|
106
107
|
pageSizeOptions: [ 10, 20, 50 ],
|
|
107
108
|
showPagination: true,
|
|
108
109
|
selectable: false,
|
|
110
|
+
rowSelectable: undefined,
|
|
109
111
|
clickable: false,
|
|
110
112
|
batchActions: [],
|
|
111
113
|
selection: [],
|
|
@@ -169,6 +171,48 @@ export const WithBatchActions: Story = {
|
|
|
169
171
|
}),
|
|
170
172
|
}
|
|
171
173
|
|
|
174
|
+
/** `rowSelectable` locks individual rows out of selection: their checkbox is disabled and "select all" skips them. */
|
|
175
|
+
export const DisabledRows: Story = {
|
|
176
|
+
parameters: {
|
|
177
|
+
...noControls,
|
|
178
|
+
docs: {
|
|
179
|
+
source: {
|
|
180
|
+
code: `
|
|
181
|
+
<template>
|
|
182
|
+
<AsyncDataTable
|
|
183
|
+
:columns="columns"
|
|
184
|
+
:fetchMethod="mockFetch"
|
|
185
|
+
:rowSelectable="row => row.status === 'active'"
|
|
186
|
+
v-model:selection="selection"
|
|
187
|
+
selectable
|
|
188
|
+
/>
|
|
189
|
+
</template>
|
|
190
|
+
`.trim(),
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
render: () => ({
|
|
195
|
+
components: { AsyncDataTable },
|
|
196
|
+
setup () {
|
|
197
|
+
const selection = ref<User[]>([])
|
|
198
|
+
const rowSelectable = (row: User) => row.status === 'active'
|
|
199
|
+
return { columns, mockFetch, selection, rowSelectable }
|
|
200
|
+
},
|
|
201
|
+
template: `
|
|
202
|
+
<AsyncDataTable
|
|
203
|
+
:columns="columns"
|
|
204
|
+
:fetchMethod="mockFetch"
|
|
205
|
+
:rowSelectable="rowSelectable"
|
|
206
|
+
v-model:selection="selection"
|
|
207
|
+
selectable
|
|
208
|
+
/>
|
|
209
|
+
<div class="mt-2 text-sm text-muted-foreground">
|
|
210
|
+
Selected: {{ selection.length > 0 ? selection.map(r => r.name).join(', ') : 'none' }}
|
|
211
|
+
</div>
|
|
212
|
+
`,
|
|
213
|
+
}),
|
|
214
|
+
}
|
|
215
|
+
|
|
172
216
|
/** `v-model:filters` holds the whole query state: `page` / `size` / `sortBy` / `sortOrder` live in the same bag as the caller's own filters, so an external panel drives sorting while the table writes its paging and header sorting back. */
|
|
173
217
|
export const FiltersModel: Story = {
|
|
174
218
|
parameters: {
|
|
@@ -17,6 +17,7 @@ const props = withDefaults(defineProps<AsyncDataTableProps<TData>>(), {
|
|
|
17
17
|
pageSizeOptions: () => [ 10, 20, 50, 100 ],
|
|
18
18
|
showPagination: true,
|
|
19
19
|
selectable: false,
|
|
20
|
+
rowSelectable: undefined,
|
|
20
21
|
clickable: false,
|
|
21
22
|
batchActions: () => [],
|
|
22
23
|
selection: () => [],
|
|
@@ -335,6 +336,7 @@ onMounted(() => {
|
|
|
335
336
|
:columns
|
|
336
337
|
:loading
|
|
337
338
|
:selectionMode="showSelectionColumn ? 'multiple' : undefined"
|
|
339
|
+
:rowSelectable
|
|
338
340
|
:clickable
|
|
339
341
|
:sortBy="sortState.sortBy"
|
|
340
342
|
:sortOrder="sortState.sortOrder"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataTableColumn } from '../DataTable/types'
|
|
1
|
+
import type { DataTableColumn, 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>>
|
|
@@ -44,6 +44,8 @@ export interface AsyncDataTableProps<T = Record<string, any>> {
|
|
|
44
44
|
showPagination?: boolean
|
|
45
45
|
/** Whether rows are selectable */
|
|
46
46
|
selectable?: boolean
|
|
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
|
+
rowSelectable?: DataTableRowSelectable<T>
|
|
47
49
|
/** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
|
|
48
50
|
clickable?: boolean
|
|
49
51
|
/** Batch action definitions for selected rows */
|
|
@@ -77,12 +77,14 @@ const meta = {
|
|
|
77
77
|
component: DataTable as any,
|
|
78
78
|
argTypes: {
|
|
79
79
|
selectionMode: { control: 'select', options: [ undefined, 'single', 'multiple' ]},
|
|
80
|
+
rowSelectable: { control: false },
|
|
80
81
|
loading: { control: 'boolean' },
|
|
81
82
|
clickable: { control: 'boolean' },
|
|
82
83
|
height: { control: 'text' },
|
|
83
84
|
},
|
|
84
85
|
args: {
|
|
85
86
|
selectionMode: undefined,
|
|
87
|
+
rowSelectable: undefined,
|
|
86
88
|
loading: false,
|
|
87
89
|
clickable: false,
|
|
88
90
|
height: undefined,
|
|
@@ -430,6 +432,50 @@ export const MultipleSelection: Story = {
|
|
|
430
432
|
}),
|
|
431
433
|
}
|
|
432
434
|
|
|
435
|
+
export const DisabledRows: Story = {
|
|
436
|
+
parameters: {
|
|
437
|
+
...noControls,
|
|
438
|
+
docs: {
|
|
439
|
+
source: {
|
|
440
|
+
code: `
|
|
441
|
+
<template>
|
|
442
|
+
<DataTable
|
|
443
|
+
:data="data"
|
|
444
|
+
:columns="columns"
|
|
445
|
+
selectionMode="multiple"
|
|
446
|
+
:rowSelectable="row => row.status === 'active'"
|
|
447
|
+
v-model:selection="selection"
|
|
448
|
+
/>
|
|
449
|
+
</template>
|
|
450
|
+
`.trim(),
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
render: () => ({
|
|
455
|
+
components: { DataTable: DataTable as any },
|
|
456
|
+
setup () {
|
|
457
|
+
const selection = ref<User[]>([])
|
|
458
|
+
const rowSelectable = (row: User) => row.status === 'active'
|
|
459
|
+
return { data: sampleData, basicColumns, selection, rowSelectable }
|
|
460
|
+
},
|
|
461
|
+
template: `
|
|
462
|
+
<div class="w-full">
|
|
463
|
+
<DataTable
|
|
464
|
+
:data="data"
|
|
465
|
+
:columns="basicColumns"
|
|
466
|
+
selectionMode="multiple"
|
|
467
|
+
:rowSelectable="rowSelectable"
|
|
468
|
+
v-model:selection="selection"
|
|
469
|
+
/>
|
|
470
|
+
<div class="mt-2 text-sm text-muted-foreground">
|
|
471
|
+
Inactive rows are locked out of selection — Selected:
|
|
472
|
+
{{ selection.length > 0 ? selection.map(r => r.name).join(', ') : 'none' }}
|
|
473
|
+
</div>
|
|
474
|
+
</div>
|
|
475
|
+
`,
|
|
476
|
+
}),
|
|
477
|
+
}
|
|
478
|
+
|
|
433
479
|
export const FrozenColumns: Story = {
|
|
434
480
|
parameters: {
|
|
435
481
|
...noControls,
|
|
@@ -22,6 +22,7 @@ const props = withDefaults(defineProps<DataTableProps<TData>>(), {
|
|
|
22
22
|
data: () => [],
|
|
23
23
|
columns: () => [],
|
|
24
24
|
selectionMode: undefined,
|
|
25
|
+
rowSelectable: undefined,
|
|
25
26
|
sortBy: undefined,
|
|
26
27
|
sortOrder: undefined,
|
|
27
28
|
loading: false,
|
|
@@ -53,25 +54,41 @@ const { formatDateTime } = useDate()
|
|
|
53
54
|
|
|
54
55
|
const showSelectionColumn = computed(() => !!props.selectionMode)
|
|
55
56
|
|
|
57
|
+
function isRowSelectable (row: TData, index: number): boolean {
|
|
58
|
+
return props.rowSelectable ? props.rowSelectable(row, index) : true
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Rows the user is allowed to toggle. A locked row is out of the running for
|
|
62
|
+
// both the header checkbox and "select all".
|
|
63
|
+
const selectableRows = computed(() =>
|
|
64
|
+
props.rowSelectable ? props.data.filter(isRowSelectable) : props.data,
|
|
65
|
+
)
|
|
66
|
+
|
|
56
67
|
// Set of raw references for O(1) lookup, centralizes toRaw conversion
|
|
57
68
|
const selectedSet = computed(() => {
|
|
58
69
|
if (!Array.isArray(selection.value)) return new Set<TData>()
|
|
59
70
|
return new Set(selection.value.map(r => toRaw(r) as TData))
|
|
60
71
|
})
|
|
61
72
|
|
|
62
|
-
// Header "select all" checkbox. Derived from the rows on screen
|
|
63
|
-
// from the selection size, so a selection still holding rows from
|
|
64
|
-
// can't read as "all selected".
|
|
73
|
+
// Header "select all" checkbox. Derived from the selectable rows on screen
|
|
74
|
+
// rather than from the selection size, so a selection still holding rows from
|
|
75
|
+
// elsewhere can't read as "all selected".
|
|
65
76
|
const allChecked = computed({
|
|
66
77
|
get () {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
const rows = selectableRows.value
|
|
79
|
+
if (!rows.length) return false
|
|
80
|
+
const selectedOnPage = rows.filter(row => selectedSet.value.has(toRaw(row) as TData)).length
|
|
81
|
+
if (selectedOnPage === rows.length) return true
|
|
70
82
|
if (selectedOnPage > 0) return 'indeterminate' as const
|
|
71
83
|
return false
|
|
72
84
|
},
|
|
73
85
|
set (val: boolean | 'indeterminate') {
|
|
74
|
-
|
|
86
|
+
// What the user can't toggle one by one, "select all" doesn't touch either:
|
|
87
|
+
// a locked row keeps whatever selection state it arrived with.
|
|
88
|
+
const locked = props.data.filter((row, index) =>
|
|
89
|
+
!isRowSelectable(row, index) && selectedSet.value.has(toRaw(row) as TData),
|
|
90
|
+
)
|
|
91
|
+
selection.value = val === true ? [ ...locked, ...selectableRows.value ] : locked
|
|
75
92
|
},
|
|
76
93
|
})
|
|
77
94
|
|
|
@@ -82,11 +99,18 @@ function isRowSelected (row: TData): boolean {
|
|
|
82
99
|
return toRaw(selection.value) === toRaw(row)
|
|
83
100
|
}
|
|
84
101
|
|
|
102
|
+
// Both selection and the `clickable` contract make a row respond to a click.
|
|
103
|
+
function isRowClickable (row: TData, index: number): boolean {
|
|
104
|
+
return props.clickable || (showSelectionColumn.value && isRowSelectable(row, index))
|
|
105
|
+
}
|
|
106
|
+
|
|
85
107
|
function isRowActive (row: TData): boolean {
|
|
86
108
|
return props.active != null && toRaw(props.active) === toRaw(row)
|
|
87
109
|
}
|
|
88
110
|
|
|
89
|
-
function toggleRow (row: TData) {
|
|
111
|
+
function toggleRow (row: TData, index: number) {
|
|
112
|
+
if (!isRowSelectable(row, index)) return
|
|
113
|
+
|
|
90
114
|
const rawRow = toRaw(row) as TData
|
|
91
115
|
if (props.selectionMode === 'single') {
|
|
92
116
|
selection.value = isRowSelected(row) ? null : rawRow
|
|
@@ -99,7 +123,7 @@ function toggleRow (row: TData) {
|
|
|
99
123
|
|
|
100
124
|
function onRowClick (row: TData, index: number, event: MouseEvent) {
|
|
101
125
|
emit('rowClick', row, index, event)
|
|
102
|
-
if (showSelectionColumn.value) toggleRow(row)
|
|
126
|
+
if (showSelectionColumn.value) toggleRow(row, index)
|
|
103
127
|
}
|
|
104
128
|
|
|
105
129
|
// -- Sorting --
|
|
@@ -342,6 +366,7 @@ defineExpose({
|
|
|
342
366
|
<Checkbox
|
|
343
367
|
v-if="selectionMode === 'multiple'"
|
|
344
368
|
v-model="allChecked"
|
|
369
|
+
:disabled="!selectableRows.length"
|
|
345
370
|
class="bg-background"
|
|
346
371
|
/>
|
|
347
372
|
</TableHead>
|
|
@@ -406,7 +431,7 @@ defineExpose({
|
|
|
406
431
|
<TableRow
|
|
407
432
|
v-for="(row, index) in data"
|
|
408
433
|
:key="index"
|
|
409
|
-
:class="(
|
|
434
|
+
:class="isRowClickable(row, index) && 'cursor-pointer'"
|
|
410
435
|
:data-state="(isRowSelected(row) || isRowActive(row)) ? 'selected' : undefined"
|
|
411
436
|
@click="onRowClick(row, index, $event)"
|
|
412
437
|
>
|
|
@@ -420,8 +445,9 @@ defineExpose({
|
|
|
420
445
|
>
|
|
421
446
|
<Checkbox
|
|
422
447
|
:modelValue="isRowSelected(row)"
|
|
448
|
+
:disabled="!isRowSelectable(row, index)"
|
|
423
449
|
class="bg-muted-foreground/15"
|
|
424
|
-
@update:modelValue="toggleRow(row)"
|
|
450
|
+
@update:modelValue="toggleRow(row, index)"
|
|
425
451
|
/>
|
|
426
452
|
</TableCell>
|
|
427
453
|
|
|
@@ -3,6 +3,9 @@ export type DataTableColumnFixed = 'left' | 'right'
|
|
|
3
3
|
export type DataTableColumnAlign = 'left' | 'center' | 'right'
|
|
4
4
|
export type DataTableSelectionMode = 'single' | 'multiple'
|
|
5
5
|
|
|
6
|
+
/** Per-row selection gate: return false to lock a row out of selection */
|
|
7
|
+
export type DataTableRowSelectable<T = Record<string, any>> = (row: T, index: number) => boolean
|
|
8
|
+
|
|
6
9
|
export interface DataTableColumn {
|
|
7
10
|
/** Column identifier - used for field binding and slot naming */
|
|
8
11
|
field: string
|
|
@@ -41,6 +44,8 @@ export interface DataTableProps<T = Record<string, any>> {
|
|
|
41
44
|
columns?: DataTableColumn[]
|
|
42
45
|
/** Selection mode: single or multiple */
|
|
43
46
|
selectionMode?: DataTableSelectionMode
|
|
47
|
+
/** 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
|
+
rowSelectable?: DataTableRowSelectable<T>
|
|
44
49
|
/** Row to highlight as active. Independent from selection; uses the same highlight style. */
|
|
45
50
|
active?: T | null
|
|
46
51
|
/** Current sort field */
|
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
DropdownActionItem,
|
|
15
15
|
DropdownCustomActionItem,
|
|
16
16
|
DropdownItem,
|
|
17
|
+
DropdownItemColor,
|
|
17
18
|
} from './types'
|
|
18
19
|
|
|
19
20
|
const actionColorVariants = cva('', {
|
|
@@ -59,6 +60,11 @@ defineProps<{
|
|
|
59
60
|
menus: DropdownItem[]
|
|
60
61
|
}>()
|
|
61
62
|
|
|
63
|
+
// Marks rows the stylesheet must leave alone, so their icons keep following
|
|
64
|
+
// the label's status color instead of taking the muted step.
|
|
65
|
+
const statusColor = (color?: DropdownItemColor) =>
|
|
66
|
+
color && color !== 'default' ? color : undefined
|
|
67
|
+
|
|
62
68
|
const ctx = inject(dropdownContextKey)
|
|
63
69
|
|
|
64
70
|
const handleItemAction = (
|
|
@@ -102,6 +108,7 @@ const handleItemAction = (
|
|
|
102
108
|
<DropdownMenuItem
|
|
103
109
|
v-else-if="menu.type === 'custom-action'"
|
|
104
110
|
:disabled="menu.disabled"
|
|
111
|
+
:data-status-color="statusColor(menu.color)"
|
|
105
112
|
:class="cn(actionColorVariants({ color: menu.color }), menu.class)"
|
|
106
113
|
@click="handleItemAction(menu, $event)"
|
|
107
114
|
>
|
|
@@ -119,6 +126,7 @@ const handleItemAction = (
|
|
|
119
126
|
<DropdownMenuSub v-else-if="menu.subMenus?.length">
|
|
120
127
|
<DropdownMenuSubTrigger
|
|
121
128
|
:disabled="menu.disabled"
|
|
129
|
+
:data-status-color="statusColor(menu.color)"
|
|
122
130
|
:class="cn(actionColorVariants({ color: menu.color }), menu.class)"
|
|
123
131
|
>
|
|
124
132
|
<ItemContent :item="menu" />
|
|
@@ -137,6 +145,7 @@ const handleItemAction = (
|
|
|
137
145
|
v-else
|
|
138
146
|
:disabled="menu.disabled"
|
|
139
147
|
:asChild="!!menu.href"
|
|
148
|
+
:data-status-color="statusColor(menu.color)"
|
|
140
149
|
:class="cn(actionColorVariants({ color: menu.color }), menu.class)"
|
|
141
150
|
@click="handleItemAction(menu, $event)"
|
|
142
151
|
>
|
|
@@ -77,6 +77,7 @@ const meta = {
|
|
|
77
77
|
pageSizeOptions: { control: 'object' },
|
|
78
78
|
showPagination: { control: 'boolean' },
|
|
79
79
|
selectable: { control: 'boolean' },
|
|
80
|
+
rowSelectable: { control: false },
|
|
80
81
|
clickable: { control: 'boolean' },
|
|
81
82
|
batchActions: { control: 'object' },
|
|
82
83
|
selection: { control: 'object' },
|
|
@@ -91,6 +92,7 @@ const meta = {
|
|
|
91
92
|
pageSizeOptions: [ 10, 20, 50 ],
|
|
92
93
|
showPagination: true,
|
|
93
94
|
selectable: false,
|
|
95
|
+
rowSelectable: undefined,
|
|
94
96
|
clickable: false,
|
|
95
97
|
batchActions: [],
|
|
96
98
|
selection: [],
|
|
@@ -151,6 +153,48 @@ export const WithBatchActions: Story = {
|
|
|
151
153
|
}),
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
/** `rowSelectable` locks individual rows out of selection: their checkbox is disabled and "select all" skips them. */
|
|
157
|
+
export const DisabledRows: Story = {
|
|
158
|
+
parameters: {
|
|
159
|
+
...noControls,
|
|
160
|
+
docs: {
|
|
161
|
+
source: {
|
|
162
|
+
code: `
|
|
163
|
+
<template>
|
|
164
|
+
<StaticDataTable
|
|
165
|
+
:data="users"
|
|
166
|
+
:columns="columns"
|
|
167
|
+
:rowSelectable="row => row.status === 'active'"
|
|
168
|
+
v-model:selection="selection"
|
|
169
|
+
selectable
|
|
170
|
+
/>
|
|
171
|
+
</template>
|
|
172
|
+
`.trim(),
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
render: () => ({
|
|
177
|
+
components: { StaticDataTable },
|
|
178
|
+
setup () {
|
|
179
|
+
const selection = ref<User[]>([])
|
|
180
|
+
const rowSelectable = (row: User) => row.status === 'active'
|
|
181
|
+
return { users: allUsers, columns, selection, rowSelectable }
|
|
182
|
+
},
|
|
183
|
+
template: `
|
|
184
|
+
<StaticDataTable
|
|
185
|
+
:data="users"
|
|
186
|
+
:columns="columns"
|
|
187
|
+
:rowSelectable="rowSelectable"
|
|
188
|
+
v-model:selection="selection"
|
|
189
|
+
selectable
|
|
190
|
+
/>
|
|
191
|
+
<div class="mt-2 text-sm text-muted-foreground">
|
|
192
|
+
Selected: {{ selection.length > 0 ? selection.map(r => r.name).join(', ') : 'none' }}
|
|
193
|
+
</div>
|
|
194
|
+
`,
|
|
195
|
+
}),
|
|
196
|
+
}
|
|
197
|
+
|
|
154
198
|
/** Custom toolbar slot with an action button. */
|
|
155
199
|
export const WithCustomToolbar: Story = {
|
|
156
200
|
parameters: {
|
|
@@ -16,6 +16,7 @@ const props = withDefaults(defineProps<StaticDataTableProps<TData>>(), {
|
|
|
16
16
|
pageSizeOptions: () => [ 10, 20, 50, 100 ],
|
|
17
17
|
showPagination: true,
|
|
18
18
|
selectable: false,
|
|
19
|
+
rowSelectable: undefined,
|
|
19
20
|
clickable: false,
|
|
20
21
|
batchActions: () => [],
|
|
21
22
|
selection: () => [],
|
|
@@ -202,6 +203,7 @@ function onSortOrderUpdate (value: number | null) {
|
|
|
202
203
|
:data="tableData"
|
|
203
204
|
:columns="columns"
|
|
204
205
|
:selectionMode="showSelectionColumn ? 'multiple' : undefined"
|
|
206
|
+
:rowSelectable="rowSelectable"
|
|
205
207
|
:clickable="clickable"
|
|
206
208
|
:sortBy="sortState.sortBy"
|
|
207
209
|
:sortOrder="sortState.sortOrder"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataTableColumn } from '../DataTable/types'
|
|
1
|
+
import type { DataTableColumn, 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>>
|
|
@@ -28,6 +28,8 @@ export interface StaticDataTableProps<T = Record<string, any>> {
|
|
|
28
28
|
showPagination?: boolean
|
|
29
29
|
/** Whether rows are selectable */
|
|
30
30
|
selectable?: boolean
|
|
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
|
+
rowSelectable?: DataTableRowSelectable<T>
|
|
31
33
|
/** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
|
|
32
34
|
clickable?: boolean
|
|
33
35
|
/** 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.15.
|
|
3
|
+
"version": "0.15.11",
|
|
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": "
|
|
45
|
+
"gitHead": "407e501d5ee2dcbde1afd91db36c51e994416e29"
|
|
46
46
|
}
|