UNPKG

@ywfe/materials-design

Version:
182 lines (178 loc) 4.72 kB
import { IPublicTypeComponentMetadata, IPublicTypeSnippet } from '@alilc/lowcode-types'; import { FormItemsProps, YwButtonBaseProps } from '../_base'; import { uuid } from '../_utils'; const YwFormDialogMeta: IPublicTypeComponentMetadata = { componentName: 'YwFormDialog', title: '表单弹窗', docUrl: '', screenshot: '', group: '基础组件', category: '弹窗类', devMode: 'proCode', npm: { package: '@ywfe/materials-design', version: '0.0.1-beta.6', exportName: 'YwFormDialog', main: 'src/index.tsx', destructuring: true, subName: '', }, configure: { props: [ { name: 'ref', title: { label: '组件标识', tip: "ref | 通过 this.$('xxx') 获取到组件实例", }, defaultValue: () => { return `form_dialog_${uuid()}`; }, setter: 'StringSetter', }, { name: 'title', title: { label: '弹窗标题', tip: 'title | 标题' }, setter: 'StringSetter', }, { name: 'size', title: { label: '弹窗尺寸', tip: 'size | 标题' }, setter: 'StringSetter', }, ...YwButtonBaseProps, // ...FormSchemaProps, ...FormItemsProps, { title: { label: '表单默认值', tip: 'initialValues | 表单默认值', }, display: 'inline', name: 'initialValues', description: '表单默认值', supportVariable: false, setter: { componentName: 'JsonSetter', isRequired: false, initialValue: {}, }, }, { title: { label: '确定操作', tip: 'onConfirm | 确定操作', }, name: 'onConfirm', setter: { componentName: 'SchemaFunctionSetter', props: { title: 'getDataSource', async: true, properties: { input: { type: 'object', properties: { values: { type: 'string', }, }, required: ['values'], }, body: { type: 'array', items: [ { type: 'Function', properties: { template: 'RequestFunction', variable: 'requestRes', extraProps: { params: '{{values}}', }, }, }, ], }, output: 'requestRes', }, }, }, }, ], supports: { events: [ { name: 'onConfirm', description: '确认事件', }, { name: 'onCancel', description: '取消事件', template: 'function onCancel() {\n this.setState({\n isShowDialog: false\n });\n}', }, { name: 'onFormInit', description: '表单初始化事件', template: 'function onFormInit(_form) {\n this.setState({\n form: _form\n });\n}', }, { name: 'onOpen', description: '弹窗打开事件(开发中)', }, ], style: true, className: true, loop: false, }, component: { isContainer: false, }, }, }; const snippets: IPublicTypeSnippet[] = [ { title: '表单弹窗', screenshot: 'https://yw-fed-static.oss-cn-hangzhou.aliyuncs.com/lowcode/dialog', schema: { componentName: 'YwFormDialog', props: { btnText: '编辑', // onFormInit: { // type: 'JSExpression', // value: '(form)=>{form.setValues(this.record)}', // }, // onConfirm: { // type: 'JSExpression', // value: // '(values) => {return new Promise((resolve)=>{console.log("values",values);this.reload();resolve()})}', // }, // initialValues: { // type: 'JSExpression', // value: 'this.record', // }, // reload: { // type: 'JSExpression', // value: 'this.reload', // }, btnType: 'link', title: '弹窗标题', items: [ { component: 'Input', primaryKey: `input_${uuid()}`, label: '表单项', size: 'medium', title: '表单项', name: `input_${uuid()}`, }, ], visible: undefined, }, }, }, ]; export default { ...YwFormDialogMeta, snippets, };