mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
@@ -24,7 +24,6 @@ Use the `items` prop as an array of objects with the following properties:
|
|||||||
- `tooltip?: TooltipProps`{lang="ts-type"}
|
- `tooltip?: TooltipProps`{lang="ts-type"}
|
||||||
- `trailingIcon?: string`{lang="ts-type"}
|
- `trailingIcon?: string`{lang="ts-type"}
|
||||||
- `type?: 'label' | 'link'`{lang="ts-type"}
|
- `type?: 'label' | 'link'`{lang="ts-type"}
|
||||||
- `collapsible?: boolean`{lang="ts-type"}
|
|
||||||
- `defaultOpen?: boolean`{lang="ts-type"}
|
- `defaultOpen?: boolean`{lang="ts-type"}
|
||||||
- `open?: boolean`{lang="ts-type"}
|
- `open?: boolean`{lang="ts-type"}
|
||||||
- `value?: string`{lang="ts-type"}
|
- `value?: string`{lang="ts-type"}
|
||||||
@@ -283,7 +282,6 @@ props:
|
|||||||
description: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
|
description: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
|
||||||
- label: Composables
|
- label: Composables
|
||||||
icon: i-lucide-database
|
icon: i-lucide-database
|
||||||
collapsible: false
|
|
||||||
open: false
|
open: false
|
||||||
children:
|
children:
|
||||||
- label: defineShortcuts
|
- label: defineShortcuts
|
||||||
@@ -300,7 +298,6 @@ props:
|
|||||||
to: /composables/use-toast
|
to: /composables/use-toast
|
||||||
- label: Components
|
- label: Components
|
||||||
icon: i-lucide-box
|
icon: i-lucide-box
|
||||||
collapsible: false
|
|
||||||
open: false
|
open: false
|
||||||
to: /components
|
to: /components
|
||||||
active: true
|
active: true
|
||||||
@@ -340,10 +337,6 @@ props:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
::tip
|
|
||||||
You can set the `collapsible: false` property on items with children to prevent them from being collapsible. This allows the item to act as a regular link while still displaying its children in a submenu.
|
|
||||||
::
|
|
||||||
|
|
||||||
### Highlight
|
### Highlight
|
||||||
|
|
||||||
Use the `highlight` prop to display a highlighted border for the active item.
|
Use the `highlight` prop to display a highlighted border for the active item.
|
||||||
@@ -940,7 +933,6 @@ props:
|
|||||||
icon: i-lucide-database
|
icon: i-lucide-database
|
||||||
tooltip:
|
tooltip:
|
||||||
text: 'Composables'
|
text: 'Composables'
|
||||||
collapsible: false
|
|
||||||
open: false
|
open: false
|
||||||
children:
|
children:
|
||||||
- label: defineShortcuts
|
- label: defineShortcuts
|
||||||
@@ -961,7 +953,6 @@ props:
|
|||||||
text: 'Components'
|
text: 'Components'
|
||||||
to: /components
|
to: /components
|
||||||
active: true
|
active: true
|
||||||
collapsible: false
|
|
||||||
open: false
|
open: false
|
||||||
children:
|
children:
|
||||||
- label: Link
|
- label: Link
|
||||||
|
|||||||
@@ -48,12 +48,6 @@ export interface NavigationMenuItem extends Omit<LinkProps, 'type' | 'raw' | 'cu
|
|||||||
* @defaultValue `item-${index}`
|
* @defaultValue `item-${index}`
|
||||||
*/
|
*/
|
||||||
value?: string
|
value?: string
|
||||||
/**
|
|
||||||
* Make the item collapsible.
|
|
||||||
* Only works when `orientation` is `vertical`.
|
|
||||||
* @defaultValue true
|
|
||||||
*/
|
|
||||||
collapsible?: boolean
|
|
||||||
children?: NavigationMenuChildItem[]
|
children?: NavigationMenuChildItem[]
|
||||||
onSelect?(e: Event): void
|
onSelect?(e: Event): void
|
||||||
class?: any
|
class?: any
|
||||||
@@ -248,7 +242,7 @@ const lists = computed<NavigationMenuItem[][]>(() =>
|
|||||||
:class="ui.linkTrailingBadge({ class: [props.ui?.linkTrailingBadge, item.ui?.linkTrailingBadge] })"
|
:class="ui.linkTrailingBadge({ class: [props.ui?.linkTrailingBadge, item.ui?.linkTrailingBadge] })"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UIcon v-if="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) || (orientation === 'vertical' && item.children?.length && item.collapsible !== false)" :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, item.ui?.linkTrailingIcon], active })" />
|
<UIcon v-if="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) || (orientation === 'vertical' && item.children?.length)" :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, item.ui?.linkTrailingIcon], active })" />
|
||||||
<UIcon v-else-if="item.trailingIcon" :name="item.trailingIcon" :class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, item.ui?.linkTrailingIcon], active })" />
|
<UIcon v-else-if="item.trailingIcon" :name="item.trailingIcon" :class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, item.ui?.linkTrailingIcon], active })" />
|
||||||
</slot>
|
</slot>
|
||||||
</span>
|
</span>
|
||||||
@@ -257,18 +251,17 @@ const lists = computed<NavigationMenuItem[][]>(() =>
|
|||||||
|
|
||||||
<DefineItemTemplate v-slot="{ item, index, level = 0 }">
|
<DefineItemTemplate v-slot="{ item, index, level = 0 }">
|
||||||
<component
|
<component
|
||||||
:is="(orientation === 'vertical' && item.children?.length) ? UCollapsible : NavigationMenuItem"
|
:is="(orientation === 'vertical' && item.children?.length && !collapsed) ? UCollapsible : NavigationMenuItem"
|
||||||
as="li"
|
as="li"
|
||||||
:value="item.value || `item-${index}`"
|
:value="item.value || `item-${index}`"
|
||||||
:default-open="item.defaultOpen"
|
:default-open="item.defaultOpen"
|
||||||
:disabled="(orientation === 'vertical' && item.children?.length) ? item.collapsible === false : undefined"
|
:unmount-on-hide="(orientation === 'vertical' && item.children?.length && !collapsed) ? unmountOnHide : undefined"
|
||||||
:unmount-on-hide="(orientation === 'vertical' && item.children?.length) ? unmountOnHide : undefined"
|
|
||||||
:open="item.open"
|
:open="item.open"
|
||||||
>
|
>
|
||||||
<div v-if="orientation === 'vertical' && item.type === 'label'" :class="ui.label({ class: [props.ui?.label, item.ui?.label, item.class] })">
|
<div v-if="orientation === 'vertical' && item.type === 'label'" :class="ui.label({ class: [props.ui?.label, item.ui?.label, item.class] })">
|
||||||
<ReuseLinkTemplate :item="item" :index="index" />
|
<ReuseLinkTemplate :item="item" :index="index" />
|
||||||
</div>
|
</div>
|
||||||
<ULink v-else-if="item.type !== 'label'" v-slot="{ active, ...slotProps }" v-bind="(orientation === 'vertical' && item.children?.length && item.collapsible !== false) ? {} : pickLinkProps(item as Omit<NavigationMenuItem, 'type'>)" custom>
|
<ULink v-else-if="item.type !== 'label'" v-slot="{ active, ...slotProps }" v-bind="(orientation === 'vertical' && item.children?.length && !collapsed) ? {} : pickLinkProps(item as Omit<NavigationMenuItem, 'type'>)" custom>
|
||||||
<component
|
<component
|
||||||
:is="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) ? NavigationMenuTrigger : NavigationMenuLink"
|
:is="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) ? NavigationMenuTrigger : NavigationMenuLink"
|
||||||
as-child
|
as-child
|
||||||
@@ -314,7 +307,7 @@ const lists = computed<NavigationMenuItem[][]>(() =>
|
|||||||
</NavigationMenuContent>
|
</NavigationMenuContent>
|
||||||
</ULink>
|
</ULink>
|
||||||
|
|
||||||
<template v-if="orientation === 'vertical' && item.children?.length " #content>
|
<template v-if="orientation === 'vertical' && item.children?.length && !collapsed" #content>
|
||||||
<ul :class="ui.childList({ class: props.ui?.childList })">
|
<ul :class="ui.childList({ class: props.ui?.childList })">
|
||||||
<ReuseItemTemplate
|
<ReuseItemTemplate
|
||||||
v-for="(childItem, childIndex) in item.children"
|
v-for="(childItem, childIndex) in item.children"
|
||||||
|
|||||||
@@ -842,23 +842,17 @@ exports[`NavigationMenu > renders with orientation vertical and collapsed correc
|
|||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li data-state="closed" class="min-w-0" value="item-1"><button type="button" aria-controls="" aria-expanded="false" data-state="closed" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-muted hover:text-highlighted hover:before:bg-elevated/50 transition-colors before:transition-colors px-1.5" data-reka-collection-item=""><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="shrink-0 size-5 text-dimmed group-hover:text-default transition-colors" width="1em" height="1em" viewBox="0 0 16 16"></svg>
|
<li data-menu-item="" class="min-w-0"><button type="button" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-muted hover:text-highlighted hover:before:bg-elevated/50 transition-colors before:transition-colors px-1.5" data-reka-collection-item=""><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="shrink-0 size-5 text-dimmed group-hover:text-default transition-colors" width="1em" height="1em" viewBox="0 0 16 16"></svg>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
</button>
|
</button>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<div class="data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" id="reka-collapsible-content-v-1" hidden="" data-state="closed" style="--reka-collapsible-content-height: 0px; --reka-collapsible-content-width: 0px;">
|
|
||||||
<!---->
|
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
<li data-state="closed" class="min-w-0" value="item-2"><button type="button" aria-controls="" aria-expanded="false" data-state="closed" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-primary before:bg-elevated px-1.5" data-active="" aria-current="page" data-reka-collection-item=""><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="shrink-0 size-5 text-primary group-data-[state=open]:text-primary" width="1em" height="1em" viewBox="0 0 16 16"></svg>
|
<li data-menu-item="" class="min-w-0"><button type="button" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-primary before:bg-elevated px-1.5" data-active="" aria-current="page" data-reka-collection-item=""><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="shrink-0 size-5 text-primary group-data-[state=open]:text-primary" width="1em" height="1em" viewBox="0 0 16 16"></svg>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
</button>
|
</button>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<div class="data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" id="reka-collapsible-content-v-2" hidden="" data-state="closed" style="--reka-collapsible-content-height: 0px; --reka-collapsible-content-width: 0px;">
|
|
||||||
<!---->
|
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -842,23 +842,17 @@ exports[`NavigationMenu > renders with orientation vertical and collapsed correc
|
|||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li data-state="closed" class="min-w-0" value="item-1"><button type="button" aria-controls="" aria-expanded="false" data-state="closed" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-muted hover:text-highlighted hover:before:bg-elevated/50 transition-colors before:transition-colors px-1.5" data-reka-collection-item=""><span class="iconify i-lucide:book-open shrink-0 size-5 text-dimmed group-hover:text-default transition-colors" aria-hidden="true"></span>
|
<li data-menu-item="" class="min-w-0"><button type="button" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-muted hover:text-highlighted hover:before:bg-elevated/50 transition-colors before:transition-colors px-1.5" data-reka-collection-item=""><span class="iconify i-lucide:book-open shrink-0 size-5 text-dimmed group-hover:text-default transition-colors" aria-hidden="true"></span>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
</button>
|
</button>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<div class="data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" id="reka-collapsible-content-v-0-0-1" hidden="" data-state="closed" style="--reka-collapsible-content-height: 0px; --reka-collapsible-content-width: 0px;">
|
|
||||||
<!---->
|
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
<li data-state="closed" class="min-w-0" value="item-2"><button type="button" aria-controls="" aria-expanded="false" data-state="closed" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-primary before:bg-elevated px-1.5" data-active="" aria-current="page" data-reka-collection-item=""><span class="iconify i-lucide:box shrink-0 size-5 text-primary group-data-[state=open]:text-primary" aria-hidden="true"></span>
|
<li data-menu-item="" class="min-w-0"><button type="button" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-primary before:bg-elevated px-1.5" data-active="" aria-current="page" data-reka-collection-item=""><span class="iconify i-lucide:box shrink-0 size-5 text-primary group-data-[state=open]:text-primary" aria-hidden="true"></span>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
</button>
|
</button>
|
||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
<div class="data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" id="reka-collapsible-content-v-0-0-2" hidden="" data-state="closed" style="--reka-collapsible-content-height: 0px; --reka-collapsible-content-width: 0px;">
|
|
||||||
<!---->
|
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user