-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for object in tags input
- Loading branch information
Showing
5 changed files
with
89 additions
and
18 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
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
42 changes: 42 additions & 0 deletions
42
packages/radix-vue/src/TagsInput/story/TagsInputObject.story.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,42 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText, TagsInputRoot } from '..' | ||
import { Icon } from '@iconify/vue' | ||
let id = 1 | ||
type Item = { id: number; label: string } | ||
const modelValue = ref<Item[]>([{ id, label: 'Test' }]) | ||
function convertValue(label: string) { | ||
id++ | ||
return { id, label } satisfies Item | ||
} | ||
function displayValue(item: Item) { | ||
return item.label | ||
} | ||
</script> | ||
|
||
<template> | ||
<Story title="TagsInput/Object" :layout="{ type: 'single', iframe: false }"> | ||
<Variant title="default"> | ||
{{ JSON.stringify(modelValue) }} | ||
<TagsInputRoot | ||
v-model="modelValue" | ||
:convert-value="convertValue" | ||
:display-value="displayValue" | ||
class="flex gap-2 items-center border p-2 rounded-lg bg-blackA7 w-[300px] flex-wrap border-blackA7 mt-6" | ||
> | ||
<TagsInputItem | ||
v-for="item in modelValue" :key="item.id" :value="item" | ||
class=" data-[disabled]:opacity-50 flex items-center justify-center gap-2 bg-green8 aria-[current=true]:bg-green9 rounded px-2 py-1" | ||
> | ||
<TagsInputItemText class="text-sm" /> | ||
<TagsInputItemDelete> | ||
<Icon icon="lucide:x" /> | ||
</TagsInputItemDelete> | ||
</TagsInputItem> | ||
|
||
<TagsInputInput placeholder="Anything..." class="focus:outline-none flex-1 rounded bg-transparent text-white placeholder:text-mauve10 px-1" /> | ||
</TagsInputRoot> | ||
</Variant> | ||
</Story> | ||
</template> |