mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* refactor(components): [select&select-v2] refactor components * refactor(components): [select-v2] * refactor(components): update * refactor(components): update * refactor(components): [select-v2] update * refactor(components): update * refactor(components): update * refactor(components): update type * refactor(components): update * refactor(components): update * refactor(components): update style * refactor(components): update docs * refactor(components): update * refactor(components): fix #15323 * refactor(theme-chalk): update * refactor(components): update * refactor(components): update * refactor(components): update * refactor(components): fix bugs * fix(components): fix issue * fix(components): update * fix(components): fix some bug * feat(components): update * feat(components): add tag slot * feat(components): update * fix(components): update * style(theme-chalk): update style * fix(theme-chalk): update * feat(theme-chalk): update * fix(components): update * feat: update * feat: update * feat: update * feat(components): update
37 lines
940 B
TypeScript
37 lines
940 B
TypeScript
import { computed } from 'vue'
|
|
import { get } from 'lodash-unified'
|
|
|
|
import type { ISelectV2Props } from './token'
|
|
import type { Option } from './select.types'
|
|
|
|
export interface Props {
|
|
label?: string
|
|
value?: string
|
|
disabled?: string
|
|
options?: string
|
|
}
|
|
|
|
export const defaultProps: Required<Props> = {
|
|
label: 'label',
|
|
value: 'value',
|
|
disabled: 'disabled',
|
|
options: 'options',
|
|
}
|
|
|
|
export function useProps(props: Pick<ISelectV2Props, 'props'>) {
|
|
const aliasProps = computed(() => ({ ...defaultProps, ...props.props }))
|
|
|
|
const getLabel = (option: Option) => get(option, aliasProps.value.label)
|
|
const getValue = (option: Option) => get(option, aliasProps.value.value)
|
|
const getDisabled = (option: Option) => get(option, aliasProps.value.disabled)
|
|
const getOptions = (option: Option) => get(option, aliasProps.value.options)
|
|
|
|
return {
|
|
aliasProps,
|
|
getLabel,
|
|
getValue,
|
|
getDisabled,
|
|
getOptions,
|
|
}
|
|
}
|