Skip to content

Commit

Permalink
feat(Select): support option slot (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-xufei committed Dec 25, 2023
1 parent 904b591 commit e000ab5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/components/src/select/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { connect, mapProps, h, mapReadPretty } from '@formily/vue'
import { defineComponent } from 'vue'
import { connect, mapProps, mapReadPretty } from '@formily/vue'
import { defineComponent, h } from 'vue'
import { PreviewText } from '../preview-text'

import { ElSelect, ElOption } from 'element-plus'
import { transformComponent } from '../__builtins__'
import { resolveComponent, transformComponent } from '../__builtins__'

export type SelectProps = typeof ElSelect & {
options?: Array<typeof ElOption>
Expand Down Expand Up @@ -34,7 +34,11 @@ const SelectOption = defineComponent({
return h(
ElOption,
{ key: option, value: option, label: option },
slots
{
default: () => [
resolveComponent(slots?.option ?? option, { option }),
],
}
)
} else {
return h(
Expand All @@ -43,7 +47,11 @@ const SelectOption = defineComponent({
key: option.value,
...option,
},
slots
{
default: () => [
resolveComponent(slots?.option ?? option, { option }),
],
}
)
}
}),
Expand Down

0 comments on commit e000ab5

Please sign in to comment.