From cd981cc11393a96d3e175d6bae5726d92511b466 Mon Sep 17 00:00:00 2001 From: winixt Date: Sat, 19 Jul 2025 11:49:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20select=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8F=97=E6=8E=A7=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/_util/use/useModel.ts | 22 +++---- components/select/props.ts | 4 ++ components/select/select.vue | 17 +++--- components/select/useCurrentValue.ts | 57 +++++++++++++++++ docs/.vitepress/components/select/index.md | 7 +++ docs/.vitepress/components/select/passive.vue | 61 +++++++++++++++++++ 6 files changed, 148 insertions(+), 20 deletions(-) create mode 100644 components/select/useCurrentValue.ts create mode 100644 docs/.vitepress/components/select/passive.vue diff --git a/components/_util/use/useModel.ts b/components/_util/use/useModel.ts index 783e657e..43ec1afd 100644 --- a/components/_util/use/useModel.ts +++ b/components/_util/use/useModel.ts @@ -21,10 +21,10 @@ export const useNormalModel = < > = ModelValuePropKey, EventName extends string = string, >( - props: Props, - emit: (eventName: EventName, ...args: any[]) => void, - config: UseNormalModelOptions = {}, - ): [WritableComputedRef, (val: Props[Key]) => void] => { + props: Props, + emit: (eventName: EventName, ...args: any[]) => void, + config: UseNormalModelOptions = {}, +): [WritableComputedRef, (val: Props[Key]) => void] => { const { prop = 'modelValue', deep = false, @@ -106,13 +106,13 @@ export const useArrayModel = < > = Extract>, EventName extends string = string, >( - props: Props, - emit: (eventName: EventName, ...args: any[]) => void, - config: UseNormalModelOptions = {}, - ): [ - WritableComputedRef, - (val: ArrayOrItem) => void, - ] => { + props: Props, + emit: (eventName: EventName, ...args: any[]) => void, + config: UseNormalModelOptions = {}, +): [ + WritableComputedRef, + (val: ArrayOrItem) => void, +] => { const [computedValue, updateCurrentValue] = useNormalModel(props, emit, { ...config, defaultValue: [] as Props[Key], diff --git a/components/select/props.ts b/components/select/props.ts index 0c1a8a07..1e288e14 100644 --- a/components/select/props.ts +++ b/components/select/props.ts @@ -93,6 +93,10 @@ export const selectProps = { type: Boolean, default: false, }, + passive: { + type: Boolean, + default: true, + }, popperClass: [String, Array, Object] as PropType, triggerClass: [String, Array, Object] as PropType, triggerStyle: [Object, String] as PropType, diff --git a/components/select/select.vue b/components/select/select.vue index fde3b1ec..2e368828 100644 --- a/components/select/select.vue +++ b/components/select/select.vue @@ -74,10 +74,10 @@ + + From 7f66e634107819558b9bc1d7b98e4171b10ef214 Mon Sep 17 00:00:00 2001 From: winixt Date: Tue, 22 Jul 2025 14:30:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20cr=20=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/select/useCurrentValue.ts | 2 ++ docs/.vitepress/components/select/passive.vue | 9 --------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/components/select/useCurrentValue.ts b/components/select/useCurrentValue.ts index 6e898d62..d7604bfe 100644 --- a/components/select/useCurrentValue.ts +++ b/components/select/useCurrentValue.ts @@ -5,6 +5,8 @@ import type { SelectProps } from './props'; export function useCurrentValue(props: SelectProps, emit: (event: 'filter' | 'update:modelValue' | 'focus' | 'blur' | 'change' | 'clear' | 'search' | 'scroll' | 'removeTag' | 'visibleChange', ...args: any[]) => void) { const currentValue = useVModel(props, 'modelValue', emit, { passive: props.passive, + deep: true, + defaultValue: props.multiple ? [] : undefined, }); function updateCurrentValue(value: SelectValue | SelectValue[]): SelectValue | SelectValue[] { diff --git a/docs/.vitepress/components/select/passive.vue b/docs/.vitepress/components/select/passive.vue index 13000eb4..0ca49106 100644 --- a/docs/.vitepress/components/select/passive.vue +++ b/docs/.vitepress/components/select/passive.vue @@ -1,14 +1,5 @@