UNPKG

el-plus-powerful-form

Version:

## [DOCS](https://peng-xiao-shuai.github.io/vite-vue-admin-docs/zh-CN/component_directive/component/powerful-form-doc.html)

1 lines 8.35 kB
{"version":3,"file":"form-view.vue2.mjs","sources":["../../../packages/powerful-form/src/form-view.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { unref as _unref, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, renderSlot as _renderSlot, createCommentVNode as _createCommentVNode, mergeProps as _mergeProps, createBlock as _createBlock, resolveDynamicComponent as _resolveDynamicComponent, normalizeStyle as _normalizeStyle, withCtx as _withCtx, createVNode as _createVNode } from \"vue\"\n\nconst _hoisted_1 = { style: {\"transition\":\"all 0.3s\",\"overflow\":\"hidden\"} }\n\nimport { ElForm, ElFormItem } from 'element-plus'\nimport { formViewProps, useFormViewState, useFunction } from './form-view-data'\nimport { FRenderJsx } from '~/components'\nimport {\n FormTypeEnum,\n clearSymbol,\n componentRegister,\n matchComponents,\n} from '~/index'\n\n\nconst __default__ = {\n name: 'PowerfulForm',\n}\n\n\nexport default /*@__PURE__*/_defineComponent({\n ...__default__,\n props: formViewProps,\n setup(__props, { expose: __expose }) {\n\nconst { appContext } = getCurrentInstance()!\ncomponentRegister(appContext.app)\n\nconst props = __props\n\nconst { formViewData, formRenderItems, elFormRef, transformHeader } =\n useFormViewState(props)\nconst { formData, rules } = toRefs(formViewData)\n\nconst { bindAttr, submitForm, resetForm, refreshRender, visibleFormTrigger } =\n useFunction(props, formData, elFormRef, transformHeader)\n\n__expose({\n $slots: useSlots(),\n $attrs: useAttrs(),\n $refs: {\n elFormRef,\n },\n props,\n powerfulFormData: formViewData,\n formItems: formRenderItems.value,\n visibleFormTrigger,\n submitForm,\n resetForm,\n refreshRender,\n})\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n _createVNode(_unref(ElForm), _mergeProps(_ctx.property, {\n ref_key: \"elFormRef\",\n ref: elFormRef,\n model: _unref(formData),\n rules: props.showType === 'query' ? {} : _unref(rules),\n disabled: _ctx.disabled,\n style: \n _ctx.property?.inline\n ? {}\n : {\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'space-between',\n }\n \n }), {\n default: _withCtx(() => [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_unref(formRenderItems), (item, index) => {\n return (_openBlock(), _createBlock(_unref(ElFormItem), {\n key: item.prop,\n prop: item.prop,\n label: _ctx.showLabel ? _unref(clearSymbol)(item.text) : '',\n style: _normalizeStyle({\n flexBasis: item?.basis || '100%',\n })\n }, {\n default: _withCtx(() => [\n (item.type == 'slot')\n ? _renderSlot(_ctx.$slots, item.slotName || 'default', {\n key: 0,\n index: index\n }, undefined, true)\n : (typeof item.render == 'function')\n ? (_openBlock(), _createBlock(_unref(FRenderJsx), _mergeProps({\n key: 1,\n ref_for: true\n }, _unref(bindAttr)(item, _unref(formData), index)), null, 16))\n : (_openBlock(), _createBlock(_resolveDynamicComponent(_unref(matchComponents)(item.type || _unref(FormTypeEnum).Input)), _mergeProps({\n key: 2,\n ref_for: true\n }, _unref(bindAttr)(item, _unref(formData), index), {\n \"onUpdate:modelValue\": ($event: any) => (_unref(formData)[item.prop!] = $event)\n }), null, 16, [\"onUpdate:modelValue\"]))\n ]),\n _: 2\n }, 1032, [\"prop\", \"label\", \"style\"]))\n }), 128)),\n (_ctx.$slots['last-item'])\n ? (_openBlock(), _createBlock(_unref(ElFormItem), { key: 0 }, {\n default: _withCtx(() => [\n _renderSlot(_ctx.$slots, \"last-item\", {}, undefined, true)\n ]),\n _: 3\n }))\n : _createCommentVNode(\"\", true)\n ]),\n _: 3\n }, 16, [\"model\", \"rules\", \"disabled\", \"style\"])\n ]))\n}\n}\n\n})"],"names":["defineComponent","getCurrentInstance","toRefs","useSlots","useAttrs","openBlock","createElementBlock","createVNode","unref","mergeProps","withCtx","Fragment","renderList","createBlock","normalizeStyle","renderSlot","resolveDynamicComponent","createCommentVNode","ElForm","ElFormItem","formViewProps","useFormViewState","useFunction","componentRegister","clearSymbol","matchComponents","FRenderJsx","FormTypeEnum","_hoisted_1","__default__","_sfc_main","_defineComponent","__props","__expose","appContext","props","formViewData","formRenderItems","elFormRef","transformHeader","formData","rules","bindAttr","submitForm","resetForm","refreshRender","visibleFormTrigger","_ctx","_cache","_a","_openBlock","_createElementBlock","_createVNode","_unref","_mergeProps","_withCtx","_Fragment","_renderList","item","index","_createBlock","_normalizeStyle","_renderSlot","_resolveDynamicComponent","$event","_createCommentVNode"],"mappings":"AAGA,SAAA,mBAAAA,GAAA,sBAAAC,GAAA,UAAAC,GAAA,YAAAC,GAAA,YAAAC,GAAA,aAAAC,GAAA,sBAAAC,GAAA,eAAAC,GAAA,SAAAC,GAAA,cAAAC,GAAA,WAAAC,GAAA,YAAAC,GAAA,cAAAC,GAAA,eAAAC,GAAA,kBAAAC,GAAA,cAAAC,GAAA,2BAAAC,GAAA,sBAAAC,SAAA;AAAA,SAAA,UAAAC,GAAA,cAAAC,SAAA;AAAA,SAAA,iBAAAC,GAAA,oBAAAC,GAAA,eAAAC,SAAA;AAAA,SAAA,qBAAAC,SAAA;AAAA,SAAA,eAAAC,GAAA,mBAAAC,SAAA;AAAA,SAAA,cAAAC,SAAA;AAAA,SAAA,gBAAAC,SAAA;AAAA,MAAMC,IAAa,EAAE,OAAO,EAAC,YAAa,YAAW,UAAW,cAa1DC,IAAc;AAAA,EAClB,MAAM;AACR,GAG4BC,KAAiBC,gBAAAA,EAAA;AAAA,EAC3C,GAAGF;AAAA,EACH,OAAOT;AAAA,EACP,MAAMY,GAAS,EAAE,QAAQC,KAAY;AAEjC,UAAA,EAAE,YAAAC,MAAejC;AACvB,IAAAsB,EAAkBW,EAAW,GAAG;AAEhC,UAAMC,IAAQH,GAER,EAAE,cAAAI,GAAc,iBAAAC,GAAiB,WAAAC,GAAW,iBAAAC,MAChDlB,EAAiBc,CAAK,GAClB,EA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