Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit be840460
authored
Apr 25, 2025
by
Netfan
Committed by
GitHub
Apr 25, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: vbenSelect support prop `allowClear` (#6043)
1 parent
cb45987f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
packages/@core/ui-kit/shadcn-ui/src/components/select/select.vue
packages/@core/ui-kit/shadcn-ui/src/components/select/select.vue
View file @
be84046
<
script
lang=
"ts"
setup
>
import
{
CircleX
}
from
'@vben-core/icons'
;
import
{
Select
,
SelectContent
,
...
...
@@ -8,17 +10,33 @@ import {
}
from
'../../ui'
;
interface
Props
{
allowClear
?:
boolean
;
class
?:
any
;
options
?:
Array
<
{
label
:
string
;
value
:
string
}
>
;
placeholder
?:
string
;
}
const
props
=
defineProps
<
Props
>
();
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
allowClear
:
false
,
});
const
modelValue
=
defineModel
<
string
>
();
function
handleClear
()
{
modelValue
.
value
=
undefined
;
}
</
script
>
<
template
>
<Select>
<SelectTrigger
:class=
"props.class"
>
<SelectValue
:placeholder=
"placeholder"
/>
<Select
v-model=
"modelValue"
>
<SelectTrigger
:class=
"props.class"
class=
"flex w-full items-center"
>
<SelectValue
class=
"flex-auto text-left"
:placeholder=
"placeholder"
/>
<CircleX
@
pointerdown
.
stop
@
click
.
stop
.
prevent=
"handleClear"
v-if=
"allowClear && modelValue"
data-clear-button
class=
"mr-1 size-4 cursor-pointer opacity-50 hover:opacity-100"
/>
</SelectTrigger>
<SelectContent>
<template
v-for=
"item in options"
:key=
"item.value"
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment