ant-design-vue/components/input/Group.tsx

45 lines
1.4 KiB
Vue
Raw Normal View History

2021-12-14 15:50:22 +00:00
import type { PropType } from 'vue';
import { computed, defineComponent } from 'vue';
import type { SizeType } from '../config-provider';
import type { FocusEventHandler, MouseEventHandler } from '../_util/EventInterface';
import useConfigInject from '../_util/hooks/useConfigInject';
2019-04-07 09:19:18 +00:00
2020-10-16 06:24:14 +00:00
export default defineComponent({
2018-04-08 13:17:20 +00:00
name: 'AInputGroup',
2017-12-06 10:54:20 +00:00
props: {
prefixCls: String,
2021-12-14 15:50:22 +00:00
size: { type: String as PropType<SizeType> },
compact: { type: Boolean, default: undefined },
2021-12-14 15:50:22 +00:00
onMouseenter: { type: Function as PropType<MouseEventHandler> },
onMouseleave: { type: Function as PropType<MouseEventHandler> },
onFocus: { type: Function as PropType<FocusEventHandler> },
onBlur: { type: Function as PropType<FocusEventHandler> },
2017-12-06 10:54:20 +00:00
},
2021-12-14 15:50:22 +00:00
setup(props, { slots }) {
const { prefixCls, direction } = useConfigInject('input-group', props);
const cls = computed(() => {
const pre = prefixCls.value;
2017-12-06 10:54:20 +00:00
return {
2021-12-14 15:50:22 +00:00
[`${pre}`]: true,
[`${pre}-lg`]: props.size === 'large',
[`${pre}-sm`]: props.size === 'small',
[`${pre}-compact`]: props.compact,
[`${pre}-rtl`]: direction.value === 'rtl',
2019-01-12 03:33:27 +00:00
};
2021-12-14 15:50:22 +00:00
});
return () => {
return (
<span
class={cls.value}
onMouseenter={props.onMouseEnter}
onMouseleave={props.onMouseLeave}
onFocus={props.onFocus}
onBlur={props.onBlur}
>
{slots.default?.()}
</span>
);
};
2018-03-19 01:43:31 +00:00
},
2020-10-16 06:24:14 +00:00
});