2023-03-17 22:38:25 +08:00
|
|
|
import { computed, defineComponent } from 'vue'
|
|
|
|
import { useProviderConfigState } from '../config-provider/context'
|
2023-03-18 18:17:20 +08:00
|
|
|
import Wave from '../_util/wave'
|
2023-03-17 22:38:25 +08:00
|
|
|
import useStyle from './style'
|
2023-03-10 22:11:33 +08:00
|
|
|
|
|
|
|
const Button = defineComponent({
|
|
|
|
name: 'AButton',
|
2023-03-17 22:38:25 +08:00
|
|
|
inheritAttrs: false,
|
|
|
|
props: {
|
|
|
|
prefixCls: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: 'default'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setup(props, { slots, attrs }) {
|
|
|
|
const { getPrefixCls } = useProviderConfigState()
|
|
|
|
const prefixCls = computed(() => getPrefixCls('btn', props.prefixCls))
|
|
|
|
const [wrapSSR, hashId] = useStyle(prefixCls)
|
|
|
|
|
|
|
|
const cls = computed(() => {
|
|
|
|
return {
|
|
|
|
[prefixCls.value]: true,
|
|
|
|
[`${prefixCls.value}-${props.type}`]: !!props.type,
|
|
|
|
[hashId.value]: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2023-03-10 22:11:33 +08:00
|
|
|
return () => {
|
2023-03-17 22:38:25 +08:00
|
|
|
return wrapSSR(
|
2023-03-18 18:17:20 +08:00
|
|
|
<Wave>
|
|
|
|
<button
|
|
|
|
{...attrs}
|
|
|
|
class={[cls.value, attrs.class]}
|
|
|
|
>
|
|
|
|
{slots.default?.()}
|
|
|
|
</button>
|
|
|
|
</Wave>
|
2023-03-17 22:38:25 +08:00
|
|
|
)
|
2023-03-10 22:11:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export default Button
|