vxe-design
Version:
A PC-based visual designer based on Vxe UI, used for building zero-code and low-code platforms
72 lines (71 loc) • 2.91 kB
JavaScript
import { h } from 'vue';
import { defineVxeComponent } from '../../ui/src/comp';
import { VxeUI, getI18n } from '@vxe-ui/core';
import { useWidgetName } from '../../form-design/src/use';
export const WidgetInputFormComponent = defineVxeComponent({
props: {
renderOpts: {
type: Object,
default: () => ({})
},
renderParams: {
type: Object,
default: () => ({})
}
},
emits: [],
setup(props) {
const VxeUIFormComponent = VxeUI.getComponent('vxe-form');
const VxeUIFormItemComponent = VxeUI.getComponent('vxe-form-item');
const VxeUIInputComponent = VxeUI.getComponent('vxe-input');
const VxeUISwitchComponent = VxeUI.getComponent('vxe-switch');
const { computeKebabCaseName } = useWidgetName(props);
return () => {
const { renderParams } = props;
const { widget } = renderParams;
const kebabCaseName = computeKebabCaseName.value;
return h(VxeUIFormComponent, {
class: ['vxe-form-design--widget-render-form-wrapper', `widget-${kebabCaseName}`],
vertical: true,
span: 24,
titleBold: true,
titleOverflow: true,
data: widget.options
}, {
default() {
return [
h(VxeUIFormItemComponent, {
title: getI18n('vxe.formDesign.widgetProp.name')
}, {
default() {
return h(VxeUIInputComponent, {
modelValue: widget.title,
'onUpdate:modelValue'(val) {
widget.title = val;
}
});
}
}),
h(VxeUIFormItemComponent, {
title: getI18n('vxe.formDesign.widgetProp.placeholder'),
field: 'placeholder',
itemRender: { name: 'VxeInput' }
}),
h(VxeUIFormItemComponent, {
title: getI18n('vxe.formDesign.widgetProp.required')
}, {
default() {
return h(VxeUISwitchComponent, {
modelValue: widget.required,
'onUpdate:modelValue'(val) {
widget.required = val;
}
});
}
})
];
}
});
};
}
});