@bjj/nuxt-layer-shadcn-ui 0.15.8 → 0.15.9
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.
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
SidebarMenuSub,
|
|
23
23
|
SidebarMenuSubButton,
|
|
24
24
|
SidebarMenuSubItem,
|
|
25
|
+
useSidebar,
|
|
25
26
|
} from '../../shadcn/sidebar'
|
|
26
27
|
|
|
27
28
|
const props = defineProps<{
|
|
@@ -37,6 +38,12 @@ const emit = defineEmits<{
|
|
|
37
38
|
|
|
38
39
|
const route = useRoute()
|
|
39
40
|
|
|
41
|
+
// In page mode this is the real provider's live state; the embedded fallback
|
|
42
|
+
// context pins it to 'expanded'. On mobile the sidebar renders as a full-width
|
|
43
|
+
// sheet, so the inline sub-menu stays regardless of the collapsed state.
|
|
44
|
+
const { state, isMobile } = useSidebar()
|
|
45
|
+
const iconCollapsed = computed(() => state.value === 'collapsed' && !isMobile.value)
|
|
46
|
+
|
|
40
47
|
const isExternal = (href: string) => /^https?:\/\//.test(href)
|
|
41
48
|
|
|
42
49
|
const navGroups = computed(() => {
|
|
@@ -74,6 +81,21 @@ function hasActiveChild (item: SidebarLayoutMenuItem): boolean {
|
|
|
74
81
|
function handleSelect (item: SidebarLayoutMenuItem) {
|
|
75
82
|
emit('select', item)
|
|
76
83
|
}
|
|
84
|
+
|
|
85
|
+
// Fly-out items for an icon-collapsed parent: the leading label stands in for
|
|
86
|
+
// the parent's text, which only shows its icon in that state.
|
|
87
|
+
function toDropdownItems (item: SidebarLayoutMenuItem): DropdownItem[] {
|
|
88
|
+
return [
|
|
89
|
+
{ type: 'label', label: item.label },
|
|
90
|
+
...(item.children ?? []).map(child => ({
|
|
91
|
+
label: child.label,
|
|
92
|
+
icon: child.icon,
|
|
93
|
+
href: child.href,
|
|
94
|
+
active: isActive(child),
|
|
95
|
+
command: () => handleSelect(child),
|
|
96
|
+
})),
|
|
97
|
+
]
|
|
98
|
+
}
|
|
77
99
|
</script>
|
|
78
100
|
|
|
79
101
|
<template>
|
|
@@ -81,7 +103,13 @@ function handleSelect (item: SidebarLayoutMenuItem) {
|
|
|
81
103
|
v-for="(group, groupIndex) in navGroups"
|
|
82
104
|
:key="groupIndex"
|
|
83
105
|
>
|
|
84
|
-
|
|
106
|
+
<!-- While icon-collapsed the vendored label hides via `opacity-0`, which
|
|
107
|
+
creates a stacking context that keeps hit-testing above the menu row
|
|
108
|
+
it overlaps, so clicks must fall through it. -->
|
|
109
|
+
<SidebarGroupLabel
|
|
110
|
+
v-if="group.label"
|
|
111
|
+
class="group-data-[collapsible=icon]:pointer-events-none"
|
|
112
|
+
>
|
|
85
113
|
{{ group.label }}
|
|
86
114
|
</SidebarGroupLabel>
|
|
87
115
|
<SidebarMenu>
|
|
@@ -89,9 +117,31 @@ function handleSelect (item: SidebarLayoutMenuItem) {
|
|
|
89
117
|
v-for="item in group.items"
|
|
90
118
|
:key="sidebarMenuItemKey(item)"
|
|
91
119
|
>
|
|
120
|
+
<!-- Icon-collapsed parent: the inline sub-menu is hidden in that
|
|
121
|
+
state, so the children fly out as a dropdown at the side. -->
|
|
122
|
+
<SidebarMenuItem v-if="item.children?.length && iconCollapsed">
|
|
123
|
+
<Dropdown
|
|
124
|
+
:menus="toDropdownItems(item)"
|
|
125
|
+
side="right"
|
|
126
|
+
align="start"
|
|
127
|
+
class="min-w-48 rounded-lg"
|
|
128
|
+
>
|
|
129
|
+
<SidebarMenuButton
|
|
130
|
+
:isActive="hasActiveChild(item)"
|
|
131
|
+
class="cursor-pointer"
|
|
132
|
+
>
|
|
133
|
+
<Icon
|
|
134
|
+
v-if="item.icon"
|
|
135
|
+
:name="item.icon"
|
|
136
|
+
/>
|
|
137
|
+
<span>{{ item.label }}</span>
|
|
138
|
+
</SidebarMenuButton>
|
|
139
|
+
</Dropdown>
|
|
140
|
+
</SidebarMenuItem>
|
|
141
|
+
|
|
92
142
|
<!-- Collapsible item with children -->
|
|
93
143
|
<Collapsible
|
|
94
|
-
v-if="item.children?.length"
|
|
144
|
+
v-else-if="item.children?.length"
|
|
95
145
|
asChild
|
|
96
146
|
:defaultOpen="item.expanded ?? hasActiveChild(item)"
|
|
97
147
|
class="group/collapsible"
|
|
@@ -199,6 +199,52 @@ export const NestedMenus: Story = {
|
|
|
199
199
|
},
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
// Page mode starting icon-collapsed (`defaultOpen` falls through to the
|
|
203
|
+
// provider): parents with children show them in a fly-out dropdown at the side.
|
|
204
|
+
export const CollapsedNestedMenus: Story = {
|
|
205
|
+
parameters: {
|
|
206
|
+
...noControls,
|
|
207
|
+
docs: {
|
|
208
|
+
source: {
|
|
209
|
+
code: `
|
|
210
|
+
<template>
|
|
211
|
+
<SidebarLayout
|
|
212
|
+
v-model:active="active"
|
|
213
|
+
:menus="menus"
|
|
214
|
+
:defaultOpen="false"
|
|
215
|
+
contentClass="p-6"
|
|
216
|
+
>
|
|
217
|
+
<template #header>
|
|
218
|
+
<div class="truncate px-2 py-1 text-base font-semibold group-data-[collapsible=icon]:hidden">Acme Inc.</div>
|
|
219
|
+
</template>
|
|
220
|
+
|
|
221
|
+
<div class="text-sm text-muted-foreground">Pane for {{ active }}</div>
|
|
222
|
+
</SidebarLayout>
|
|
223
|
+
</template>
|
|
224
|
+
`.trim(),
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
render: () => ({
|
|
229
|
+
components: { SidebarLayout },
|
|
230
|
+
setup () {
|
|
231
|
+
const active = ref('intro')
|
|
232
|
+
return { active, nestedMenus }
|
|
233
|
+
},
|
|
234
|
+
template: `
|
|
235
|
+
<SidebarLayout
|
|
236
|
+
v-model:active="active"
|
|
237
|
+
:menus="nestedMenus"
|
|
238
|
+
:defaultOpen="false"
|
|
239
|
+
contentClass="p-6"
|
|
240
|
+
>
|
|
241
|
+
${brandTemplate}
|
|
242
|
+
<div class="text-sm text-muted-foreground">Pane for {{ active }}</div>
|
|
243
|
+
</SidebarLayout>
|
|
244
|
+
`,
|
|
245
|
+
}),
|
|
246
|
+
}
|
|
247
|
+
|
|
202
248
|
export const EmptyText: Story = {
|
|
203
249
|
parameters: noControls,
|
|
204
250
|
args: {
|
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.9",
|
|
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": "7f4cf572fa25bd362436144ff826ae2ebf352317"
|
|
46
46
|
}
|