UNPKG

vue-admin-core

Version:
73 lines (69 loc) 1.93 kB
'use strict'; var vue$1 = require('vue'); var vue = require('@formily/vue'); var core = require('@formily/core'); require('../../formily/index.js'); var reactiveVue = require('@formily/reactive-vue'); var index = require('../../formily/form-layout/src/index.js'); const useFormilyForm = (schema, options, SchemaField) => { const form = vue.useForm(); const app = vue$1.getCurrentInstance(); const SelfSchemaField = (app == null ? void 0 : app.appContext.components.SchemaField) || SchemaField; if (!SelfSchemaField) { throw new Error(`SchemaField \u627E\u4E0D\u5230\uFF0C\u5728\u5168\u5C40\u8BBE\u7F6Eapp.use(setupFormily)\u6216\u8005\u4F20\u5165SchemaField`); } if (!form.value) { form.value = core.createForm(options); } const FormilyForm = vue$1.defineComponent({ name: "FormilyForm", props: { ...index.formLayoutProps, schema: { type: Object }, components: { type: Object }, scope: { type: Object }, name: { type: [String, Number] }, definitions: { type: Object } }, setup(props, { slots }) { const { schema: schemaProps, components, scope, name, ...reset } = props; const _schema = vue$1.computed(() => ({ type: "object", definitions: props.definitions, properties: schemaProps || schema })); return () => vue$1.createVNode(index.FormLayout, reset, { default: () => [vue$1.createVNode(SelfSchemaField, { "schema": _schema.value, "components": components, "scope": scope, "name": name }, null), slots.default && slots.default()] }); } }); return { form, FormilyForm: reactiveVue.observer(FormilyForm) }; }; exports.useFormilyForm = useFormilyForm; //# sourceMappingURL=useFormilyForm.js.map