@bjj/nuxt-layer-shadcn-ui 0.15.10 → 0.15.16
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/assets/styles/overlay.css +6 -7
- package/app/components/ui/AsyncDataTable/index.stories.ts +2 -0
- package/app/components/ui/AsyncDataTable/index.vue +2 -0
- package/app/components/ui/AsyncDataTable/types.ts +2 -0
- package/app/components/ui/DataTable/index.stories.ts +54 -0
- package/app/components/ui/DataTable/index.vue +13 -0
- package/app/components/ui/DataTable/types.ts +2 -0
- package/app/components/ui/Dropdown/MenuItems.vue +9 -0
- package/app/components/ui/FormItem/index.stories.ts +127 -0
- package/app/components/ui/FormItem/index.vue +86 -14
- package/app/components/ui/InfiniteDataTable/index.stories.ts +2 -0
- package/app/components/ui/InfiniteDataTable/index.vue +2 -0
- package/app/components/ui/InfiniteDataTable/types.ts +2 -0
- package/app/components/ui/StaticDataTable/index.stories.ts +2 -0
- package/app/components/ui/StaticDataTable/index.vue +2 -0
- package/app/components/ui/StaticDataTable/types.ts +2 -0
- package/nuxt.config.ts +10 -3
- 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
|
+
}
|
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
* here so Modal and Drawer keep a consistent translucent blur backdrop.
|
|
7
7
|
* ========================================================================= */
|
|
8
8
|
|
|
9
|
+
/* One dark scrim for both themes: a light tint reads as a blurred page rather
|
|
10
|
+
than a page put behind the dialog, and in dark mode it would have to be dark
|
|
11
|
+
anyway. Kept shallow — the dialog sits on an opaque card, so the scrim only
|
|
12
|
+
has to push the page back, not hide it. */
|
|
9
13
|
[data-slot='dialog-overlay'],
|
|
10
14
|
[data-slot='sheet-overlay'] {
|
|
11
|
-
background-color: rgba(
|
|
12
|
-
backdrop-filter: blur(
|
|
15
|
+
background-color: rgba(0, 0, 0, 0.26);
|
|
16
|
+
backdrop-filter: blur(2px);
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
.dark [data-slot='dialog-overlay'],
|
|
16
|
-
.dark [data-slot='sheet-overlay'] {
|
|
17
|
-
background-color: rgba(25, 25, 25, 0.3);
|
|
18
|
-
}
|
|
@@ -93,6 +93,7 @@ const meta = {
|
|
|
93
93
|
selectable: { control: 'boolean' },
|
|
94
94
|
rowSelectable: { control: false },
|
|
95
95
|
clickable: { control: 'boolean' },
|
|
96
|
+
hoverable: { control: 'boolean' },
|
|
96
97
|
batchActions: { control: 'object' },
|
|
97
98
|
selection: { control: 'object' },
|
|
98
99
|
},
|
|
@@ -109,6 +110,7 @@ const meta = {
|
|
|
109
110
|
selectable: false,
|
|
110
111
|
rowSelectable: undefined,
|
|
111
112
|
clickable: false,
|
|
113
|
+
hoverable: true,
|
|
112
114
|
batchActions: [],
|
|
113
115
|
selection: [],
|
|
114
116
|
},
|
|
@@ -19,6 +19,7 @@ const props = withDefaults(defineProps<AsyncDataTableProps<TData>>(), {
|
|
|
19
19
|
selectable: false,
|
|
20
20
|
rowSelectable: undefined,
|
|
21
21
|
clickable: false,
|
|
22
|
+
hoverable: true,
|
|
22
23
|
batchActions: () => [],
|
|
23
24
|
selection: () => [],
|
|
24
25
|
})
|
|
@@ -338,6 +339,7 @@ onMounted(() => {
|
|
|
338
339
|
:selectionMode="showSelectionColumn ? 'multiple' : undefined"
|
|
339
340
|
:rowSelectable
|
|
340
341
|
:clickable
|
|
342
|
+
:hoverable
|
|
341
343
|
:sortBy="sortState.sortBy"
|
|
342
344
|
:sortOrder="sortState.sortOrder"
|
|
343
345
|
@update:selection="onSelectionChange"
|
|
@@ -48,6 +48,8 @@ export interface AsyncDataTableProps<T = Record<string, any>> {
|
|
|
48
48
|
rowSelectable?: DataTableRowSelectable<T>
|
|
49
49
|
/** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
|
|
50
50
|
clickable?: boolean
|
|
51
|
+
/** 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
|
+
hoverable?: boolean
|
|
51
53
|
/** Batch action definitions for selected rows */
|
|
52
54
|
batchActions?: AsyncDataTableBatchAction<T>[]
|
|
53
55
|
/** Selected rows (v-model:selection). Cleared whenever a fetch replaces the rows — paging, sorting, filtering, refresh. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import Input from '../Input/index.vue'
|
|
2
3
|
import Tag from '../Tag/index.vue'
|
|
3
4
|
import type { DataTableColumn } from './types'
|
|
4
5
|
import DataTable from './index.vue'
|
|
@@ -80,6 +81,7 @@ const meta = {
|
|
|
80
81
|
rowSelectable: { control: false },
|
|
81
82
|
loading: { control: 'boolean' },
|
|
82
83
|
clickable: { control: 'boolean' },
|
|
84
|
+
hoverable: { control: 'boolean' },
|
|
83
85
|
height: { control: 'text' },
|
|
84
86
|
},
|
|
85
87
|
args: {
|
|
@@ -87,6 +89,7 @@ const meta = {
|
|
|
87
89
|
rowSelectable: undefined,
|
|
88
90
|
loading: false,
|
|
89
91
|
clickable: false,
|
|
92
|
+
hoverable: true,
|
|
90
93
|
height: undefined,
|
|
91
94
|
},
|
|
92
95
|
render: args => ({
|
|
@@ -312,6 +315,57 @@ export const ActiveRow: Story = {
|
|
|
312
315
|
}),
|
|
313
316
|
}
|
|
314
317
|
|
|
318
|
+
/** A form grid: the hover tint would read as "this row is not editable", so it is turned off. Hover any row — only the selected one stays tinted. */
|
|
319
|
+
export const NoHover: Story = {
|
|
320
|
+
parameters: {
|
|
321
|
+
...noControls,
|
|
322
|
+
docs: {
|
|
323
|
+
source: {
|
|
324
|
+
code: `
|
|
325
|
+
<template>
|
|
326
|
+
<DataTable
|
|
327
|
+
v-model:selection="selection"
|
|
328
|
+
:data="data"
|
|
329
|
+
:columns="columns"
|
|
330
|
+
selectionMode="single"
|
|
331
|
+
:hoverable="false"
|
|
332
|
+
>
|
|
333
|
+
<template #name="{ row }">
|
|
334
|
+
<Input v-model="row.name" />
|
|
335
|
+
</template>
|
|
336
|
+
</DataTable>
|
|
337
|
+
</template>
|
|
338
|
+
`.trim(),
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
render: () => ({
|
|
343
|
+
components: { DataTable: DataTable as any, Input },
|
|
344
|
+
setup () {
|
|
345
|
+
// Own copy: the inputs write straight into the row objects, and
|
|
346
|
+
// `sampleData` is shared with every other story in this file.
|
|
347
|
+
const data = reactive(sampleData.map(row => ({ ...row })))
|
|
348
|
+
const selection = ref(data[1])
|
|
349
|
+
return { data, basicColumns, selection }
|
|
350
|
+
},
|
|
351
|
+
template: `
|
|
352
|
+
<div class="w-full">
|
|
353
|
+
<DataTable
|
|
354
|
+
v-model:selection="selection"
|
|
355
|
+
:data="data"
|
|
356
|
+
:columns="basicColumns"
|
|
357
|
+
selectionMode="single"
|
|
358
|
+
:hoverable="false"
|
|
359
|
+
>
|
|
360
|
+
<template #name="{ row }">
|
|
361
|
+
<Input v-model="row.name" />
|
|
362
|
+
</template>
|
|
363
|
+
</DataTable>
|
|
364
|
+
</div>
|
|
365
|
+
`,
|
|
366
|
+
}),
|
|
367
|
+
}
|
|
368
|
+
|
|
315
369
|
export const Loading: Story = {
|
|
316
370
|
parameters: {
|
|
317
371
|
...noControls,
|
|
@@ -27,6 +27,7 @@ const props = withDefaults(defineProps<DataTableProps<TData>>(), {
|
|
|
27
27
|
sortOrder: undefined,
|
|
28
28
|
loading: false,
|
|
29
29
|
clickable: false,
|
|
30
|
+
hoverable: true,
|
|
30
31
|
height: undefined,
|
|
31
32
|
active: null,
|
|
32
33
|
})
|
|
@@ -324,6 +325,7 @@ defineExpose({
|
|
|
324
325
|
`,
|
|
325
326
|
!$slots.footer && 'pb-1',
|
|
326
327
|
height && 'has-sticky-bounds',
|
|
328
|
+
!hoverable && 'no-hover',
|
|
327
329
|
)"
|
|
328
330
|
:style="heightStyle"
|
|
329
331
|
>
|
|
@@ -602,6 +604,17 @@ defineExpose({
|
|
|
602
604
|
--cell-overlay: var(--color-muted);
|
|
603
605
|
}
|
|
604
606
|
|
|
607
|
+
/* Drops the hover tint only, so a selected or active row still stands out.
|
|
608
|
+
Consumers cannot do this from the outside: the tint is painted by the cell's
|
|
609
|
+
`background` shorthand, which a `bg-*` utility on the row never reaches.
|
|
610
|
+
`TableRow` carries its own `hover:bg-muted/50`, invisible here only because
|
|
611
|
+
the cells paint an opaque base over it — clearing it too keeps this working
|
|
612
|
+
if a cell ever stops being opaque. */
|
|
613
|
+
.no-hover :deep(tbody tr:not([data-state="selected"]):hover) {
|
|
614
|
+
--cell-overlay: transparent;
|
|
615
|
+
background-color: transparent;
|
|
616
|
+
}
|
|
617
|
+
|
|
605
618
|
/* Opaque card base under a translucent state overlay: frozen (sticky) cells
|
|
606
619
|
must fully occlude columns scrolling beneath them. */
|
|
607
620
|
:deep(tbody td) {
|
|
@@ -56,6 +56,8 @@ export interface DataTableProps<T = Record<string, any>> {
|
|
|
56
56
|
loading?: boolean
|
|
57
57
|
/** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
|
|
58
58
|
clickable?: boolean
|
|
59
|
+
/** 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
|
+
hoverable?: boolean
|
|
59
61
|
/** Fixed height for the inner scroll container (e.g. '400px'). Enables internal vertical scroll, with sticky header and footer. */
|
|
60
62
|
height?: string
|
|
61
63
|
}
|
|
@@ -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
|
>
|
|
@@ -20,6 +20,8 @@ import RadioGroup from '../RadioGroup/index.vue'
|
|
|
20
20
|
import SearchSelect from '../SearchSelect/index.vue'
|
|
21
21
|
import Select from '../Select/index.vue'
|
|
22
22
|
import Textarea from '../Textarea/index.vue'
|
|
23
|
+
import Help from '../Help/index.vue'
|
|
24
|
+
import Icon from '../Icon/index.vue'
|
|
23
25
|
import FormItem from './index.vue'
|
|
24
26
|
|
|
25
27
|
const orientations = [ 'vertical', 'horizontal', 'responsive' ] as const
|
|
@@ -87,6 +89,131 @@ export const Horizontal: Story = {
|
|
|
87
89
|
},
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
export const LabelSlot: Story = {
|
|
93
|
+
parameters: {
|
|
94
|
+
...noControls,
|
|
95
|
+
docs: {
|
|
96
|
+
description: {
|
|
97
|
+
story: 'The `#label` slot replaces the label text (defaults to the `label` prop). The required asterisk is still appended, and the slot alone is enough to render the label row.',
|
|
98
|
+
},
|
|
99
|
+
source: {
|
|
100
|
+
code: `
|
|
101
|
+
<template>
|
|
102
|
+
<FormItem required>
|
|
103
|
+
<template #label>
|
|
104
|
+
Nickname <span class="text-muted-foreground font-normal">(optional display)</span>
|
|
105
|
+
</template>
|
|
106
|
+
<Input placeholder="Enter value" />
|
|
107
|
+
</FormItem>
|
|
108
|
+
</template>
|
|
109
|
+
`.trim(),
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
render: () => ({
|
|
114
|
+
components: { FormItem, Input },
|
|
115
|
+
template: `
|
|
116
|
+
<div class="max-w-md">
|
|
117
|
+
<FormItem required>
|
|
118
|
+
<template #label>
|
|
119
|
+
Nickname <span class="text-muted-foreground font-normal">(optional display)</span>
|
|
120
|
+
</template>
|
|
121
|
+
<Input placeholder="Enter value" />
|
|
122
|
+
</FormItem>
|
|
123
|
+
</div>
|
|
124
|
+
`,
|
|
125
|
+
}),
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const LabelSuffix: Story = {
|
|
129
|
+
parameters: {
|
|
130
|
+
...noControls,
|
|
131
|
+
docs: {
|
|
132
|
+
description: {
|
|
133
|
+
story: 'The `#labelSuffix` slot appends inline content after the label text and the required asterisk.',
|
|
134
|
+
},
|
|
135
|
+
source: {
|
|
136
|
+
code: `
|
|
137
|
+
<template>
|
|
138
|
+
<FormItem required label="API Key">
|
|
139
|
+
<template #labelSuffix>
|
|
140
|
+
<Help text="Find it under Settings → Developers" />
|
|
141
|
+
</template>
|
|
142
|
+
<Input placeholder="Enter value" />
|
|
143
|
+
</FormItem>
|
|
144
|
+
</template>
|
|
145
|
+
`.trim(),
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
render: () => ({
|
|
150
|
+
components: { FormItem, Input, Help },
|
|
151
|
+
template: `
|
|
152
|
+
<div class="max-w-md space-y-6">
|
|
153
|
+
<FormItem required label="API Key">
|
|
154
|
+
<template #labelSuffix>
|
|
155
|
+
<Help text="Find it under Settings → Developers" />
|
|
156
|
+
</template>
|
|
157
|
+
<Input placeholder="Enter value" />
|
|
158
|
+
</FormItem>
|
|
159
|
+
<FormItem label="Webhook URL">
|
|
160
|
+
<template #labelSuffix>
|
|
161
|
+
<span class="text-muted-foreground font-normal">(optional)</span>
|
|
162
|
+
</template>
|
|
163
|
+
<Input placeholder="Enter value" />
|
|
164
|
+
</FormItem>
|
|
165
|
+
</div>
|
|
166
|
+
`,
|
|
167
|
+
}),
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export const LabelExtra: Story = {
|
|
171
|
+
parameters: {
|
|
172
|
+
...noControls,
|
|
173
|
+
docs: {
|
|
174
|
+
description: {
|
|
175
|
+
story: 'The `#labelExtra` slot puts extra content on the label row, aligned to the trailing edge. In `horizontal` orientation it sits right after the label in the label column.',
|
|
176
|
+
},
|
|
177
|
+
source: {
|
|
178
|
+
code: `
|
|
179
|
+
<template>
|
|
180
|
+
<FormItem required label="English">
|
|
181
|
+
<template #labelExtra>
|
|
182
|
+
<span class="inline-flex items-center gap-1 text-success">
|
|
183
|
+
<Icon name="check" class="size-3.5" /> Filled
|
|
184
|
+
</span>
|
|
185
|
+
</template>
|
|
186
|
+
<Input placeholder="Enter value" />
|
|
187
|
+
</FormItem>
|
|
188
|
+
</template>
|
|
189
|
+
`.trim(),
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
render: () => ({
|
|
194
|
+
components: { FormItem, Input, Icon },
|
|
195
|
+
setup: () => ({ orientations }),
|
|
196
|
+
template: `
|
|
197
|
+
<div class="max-w-md space-y-6">
|
|
198
|
+
<FormItem
|
|
199
|
+
v-for="o in orientations"
|
|
200
|
+
:key="o"
|
|
201
|
+
required
|
|
202
|
+
:label="o"
|
|
203
|
+
:orientation="o"
|
|
204
|
+
>
|
|
205
|
+
<template #labelExtra>
|
|
206
|
+
<span class="inline-flex items-center gap-1 text-success">
|
|
207
|
+
<Icon name="check" class="size-3.5" /> Filled
|
|
208
|
+
</span>
|
|
209
|
+
</template>
|
|
210
|
+
<Input placeholder="Enter value" />
|
|
211
|
+
</FormItem>
|
|
212
|
+
</div>
|
|
213
|
+
`,
|
|
214
|
+
}),
|
|
215
|
+
}
|
|
216
|
+
|
|
90
217
|
const selectOptions: SelectOption[] = [
|
|
91
218
|
{ label: 'React', value: 'react' },
|
|
92
219
|
{ label: 'Vue', value: 'vue' },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { createReusableTemplate } from '@vueuse/core'
|
|
2
3
|
import {
|
|
3
4
|
Field,
|
|
4
5
|
FieldContent,
|
|
@@ -12,9 +13,17 @@ const props = defineProps<FormItemProps>()
|
|
|
12
13
|
|
|
13
14
|
defineSlots<{
|
|
14
15
|
default?: () => any
|
|
16
|
+
/** Replaces the label text; the required asterisk is still appended */
|
|
17
|
+
label?: () => any
|
|
18
|
+
/** Inline content right after the label text and the required asterisk */
|
|
19
|
+
labelSuffix?: () => any
|
|
20
|
+
/** Extra content on the label row, aligned to the trailing edge */
|
|
21
|
+
labelExtra?: () => any
|
|
15
22
|
description?: () => any
|
|
16
23
|
}>()
|
|
17
24
|
|
|
25
|
+
const [ DefineLabelText, LabelText ] = createReusableTemplate()
|
|
26
|
+
|
|
18
27
|
useFormItemInvalid(() => !!props.error)
|
|
19
28
|
|
|
20
29
|
const errorArray = computed(() => {
|
|
@@ -22,30 +31,62 @@ const errorArray = computed(() => {
|
|
|
22
31
|
return [{ message: props.error }]
|
|
23
32
|
})
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`
|
|
34
|
+
// Tighter gap between the label and the content below when stacked;
|
|
35
|
+
// horizontal layout keeps the default column gap
|
|
36
|
+
const fieldClass = computed(() => {
|
|
37
|
+
if (props.orientation === 'horizontal') return props.class
|
|
38
|
+
if (props.orientation === 'responsive') return cn(`
|
|
39
|
+
gap-2
|
|
40
|
+
@md/field-group:gap-3
|
|
41
|
+
`, props.class)
|
|
42
|
+
return cn('gap-2', props.class)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const labelBaseClass = 'group-data-[invalid=true]/field:text-foreground'
|
|
46
|
+
|
|
47
|
+
// Label alignment per orientation: applied to FieldLabel itself, or to the row
|
|
48
|
+
// wrapping FieldLabel and labelExtra when the labelExtra slot is used
|
|
49
|
+
const labelAlignClass = computed(() => {
|
|
50
|
+
if (props.orientation === 'horizontal') return 'mt-2 justify-end text-right'
|
|
51
|
+
if (props.orientation === 'responsive') return '@md/field-group:justify-end @md/field-group:text-right @md/field-group:mt-2'
|
|
52
|
+
return ''
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const labelClass = computed(() => cn(labelBaseClass, labelAlignClass.value))
|
|
56
|
+
|
|
57
|
+
const labelRowClass = computed(() => {
|
|
58
|
+
const base = 'flex items-center gap-2'
|
|
59
|
+
if (props.orientation === 'horizontal') return cn(base, 'flex-auto', labelAlignClass.value)
|
|
30
60
|
if (props.orientation === 'responsive') return cn(base, `
|
|
31
|
-
@md/field-group:
|
|
32
|
-
|
|
61
|
+
@md/field-group:flex-auto
|
|
62
|
+
`, labelAlignClass.value)
|
|
33
63
|
return base
|
|
34
64
|
})
|
|
65
|
+
|
|
66
|
+
// Pushed to the trailing edge when stacked; in horizontal layout the label column
|
|
67
|
+
// is already right-aligned, so labelExtra just follows the label
|
|
68
|
+
const labelExtraClass = computed(() => {
|
|
69
|
+
const base = 'shrink-0 text-sm leading-snug'
|
|
70
|
+
if (props.orientation === 'horizontal') return base
|
|
71
|
+
if (props.orientation === 'responsive') return cn(base, `
|
|
72
|
+
@md/field-group:ml-0
|
|
73
|
+
ml-auto
|
|
74
|
+
`)
|
|
75
|
+
return cn(base, 'ml-auto')
|
|
76
|
+
})
|
|
35
77
|
</script>
|
|
36
78
|
|
|
37
79
|
<template>
|
|
38
80
|
<Field
|
|
39
81
|
:orientation="orientation"
|
|
40
|
-
:class="
|
|
82
|
+
:class="fieldClass"
|
|
41
83
|
:data-invalid="!!error || undefined"
|
|
42
84
|
>
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{{ label }}
|
|
85
|
+
<DefineLabelText>
|
|
86
|
+
<div :class="$slots.labelSuffix ? 'gap-1 flex items-center' : undefined">
|
|
87
|
+
<slot name="label">
|
|
88
|
+
{{ label }}
|
|
89
|
+
</slot>
|
|
49
90
|
<span
|
|
50
91
|
v-if="required"
|
|
51
92
|
class="text-danger"
|
|
@@ -53,7 +94,38 @@ const labelClass = computed(() => {
|
|
|
53
94
|
>
|
|
54
95
|
*
|
|
55
96
|
</span>
|
|
97
|
+
<span
|
|
98
|
+
v-if="$slots.labelSuffix"
|
|
99
|
+
data-slot="form-item-label-suffix"
|
|
100
|
+
class="flex items-center"
|
|
101
|
+
>
|
|
102
|
+
<slot name="labelSuffix" />
|
|
103
|
+
</span>
|
|
104
|
+
</div>
|
|
105
|
+
</DefineLabelText>
|
|
106
|
+
<div
|
|
107
|
+
v-if="$slots.labelExtra"
|
|
108
|
+
data-slot="form-item-label-row"
|
|
109
|
+
:class="labelRowClass"
|
|
110
|
+
>
|
|
111
|
+
<FieldLabel
|
|
112
|
+
v-if="label || $slots.label"
|
|
113
|
+
:class="labelBaseClass"
|
|
114
|
+
>
|
|
115
|
+
<LabelText />
|
|
116
|
+
</FieldLabel>
|
|
117
|
+
<div
|
|
118
|
+
data-slot="form-item-label-extra"
|
|
119
|
+
:class="labelExtraClass"
|
|
120
|
+
>
|
|
121
|
+
<slot name="labelExtra" />
|
|
56
122
|
</div>
|
|
123
|
+
</div>
|
|
124
|
+
<FieldLabel
|
|
125
|
+
v-else-if="label || $slots.label"
|
|
126
|
+
:class="labelClass"
|
|
127
|
+
>
|
|
128
|
+
<LabelText />
|
|
57
129
|
</FieldLabel>
|
|
58
130
|
<FieldContent>
|
|
59
131
|
<slot />
|
|
@@ -79,6 +79,7 @@ const meta = {
|
|
|
79
79
|
pageSize: { control: 'number' },
|
|
80
80
|
height: { control: 'text' },
|
|
81
81
|
clickable: { control: 'boolean' },
|
|
82
|
+
hoverable: { control: 'boolean' },
|
|
82
83
|
},
|
|
83
84
|
args: {
|
|
84
85
|
columns,
|
|
@@ -88,6 +89,7 @@ const meta = {
|
|
|
88
89
|
pageSize: 30,
|
|
89
90
|
height: '360px',
|
|
90
91
|
clickable: false,
|
|
92
|
+
hoverable: true,
|
|
91
93
|
},
|
|
92
94
|
render: args => {
|
|
93
95
|
const onUpdateFilters = useArgsModel('filters')
|
|
@@ -9,6 +9,7 @@ const props = withDefaults(defineProps<InfiniteDataTableProps<TData>>(), {
|
|
|
9
9
|
pageSize: 30,
|
|
10
10
|
height: undefined,
|
|
11
11
|
clickable: false,
|
|
12
|
+
hoverable: true,
|
|
12
13
|
})
|
|
13
14
|
|
|
14
15
|
const emit = defineEmits<{
|
|
@@ -254,6 +255,7 @@ onMounted(() => {
|
|
|
254
255
|
:height
|
|
255
256
|
:loading="isInitialLoad"
|
|
256
257
|
:clickable
|
|
258
|
+
:hoverable
|
|
257
259
|
:sortBy="sortState.sortBy"
|
|
258
260
|
:sortOrder="sortState.sortOrder"
|
|
259
261
|
@update:sortBy="onSortByUpdate"
|
|
@@ -38,4 +38,6 @@ 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
|
+
/** 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
|
+
hoverable?: boolean
|
|
41
43
|
}
|
|
@@ -79,6 +79,7 @@ const meta = {
|
|
|
79
79
|
selectable: { control: 'boolean' },
|
|
80
80
|
rowSelectable: { control: false },
|
|
81
81
|
clickable: { control: 'boolean' },
|
|
82
|
+
hoverable: { control: 'boolean' },
|
|
82
83
|
batchActions: { control: 'object' },
|
|
83
84
|
selection: { control: 'object' },
|
|
84
85
|
},
|
|
@@ -94,6 +95,7 @@ const meta = {
|
|
|
94
95
|
selectable: false,
|
|
95
96
|
rowSelectable: undefined,
|
|
96
97
|
clickable: false,
|
|
98
|
+
hoverable: true,
|
|
97
99
|
batchActions: [],
|
|
98
100
|
selection: [],
|
|
99
101
|
},
|
|
@@ -18,6 +18,7 @@ const props = withDefaults(defineProps<StaticDataTableProps<TData>>(), {
|
|
|
18
18
|
selectable: false,
|
|
19
19
|
rowSelectable: undefined,
|
|
20
20
|
clickable: false,
|
|
21
|
+
hoverable: true,
|
|
21
22
|
batchActions: () => [],
|
|
22
23
|
selection: () => [],
|
|
23
24
|
})
|
|
@@ -205,6 +206,7 @@ function onSortOrderUpdate (value: number | null) {
|
|
|
205
206
|
:selectionMode="showSelectionColumn ? 'multiple' : undefined"
|
|
206
207
|
:rowSelectable="rowSelectable"
|
|
207
208
|
:clickable="clickable"
|
|
209
|
+
:hoverable="hoverable"
|
|
208
210
|
:sortBy="sortState.sortBy"
|
|
209
211
|
:sortOrder="sortState.sortOrder"
|
|
210
212
|
@update:selection="onSelectionChange"
|
|
@@ -32,6 +32,8 @@ export interface StaticDataTableProps<T = Record<string, any>> {
|
|
|
32
32
|
rowSelectable?: DataTableRowSelectable<T>
|
|
33
33
|
/** Whether rows are clickable (shows pointer cursor and pairs with `@rowClick`) */
|
|
34
34
|
clickable?: boolean
|
|
35
|
+
/** 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
|
+
hoverable?: boolean
|
|
35
37
|
/** Batch action definitions for selected rows */
|
|
36
38
|
batchActions?: StaticDataTableBatchAction<T>[]
|
|
37
39
|
/** Selected rows (v-model:selection). Cleared whenever the visible rows are swapped — paging, sorting, new data. */
|
package/nuxt.config.ts
CHANGED
|
@@ -44,7 +44,11 @@ export default defineNuxtConfig({
|
|
|
44
44
|
{ code: 'vi', file: 'vi.json' },
|
|
45
45
|
{ code: 'zh-CN', file: 'zh-CN.json' },
|
|
46
46
|
{ code: 'zh-TW', file: 'zh-TW.json' },
|
|
47
|
-
|
|
47
|
+
// Handed over untyped on purpose: `@nuxtjs/i18n` narrows `code` to the
|
|
48
|
+
// consuming app's own locale union, and this layer ships translations
|
|
49
|
+
// for more languages than any one consumer declares — without this the
|
|
50
|
+
// list fails to type-check in every app that declares fewer.
|
|
51
|
+
] as never,
|
|
48
52
|
},
|
|
49
53
|
|
|
50
54
|
// Register the layer's global stylesheet. Consumers extending this layer
|
|
@@ -76,9 +80,12 @@ export default defineNuxtConfig({
|
|
|
76
80
|
// `.vue` files must not export types per project convention; exported
|
|
77
81
|
// types live in a co-located `types.ts` that gets scanned here.
|
|
78
82
|
'imports:extend': async (imports: unknown[]) => {
|
|
79
|
-
//
|
|
83
|
+
// `ts-ignore`, not `ts-expect-error`: both packages are untyped here but
|
|
84
|
+
// resolve fine from a consuming app, where `expect-error` would itself
|
|
85
|
+
// become the error.
|
|
86
|
+
// @ts-ignore fast-glob has no types in this project scope
|
|
80
87
|
const { default: fg } = await import('fast-glob')
|
|
81
|
-
// @ts-
|
|
88
|
+
// @ts-ignore unimport has no types in this project scope
|
|
82
89
|
const { scanExports } = await import('unimport')
|
|
83
90
|
const files = await fg('**/types.ts', {
|
|
84
91
|
cwd: join(currentDir, 'app/components'),
|
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.16",
|
|
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": "c6e590a0ab1cec58c0b5564751f15a88296f7377"
|
|
46
46
|
}
|