Skip to content

Commit de9f13a

Browse files
authored
Merge branch 'v3' into feat/support-overlay-stacking
2 parents fd53211 + abfd0ed commit de9f13a

File tree

5 files changed

+60
-45
lines changed

5 files changed

+60
-45
lines changed

cli/templates.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ const component = ({ name, primitive, pro, prose, content }) => {
3131
? `
3232
<script lang="ts">
3333
import type { AppConfig } from '@nuxt/schema'
34+
${pro ? `import type { ComponentConfig } from '@nuxt/ui'` : ''}
3435
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
35-
import type { ComponentConfig } from '../types/utils'
36+
${!pro ? `import type { ComponentConfig } from '../types/utils'` : ''}
3637
3738
type ${upperName} = ComponentConfig<typeof theme, AppConfig, ${upperName}${pro ? `, '${key}'` : ''}>
3839
@@ -62,7 +63,7 @@ defineSlots<${upperName}Slots>()
6263
6364
const appConfig = useAppConfig() as ${upperName}['AppConfig']
6465
65-
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.${camelName} || {}) })())
66+
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.${pro ? 'uiPro' : 'ui'}?.${camelName} || {}) })())
6667
</script>
6768
6869
<template>
@@ -75,8 +76,9 @@ const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.${camelName}
7576
<script lang="ts">
7677
import type { ${upperName}RootProps, ${upperName}RootEmits } from 'reka-ui'
7778
import type { AppConfig } from '@nuxt/schema'
79+
${pro ? `import type { ComponentConfig } from '@nuxt/ui'` : ''}
7880
import theme from '#build/${path}/${prose ? 'prose/' : ''}${content ? 'content/' : ''}${kebabName}'
79-
import type { ComponentConfig } from '../types/utils'
81+
${!pro ? `import type { ComponentConfig } from '../types/utils'` : ''}
8082
8183
type ${upperName} = ComponentConfig<typeof theme, AppConfig, ${upperName}${pro ? `, '${key}'` : ''}>
8284
@@ -105,7 +107,7 @@ const appConfig = useAppConfig() as ${upperName}['AppConfig']
105107
106108
const rootProps = useForwardPropsEmits(reactivePick(props), emits)
107109
108-
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.${camelName} || {}) })())
110+
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.${pro ? 'uiPro' : 'ui'}?.${camelName} || {}) })())
109111
</script>
110112
111113
<template>
@@ -186,6 +188,7 @@ links:${primitive
186188
- label: GitHub
187189
icon: i-simple-icons-github
188190
to: https://github.com/nuxt/${pro ? 'ui-pro' : 'ui'}/tree/v3/src/runtime/components/${upperName}.vue
191+
navigation.badge: Soon
189192
---
190193
191194
## Usage

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"@vue/test-utils": "^2.4.6",
163163
"embla-carousel": "^8.6.0",
164164
"eslint": "^9.29.0",
165-
"happy-dom": "^17.6.3",
165+
"happy-dom": "^18.0.1",
166166
"nuxt": "^3.17.5",
167167
"release-it": "^19.0.3",
168168
"vitest": "^3.2.3",

pnpm-lock.yaml

Lines changed: 35 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/components/NavigationMenu.vue

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -236,20 +236,13 @@ const lists = computed<NavigationMenuItem[][]>(() =>
236236
: []
237237
)
238238
239-
function getAccordionDefaultValue(list: NavigationMenuItem[]) {
240-
function findItemsWithDefaultOpen(items: NavigationMenuItem[], level = 0): string[] {
241-
return items.reduce((acc: string[], item, index) => {
242-
if (item.defaultOpen || item.open) {
243-
acc.push(item.value || (level > 0 ? `item-${level}-${index}` : `item-${index}`))
244-
}
245-
if (item.children?.length) {
246-
acc.push(...findItemsWithDefaultOpen(item.children, level + 1))
247-
}
248-
return acc
249-
}, [])
250-
}
251-
252-
const indexes = findItemsWithDefaultOpen(list)
239+
function getAccordionDefaultValue(list: NavigationMenuItem[], level = 0) {
240+
const indexes = list.reduce((acc: string[], item, index) => {
241+
if (item.defaultOpen || item.open) {
242+
acc.push(item.value || (level > 0 ? `item-${level}-${index}` : `item-${index}`))
243+
}
244+
return acc
245+
}, [])
253246
254247
return props.type === 'single' ? indexes[0] : indexes
255248
}
@@ -378,7 +371,14 @@ function getAccordionDefaultValue(list: NavigationMenuItem[]) {
378371
</ULink>
379372

380373
<AccordionContent v-if="orientation === 'vertical' && item.children?.length && !collapsed" :class="ui.content({ class: [props.ui?.content, item.ui?.content] })">
381-
<ul :class="ui.childList({ class: props.ui?.childList })">
374+
<AccordionRoot
375+
v-bind="({
376+
...accordionProps,
377+
defaultValue: getAccordionDefaultValue(item.children, level + 1)
378+
} as AccordionRootProps)"
379+
as="ul"
380+
:class="ui.childList({ class: props.ui?.childList })"
381+
>
382382
<ReuseItemTemplate
383383
v-for="(childItem, childIndex) in item.children"
384384
:key="childIndex"
@@ -387,7 +387,7 @@ function getAccordionDefaultValue(list: NavigationMenuItem[]) {
387387
:level="level + 1"
388388
:class="ui.childItem({ class: [props.ui?.childItem, childItem.ui?.childItem] })"
389389
/>
390-
</ul>
390+
</AccordionRoot>
391391
</AccordionContent>
392392
</component>
393393
</DefineItemTemplate>

src/theme/toaster.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default {
22
slots: {
33
viewport: 'fixed flex flex-col w-[calc(100%-2rem)] sm:w-96 z-[100] data-[expanded=true]:h-(--height) focus:outline-none',
4-
base: 'pointer-events-auto absolute inset-x-0 z-(--index) transform-(--transform) data-[expanded=false]:data-[front=false]:h-(--front-height) data-[expanded=false]:data-[front=false]:*:invisible data-[state=closed]:animate-[toast-closed_200ms_ease-in-out] data-[state=closed]:data-[expanded=false]:data-[front=false]:animate-[toast-collapsed-closed_200ms_ease-in-out] data-[swipe=move]:transition-none transition-[transform,translate,height] duration-200 ease-out'
4+
base: 'pointer-events-auto absolute inset-x-0 z-(--index) transform-(--transform) data-[expanded=false]:data-[front=false]:h-(--front-height) data-[expanded=false]:data-[front=false]:*:opacity-0 data-[front=false]:*:transition-opacity data-[front=false]:*:duration-100 data-[state=closed]:animate-[toast-closed_200ms_ease-in-out] data-[state=closed]:data-[expanded=false]:data-[front=false]:animate-[toast-collapsed-closed_200ms_ease-in-out] data-[swipe=move]:transition-none transition-[transform,translate,height] duration-200 ease-out'
55
},
66
variants: {
77
position: {

0 commit comments

Comments
 (0)