index.js 2.7 KB

123456789
  1. /*!
  2. * FormCreate 低代码表单渲染器
  3. * @form-create/component-elm-select v2.6.3
  4. * (c) 2018-2024 xaboy
  5. * Github https://github.com/xaboy/form-create
  6. * Site https://form-create.com/
  7. * Released under the MIT License.
  8. */
  9. (function(l,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(l=typeof globalThis!="undefined"?globalThis:l||self,l.FcSelect=s())})(this,function(){"use strict";function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t,n=1;n<arguments.length;n++)for(var r in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)}var d=["attrs","props","domProps"],m=["class","style","directives"],g=["on","nativeOn"],O=function(e){return e.reduce(function(t,n){for(var r in n)if(!t[r])t[r]=n[r];else if(d.indexOf(r)!==-1)t[r]=s({},t[r],n[r]);else if(m.indexOf(r)!==-1){var c=t[r]instanceof Array?t[r]:[t[r]],i=n[r]instanceof Array?n[r]:[n[r]];t[r]=[].concat(c,i)}else if(g.indexOf(r)!==-1)for(var o in n[r])if(t[r][o]){var u=t[r][o]instanceof Array?t[r][o]:[t[r][o]],p=n[r][o]instanceof Array?n[r][o]:[n[r][o]];t[r][o]=[].concat(u,p)}else t[r][o]=n[r][o];else if(r==="hook")for(var f in n[r])t[r][f]=t[r][f]?A(t[r][f],n[r][f]):n[r][f];else t[r]=n[r];return t},{})},A=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},h=O;const y=l(h),a={type(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef(e){return e==null},Element(e){return typeof e=="object"&&e!==null&&e.nodeType===1&&!a.Object(e)},trueArray(e){return Array.isArray(e)&&e.length>0},Function(e){const t=this.getType(e);return t==="Function"||t==="AsyncFunction"},getType(e){const t=Object.prototype.toString.call(e);return/^\[object (.*)\]$/.exec(t)[1]},empty(e){return e==null||Array.isArray(e)&&Array.isArray(e)&&!e.length?!0:typeof e=="string"&&!e}};["Date","Object","String","Boolean","Array","Number"].forEach(e=>{a[e]=function(t){return a.type(t,e)}});function j(e,t){return{}.hasOwnProperty.call(e,t)}return{name:"fcSelect",functional:!0,props:{formCreateInject:{type:Object,required:!0}},render(e,t){const n=(i,o)=>{const u=i.slot;return e("ElOption",y([{},{props:i},{key:""+o+"-"+i.value}]),[u?e("template",{slot:i.slotName||"default"},[a.Function(u)?i.slot(e):u]):null])},r=(i,o)=>e("ElOptionGroup",{attrs:{label:i.label},key:""+o+"-"+i.label},[a.trueArray(i.options)&&i.options.map((u,p)=>n(u,p))]),c=t.props.formCreateInject.options;return e("ElSelect",y([{},t.data,{ref:"el"}]),[(Array.isArray(c)?c:[]).map((i,o)=>j(i||"","options")?r(i,o):n(i,o)),t.children])},mounted(){this.$emit("fc.el",this.$refs.el)}}});