You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.7 KiB
51 lines
1.7 KiB
import type { PropType } from 'vue';
|
|
import { computed, defineComponent } from 'vue';
|
|
import type { SizeType } from '../config-provider';
|
|
import { FormItemInputContext } from '../form/FormItemContext';
|
|
import type { FocusEventHandler, MouseEventHandler } from '../_util/EventInterface';
|
|
import useConfigInject from '../config-provider/hooks/useConfigInject';
|
|
|
|
export default defineComponent({
|
|
compatConfig: { MODE: 3 },
|
|
name: 'AInputGroup',
|
|
props: {
|
|
prefixCls: String,
|
|
size: { type: String as PropType<SizeType> },
|
|
compact: { type: Boolean, default: undefined },
|
|
onMouseenter: { type: Function as PropType<MouseEventHandler> },
|
|
onMouseleave: { type: Function as PropType<MouseEventHandler> },
|
|
onFocus: { type: Function as PropType<FocusEventHandler> },
|
|
onBlur: { type: Function as PropType<FocusEventHandler> },
|
|
},
|
|
setup(props, { slots }) {
|
|
const { prefixCls, direction } = useConfigInject('input-group', props);
|
|
const formItemInputContext = FormItemInputContext.useInject();
|
|
FormItemInputContext.useProvide(formItemInputContext, {
|
|
isFormItemInput: false,
|
|
});
|
|
const cls = computed(() => {
|
|
const pre = prefixCls.value;
|
|
return {
|
|
[`${pre}`]: true,
|
|
[`${pre}-lg`]: props.size === 'large',
|
|
[`${pre}-sm`]: props.size === 'small',
|
|
[`${pre}-compact`]: props.compact,
|
|
[`${pre}-rtl`]: direction.value === 'rtl',
|
|
};
|
|
});
|
|
return () => {
|
|
return (
|
|
<span
|
|
class={cls.value}
|
|
onMouseenter={props.onMouseenter}
|
|
onMouseleave={props.onMouseleave}
|
|
onFocus={props.onFocus}
|
|
onBlur={props.onBlur}
|
|
>
|
|
{slots.default?.()}
|
|
</span>
|
|
);
|
|
};
|
|
},
|
|
});
|