|
@@ -41,6 +41,7 @@ import {
|
|
|
const withDefaultPlaceholder = <T extends Component>(
|
|
|
component: T,
|
|
|
type: 'input' | 'select',
|
|
|
+ componentProps: Recordable<any> = {},
|
|
|
) => {
|
|
|
return defineComponent({
|
|
|
inheritAttrs: false,
|
|
@@ -63,7 +64,11 @@ const withDefaultPlaceholder = <T extends Component>(
|
|
|
}
|
|
|
});
|
|
|
return () =>
|
|
|
- h(component, { ...props, ...attrs, placeholder, ref: innerRef }, slots);
|
|
|
+ h(
|
|
|
+ component,
|
|
|
+ { ...componentProps, placeholder, ...props, ...attrs, ref: innerRef },
|
|
|
+ slots,
|
|
|
+ );
|
|
|
},
|
|
|
});
|
|
|
};
|
|
@@ -102,38 +107,20 @@ async function initComponentAdapter() {
|
|
|
// 如果你的组件体积比较大,可以使用异步加载
|
|
|
// Button: () =>
|
|
|
// import('xxx').then((res) => res.Button),
|
|
|
- ApiSelect: (props, { attrs, slots }) => {
|
|
|
- return h(
|
|
|
- ApiComponent,
|
|
|
- {
|
|
|
- placeholder: $t('ui.placeholder.select'),
|
|
|
- ...props,
|
|
|
- ...attrs,
|
|
|
- component: Select,
|
|
|
- loadingSlot: 'suffixIcon',
|
|
|
- visibleEvent: 'onDropdownVisibleChange',
|
|
|
- modelPropName: 'value',
|
|
|
- },
|
|
|
- slots,
|
|
|
- );
|
|
|
- },
|
|
|
- ApiTreeSelect: (props, { attrs, slots }) => {
|
|
|
- return h(
|
|
|
- ApiComponent,
|
|
|
- {
|
|
|
- placeholder: $t('ui.placeholder.select'),
|
|
|
- ...props,
|
|
|
- ...attrs,
|
|
|
- component: TreeSelect,
|
|
|
- fieldNames: { label: 'label', value: 'value', children: 'children' },
|
|
|
- loadingSlot: 'suffixIcon',
|
|
|
- modelPropName: 'value',
|
|
|
- optionsPropName: 'treeData',
|
|
|
- visibleEvent: 'onVisibleChange',
|
|
|
- },
|
|
|
- slots,
|
|
|
- );
|
|
|
- },
|
|
|
+ ApiSelect: withDefaultPlaceholder(ApiComponent, 'select', {
|
|
|
+ component: Select,
|
|
|
+ loadingSlot: 'suffixIcon',
|
|
|
+ visibleEvent: 'onDropdownVisibleChange',
|
|
|
+ modelPropName: 'value',
|
|
|
+ }),
|
|
|
+ ApiTreeSelect: withDefaultPlaceholder(ApiComponent, 'select', {
|
|
|
+ component: TreeSelect,
|
|
|
+ fieldNames: { label: 'label', value: 'value', children: 'children' },
|
|
|
+ loadingSlot: 'suffixIcon',
|
|
|
+ modelPropName: 'value',
|
|
|
+ optionsPropName: 'treeData',
|
|
|
+ visibleEvent: 'onVisibleChange',
|
|
|
+ }),
|
|
|
AutoComplete,
|
|
|
Checkbox,
|
|
|
CheckboxGroup,
|
|
@@ -143,19 +130,11 @@ async function initComponentAdapter() {
|
|
|
return h(Button, { ...props, attrs, type: 'default' }, slots);
|
|
|
},
|
|
|
Divider,
|
|
|
- IconPicker: (props, { attrs, slots }) => {
|
|
|
- return h(
|
|
|
- IconPicker,
|
|
|
- {
|
|
|
- iconSlot: 'addonAfter',
|
|
|
- inputComponent: Input,
|
|
|
- modelValueProp: 'value',
|
|
|
- ...props,
|
|
|
- ...attrs,
|
|
|
- },
|
|
|
- slots,
|
|
|
- );
|
|
|
- },
|
|
|
+ IconPicker: withDefaultPlaceholder(IconPicker, 'select', {
|
|
|
+ iconSlot: 'addonAfter',
|
|
|
+ inputComponent: Input,
|
|
|
+ modelValueProp: 'value',
|
|
|
+ }),
|
|
|
Input: withDefaultPlaceholder(Input, 'input'),
|
|
|
InputNumber: withDefaultPlaceholder(InputNumber, 'input'),
|
|
|
InputPassword: withDefaultPlaceholder(InputPassword, 'input'),
|