@wibetter/json-schema-editor 7.0.2 → 7.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,2 +1,3052 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.JSONSchemaEditor=t():e.JSONSchemaEditor=t()}(this,function(){return function(){var e={23:function(e,t,n){var a=n(382);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(611).A)("adbe60da",a,!1,{sourceMap:!1})},40:function(e,t,n){var a=n(961);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(611).A)("405d88dc",a,!1,{sourceMap:!1})},80:function(){},286:function(){},382:function(){},611:function(e,t,n){"use strict";function a(e,t){for(var n=[],a={},o=0;o<t.length;o++){var r=t[o],i=r[0],s={id:e+":"+o,css:r[1],media:r[2],sourceMap:r[3]};a[i]?a[i].parts.push(s):n.push(a[i]={id:i,parts:[s]})}return n}n.d(t,{A:function(){return m}});var o="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!o)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var r={},i=o&&(document.head||document.getElementsByTagName("head")[0]),s=null,l=0,d=!1,p=function(){},c=null,u="data-vue-ssr-id",h="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function m(e,t,n,o){d=n,c=o||{};var i=a(e,t);return y(i),function(t){for(var n=[],o=0;o<i.length;o++){var s=i[o];(l=r[s.id]).refs--,n.push(l)}for(t?y(i=a(e,t)):i=[],o=0;o<n.length;o++){var l;if(0===(l=n[o]).refs){for(var d=0;d<l.parts.length;d++)l.parts[d]();delete r[l.id]}}}}function y(e){for(var t=0;t<e.length;t++){var n=e[t],a=r[n.id];if(a){a.refs++;for(var o=0;o<a.parts.length;o++)a.parts[o](n.parts[o]);for(;o<n.parts.length;o++)a.parts.push(g(n.parts[o]));a.parts.length>n.parts.length&&(a.parts.length=n.parts.length)}else{var i=[];for(o=0;o<n.parts.length;o++)i.push(g(n.parts[o]));r[n.id]={id:n.id,refs:1,parts:i}}}}function f(){var e=document.createElement("style");return e.type="text/css",i.appendChild(e),e}function g(e){var t,n,a=document.querySelector("style["+u+'~="'+e.id+'"]');if(a){if(d)return p;a.parentNode.removeChild(a)}if(h){var o=l++;a=s||(s=f()),t=b.bind(null,a,o,!1),n=b.bind(null,a,o,!0)}else a=f(),t=x.bind(null,a),n=function(){a.parentNode.removeChild(a)};return t(e),function(a){if(a){if(a.css===e.css&&a.media===e.media&&a.sourceMap===e.sourceMap)return;t(e=a)}else n()}}var v,S=(v=[],function(e,t){return v[e]=t,v.filter(Boolean).join("\n")});function b(e,t,n,a){var o=n?"":a.css;if(e.styleSheet)e.styleSheet.cssText=S(t,o);else{var r=document.createTextNode(o),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(r,i[t]):e.appendChild(r)}}function x(e,t){var n=t.css,a=t.media,o=t.sourceMap;if(a&&e.setAttribute("media",a),c.ssrId&&e.setAttribute(u,t.id),o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}},617:function(e,t,n){var a=n(80);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(611).A)("9c82b91a",a,!1,{sourceMap:!1})},707:function(){},790:function(e,t,n){var a=n(707);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(611).A)("2b121068",a,!1,{sourceMap:!1})},915:function(e,t,n){var a=n(286);a.__esModule&&(a=a.default),"string"==typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals),(0,n(611).A)("5e9c0933",a,!1,{sourceMap:!1})},961:function(){}},t={};function n(a){var o=t[a];if(void 0!==o)return o.exports;var r=t[a]={id:a,exports:{}};return e[a](r,r.exports,n),r.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){"use strict";n.r(a),n.d(a,{buildPropsSchema:function(){return I},default:function(){return Le},registerSchema:function(){return O},schemaRegistry:function(){return C}});var e=require("@babel/runtime/helpers/extends"),t=n.n(e),o=require("@babel/runtime/helpers/inheritsLoose"),r=n.n(o),i=require("react"),s=n.n(i),l=require("react-dom"),d=n.n(l),p=require("mobx-react"),c=require("@babel/runtime/helpers/createClass"),u=n.n(c),h=require("tslib"),m=require("mobx"),y=require("antd"),f=require("lodash"),g=require("@wibetter/json-utils");function v(e){return(0,g.objClone)(e)}function S(e,t){return(0,g.isEqual)(e,t)}function b(e,t){window.sessionStorage&&window.sessionStorage.setItem(e,t)}var x=function(){function e(){this.descriptors=new Map}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var t=e.prototype;return t.register=function(e){this.descriptors.set(e.type,e)},t.registerAll=function(e){var t=this;e.forEach(function(e){return t.register(e)})},t.get=function(e){return this.descriptors.get(e)},t.getAllTypes=function(){return Array.from(this.descriptors.keys())},t.getAll=function(){return Array.from(this.descriptors.values())},t.has=function(e){return this.descriptors.has(e)},t.getDefaultSchema=function(e){var t;return null===(t=this.descriptors.get(e))||void 0===t?void 0:t.defaultSchema},e}();x.instance=void 0;var C=x.getInstance(),O=function(e,t){void 0===t&&(t=!1),!C.has(e.type)||t?C.register(e):console.warn("[JSONSchemaEditor] 已存在 "+e.type+" 类型的描述:",e)},E={description:{type:"input",title:"字段描述",description:"字段描述内容将作为 Title 的补充信息提供给用户",placeholder:"请输入字段描述"},showKey:{type:"boolean",title:"展示Key值",description:"开启后,在 JSONEditor 端会展示当前 Key 值,以便增加辨识度"},onShow:{type:"input",title:"显隐表达式",description:'设置显隐表达式,例如 "dataType === 1" 表示当 dataType 为 1 时显示当前项',placeholder:"请输入显隐表达式"},titleStyle:{type:"json",title:"标题样式",description:"可用于设置标题展示样式"}},j=Object.keys(E),R={readOnly:{type:"boolean",title:"是否只读",description:"当前属性设置为只读后,用户不能对其进行任何编辑操作"},isRequired:{type:"boolean",title:"是否必填项",description:"当前属性设置为必填项后,如果用户没有给其设置数值,则会进行标红提示"},isConditionProp:{type:"boolean",title:"条件字段",description:"设置为条件字段后,其他字段可根据其数值变化进行实时联动"}};function I(e){void 0===e&&(e={});var n=Object.keys(e);return{type:"object",wrapWithPanel:!1,properties:t()({},e,E),propertyOrder:[].concat(n,j)}}var N=g.TypeDataList.jsonschema;function _(){return C.getDefaultSchema("input")}var K=function(){function e(){var e=this;this.curJsonKeyIndex=1,this.triggerChange=!1,this.jsonSchema={},this.SchemaTypeList={},this.onChange=function(e){},this.childElemSort=function(t){for(var n=(0,g.getSchemaByIndexRoute)(t,e.jsonSchema,!1),a=n.propertyOrder,o=[],r=[],i=[],s=[],l=[],d=[],p=[],c=[],u=0,h=a.length;u<h;u++){var m=a[u];switch(n.properties[m].type){case"input":case"url":o.push(m);break;case"number":case"quantity":r.push(m);break;case"radio":case"checkboxes":case"boolean":case"color":i.push(m);break;case"date":case"date-time":case"time":s.push(m);break;case"textarea":case"json":case"codearea":case"htmlarea":l.push(m);break;case"image":d.push(m);break;case"object":case"array":p.push(m);break;default:c.push(m)}}n.propertyOrder=[].concat(o,r,i,s,d,l,p,c),e.jsonSchemaChange(!1)},(0,m.makeObservable)(this)}var n=e.prototype;return n.triggerChangeAction=function(){this.triggerChange=!this.triggerChange},n.initSchemaTypeList=function(e){},n.initJSONSchemaData=function(e){if(e&&"{}"!==JSON.stringify(e)){if(!S(e,this.JSONSchemaObj))if(e&&(0,g.isNewSchemaData)(e))this.jsonSchema=e;else{var t=(0,g.oldSchemaToNewSchema)(e);this.jsonSchema=t}}else this.jsonSchema=v(N)},n.initOnChange=function(e){var t,n;(e||(t=e,n=!1,"Function"===Object.prototype.toString.call(t).slice(8,-1)&&(n=!0),n))&&(this.onChange=e)},n.schemaChange=function(e){this.jsonSchema=e,this.jsonSchemaChange(!1)},n.jsonSchemaChange=function(e){this.jsonSchema.lastUpdateTime=(new Date).getTime(),e||this.onChange(this.JSONSchemaObj)},n.indexRoute2keyRoute=function(e){return(0,g.indexRoute2keyRoute)(e,this.jsonSchema)},n.keyRoute2indexRoute=function(e){return(0,g.keyRoute2indexRoute)(e,this.jsonSchema)},n.getSchemaByIndexRoute=function(e){return(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!0)},n.getSchemaByKeyRoute=function(e){return(0,g.getSchemaByKeyRoute)(e,this.jsonSchema,!0)},n.getNewJsonKeyIndex=function(e,t){var n=(t||"field")+"_"+this.curJsonKeyIndex;return e.propertyOrder.indexOf(n)>=0&&(this.curJsonKeyIndex+=1,n=this.getNewJsonKeyIndex(e,t)),this.curJsonKeyIndex+=1,n},n.isExitJsonKey=function(e,t){var n=(0,g.getParentIndexRoute)(e),a=this.getSchemaByIndexRoute(n);return!!(a.propertyOrder&&a.propertyOrder.indexOf(t)>=0)||(g.KeyWordList&&g.KeyWordList.indexOf(t)>=0&&y.message.warning(t+"是JSONSchema的关键字,建议您换一个,避免后续出现数据异常。"),t&&t.indexOf("-")>-1&&y.message.warning(t+"含特殊字符(‘-’),会影响后续数据获取和更新,建议您换一个数值。"),!1)},n.addChildJson=function(e,t){var n=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1),a=null==n?void 0:n.type,o=a?C.get(a):void 0;if(null!=o&&o.isContainer){var r=this.getNewJsonKeyIndex(n);n.propertyOrder.push(r),n.properties[r]=_(),this.jsonSchemaChange(t)}else y.message.warning("非对象类型字段不允许插入子元素")},n.changeType=function(e,t,n,a,o){var r=(0,g.getParentIndexRoute)(e),i=(0,g.getSchemaByIndexRoute)(r,this.jsonSchema,!1),s=Object.assign({},n,(0,f.pick)(a,["title","description","isConditionProp","showKey","showCodeViewBtn","onShow"]));i.properties&&i.properties[t]?i.properties[t]=v(s):i[t]&&(i[t]=v(s)),this.jsonSchemaChange(o)},n.updateSchemaData=function(e,t,n){var a=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);Object.assign(a,v(t)),this.jsonSchemaChange(n)},n.editSchemaData=function(e,n,a,o){var r=(0,g.getParentIndexRoute)(e),i=(0,g.getSchemaByIndexRoute)(r,this.jsonSchema,!1);i.properties[n]=t()({},v(i.properties[n]),a),this.jsonSchemaChange(o)},n.editJsonKey=function(e,t,n){var a=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!0);this.insertJsonData(e,t,a,"",!0),this.deleteJsonByIndex(e,!0),this.jsonSchemaChange(n)},n.addNextJsonData=function(e){var t=(0,g.getParentIndexRoute)(e),n=(0,g.getSchemaByIndexRoute)(t,this.jsonSchema,!1),a=this.getNewJsonKeyIndex(n);this.insertJsonData(e,a,_(),"",!1)},n.insertJsonData=function(e,t,n,a,o){var r=(0,g.getParentIndexRoute_CurIndex)(e),i=r[0]||"",s=r[1],l=(0,g.getSchemaByIndexRoute)(i,this.jsonSchema,!1);l.properties[t]=n;var d=l.propertyOrder,p="before"===a?Number(s):Number(s)+1,c=d.slice(0,p),u=d.slice(p);l.propertyOrder=[].concat(c,[t],u),this.jsonSchemaChange(o)},n.deleteJsonByIndex_CurKey=function(e,t,n){var a=(0,g.getParentIndexRoute)(e),o=(0,g.getSchemaByIndexRoute)(a,this.jsonSchema,!1);delete o.properties[t];var r=o.propertyOrder.indexOf(t);o.propertyOrder.splice(r,1),this.jsonSchemaChange(n)},n.deleteJsonByIndex=function(e,t){var n=(0,g.getParentIndexRoute_CurIndex)(e),a=n[0]||"",o=n[1],r=(0,g.getSchemaByIndexRoute)(a,this.jsonSchema,!1),i=r.propertyOrder[o];delete r.properties[i];var s=r.propertyOrder.indexOf(i);r.propertyOrder.splice(s,1),this.jsonSchemaChange(t)},n.updateEnumItem=function(e,t,n,a,o){var r=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);r.enum&&r.enumextra&&(r.enum[t]=n,r.enumextra[t]=a),this.jsonSchemaChange(o)},n.isExitEnumKey=function(e,t,n){var a=!1,o=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);if(o.enum){var r=v(o.enum);t>=0&&r.splice(t,1),r.indexOf(n)>=0&&(a=!0)}return g.KeyWordList&&g.KeyWordList.indexOf(n)>=0&&y.message.warning(n+"是JSONSchema的关键字,建议您换一个,避免后续出现数据异常。"),a},n.updateEnumKey=function(e,t,n,a){var o=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);o.enum&&(o.enum[t]=n),this.jsonSchemaChange(a)},n.updateEnumText=function(e,t,n,a){var o=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);o.enumextra&&(o.enumextra[t]=n),this.jsonSchemaChange(a)},n.deleteEnumItem=function(e,t,n){var a=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);a.enum&&a.enumextra&&(a.enum.splice(t,1),a.enumextra.splice(t,1)),this.jsonSchemaChange(n)},n.insertEnumItem=function(e,t,n,a,o,r){var i=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);if(i.enum&&i.enumextra){var s="before"===o?Number(t):Number(t)+1,l=i.enum.slice(0,s),d=i.enum.slice(s);i.enum=[].concat(l,[n],d);var p=i.enumextra.slice(0,s),c=i.enumextra.slice(s);i.enumextra=[].concat(p,[a],c)}this.jsonSchemaChange(r)},n.getNewEnumIndex=function(e,t){var n=(t||"enum")+"_"+this.curJsonKeyIndex;return e.indexOf(n)>=0&&(this.curJsonKeyIndex+=1,n=this.getNewEnumIndex(e,t)),this.curJsonKeyIndex+=1,n},n.addEnumItem=function(e,t){var n=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);if(n.enum){var a=this.getNewEnumIndex(n.enum),o="选项"+(this.curJsonKeyIndex-1);this.insertEnumItem(e,t,a,o,"",!1)}},n.copyEnumItem=function(e,t){var n=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);if(n.enum){var a=n.enum[t],o=n.enumextra[t],r=this.getNewEnumIndex(n.enum,a),i=o+"_"+(this.curJsonKeyIndex-1);this.insertEnumItem(e,t,r,i,"",!1)}},n.updateOptionItem=function(e,t,n,a,o){var r=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);r.options&&r.options[t]&&(r.options[t].label=n,r.options[t].value=a),this.jsonSchemaChange(o)},n.isExitOptionLabel=function(e,t){var n=!1,a=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);return a.options&&a.options.find(function(e){return e.label===t})&&(n=!0),g.KeyWordList&&g.KeyWordList.indexOf(t)>=0&&y.message.warning(t+"是JSONSchema的保留关键字,建议您换一个名称。"),n},n.updateOptionLabel=function(e,t,n,a){var o=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);o.options&&o.options[t]&&(o.options[t].label=n),this.jsonSchemaChange(a)},n.updateOptionValue=function(e,t,n,a){var o=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);o.options&&o.options[t]&&(o.options[t].value=n),this.jsonSchemaChange(a)},n.deleteOptionItem=function(e,t,n){var a=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);a.options&&a.options[t]&&a.options.splice(t,1),this.jsonSchemaChange(n)},n.insertOption=function(e,t,n,a,o,r){var i=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);if(i.options){var s="before"===o?Number(t):Number(t)+1,l=i.options.slice(0,s),d=i.options.slice(s),p={label:n,value:a};i.options=[].concat(l,[p],d)}this.jsonSchemaChange(r)},n.getNewOptionValue=function(e){return e&&e.length>0?e[e.length-1].value+"_"+(e.length+1):"value1"},n.addOptionItem=function(e,t){var n=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);if(n.options){var a=this.getNewOptionValue(n.options),o="选项"+(n.options.length+1);this.insertOption(e,t,o,a,"",!1)}},n.copyOptionItem=function(e,t){var n=(0,g.getSchemaByIndexRoute)(e,this.jsonSchema,!1);if(n.options){var a=n.options[t],o=this.getNewOptionValue(n.options),r=(a.label||a.name)+"_copy";this.insertOption(e,t,r,o,"",!1)}},u()(e,[{key:"JSONSchemaObj",get:function(){return(0,m.toJS)(this.jsonSchema)}}])}();(0,h.__decorate)([m.observable],K.prototype,"triggerChange",void 0),(0,h.__decorate)([m.observable],K.prototype,"jsonSchema",void 0),(0,h.__decorate)([m.observable],K.prototype,"SchemaTypeList",void 0),(0,h.__decorate)([m.observable],K.prototype,"onChange",void 0),(0,h.__decorate)([m.action.bound],K.prototype,"triggerChangeAction",null),(0,h.__decorate)([m.action.bound],K.prototype,"initSchemaTypeList",null),(0,h.__decorate)([m.action.bound],K.prototype,"initJSONSchemaData",null),(0,h.__decorate)([m.computed],K.prototype,"JSONSchemaObj",null),(0,h.__decorate)([m.action.bound],K.prototype,"initOnChange",null),(0,h.__decorate)([m.action.bound],K.prototype,"schemaChange",null),(0,h.__decorate)([m.action.bound],K.prototype,"jsonSchemaChange",null),(0,h.__decorate)([m.action.bound],K.prototype,"indexRoute2keyRoute",null),(0,h.__decorate)([m.action.bound],K.prototype,"keyRoute2indexRoute",null),(0,h.__decorate)([m.action.bound],K.prototype,"getSchemaByIndexRoute",null),(0,h.__decorate)([m.action.bound],K.prototype,"getSchemaByKeyRoute",null),(0,h.__decorate)([m.action.bound],K.prototype,"getNewJsonKeyIndex",null),(0,h.__decorate)([m.action.bound],K.prototype,"isExitJsonKey",null),(0,h.__decorate)([m.action.bound],K.prototype,"addChildJson",null),(0,h.__decorate)([m.action.bound],K.prototype,"changeType",null),(0,h.__decorate)([m.action.bound],K.prototype,"updateSchemaData",null),(0,h.__decorate)([m.action.bound],K.prototype,"editSchemaData",null),(0,h.__decorate)([m.action.bound],K.prototype,"editJsonKey",null),(0,h.__decorate)([m.action.bound],K.prototype,"addNextJsonData",null),(0,h.__decorate)([m.action.bound],K.prototype,"insertJsonData",null),(0,h.__decorate)([m.action.bound],K.prototype,"deleteJsonByIndex_CurKey",null),(0,h.__decorate)([m.action.bound],K.prototype,"deleteJsonByIndex",null),(0,h.__decorate)([m.action.bound],K.prototype,"updateEnumItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"isExitEnumKey",null),(0,h.__decorate)([m.action.bound],K.prototype,"updateEnumKey",null),(0,h.__decorate)([m.action.bound],K.prototype,"updateEnumText",null),(0,h.__decorate)([m.action.bound],K.prototype,"deleteEnumItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"insertEnumItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"getNewEnumIndex",null),(0,h.__decorate)([m.action.bound],K.prototype,"addEnumItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"copyEnumItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"updateOptionItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"isExitOptionLabel",null),(0,h.__decorate)([m.action.bound],K.prototype,"updateOptionLabel",null),(0,h.__decorate)([m.action.bound],K.prototype,"updateOptionValue",null),(0,h.__decorate)([m.action.bound],K.prototype,"deleteOptionItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"insertOption",null),(0,h.__decorate)([m.action.bound],K.prototype,"getNewOptionValue",null),(0,h.__decorate)([m.action.bound],K.prototype,"addOptionItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"copyOptionItem",null),(0,h.__decorate)([m.action.bound],K.prototype,"childElemSort",void 0);var w={schemaStore:K},J=require("@babel/runtime/helpers/objectWithoutPropertiesLoose"),B=n.n(J),T=require("@ant-design/icons"),k=require("@wibetter/json-editor"),q=n.n(k),D=function(e){function t(){return e.apply(this,arguments)||this}return r()(t,e),t.prototype.render=function(){var e=this.props,t=e.indexRoute,n=e.jsonKey,a=e.targetJsonSchema,o=(this.props.schemaStore||{}).editSchemaData,r=null==a?void 0:a.type;if(!r||!a)return i.createElement("div",{className:"advance-config-empty"},"暂无高级配置");var s=C.get(r),l=null==s?void 0:s.propsSchema;return l&&0!==Object.keys(l.properties||{}).length?i.createElement("div",{className:"advance-config-model"},i.createElement(q(),{wideScreen:!0,schemaData:l,jsonData:a,onChange:function(e){if(e&&o){var a={};Object.keys(l.properties||{}).forEach(function(t){void 0!==e[t]&&(a[t]=e[t])}),o(t,n,a)}}})):i.createElement("div",{className:"advance-config-empty"},"当前类型暂无高级配置")},t}(i.PureComponent),P=(0,p.inject)(function(e){return{schemaStore:e.schemaStore}})((0,p.observer)(D)),A=(n(915),y.Select.Option),L=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleTypeChange=function(e){var t=(n.props.schemaStore||{}).changeType,a=n.props,o=a.indexRoute,r=a.jsonKey,i=a.targetJsonSchema;i.type!==e&&t(o,r,C.getDefaultSchema(e),i)},n.handleJsonKeyChange=function(e){var t=n.props.schemaStore||{},a=t.editJsonKey,o=t.isExitJsonKey,r=e.target.value,i=n.props,s=i.indexRoute;i.jsonKey!==r&&(o(s,r)?y.message.warning("当前key已存在,请换一个吧。"):a(s,r))},n.handleTitleChange=function(e){var t=(n.props.schemaStore||{}).editSchemaData,a=e.target.value,o=n.props,r=o.indexRoute,i=o.jsonKey;o.targetJsonSchema.title!==a&&t(r,i,{title:a})},n.getAllTypeList=function(){return C.getAllTypes()},n.onAddBtnEvent=function(){var e=n.props.schemaStore||{},t=e.addChildJson,a=e.addNextJsonData,o=n.props,r=o.indexRoute,i=o.targetJsonSchema,s=null==i?void 0:i.type,l=s?C.get(s):void 0;null!=l&&l.isContainer?t(r):a(r)},n.onCopyBtnEvent=function(){var e=n.props,t=e.indexRoute,a=e.targetJsonSchema,o=e.jsonKey,r=n.props.schemaStore||{},i=r.getSchemaByIndexRoute,s=r.indexRoute2keyRoute,l=r.insertJsonData,d=r.getNewJsonKeyIndex,p=v(a),c=(0,g.getParentIndexRoute)(t),u=d(i(c),o),h=a.type;b(s(c)+"-"+u+"-"+h,s(t)),l(t,u,p)},n.onDeleteBtnEvent=function(){var e=n.props,t=e.jsonKey,a=e.indexRoute;(0,(n.props.schemaStore||{}).deleteJsonByIndex_CurKey)(a,t)},n.ignoreDragEvent=function(e){e.preventDefault(),e.stopPropagation()},n.childElemSort=function(){var e=n.props.indexRoute;(0,(n.props.schemaStore||{}).childElemSort)(e)},n.state={showAdvanceConfig:!1},n.onAddBtnEvent=n.onAddBtnEvent.bind(n),n.onCopyBtnEvent=n.onCopyBtnEvent.bind(n),n.onDeleteBtnEvent=n.onDeleteBtnEvent.bind(n),n.handleJsonKeyChange=n.handleJsonKeyChange.bind(n),n.handleTitleChange=n.handleTitleChange.bind(n),n.handleTypeChange=n.handleTypeChange.bind(n),n.childElemSort=n.childElemSort.bind(n),n}return r()(t,e),t.prototype.render=function(){var e,t,n=this,a=(this.props.schemaStore||{}).getSchemaByIndexRoute,o=this.props,r=(o.parentType,o.indexRoute),s=o.jsonKey,l=o.nodeKey,d=o.targetJsonSchema,p=this.state.showAdvanceConfig,c=r?(0,g.getParentIndexRoute)(r):"",u=c?a(c):{},h=null===(e=u&&u.isContainer)||void 0===e||e,m=null==d?void 0:d.type,f=m?C.get(m):void 0,v=(null==f?void 0:f.isFixed)||!1,S=(null==f||f.readOnly,void 0!==this.props.keyIsFixed?this.props.keyIsFixed:void 0!==(null==f?void 0:f.keyIsFixed)?f.keyIsFixed:!h||v),b=void 0!==this.props.typeIsFixed?this.props.typeIsFixed:void 0!==(null==f?void 0:f.typeIsFixed)?f.typeIsFixed:v,x=void 0!==this.props.titleIsFixed?this.props.titleIsFixed:void 0!==(null==f?void 0:f.titleIsFixed)?f.titleIsFixed:v,O=void 0!==this.props.hideOperaBtn?this.props.hideOperaBtn:void 0!==(null==f?void 0:f.hideOperaBtn)?f.hideOperaBtn:!h,E=void 0!==this.props.showAdvanceBtn?this.props.showAdvanceBtn:void 0===(null==f?void 0:f.showAdvanceBtn)||f.showAdvanceBtn,j=this.getAllTypeList(),R=null!==(t=null==f?void 0:f.isContainer)&&void 0!==t&&t;return i.createElement(i.Fragment,null,d&&i.createElement("div",{className:"base-schema-box",id:l},i.createElement("div",{className:"key-input-item",draggable:"true",onDragStart:this.ignoreDragEvent},i.createElement(y.Input,{defaultValue:s||"key值不存在",disabled:S,onBlur:this.handleJsonKeyChange})),i.createElement("div",{className:"type-select-item",draggable:"true",onDragStart:this.ignoreDragEvent},i.createElement(y.Select,{showSearch:!0,defaultValue:m,style:{width:150},onChange:this.handleTypeChange,disabled:b,filterOption:function(e,t){return!!(t&&t.value.indexOf(e)>-1||t.children&&t.children.indexOf(e)>-1)}},j.map(function(e){var t;return i.createElement(A,{key:e,value:e},(null===(t=C.get(e))||void 0===t?void 0:t.label)||e)}))),i.createElement("div",{className:"title-input-item",draggable:"true",onDragStart:this.ignoreDragEvent},i.createElement(y.Input,{defaultValue:d.title,disabled:x,onBlur:this.handleTitleChange})),i.createElement("div",{className:"operate-item"},!O&&i.createElement(i.Fragment,null,!v&&i.createElement(y.Tooltip,{title:"删除"},i.createElement(T.CloseOutlined,{className:"operate-btn delete-operate",onClick:this.onDeleteBtnEvent})),i.createElement(y.Tooltip,{title:R?"新增子元素":"新增同级元素"},i.createElement(T.PlusOutlined,{className:"operate-btn",onClick:this.onAddBtnEvent})),R&&i.createElement(y.Tooltip,{title:"数据项排序"},i.createElement(T.SortAscendingOutlined,{className:"operate-btn",onClick:this.childElemSort})),!v&&i.createElement(i.Fragment,null,i.createElement(y.Tooltip,{title:"复制"},i.createElement(T.CopyOutlined,{className:"operate-btn",onClick:this.onCopyBtnEvent})),i.createElement(y.Tooltip,{title:"按住进行拖拽"},i.createElement(T.DragOutlined,{className:"operate-btn drag-btn"})))),E&&i.createElement(y.Tooltip,{title:"高级设置"},i.createElement(T.SettingOutlined,{className:"operate-btn",onClick:function(){n.setState({showAdvanceConfig:!0})}}))),p&&i.createElement(y.Modal,{open:!0,title:"高级设置 / 当前字段:"+d.title+"("+s+")",width:800,onCancel:function(){n.setState({showAdvanceConfig:!1})},footer:[i.createElement(y.Button,{key:"submit",type:"primary",onClick:function(){n.setState({showAdvanceConfig:!1})}},"保存并关闭")]},i.createElement(P,{indexRoute:r,jsonKey:s,targetJsonSchema:d}))),!d&&i.createElement("div",{className:"base-schema-box"},i.createElement("div",{className:"warn-text"},s,":数据元素为空")))},t}(i.PureComponent),F=(0,p.inject)(function(e){return{schemaStore:e.schemaStore}})((0,p.observer)(L)),V=y.Tree.TreeNode,M=function(e){return s().createElement(F,t()({},e))},W=function(e){var t=e.jsonKey,n=e.indexRoute,a=e.nodeKey,o=e.targetJsonSchema.type;return s().createElement(V,{className:o+"-schema schema-item-form",id:a,key:a,"data-indexRoute":n,"data-jsonKey":t,title:M(e)})},U=function(e){var t=e.targetJsonSchema,n=t.type,a=C.get(n);return a&&a.renderer?a.renderer(e):t.properties&&Object.keys(t.properties).length>0?Z(e):W(e)},z=["propertyOrder","properties","parentIndexRoute","parentNodeKey","parentType","isOnlyShowChild"],G=y.Tree.TreeNode,H=function(e){return s().createElement(F,t()({},e))},Z=function(e){var n,a,o,r,i,l,d,p=e.jsonKey,c=e.indexRoute,u=e.nodeKey,h=e.targetJsonSchema,m=e.isOnlyShowChild,y=h.type,f=C.get(y),g=null==f?void 0:f.isFixed,v=(a=(n=t()({},e,{propertyOrder:h.propertyOrder,properties:h.properties,parentIndexRoute:c,parentNodeKey:u,parentType:y,isOnlyShowChild:m})).propertyOrder,o=n.properties,r=n.parentIndexRoute,i=n.parentNodeKey,l=n.parentType,n.isOnlyShowChild,d=B()(n,z),a.map(function(e,n){var a=r?r+"-"+n:""+n,s=e,p=o[s],c=p.type,u=(i?i+"-":"")+c+"-"+s;return U(t()({},d,{parentType:l,jsonKey:s,indexRoute:a,key:u,nodeKey:u,targetJsonSchema:p}))})),S=s().createElement(G,{className:y+"-schema schema-item-form",id:u,key:u,"data-indexRoute":c,"data-jsonKey":p,disabled:g,title:H(t()({},e))},v);return m?v:S},X=require("react-ace"),Q=n.n(X),Y=(require("ace-builds/src-noconflict/mode-json"),require("ace-builds/src-noconflict/theme-solarized_light"),n(40),function(e){function t(t){var n;return(n=e.call(this,t)||this).handleValueChange=function(e){n.props.onChange&&(0,g.isFunction)(n.props.onChange)&&n.props.onChange(e)},n.state={isShowWarn:!1,warnText:"",curJSONDataTemp:void 0},n.handleValueChange=n.handleValueChange.bind(n),n}return r()(t,e),t.prototype.render=function(){var e=this,t=this.props,n=t.jsonData,a=t.readOnly,o=t.maxLines,r=n||{},s=this.state,l=s.isShowWarn,d=s.warnText,p=(s.curJSONDataTemp,a||!1);return r=void 0!==r?r:r||"{}",((0,g.isObject)(r)||(0,g.isArray)(r))&&(r=JSON.stringify(r,null,2)),i.createElement("div",{className:"json-view-box"},p&&i.createElement("div",{className:"readOnly-btn"},"[只读]"),l&&i.createElement("div",{className:"warning-box code-area-item"},i.createElement("div",{className:"warning-img"},"X"),i.createElement("div",{className:"warning-text"},d)),i.createElement(Q(),{key:"json_area_ace",defaultValue:r,className:"json-view-ace",mode:"json",theme:"solarized_light",name:"JSON_CODE_EDIT",fontSize:14,showPrintMargin:!0,showGutter:!0,highlightActiveLine:!0,readOnly:p,minLines:5,maxLines:o||10,width:"100%",setOptions:{useWorker:!1,showLineNumbers:!0,tabSize:2},onChange:function(t){try{var n=JSON.parse(t);e.handleValueChange(n),e.setState({isShowWarn:!1,curJSONDataTemp:void 0})}catch(n){e.setState({curJSONDataTemp:t,warnText:n.message,isShowWarn:!0})}}}))},t}(i.PureComponent)),$=(n(23),function(e){function n(t){var n;(n=e.call(this,t)||this).onDragStart=function(e){var t=(n.props.schemaStore||{}).getSchemaByIndexRoute,a=e.node,o=t(a.indexRoute||a["data-indexRoute"]),r=C.get(o.type);null!=r&&r.isFixed&&y.message.warning("当前元素不支持拖拽哦。")},n.onDrop=function(e){var t=e.dragNode,a=e.node,o=n.props.schemaStore||{},r=o.getSchemaByIndexRoute,i=o.indexRoute2keyRoute,s=o.insertJsonData,l=o.deleteJsonByIndex,d=o.isExitJsonKey,p=t.indexRoute||t["data-indexRoute"],c=t.jsonKey||t["data-jsonKey"],u=r(p),h=C.get(u.type);if(null==h||!h.isFixed){var m=a.indexRoute||a["data-indexRoute"],f=(0,g.isSameParent)(p,m),v=(0,g.getCurPosition)(p,m);if(f)l(p,!0),"before"===v&&(m=(0,g.moveForward)(m)),a.dragOverGapTop?s(m,c,u,"before"):(a.dragOver||a.dragOverGapBottom)&&s(m,c,u);else{if(d(m,c))return void y.message.warning("目标位置中有重名的元素");var S=u.type,x=i(p),O=(0,g.getParentIndexRoute)(m),E=function(e){if(window.sessionStorage)return window.sessionStorage.getItem(e)}(x+"-"+S);b(i(O)+"-"+c+"-"+S,E||x),a.dragOverGapTop?"after"===v?(l(p,!0),s(m,c,u,"before")):(s(m,c,u,"before",!0),l(p)):(a.dragOver||a.dragOverGapBottom)&&("after"===v?(l(p,!0),s(m,c,u)):(s(m,c,u,"",!0),l(p)))}}},n.catchExpandedKeys=function(e){var t=[];return e&&e.propertyOrder&&e.properties&&e.propertyOrder.map(function(n,a){var o=n,r=e.properties[o].type+"-"+o;t.push(r)}),t};var a=n.props.schemaStore||{},o=a.initJSONSchemaData,r=a.initOnChange;return t.data&&o(t.data),t.onChange&&r(t.onChange),n}r()(n,e);var a=n.prototype;return a.componentWillReceiveProps=function(e){var t=this.props.schemaStore||{},n=t.initJSONSchemaData,a=t.initOnChange;S(e.data,this.props.data)||n(e.data),S(e.onChange,this.props.onChange)||a(e.onChange)},a.render=function(){var e=this.props,n=e.jsonView,a=e.jsonViewReadOnly,o=this.props.schemaStore||{},r=o.jsonSchema,s=o.schemaChange,l=(0,g.isEmptySchema)(r),d=r.type;return i.createElement("div",{className:"json-schema-container"},!l&&!n&&i.createElement(i.Fragment,null,i.createElement(y.Tree,{draggable:!0,selectable:!1,onDragStart:this.onDragStart,onDrop:this.onDrop,defaultExpandedKeys:"object"!==d||l?[]:this.catchExpandedKeys(r)},"object"===d&&Z(t()({},this.props,{parentType:"",jsonKey:"",indexRoute:"",nodeKey:"",targetJsonSchema:r,isOnlyShowChild:!0})),"object"!==d&&U(t()({},this.props,{parentType:"",jsonKey:"",indexRoute:"",nodeKey:"first-schema",targetJsonSchema:r,key:"schema",isFirstSchema:!0})))),!l&&n&&i.createElement(Y,{jsonData:r,readOnly:null==a||a,maxLines:25,onChange:s}),l&&i.createElement("p",{className:"json-schema-empty"},"当前jsonSchema没有数据内容"))},n}(i.PureComponent)),ee=(0,p.inject)(function(e){return{schemaStore:e.schemaStore}})((0,p.observer)($)),te={type:"input",label:"字符串/单行文本",isContainer:!1,defaultSchema:{type:"input",title:"单文本框",default:"",description:"",placeholder:"",autoComplete:!1,options:[]},renderer:W,propsSchema:I(t()({},R,{isConditionProp:R.isConditionProp,default:{type:"input",title:"默认值",placeholder:"请输入默认值"},placeholder:{type:"input",title:"输入提示",description:"输入提示内容将作为输入区域的提示信息展示给用户",placeholder:"请输入输入提示"},autoComplete:{type:"boolean",title:"开启可选项",description:"开启后支持添加可选项,并支持 autoComplete"},options:{type:"json",title:"可选项",description:"开启可选项后,可在此设置可选数据列表(数组格式)",onShow:"autoComplete === true"}}))};C.register(te);var ne={type:"boolean",label:"Boolean/开关",isContainer:!1,defaultSchema:{type:"boolean",title:"布尔值",default:!1,description:""},renderer:W,propsSchema:I({isConditionProp:R.isConditionProp,readOnly:R.readOnly,isRequired:R.isRequired,default:{type:"boolean",title:"默认值"}})};C.register(ne);var ae={type:"number",label:"Number数值",isContainer:!1,defaultSchema:{type:"number",title:"数量number",default:1,description:"",placeholder:""},renderer:W,propsSchema:I({isConditionProp:R.isConditionProp,readOnly:R.readOnly,isRequired:R.isRequired,default:{type:"number",title:"默认值",placeholder:"请输入默认数值"},placeholder:{type:"input",title:"输入提示",placeholder:"请输入输入提示"},minimum:{type:"number",title:"最小值",description:"设置最小值后,用户输入的数值必须大于当前最小值"},maximum:{type:"number",title:"最大值",description:"设置最大值后,用户输入的数值必须小于当前最大值"}})};C.register(ae);var oe={type:"color",label:"颜色数值",isContainer:!1,defaultSchema:{type:"color",title:"颜色color",default:"#ffffff",description:""},renderer:W,propsSchema:I({isConditionProp:R.isConditionProp,readOnly:R.readOnly,isRequired:R.isRequired,default:{type:"color",title:"默认颜色值"}})};C.register(oe);var re={type:"url",label:"URL数值",isContainer:!1,defaultSchema:{type:"url",title:"链接地址url",default:"",description:"",placeholder:""},renderer:W,propsSchema:I({isConditionProp:R.isConditionProp,readOnly:R.readOnly,isRequired:R.isRequired,default:{type:"input",title:"默认值",placeholder:"请输入默认 URL"},placeholder:{type:"input",title:"输入提示",placeholder:"请输入输入提示"}})};C.register(re);var ie={type:"textarea",label:"多行文本",isContainer:!1,defaultSchema:{type:"textarea",title:"多行文本框",default:"",description:"",placeholder:""},renderer:W,propsSchema:I({readOnly:R.readOnly,isRequired:R.isRequired,default:{type:"textarea",title:"默认值",placeholder:"请输入默认值"},placeholder:{type:"input",title:"输入提示",placeholder:"请输入输入提示"}})};C.register(ie);var se={type:"text-editor",label:"富文本内容",isContainer:!1,defaultSchema:{type:"text-editor",title:"富文本",default:"",description:"",placeholder:""},renderer:W,propsSchema:I({readOnly:R.readOnly,isRequired:R.isRequired,default:{type:"text-editor",title:"默认值",placeholder:"请输入默认富文本内容"},placeholder:{type:"input",title:"输入提示",placeholder:"请输入输入提示"}})};C.register(se);var le=function(e){return void 0===e&&(e="textarea"),I({readOnly:R.readOnly,isRequired:R.isRequired,default:{type:e,title:"默认值",placeholder:"请输入默认值"},placeholder:{type:"input",title:"输入提示",placeholder:"请输入输入提示"}})},de={type:"json",label:"json内容",isContainer:!1,defaultSchema:{type:"json",title:"json数据",default:"{}",description:"",placeholder:""},renderer:W,propsSchema:le("json")},pe={type:"codearea",label:"code内容",isContainer:!1,defaultSchema:{type:"codearea",title:"函数类型",default:'function func() { console.log("hello, world!"); }',description:"用于定义函数方法",placeholder:"请输入函数方法"},renderer:W,propsSchema:le("codearea")},ce={type:"htmlarea",label:"html内容",isContainer:!1,defaultSchema:{type:"htmlarea",title:"富文本",default:"<p>hello,world!</p>",description:"用于放置html代码片段",placeholder:"请输入html代码片段"},renderer:W,propsSchema:le("htmlarea")};C.registerAll([de,pe,ce]);var ue=function(e){return void 0===e&&(e="date"),I({isConditionProp:R.isConditionProp,readOnly:R.readOnly,isRequired:R.isRequired,default:{type:e,title:"默认值",placeholder:"请输入默认日期值"},placeholder:{type:"input",title:"输入提示",placeholder:"请输入输入提示"}})},he={type:"date",label:"日期",isContainer:!1,defaultSchema:{type:"date",title:"日期Date",default:"",description:"",placeholder:""},renderer:W,propsSchema:ue()},me={type:"date-time",label:"日期时间",isContainer:!1,defaultSchema:{type:"date-time",title:"日期时间",default:"",description:"",placeholder:""},renderer:W,propsSchema:ue("date-time")},ye={type:"time",label:"时间",isContainer:!1,defaultSchema:{type:"time",title:"时间Time",default:"",description:"",placeholder:""},renderer:W,propsSchema:ue("time")};C.registerAll([he,me,ye]);var fe={type:"input-image",label:"图片上传",isContainer:!1,defaultSchema:{type:"input-image",title:"图片地址",default:"",description:""},renderer:W,propsSchema:I({isConditionProp:R.isConditionProp,readOnly:R.readOnly,isRequired:R.isRequired,default:{type:"input",title:"默认图片URL",placeholder:"请输入默认图片地址"}})};C.register(fe),n(617);var ge=y.Select.Option,ve=function(e){function t(t){var n;return(n=e.call(this,t)||this).handleLabelChange=function(e){var t=n.props.schemaStore||{},a=t.isExitOptionLabel,o=t.updateOptionLabel,r=e.target.value,i=n.props,s=i.indexRoute,l=i.optionIndex;r!==i.optionLabel&&(a(s,r)?y.message.warning("对不起,存在相同的Label值,请重新设置。"):o(s,l,r))},n.handleValueChange=function(e){var t=(n.props.schemaStore||{}).updateOptionValue,a=e.target.value,o=n.props,r=o.indexRoute,i=o.optionIndex,s=o.optionValue;if(a!==s){var l=a;if((0,g.isObject)(s)&&(0,g.isString)(l))try{l=JSON.parse(l)}catch(e){console.warn("option 数值转换失败:",l),l=s}t(r,i,l)}},n.onAddBtnEvent=function(){var e=(n.props.schemaStore||{}).addOptionItem,t=n.props;e(t.indexRoute,t.optionIndex)},n.onCopyBtnEvent=function(){var e=(n.props.schemaStore||{}).copyOptionItem,t=n.props;e(t.indexRoute,t.optionIndex)},n.onDeleteBtnEvent=function(){var e=n.props.schemaStore||{},t=(e.getSchemaByIndexRoute,e.deleteOptionItem),a=n.props;t(a.indexRoute,a.optionIndex)},n.onAddBtnEvent=n.onAddBtnEvent.bind(n),n.onCopyBtnEvent=n.onCopyBtnEvent.bind(n),n.onDeleteBtnEvent=n.onDeleteBtnEvent.bind(n),n.handleLabelChange=n.handleLabelChange.bind(n),n.handleValueChange=n.handleValueChange.bind(n),n}return r()(t,e),t.prototype.render=function(){var e=this.props,t=e.optionLabel,n=e.optionValue,a=(e.optionNodeKey,n);return((0,g.isObject)(n)||(0,g.isArray)(n))&&(a=JSON.stringify(n)),i.createElement("div",{className:"option-schema-box",id:t},i.createElement("div",{className:"key-input-item"},i.createElement(y.Input,{defaultValue:a,onPressEnter:this.handleValueChange,onBlur:this.handleValueChange})),i.createElement("div",{className:"type-select-item"},i.createElement(y.Select,{defaultValue:"string",style:{width:120}},i.createElement(ge,{key:"string",value:"string"},"string"))),i.createElement("div",{className:"title-input-item"},i.createElement(y.Input,{defaultValue:t,onPressEnter:this.handleLabelChange,onBlur:this.handleLabelChange})),i.createElement("div",{className:"operate-item"},i.createElement(y.Tooltip,{title:"删除"},i.createElement(T.CloseOutlined,{className:"operate-btn delete-operate",onClick:this.onDeleteBtnEvent})),i.createElement(y.Tooltip,{title:"新增可选项"},i.createElement(T.PlusOutlined,{className:"operate-btn",onClick:this.onAddBtnEvent})),i.createElement(y.Tooltip,{title:"复制"},i.createElement(T.CopyOutlined,{className:"operate-btn",onClick:this.onCopyBtnEvent}))))},t}(i.PureComponent),Se=(0,p.inject)(function(e){return{schemaStore:e.schemaStore}})((0,p.observer)(ve)),be=y.Tree.TreeNode,xe=function(e){return s().createElement(Se,t()({},e))},Ce=function(e){var n,a=e.jsonKey,o=e.indexRoute,r=e.nodeKey,i=e.targetJsonSchema,l=i.type,d=i.options,p=o||"0";return s().createElement(be,{className:l+"-schema schema-item-form",id:r,key:r,"data-indexRoute":o||"0","data-jsonKey":a,title:(n=t()({},e),s().createElement(F,t()({},n)))},d&&d.length>0&&d.map(function(e,t){var n=e.label||e.name,a=e.value,o=""+r+l+"-"+n;return s().createElement(be,{className:"enum-item-schema schema-item-form",id:o,key:o,"data-indexRoute":p,disabled:!0,title:xe({indexRoute:p,optionIndex:t,optionLabel:n,optionValue:a,optionNodeKey:o})})}))},Oe={type:"radio",label:"单选",isContainer:!1,defaultSchema:{type:"radio",title:"单选",options:[{label:"选项a",value:"a"},{label:"选项b",value:"b"},{label:"选项c",value:"c"}],default:"",description:""},renderer:Ce,propsSchema:I({isConditionProp:R.isConditionProp,readOnly:R.readOnly,isRequired:R.isRequired,defaultActiveFirstOption:{type:"boolean",title:"选中第一项",description:"是否默认高亮第一个选项"},default:{type:"input",title:"默认值",placeholder:"请输入默认选中项的 value 值"}})};C.register(Oe);var Ee={type:"select",label:"下拉选择/多选",isContainer:!1,defaultSchema:{type:"select",title:"下拉选择",options:[{label:"选项a",value:"a"},{label:"选项b",value:"b"},{label:"选项c",value:"c"}],description:""},renderer:Ce,propsSchema:I({isConditionProp:R.isConditionProp,readOnly:R.readOnly,isRequired:R.isRequired,multiple:{type:"boolean",title:"支持多选",description:"开启多选后,select 下拉列表支持选择多个选项"},defaultActiveFirstOption:{type:"boolean",title:"选中第一项",description:"是否默认高亮第一个选项"},withLabel:{type:"boolean",title:"附带label数值",description:"开启后,选中选项时,其数值会带上当前选项的 label 数值"},default:{type:"input",title:"默认值",placeholder:"请输入默认选中项的 value 值"}})};C.register(Ee);var je={type:"cascader",label:"级联选择",isContainer:!1,defaultSchema:{type:"cascader",title:"级联选择",options:[{value:"zhejiang",label:"Zhejiang",children:[{value:"hangzhou",label:"Hangzhou",children:[{value:"xihu",label:"West Lake"}]}]},{value:"jiangsu",label:"Jiangsu",children:[{value:"nanjing",label:"Nanjing",children:[{value:"zhonghuamen",label:"Zhong Hua Men"}]}]}],default:"a",description:""},renderer:W,propsSchema:I({readOnly:R.readOnly,isRequired:R.isRequired,multiple:{type:"boolean",title:"支持多选",description:"开启多选后,级联选择支持选择多个选项"},options:{type:"json",title:"options 配置",description:"用于添加级联选择组件的 options 数据"},default:{type:"input",title:"默认值",placeholder:"请输入默认值"}})};C.register(je);var Re={type:"checkboxes",label:"多选框",isContainer:!1,defaultSchema:{type:"checkboxes",title:"多选",options:[{label:"选项a",value:"a"},{label:"选项b",value:"b"},{label:"选项c",value:"c"}],default:["a"],description:""},renderer:Ce,propsSchema:I({readOnly:R.readOnly,isRequired:R.isRequired,default:{type:"json",title:"默认值",description:'默认选中的选项值数组,格式为 ["value1", "value2"]'}})};C.register(Re),n(790);var Ie=y.Select.Option,Ne=function(e){function t(t){var n;return(n=e.call(this,t)||this).typeChange=function(e){var t=n.props.schemaStore||{},a=t.editSchemaData,o=(t.updateSchemaData,n.props),r=o.indexRoute,i=o.jsonKey,s=o.targetJsonSchema;o.typeSelectData,s.default!==e&&a(r||"",i,{default:e})},n.typeChange=n.typeChange.bind(n),n}return r()(t,e),t.prototype.render=function(){var e=this.props,t=e.nodeKey,n=e.targetJsonSchema,a=n.type,o=n.options||[];return i.createElement("div",{className:"typeSelect-schema-box",id:t},i.createElement("div",{className:"key-input-item"},i.createElement(y.Select,{defaultValue:n.default||"local",onChange:this.typeChange},o.map(function(e,t){return i.createElement(Ie,{key:t,value:e.value},e.label||e.name)}))),i.createElement("div",{className:"type-select-item"},i.createElement(y.Select,{defaultValue:a,style:{width:120},disabled:!0},i.createElement(Ie,{key:a,value:a},a))),i.createElement("div",{className:"title-input-item"},i.createElement(y.Input,{defaultValue:n.title,disabled:!0})),i.createElement("div",{className:"operate-item"}," "))},t}(i.PureComponent),_e=(0,p.inject)(function(e){return{schemaStore:e.schemaStore}})((0,p.observer)(Ne)),Ke=y.Tree.TreeNode,we=function(e){return s().createElement(F,t()({},e))},Je={type:"quantity",label:"数值单位设置",isContainer:!1,defaultSchema:{type:"quantity",title:"单位计量",description:"",properties:{unit:{type:"number",title:"单位数值",default:50},quantity:{type:"select",title:"单位类型",options:[{label:"px",value:"px"},{label:"rem",value:"rem"},{label:"em",value:"em"},{label:"%",value:"%"}],default:"px"}},propertyOrder:["unit","quantity"]},showAdvanceBtn:!1,renderer:function(e){var n,a=e.jsonKey,o=e.indexRoute,r=e.nodeKey,i=e.targetJsonSchema,l=i.type,d=i.propertyOrder[0],p=i.properties[d];return s().createElement(Ke,{className:l+"-schema schema-item-form",id:r,key:r,"data-indexRoute":o,"data-jsonKey":a,title:we(t()({},e))},s().createElement(Ke,{className:"quantity-unit-item-schema schema-item-form",id:r+"-"+d,key:r+"-"+d,"data-indexRoute":o?o+"-0":"0","data-jsonKey":d,disabled:!0,title:we(t()({},e,{indexRoute:o?o+"-0":"0",jsonKey:d,targetJsonSchema:p,parentType:l,nodeKey:r+"-"+d,hideOperaBtn:!0,showAdvanceBtn:!0,typeIsFixed:!0}))}),s().createElement(Ke,{className:"quantity-typeSelect-item-schema schema-item-form",id:r+"-quantity",key:r+"-quantity","data-indexRoute":o?o+"-1":"1","data-jsonKey":"quantity",disabled:!0,title:(n=t()({},e,{indexRoute:o?o+"-1":"1",jsonKey:"quantity",targetJsonSchema:i.properties.quantity,parentType:l,nodeKey:r+"-quantity"}),s().createElement(_e,t()({},n)))}))},propsSchema:I({readOnly:R.readOnly,isRequired:R.isRequired,autoComplete:{type:"boolean",title:"开启可选项",description:"开启后支持添加可选项,并支持 autoComplete"},options:{type:"json",title:"可选项",description:"可选项数据列表(数组格式)",onShow:"autoComplete === true"}})};C.register(Je);var Be={type:"padding-margin",label:"边距设置",isContainer:!1,defaultSchema:{type:"padding-margin",title:"边距设置",isContainer:!1,properties:{margin:{title:"外边距",type:"input",default:"0",description:""},padding:{title:"内边距",type:"input",default:"0",description:""},quantity:{type:"select",default:"px",options:[{label:"px",value:"px"},{label:"rem",value:"rem"},{label:"em",value:"em"},{label:"%",value:"%"}],title:"单位类型"}},propertyOrder:["margin","padding","quantity"]},propsSchema:I({autoComplete:{type:"boolean",title:"开启可选项",description:"开启后支持添加可选项,并支持 autoComplete"}}),renderer:Z};C.register(Be);var Te={type:"object",label:"对象(Object)",isContainer:!0,wrapWithPanel:!0,defaultSchema:{type:"object",title:"对象Object",description:"",properties:{a:{type:"input",title:"单文本框",default:"",description:"",placeholder:""}},propertyOrder:["a"]},propsSchema:I({showCodeViewBtn:{type:"boolean",title:"源码模式",description:"用于控制是否显示源码模式切换按钮,默认显示"}}),renderer:Z};C.register(Te);var ke=y.Tree.TreeNode,qe=function(e){return s().createElement(F,t()({},e))},De={type:"array",label:"数组(Array)",isContainer:!1,defaultSchema:{type:"array",title:"数组Array",description:"",items:{type:"object",title:"数组项",description:"",properties:{name:{type:"input",title:"名字",default:"",description:"",placeholder:""}},propertyOrder:["name"]}},propsSchema:I({showCodeViewBtn:{type:"boolean",title:"源码模式",description:"用于控制是否显示源码模式切换按钮,默认显示"},"minimum-child":{type:"number",title:"最小数据项",description:"用于限制数据项最小个数"},"maximum-child":{type:"number",title:"最多数据项",description:"用于限制数据项最多个数"}}),renderer:function(e){var n=e.jsonKey,a=e.indexRoute,o=e.nodeKey,r=e.targetJsonSchema,i=r.type,l=a?a+"-0":"0",d="items",p=o?o+"-"+d:d,c=r[d]||{};return s().createElement(ke,{className:i+"-schema schema-item-form",id:o,key:o,"data-indexRoute":a,"data-jsonKey":n,title:qe(t()({},e))},function(e){var n=e.parentType,a=e.jsonKey,o=e.indexRoute,r=e.nodeKey,i=e.targetJsonSchema;return s().createElement(ke,{className:"array-item-schema schema-item-form",id:r,key:r,"data-jsonKey":a,disabled:!0,title:qe(t()({},e,{indexRoute:o,jsonKey:a,targetJsonSchema:i,parentType:n,nodeKey:r,isFixed:!0,typeIsFixed:!1}))},"object"===i.type&&function(e){var n=e.propertyOrder,a=e.properties,o=e.parentIndexRoute,r=e.parentNodeKey,i=e.parentType;return n.map(function(n,s){var l=o?o+"-"+s:""+s,d=n,p=a[d],c=p.type,u=(r?r+"-":"")+c+"-"+d;return U(t()({},e,{parentType:i,jsonKey:d,indexRoute:l,key:u,nodeKey:u,targetJsonSchema:p}))})}(t()({},e,{propertyOrder:i.propertyOrder,properties:i.properties,parentIndexRoute:o,parentNodeKey:r,parentType:n})))}(t()({},e,{parentType:"array",jsonKey:d,indexRoute:l,nodeKey:p,targetJsonSchema:c})))}};C.register(De);var Pe=y.Tree.TreeNode,Ae={type:"api",label:"API 配置",isContainer:!1,isFixed:!1,keyIsFixed:!1,typeIsFixed:!1,defaultSchema:{type:"api",title:"API 配置",properties:{url:{type:"url",title:"请求地址",default:"",description:"API 的 URL",isRequired:!0},method:{type:"select",title:"请求方式",default:"get",options:[{label:"GET",value:"get"},{label:"POST",value:"post"},{label:"PUT",value:"put"},{label:"DELETE",value:"delete"}],isRequired:!0},headers:{type:"json",title:"请求头",default:"{}",description:"请求头对象"},data:{type:"json",title:"请求参数",default:"{}",description:"请求体或查询参数"}},propertyOrder:["url","method","headers","data"]},propsSchema:I(),renderer:function(e){var n=e.jsonKey,a=e.indexRoute,o=e.nodeKey,r=e.targetJsonSchema,i=r.type,l=r.properties.url||{},d=r.properties.method||{},p=r.properties.headers||{},c=r.properties.data||{};return s().createElement(Pe,{className:i+"-schema schema-item-form",id:o,key:o,"data-indexRoute":a,"data-jsonKey":n,title:s().createElement(F,t()({},e))},s().createElement(Pe,{className:"api-url-item-schema schema-item-form",id:o+"-url",key:o+"-url","data-indexRoute":a?a+"-0":"0","data-jsonKey":"url",title:s().createElement(F,t()({},e,{indexRoute:a?a+"-0":"0",jsonKey:"url",targetJsonSchema:l,parentType:i,nodeKey:o+"-url",hideOperaBtn:!0,keyIsFixed:!0,typeIsFixed:!0}))}),s().createElement(Pe,{className:"api-method-item-schema schema-item-form",id:o+"-method",key:o+"-method","data-indexRoute":a?a+"-1":"1",title:s().createElement(F,t()({},e,{indexRoute:a?a+"-1":"1",jsonKey:"method",targetJsonSchema:d,parentType:i,nodeKey:o+"-method",hideOperaBtn:!0,keyIsFixed:!0,typeIsFixed:!0}))}),s().createElement(Pe,{className:"api-headers-item-schema schema-item-form",id:o+"-headers",key:o+"-headers","data-indexRoute":a?a+"-2":"2","data-jsonKey":"headers",title:s().createElement(F,t()({},e,{indexRoute:a?a+"-2":"2",jsonKey:"headers",targetJsonSchema:p,parentType:i,nodeKey:o+"-headers",hideOperaBtn:!0,keyIsFixed:!0,typeIsFixed:!0}))}),s().createElement(Pe,{className:"api-data-item-schema schema-item-form",id:o+"-data",key:o+"-data","data-indexRoute":a?a+"-3":"3","data-jsonKey":"data",title:s().createElement(F,t()({},e,{indexRoute:a?a+"-3":"3",jsonKey:"data",targetJsonSchema:c,parentType:i,nodeKey:o+"-data",hideOperaBtn:!0,keyIsFixed:!0,typeIsFixed:!0}))}))}};C.register(Ae);var Le=function(e){function n(t){var n;return(n=e.call(this,t)||this).state={schemaStore:new w.schemaStore},n}return r()(n,e),n.prototype.render=function(){var e=this.props.element,n=this.state.schemaStore,a=i.createElement(p.Provider,{schemaStore:n},i.createElement(ee,t()({},this.props)));return e?(d().render(a,e),null):a},n}(i.PureComponent)}(),a}()});
2
+ !(function (e, t) {
3
+ 'object' == typeof exports && 'object' == typeof module
4
+ ? (module.exports = t())
5
+ : 'function' == typeof define && define.amd
6
+ ? define([], t)
7
+ : 'object' == typeof exports
8
+ ? (exports.JSONSchemaEditor = t())
9
+ : (e.JSONSchemaEditor = t());
10
+ })(this, function () {
11
+ return (function () {
12
+ var e = {
13
+ 23: function (e, t, n) {
14
+ var a = n(382);
15
+ (a.__esModule && (a = a.default),
16
+ 'string' == typeof a && (a = [[e.id, a, '']]),
17
+ a.locals && (e.exports = a.locals),
18
+ (0, n(611).A)('adbe60da', a, !1, { sourceMap: !1 }));
19
+ },
20
+ 40: function (e, t, n) {
21
+ var a = n(961);
22
+ (a.__esModule && (a = a.default),
23
+ 'string' == typeof a && (a = [[e.id, a, '']]),
24
+ a.locals && (e.exports = a.locals),
25
+ (0, n(611).A)('405d88dc', a, !1, { sourceMap: !1 }));
26
+ },
27
+ 80: function () {},
28
+ 286: function () {},
29
+ 382: function () {},
30
+ 611: function (e, t, n) {
31
+ 'use strict';
32
+ function a(e, t) {
33
+ for (var n = [], a = {}, o = 0; o < t.length; o++) {
34
+ var r = t[o],
35
+ i = r[0],
36
+ s = {
37
+ id: e + ':' + o,
38
+ css: r[1],
39
+ media: r[2],
40
+ sourceMap: r[3],
41
+ };
42
+ a[i]
43
+ ? a[i].parts.push(s)
44
+ : n.push((a[i] = { id: i, parts: [s] }));
45
+ }
46
+ return n;
47
+ }
48
+ n.d(t, {
49
+ A: function () {
50
+ return m;
51
+ },
52
+ });
53
+ var o = 'undefined' != typeof document;
54
+ if ('undefined' != typeof DEBUG && DEBUG && !o)
55
+ throw new Error(
56
+ "vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.",
57
+ );
58
+ var r = {},
59
+ i =
60
+ o && (document.head || document.getElementsByTagName('head')[0]),
61
+ s = null,
62
+ l = 0,
63
+ d = !1,
64
+ c = function () {},
65
+ p = null,
66
+ u = 'data-vue-ssr-id',
67
+ h =
68
+ 'undefined' != typeof navigator &&
69
+ /msie [6-9]\b/.test(navigator.userAgent.toLowerCase());
70
+ function m(e, t, n, o) {
71
+ ((d = n), (p = o || {}));
72
+ var i = a(e, t);
73
+ return (
74
+ y(i),
75
+ function (t) {
76
+ for (var n = [], o = 0; o < i.length; o++) {
77
+ var s = i[o];
78
+ ((l = r[s.id]).refs--, n.push(l));
79
+ }
80
+ for (
81
+ t ? y((i = a(e, t))) : (i = []), o = 0;
82
+ o < n.length;
83
+ o++
84
+ ) {
85
+ var l;
86
+ if (0 === (l = n[o]).refs) {
87
+ for (var d = 0; d < l.parts.length; d++) l.parts[d]();
88
+ delete r[l.id];
89
+ }
90
+ }
91
+ }
92
+ );
93
+ }
94
+ function y(e) {
95
+ for (var t = 0; t < e.length; t++) {
96
+ var n = e[t],
97
+ a = r[n.id];
98
+ if (a) {
99
+ a.refs++;
100
+ for (var o = 0; o < a.parts.length; o++) a.parts[o](n.parts[o]);
101
+ for (; o < n.parts.length; o++) a.parts.push(g(n.parts[o]));
102
+ a.parts.length > n.parts.length &&
103
+ (a.parts.length = n.parts.length);
104
+ } else {
105
+ var i = [];
106
+ for (o = 0; o < n.parts.length; o++) i.push(g(n.parts[o]));
107
+ r[n.id] = { id: n.id, refs: 1, parts: i };
108
+ }
109
+ }
110
+ }
111
+ function f() {
112
+ var e = document.createElement('style');
113
+ return ((e.type = 'text/css'), i.appendChild(e), e);
114
+ }
115
+ function g(e) {
116
+ var t,
117
+ n,
118
+ a = document.querySelector('style[' + u + '~="' + e.id + '"]');
119
+ if (a) {
120
+ if (d) return c;
121
+ a.parentNode.removeChild(a);
122
+ }
123
+ if (h) {
124
+ var o = l++;
125
+ ((a = s || (s = f())),
126
+ (t = b.bind(null, a, o, !1)),
127
+ (n = b.bind(null, a, o, !0)));
128
+ } else
129
+ ((a = f()),
130
+ (t = x.bind(null, a)),
131
+ (n = function () {
132
+ a.parentNode.removeChild(a);
133
+ }));
134
+ return (
135
+ t(e),
136
+ function (a) {
137
+ if (a) {
138
+ if (
139
+ a.css === e.css &&
140
+ a.media === e.media &&
141
+ a.sourceMap === e.sourceMap
142
+ )
143
+ return;
144
+ t((e = a));
145
+ } else n();
146
+ }
147
+ );
148
+ }
149
+ var v,
150
+ S =
151
+ ((v = []),
152
+ function (e, t) {
153
+ return ((v[e] = t), v.filter(Boolean).join('\n'));
154
+ });
155
+ function b(e, t, n, a) {
156
+ var o = n ? '' : a.css;
157
+ if (e.styleSheet) e.styleSheet.cssText = S(t, o);
158
+ else {
159
+ var r = document.createTextNode(o),
160
+ i = e.childNodes;
161
+ (i[t] && e.removeChild(i[t]),
162
+ i.length ? e.insertBefore(r, i[t]) : e.appendChild(r));
163
+ }
164
+ }
165
+ function x(e, t) {
166
+ var n = t.css,
167
+ a = t.media,
168
+ o = t.sourceMap;
169
+ if (
170
+ (a && e.setAttribute('media', a),
171
+ p.ssrId && e.setAttribute(u, t.id),
172
+ o &&
173
+ ((n += '\n/*# sourceURL=' + o.sources[0] + ' */'),
174
+ (n +=
175
+ '\n/*# sourceMappingURL=data:application/json;base64,' +
176
+ btoa(unescape(encodeURIComponent(JSON.stringify(o)))) +
177
+ ' */')),
178
+ e.styleSheet)
179
+ )
180
+ e.styleSheet.cssText = n;
181
+ else {
182
+ for (; e.firstChild; ) e.removeChild(e.firstChild);
183
+ e.appendChild(document.createTextNode(n));
184
+ }
185
+ }
186
+ },
187
+ 617: function (e, t, n) {
188
+ var a = n(80);
189
+ (a.__esModule && (a = a.default),
190
+ 'string' == typeof a && (a = [[e.id, a, '']]),
191
+ a.locals && (e.exports = a.locals),
192
+ (0, n(611).A)('9c82b91a', a, !1, { sourceMap: !1 }));
193
+ },
194
+ 707: function () {},
195
+ 790: function (e, t, n) {
196
+ var a = n(707);
197
+ (a.__esModule && (a = a.default),
198
+ 'string' == typeof a && (a = [[e.id, a, '']]),
199
+ a.locals && (e.exports = a.locals),
200
+ (0, n(611).A)('2b121068', a, !1, { sourceMap: !1 }));
201
+ },
202
+ 915: function (e, t, n) {
203
+ var a = n(286);
204
+ (a.__esModule && (a = a.default),
205
+ 'string' == typeof a && (a = [[e.id, a, '']]),
206
+ a.locals && (e.exports = a.locals),
207
+ (0, n(611).A)('5e9c0933', a, !1, { sourceMap: !1 }));
208
+ },
209
+ 961: function () {},
210
+ },
211
+ t = {};
212
+ function n(a) {
213
+ var o = t[a];
214
+ if (void 0 !== o) return o.exports;
215
+ var r = (t[a] = { id: a, exports: {} });
216
+ return (e[a](r, r.exports, n), r.exports);
217
+ }
218
+ ((n.n = function (e) {
219
+ var t =
220
+ e && e.__esModule
221
+ ? function () {
222
+ return e.default;
223
+ }
224
+ : function () {
225
+ return e;
226
+ };
227
+ return (n.d(t, { a: t }), t);
228
+ }),
229
+ (n.d = function (e, t) {
230
+ for (var a in t)
231
+ n.o(t, a) &&
232
+ !n.o(e, a) &&
233
+ Object.defineProperty(e, a, { enumerable: !0, get: t[a] });
234
+ }),
235
+ (n.o = function (e, t) {
236
+ return Object.prototype.hasOwnProperty.call(e, t);
237
+ }),
238
+ (n.r = function (e) {
239
+ ('undefined' != typeof Symbol &&
240
+ Symbol.toStringTag &&
241
+ Object.defineProperty(e, Symbol.toStringTag, { value: 'Module' }),
242
+ Object.defineProperty(e, '__esModule', { value: !0 }));
243
+ }));
244
+ var a = {};
245
+ return (
246
+ (function () {
247
+ 'use strict';
248
+ (n.r(a),
249
+ n.d(a, {
250
+ buildPropsSchema: function () {
251
+ return I;
252
+ },
253
+ default: function () {
254
+ return Fe;
255
+ },
256
+ registerSchema: function () {
257
+ return E;
258
+ },
259
+ schemaRegistry: function () {
260
+ return O;
261
+ },
262
+ }));
263
+ var e = require('@babel/runtime/helpers/extends'),
264
+ t = n.n(e),
265
+ o = require('@babel/runtime/helpers/inheritsLoose'),
266
+ r = n.n(o),
267
+ i = require('react'),
268
+ s = n.n(i),
269
+ l = require('react-dom'),
270
+ d = n.n(l),
271
+ c = require('mobx-react'),
272
+ p = require('@babel/runtime/helpers/createClass'),
273
+ u = n.n(p),
274
+ h = require('tslib'),
275
+ m = require('mobx'),
276
+ y = require('antd'),
277
+ f = require('lodash'),
278
+ g = require('@wibetter/json-utils');
279
+ function v(e) {
280
+ return (0, g.objClone)(e);
281
+ }
282
+ function S(e, t) {
283
+ return (0, g.isEqual)(e, t);
284
+ }
285
+ function b(e, t) {
286
+ window.sessionStorage && window.sessionStorage.setItem(e, t);
287
+ }
288
+ var x = (function () {
289
+ function e() {
290
+ this.descriptors = new Map();
291
+ }
292
+ e.getInstance = function () {
293
+ return (e.instance || (e.instance = new e()), e.instance);
294
+ };
295
+ var t = e.prototype;
296
+ return (
297
+ (t.register = function (e) {
298
+ this.descriptors.set(e.type, e);
299
+ }),
300
+ (t.registerAll = function (e) {
301
+ var t = this;
302
+ e.forEach(function (e) {
303
+ return t.register(e);
304
+ });
305
+ }),
306
+ (t.get = function (e) {
307
+ return this.descriptors.get(e);
308
+ }),
309
+ (t.getAllTypes = function () {
310
+ return Array.from(this.descriptors.keys());
311
+ }),
312
+ (t.getAll = function () {
313
+ return Array.from(this.descriptors.values());
314
+ }),
315
+ (t.has = function (e) {
316
+ return this.descriptors.has(e);
317
+ }),
318
+ (t.getDefaultSchema = function (e) {
319
+ var t;
320
+ return null === (t = this.descriptors.get(e)) || void 0 === t
321
+ ? void 0
322
+ : t.defaultSchema;
323
+ }),
324
+ e
325
+ );
326
+ })();
327
+ x.instance = void 0;
328
+ var O = x.getInstance(),
329
+ E = function (e, t) {
330
+ (void 0 === t && (t = !1),
331
+ !O.has(e.type) || t
332
+ ? O.register(e)
333
+ : console.warn(
334
+ '[JSONSchemaEditor] 已存在 ' + e.type + ' 类型的描述:',
335
+ e,
336
+ ));
337
+ },
338
+ C = {
339
+ description: {
340
+ type: 'input',
341
+ title: '字段描述',
342
+ description: '字段描述内容将作为 Title 的补充信息提供给用户',
343
+ placeholder: '请输入字段描述',
344
+ },
345
+ showKey: {
346
+ type: 'boolean',
347
+ title: '展示Key值',
348
+ description:
349
+ '开启后,在 JSONEditor 端会展示当前 Key 值,以便增加辨识度',
350
+ },
351
+ onShow: {
352
+ type: 'input',
353
+ title: '显隐表达式',
354
+ description:
355
+ '设置显隐表达式,例如 "dataType === 1" 表示当 dataType 为 1 时显示当前项',
356
+ placeholder: '请输入显隐表达式',
357
+ },
358
+ titleStyle: {
359
+ type: 'json',
360
+ title: '标题样式',
361
+ description: '可用于设置标题展示样式',
362
+ },
363
+ },
364
+ j = Object.keys(C),
365
+ R = {
366
+ readOnly: {
367
+ type: 'boolean',
368
+ title: '是否只读',
369
+ description: '当前属性设置为只读后,用户不能对其进行任何编辑操作',
370
+ },
371
+ isRequired: {
372
+ type: 'boolean',
373
+ title: '是否必填项',
374
+ description:
375
+ '当前属性设置为必填项后,如果用户没有给其设置数值,则会进行标红提示',
376
+ },
377
+ };
378
+ function I(e) {
379
+ void 0 === e && (e = {});
380
+ var n = Object.keys(e);
381
+ return {
382
+ type: 'object',
383
+ wrapWithPanel: !1,
384
+ properties: t()({}, e, C),
385
+ propertyOrder: [].concat(n, j),
386
+ };
387
+ }
388
+ var N = g.TypeDataList.jsonschema;
389
+ function _() {
390
+ return O.getDefaultSchema('input');
391
+ }
392
+ var K = (function () {
393
+ function e() {
394
+ var e = this;
395
+ ((this.curJsonKeyIndex = 1),
396
+ (this.triggerChange = !1),
397
+ (this.jsonSchema = {}),
398
+ (this.SchemaTypeList = {}),
399
+ (this.onChange = function (e) {}),
400
+ (this.childElemSort = function (t) {
401
+ for (
402
+ var n = (0, g.getSchemaByIndexRoute)(t, e.jsonSchema, !1),
403
+ a = n.propertyOrder,
404
+ o = [],
405
+ r = [],
406
+ i = [],
407
+ s = [],
408
+ l = [],
409
+ d = [],
410
+ c = [],
411
+ p = [],
412
+ u = 0,
413
+ h = a.length;
414
+ u < h;
415
+ u++
416
+ ) {
417
+ var m = a[u];
418
+ switch (n.properties[m].type) {
419
+ case 'input':
420
+ case 'url':
421
+ o.push(m);
422
+ break;
423
+ case 'number':
424
+ case 'quantity':
425
+ r.push(m);
426
+ break;
427
+ case 'radio':
428
+ case 'checkboxes':
429
+ case 'boolean':
430
+ case 'color':
431
+ i.push(m);
432
+ break;
433
+ case 'date':
434
+ case 'date-time':
435
+ case 'time':
436
+ s.push(m);
437
+ break;
438
+ case 'textarea':
439
+ case 'json':
440
+ case 'codearea':
441
+ case 'htmlarea':
442
+ l.push(m);
443
+ break;
444
+ case 'image':
445
+ d.push(m);
446
+ break;
447
+ case 'object':
448
+ case 'array':
449
+ c.push(m);
450
+ break;
451
+ default:
452
+ p.push(m);
453
+ }
454
+ }
455
+ ((n.propertyOrder = [].concat(o, r, i, s, d, l, c, p)),
456
+ e.jsonSchemaChange(!1));
457
+ }),
458
+ (0, m.makeObservable)(this));
459
+ }
460
+ var n = e.prototype;
461
+ return (
462
+ (n.triggerChangeAction = function () {
463
+ this.triggerChange = !this.triggerChange;
464
+ }),
465
+ (n.initSchemaTypeList = function (e) {}),
466
+ (n.initJSONSchemaData = function (e) {
467
+ if (e && '{}' !== JSON.stringify(e)) {
468
+ if (!S(e, this.JSONSchemaObj))
469
+ if (e && (0, g.isNewSchemaData)(e)) this.jsonSchema = e;
470
+ else {
471
+ var t = (0, g.oldSchemaToNewSchema)(e);
472
+ this.jsonSchema = t;
473
+ }
474
+ } else this.jsonSchema = v(N);
475
+ }),
476
+ (n.initOnChange = function (e) {
477
+ var t, n;
478
+ (e ||
479
+ ((t = e),
480
+ (n = !1),
481
+ 'Function' === Object.prototype.toString.call(t).slice(8, -1) &&
482
+ (n = !0),
483
+ n)) &&
484
+ (this.onChange = e);
485
+ }),
486
+ (n.schemaChange = function (e) {
487
+ ((this.jsonSchema = e), this.jsonSchemaChange(!1));
488
+ }),
489
+ (n.jsonSchemaChange = function (e) {
490
+ ((this.jsonSchema.lastUpdateTime = new Date().getTime()),
491
+ e || this.onChange(this.JSONSchemaObj));
492
+ }),
493
+ (n.indexRoute2keyRoute = function (e) {
494
+ return (0, g.indexRoute2keyRoute)(e, this.jsonSchema);
495
+ }),
496
+ (n.keyRoute2indexRoute = function (e) {
497
+ return (0, g.keyRoute2indexRoute)(e, this.jsonSchema);
498
+ }),
499
+ (n.getSchemaByIndexRoute = function (e) {
500
+ return (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !0);
501
+ }),
502
+ (n.getSchemaByKeyRoute = function (e) {
503
+ return (0, g.getSchemaByKeyRoute)(e, this.jsonSchema, !0);
504
+ }),
505
+ (n.getNewJsonKeyIndex = function (e, t) {
506
+ var n = (t || 'field') + '_' + this.curJsonKeyIndex;
507
+ return (
508
+ e.propertyOrder.indexOf(n) >= 0 &&
509
+ ((this.curJsonKeyIndex += 1),
510
+ (n = this.getNewJsonKeyIndex(e, t))),
511
+ (this.curJsonKeyIndex += 1),
512
+ n
513
+ );
514
+ }),
515
+ (n.isExitJsonKey = function (e, t) {
516
+ var n = (0, g.getParentIndexRoute)(e),
517
+ a = this.getSchemaByIndexRoute(n);
518
+ return (
519
+ !!(a.propertyOrder && a.propertyOrder.indexOf(t) >= 0) ||
520
+ (g.KeyWordList &&
521
+ g.KeyWordList.indexOf(t) >= 0 &&
522
+ y.message.warning(
523
+ t +
524
+ '是JSONSchema的关键字,建议您换一个,避免后续出现数据异常。',
525
+ ),
526
+ t &&
527
+ t.indexOf('-') > -1 &&
528
+ y.message.warning(
529
+ t +
530
+ '含特殊字符(‘-’),会影响后续数据获取和更新,建议您换一个数值。',
531
+ ),
532
+ !1)
533
+ );
534
+ }),
535
+ (n.addChildJson = function (e, t) {
536
+ var n = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1),
537
+ a = null == n ? void 0 : n.type,
538
+ o = a ? O.get(a) : void 0;
539
+ if (null != o && o.isContainer) {
540
+ var r = this.getNewJsonKeyIndex(n);
541
+ (n.propertyOrder.push(r),
542
+ (n.properties[r] = _()),
543
+ this.jsonSchemaChange(t));
544
+ } else y.message.warning('非对象类型字段不允许插入子元素');
545
+ }),
546
+ (n.changeType = function (e, t, n, a, o) {
547
+ var r = (0, g.getParentIndexRoute)(e),
548
+ i = (0, g.getSchemaByIndexRoute)(r, this.jsonSchema, !1),
549
+ s = Object.assign(
550
+ {},
551
+ n,
552
+ (0, f.pick)(a, [
553
+ 'title',
554
+ 'description',
555
+ 'showKey',
556
+ 'showCodeViewBtn',
557
+ 'onShow',
558
+ ]),
559
+ );
560
+ (i.properties && i.properties[t]
561
+ ? (i.properties[t] = v(s))
562
+ : i[t] && (i[t] = v(s)),
563
+ this.jsonSchemaChange(o));
564
+ }),
565
+ (n.updateSchemaData = function (e, t, n) {
566
+ var a = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
567
+ (Object.assign(a, v(t)), this.jsonSchemaChange(n));
568
+ }),
569
+ (n.editSchemaData = function (e, n, a, o) {
570
+ var r = (0, g.getParentIndexRoute)(e),
571
+ i = (0, g.getSchemaByIndexRoute)(r, this.jsonSchema, !1);
572
+ ((i.properties[n] = t()({}, v(i.properties[n]), a)),
573
+ this.jsonSchemaChange(o));
574
+ }),
575
+ (n.editJsonKey = function (e, t, n) {
576
+ var a = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !0);
577
+ (this.insertJsonData(e, t, a, '', !0),
578
+ this.deleteJsonByIndex(e, !0),
579
+ this.jsonSchemaChange(n));
580
+ }),
581
+ (n.addNextJsonData = function (e) {
582
+ var t = (0, g.getParentIndexRoute)(e),
583
+ n = (0, g.getSchemaByIndexRoute)(t, this.jsonSchema, !1),
584
+ a = this.getNewJsonKeyIndex(n);
585
+ this.insertJsonData(e, a, _(), '', !1);
586
+ }),
587
+ (n.insertJsonData = function (e, t, n, a, o) {
588
+ var r = (0, g.getParentIndexRoute_CurIndex)(e),
589
+ i = r[0] || '',
590
+ s = r[1],
591
+ l = (0, g.getSchemaByIndexRoute)(i, this.jsonSchema, !1);
592
+ l.properties[t] = n;
593
+ var d = l.propertyOrder,
594
+ c = 'before' === a ? Number(s) : Number(s) + 1,
595
+ p = d.slice(0, c),
596
+ u = d.slice(c);
597
+ ((l.propertyOrder = [].concat(p, [t], u)),
598
+ this.jsonSchemaChange(o));
599
+ }),
600
+ (n.deleteJsonByIndex_CurKey = function (e, t, n) {
601
+ var a = (0, g.getParentIndexRoute)(e),
602
+ o = (0, g.getSchemaByIndexRoute)(a, this.jsonSchema, !1);
603
+ delete o.properties[t];
604
+ var r = o.propertyOrder.indexOf(t);
605
+ (o.propertyOrder.splice(r, 1), this.jsonSchemaChange(n));
606
+ }),
607
+ (n.deleteJsonByIndex = function (e, t) {
608
+ var n = (0, g.getParentIndexRoute_CurIndex)(e),
609
+ a = n[0] || '',
610
+ o = n[1],
611
+ r = (0, g.getSchemaByIndexRoute)(a, this.jsonSchema, !1),
612
+ i = r.propertyOrder[o];
613
+ delete r.properties[i];
614
+ var s = r.propertyOrder.indexOf(i);
615
+ (r.propertyOrder.splice(s, 1), this.jsonSchemaChange(t));
616
+ }),
617
+ (n.updateEnumItem = function (e, t, n, a, o) {
618
+ var r = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
619
+ (r.enum && r.enumextra && ((r.enum[t] = n), (r.enumextra[t] = a)),
620
+ this.jsonSchemaChange(o));
621
+ }),
622
+ (n.isExitEnumKey = function (e, t, n) {
623
+ var a = !1,
624
+ o = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
625
+ if (o.enum) {
626
+ var r = v(o.enum);
627
+ (t >= 0 && r.splice(t, 1), r.indexOf(n) >= 0 && (a = !0));
628
+ }
629
+ return (
630
+ g.KeyWordList &&
631
+ g.KeyWordList.indexOf(n) >= 0 &&
632
+ y.message.warning(
633
+ n +
634
+ '是JSONSchema的关键字,建议您换一个,避免后续出现数据异常。',
635
+ ),
636
+ a
637
+ );
638
+ }),
639
+ (n.updateEnumKey = function (e, t, n, a) {
640
+ var o = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
641
+ (o.enum && (o.enum[t] = n), this.jsonSchemaChange(a));
642
+ }),
643
+ (n.updateEnumText = function (e, t, n, a) {
644
+ var o = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
645
+ (o.enumextra && (o.enumextra[t] = n), this.jsonSchemaChange(a));
646
+ }),
647
+ (n.deleteEnumItem = function (e, t, n) {
648
+ var a = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
649
+ (a.enum &&
650
+ a.enumextra &&
651
+ (a.enum.splice(t, 1), a.enumextra.splice(t, 1)),
652
+ this.jsonSchemaChange(n));
653
+ }),
654
+ (n.insertEnumItem = function (e, t, n, a, o, r) {
655
+ var i = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
656
+ if (i.enum && i.enumextra) {
657
+ var s = 'before' === o ? Number(t) : Number(t) + 1,
658
+ l = i.enum.slice(0, s),
659
+ d = i.enum.slice(s);
660
+ i.enum = [].concat(l, [n], d);
661
+ var c = i.enumextra.slice(0, s),
662
+ p = i.enumextra.slice(s);
663
+ i.enumextra = [].concat(c, [a], p);
664
+ }
665
+ this.jsonSchemaChange(r);
666
+ }),
667
+ (n.getNewEnumIndex = function (e, t) {
668
+ var n = (t || 'enum') + '_' + this.curJsonKeyIndex;
669
+ return (
670
+ e.indexOf(n) >= 0 &&
671
+ ((this.curJsonKeyIndex += 1),
672
+ (n = this.getNewEnumIndex(e, t))),
673
+ (this.curJsonKeyIndex += 1),
674
+ n
675
+ );
676
+ }),
677
+ (n.addEnumItem = function (e, t) {
678
+ var n = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
679
+ if (n.enum) {
680
+ var a = this.getNewEnumIndex(n.enum),
681
+ o = '选项' + (this.curJsonKeyIndex - 1);
682
+ this.insertEnumItem(e, t, a, o, '', !1);
683
+ }
684
+ }),
685
+ (n.copyEnumItem = function (e, t) {
686
+ var n = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
687
+ if (n.enum) {
688
+ var a = n.enum[t],
689
+ o = n.enumextra[t],
690
+ r = this.getNewEnumIndex(n.enum, a),
691
+ i = o + '_' + (this.curJsonKeyIndex - 1);
692
+ this.insertEnumItem(e, t, r, i, '', !1);
693
+ }
694
+ }),
695
+ (n.updateOptionItem = function (e, t, n, a, o) {
696
+ var r = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
697
+ (r.options &&
698
+ r.options[t] &&
699
+ ((r.options[t].label = n), (r.options[t].value = a)),
700
+ this.jsonSchemaChange(o));
701
+ }),
702
+ (n.isExitOptionLabel = function (e, t) {
703
+ var n = !1,
704
+ a = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
705
+ return (
706
+ a.options &&
707
+ a.options.find(function (e) {
708
+ return e.label === t;
709
+ }) &&
710
+ (n = !0),
711
+ g.KeyWordList &&
712
+ g.KeyWordList.indexOf(t) >= 0 &&
713
+ y.message.warning(
714
+ t + '是JSONSchema的保留关键字,建议您换一个名称。',
715
+ ),
716
+ n
717
+ );
718
+ }),
719
+ (n.updateOptionLabel = function (e, t, n, a) {
720
+ var o = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
721
+ (o.options && o.options[t] && (o.options[t].label = n),
722
+ this.jsonSchemaChange(a));
723
+ }),
724
+ (n.updateOptionValue = function (e, t, n, a) {
725
+ var o = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
726
+ (o.options && o.options[t] && (o.options[t].value = n),
727
+ this.jsonSchemaChange(a));
728
+ }),
729
+ (n.deleteOptionItem = function (e, t, n) {
730
+ var a = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
731
+ (a.options && a.options[t] && a.options.splice(t, 1),
732
+ this.jsonSchemaChange(n));
733
+ }),
734
+ (n.insertOption = function (e, t, n, a, o, r) {
735
+ var i = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
736
+ if (i.options) {
737
+ var s = 'before' === o ? Number(t) : Number(t) + 1,
738
+ l = i.options.slice(0, s),
739
+ d = i.options.slice(s),
740
+ c = { label: n, value: a };
741
+ i.options = [].concat(l, [c], d);
742
+ }
743
+ this.jsonSchemaChange(r);
744
+ }),
745
+ (n.getNewOptionValue = function (e) {
746
+ return e && e.length > 0
747
+ ? e[e.length - 1].value + '_' + (e.length + 1)
748
+ : 'value1';
749
+ }),
750
+ (n.addOptionItem = function (e, t) {
751
+ var n = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
752
+ if (n.options) {
753
+ var a = this.getNewOptionValue(n.options),
754
+ o = '选项' + (n.options.length + 1);
755
+ this.insertOption(e, t, o, a, '', !1);
756
+ }
757
+ }),
758
+ (n.copyOptionItem = function (e, t) {
759
+ var n = (0, g.getSchemaByIndexRoute)(e, this.jsonSchema, !1);
760
+ if (n.options) {
761
+ var a = n.options[t],
762
+ o = this.getNewOptionValue(n.options),
763
+ r = (a.label || a.name) + '_copy';
764
+ this.insertOption(e, t, r, o, '', !1);
765
+ }
766
+ }),
767
+ u()(e, [
768
+ {
769
+ key: 'JSONSchemaObj',
770
+ get: function () {
771
+ return (0, m.toJS)(this.jsonSchema);
772
+ },
773
+ },
774
+ ])
775
+ );
776
+ })();
777
+ ((0, h.__decorate)(
778
+ [m.observable],
779
+ K.prototype,
780
+ 'triggerChange',
781
+ void 0,
782
+ ),
783
+ (0, h.__decorate)([m.observable], K.prototype, 'jsonSchema', void 0),
784
+ (0, h.__decorate)(
785
+ [m.observable],
786
+ K.prototype,
787
+ 'SchemaTypeList',
788
+ void 0,
789
+ ),
790
+ (0, h.__decorate)([m.observable], K.prototype, 'onChange', void 0),
791
+ (0, h.__decorate)(
792
+ [m.action.bound],
793
+ K.prototype,
794
+ 'triggerChangeAction',
795
+ null,
796
+ ),
797
+ (0, h.__decorate)(
798
+ [m.action.bound],
799
+ K.prototype,
800
+ 'initSchemaTypeList',
801
+ null,
802
+ ),
803
+ (0, h.__decorate)(
804
+ [m.action.bound],
805
+ K.prototype,
806
+ 'initJSONSchemaData',
807
+ null,
808
+ ),
809
+ (0, h.__decorate)([m.computed], K.prototype, 'JSONSchemaObj', null),
810
+ (0, h.__decorate)(
811
+ [m.action.bound],
812
+ K.prototype,
813
+ 'initOnChange',
814
+ null,
815
+ ),
816
+ (0, h.__decorate)(
817
+ [m.action.bound],
818
+ K.prototype,
819
+ 'schemaChange',
820
+ null,
821
+ ),
822
+ (0, h.__decorate)(
823
+ [m.action.bound],
824
+ K.prototype,
825
+ 'jsonSchemaChange',
826
+ null,
827
+ ),
828
+ (0, h.__decorate)(
829
+ [m.action.bound],
830
+ K.prototype,
831
+ 'indexRoute2keyRoute',
832
+ null,
833
+ ),
834
+ (0, h.__decorate)(
835
+ [m.action.bound],
836
+ K.prototype,
837
+ 'keyRoute2indexRoute',
838
+ null,
839
+ ),
840
+ (0, h.__decorate)(
841
+ [m.action.bound],
842
+ K.prototype,
843
+ 'getSchemaByIndexRoute',
844
+ null,
845
+ ),
846
+ (0, h.__decorate)(
847
+ [m.action.bound],
848
+ K.prototype,
849
+ 'getSchemaByKeyRoute',
850
+ null,
851
+ ),
852
+ (0, h.__decorate)(
853
+ [m.action.bound],
854
+ K.prototype,
855
+ 'getNewJsonKeyIndex',
856
+ null,
857
+ ),
858
+ (0, h.__decorate)(
859
+ [m.action.bound],
860
+ K.prototype,
861
+ 'isExitJsonKey',
862
+ null,
863
+ ),
864
+ (0, h.__decorate)(
865
+ [m.action.bound],
866
+ K.prototype,
867
+ 'addChildJson',
868
+ null,
869
+ ),
870
+ (0, h.__decorate)([m.action.bound], K.prototype, 'changeType', null),
871
+ (0, h.__decorate)(
872
+ [m.action.bound],
873
+ K.prototype,
874
+ 'updateSchemaData',
875
+ null,
876
+ ),
877
+ (0, h.__decorate)(
878
+ [m.action.bound],
879
+ K.prototype,
880
+ 'editSchemaData',
881
+ null,
882
+ ),
883
+ (0, h.__decorate)([m.action.bound], K.prototype, 'editJsonKey', null),
884
+ (0, h.__decorate)(
885
+ [m.action.bound],
886
+ K.prototype,
887
+ 'addNextJsonData',
888
+ null,
889
+ ),
890
+ (0, h.__decorate)(
891
+ [m.action.bound],
892
+ K.prototype,
893
+ 'insertJsonData',
894
+ null,
895
+ ),
896
+ (0, h.__decorate)(
897
+ [m.action.bound],
898
+ K.prototype,
899
+ 'deleteJsonByIndex_CurKey',
900
+ null,
901
+ ),
902
+ (0, h.__decorate)(
903
+ [m.action.bound],
904
+ K.prototype,
905
+ 'deleteJsonByIndex',
906
+ null,
907
+ ),
908
+ (0, h.__decorate)(
909
+ [m.action.bound],
910
+ K.prototype,
911
+ 'updateEnumItem',
912
+ null,
913
+ ),
914
+ (0, h.__decorate)(
915
+ [m.action.bound],
916
+ K.prototype,
917
+ 'isExitEnumKey',
918
+ null,
919
+ ),
920
+ (0, h.__decorate)(
921
+ [m.action.bound],
922
+ K.prototype,
923
+ 'updateEnumKey',
924
+ null,
925
+ ),
926
+ (0, h.__decorate)(
927
+ [m.action.bound],
928
+ K.prototype,
929
+ 'updateEnumText',
930
+ null,
931
+ ),
932
+ (0, h.__decorate)(
933
+ [m.action.bound],
934
+ K.prototype,
935
+ 'deleteEnumItem',
936
+ null,
937
+ ),
938
+ (0, h.__decorate)(
939
+ [m.action.bound],
940
+ K.prototype,
941
+ 'insertEnumItem',
942
+ null,
943
+ ),
944
+ (0, h.__decorate)(
945
+ [m.action.bound],
946
+ K.prototype,
947
+ 'getNewEnumIndex',
948
+ null,
949
+ ),
950
+ (0, h.__decorate)([m.action.bound], K.prototype, 'addEnumItem', null),
951
+ (0, h.__decorate)(
952
+ [m.action.bound],
953
+ K.prototype,
954
+ 'copyEnumItem',
955
+ null,
956
+ ),
957
+ (0, h.__decorate)(
958
+ [m.action.bound],
959
+ K.prototype,
960
+ 'updateOptionItem',
961
+ null,
962
+ ),
963
+ (0, h.__decorate)(
964
+ [m.action.bound],
965
+ K.prototype,
966
+ 'isExitOptionLabel',
967
+ null,
968
+ ),
969
+ (0, h.__decorate)(
970
+ [m.action.bound],
971
+ K.prototype,
972
+ 'updateOptionLabel',
973
+ null,
974
+ ),
975
+ (0, h.__decorate)(
976
+ [m.action.bound],
977
+ K.prototype,
978
+ 'updateOptionValue',
979
+ null,
980
+ ),
981
+ (0, h.__decorate)(
982
+ [m.action.bound],
983
+ K.prototype,
984
+ 'deleteOptionItem',
985
+ null,
986
+ ),
987
+ (0, h.__decorate)(
988
+ [m.action.bound],
989
+ K.prototype,
990
+ 'insertOption',
991
+ null,
992
+ ),
993
+ (0, h.__decorate)(
994
+ [m.action.bound],
995
+ K.prototype,
996
+ 'getNewOptionValue',
997
+ null,
998
+ ),
999
+ (0, h.__decorate)(
1000
+ [m.action.bound],
1001
+ K.prototype,
1002
+ 'addOptionItem',
1003
+ null,
1004
+ ),
1005
+ (0, h.__decorate)(
1006
+ [m.action.bound],
1007
+ K.prototype,
1008
+ 'copyOptionItem',
1009
+ null,
1010
+ ),
1011
+ (0, h.__decorate)(
1012
+ [m.action.bound],
1013
+ K.prototype,
1014
+ 'childElemSort',
1015
+ void 0,
1016
+ ));
1017
+ var w = { schemaStore: K },
1018
+ J = require('@babel/runtime/helpers/objectWithoutPropertiesLoose'),
1019
+ B = n.n(J),
1020
+ T = require('@ant-design/icons'),
1021
+ k = require('@wibetter/json-editor'),
1022
+ q = n.n(k),
1023
+ D = (function (e) {
1024
+ function t() {
1025
+ return e.apply(this, arguments) || this;
1026
+ }
1027
+ return (
1028
+ r()(t, e),
1029
+ (t.prototype.render = function () {
1030
+ var e = this.props,
1031
+ t = e.indexRoute,
1032
+ n = e.jsonKey,
1033
+ a = e.targetJsonSchema,
1034
+ o = (this.props.schemaStore || {}).editSchemaData,
1035
+ r = null == a ? void 0 : a.type;
1036
+ if (!r || !a)
1037
+ return i.createElement(
1038
+ 'div',
1039
+ { className: 'advance-config-empty' },
1040
+ '暂无高级配置',
1041
+ );
1042
+ var s = O.get(r),
1043
+ l = null == s ? void 0 : s.propsSchema;
1044
+ return l && 0 !== Object.keys(l.properties || {}).length
1045
+ ? i.createElement(
1046
+ 'div',
1047
+ { className: 'advance-config-model' },
1048
+ i.createElement(q(), {
1049
+ wideScreen: !0,
1050
+ schemaData: l,
1051
+ jsonData: a,
1052
+ onChange: function (e) {
1053
+ if (e && o) {
1054
+ var a = {};
1055
+ (Object.keys(l.properties || {}).forEach(
1056
+ function (t) {
1057
+ void 0 !== e[t] && (a[t] = e[t]);
1058
+ },
1059
+ ),
1060
+ o(t, n, a));
1061
+ }
1062
+ },
1063
+ }),
1064
+ )
1065
+ : i.createElement(
1066
+ 'div',
1067
+ { className: 'advance-config-empty' },
1068
+ '当前类型暂无高级配置',
1069
+ );
1070
+ }),
1071
+ t
1072
+ );
1073
+ })(i.PureComponent),
1074
+ A = (0, c.inject)(function (e) {
1075
+ return { schemaStore: e.schemaStore };
1076
+ })((0, c.observer)(D)),
1077
+ L = (n(915), y.Select.Option),
1078
+ F = (function (e) {
1079
+ function t(t) {
1080
+ var n;
1081
+ return (
1082
+ ((n = e.call(this, t) || this).handleTypeChange = function (e) {
1083
+ var t = (n.props.schemaStore || {}).changeType,
1084
+ a = n.props,
1085
+ o = a.indexRoute,
1086
+ r = a.jsonKey,
1087
+ i = a.targetJsonSchema;
1088
+ i.type !== e && t(o, r, O.getDefaultSchema(e), i);
1089
+ }),
1090
+ (n.handleJsonKeyChange = function (e) {
1091
+ var t = n.props.schemaStore || {},
1092
+ a = t.editJsonKey,
1093
+ o = t.isExitJsonKey,
1094
+ r = e.target.value,
1095
+ i = n.props,
1096
+ s = i.indexRoute;
1097
+ i.jsonKey !== r &&
1098
+ (o(s, r)
1099
+ ? y.message.warning('当前key已存在,请换一个吧。')
1100
+ : a(s, r));
1101
+ }),
1102
+ (n.handleTitleChange = function (e) {
1103
+ var t = (n.props.schemaStore || {}).editSchemaData,
1104
+ a = e.target.value,
1105
+ o = n.props,
1106
+ r = o.indexRoute,
1107
+ i = o.jsonKey;
1108
+ o.targetJsonSchema.title !== a && t(r, i, { title: a });
1109
+ }),
1110
+ (n.getAllTypeList = function () {
1111
+ return O.getAllTypes();
1112
+ }),
1113
+ (n.onAddBtnEvent = function () {
1114
+ var e = n.props.schemaStore || {},
1115
+ t = e.addChildJson,
1116
+ a = e.addNextJsonData,
1117
+ o = n.props,
1118
+ r = o.indexRoute,
1119
+ i = o.targetJsonSchema,
1120
+ s = null == i ? void 0 : i.type,
1121
+ l = s ? O.get(s) : void 0;
1122
+ null != l && l.isContainer ? t(r) : a(r);
1123
+ }),
1124
+ (n.onCopyBtnEvent = function () {
1125
+ var e = n.props,
1126
+ t = e.indexRoute,
1127
+ a = e.targetJsonSchema,
1128
+ o = e.jsonKey,
1129
+ r = n.props.schemaStore || {},
1130
+ i = r.getSchemaByIndexRoute,
1131
+ s = r.indexRoute2keyRoute,
1132
+ l = r.insertJsonData,
1133
+ d = r.getNewJsonKeyIndex,
1134
+ c = v(a),
1135
+ p = (0, g.getParentIndexRoute)(t),
1136
+ u = d(i(p), o),
1137
+ h = a.type;
1138
+ (b(s(p) + '-' + u + '-' + h, s(t)), l(t, u, c));
1139
+ }),
1140
+ (n.onDeleteBtnEvent = function () {
1141
+ var e = n.props,
1142
+ t = e.jsonKey,
1143
+ a = e.indexRoute;
1144
+ (0, (n.props.schemaStore || {}).deleteJsonByIndex_CurKey)(
1145
+ a,
1146
+ t,
1147
+ );
1148
+ }),
1149
+ (n.ignoreDragEvent = function (e) {
1150
+ (e.preventDefault(), e.stopPropagation());
1151
+ }),
1152
+ (n.childElemSort = function () {
1153
+ var e = n.props.indexRoute;
1154
+ (0, (n.props.schemaStore || {}).childElemSort)(e);
1155
+ }),
1156
+ (n.state = { showAdvanceConfig: !1 }),
1157
+ (n.onAddBtnEvent = n.onAddBtnEvent.bind(n)),
1158
+ (n.onCopyBtnEvent = n.onCopyBtnEvent.bind(n)),
1159
+ (n.onDeleteBtnEvent = n.onDeleteBtnEvent.bind(n)),
1160
+ (n.handleJsonKeyChange = n.handleJsonKeyChange.bind(n)),
1161
+ (n.handleTitleChange = n.handleTitleChange.bind(n)),
1162
+ (n.handleTypeChange = n.handleTypeChange.bind(n)),
1163
+ (n.childElemSort = n.childElemSort.bind(n)),
1164
+ n
1165
+ );
1166
+ }
1167
+ return (
1168
+ r()(t, e),
1169
+ (t.prototype.render = function () {
1170
+ var e,
1171
+ t,
1172
+ n = this,
1173
+ a = (this.props.schemaStore || {}).getSchemaByIndexRoute,
1174
+ o = this.props,
1175
+ r = (o.parentType, o.indexRoute),
1176
+ s = o.jsonKey,
1177
+ l = o.nodeKey,
1178
+ d = o.targetJsonSchema,
1179
+ c = this.state.showAdvanceConfig,
1180
+ p = r ? (0, g.getParentIndexRoute)(r) : '',
1181
+ u = p ? a(p) : {},
1182
+ h = null === (e = u && u.isContainer) || void 0 === e || e,
1183
+ m = null == d ? void 0 : d.type,
1184
+ f = m ? O.get(m) : void 0,
1185
+ v = (null == f ? void 0 : f.isFixed) || !1,
1186
+ S =
1187
+ (null == f || f.readOnly,
1188
+ void 0 !== this.props.keyIsFixed
1189
+ ? this.props.keyIsFixed
1190
+ : void 0 !== (null == f ? void 0 : f.keyIsFixed)
1191
+ ? f.keyIsFixed
1192
+ : !h || v),
1193
+ b =
1194
+ void 0 !== this.props.typeIsFixed
1195
+ ? this.props.typeIsFixed
1196
+ : void 0 !== (null == f ? void 0 : f.typeIsFixed)
1197
+ ? f.typeIsFixed
1198
+ : v,
1199
+ x =
1200
+ void 0 !== this.props.titleIsFixed
1201
+ ? this.props.titleIsFixed
1202
+ : void 0 !== (null == f ? void 0 : f.titleIsFixed)
1203
+ ? f.titleIsFixed
1204
+ : v,
1205
+ E =
1206
+ void 0 !== this.props.hideOperaBtn
1207
+ ? this.props.hideOperaBtn
1208
+ : void 0 !== (null == f ? void 0 : f.hideOperaBtn)
1209
+ ? f.hideOperaBtn
1210
+ : !h,
1211
+ C =
1212
+ void 0 !== this.props.showAdvanceBtn
1213
+ ? this.props.showAdvanceBtn
1214
+ : void 0 === (null == f ? void 0 : f.showAdvanceBtn) ||
1215
+ f.showAdvanceBtn,
1216
+ j = this.getAllTypeList(),
1217
+ R =
1218
+ null !== (t = null == f ? void 0 : f.isContainer) &&
1219
+ void 0 !== t &&
1220
+ t;
1221
+ return i.createElement(
1222
+ i.Fragment,
1223
+ null,
1224
+ d &&
1225
+ i.createElement(
1226
+ 'div',
1227
+ { className: 'base-schema-box', id: l },
1228
+ i.createElement(
1229
+ 'div',
1230
+ {
1231
+ className: 'key-input-item',
1232
+ draggable: 'true',
1233
+ onDragStart: this.ignoreDragEvent,
1234
+ },
1235
+ i.createElement(y.Input, {
1236
+ defaultValue: s || 'key值不存在',
1237
+ disabled: S,
1238
+ onBlur: this.handleJsonKeyChange,
1239
+ }),
1240
+ ),
1241
+ i.createElement(
1242
+ 'div',
1243
+ {
1244
+ className: 'type-select-item',
1245
+ draggable: 'true',
1246
+ onDragStart: this.ignoreDragEvent,
1247
+ },
1248
+ i.createElement(
1249
+ y.Select,
1250
+ {
1251
+ showSearch: !0,
1252
+ defaultValue: m,
1253
+ style: { width: 150 },
1254
+ onChange: this.handleTypeChange,
1255
+ disabled: b,
1256
+ filterOption: function (e, t) {
1257
+ return !!(
1258
+ (t && t.value.indexOf(e) > -1) ||
1259
+ (t.children && t.children.indexOf(e) > -1)
1260
+ );
1261
+ },
1262
+ },
1263
+ j.map(function (e) {
1264
+ var t;
1265
+ return i.createElement(
1266
+ L,
1267
+ { key: e, value: e },
1268
+ (null === (t = O.get(e)) || void 0 === t
1269
+ ? void 0
1270
+ : t.label) || e,
1271
+ );
1272
+ }),
1273
+ ),
1274
+ ),
1275
+ i.createElement(
1276
+ 'div',
1277
+ {
1278
+ className: 'title-input-item',
1279
+ draggable: 'true',
1280
+ onDragStart: this.ignoreDragEvent,
1281
+ },
1282
+ i.createElement(y.Input, {
1283
+ defaultValue: d.title,
1284
+ disabled: x,
1285
+ onBlur: this.handleTitleChange,
1286
+ }),
1287
+ ),
1288
+ i.createElement(
1289
+ 'div',
1290
+ { className: 'operate-item' },
1291
+ !E &&
1292
+ i.createElement(
1293
+ i.Fragment,
1294
+ null,
1295
+ !v &&
1296
+ i.createElement(
1297
+ y.Tooltip,
1298
+ { title: '删除' },
1299
+ i.createElement(T.CloseOutlined, {
1300
+ className: 'operate-btn delete-operate',
1301
+ onClick: this.onDeleteBtnEvent,
1302
+ }),
1303
+ ),
1304
+ i.createElement(
1305
+ y.Tooltip,
1306
+ { title: R ? '新增子元素' : '新增同级元素' },
1307
+ i.createElement(T.PlusOutlined, {
1308
+ className: 'operate-btn',
1309
+ onClick: this.onAddBtnEvent,
1310
+ }),
1311
+ ),
1312
+ R &&
1313
+ i.createElement(
1314
+ y.Tooltip,
1315
+ { title: '数据项排序' },
1316
+ i.createElement(T.SortAscendingOutlined, {
1317
+ className: 'operate-btn',
1318
+ onClick: this.childElemSort,
1319
+ }),
1320
+ ),
1321
+ !v &&
1322
+ i.createElement(
1323
+ i.Fragment,
1324
+ null,
1325
+ i.createElement(
1326
+ y.Tooltip,
1327
+ { title: '复制' },
1328
+ i.createElement(T.CopyOutlined, {
1329
+ className: 'operate-btn',
1330
+ onClick: this.onCopyBtnEvent,
1331
+ }),
1332
+ ),
1333
+ i.createElement(
1334
+ y.Tooltip,
1335
+ { title: '按住进行拖拽' },
1336
+ i.createElement(T.DragOutlined, {
1337
+ className: 'operate-btn drag-btn',
1338
+ }),
1339
+ ),
1340
+ ),
1341
+ ),
1342
+ C &&
1343
+ i.createElement(
1344
+ y.Tooltip,
1345
+ { title: '高级设置' },
1346
+ i.createElement(T.SettingOutlined, {
1347
+ className: 'operate-btn',
1348
+ onClick: function () {
1349
+ n.setState({ showAdvanceConfig: !0 });
1350
+ },
1351
+ }),
1352
+ ),
1353
+ ),
1354
+ c &&
1355
+ i.createElement(
1356
+ y.Modal,
1357
+ {
1358
+ open: !0,
1359
+ title:
1360
+ '高级设置 / 当前字段:' + d.title + '(' + s + ')',
1361
+ width: 800,
1362
+ onCancel: function () {
1363
+ n.setState({ showAdvanceConfig: !1 });
1364
+ },
1365
+ footer: [
1366
+ i.createElement(
1367
+ y.Button,
1368
+ {
1369
+ key: 'submit',
1370
+ type: 'primary',
1371
+ onClick: function () {
1372
+ n.setState({ showAdvanceConfig: !1 });
1373
+ },
1374
+ },
1375
+ '保存并关闭',
1376
+ ),
1377
+ ],
1378
+ },
1379
+ i.createElement(A, {
1380
+ indexRoute: r,
1381
+ jsonKey: s,
1382
+ targetJsonSchema: d,
1383
+ }),
1384
+ ),
1385
+ ),
1386
+ !d &&
1387
+ i.createElement(
1388
+ 'div',
1389
+ { className: 'base-schema-box' },
1390
+ i.createElement(
1391
+ 'div',
1392
+ { className: 'warn-text' },
1393
+ s,
1394
+ ':数据元素为空',
1395
+ ),
1396
+ ),
1397
+ );
1398
+ }),
1399
+ t
1400
+ );
1401
+ })(i.PureComponent),
1402
+ P = (0, c.inject)(function (e) {
1403
+ return { schemaStore: e.schemaStore };
1404
+ })((0, c.observer)(F)),
1405
+ V = y.Tree.TreeNode,
1406
+ M = function (e) {
1407
+ return s().createElement(P, t()({}, e));
1408
+ },
1409
+ W = function (e) {
1410
+ var t = e.jsonKey,
1411
+ n = e.indexRoute,
1412
+ a = e.nodeKey,
1413
+ o = e.targetJsonSchema.type;
1414
+ return s().createElement(V, {
1415
+ className: o + '-schema schema-item-form',
1416
+ id: a,
1417
+ key: a,
1418
+ 'data-indexRoute': n,
1419
+ 'data-jsonKey': t,
1420
+ title: M(e),
1421
+ });
1422
+ },
1423
+ U = function (e) {
1424
+ var t = e.targetJsonSchema,
1425
+ n = t.type,
1426
+ a = O.get(n);
1427
+ return a && a.renderer
1428
+ ? a.renderer(e)
1429
+ : t.properties && Object.keys(t.properties).length > 0
1430
+ ? Z(e)
1431
+ : W(e);
1432
+ },
1433
+ z = [
1434
+ 'propertyOrder',
1435
+ 'properties',
1436
+ 'parentIndexRoute',
1437
+ 'parentNodeKey',
1438
+ 'parentType',
1439
+ 'isOnlyShowChild',
1440
+ ],
1441
+ G = y.Tree.TreeNode,
1442
+ H = function (e) {
1443
+ return s().createElement(P, t()({}, e));
1444
+ },
1445
+ Z = function (e) {
1446
+ var n,
1447
+ a,
1448
+ o,
1449
+ r,
1450
+ i,
1451
+ l,
1452
+ d,
1453
+ c = e.jsonKey,
1454
+ p = e.indexRoute,
1455
+ u = e.nodeKey,
1456
+ h = e.targetJsonSchema,
1457
+ m = e.isOnlyShowChild,
1458
+ y = h.type,
1459
+ f = O.get(y),
1460
+ g = null == f ? void 0 : f.isFixed,
1461
+ v =
1462
+ ((a = (n = t()({}, e, {
1463
+ propertyOrder: h.propertyOrder,
1464
+ properties: h.properties,
1465
+ parentIndexRoute: p,
1466
+ parentNodeKey: u,
1467
+ parentType: y,
1468
+ isOnlyShowChild: m,
1469
+ })).propertyOrder),
1470
+ (o = n.properties),
1471
+ (r = n.parentIndexRoute),
1472
+ (i = n.parentNodeKey),
1473
+ (l = n.parentType),
1474
+ n.isOnlyShowChild,
1475
+ (d = B()(n, z)),
1476
+ a.map(function (e, n) {
1477
+ var a = r ? r + '-' + n : '' + n,
1478
+ s = e,
1479
+ c = o[s],
1480
+ p = c.type,
1481
+ u = (i ? i + '-' : '') + p + '-' + s;
1482
+ return U(
1483
+ t()({}, d, {
1484
+ parentType: l,
1485
+ jsonKey: s,
1486
+ indexRoute: a,
1487
+ key: u,
1488
+ nodeKey: u,
1489
+ targetJsonSchema: c,
1490
+ }),
1491
+ );
1492
+ })),
1493
+ S = s().createElement(
1494
+ G,
1495
+ {
1496
+ className: y + '-schema schema-item-form',
1497
+ id: u,
1498
+ key: u,
1499
+ 'data-indexRoute': p,
1500
+ 'data-jsonKey': c,
1501
+ disabled: g,
1502
+ title: H(t()({}, e)),
1503
+ },
1504
+ v,
1505
+ );
1506
+ return m ? v : S;
1507
+ },
1508
+ X = require('react-ace'),
1509
+ Q = n.n(X),
1510
+ Y =
1511
+ (require('ace-builds/src-noconflict/mode-json'),
1512
+ require('ace-builds/src-noconflict/theme-solarized_light'),
1513
+ n(40),
1514
+ (function (e) {
1515
+ function t(t) {
1516
+ var n;
1517
+ return (
1518
+ ((n = e.call(this, t) || this).handleValueChange = function (
1519
+ e,
1520
+ ) {
1521
+ n.props.onChange &&
1522
+ (0, g.isFunction)(n.props.onChange) &&
1523
+ n.props.onChange(e);
1524
+ }),
1525
+ (n.state = {
1526
+ isShowWarn: !1,
1527
+ warnText: '',
1528
+ curJSONDataTemp: void 0,
1529
+ }),
1530
+ (n.handleValueChange = n.handleValueChange.bind(n)),
1531
+ n
1532
+ );
1533
+ }
1534
+ return (
1535
+ r()(t, e),
1536
+ (t.prototype.render = function () {
1537
+ var e = this,
1538
+ t = this.props,
1539
+ n = t.jsonData,
1540
+ a = t.readOnly,
1541
+ o = t.maxLines,
1542
+ r = n || {},
1543
+ s = this.state,
1544
+ l = s.isShowWarn,
1545
+ d = s.warnText,
1546
+ c = (s.curJSONDataTemp, a || !1);
1547
+ return (
1548
+ (r = void 0 !== r ? r : r || '{}'),
1549
+ ((0, g.isObject)(r) || (0, g.isArray)(r)) &&
1550
+ (r = JSON.stringify(r, null, 2)),
1551
+ i.createElement(
1552
+ 'div',
1553
+ { className: 'json-view-box' },
1554
+ c &&
1555
+ i.createElement(
1556
+ 'div',
1557
+ { className: 'readOnly-btn' },
1558
+ '[只读]',
1559
+ ),
1560
+ l &&
1561
+ i.createElement(
1562
+ 'div',
1563
+ { className: 'warning-box code-area-item' },
1564
+ i.createElement(
1565
+ 'div',
1566
+ { className: 'warning-img' },
1567
+ 'X',
1568
+ ),
1569
+ i.createElement(
1570
+ 'div',
1571
+ { className: 'warning-text' },
1572
+ d,
1573
+ ),
1574
+ ),
1575
+ i.createElement(Q(), {
1576
+ key: 'json_area_ace',
1577
+ defaultValue: r,
1578
+ className: 'json-view-ace',
1579
+ mode: 'json',
1580
+ theme: 'solarized_light',
1581
+ name: 'JSON_CODE_EDIT',
1582
+ fontSize: 14,
1583
+ showPrintMargin: !0,
1584
+ showGutter: !0,
1585
+ highlightActiveLine: !0,
1586
+ readOnly: c,
1587
+ minLines: 5,
1588
+ maxLines: o || 10,
1589
+ width: '100%',
1590
+ setOptions: {
1591
+ useWorker: !1,
1592
+ showLineNumbers: !0,
1593
+ tabSize: 2,
1594
+ },
1595
+ onChange: function (t) {
1596
+ try {
1597
+ var n = JSON.parse(t);
1598
+ (e.handleValueChange(n),
1599
+ e.setState({
1600
+ isShowWarn: !1,
1601
+ curJSONDataTemp: void 0,
1602
+ }));
1603
+ } catch (n) {
1604
+ e.setState({
1605
+ curJSONDataTemp: t,
1606
+ warnText: n.message,
1607
+ isShowWarn: !0,
1608
+ });
1609
+ }
1610
+ },
1611
+ }),
1612
+ )
1613
+ );
1614
+ }),
1615
+ t
1616
+ );
1617
+ })(i.PureComponent)),
1618
+ $ =
1619
+ (n(23),
1620
+ (function (e) {
1621
+ function n(t) {
1622
+ var n;
1623
+ (((n = e.call(this, t) || this).onDragStart = function (e) {
1624
+ var t = (n.props.schemaStore || {}).getSchemaByIndexRoute,
1625
+ a = e.node,
1626
+ o = t(a.indexRoute || a['data-indexRoute']),
1627
+ r = O.get(o.type);
1628
+ null != r &&
1629
+ r.isFixed &&
1630
+ y.message.warning('当前元素不支持拖拽哦。');
1631
+ }),
1632
+ (n.onDrop = function (e) {
1633
+ var t = e.dragNode,
1634
+ a = e.node,
1635
+ o = n.props.schemaStore || {},
1636
+ r = o.getSchemaByIndexRoute,
1637
+ i = o.indexRoute2keyRoute,
1638
+ s = o.insertJsonData,
1639
+ l = o.deleteJsonByIndex,
1640
+ d = o.isExitJsonKey,
1641
+ c = t.indexRoute || t['data-indexRoute'],
1642
+ p = t.jsonKey || t['data-jsonKey'],
1643
+ u = r(c),
1644
+ h = O.get(u.type);
1645
+ if (null == h || !h.isFixed) {
1646
+ var m = a.indexRoute || a['data-indexRoute'],
1647
+ f = (0, g.isSameParent)(c, m),
1648
+ v = (0, g.getCurPosition)(c, m);
1649
+ if (f)
1650
+ (l(c, !0),
1651
+ 'before' === v && (m = (0, g.moveForward)(m)),
1652
+ a.dragOverGapTop
1653
+ ? s(m, p, u, 'before')
1654
+ : (a.dragOver || a.dragOverGapBottom) &&
1655
+ s(m, p, u));
1656
+ else {
1657
+ if (d(m, p))
1658
+ return void y.message.warning(
1659
+ '目标位置中有重名的元素',
1660
+ );
1661
+ var S = u.type,
1662
+ x = i(c),
1663
+ E = (0, g.getParentIndexRoute)(m),
1664
+ C = (function (e) {
1665
+ if (window.sessionStorage)
1666
+ return window.sessionStorage.getItem(e);
1667
+ })(x + '-' + S);
1668
+ (b(i(E) + '-' + p + '-' + S, C || x),
1669
+ a.dragOverGapTop
1670
+ ? 'after' === v
1671
+ ? (l(c, !0), s(m, p, u, 'before'))
1672
+ : (s(m, p, u, 'before', !0), l(c))
1673
+ : (a.dragOver || a.dragOverGapBottom) &&
1674
+ ('after' === v
1675
+ ? (l(c, !0), s(m, p, u))
1676
+ : (s(m, p, u, '', !0), l(c))));
1677
+ }
1678
+ }
1679
+ }),
1680
+ (n.catchExpandedKeys = function (e) {
1681
+ var t = [];
1682
+ return (
1683
+ e &&
1684
+ e.propertyOrder &&
1685
+ e.properties &&
1686
+ e.propertyOrder.map(function (n, a) {
1687
+ var o = n,
1688
+ r = e.properties[o].type + '-' + o;
1689
+ t.push(r);
1690
+ }),
1691
+ t
1692
+ );
1693
+ }));
1694
+ var a = n.props.schemaStore || {},
1695
+ o = a.initJSONSchemaData,
1696
+ r = a.initOnChange;
1697
+ return (t.data && o(t.data), t.onChange && r(t.onChange), n);
1698
+ }
1699
+ r()(n, e);
1700
+ var a = n.prototype;
1701
+ return (
1702
+ (a.componentWillReceiveProps = function (e) {
1703
+ var t = this.props.schemaStore || {},
1704
+ n = t.initJSONSchemaData,
1705
+ a = t.initOnChange;
1706
+ (S(e.data, this.props.data) || n(e.data),
1707
+ S(e.onChange, this.props.onChange) || a(e.onChange));
1708
+ }),
1709
+ (a.render = function () {
1710
+ var e = this.props,
1711
+ n = e.jsonView,
1712
+ a = e.jsonViewReadOnly,
1713
+ o = this.props.schemaStore || {},
1714
+ r = o.jsonSchema,
1715
+ s = o.schemaChange,
1716
+ l = (0, g.isEmptySchema)(r),
1717
+ d = r.type;
1718
+ return i.createElement(
1719
+ 'div',
1720
+ { className: 'json-schema-container' },
1721
+ !l &&
1722
+ !n &&
1723
+ i.createElement(
1724
+ i.Fragment,
1725
+ null,
1726
+ i.createElement(
1727
+ y.Tree,
1728
+ {
1729
+ draggable: !0,
1730
+ selectable: !1,
1731
+ onDragStart: this.onDragStart,
1732
+ onDrop: this.onDrop,
1733
+ defaultExpandedKeys:
1734
+ 'object' !== d || l
1735
+ ? []
1736
+ : this.catchExpandedKeys(r),
1737
+ },
1738
+ 'object' === d &&
1739
+ Z(
1740
+ t()({}, this.props, {
1741
+ parentType: '',
1742
+ jsonKey: '',
1743
+ indexRoute: '',
1744
+ nodeKey: '',
1745
+ targetJsonSchema: r,
1746
+ isOnlyShowChild: !0,
1747
+ }),
1748
+ ),
1749
+ 'object' !== d &&
1750
+ U(
1751
+ t()({}, this.props, {
1752
+ parentType: '',
1753
+ jsonKey: '',
1754
+ indexRoute: '',
1755
+ nodeKey: 'first-schema',
1756
+ targetJsonSchema: r,
1757
+ key: 'schema',
1758
+ isFirstSchema: !0,
1759
+ }),
1760
+ ),
1761
+ ),
1762
+ ),
1763
+ !l &&
1764
+ n &&
1765
+ i.createElement(Y, {
1766
+ jsonData: r,
1767
+ readOnly: null == a || a,
1768
+ maxLines: 25,
1769
+ onChange: s,
1770
+ }),
1771
+ l &&
1772
+ i.createElement(
1773
+ 'p',
1774
+ { className: 'json-schema-empty' },
1775
+ '当前jsonSchema没有数据内容',
1776
+ ),
1777
+ );
1778
+ }),
1779
+ n
1780
+ );
1781
+ })(i.PureComponent)),
1782
+ ee = (0, c.inject)(function (e) {
1783
+ return { schemaStore: e.schemaStore };
1784
+ })((0, c.observer)($)),
1785
+ te = {
1786
+ type: 'input',
1787
+ label: '字符串/单行文本',
1788
+ isContainer: !1,
1789
+ defaultSchema: {
1790
+ type: 'input',
1791
+ title: '单文本框',
1792
+ default: '',
1793
+ description: '',
1794
+ placeholder: '',
1795
+ autoComplete: !1,
1796
+ options: [],
1797
+ },
1798
+ renderer: W,
1799
+ propsSchema: I(
1800
+ t()({}, R, {
1801
+ default: {
1802
+ type: 'input',
1803
+ title: '默认值',
1804
+ placeholder: '请输入默认值',
1805
+ },
1806
+ placeholder: {
1807
+ type: 'input',
1808
+ title: '输入提示',
1809
+ description: '输入提示内容将作为输入区域的提示信息展示给用户',
1810
+ placeholder: '请输入输入提示',
1811
+ },
1812
+ autoComplete: {
1813
+ type: 'boolean',
1814
+ title: '开启可选项',
1815
+ description: '开启后支持添加可选项,并支持 autoComplete',
1816
+ },
1817
+ options: {
1818
+ type: 'json',
1819
+ title: '可选项',
1820
+ description:
1821
+ '开启可选项后,可在此设置可选数据列表(数组格式)',
1822
+ onShow: 'autoComplete === true',
1823
+ },
1824
+ }),
1825
+ ),
1826
+ };
1827
+ O.register(te);
1828
+ var ne = {
1829
+ type: 'boolean',
1830
+ label: 'Boolean/开关',
1831
+ isContainer: !1,
1832
+ defaultSchema: {
1833
+ type: 'boolean',
1834
+ title: '布尔值',
1835
+ default: !1,
1836
+ description: '',
1837
+ },
1838
+ renderer: W,
1839
+ propsSchema: I({
1840
+ readOnly: R.readOnly,
1841
+ isRequired: R.isRequired,
1842
+ default: { type: 'boolean', title: '默认值' },
1843
+ }),
1844
+ };
1845
+ O.register(ne);
1846
+ var ae = {
1847
+ type: 'number',
1848
+ label: 'Number数值',
1849
+ isContainer: !1,
1850
+ defaultSchema: {
1851
+ type: 'number',
1852
+ title: '数量number',
1853
+ default: 1,
1854
+ description: '',
1855
+ placeholder: '',
1856
+ },
1857
+ renderer: W,
1858
+ propsSchema: I({
1859
+ readOnly: R.readOnly,
1860
+ isRequired: R.isRequired,
1861
+ default: {
1862
+ type: 'number',
1863
+ title: '默认值',
1864
+ placeholder: '请输入默认数值',
1865
+ },
1866
+ placeholder: {
1867
+ type: 'input',
1868
+ title: '输入提示',
1869
+ placeholder: '请输入输入提示',
1870
+ },
1871
+ minimum: {
1872
+ type: 'number',
1873
+ title: '最小值',
1874
+ description: '设置最小值后,用户输入的数值必须大于当前最小值',
1875
+ },
1876
+ maximum: {
1877
+ type: 'number',
1878
+ title: '最大值',
1879
+ description: '设置最大值后,用户输入的数值必须小于当前最大值',
1880
+ },
1881
+ }),
1882
+ };
1883
+ O.register(ae);
1884
+ var oe = {
1885
+ type: 'color',
1886
+ label: '颜色数值',
1887
+ isContainer: !1,
1888
+ defaultSchema: {
1889
+ type: 'color',
1890
+ title: '颜色color',
1891
+ default: '#ffffff',
1892
+ description: '',
1893
+ },
1894
+ renderer: W,
1895
+ propsSchema: I({
1896
+ readOnly: R.readOnly,
1897
+ isRequired: R.isRequired,
1898
+ default: { type: 'color', title: '默认颜色值' },
1899
+ }),
1900
+ };
1901
+ O.register(oe);
1902
+ var re = {
1903
+ type: 'url',
1904
+ label: 'URL数值',
1905
+ isContainer: !1,
1906
+ defaultSchema: {
1907
+ type: 'url',
1908
+ title: '链接地址url',
1909
+ default: '',
1910
+ description: '',
1911
+ placeholder: '',
1912
+ },
1913
+ renderer: W,
1914
+ propsSchema: I({
1915
+ readOnly: R.readOnly,
1916
+ isRequired: R.isRequired,
1917
+ default: {
1918
+ type: 'input',
1919
+ title: '默认值',
1920
+ placeholder: '请输入默认 URL',
1921
+ },
1922
+ placeholder: {
1923
+ type: 'input',
1924
+ title: '输入提示',
1925
+ placeholder: '请输入输入提示',
1926
+ },
1927
+ }),
1928
+ };
1929
+ O.register(re);
1930
+ var ie = {
1931
+ type: 'textarea',
1932
+ label: '多行文本',
1933
+ isContainer: !1,
1934
+ defaultSchema: {
1935
+ type: 'textarea',
1936
+ title: '多行文本框',
1937
+ default: '',
1938
+ description: '',
1939
+ placeholder: '',
1940
+ },
1941
+ renderer: W,
1942
+ propsSchema: I({
1943
+ readOnly: R.readOnly,
1944
+ isRequired: R.isRequired,
1945
+ default: {
1946
+ type: 'textarea',
1947
+ title: '默认值',
1948
+ placeholder: '请输入默认值',
1949
+ },
1950
+ placeholder: {
1951
+ type: 'input',
1952
+ title: '输入提示',
1953
+ placeholder: '请输入输入提示',
1954
+ },
1955
+ }),
1956
+ };
1957
+ O.register(ie);
1958
+ var se = {
1959
+ type: 'text-editor',
1960
+ label: '富文本内容',
1961
+ isContainer: !1,
1962
+ defaultSchema: {
1963
+ type: 'text-editor',
1964
+ title: '富文本',
1965
+ default: '',
1966
+ description: '',
1967
+ placeholder: '',
1968
+ },
1969
+ renderer: W,
1970
+ propsSchema: I({
1971
+ readOnly: R.readOnly,
1972
+ isRequired: R.isRequired,
1973
+ default: {
1974
+ type: 'text-editor',
1975
+ title: '默认值',
1976
+ placeholder: '请输入默认富文本内容',
1977
+ },
1978
+ placeholder: {
1979
+ type: 'input',
1980
+ title: '输入提示',
1981
+ placeholder: '请输入输入提示',
1982
+ },
1983
+ }),
1984
+ };
1985
+ O.register(se);
1986
+ var le = function (e) {
1987
+ return (
1988
+ void 0 === e && (e = 'textarea'),
1989
+ I({
1990
+ readOnly: R.readOnly,
1991
+ isRequired: R.isRequired,
1992
+ default: {
1993
+ type: e,
1994
+ title: '默认值',
1995
+ placeholder: '请输入默认值',
1996
+ },
1997
+ placeholder: {
1998
+ type: 'input',
1999
+ title: '输入提示',
2000
+ placeholder: '请输入输入提示',
2001
+ },
2002
+ })
2003
+ );
2004
+ },
2005
+ de = {
2006
+ type: 'json',
2007
+ label: 'json内容',
2008
+ isContainer: !1,
2009
+ defaultSchema: {
2010
+ type: 'json',
2011
+ title: 'json数据',
2012
+ default: '{}',
2013
+ description: '',
2014
+ placeholder: '',
2015
+ },
2016
+ renderer: W,
2017
+ propsSchema: le('json'),
2018
+ },
2019
+ ce = {
2020
+ type: 'codearea',
2021
+ label: 'code内容',
2022
+ isContainer: !1,
2023
+ defaultSchema: {
2024
+ type: 'codearea',
2025
+ title: '函数类型',
2026
+ default: 'function func() { console.log("hello, world!"); }',
2027
+ description: '用于定义函数方法',
2028
+ placeholder: '请输入函数方法',
2029
+ },
2030
+ renderer: W,
2031
+ propsSchema: le('codearea'),
2032
+ },
2033
+ pe = {
2034
+ type: 'htmlarea',
2035
+ label: 'html内容',
2036
+ isContainer: !1,
2037
+ defaultSchema: {
2038
+ type: 'htmlarea',
2039
+ title: '富文本',
2040
+ default: '<p>hello,world!</p>',
2041
+ description: '用于放置html代码片段',
2042
+ placeholder: '请输入html代码片段',
2043
+ },
2044
+ renderer: W,
2045
+ propsSchema: le('htmlarea'),
2046
+ };
2047
+ O.registerAll([de, ce, pe]);
2048
+ var ue = function (e) {
2049
+ return (
2050
+ void 0 === e && (e = 'date'),
2051
+ I({
2052
+ readOnly: R.readOnly,
2053
+ isRequired: R.isRequired,
2054
+ default: {
2055
+ type: e,
2056
+ title: '默认值',
2057
+ placeholder: '请输入默认日期值',
2058
+ },
2059
+ placeholder: {
2060
+ type: 'input',
2061
+ title: '输入提示',
2062
+ placeholder: '请输入输入提示',
2063
+ },
2064
+ })
2065
+ );
2066
+ },
2067
+ he = {
2068
+ type: 'date',
2069
+ label: '日期',
2070
+ isContainer: !1,
2071
+ defaultSchema: {
2072
+ type: 'date',
2073
+ title: '日期Date',
2074
+ default: '',
2075
+ description: '',
2076
+ placeholder: '',
2077
+ },
2078
+ renderer: W,
2079
+ propsSchema: ue(),
2080
+ },
2081
+ me = {
2082
+ type: 'date-time',
2083
+ label: '日期时间',
2084
+ isContainer: !1,
2085
+ defaultSchema: {
2086
+ type: 'date-time',
2087
+ title: '日期时间',
2088
+ default: '',
2089
+ description: '',
2090
+ placeholder: '',
2091
+ },
2092
+ renderer: W,
2093
+ propsSchema: ue('date-time'),
2094
+ },
2095
+ ye = {
2096
+ type: 'time',
2097
+ label: '时间',
2098
+ isContainer: !1,
2099
+ defaultSchema: {
2100
+ type: 'time',
2101
+ title: '时间Time',
2102
+ default: '',
2103
+ description: '',
2104
+ placeholder: '',
2105
+ },
2106
+ renderer: W,
2107
+ propsSchema: ue('time'),
2108
+ };
2109
+ O.registerAll([he, me, ye]);
2110
+ var fe = {
2111
+ type: 'input-image',
2112
+ label: '图片上传',
2113
+ isContainer: !1,
2114
+ defaultSchema: {
2115
+ type: 'input-image',
2116
+ title: '图片地址',
2117
+ default: '',
2118
+ description: '',
2119
+ },
2120
+ renderer: W,
2121
+ propsSchema: I({
2122
+ readOnly: R.readOnly,
2123
+ isRequired: R.isRequired,
2124
+ default: {
2125
+ type: 'input',
2126
+ title: '默认图片URL',
2127
+ placeholder: '请输入默认图片地址',
2128
+ },
2129
+ }),
2130
+ };
2131
+ (O.register(fe), n(617));
2132
+ var ge = y.Select.Option,
2133
+ ve = (function (e) {
2134
+ function t(t) {
2135
+ var n;
2136
+ return (
2137
+ ((n = e.call(this, t) || this).handleLabelChange = function (
2138
+ e,
2139
+ ) {
2140
+ var t = n.props.schemaStore || {},
2141
+ a = t.isExitOptionLabel,
2142
+ o = t.updateOptionLabel,
2143
+ r = e.target.value,
2144
+ i = n.props,
2145
+ s = i.indexRoute,
2146
+ l = i.optionIndex;
2147
+ r !== i.optionLabel &&
2148
+ (a(s, r)
2149
+ ? y.message.warning(
2150
+ '对不起,存在相同的Label值,请重新设置。',
2151
+ )
2152
+ : o(s, l, r));
2153
+ }),
2154
+ (n.handleValueChange = function (e) {
2155
+ var t = (n.props.schemaStore || {}).updateOptionValue,
2156
+ a = e.target.value,
2157
+ o = n.props,
2158
+ r = o.indexRoute,
2159
+ i = o.optionIndex,
2160
+ s = o.optionValue;
2161
+ if (a !== s) {
2162
+ var l = a;
2163
+ if ((0, g.isObject)(s) && (0, g.isString)(l))
2164
+ try {
2165
+ l = JSON.parse(l);
2166
+ } catch (e) {
2167
+ (console.warn('option 数值转换失败:', l), (l = s));
2168
+ }
2169
+ t(r, i, l);
2170
+ }
2171
+ }),
2172
+ (n.onAddBtnEvent = function () {
2173
+ var e = (n.props.schemaStore || {}).addOptionItem,
2174
+ t = n.props;
2175
+ e(t.indexRoute, t.optionIndex);
2176
+ }),
2177
+ (n.onCopyBtnEvent = function () {
2178
+ var e = (n.props.schemaStore || {}).copyOptionItem,
2179
+ t = n.props;
2180
+ e(t.indexRoute, t.optionIndex);
2181
+ }),
2182
+ (n.onDeleteBtnEvent = function () {
2183
+ var e = n.props.schemaStore || {},
2184
+ t = (e.getSchemaByIndexRoute, e.deleteOptionItem),
2185
+ a = n.props;
2186
+ t(a.indexRoute, a.optionIndex);
2187
+ }),
2188
+ (n.onAddBtnEvent = n.onAddBtnEvent.bind(n)),
2189
+ (n.onCopyBtnEvent = n.onCopyBtnEvent.bind(n)),
2190
+ (n.onDeleteBtnEvent = n.onDeleteBtnEvent.bind(n)),
2191
+ (n.handleLabelChange = n.handleLabelChange.bind(n)),
2192
+ (n.handleValueChange = n.handleValueChange.bind(n)),
2193
+ n
2194
+ );
2195
+ }
2196
+ return (
2197
+ r()(t, e),
2198
+ (t.prototype.render = function () {
2199
+ var e = this.props,
2200
+ t = e.optionLabel,
2201
+ n = e.optionValue,
2202
+ a = (e.optionNodeKey, n);
2203
+ return (
2204
+ ((0, g.isObject)(n) || (0, g.isArray)(n)) &&
2205
+ (a = JSON.stringify(n)),
2206
+ i.createElement(
2207
+ 'div',
2208
+ { className: 'option-schema-box', id: t },
2209
+ i.createElement(
2210
+ 'div',
2211
+ { className: 'key-input-item' },
2212
+ i.createElement(y.Input, {
2213
+ defaultValue: a,
2214
+ onPressEnter: this.handleValueChange,
2215
+ onBlur: this.handleValueChange,
2216
+ }),
2217
+ ),
2218
+ i.createElement(
2219
+ 'div',
2220
+ { className: 'type-select-item' },
2221
+ i.createElement(
2222
+ y.Select,
2223
+ { defaultValue: 'string', style: { width: 120 } },
2224
+ i.createElement(
2225
+ ge,
2226
+ { key: 'string', value: 'string' },
2227
+ 'string',
2228
+ ),
2229
+ ),
2230
+ ),
2231
+ i.createElement(
2232
+ 'div',
2233
+ { className: 'title-input-item' },
2234
+ i.createElement(y.Input, {
2235
+ defaultValue: t,
2236
+ onPressEnter: this.handleLabelChange,
2237
+ onBlur: this.handleLabelChange,
2238
+ }),
2239
+ ),
2240
+ i.createElement(
2241
+ 'div',
2242
+ { className: 'operate-item' },
2243
+ i.createElement(
2244
+ y.Tooltip,
2245
+ { title: '删除' },
2246
+ i.createElement(T.CloseOutlined, {
2247
+ className: 'operate-btn delete-operate',
2248
+ onClick: this.onDeleteBtnEvent,
2249
+ }),
2250
+ ),
2251
+ i.createElement(
2252
+ y.Tooltip,
2253
+ { title: '新增可选项' },
2254
+ i.createElement(T.PlusOutlined, {
2255
+ className: 'operate-btn',
2256
+ onClick: this.onAddBtnEvent,
2257
+ }),
2258
+ ),
2259
+ i.createElement(
2260
+ y.Tooltip,
2261
+ { title: '复制' },
2262
+ i.createElement(T.CopyOutlined, {
2263
+ className: 'operate-btn',
2264
+ onClick: this.onCopyBtnEvent,
2265
+ }),
2266
+ ),
2267
+ ),
2268
+ )
2269
+ );
2270
+ }),
2271
+ t
2272
+ );
2273
+ })(i.PureComponent),
2274
+ Se = (0, c.inject)(function (e) {
2275
+ return { schemaStore: e.schemaStore };
2276
+ })((0, c.observer)(ve)),
2277
+ be = y.Tree.TreeNode,
2278
+ xe = function (e) {
2279
+ return s().createElement(Se, t()({}, e));
2280
+ },
2281
+ Oe = function (e) {
2282
+ var n,
2283
+ a = e.jsonKey,
2284
+ o = e.indexRoute,
2285
+ r = e.nodeKey,
2286
+ i = e.targetJsonSchema,
2287
+ l = i.type,
2288
+ d = i.options,
2289
+ c = o || '0';
2290
+ return s().createElement(
2291
+ be,
2292
+ {
2293
+ className: l + '-schema schema-item-form',
2294
+ id: r,
2295
+ key: r,
2296
+ 'data-indexRoute': o || '0',
2297
+ 'data-jsonKey': a,
2298
+ title: ((n = t()({}, e)), s().createElement(P, t()({}, n))),
2299
+ },
2300
+ d &&
2301
+ d.length > 0 &&
2302
+ d.map(function (e, t) {
2303
+ var n = e.label || e.name,
2304
+ a = e.value,
2305
+ o = '' + r + l + '-' + n;
2306
+ return s().createElement(be, {
2307
+ className: 'enum-item-schema schema-item-form',
2308
+ id: o,
2309
+ key: o,
2310
+ 'data-indexRoute': c,
2311
+ disabled: !0,
2312
+ title: xe({
2313
+ indexRoute: c,
2314
+ optionIndex: t,
2315
+ optionLabel: n,
2316
+ optionValue: a,
2317
+ optionNodeKey: o,
2318
+ }),
2319
+ });
2320
+ }),
2321
+ );
2322
+ },
2323
+ Ee = {
2324
+ type: 'radio',
2325
+ label: '单选',
2326
+ isContainer: !1,
2327
+ defaultSchema: {
2328
+ type: 'radio',
2329
+ title: '单选',
2330
+ options: [
2331
+ { label: '选项a', value: 'a' },
2332
+ { label: '选项b', value: 'b' },
2333
+ { label: '选项c', value: 'c' },
2334
+ ],
2335
+ default: '',
2336
+ description: '',
2337
+ },
2338
+ renderer: Oe,
2339
+ propsSchema: I({
2340
+ readOnly: R.readOnly,
2341
+ isRequired: R.isRequired,
2342
+ defaultActiveFirstOption: {
2343
+ type: 'boolean',
2344
+ title: '选中第一项',
2345
+ description: '是否默认高亮第一个选项',
2346
+ },
2347
+ default: {
2348
+ type: 'input',
2349
+ title: '默认值',
2350
+ placeholder: '请输入默认选中项的 value 值',
2351
+ },
2352
+ }),
2353
+ };
2354
+ O.register(Ee);
2355
+ var Ce = {
2356
+ type: 'select',
2357
+ label: '下拉选择/多选',
2358
+ isContainer: !1,
2359
+ defaultSchema: {
2360
+ type: 'select',
2361
+ title: '下拉选择',
2362
+ options: [
2363
+ { label: '选项a', value: 'a' },
2364
+ { label: '选项b', value: 'b' },
2365
+ { label: '选项c', value: 'c' },
2366
+ ],
2367
+ description: '',
2368
+ },
2369
+ renderer: Oe,
2370
+ propsSchema: I({
2371
+ readOnly: R.readOnly,
2372
+ isRequired: R.isRequired,
2373
+ multiple: {
2374
+ type: 'boolean',
2375
+ title: '支持多选',
2376
+ description: '开启多选后,select 下拉列表支持选择多个选项',
2377
+ },
2378
+ defaultActiveFirstOption: {
2379
+ type: 'boolean',
2380
+ title: '选中第一项',
2381
+ description: '是否默认高亮第一个选项',
2382
+ },
2383
+ withLabel: {
2384
+ type: 'boolean',
2385
+ title: '附带label数值',
2386
+ description:
2387
+ '开启后,选中选项时,其数值会带上当前选项的 label 数值',
2388
+ },
2389
+ default: {
2390
+ type: 'input',
2391
+ title: '默认值',
2392
+ placeholder: '请输入默认选中项的 value 值',
2393
+ },
2394
+ }),
2395
+ };
2396
+ O.register(Ce);
2397
+ var je = {
2398
+ type: 'cascader',
2399
+ label: '级联选择',
2400
+ isContainer: !1,
2401
+ defaultSchema: {
2402
+ type: 'cascader',
2403
+ title: '级联选择',
2404
+ options: [
2405
+ {
2406
+ value: 'zhejiang',
2407
+ label: 'Zhejiang',
2408
+ children: [
2409
+ {
2410
+ value: 'hangzhou',
2411
+ label: 'Hangzhou',
2412
+ children: [{ value: 'xihu', label: 'West Lake' }],
2413
+ },
2414
+ ],
2415
+ },
2416
+ {
2417
+ value: 'jiangsu',
2418
+ label: 'Jiangsu',
2419
+ children: [
2420
+ {
2421
+ value: 'nanjing',
2422
+ label: 'Nanjing',
2423
+ children: [
2424
+ { value: 'zhonghuamen', label: 'Zhong Hua Men' },
2425
+ ],
2426
+ },
2427
+ ],
2428
+ },
2429
+ ],
2430
+ default: 'a',
2431
+ description: '',
2432
+ },
2433
+ renderer: W,
2434
+ propsSchema: I({
2435
+ readOnly: R.readOnly,
2436
+ isRequired: R.isRequired,
2437
+ multiple: {
2438
+ type: 'boolean',
2439
+ title: '支持多选',
2440
+ description: '开启多选后,级联选择支持选择多个选项',
2441
+ },
2442
+ options: {
2443
+ type: 'json',
2444
+ title: 'options 配置',
2445
+ description: '用于添加级联选择组件的 options 数据',
2446
+ },
2447
+ default: {
2448
+ type: 'input',
2449
+ title: '默认值',
2450
+ placeholder: '请输入默认值',
2451
+ },
2452
+ }),
2453
+ };
2454
+ O.register(je);
2455
+ var Re = {
2456
+ type: 'checkboxes',
2457
+ label: '多选框',
2458
+ isContainer: !1,
2459
+ defaultSchema: {
2460
+ type: 'checkboxes',
2461
+ title: '多选',
2462
+ options: [
2463
+ { label: '选项a', value: 'a' },
2464
+ { label: '选项b', value: 'b' },
2465
+ { label: '选项c', value: 'c' },
2466
+ ],
2467
+ default: ['a'],
2468
+ description: '',
2469
+ },
2470
+ renderer: Oe,
2471
+ propsSchema: I({
2472
+ readOnly: R.readOnly,
2473
+ isRequired: R.isRequired,
2474
+ default: {
2475
+ type: 'json',
2476
+ title: '默认值',
2477
+ description: '默认选中的选项值数组,格式为 ["value1", "value2"]',
2478
+ },
2479
+ }),
2480
+ };
2481
+ (O.register(Re), n(790));
2482
+ var Ie = y.Select.Option,
2483
+ Ne = (function (e) {
2484
+ function t(t) {
2485
+ var n;
2486
+ return (
2487
+ ((n = e.call(this, t) || this).typeChange = function (e) {
2488
+ var t = n.props.schemaStore || {},
2489
+ a = t.editSchemaData,
2490
+ o = (t.updateSchemaData, n.props),
2491
+ r = o.indexRoute,
2492
+ i = o.jsonKey,
2493
+ s = o.targetJsonSchema;
2494
+ (o.typeSelectData,
2495
+ s.default !== e && a(r || '', i, { default: e }));
2496
+ }),
2497
+ (n.typeChange = n.typeChange.bind(n)),
2498
+ n
2499
+ );
2500
+ }
2501
+ return (
2502
+ r()(t, e),
2503
+ (t.prototype.render = function () {
2504
+ var e = this.props,
2505
+ t = e.nodeKey,
2506
+ n = e.targetJsonSchema,
2507
+ a = n.type,
2508
+ o = n.options || [];
2509
+ return i.createElement(
2510
+ 'div',
2511
+ { className: 'typeSelect-schema-box', id: t },
2512
+ i.createElement(
2513
+ 'div',
2514
+ { className: 'key-input-item' },
2515
+ i.createElement(
2516
+ y.Select,
2517
+ {
2518
+ defaultValue: n.default || 'local',
2519
+ onChange: this.typeChange,
2520
+ },
2521
+ o.map(function (e, t) {
2522
+ return i.createElement(
2523
+ Ie,
2524
+ { key: t, value: e.value },
2525
+ e.label || e.name,
2526
+ );
2527
+ }),
2528
+ ),
2529
+ ),
2530
+ i.createElement(
2531
+ 'div',
2532
+ { className: 'type-select-item' },
2533
+ i.createElement(
2534
+ y.Select,
2535
+ { defaultValue: a, style: { width: 120 }, disabled: !0 },
2536
+ i.createElement(Ie, { key: a, value: a }, a),
2537
+ ),
2538
+ ),
2539
+ i.createElement(
2540
+ 'div',
2541
+ { className: 'title-input-item' },
2542
+ i.createElement(y.Input, {
2543
+ defaultValue: n.title,
2544
+ disabled: !0,
2545
+ }),
2546
+ ),
2547
+ i.createElement('div', { className: 'operate-item' }, ' '),
2548
+ );
2549
+ }),
2550
+ t
2551
+ );
2552
+ })(i.PureComponent),
2553
+ _e = (0, c.inject)(function (e) {
2554
+ return { schemaStore: e.schemaStore };
2555
+ })((0, c.observer)(Ne)),
2556
+ Ke = y.Tree.TreeNode,
2557
+ we = function (e) {
2558
+ return s().createElement(P, t()({}, e));
2559
+ },
2560
+ Je = {
2561
+ type: 'quantity',
2562
+ label: '数值单位设置',
2563
+ isContainer: !1,
2564
+ defaultSchema: {
2565
+ type: 'quantity',
2566
+ title: '单位计量',
2567
+ description: '',
2568
+ properties: {
2569
+ unit: { type: 'number', title: '单位数值', default: 50 },
2570
+ quantity: {
2571
+ type: 'select',
2572
+ title: '单位类型',
2573
+ options: [
2574
+ { label: 'px', value: 'px' },
2575
+ { label: 'rem', value: 'rem' },
2576
+ { label: 'em', value: 'em' },
2577
+ { label: '%', value: '%' },
2578
+ ],
2579
+ default: 'px',
2580
+ },
2581
+ },
2582
+ propertyOrder: ['unit', 'quantity'],
2583
+ },
2584
+ showAdvanceBtn: !1,
2585
+ renderer: function (e) {
2586
+ var n,
2587
+ a = e.jsonKey,
2588
+ o = e.indexRoute,
2589
+ r = e.nodeKey,
2590
+ i = e.targetJsonSchema,
2591
+ l = i.type,
2592
+ d = i.propertyOrder[0],
2593
+ c = i.properties[d];
2594
+ return s().createElement(
2595
+ Ke,
2596
+ {
2597
+ className: l + '-schema schema-item-form',
2598
+ id: r,
2599
+ key: r,
2600
+ 'data-indexRoute': o,
2601
+ 'data-jsonKey': a,
2602
+ title: we(t()({}, e)),
2603
+ },
2604
+ s().createElement(Ke, {
2605
+ className: 'quantity-unit-item-schema schema-item-form',
2606
+ id: r + '-' + d,
2607
+ key: r + '-' + d,
2608
+ 'data-indexRoute': o ? o + '-0' : '0',
2609
+ 'data-jsonKey': d,
2610
+ disabled: !0,
2611
+ title: we(
2612
+ t()({}, e, {
2613
+ indexRoute: o ? o + '-0' : '0',
2614
+ jsonKey: d,
2615
+ targetJsonSchema: c,
2616
+ parentType: l,
2617
+ nodeKey: r + '-' + d,
2618
+ hideOperaBtn: !0,
2619
+ showAdvanceBtn: !0,
2620
+ typeIsFixed: !0,
2621
+ }),
2622
+ ),
2623
+ }),
2624
+ s().createElement(Ke, {
2625
+ className: 'quantity-typeSelect-item-schema schema-item-form',
2626
+ id: r + '-quantity',
2627
+ key: r + '-quantity',
2628
+ 'data-indexRoute': o ? o + '-1' : '1',
2629
+ 'data-jsonKey': 'quantity',
2630
+ disabled: !0,
2631
+ title:
2632
+ ((n = t()({}, e, {
2633
+ indexRoute: o ? o + '-1' : '1',
2634
+ jsonKey: 'quantity',
2635
+ targetJsonSchema: i.properties.quantity,
2636
+ parentType: l,
2637
+ nodeKey: r + '-quantity',
2638
+ })),
2639
+ s().createElement(_e, t()({}, n))),
2640
+ }),
2641
+ );
2642
+ },
2643
+ propsSchema: I({
2644
+ readOnly: R.readOnly,
2645
+ isRequired: R.isRequired,
2646
+ autoComplete: {
2647
+ type: 'boolean',
2648
+ title: '开启可选项',
2649
+ description: '开启后支持添加可选项,并支持 autoComplete',
2650
+ },
2651
+ options: {
2652
+ type: 'json',
2653
+ title: '可选项',
2654
+ description: '可选项数据列表(数组格式)',
2655
+ onShow: 'autoComplete === true',
2656
+ },
2657
+ }),
2658
+ };
2659
+ O.register(Je);
2660
+ var Be = {
2661
+ type: 'padding-margin',
2662
+ label: '边距设置',
2663
+ isContainer: !1,
2664
+ defaultSchema: {
2665
+ type: 'padding-margin',
2666
+ title: '边距设置',
2667
+ isContainer: !1,
2668
+ properties: {
2669
+ margin: {
2670
+ title: '外边距',
2671
+ type: 'input',
2672
+ default: '0',
2673
+ description: '',
2674
+ },
2675
+ padding: {
2676
+ title: '内边距',
2677
+ type: 'input',
2678
+ default: '0',
2679
+ description: '',
2680
+ },
2681
+ quantity: {
2682
+ type: 'select',
2683
+ default: 'px',
2684
+ options: [
2685
+ { label: 'px', value: 'px' },
2686
+ { label: 'rem', value: 'rem' },
2687
+ { label: 'em', value: 'em' },
2688
+ { label: '%', value: '%' },
2689
+ ],
2690
+ title: '单位类型',
2691
+ },
2692
+ },
2693
+ propertyOrder: ['margin', 'padding', 'quantity'],
2694
+ },
2695
+ propsSchema: I({
2696
+ autoComplete: {
2697
+ type: 'boolean',
2698
+ title: '开启可选项',
2699
+ description: '开启后支持添加可选项,并支持 autoComplete',
2700
+ },
2701
+ }),
2702
+ renderer: Z,
2703
+ };
2704
+ O.register(Be);
2705
+ var Te = {
2706
+ type: 'object',
2707
+ label: '对象(Object)',
2708
+ isContainer: !0,
2709
+ wrapWithPanel: !0,
2710
+ defaultSchema: {
2711
+ type: 'object',
2712
+ title: '对象Object',
2713
+ description: '',
2714
+ properties: {
2715
+ a: {
2716
+ type: 'input',
2717
+ title: '单文本框',
2718
+ default: '',
2719
+ description: '',
2720
+ placeholder: '',
2721
+ },
2722
+ },
2723
+ propertyOrder: ['a'],
2724
+ },
2725
+ propsSchema: I({
2726
+ showCodeViewBtn: {
2727
+ type: 'boolean',
2728
+ title: '源码模式',
2729
+ description: '用于控制是否显示源码模式切换按钮,默认显示',
2730
+ },
2731
+ }),
2732
+ renderer: Z,
2733
+ };
2734
+ O.register(Te);
2735
+ var ke = y.Tree.TreeNode,
2736
+ qe = function (e) {
2737
+ return s().createElement(P, t()({}, e));
2738
+ },
2739
+ De = {
2740
+ type: 'array',
2741
+ label: '数组(Array)',
2742
+ isContainer: !1,
2743
+ defaultSchema: {
2744
+ type: 'array',
2745
+ title: '数组Array',
2746
+ description: '',
2747
+ items: {
2748
+ type: 'object',
2749
+ title: '数组项',
2750
+ description: '',
2751
+ properties: {
2752
+ name: {
2753
+ type: 'input',
2754
+ title: '名字',
2755
+ default: '',
2756
+ description: '',
2757
+ placeholder: '',
2758
+ },
2759
+ },
2760
+ propertyOrder: ['name'],
2761
+ },
2762
+ },
2763
+ propsSchema: I({
2764
+ showCodeViewBtn: {
2765
+ type: 'boolean',
2766
+ title: '源码模式',
2767
+ description: '用于控制是否显示源码模式切换按钮,默认显示',
2768
+ },
2769
+ 'minimum-child': {
2770
+ type: 'number',
2771
+ title: '最小数据项',
2772
+ description: '用于限制数据项最小个数',
2773
+ },
2774
+ 'maximum-child': {
2775
+ type: 'number',
2776
+ title: '最多数据项',
2777
+ description: '用于限制数据项最多个数',
2778
+ },
2779
+ }),
2780
+ renderer: function (e) {
2781
+ var n = e.jsonKey,
2782
+ a = e.indexRoute,
2783
+ o = e.nodeKey,
2784
+ r = e.targetJsonSchema,
2785
+ i = r.type,
2786
+ l = a ? a + '-0' : '0',
2787
+ d = 'items',
2788
+ c = o ? o + '-' + d : d,
2789
+ p = r[d] || {};
2790
+ return s().createElement(
2791
+ ke,
2792
+ {
2793
+ className: i + '-schema schema-item-form',
2794
+ id: o,
2795
+ key: o,
2796
+ 'data-indexRoute': a,
2797
+ 'data-jsonKey': n,
2798
+ title: qe(t()({}, e)),
2799
+ },
2800
+ (function (e) {
2801
+ var n = e.parentType,
2802
+ a = e.jsonKey,
2803
+ o = e.indexRoute,
2804
+ r = e.nodeKey,
2805
+ i = e.targetJsonSchema;
2806
+ return s().createElement(
2807
+ ke,
2808
+ {
2809
+ className: 'array-item-schema schema-item-form',
2810
+ id: r,
2811
+ key: r,
2812
+ 'data-jsonKey': a,
2813
+ disabled: !0,
2814
+ title: qe(
2815
+ t()({}, e, {
2816
+ indexRoute: o,
2817
+ jsonKey: a,
2818
+ targetJsonSchema: i,
2819
+ parentType: n,
2820
+ nodeKey: r,
2821
+ isFixed: !0,
2822
+ typeIsFixed: !1,
2823
+ }),
2824
+ ),
2825
+ },
2826
+ 'object' === i.type &&
2827
+ (function (e) {
2828
+ var n = e.propertyOrder,
2829
+ a = e.properties,
2830
+ o = e.parentIndexRoute,
2831
+ r = e.parentNodeKey,
2832
+ i = e.parentType;
2833
+ return n.map(function (n, s) {
2834
+ var l = o ? o + '-' + s : '' + s,
2835
+ d = n,
2836
+ c = a[d],
2837
+ p = c.type,
2838
+ u = (r ? r + '-' : '') + p + '-' + d;
2839
+ return U(
2840
+ t()({}, e, {
2841
+ parentType: i,
2842
+ jsonKey: d,
2843
+ indexRoute: l,
2844
+ key: u,
2845
+ nodeKey: u,
2846
+ targetJsonSchema: c,
2847
+ }),
2848
+ );
2849
+ });
2850
+ })(
2851
+ t()({}, e, {
2852
+ propertyOrder: i.propertyOrder,
2853
+ properties: i.properties,
2854
+ parentIndexRoute: o,
2855
+ parentNodeKey: r,
2856
+ parentType: n,
2857
+ }),
2858
+ ),
2859
+ );
2860
+ })(
2861
+ t()({}, e, {
2862
+ parentType: 'array',
2863
+ jsonKey: d,
2864
+ indexRoute: l,
2865
+ nodeKey: c,
2866
+ targetJsonSchema: p,
2867
+ }),
2868
+ ),
2869
+ );
2870
+ },
2871
+ };
2872
+ O.register(De);
2873
+ var Ae = y.Tree.TreeNode,
2874
+ Le = {
2875
+ type: 'api',
2876
+ label: 'API 配置',
2877
+ isContainer: !1,
2878
+ isFixed: !1,
2879
+ keyIsFixed: !1,
2880
+ typeIsFixed: !1,
2881
+ defaultSchema: {
2882
+ type: 'api',
2883
+ title: 'API 配置',
2884
+ properties: {
2885
+ url: {
2886
+ type: 'url',
2887
+ title: '请求地址',
2888
+ default: '',
2889
+ description: 'API 的 URL',
2890
+ isRequired: !0,
2891
+ },
2892
+ method: {
2893
+ type: 'select',
2894
+ title: '请求方式',
2895
+ default: 'get',
2896
+ options: [
2897
+ { label: 'GET', value: 'get' },
2898
+ { label: 'POST', value: 'post' },
2899
+ { label: 'PUT', value: 'put' },
2900
+ { label: 'DELETE', value: 'delete' },
2901
+ ],
2902
+ isRequired: !0,
2903
+ },
2904
+ headers: {
2905
+ type: 'json',
2906
+ title: '请求头',
2907
+ default: '{}',
2908
+ description: '请求头对象',
2909
+ },
2910
+ data: {
2911
+ type: 'json',
2912
+ title: '请求参数',
2913
+ default: '{}',
2914
+ description: '请求体或查询参数',
2915
+ },
2916
+ },
2917
+ propertyOrder: ['url', 'method', 'headers', 'data'],
2918
+ },
2919
+ propsSchema: I(),
2920
+ renderer: function (e) {
2921
+ var n = e.jsonKey,
2922
+ a = e.indexRoute,
2923
+ o = e.nodeKey,
2924
+ r = e.targetJsonSchema,
2925
+ i = r.type,
2926
+ l = r.properties.url || {},
2927
+ d = r.properties.method || {},
2928
+ c = r.properties.headers || {},
2929
+ p = r.properties.data || {};
2930
+ return s().createElement(
2931
+ Ae,
2932
+ {
2933
+ className: i + '-schema schema-item-form',
2934
+ id: o,
2935
+ key: o,
2936
+ 'data-indexRoute': a,
2937
+ 'data-jsonKey': n,
2938
+ title: s().createElement(P, t()({}, e)),
2939
+ },
2940
+ s().createElement(Ae, {
2941
+ className: 'api-url-item-schema schema-item-form',
2942
+ id: o + '-url',
2943
+ key: o + '-url',
2944
+ 'data-indexRoute': a ? a + '-0' : '0',
2945
+ 'data-jsonKey': 'url',
2946
+ title: s().createElement(
2947
+ P,
2948
+ t()({}, e, {
2949
+ indexRoute: a ? a + '-0' : '0',
2950
+ jsonKey: 'url',
2951
+ targetJsonSchema: l,
2952
+ parentType: i,
2953
+ nodeKey: o + '-url',
2954
+ hideOperaBtn: !0,
2955
+ keyIsFixed: !0,
2956
+ typeIsFixed: !0,
2957
+ }),
2958
+ ),
2959
+ }),
2960
+ s().createElement(Ae, {
2961
+ className: 'api-method-item-schema schema-item-form',
2962
+ id: o + '-method',
2963
+ key: o + '-method',
2964
+ 'data-indexRoute': a ? a + '-1' : '1',
2965
+ title: s().createElement(
2966
+ P,
2967
+ t()({}, e, {
2968
+ indexRoute: a ? a + '-1' : '1',
2969
+ jsonKey: 'method',
2970
+ targetJsonSchema: d,
2971
+ parentType: i,
2972
+ nodeKey: o + '-method',
2973
+ hideOperaBtn: !0,
2974
+ keyIsFixed: !0,
2975
+ typeIsFixed: !0,
2976
+ }),
2977
+ ),
2978
+ }),
2979
+ s().createElement(Ae, {
2980
+ className: 'api-headers-item-schema schema-item-form',
2981
+ id: o + '-headers',
2982
+ key: o + '-headers',
2983
+ 'data-indexRoute': a ? a + '-2' : '2',
2984
+ 'data-jsonKey': 'headers',
2985
+ title: s().createElement(
2986
+ P,
2987
+ t()({}, e, {
2988
+ indexRoute: a ? a + '-2' : '2',
2989
+ jsonKey: 'headers',
2990
+ targetJsonSchema: c,
2991
+ parentType: i,
2992
+ nodeKey: o + '-headers',
2993
+ hideOperaBtn: !0,
2994
+ keyIsFixed: !0,
2995
+ typeIsFixed: !0,
2996
+ }),
2997
+ ),
2998
+ }),
2999
+ s().createElement(Ae, {
3000
+ className: 'api-data-item-schema schema-item-form',
3001
+ id: o + '-data',
3002
+ key: o + '-data',
3003
+ 'data-indexRoute': a ? a + '-3' : '3',
3004
+ 'data-jsonKey': 'data',
3005
+ title: s().createElement(
3006
+ P,
3007
+ t()({}, e, {
3008
+ indexRoute: a ? a + '-3' : '3',
3009
+ jsonKey: 'data',
3010
+ targetJsonSchema: p,
3011
+ parentType: i,
3012
+ nodeKey: o + '-data',
3013
+ hideOperaBtn: !0,
3014
+ keyIsFixed: !0,
3015
+ typeIsFixed: !0,
3016
+ }),
3017
+ ),
3018
+ }),
3019
+ );
3020
+ },
3021
+ };
3022
+ O.register(Le);
3023
+ var Fe = (function (e) {
3024
+ function n(t) {
3025
+ var n;
3026
+ return (
3027
+ ((n = e.call(this, t) || this).state = {
3028
+ schemaStore: new w.schemaStore(),
3029
+ }),
3030
+ n
3031
+ );
3032
+ }
3033
+ return (
3034
+ r()(n, e),
3035
+ (n.prototype.render = function () {
3036
+ var e = this.props.element,
3037
+ n = this.state.schemaStore,
3038
+ a = i.createElement(
3039
+ c.Provider,
3040
+ { schemaStore: n },
3041
+ i.createElement(ee, t()({}, this.props)),
3042
+ );
3043
+ return e ? (d().render(a, e), null) : a;
3044
+ }),
3045
+ n
3046
+ );
3047
+ })(i.PureComponent);
3048
+ })(),
3049
+ a
3050
+ );
3051
+ })();
3052
+ });