@polymarbot/nuxt-layer-shadcn-ui 0.9.1 → 0.9.3
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.
|
@@ -57,7 +57,7 @@ const rootProps = computed<AccordionRootProps>(() => {
|
|
|
57
57
|
:value="item.value"
|
|
58
58
|
:disabled="item.disabled"
|
|
59
59
|
>
|
|
60
|
-
<AccordionTrigger>
|
|
60
|
+
<AccordionTrigger :class="triggerClass">
|
|
61
61
|
<slot
|
|
62
62
|
name="title"
|
|
63
63
|
:item="item"
|
|
@@ -66,7 +66,7 @@ const rootProps = computed<AccordionRootProps>(() => {
|
|
|
66
66
|
{{ item.title }}
|
|
67
67
|
</slot>
|
|
68
68
|
</AccordionTrigger>
|
|
69
|
-
<AccordionContent>
|
|
69
|
+
<AccordionContent :class="contentClass">
|
|
70
70
|
<slot
|
|
71
71
|
name="content"
|
|
72
72
|
:item="item"
|
|
@@ -220,6 +220,49 @@ export const RowClick: Story = {
|
|
|
220
220
|
}),
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
/** `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. */
|
|
224
|
+
export const ActiveRow: Story = {
|
|
225
|
+
parameters: {
|
|
226
|
+
...noControls,
|
|
227
|
+
docs: {
|
|
228
|
+
source: {
|
|
229
|
+
code: `
|
|
230
|
+
<template>
|
|
231
|
+
<DataTable
|
|
232
|
+
:data="data"
|
|
233
|
+
:columns="columns"
|
|
234
|
+
:active="active"
|
|
235
|
+
clickable
|
|
236
|
+
@rowClick="row => active = row"
|
|
237
|
+
/>
|
|
238
|
+
</template>
|
|
239
|
+
`.trim(),
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
render: () => ({
|
|
244
|
+
components: { DataTable: DataTable as any },
|
|
245
|
+
setup () {
|
|
246
|
+
const active = ref<User | null>(sampleData[1]!)
|
|
247
|
+
return { data: sampleData, basicColumns, active }
|
|
248
|
+
},
|
|
249
|
+
template: `
|
|
250
|
+
<div class="w-full">
|
|
251
|
+
<DataTable
|
|
252
|
+
:data="data"
|
|
253
|
+
:columns="basicColumns"
|
|
254
|
+
:active="active"
|
|
255
|
+
clickable
|
|
256
|
+
@rowClick="row => active = row"
|
|
257
|
+
/>
|
|
258
|
+
<div class="mt-2 text-sm text-muted-foreground">
|
|
259
|
+
Active: {{ active?.name ?? 'none' }}
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
`,
|
|
263
|
+
}),
|
|
264
|
+
}
|
|
265
|
+
|
|
223
266
|
export const Loading: Story = {
|
|
224
267
|
parameters: {
|
|
225
268
|
...noControls,
|
|
@@ -27,6 +27,7 @@ const props = withDefaults(defineProps<DataTableProps<TData>>(), {
|
|
|
27
27
|
loading: false,
|
|
28
28
|
clickable: false,
|
|
29
29
|
height: undefined,
|
|
30
|
+
active: null,
|
|
30
31
|
})
|
|
31
32
|
|
|
32
33
|
const emit = defineEmits<{
|
|
@@ -85,6 +86,10 @@ function isRowSelected (row: TData): boolean {
|
|
|
85
86
|
return toRaw(selection.value) === toRaw(row)
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
function isRowActive (row: TData): boolean {
|
|
90
|
+
return props.active != null && toRaw(props.active) === toRaw(row)
|
|
91
|
+
}
|
|
92
|
+
|
|
88
93
|
function toggleRow (row: TData) {
|
|
89
94
|
const rawRow = toRaw(row) as TData
|
|
90
95
|
if (props.selectionMode === 'single') {
|
|
@@ -387,7 +392,7 @@ defineExpose({
|
|
|
387
392
|
v-for="(row, index) in data"
|
|
388
393
|
:key="index"
|
|
389
394
|
:class="(showSelectionColumn || clickable) && 'cursor-pointer'"
|
|
390
|
-
:data-state="isRowSelected(row) ? 'selected' : undefined"
|
|
395
|
+
:data-state="(isRowSelected(row) || isRowActive(row)) ? 'selected' : undefined"
|
|
391
396
|
@click="onRowClick(row, index, $event)"
|
|
392
397
|
>
|
|
393
398
|
<!-- Selection cell: stop click to prevent double toggle with row click -->
|
|
@@ -520,7 +525,8 @@ defineExpose({
|
|
|
520
525
|
--cell-bg: var(--color-card);
|
|
521
526
|
}
|
|
522
527
|
|
|
523
|
-
:deep(tbody tr:not([data-virtual-row]):hover)
|
|
528
|
+
:deep(tbody tr:not([data-virtual-row]):hover),
|
|
529
|
+
:deep(tbody tr[data-state="selected"]) {
|
|
524
530
|
--cell-bg: var(--color-muted);
|
|
525
531
|
}
|
|
526
532
|
|
|
@@ -39,6 +39,8 @@ export interface DataTableProps<T = Record<string, any>> {
|
|
|
39
39
|
columns?: DataTableColumn[]
|
|
40
40
|
/** Selection mode: single or multiple */
|
|
41
41
|
selectionMode?: DataTableSelectionMode
|
|
42
|
+
/** Row to highlight as active. Independent from selection; uses the same highlight style. */
|
|
43
|
+
active?: T | null
|
|
42
44
|
/** Current sort field */
|
|
43
45
|
sortBy?: string | null
|
|
44
46
|
/** Current sort order: 1 for asc, -1 for desc */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polymarbot/nuxt-layer-shadcn-ui",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
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": "b822984cfbf1b5492a79e13b08e99909b9a70630"
|
|
46
46
|
}
|