-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathGroup.tsx
59 lines (55 loc) · 1.93 KB
/
Group.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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';
// CSSINJS
import useStyle from './style';
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,
});
// style
const { prefixCls: inputPrefixCls } = useConfigInject('input', props);
const [wrapSSR, hashId] = useStyle(inputPrefixCls);
const cls = computed(() => {
const pre = prefixCls.value;
return {
[`${pre}`]: true,
[hashId.value]: true,
[`${pre}-lg`]: props.size === 'large',
[`${pre}-sm`]: props.size === 'small',
[`${pre}-compact`]: props.compact,
[`${pre}-rtl`]: direction.value === 'rtl',
};
});
return () => {
return wrapSSR(
<span
class={cls.value}
onMouseenter={props.onMouseenter}
onMouseleave={props.onMouseleave}
onFocus={props.onFocus}
onBlur={props.onBlur}
>
{slots.default?.()}
</span>,
);
};
},
});