UNPKG

@form-create/ant-design-vue

Version:

AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。

12 lines (11 loc) 80.2 kB
/*! * FormCreate 低代码表单渲染器 * @form-create/ant-design-vue v2.6.3 * (c) 2018-2024 xaboy * Github https://github.com/xaboy/form-create * Site https://form-create.com/ * Released under the MIT License. */ (function(){"use strict";try{if(typeof document!="undefined"){var o=document.createElement("style");o.appendChild(document.createTextNode('._fc-frame .fc-files img{width:100%;height:100%;display:inline-block;vertical-align:top}._fc-frame .fc-upload-cover{opacity:0;position:absolute;inset:0;background:#0009;transition:opacity .3s}._fc-frame .fc-upload-cover i{color:#fff;font-size:20px;cursor:pointer;margin:0 2px}._fc-frame .fc-files:hover .fc-upload-cover{opacity:1}._fc-frame .ant-upload{display:block}._fc-frame .fc-upload-btn,.fc-files{display:inline-block;width:104px;height:104px;text-align:center;line-height:104px;border:1px solid #c0ccda;border-radius:4px;overflow:hidden;background:#fff;position:relative;box-shadow:2px 2px 5px #0000001a;margin-right:4px;box-sizing:border-box}._fc-group{display:flex;min-height:42px;justify-content:center;flex-direction:column}._fc-group-disabled ._fc-group-btn,._fc-group-disabled ._fc-group-add{cursor:not-allowed}._fc-group-handle{display:flex;flex-direction:row;position:absolute;bottom:-15px;right:30px;border-radius:15px;border:1px dashed #d9d9d9;padding:3px 8px;background-color:#fff}._fc-group-btn{cursor:pointer}._fc-group-idx{position:absolute;bottom:-15px;left:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:#eee;border-radius:15px;font-weight:700}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{position:relative;display:flex;flex-direction:column;border:1px dashed #d9d9d9;padding:20px 20px 25px;margin:5px 5px 25px;border-radius:5px}._fc-group-arrow{position:relative;width:20px;height:20px}._fc-group-arrow:before{content:"";position:absolute;top:8px;left:5px;width:9px;height:9px;border-left:2px solid #999;border-top:2px solid #999}._fc-group-arrow:before{transform:rotate(45deg)}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{width:20px;height:20px;position:relative;cursor:pointer}._fc-group-plus-minus:before,._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:60%;height:2px;background-color:#409eff;transform:translate(-50%,-50%)}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{cursor:pointer;width:25px;height:25px;border:1px solid rgb(64 158 255 / 50%);border-radius:15px}._fc-group-add._fc-group-plus-minus:before,._fc-group-add._fc-group-plus-minus:after{width:50%}.form-create .form-create .ant-form-item{margin-bottom:22px}.form-create .form-create .ant-form-item .ant-form-item{margin-bottom:0}.form-create .form-create .ant-form-item.ant-form-item-with-help{margin-bottom:3px}.form-create .form-create .ant-form-item .ant-form-item.ant-form-item-with-help{margin-bottom:-22px}')),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})(); (function(O,v){typeof exports=="object"&&typeof module!="undefined"?v(exports,require("vue"),require("moment")):typeof define=="function"&&define.amd?define(["exports","vue","moment"],v):(O=typeof globalThis!="undefined"?globalThis:O||self,v(O.formCreate={},O.Vue,O.moment))})(this,function(O,v,R){"use strict";var Ur=Object.defineProperty,Hr=Object.defineProperties;var Jr=Object.getOwnPropertyDescriptors;var ct=Object.getOwnPropertySymbols;var xr=Object.prototype.hasOwnProperty,Yr=Object.prototype.propertyIsEnumerable;var dt=(O,v,R)=>v in O?Ur(O,v,{enumerable:!0,configurable:!0,writable:!0,value:R}):O[v]=R,m=(O,v)=>{for(var R in v||(v={}))xr.call(v,R)&&dt(O,R,v[R]);if(ct)for(var R of ct(v))Yr.call(v,R)&&dt(O,R,v[R]);return O},M=(O,v)=>Hr(O,Jr(v));function pt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function se(){return se=Object.assign?Object.assign.bind():function(t){for(var e,r=1;r<arguments.length;r++)for(var i in e=arguments[r],e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},se.apply(this,arguments)}var mt=["attrs","props","domProps"],yt=["class","style","directives"],gt=["on","nativeOn"],$t=function(t){return t.reduce(function(e,r){for(var i in r)if(!e[i])e[i]=r[i];else if(mt.indexOf(i)!==-1)e[i]=se({},e[i],r[i]);else if(yt.indexOf(i)!==-1){var s=e[i]instanceof Array?e[i]:[e[i]],n=r[i]instanceof Array?r[i]:[r[i]];e[i]=[].concat(s,n)}else if(gt.indexOf(i)!==-1)for(var o in r[i])if(e[i][o]){var a=e[i][o]instanceof Array?e[i][o]:[e[i][o]],u=r[i][o]instanceof Array?r[i][o]:[r[i][o]];e[i][o]=[].concat(a,u)}else e[i][o]=r[i][o];else if(i==="hook")for(var l in r[i])e[i][l]=e[i][l]?bt(e[i][l],r[i][l]):r[i][l];else e[i]=r[i];return e},{})},bt=function(t,e){return function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)}},vt=$t;const q=pt(vt);function Fe(t){return t==null?"":typeof t=="object"?JSON.stringify(t,null,2):String(t)}function E(t,e,r){v.set(t,e,r)}function N(t,e){v.delete(t,e)}const h={type(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"},Undef(t){return t==null},Element(t){return typeof t=="object"&&t!==null&&t.nodeType===1&&!h.Object(t)},trueArray(t){return Array.isArray(t)&&t.length>0},Function(t){const e=this.getType(t);return e==="Function"||e==="AsyncFunction"},getType(t){const e=Object.prototype.toString.call(t);return/^\[object (.*)\]$/.exec(e)[1]},empty(t){return t==null||Array.isArray(t)&&Array.isArray(t)&&!t.length?!0:typeof t=="string"&&!t}};["Date","Object","String","Boolean","Array","Number"].forEach(t=>{h[t]=function(e){return h.type(e,t)}});function k(t,e){return{}.hasOwnProperty.call(t,e)}function Y(t,e={},r){let i=!1;for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let n=e[s];if((i=Array.isArray(n))||h.Object(n)){let o=t[s]===void 0;if(i)i=!1,o&&E(t,s,[]);else if(n._clone&&r!==void 0)if(r)n=n.getRule(),o&&E(t,s,{});else{E(t,s,n._clone());continue}else o&&E(t,s,{});t[s]=Y(t[s],n,r)}else E(t,s,n),h.Undef(n)||(h.Undef(n.__json)||(t[s].__json=n.__json),h.Undef(n.__origin)||(t[s].__origin=n.__origin))}return r!==void 0&&Array.isArray(t)?t.filter(s=>!s||!s.__ctrl):t}function L(t){return Y({},{value:t}).value}function D(t){return Array.isArray(t)?t:[null,void 0,""].indexOf(t)>-1?[]:[t]}function _t(t,e){return Object.keys(t).reduce((r,i)=>((!e||e.indexOf(i)===-1)&&r.push(t[i]),r),[])}const Ee=function(t,e){return{url:t,name:Ct(t),status:"done",uid:e+1}},Ct=function(t){return Fe(t).split("/").pop()},Se=function(t){return{url:t.url,file:t}},Ot={name:"fcUpload",formCreateParser:{toFormValue(t){return D(t)},toValue(t,e){return e.prop.props.limit===1?t[0]||"":t}},props:{limit:{type:Number,default:0},formCreateInject:{type:Object,required:!0},value:{type:Array,default:()=>[]},onSuccess:{type:Function,required:!0},onHandle:{type:Function,default:function(t){this.previewImage=t.url,this.previewVisible=!0}},modalTitle:String,previewMask:void 0},data(){const t=this.value.map(Ee);return{defaultUploadList:t,previewImage:"",previewVisible:!1,uploadList:t.map(Se)}},watch:{value(t){const e=t.map(Ee);this.$refs.upload.sFileList=e,this.uploadList=e.map(Se)}},methods:{handleChange({file:t,fileList:e}){const r=this.uploadList;t.status==="done"?(this.onSuccess(t,e),t.url&&r.push({url:t.url,file:e[e.length-1]}),this.input()):t.status==="removed"&&(r.forEach((i,s)=>{i.file===t&&r.splice(s,1)}),this.input())},input(){this.$emit("input",this.uploadList.map(t=>t.url))}},render(){const t=arguments[0],e=!this.limit||this.limit>this.uploadList.length,r=m({},this.formCreateInject.prop);return r.on=Y({},r.on||{}),t("div",{class:"_fc-upload"},[t("AUpload",q([{},r,{},{on:{preview:this.onHandle.bind(this),change:this.handleChange.bind(this)},props:{defaultFileList:this.defaultUploadList},ref:"upload"}]),[e?t("template",{slot:"default"},[this.$slots.default||t("AIcon",{attrs:{type:"plus"}})]):null,_t(this.$slots,["default"])]),t("aModal",q([{},{props:{mask:this.previewMask,title:this.modalTitle,footer:null}},{model:{value:this.previewVisible,callback:i=>{this.previewVisible=i}}}]),[t("img",{style:"width: 100%",attrs:{src:this.previewImage}})])])},mounted(){this.$emit("fc.el",this.$refs.upload)}},kt={name:"fcFrame",props:{formCreateInject:{type:Object,required:!0},type:{type:String,default:"input"},field:String,helper:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},src:{type:String,required:!0},icon:{type:String,default:"folder"},width:{type:[Number,String],default:500},height:{type:String,default:"370px"},maxLength:{type:Number,default:0},okBtnText:{type:String,default:"确定"},closeBtnText:{type:String,default:"关闭"},modalTitle:String,handleIcon:{type:[String,Boolean],default:void 0},title:String,allowRemove:{type:Boolean,default:!0},onOpen:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}},onCancel:{type:Function,default:()=>{}},onLoad:{type:Function,default:()=>{}},onBeforeRemove:{type:Function,default:()=>{}},onRemove:{type:Function,default:()=>{}},onHandle:{type:Function,default(t){this.previewImage=this.getSrc(t),this.previewVisible=!0}},modal:{type:Object,default:()=>({})},srcKey:{type:[String,Number]},value:[Array,String,Number,Object],previewMask:void 0,footer:{type:Boolean,default:!0},reload:{type:Boolean,default:!0},closeBtn:{type:Boolean,default:!0},okBtn:{type:Boolean,default:!0}},data(){return{fileList:D(this.value),previewVisible:!1,frameVisible:!1,previewImage:""}},watch:{value(t){this.fileList=D(t)},fileList(t){const e=this.maxLength===1?t[0]||"":t;this.$emit("input",e),this.$emit("change",e)}},methods:{key(t){return t},closeModal(t){this.$emit(t?"$close":"$ok"),this.reload&&(this.$off("$ok"),this.$off("$close")),this.frameVisible=!1},showModal(){this.disabled||this.onOpen()===!1||(this.frameVisible=!0)},makeInput(){const t=this.$createElement,e={type:"text",value:this.fileList.map(r=>this.getSrc(r)).toString(),readonly:!0};return t("AInput",q([{},{props:e},{key:this.key("input")}]),[t("AIcon",{attrs:{type:this.icon},slot:"addonAfter",on:{click:this.showModal}}),this.fileList.length?t("AIcon",{attrs:{type:"close-circle"},slot:"suffix",on:{click:()=>this.fileList=[]}}):null])},makeGroup(t){const e=this.$createElement;return(!this.maxLength||this.fileList.length<this.maxLength)&&t.push(this.makeBtn()),e("div",{key:this.key("group")},[...t])},makeItem(t,e){const r=this.$createElement;return r("div",{class:"fc-files",key:this.key("file"+t)},[...e])},valid(t){const e=this.formCreateInject.field||this.field;if(e&&t!==e)throw new Error("[frame]无效的字段值")},makeIcons(t,e){const r=this.$createElement;if(this.handleIcon!==!1||this.allowRemove===!0){const i=[];return(this.type!=="file"&&this.handleIcon!==!1||this.type==="file"&&this.handleIcon)&&i.push(this.makeHandleIcon(t,e)),this.allowRemove&&i.push(this.makeRemoveIcon(t,e)),r("div",{class:"fc-upload-cover",key:this.key("uc")},[i])}},makeHandleIcon(t,e){const r=this.$createElement;return r("AIcon",{attrs:{type:this.handleIcon===!0||this.handleIcon===void 0?"eye-o":this.handleIcon},on:{click:()=>this.handleClick(t)},key:this.key("hi"+e)})},makeRemoveIcon(t,e){const r=this.$createElement;return r("AIcon",{attrs:{type:"delete"},on:{click:()=>this.handleRemove(t)},key:this.key("ri"+e)})},makeFiles(){const t=this.$createElement;return this.makeGroup(this.fileList.map((e,r)=>this.makeItem(r,[t("AIcon",{attrs:{type:"file"},on:{click:()=>this.handleClick(e)}}),this.makeIcons(e,r)])))},makeImages(){const t=this.$createElement;return this.makeGroup(this.fileList.map((e,r)=>this.makeItem(r,[t("img",{attrs:{src:this.getSrc(e)}}),this.makeIcons(e,r)])))},makeBtn(){const t=this.$createElement;return t("div",{class:"fc-upload-btn",on:{click:()=>this.showModal()},key:this.key("btn")},[t("AIcon",{attrs:{type:this.icon,theme:"filled"}})])},handleClick(t){return this.onHandle(t)},handleRemove(t){this.disabled||this.onBeforeRemove(t)!==!1&&(this.fileList.splice(this.fileList.indexOf(t),1),this.onRemove(t))},getSrc(t){return this.srcKey?t[this.srcKey]:t},frameLoad(t){this.onLoad(t);try{this.helper===!0&&(t.form_create_helper={api:this.formCreateInject.api,close:e=>{this.valid(e),this.closeModal()},set:(e,r)=>{this.valid(e),this.disabled||this.$emit("input",r)},get:e=>(this.valid(e),this.value),onOk:e=>this.$on("$ok",e),onClose:e=>this.$on("$close",e)})}catch(e){console.log(e)}},makeFooter(){const t=this.$createElement,{okBtnText:e,closeBtnText:r,closeBtn:i,okBtn:s,footer:n}=this.$props,o=[];return n&&(i&&o.push(t("AButton",{on:{click:()=>this.onCancel()!==!1&&this.closeModal(!0)}},[r])),s&&o.push(t("AButton",{attrs:{type:"primary"},on:{click:()=>this.onOk()!==!1&&this.closeModal()}},[e]))),o}},render(){const t=arguments[0],e=this.type;let r;e==="input"?r=this.makeInput():e==="image"?r=this.makeImages():r=this.makeFiles();const{width:i="30%",height:s,src:n,title:o,modalTitle:a}=this.$props;return this.$nextTick(()=>{this.$refs.frame&&this.frameLoad(this.$refs.frame.contentWindow||{})}),t("div",{class:"_fc-frame"},[r,t("aModal",q([{},{props:{mask:this.previewMask,title:a,footer:null}},{model:{value:this.previewVisible,callback:u=>{this.previewVisible=u}}}]),[t("img",{style:"width: 100%",attrs:{src:this.previewImage}})]),t("aModal",q([{},{props:M(m({width:i,title:o},this.modal),{visible:this.frameVisible})},{on:{cancel:()=>this.closeModal(!0)}}]),[this.frameVisible||!this.reload?t("iframe",{ref:"frame",attrs:{src:n,frameborder:"0"},style:{height:s,border:"0 none",width:"100%"}}):null,t("div",{slot:"footer"},[this.makeFooter()])])])},mounted(){this.$on("fc.closeModal",this.closeModal)}},wt=Object.assign||function(t){for(let e,r=1;r<arguments.length;r++)for(let i in e=arguments[r],e)Object.prototype.hasOwnProperty.call(e,i)&&E(t,i,e[i]);return t};function p(){return wt.apply(this,arguments)}const Ft=[Ot,kt,{name:"fcGroup",props:{field:String,rule:[Array,Object],rules:Array,expand:Number,options:Object,formCreateInject:{type:Object,required:!0},button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},value:{type:Array,default:()=>[]},sortBtn:{type:Boolean,default:!0},defaultValue:Object,disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},onBeforeRemove:{type:Function,default:()=>{}},onBeforeAdd:{type:Function,default:()=>{}},parse:Function},data(){return{len:0,cacheRule:{},cacheValue:{},sort:[],type:void 0}},computed:{formRule(){return this.rules?this.rules:this.rule?Array.isArray(this.rule)?this.rule:[this.rule]:[]}},watch:{cacheRule:{handler(t){this.sort=Object.keys(t)},immediate:!0},formRule:{handler(t,e){Object.keys(this.cacheRule).forEach(r=>{const i=this.cacheRule[r];if(i.$f){const s=i.$f.formData();if(t===e)i.$f.deferSyncValue(()=>{Y(i.rule,t),i.$f.setValue(s)},!0);else{const n=i.$f.formData();i.$f.once("reloading",()=>{i.$f.setValue(n)}),i.rule=L(t)}}})},deep:!0},expand(t){let e=t-this.value.length;e>0&&this.expandRule(e)},value(t,e){t=t||[];let r=this.sort,i=r.length,s=i-t.length;if(s<0){for(let n=s;n<0;n++)this.addRule(t.length+n);this.sort=Object.keys(this.cacheRule);for(let n=0;n<i;n++)this.setValue(r[n],t[n])}else{if(s>0)for(let n=0;n<s;n++)this.removeRule(r[i-n-1]);this.sort=Object.keys(this.cacheRule),t.forEach((n,o)=>{this.setValue(r[o],t[o])})}}},methods:{_value(t){return t&&k(t,this.field)?t[this.field]:t},cache(t,e){this.cacheValue[t]=JSON.stringify(e)},input(t){this.$emit("input",t),this.$emit("change",t)},formData(t,e){const r=this.cacheRule,i=this.sort;if(i.filter(n=>r[n].$f).length!==i.length)return;const s=i.map(n=>{const o=t===n?e:m({},this.cacheRule[n].$f.form),a=this.field?o[this.field]||null:o;return this.cache(n,a),a});this.input(s)},setValue(t,e){const r=this.field,i=this.cacheRule[t].$f;r&&(e={[r]:this._value(e)}),this.cacheValue[t]!==JSON.stringify(r?e[r]:e)&&(this.cache(t,e),i&&i.coverValue(e||{}))},addRule(t,e){const r=this.formCreateInject.form.copyRules(this.formRule),i=this.options?m({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){i.formData||(i.formData={});const s=L(this.defaultValue);p(i.formData,this.field?{[this.field]:s}:s)}this.parse&&this.parse({rule:r,options:i,index:this.sort.length}),this.$set(this.cacheRule,++this.len,{rule:r,options:i}),e&&this.$nextTick(()=>this.$emit("add",r,Object.keys(this.cacheRule).length-1))},add$f(t,e,r){this.cacheRule[e].$f=r,this.$nextTick(()=>{this.$emit("itemMounted",r,Object.keys(this.cacheRule).indexOf(e))})},removeRule(t,e){const r=Object.keys(this.cacheRule).indexOf(t);this.$delete(this.cacheRule,t),this.$delete(this.cacheValue,t),e&&this.$nextTick(()=>this.$emit("remove",r))},add(t){this.disabled||this.onBeforeAdd(this.value)===!1||this.addRule(t,!0)},del(t,e){if(this.disabled||this.onBeforeRemove(this.value,t)===!1)return;this.removeRule(e,!0);const r=[...this.value];r.splice(t,1),this.input(r)},addIcon(t){const e=this.$createElement;return e("div",{class:"_fc-group-btn _fc-group-plus-minus",on:{click:this.add}})},delIcon(t,e){const r=this.$createElement;return r("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",on:{click:()=>this.del(t,e)}})},sortUpIcon(t){const e=this.$createElement;return e("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",on:{click:()=>this.changeSort(t,-1)}})},sortDownIcon(t){const e=this.$createElement;return e("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",on:{click:()=>this.changeSort(t,1)}})},changeSort(t,e){const r=this.sort[t];this.$set(this.sort,t,this.sort[t+e]),this.sort[t+e]=r,this.formData(0)},makeIcon(t,e,r){if(this.$scopedSlots.button)return this.$scopedSlots.button({total:t,index:e,vm:this,key:r,del:()=>this.del(e,r),add:this.add});const i=[];return(!this.max||t<this.max)&&t===e+1&&i.push(this.addIcon(r)),t>this.min&&i.push(this.delIcon(e,r)),this.sortBtn&&e&&i.push(this.sortUpIcon(e)),this.sortBtn&&e!==t-1&&i.push(this.sortDownIcon(e)),i},emitEvent(t,e,r,i){this.$emit(t,...e,this.cacheRule[i].$f,r)},expandRule(t){for(let e=0;e<t;e++)this.value.push(this.field?null:{})}},created(){this.type=this.formCreateInject.form.$form();const t=(this.expand||0)-this.value.length;t>0&&this.expandRule(t);for(let e=0;e<this.value.length;e++)this.addRule(e)},render(){const t=arguments[0],e=this.sort,r=this.button,i=this.type,s=this.disabled,n=e.length===0?this.$scopedSlots.default?this.$scopedSlots.default({vm:this,add:this.add}):t("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add",on:{click:this.add}}):e.map((o,a)=>{const{rule:u,options:l}=this.cacheRule[o],c=r&&!s?this.makeIcon(e.length,a,o):[];return t("div",{class:"_fc-group-container",key:o},[t(i,q([{key:o},{on:{"update:value":y=>this.formData(o,y),"emit-event":(y,...b)=>this.emitEvent(y,b,a,o),input:y=>this.add$f(a,o,y)}},{},{props:{disabled:s,inFor:!0,value:this.field?{[this.field]:this._value(this.value[a])}:this.value[a],rule:u,option:l,extendOption:!0}}])),t("div",{class:"_fc-group-idx"},[a+1]),c.length?t("div",{class:"_fc-group-handle"},[c]):null])});return t("div",{key:"con",class:"_fc-group "+(s?"_fc-group-disabled":"")},[n])}},{name:"fcSubForm",props:{rule:Array,options:Object,formCreateInject:{type:Object,required:!0},value:{type:Object,default:()=>({})},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0}},data(){return{cacheRule:{},cacheValue:{},type:void 0}},watch:{value(t){this.setValue(t)}},methods:{formData(t){this.cacheValue=JSON.stringify(t),this.$emit("input",t),this.$emit("change",t)},setValue(t){const e=JSON.stringify(t);this.cacheValue!==e&&(this.cacheValue=e,this.cacheRule.$f.coverValue(t||{}))},addRule(){const t=this.options?this.options:{submitBtn:!1,resetBtn:!1};t.formData=m({},this.value||{}),this.cacheRule={rule:this.rule,options:t}},add$f(t){this.cacheRule.$f=t,this.$nextTick(()=>{this.$emit("itemMounted",t)})},emitEvent(t,...e){this.$emit(t,...e)}},created(){this.addRule(),this.type=this.formCreateInject.form.$form()},render(){const t=arguments[0],{rule:e,options:r}=this.cacheRule,i=this.type;return t(i,q([{},{on:{"update:value":this.formData,"emit-event":this.emitEvent,input:this.add$f}},{},{props:{rule:e,option:r,disabled:this.disabled,extendOption:!0}}]))}}],oe={name:"checkbox",mergeProp(t){const e=t.prop.props;k(e,"options")||(e.options=t.prop.options||[])}},Et=M(m({},oe),{name:"radio"}),St=M(m({},oe),{name:"select"}),Re="FormCreate",ae=(t,e)=>{if(!(!t||t===e)){if(t.formCreateInject)return t.formCreateInject;if(t.$parent)return ae(t.$parent,e)}};function Rt(t,e,r){return{name:Re,componentName:Re,model:{prop:"api"},components:e,directives:r,provide(){return{$pfc:this}},inject:{$pfc:{default:null}},props:{rule:{type:Array,required:!0},option:{type:Object,default:()=>({})},extendOption:Boolean,disabled:{type:Boolean,default:void 0},value:Object,api:Object,name:String,subForm:{type:Boolean,default:!0},inFor:Boolean},data(){return{formData:void 0,destroyed:!1,validate:{},$f:void 0,isShow:!0,unique:1,renderRule:[...this.rule||[]],ctxInject:{},updateValue:JSON.stringify(this.value||{}),isMore:!!this.inFor}},render(){return this.formCreate.render()},methods:{_refresh(){++this.unique},_renderRule(){this.renderRule=[...this.rule||[]]},_updateValue(i){this.destroyed||(this.updateValue=JSON.stringify(i),this.$emit("update:value",i))}},watch:{value:{handler(i){JSON.stringify(i||{})!==this.updateValue&&(this.$f.config.forceCoverValue?this.$f.coverValue(i||{}):this.$f.setValue(i||{}))},deep:!0},option:{handler(){this.formCreate.initOptions(),this.$f.refresh()},deep:!0},rule(i,s){i.length===this.renderRule.length&&i.every(n=>this.renderRule.indexOf(n)>-1)||(this.formCreate.$handle.reloadRule(i),this._renderRule(),i!==s&&this.formCreate.$handle.targetReload())},disabled(){this.$f.refresh()}},beforeCreate(){this.formCreate=new t(this),Object.keys(this.formCreate.prop).forEach(i=>{p(this.$options[i],this.formCreate.prop[i])}),this.$emit("beforeCreate",this.formCreate.api())},created(){const i=this,s=this.formCreate.api(),n=()=>{if(i.$pfc){const a=ae(i,i.$pfc);if(a){let u;i.isMore?(u=D(a.getSubForm()),u.push(s)):u=s,a.subForm(u)}}},o=()=>{const a=ae(i,i.$pfc);if(a)if(i.isMore){const u=D(a.getSubForm()),l=u.indexOf(s);l>-1&&u.splice(l,1)}else a.subForm()};i.$on("hook:beforeDestroy",()=>{o()}),this.$watch(()=>this.subForm,a=>{a?n():o()},{immediate:!0})}}}const je=["attrs","props","domProps","scopedSlots"],Ae=["class","style","directives"],Pe=["on","nativeOn"],T=(t,e={},r={})=>{const i=[...je,...r.normal||[]],s=[...Ae,...r.array||[]],n=[...Pe,...r.functional||[]],o=r.props||[];return t.reduce((a,u)=>{for(const l in u)if(a[l])if(o.indexOf(l)>-1)a[l]=T([u[l]],a[l]);else if(i.indexOf(l)>-1)a[l]=m(m({},a[l]),u[l]);else if(s.indexOf(l)>-1){const c=a[l]instanceof Array?a[l]:[a[l]],y=u[l]instanceof Array?u[l]:[u[l]];a[l]=[...c,...y]}else if(n.indexOf(l)>-1)for(const c in u[l])if(a[l][c]){const y=a[l][c]instanceof Array?a[l][c]:[a[l][c]],b=u[l][c]instanceof Array?u[l][c]:[u[l][c]];a[l][c]=[...y,...b]}else a[l][c]=u[l][c];else if(l==="hook")for(let c in u[l])a[l][c]?a[l][c]=jt(a[l][c],u[l][c]):a[l][c]=u[l][c];else a[l]=u[l];else i.indexOf(l)>-1||n.indexOf(l)>-1||o.indexOf(l)>-1?a[l]=m({},u[l]):s.indexOf(l)>-1?a[l]=u[l]instanceof Array?[...u[l]]:typeof u[l]=="object"?m({},u[l]):u[l]:a[l]=u[l];return a},e)},jt=(t,e)=>function(){t&&t.apply(this,arguments),e&&e.apply(this,arguments)},Ie=["type","slot","emitPrefix","value","name","native","hidden","display","inject","options","emit","nativeEmit","link","prefix","suffix","update","sync","optionsTo","key","preview","component","cache"],le=["validate","children","control"],ue=["effect","deep"];function At(){return[...Ie,...je,...Ae,...Pe,...le,...ue]}function fe(t,e,r){return`[form-create ${t}]: ${e}`}function Pt(t,e){console.warn(fe("tip",t))}function he(t,e){console.error(fe("err",t))}function It(t){he(t.toString()),console.error(t)}const ce="[[FORM-CREATE-PREFIX-",de="-FORM-CREATE-SUFFIX]]";function Ve(t,e){return JSON.stringify(Y(Array.isArray(t)?[]:{},t,!0),function(r,i){if(!(i&&i._isVue===!0)){if(typeof i!="function")return i;if(i.__json)return i.__json;if(i.__origin&&(i=i.__origin),!i.__emit)return ce+i+de}},e)}function pe(t){return new Function("return "+t)()}function U(t,e){if(t&&h.String(t)&&t.length>4){let r=t.trim(),i=!1;try{if(r.indexOf(de)>0&&r.indexOf(ce)===0)r=r.replace(de,"").replace(ce,""),i=!0;else if(r.indexOf("$FN:")===0)r=r.substring(4),i=!0;else if(r.indexOf("$EXEC:")===0)r=r.substring(6),i=!0;else if(r.indexOf("$GLOBAL:")===0){const n=r.substring(8);return r=function(...o){const a=o[0].api.getGlobalEvent(n);if(a)return a.call(this,...o)},r.__json=t,r.__inject=!0,r}else{if(r.indexOf("$FNX:")===0)return r=pe("function($inject){"+r.substring(5)+"}"),r.__json=t,r.__inject=!0,r;(!e&&r.indexOf("function ")===0&&r!=="function "||!e&&r.indexOf("function(")===0&&r!=="function(")&&(i=!0)}if(!i)return t;let s;try{s=pe(r)}catch(n){s=pe("function "+r)}return s.__json=t,s}catch(s){he(`解析失败:${r} err: ${s}`);return}}return t}function Vt(t,e){return JSON.parse(t,function(r,i){return h.Undef(i)||!i.indexOf?i:U(i,e)})}function me(t,e){return{value:t,enumerable:!1,configurable:!1,writable:!!e}}function ye(t){return De([t])[0]}function De(t,e){return Y([],[...t],e||!1)}function H(t,e){return T(Array.isArray(e)?e:[e],t,{array:le,normal:ue}),t}function Te(t){const e=h.Function(t.getRule)?t.getRule():t;return e.type||(e.type="input"),e}function Dt(t,e){return t?(Object.keys(e||{}).forEach(r=>{e[r]&&(t[r]=H(t[r]||{},e[r]))}),t):e}function Be(t,e){Object.defineProperties(t,Object.keys(e).reduce((r,i)=>(r[i]={get(){return e[i]()}},r),{}))}function W(t){return t.__fc__||(t.__origin__?t.__origin__.__fc__:null)}function j(t,e){try{e=t()}catch(r){It(r)}return e}const Me=(t,e)=>typeof t=="string"?String(e):typeof t=="number"?Number(e):e,G={"==":(t,e)=>JSON.stringify(t)===JSON.stringify(Me(t,e)),"!=":(t,e)=>!G["=="](t,e),">":(t,e)=>t>e,">=":(t,e)=>t>=e,"<":(t,e)=>t<e,"<=":(t,e)=>t<=e,on(t,e){return t&&t.indexOf&&t.indexOf(Me(t[0],e))>-1},notOn(t,e){return!G.on(t,e)},in(t,e){return e&&e.indexOf&&e.indexOf(t)>-1},notIn(t,e){return!G.in(t,e)},between(t,e){return t>e[0]&&t<e[1]},notBetween(t,e){return t<e[0]||t>e[1]},empty(t){return h.empty(t)},notEmpty(t){return!h.empty(t)},pattern(t,e){return new RegExp(e,"g").test(t)}};function Ne(){return{props:{},on:{},options:[],children:[],effect:{},hidden:!1,display:!0,value:void 0}}function S(t,e){return(r,i,s,n={})=>{const o=new ge(t,r,i,s,n);return e&&(h.Function(e)?e(o):o.props(e)),o}}function ge(t,e,r,i,s){this._data=p(Ne(),{type:t,title:e,field:r,value:i,props:s||{}}),this.event=this.on}p(ge.prototype,{getRule(){return this._data},setProp(t,e){return E(this._data,t,e),this},_clone(){const t=new this.constructor;return t._data=ye(this._data),t}});function Le(t){t.forEach(e=>{ge.prototype[e]=function(r){return H(this._data,{[e]:arguments.length<2?r:{[r]:arguments[1]}}),this}})}Le(At());const qe=S("");function Tt(t,e,r){let i=qe("",e);return i._data.type=t,i._data.title=r,i}function Ue(t,e,r,i){let s=qe("",r);return s._data.type="template",s._data.template=t,s._data.title=i,s._data.vm=e,s}function Bt(){return{create:Tt,createTmp:Ue,template:Ue,factory:S}}function Mt(t,e,r){const i=`fail to ${t} ${r.status}'`,s=new Error(i);return s.status=r.status,s.url=t,s}function He(t){const e=t.responseText||t.response;if(!e)return e;try{return JSON.parse(e)}catch(r){return e}}function Je(t){if(typeof XMLHttpRequest=="undefined")return;const e=new XMLHttpRequest,r=t.action;e.onerror=function(o){t.onError(o)},e.onload=function(){if(e.status<200||e.status>=300)return t.onError(Mt(r,t,e),He(e));t.onSuccess(He(e))},e.open(t.method||"get",r,!0);let i;t.data&&((t.dataType||"").toLowerCase()!=="json"?(i=new FormData,Object.keys(t.data).map(n=>{i.append(n,t.data[n])})):(i=JSON.stringify(t.data),e.setRequestHeader("content-type","application/json"))),t.withCredentials&&"withCredentials"in e&&(e.withCredentials=!0);const s=t.headers||{};Object.keys(s).forEach(n=>{s[n]!==null&&e.setRequestHeader(n,s[n])}),e.send(i)}function Nt(t){return new Promise((e,r)=>{Je(M(m({},t),{onSuccess(i){let s=o=>o;const n=U(t.parse);h.Function(n)?s=n:n&&h.String(n)&&(s=o=>(n.split(".").forEach(a=>{o&&(o=o[a])}),o)),e(s(i))},onError(i){r(i)}}))})}function X(t){return L(t)}function Lt(t){function e(n){return h.Undef(n)?n=t.fields():Array.isArray(n)||(n=[n]),n}function r(n,o,a){e(n).forEach(u=>{t.getCtxs(u).forEach(l=>{E(l.rule,o,a),t.$render.clearCache(l)})})}function i(){const n=t.subForm;return Object.keys(n).reduce((o,a)=>{const u=n[a];return u&&(Array.isArray(u)?o.push(...u):o.push(u)),o},[])}const s={get config(){return t.options},get options(){return t.options},get form(){return t.form},get rule(){return t.rules},get parent(){return t.vm.$pfc&&t.vm.$pfc.$f},get top(){return s.parent?s.parent.top:s},get children(){return i()},formData(n){return e(n).reduce((o,a)=>{const u=t.getFieldCtx(a);return u&&(o[u.field]=X(u.rule.value)),o},t.options.appendValue!==!1?X(t.appendData):{})},getValue(n){const o=t.getFieldCtx(n);if(o)return X(o.rule.value)},coverValue(n){const o=m({},n||{});t.deferSyncValue(()=>{s.fields().forEach(a=>{const u=t.fieldCtx[a];if(u){const l=k(o,a);u.forEach(c=>{c.rule.value=l?o[a]:void 0}),delete o[a]}}),p(t.appendData,o)})},setValue(n){let o=n;arguments.length>=2&&(o={[n]:arguments[1]}),t.deferSyncValue(()=>{Object.keys(o).forEach(a=>{const u=t.fieldCtx[a];if(!u)return t.appendData[a]=o[a];u.forEach(l=>{l.rule.value=o[a]})})})},removeField(n){const o=t.getCtx(n);return t.deferSyncValue(()=>{t.getCtxs(n).forEach(a=>{a.rm()})},!0),o?o.origin:void 0},removeRule(n){const o=n&&W(n);if(o)return o.rm(),o.origin},destroy:()=>{t.vm.$el.parentNode&&t.vm.$el.parentNode.removeChild(t.vm.$el),t.vm.$destroy()},fields:()=>t.fields(),append:(n,o,a)=>{let u=t.sort.length-1,l;const c=t.getCtx(o);c?a?(l=c.rule.children,u=c.rule.children.length-1):(u=c.root.indexOf(c.origin),l=c.root):l=t.rules,l.splice(u+1,0,n)},prepend:(n,o,a)=>{let u=0,l;const c=t.getCtx(o);c?a?l=c.rule.children:(u=c.root.indexOf(c.origin),l=c.root):l=t.rules,l.splice(u,0,n)},hidden(n,o){r(o,"hidden",!!n),t.refresh()},hiddenStatus(n){const o=t.getCtx(n);if(o)return!!o.rule.hidden},display(n,o){r(o,"display",!!n),t.refresh()},displayStatus(n){const o=t.getCtx(n);if(o)return!!o.rule.display},disabled(n,o){e(o).forEach(a=>{t.getCtxs(a).forEach(u=>{u.rule.props&&E(u.rule.props,"disabled",!!n)})}),t.refresh()},all(n){return Object.keys(t.ctxs).map(o=>{const a=t.ctxs[o];return n?a.origin:a.rule})},model(n){return t.fields().reduce((o,a)=>{const u=t.fieldCtx[a][0];return o[a]=n?u.origin:u.rule,o},{})},component(n){return Object.keys(t.nameCtx).reduce((o,a)=>{const u=t.nameCtx[a].map(l=>n?l.origin:l.rule);return o[a]=u.length===1?u[0]:u,o},{})},bind(){return s.form},reload:n=>{t.reloadRule(n)},updateOptions(n){t.fc.updateOptions(n),s.refresh()},onSubmit(n){s.updateOptions({onSubmit:n})},sync:n=>{if(Array.isArray(n)){n.forEach(a=>s.sync(a));return}let o=h.Object(n)?W(n):t.getCtxs(n);o&&(o=Array.isArray(o)?o:[o],o.forEach(a=>{if(!a.deleted){const u=t.subForm[a.id];u&&(Array.isArray(u)?u.forEach(l=>{l.refresh()}):u&&u.refresh()),t.$render.clearCache(a)}}),t.refresh())},refresh:()=>{i().forEach(n=>{n.refresh()}),t.$render.clearCacheAll(),t.refresh()},refreshOptions(){t.$manager.updateOptions(t.options),s.refresh()},hideForm:n=>{E(t.vm,"isShow",!n)},changeStatus:()=>t.changeStatus,clearChangeStatus:()=>{t.changeStatus=!1},updateRule(n,o){t.getCtxs(n).forEach(a=>{p(a.rule,o)})},updateRules(n){Object.keys(n).forEach(o=>{s.updateRule(o,n[o])})},mergeRule:(n,o)=>{t.getCtxs(n).forEach(a=>{H(a.rule,o)})},mergeRules(n){Object.keys(n).forEach(o=>{s.mergeRule(o,n[o])})},getRule:(n,o)=>{const a=t.getCtx(n);if(a)return o?a.origin:a.rule},getRenderRule:n=>{const o=t.getCtx(n);if(o)return o.prop},getRefRule:n=>{const o=t.getCtxs(n);if(o&&o.length){const a=o.map(u=>u.rule);return a.length===1?a[0]:a}},setEffect(n,o,a){const u=t.getCtx(n);u&&o&&(o[0]==="$"&&(o=o.substr(1)),k(u.rule,"$"+o)&&E(u.rule,"$"+o,a),k(u.rule,"effect")||E(u.rule,"effect",{}),E(u.rule.effect,o,a))},clearEffectData(n,o){const a=t.getCtx(n);a&&(o&&o[0]==="$"&&(o=o.substr(1)),a.clearEffectData(o),s.sync(n))},updateValidate(n,o,a){a?s.mergeRule(n,{validate:o}):r(n,"validate",o)},updateValidates(n,o){Object.keys(n).forEach(a=>{s.updateValidate(a,n[a],o)})},refreshValidate(){t.vm.validate={},s.refresh()},resetFields(n){e(n).forEach(o=>{t.getCtxs(o).forEach(a=>{t.$render.clearCache(a),a.rule.value=X(a.defaultValue)})}),t.vm.$nextTick(()=>{s.clearValidateState()}),n==null&&(h.Function(t.options.onReset)&&j(()=>t.options.onReset(s)),t.vm.$emit("reset",s))},method(n,o){const a=s.el(n);if(!a||!a[o])throw new Error(fe("err",`${o}方法不存在`));return(...u)=>a[o](...u)},exec(n,o,...a){return j(()=>s.method(n,o)(...a))},toJson(n){return Ve(s.rule,n)},trigger(n,o,...a){const u=s.el(n);u&&u.$emit(o,...a)},el(n){const o=t.getCtx(n);if(o)return o.exportEl||o.el||t.vm.$refs[o.ref]},closeModal:n=>{const o=s.el(n);o&&o.$emit&&o.$emit("close-modal")},getSubForm(n){const o=t.getCtx(n);return o?t.subForm[o.id]:void 0},nextTick(n){t.bus.$once("next-tick",n),t.refresh()},nextRefresh(n){t.nextRefresh(),n&&j(n)},emit(n,...o){t.vm.$emit(n,...o)},deferSyncValue(n,o){t.deferSyncValue(n,o)},fetch(n){return new Promise((o,a)=>{t.beforeFetch(n).then(()=>Nt(n).then(o).catch(a))})},getData(n,o){return t.fc.getData(n,o)},setData(n,o){return t.fc.setData(n,o)},helper:{tidyFields:e,props:r}};return["on","once","off","set","emit"].forEach(n=>{s[n]=function(...o){t.vm[`$${n}`](...o)}}),s.changeValue=s.changeField=s.setValue,s}function qt(t){p(t.prototype,{initCache(){this.clearCacheAll()},clearCache(e){if(e.rule.cache)return;if(!this.cache[e.id]){e.parent&&this.clearCache(e.parent);return}(this.cache[e.id].use===!0||this.cache[e.id].parent)&&this.$handle.refresh();const r=this.cache[e.id].parent;this.cache[e.id]=null,r&&this.clearCache(r)},clearCacheAll(){this.cache={}},setCache(e,r,i){this.cache[e.id]={vnode:r,use:!1,parent:i,slot:e.rule.slot}},getCache(e){const r=this.cache[e.id];if(r)return r.use=!0,r.vnode}})}function P(t){const e=t.replace(/(-[a-z])/g,function(r){return r.replace("-","").toLocaleUpperCase()});return xe(e)}function xe(t){return t.replace(t[0],t[0].toLowerCase())}function z(t){let e=t.replace(/([A-Z])/g,"-$1").toLocaleLowerCase();return e.indexOf("-")===0&&(e=e.substr(1)),e}let Ut=0;function Q(){const t=370+ ++Ut;return"F"+Math.random().toString(36).substr(3,3)+(+`${Date.now()}`).toString(36)+t.toString(36)+"c"}function Z(t,e,r){let i=t,s;return(e||"").split(".").forEach(n=>{s&&((!i[s]||typeof i[s]!="object")&&(i[s]={}),i=i[s]),s=n}),i[s]=r,i}function Ht(t){p(t.prototype,{initRender(){this.tempList={},this.clearOrgChildren()},initOrgChildren(){const e=this.$handle.ctxs;this.orgChildren=Object.keys(e).reduce((r,i)=>{if(e[i].parser.loadChildren!==!1){const s=e[i].rule.children;r[i]=h.trueArray(s)?[...s]:[]}return r},{})},clearOrgChildren(){this.orgChildren={}},getTypeSlot(e){const r=i=>{if(i){let s;return e.rule.field&&(s=i.$scopedSlots["field-"+z(e.rule.field)]||i.$scopedSlots["field-"+e.rule.field]),s||(s=i.$scopedSlots["type-"+z(e.type)]||i.$scopedSlots["type-"+e.type]),s||r(i.$pfc)}};return r(this.vm)},render(){if(!this.vm.isShow)return;this.$h=this.vm.$createElement,this.$manager.beforeRender();let e;const r=()=>this.renderList();return r.renderSlot=i=>this.renderList(i),r.renderName=i=>this.renderId(i),r.renderField=i=>this.renderId(i,"field"),this.vm.$scopedSlots.container?e=[this.vm.$scopedSlots.container(r)]:e=r(),this.$manager.render(e)},renderList(e){return this.sort.map(r=>e?this.renderSlot(this.$handle.ctxs[r],e):this.renderCtx(this.$handle.ctxs[r])).filter(r=>r!==void 0)},makeVm(e){const r=e.vm;if(r){if(h.Function(r))return j(()=>e.vm(this.$handle.getInjectData(e)));if(!r._isVue)return new v(r)}else return new v;return r},mergeGlobal(e){const r=this.$handle.options.global;r&&(e.cacheConfig||(e.cacheConfig=r[e.originType]||r[e.type]||r[e.trueType]||{}),e.prop=H({},[r["*"],e.cacheConfig,e.prop]))},setOptions(e){e.prop.optionsTo&&e.prop.options&&Z(e.prop,e.prop.optionsTo,e.prop.options)},deepSet(e){const r=e.rule.deep;r&&Object.keys(r).sort((i,s)=>i.length<s.length?-1:1).forEach(i=>{Z(e.prop,i,r[i])})},setTempProps(e,r){if(!e.$props)return;const{prop:i}=r,s=Object.keys(e.$props),n=this.injectProp(r),o=Object.keys(n);s.forEach(u=>{k(i.props,u)?e.$props[u]=i.props[u]:o.indexOf(u)>-1&&(e.$props[u]=n[u])});const a=e.$options.model&&e.$options.model.prop||"value";s.indexOf(a)>-1&&(e.$props[a]=i.value)},renderTemp(e){if(!v.compile)return Pt("当前使用的Vue构建版本不支持compile,无法使用template功能"),[];const r=e.prop,{id:i,key:s}=e;if(!this.tempList[i]){e.el||(e.el=this.makeVm(r),this.vm.$nextTick(()=>e.parser.mounted(e)));let u=e.el;e.input&&u.$on(u.$options.model&&u.$options.model.event||"input",l=>{this.onInput(e,l)}),this.tempList[i]={vm:u,template:v.compile(r.template)}}const{vm:n,template:o}=this.tempList[i];this.setTempProps(n,e);const a=o.render.call(n);return h.Undef(a.data)&&(a.data={}),a.key=s,a.data.ref=e.ref,a.data.key=s,a},parseSide(e,r){return h.Object(e)?H({props:{formCreateInject:r.prop.props.formCreateInject}},e):e},renderSides(e,r,i){const s=r[i?"rule":"prop"];return[this.renderRule(this.parseSide(s.prefix,r)),e,this.renderRule(this.parseSide(s.suffix,r))]},renderSlot(e,r){return e.rule.slot===r?this.renderCtx(e):void 0},renderId(e,r){const i=this.$handle[r==="field"?"fieldCtx":"nameCtx"][e];return i?i.map(s=>this.renderCtx(s,s.parent)):void 0},renderCtx(e,r){if(e.type==="hidden")return;const i=e.rule;if(!this.cache[e.id]||this.cache[e.id].slot!==i.slot){let s,n=i.cache!==!1;const o=e.trueType,a=!(h.Undef(i.display)||i.display);if(o==="template"&&!i.template)s=this.renderSides(this.renderChildren(e),e,!0),a&&this.display(s),s=this.item(e,s);else if(o==="fcFragment")s=this.renderChildren(e);else{e.initProp(),this.mergeGlobal(e),this.$manager.tidyRule(e),this.deepSet(e),this.setOptions(e),this.ctxProp(e);let u=e.prop;u.preview=!!(k(u,"preview")?u.preview:this.options.preview),u.props.formCreateInject=this.injectProp(e);const l=u.preview;if(u.hidden){this.setCache(e,void 0,r);return}if(o==="template"&&u.template)s=this.renderTemp(e),n=!1;else{let c=[];e.parser.renderChildren?c=e.parser.renderChildren(e):e.parser.loadChildren!==!1&&(c=this.renderChildren(e));const y=this.getTypeSlot(e);y?s=y({rule:i,prop:u,preview:l,children:c,api:this.$handle.api,model:u.model||{}}):s=l?e.parser.preview(c,e):e.parser.render(c,e)}s=this.renderSides(s,e),!(!e.input&&h.Undef(u.native))&&u.native!==!0&&(s=this.$manager.makeWrap(e,s)),a&&(s=this.display(s)),s=this.item(e,s)}return n&&this.setCache(e,s,r),s}return this.getCache(e)},display(e){if(Array.isArray(e)){const r=[];return e.forEach(i=>{if(Array.isArray(i))return this.display(i);this.none(i)&&r.push(i)}),r}else return this.none(e)},none(e){if(e&&e.data)return Array.isArray(e.data.style)?e.data.style.push({display:"none"}):h.String(e.data.style)?e.data.style+=";display:none;":e.data.style=[e.data.style,{display:"none"}],e},item(e,r){return this.$h("fcFragment",{slot:e.rule.slot,key:e.key},[r])},injectProp(e){this.vm.ctxInject[e.id]||E(this.vm.ctxInject,e.id,{api:this.$handle.api,form:this.fc.create,subForm:i=>{this.$handle.addSubForm(e,i)},getSubForm:()=>this.$handle.subForm[e.id],options:[],children:[],prop:{},preview:!1,id:e.id,field:e.field,rule:e.rule,input:e.input});const r=this.vm.ctxInject[e.id];return p(r,{preview:e.prop.preview,options:e.prop.options,children:e.rule.children,prop:function(){const i=m({},e.prop);return i.on=i.on?m({},i.on):{},delete i.model,i}()}),r},ctxProp(e){const{ref:r,key:i,rule:s}=e;this.$manager.mergeProp(e),e.parser.mergeProp(e);const n=[{ref:r,key:s.key||`${i}fc`,slot:void 0,on:{"hook:mounted":()=>{this.onMounted(e)},"fc.sub-form":o=>{this.$handle.addSubForm(e,o)},"fc.el":o=>{e.exportEl=o,o&&((o.$el||o).__rule__=e.rule)}}}];return e.input&&(this.vm.$props.disabled===!0&&(e.prop.props.disabled=!0),e.prop.model={value:this.$handle.getFormData(e),callback:o=>{this.onInput(e,o)},expression:`formData.${e.id}`}),T(n,e.prop),e.prop},onMounted(e){e.el=this.vm.$refs[e.ref],e.el&&((e.el.$el||e.el).__rule__=e.rule),e.parser.mounted(e),this.$handle.effect(e,"mounted")},onInput(e,r){this.$handle.onInput(e,r)},renderChildren(e){const{children:r}=e.rule,i=this.orgChildren[e.id],s=n=>!h.String(n)&&n.__fc__&&!this.$handle.ctxs[n.__fc__.id];return!h.trueArray(r)&&i?(this.$handle.deferSyncValue(()=>{i.forEach(n=>{n&&s(n)&&this.$handle.rmCtx(n.__fc__)})}),this.orgChildren[e.id]=[],[]):(i&&this.$handle.deferSyncValue(()=>{i.forEach(n=>{n&&r.indexOf(n)===-1&&s(n)&&this.$handle.rmCtx(n.__fc__)})}),r.map(n=>{if(n){if(h.String(n))return n;if(n.__fc__)return this.renderCtx(n.__fc__,e);n.type&&this.vm.$nextTick(()=>{this.$handle.loadChildren(r,e),this.$handle.refresh()})}}))},defaultRender(e,r){const i=e.prop;return i.component?this.vNode.makeComponent(i.component,i,r):this.vNode[e.type]?this.vNode[e.type](i,r):this.vNode[e.originType]?this.vNode[e.originType](i,r):this.vNode.make(xe(e.originType),i,r)},renderRule(e,r,i){if(!e)return;if(h.String(e))return e;let s;if(i)s=e.type;else if(s=e.is,e.type){s=P(e.type);const o=this.vNode.aliasMap[s];o&&(s=P(o))}if(!s)return;let n=[[r]];return h.trueArray(e.children)&&n.push(e.children.map(o=>this.renderRule(o))),this.$h(s,m({},e),n)}})}function $e(t){p(this,{$handle:t,fc:t.fc,vm:t.vm,$manager:t.$manager,vNode:new t.fc.CreateNode(t.vm)}),Be(this,{options(){return t.options},sort(){return t.sort}}),this.initCache(),this.initRender()}qt($e),Ht($e);function Jt(t){p(t.prototype,{parseInjectEvent(e,r){const i=e.inject||this.options.injectEvent;return this.parseEventLst(e,r,i)},parseEventLst(e,r,i,s){return Object.keys(r).forEach(n=>{const o=this.parseEvent(e,r[n],i,s);o&&(r[n]=o)}),r},parseEvent(e,r,i,s){if(h.Function(r)&&(i!==!1&&!h.Undef(i)||r.__inject))return this.inject(e,r,i);if(!s&&Array.isArray(r)&&r[0]&&(h.String(r[0])||h.Function(r[0])))return this.parseEventLst(e,r,i,!0);if(h.String(r)){const n=U(r);if(n&&r!==n)return n.__inject?this.parseEvent(e,n,i,!0):n}},parseEmit(e,r){let i={},s=e.rule,{emitPrefix:n,field:o,name:a,inject:u}=s,l=s[r?"emit":"nativeEmit"]||[];return h.trueArray(l)&&l.forEach(c=>{if(!c)return;let y,b=n||o||a;if(h.Object(c)&&(y=c.inject,c=c.name,b=c.prefix||b),b){r||(b=`native-${b}`);const w=z(`${b}-${c}`),g=(...F)=>{this.vm.$emit(w,...F),this.vm.$emit("emit-event",w,...F)};if(g.__emit=!0,!y&&u===!1)i[c]=g;else{let F=y||u||this.options.injectEvent;i[c]=h.Undef(F)?g:this.inject(s,g,F)}}}),e.computed[r?"on":"nativeOn"]=i,i},getInjectData(e,r){const{option:i,rule:s}=this.vm.$options.propsData;return{api:this.api,$f:this.api,rule:s,self:e.__origin__,option:i,inject:r}},inject(e,r,i){if(r.__origin){if(this.watching&&!this.loading)return r;r=r.__origin}const s=this,n=function(...o){const a=s.getInjectData(e,i);return a.args=[...o],o.unshift(a),r.apply(this,o)};return n.__origin=r,n.__json=r.__json,n}})}const Ye=["hook:updated","hook:mounted"];function xt(t){p(t.prototype,{usePage(){const e=this.options.page;if(!e)return;let r=25,i=Yt(this.rules);h.Object(e)&&(e.first&&(r=parseInt(e.first,10)||r),e.limit&&(i=parseInt(e.limit,10)||i)),p(this,{first:r,limit:i,pageEnd:this.rules.length<=r}),this.bus.$on("page-end",()=>this.vm.$emit("page-end",this.api)),this.pageLoad()},pageLoad(){const e=()=>{this.pageEnd?(this.vm.$off(Ye,e),this.bus.$emit("page-end")):(this.first+=this.limit,this.pageEnd=this.rules.length<=this.first,this.loadRule(),this.refresh())};this.vm.$on(Ye,e)}})}function Yt(t){return t.length<31?31:Math.ceil(t.length/3)}function Gt(t){p(t.prototype,{clearNextTick(){this.nextTick&&clearTimeout(this.nextTick),this.nextTick=null},bindNextTick(e){this.clearNextTick(),this.nextTick=setTimeout(()=>{e(),this.nextTick=null},10)},render(){return++this.loadedId,this.vm.unique>0?this.$render.render():(this.vm.unique=1,[])}})}function Kt(t){Object.defineProperties(t.origin,{__fc__:me(t,!0)}),t.rule!==t.origin&&Object.defineProperties(t.rule,{__fc__:me(t,!0)})}function Ge(t,e,r){const i=Q();p(this,{id:i,ref:i,wrapRef:i+"fi",rule:e,origin:e.__origin__||e,name:e.name,watch:[],linkOn:[],root:[],ctrlRule:[],parent:null,cacheConfig:null,prop:m({},e),computed:{},payload:{},input:!!e.field,el:void 0,exportEl:void 0,defaultValue:e.field?L(r):void 0,field:e.field||void 0}),this.updateKey(),Kt(this),this.update(t,!0)}p(Ge.prototype,{effectData(t){return this.payload[t]||(this.payload[t]={}),this.payload[t]},clearEffectData(t){t===void 0?this.payload={}:delete this.payload[t]},updateKey(t){this.key=Q(),t&&this.parent&&this.parent.updateKey(t)},updateType(){this.originType=this.rule.type,this.type=P(this.rule.type),this.trueType=this.$handle.getType(this.originType)},setParser(t){this.parser=t,t.init(this)},initProp(){const t=m({},this.rule);delete t.children,this.prop=H({},[t,...Object.keys(this.payload).map(e=>this.payload[e]),this.computed])},injectValidate(){return D(this.prop.validate).map(t=>{if(h.Function(t.validator)){const e=m({},t),r=this;return e.validator=function(...i){return t.validator.call({that:this,id:r.id,field:r.field,rule:r.rule,api:r.$handle.api},...i)},e}return t})},check(t){return this.vm===t.vm},unwatch(){this.watch.forEach(t=>t()),this.watch=[]},unlink(){this.linkOn.forEach(t=>t()),this.linkOn=[]},link(){this.unlink(),this.$handle.appendLink(this)},watchTo(){this.$handle.watchCtx(this)},delete(){this.unwatch(),this.unlink(),this.rmCtrl(),p(this,{deleted:!0,prop:m({},this.rule),computed:{},el:void 0,$handle:void 0,$render:void 0,$api:void 0,vm:void 0,vNode:void 0,parent:null,cacheConfig:null})},rmCtrl(){this.ctrlRule.forEach(t=>t.__fc__&&t.__fc__.rm()),this.ctrlRule=[]},rm(){const t=()=>{let e=this.root.indexOf(this.origin);e>-1&&(this.root.splice(e,1),this.$handle&&this.$handle.refresh())};if(this.deleted){t();return}this.$handle.noWatch(()=>{this.$handle.deferSyncValue(()=>{this.rmCtrl(),t(),this.$handle.rmCtx(this),p(this,{root:[]})},this.input)})},update(t,e){p(this,{deleted:!1,$handle:t,$render:t.$render,$api:t.api,vm:t.vm,vNode:t.$render.vNode,updated:!1,cacheValue:this.rule.value}),!e&&this.unwatch(),this.watchTo(),this.link(),this.updateType()}});function Wt(t){p(t.prototype,{nextRefresh(e){const r=this.loadedId;this.vm.$nextTick(()=>{r===this.loadedId&&(e?e():this.refresh())})},parseRule(e){const r=Te(e);return Object.defineProperties(r,{__origin__:me(e,!0)}),Xt(r),this.appendValue(r),r.options=Array.isArray(r.options)?r.options:[],[r,r.prefix,r.suffix].forEach(i=>{i&&this.loadFn(i,r)}),this.loadCtrl(r),r.update&&(r.update=U(r.update)),r},loadFn(e,r){["on","props","nativeOn","deep"].forEach(i=>{e[i]&&this.parseInjectEvent(r,e[i])})},loadCtrl(e){e.control&&e.control.forEach(r=>{r.handle&&(r.handle=U(r.handle))})},syncProp(e){const r=e.rule;h.trueArray(r.sync)&&T([{on:r.sync.reduce((i,s)=>(i[`update:${s}`]=n=>{r.props[s]=n,this.vm.$emit("sync",s,n,r,this.fapi)},i),{})}],e.computed)},loadRule(){this.cycleLoad=!1,this.loading=!0,this.pageEnd&&this.bus.$emit("load-start"),this.deferSyncValue(()=>{if(this._loadRule(this.rules),this.loading=!1,this.cycleLoad&&this.pageEnd)return this.loadRule();this.pageEnd&&this.bus.$emit("load-end"),this.vm._renderRule(),this.$render.initOrgChildren(),this.syncForm()})},loadChildren(e,r){if(this.cycleLoad=!1,this.loading=!0,this.bus.$emit("load-start"),this._loadRule(e,r),this.loading=!1,this.cycleLoad)return this.loadRule();this.bus.$emit("load-end"),this.syncForm(),this.$render.clearCache(r)},_loadRule(e,r){const i=n=>{let o=e[n-1];if(!o||!o.__fc__)return n>0?i(n-1):-1;let a=this.sort.indexOf(o.__fc__.id);return a>-1?a:i(n-1)},s=(n,o)=>{h.trueArray(n)&&this._loadRule(n,o)};e.map((n,o)=>{if(r&&!h.Object(n)||!this.pageEnd&&!r&&o>=this.first)return;if(n.__fc__&&n.__fc__.root===e&&this.ctxs[n.__fc__.id])return s(n.__fc__.rule.children,n.__fc__),n.__fc__;let a=Te(n);const u=()=>!!(a.field&&this.fieldCtx[a.field]&&this.fieldCtx[a.field][0]!==n.__fc__);this.ruleEffect(a,"init",{repeat:u()}),u()&&this.vm.$emit("repeat-field",n,this.api);let l,c=!1,y=!!n.__fc__,b=a.value;if(y){l=n.__fc__,b=l.defaultValue;const g=!l.check(this);if(l.deleted){if(g){if(Ke(l))return;l.update(this)}}else if(g){if(Ke(l))return;e[o]=n=n._clone?n._clone():ye(n),l=null,c=!0}}if(l)l.originType!==l.rule.type&&l.updateType(),this.bindParser(l),this.appendValue(l.rule);else{const g=this.parseRule(n);l=new Ge(this,g,b),this.bindParser(l)}if([!1,!0].forEach(g=>this.parseEmit(l,g)),this.syncProp(l),l.parent=r||null,l.root=e,this.setCtx(l),!c&&!y&&this.effect(l,"load"),this.effect(l,"created"),l.parser.loadChildren===!1||s(l.rule.children,l),!r){const g=i(o);g>-1||!o?this.sort.splice(g+1,0,l.id):this.sort.push(l.id)}const w=l.rule;return l.updated||(l.updated=!0,h.Function(w.update)&&this.bus.$once("load-end",()=>{this.refreshUpdate(l,w.value,"init")}),this.effect(l,"loaded")),l.input&&Object.defineProperty(w,"value",this.valueHandle(l)),this.refreshControl(l)&&(this.cycleLoad=!0),l})},refreshControl(e){return e.input&&e.rule.control&&this.useCtrl(e)},useCtrl(e){const r=zt(e),i=[],s=this.api;if(!r.length)return!1;for(let a=0;a<r.length;a++){const u=r[a],l=u.handle||function(y){return(G[u.condition||"=="]||G["=="])(y,u.value)};if(!h.trueArray(u.rule))continue;const c=M(m({},u),{valid:j(()=>l(e.rule.value,s)),ctrl:Qt(e,u.rule),isHidden:h.String(u.rule[0])});c.valid&&c.ctrl||!c.valid&&!c.ctrl&&!c.isHidden||i.push(c)}if(!i.length)return!1;const n=[];let o=!1;return this.deferSyncValue(()=>{i.reverse().forEach(({isHidden:a,valid:u,rule:l,prepend:c,append:y,child:b,ctrl:w,method:g})=>{if(a){u?e.ctrlRule.push({__ctrl:!0,children:l,valid:u}):w&&e.ctrlRule.splice(e.ctrlRule.indexOf(w)>>>0,1),n[u?"push":"unshift"](()=>{g==="disabled"||g==="enabled"?this.api.disabled(!u,l):g==="display"?this.api.display(u,l):g==="required"?(l.forEach(F=>{this.api.setEffect(F,"required",u)}),u||this.api.clearValidateState(l)):this.api.hidden(!u,l)});return}if(u){o=!0;const F={type:"fcFragmen