-
-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
240 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"> | ||
import Callout from './Callout.vue' | ||
</script> | ||
|
||
<template> | ||
<Callout type="tip"> | ||
Built with <a href="/docs/utilities/presence">Presence</a> component - supports any <a href="/docs/guides/animation">animation techniques</a> while maintaining access to presence emitted events. | ||
</Callout> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: Focus Scope | ||
description: Manages focus within a component boundary with support for trapping and looping focus navigation. | ||
--- | ||
|
||
# Focus Scope | ||
|
||
<Description> | ||
Manages focus within a component boundary with support for trapping and looping focus navigation. | ||
</Description> | ||
|
||
Focus Scope provides enhanced control over keyboard focus management within component boundaries. It can trap focus within its container and optionally loop focus navigation, making it ideal for modal interfaces and other interactive components that need to manage focus states. | ||
|
||
## API Reference | ||
|
||
<!-- @include: @/meta/FocusScope.md --> | ||
|
||
## Example | ||
|
||
Basic usage with focus trapping | ||
|
||
```vue line=2 | ||
<template> | ||
<FocusScope :trapped="true"> | ||
<div> | ||
<button>Action 1</button> | ||
<button>Action 2</button> | ||
<button>Close</button> | ||
</div> | ||
</FocusScope> | ||
</template> | ||
``` | ||
|
||
### With Focus Looping | ||
|
||
Enable both trapping and looping for complete focus management: | ||
|
||
```vue line=2 | ||
<template> | ||
<FocusScope :trapped="true" :loop="true"> | ||
<div> | ||
<button v-for="item in items" :key="item.id"> | ||
{{ item.label }} | ||
</button> | ||
</div> | ||
</FocusScope> | ||
</template> | ||
``` | ||
|
||
### Handling Focus Event | ||
|
||
```vue line=2-5 | ||
<script setup> | ||
function handleMountFocus(event) { | ||
// Prevent default auto-focus behavior if needed | ||
event.preventDefault() | ||
} | ||
</script> | ||
<template> | ||
<FocusScope | ||
@mount-auto-focus="handleMountFocus" | ||
@unmount-auto-focus="handleUnmountFocus" | ||
> | ||
<div> | ||
… | ||
</div> | ||
</FocusScope> | ||
</template> | ||
``` | ||
|
||
<br> | ||
|
||
<Callout type="warning"> | ||
|
||
When using trapped mode, ensure there is always at least one focusable element within the scope to prevent focus from being trapped in an inaccessible state. | ||
|
||
</Callout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
title: Presence | ||
description: Manages mounting and unmounting of element with transition support. | ||
--- | ||
|
||
# Presence | ||
|
||
<Description> | ||
Manages mounting and unmounting of element with transition support. | ||
</Description> | ||
|
||
<Callout type="info" title="Question"> | ||
|
||
How is this component different from [Vue Transition](https://vuejs.org/guide/built-ins/transition.html#transition)? | ||
|
||
A: The biggest difference is it accepts css animation, and control the visibility of element. | ||
|
||
</Callout> | ||
|
||
Presence component provides enhanced control over element mounting/unmounting compared to Vue's native `v-if`. It ensures animations and transitions complete before removing elements from the DOM, making it perfect for animated UI components. | ||
|
||
## API Reference | ||
|
||
<PropsTable :data="[ | ||
{ | ||
'name': 'present', | ||
'description': '<p>Conditional to mount or unmount the child element. Similar to <code>v-if</code></p>\n', | ||
'type': 'boolean', | ||
'required': true, | ||
}, | ||
{ | ||
'name': 'forceMount', | ||
'description': '<p>Force the element to render all the time.\n\nUseful for programmatically render grandchild component with the exposed <code>present</code></p>\n', | ||
'type': 'boolean', | ||
'required': false, | ||
'default': false | ||
}, | ||
]" /> | ||
|
||
<EmitsTable :data="[ | ||
{ | ||
'name': 'enter', | ||
'description': '<p>Event handler called when the enter animation has started</p>\n', | ||
'type': 'CustomEvent' | ||
}, | ||
{ | ||
'name': 'after-enter', | ||
'description': '<p>Event handler called when the enter animation has finished</p>\n', | ||
'type': 'CustomEvent' | ||
}, | ||
{ | ||
'name': 'leave', | ||
'description': '<p>Event handler called when the leave animation has started</p>\n', | ||
'type': 'CustomEvent' | ||
}, | ||
{ | ||
'name': 'after-leave', | ||
'description': '<p>Event handler called when the leave animation has finished</p>\n', | ||
'type': 'CustomEvent' | ||
}, | ||
]" /> | ||
|
||
<Callout type="tip"> | ||
|
||
Read our [Animation Guide](/docs/guides/animation) to learn more about implementing animations with Presence component. | ||
|
||
</Callout> | ||
|
||
## Example | ||
|
||
```vue line=2,4,5 | ||
<template> | ||
<Presence :present="isVisible"> | ||
<div | ||
:data-open="isVisible ? 'open' : 'close'" | ||
class="data-[state=open]:animate-fadeIn data-[state=closed]:animate-fadeOut" | ||
> | ||
<slot /> | ||
</div> | ||
</Presence> | ||
</template> | ||
``` | ||
|
||
### Force Mount Usage | ||
|
||
When you need to ensure content is always rendered regardless of the present state: | ||
|
||
```vue | ||
<template> | ||
<Presence v-slot="{ present }" :present="isVisible" :force-mount="true"> | ||
<div> | ||
This content will always be rendered | ||
<div v-if="present"> | ||
This content is hidden | ||
</div> | ||
</div> | ||
</Presence> | ||
</template> | ||
``` |
Oops, something went wrong.