-
Notifications
You must be signed in to change notification settings - Fork 586
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
1 parent
32ac575
commit 8709717
Showing
19 changed files
with
757 additions
and
117 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
docs/app/components/content/examples/command-palette/CommandPaletteCustomSlotExample.vue
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,48 @@ | ||
<script setup lang="ts"> | ||
const groups = [{ | ||
id: 'settings', | ||
items: [{ | ||
label: 'Profile', | ||
icon: 'i-heroicons-user', | ||
kbds: ['meta', 'P'] | ||
}, { | ||
label: 'Billing', | ||
icon: 'i-heroicons-credit-card', | ||
kbds: ['meta', 'B'], | ||
slot: 'billing' | ||
}, { | ||
label: 'Notifications', | ||
icon: 'i-heroicons-bell' | ||
}, { | ||
label: 'Security', | ||
icon: 'i-heroicons-lock-closed' | ||
}] | ||
}, { | ||
id: 'users', | ||
label: 'Users', | ||
slot: 'users', | ||
items: [ | ||
{ id: 1, label: 'Durward Reynolds' }, | ||
{ id: 2, label: 'Kenton Towne' }, | ||
{ id: 3, label: 'Therese Wunsch' }, | ||
{ id: 4, label: 'Benedict Kessler' }, | ||
{ id: 5, label: 'Katelyn Rohan' } | ||
] | ||
}] | ||
</script> | ||
|
||
<template> | ||
<UCommandPalette :groups="groups" class="flex-1 h-80"> | ||
<template #users-leading="{ item }"> | ||
<UAvatar :src="`https://i.pravatar.cc/120?img=${item.id}`" size="2xs" /> | ||
</template> | ||
|
||
<template #billing-label="{ item }"> | ||
{{ item.label }} | ||
|
||
<UBadge variant="subtle" size="sm"> | ||
50% off | ||
</UBadge> | ||
</template> | ||
</UCommandPalette> | ||
</template> |
25 changes: 25 additions & 0 deletions
25
docs/app/components/content/examples/command-palette/CommandPaletteFetchExample.vue
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,25 @@ | ||
<script setup lang="ts"> | ||
const searchTerm = ref('') | ||
const { data: users, status } = await useFetch('https://jsonplaceholder.typicode.com/users', { | ||
transform: (data: any[]) => { | ||
return data?.map(user => ({ id: user.id, label: user.name, suffix: user.email, avatar: { src: `https://i.pravatar.cc/120?img=${user.id}` } })) || [] | ||
}, | ||
lazy: true | ||
}) | ||
const groups = computed(() => [{ | ||
id: 'users', | ||
label: searchTerm.value ? `Users matching “${searchTerm.value}”...` : 'Users', | ||
items: users.value || [] | ||
}]) | ||
</script> | ||
|
||
<template> | ||
<UCommandPalette | ||
v-model:search-term="searchTerm" | ||
:loading="status === 'pending'" | ||
:groups="groups" | ||
class="flex-1 h-80" | ||
/> | ||
</template> |
28 changes: 28 additions & 0 deletions
28
docs/app/components/content/examples/command-palette/CommandPaletteFilterExample.vue
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,28 @@ | ||
<script setup lang="ts"> | ||
const searchTerm = ref('') | ||
const searchTermDebounced = refDebounced(searchTerm, 200) | ||
const { data: users, status } = await useFetch('https://jsonplaceholder.typicode.com/users', { | ||
params: { q: searchTermDebounced }, | ||
transform: (data: any[]) => { | ||
return data?.map(user => ({ id: user.id, label: user.name, suffix: user.email, avatar: { src: `https://i.pravatar.cc/120?img=${user.id}` } })) || [] | ||
}, | ||
lazy: true | ||
}) | ||
const groups = computed(() => [{ | ||
id: 'users', | ||
label: searchTerm.value ? `Users matching “${searchTerm.value}”...` : 'Users', | ||
items: users.value || [], | ||
filter: false | ||
}]) | ||
</script> | ||
|
||
<template> | ||
<UCommandPalette | ||
v-model:search-term="searchTerm" | ||
:loading="status === 'pending'" | ||
:groups="groups" | ||
class="flex-1 h-80" | ||
/> | ||
</template> |
16 changes: 16 additions & 0 deletions
16
docs/app/components/content/examples/command-palette/CommandPaletteFuseExample.vue
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,16 @@ | ||
<script setup lang="ts"> | ||
const { data: users } = await useFetch('https://jsonplaceholder.typicode.com/users', { | ||
transform: (data: any[]) => { | ||
return data?.map(user => ({ id: user.id, label: user.name, suffix: user.email, avatar: { src: `https://i.pravatar.cc/120?img=${user.id}` } })) || [] | ||
}, | ||
lazy: true | ||
}) | ||
</script> | ||
|
||
<template> | ||
<UCommandPalette | ||
:groups="[{ id: 'users', items: users || [] }]" | ||
:fuse="{ fuseOptions: { includeMatches: true } }" | ||
class="flex-1 h-80" | ||
/> | ||
</template> |
24 changes: 24 additions & 0 deletions
24
docs/app/components/content/examples/command-palette/CommandPaletteModelValueExample.vue
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,24 @@ | ||
<script setup lang="ts"> | ||
const users = [ | ||
{ id: 1, label: 'Durward Reynolds' }, | ||
{ id: 2, label: 'Kenton Towne' }, | ||
{ id: 3, label: 'Therese Wunsch' }, | ||
{ id: 4, label: 'Benedict Kessler' }, | ||
{ id: 5, label: 'Katelyn Rohan' } | ||
] | ||
const selected = ref(users[0]) | ||
function onSelect(item: any) { | ||
console.log(item) | ||
} | ||
</script> | ||
|
||
<template> | ||
<UCommandPalette | ||
v-model="selected" | ||
:groups="[{ id: 'users', items: users }]" | ||
class="flex-1" | ||
@update:model-value="onSelect" | ||
/> | ||
</template> |
25 changes: 25 additions & 0 deletions
25
...p/components/content/examples/command-palette/CommandPaletteModelValueMultipleExample.vue
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,25 @@ | ||
<script setup lang="ts"> | ||
const users = [ | ||
{ id: 1, label: 'Durward Reynolds' }, | ||
{ id: 2, label: 'Kenton Towne' }, | ||
{ id: 3, label: 'Therese Wunsch' }, | ||
{ id: 4, label: 'Benedict Kessler' }, | ||
{ id: 5, label: 'Katelyn Rohan' } | ||
] | ||
const selected = ref([users[0], users[1]]) | ||
function onSelect(items: any) { | ||
console.log(items) | ||
} | ||
</script> | ||
|
||
<template> | ||
<UCommandPalette | ||
v-model="selected" | ||
multiple | ||
:groups="[{ id: 'users', items: users }]" | ||
class="flex-1" | ||
@update:model-value="onSelect" | ||
/> | ||
</template> |
25 changes: 25 additions & 0 deletions
25
docs/app/components/content/examples/command-palette/CommandPaletteOpenExample.vue
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,25 @@ | ||
<script setup lang="ts"> | ||
const open = ref(false) | ||
const users = [ | ||
{ id: 1, label: 'Durward Reynolds' }, | ||
{ id: 2, label: 'Kenton Towne' }, | ||
{ id: 3, label: 'Therese Wunsch' }, | ||
{ id: 4, label: 'Benedict Kessler' }, | ||
{ id: 5, label: 'Katelyn Rohan' } | ||
] | ||
</script> | ||
|
||
<template> | ||
<UModal v-model:open="open"> | ||
<UButton label="Search users..." color="gray" variant="subtle" icon="i-heroicons-magnifying-glass" /> | ||
|
||
<template #content> | ||
<UCommandPalette | ||
close | ||
:groups="[{ id: 'users', items: users }]" | ||
@update:open="open = $event" | ||
/> | ||
</template> | ||
</UModal> | ||
</template> |
40 changes: 40 additions & 0 deletions
40
docs/app/components/content/examples/command-palette/CommandPalettePostFilterExample.vue
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,40 @@ | ||
<script setup lang="ts"> | ||
const items = [{ | ||
id: '/', | ||
label: 'Introduction', | ||
level: 1 | ||
}, { | ||
id: '/getting-started#whats-new-in-v3', | ||
label: 'What\'s new in v3?', | ||
level: 2 | ||
}, { | ||
id: '/getting-started#radix-vue-3', | ||
label: 'Radix Vue', | ||
level: 3 | ||
}, { | ||
id: '/getting-started#tailwind-css-v4', | ||
label: 'Tailwind CSS v4', | ||
level: 3 | ||
}, { | ||
id: '/getting-started#tailwind-variants', | ||
label: 'Tailwind Variants', | ||
level: 3 | ||
}, { | ||
id: '/getting-started/installation', | ||
label: 'Installation', | ||
level: 1 | ||
}] | ||
function postFilter(searchTerm: string, items: any[]) { | ||
// Filter only first level items if no searchTerm | ||
if (!searchTerm) { | ||
return items?.filter(item => item.level === 1) | ||
} | ||
return items | ||
} | ||
</script> | ||
|
||
<template> | ||
<UCommandPalette :groups="[{ id: 'files', items, postFilter }]" class="flex-1" /> | ||
</template> |
19 changes: 19 additions & 0 deletions
19
docs/app/components/content/examples/command-palette/CommandPaletteSearchTermExample.vue
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,19 @@ | ||
<script setup lang="ts"> | ||
const users = [ | ||
{ id: 1, label: 'Durward Reynolds' }, | ||
{ id: 2, label: 'Kenton Towne' }, | ||
{ id: 3, label: 'Therese Wunsch' }, | ||
{ id: 4, label: 'Benedict Kessler' }, | ||
{ id: 5, label: 'Katelyn Rohan' } | ||
] | ||
const searchTerm = ref('Th') | ||
</script> | ||
|
||
<template> | ||
<UCommandPalette | ||
v-model:search-term="searchTerm" | ||
:groups="[{ id: 'users', items: users }]" | ||
class="flex-1" | ||
/> | ||
</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
Oops, something went wrong.