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

46 lines
1.5 KiB
Vue
Raw Normal View History

2021-12-14 23:50:22 +08:00
import type { PropType } from 'vue';
import { computed, defineComponent } from 'vue';
2019-09-11 18:11:48 +08:00
import PropTypes from '../_util/vue-types';
2021-12-14 23:50:22 +08:00
import type { SizeType } from '../config-provider';
import type { FocusEventHandler, MouseEventHandler } from '../_util/EventInterface';
import useConfigInject from '../_util/hooks/useConfigInject';
2019-04-07 17:19:18 +08:00
2020-10-16 14:24:14 +08:00
export default defineComponent({
2018-04-08 21:17:20 +08:00
name: 'AInputGroup',
2017-12-06 18:54:20 +08:00
props: {
2019-09-11 18:11:48 +08:00
prefixCls: PropTypes.string,
2021-12-14 23:50:22 +08:00
size: { type: String as PropType<SizeType> },
compact: PropTypes.looseBool,
2021-12-14 23:50:22 +08: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 18:54:20 +08:00
},
2021-12-14 23:50:22 +08:00
setup(props, { slots }) {
const { prefixCls, direction } = useConfigInject('input-group', props);
const cls = computed(() => {
const pre = prefixCls.value;
2017-12-06 18:54:20 +08:00
return {
2021-12-14 23:50:22 +08: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 11:33:27 +08:00
};
2021-12-14 23:50:22 +08: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 09:43:31 +08:00
},
2020-10-16 14:24:14 +08:00
});