-
Notifications
You must be signed in to change notification settings - Fork 1
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
429b344
commit b15e337
Showing
5 changed files
with
105 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
## [Unreleased] | ||
- 🌟 [@mixte/snippets] 新增 `mel-select` 组件 | ||
|
||
## [v3.0.0-beta.2] | ||
- 📅 2024-11-14 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import MelSelect from './src/index.vue'; | ||
|
||
export { | ||
MelSelect, | ||
}; |
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,39 @@ | ||
<template> | ||
<Render /> | ||
</template> | ||
|
||
<script lang="tsx" setup> | ||
import type { ISelectProps } from 'element-plus'; | ||
import type { MelSelectProps, MelSelectSlots, SelectInstance } from './types'; | ||
import { ElOption, ElSelect } from 'element-plus'; | ||
import { ref } from 'vue'; | ||
const props = defineProps<MelSelectProps>(); | ||
const slots = defineSlots<MelSelectSlots>(); | ||
const value = defineModel<ISelectProps['modelValue']>('modelValue'); | ||
const selectRef = ref<SelectInstance>(); | ||
function Render() { | ||
return ( | ||
<ElSelect | ||
ref={selectRef} | ||
v-model={value.value} | ||
> | ||
{{ | ||
default: () => { | ||
return props.options?.map((option) => { | ||
return <ElOption key={`${option.value}`} {...option} />; | ||
}); | ||
}, | ||
...slots, | ||
}} | ||
</ElSelect> | ||
); | ||
} | ||
defineExpose({ | ||
selectRef, | ||
}); | ||
</script> |
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,50 @@ | ||
import type { ElSelect, ISelectProps, SelectOptionProxy } from 'element-plus'; | ||
|
||
export type SelectInstance = InstanceType<typeof ElSelect>; | ||
|
||
export type MelOptionProps = Pick<SelectOptionProxy, 'value' | 'label' | 'disabled'>; | ||
|
||
export interface MelSelectProps extends /* @vue-ignore */ Omit<ISelectProps, 'modelValue'> { | ||
/** 选项数据源 */ | ||
options?: MelOptionProps[]; | ||
} | ||
|
||
export interface MelSelectSlots { | ||
/** | ||
* 默认插槽, 可自定义渲染 option 组件列表 | ||
*/ | ||
default?: () => void; | ||
/** | ||
* 下拉列表顶部的内容 | ||
* @version 2.4.3 | ||
*/ | ||
header?: () => void; | ||
/** | ||
* 下拉列表底部的内容 | ||
* @version 2.4.3 | ||
*/ | ||
footer?: () => void; | ||
/** | ||
* Select 组件头部内容 | ||
*/ | ||
prefix?: () => void; | ||
/** | ||
* 无选项时的列表 | ||
*/ | ||
empty?: () => void; | ||
/** | ||
* select 组件自定义标签内容 | ||
* @version 2.5.0 | ||
*/ | ||
tag?: () => void; | ||
/** | ||
* select 组件自定义 loading 内容 | ||
* @version 2.5.2 | ||
*/ | ||
loading?: () => void; | ||
/** | ||
* select 组件自定义标签内容 | ||
* @version 2.7.4 | ||
*/ | ||
label?: () => void; | ||
} |