File tree 1 file changed +22
-4
lines changed
packages/@core/ui-kit/shadcn-ui/src/components/select
1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change 1
1
<script lang="ts" setup>
2
+ import { CircleX } from ' @vben-core/icons' ;
3
+
2
4
import {
3
5
Select ,
4
6
SelectContent ,
@@ -8,17 +10,33 @@ import {
8
10
} from ' ../../ui' ;
9
11
10
12
interface Props {
13
+ allowClear? : boolean ;
11
14
class? : any ;
12
15
options? : Array <{ label: string ; value: string }>;
13
16
placeholder? : string ;
14
17
}
15
18
16
- const props = defineProps <Props >();
19
+ const props = withDefaults (defineProps <Props >(), {
20
+ allowClear: false ,
21
+ });
22
+
23
+ const modelValue = defineModel <string >();
24
+
25
+ function handleClear() {
26
+ modelValue .value = undefined ;
27
+ }
17
28
</script >
18
29
<template >
19
- <Select >
20
- <SelectTrigger :class =" props.class" >
21
- <SelectValue :placeholder =" placeholder" />
30
+ <Select v-model =" modelValue" >
31
+ <SelectTrigger :class =" props.class" class =" flex w-full items-center" >
32
+ <SelectValue class =" flex-auto text-left" :placeholder =" placeholder" />
33
+ <CircleX
34
+ @pointerdown.stop
35
+ @click.stop.prevent =" handleClear"
36
+ v-if =" allowClear && modelValue"
37
+ data-clear-button
38
+ class =" mr-1 size-4 cursor-pointer opacity-50 hover:opacity-100"
39
+ />
22
40
</SelectTrigger >
23
41
<SelectContent >
24
42
<template v-for =" item in options " :key =" item .value " >
You can’t perform that action at this time.
0 commit comments