UNPKG

@form-create/component-ivu-radio

Version:

@form-create/iview 内置组件

10 lines (9 loc) 2.8 kB
/*! * FormCreate 低代码表单渲染器 * @form-create/component-ivu-radio v2.6.3 * (c) 2018-2024 xaboy * Github https://github.com/xaboy/form-create * Site https://form-create.com/ * Released under the MIT License. */ (function(i,o){typeof exports=="object"&&typeof module!="undefined"?module.exports=o():typeof define=="function"&&define.amd?define(o):(i=typeof globalThis!="undefined"?globalThis:i||self,i.FcRadio=o())})(this,function(){"use strict";var M=Object.defineProperty;var l=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var d=(i,o,s)=>o in i?M(i,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[o]=s,f=(i,o)=>{for(var s in o||(o={}))R.call(o,s)&&d(i,s,o[s]);if(l)for(var s of l(o))x.call(o,s)&&d(i,s,o[s]);return i};function i(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function o(){return o=Object.assign?Object.assign.bind():function(r){for(var t,n=1;n<arguments.length;n++)for(var e in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r},o.apply(this,arguments)}var s=["attrs","props","domProps"],h=["class","style","directives"],c=["on","nativeOn"],m=function(r){return r.reduce(function(t,n){for(var e in n)if(!t[e])t[e]=n[e];else if(s.indexOf(e)!==-1)t[e]=o({},t[e],n[e]);else if(h.indexOf(e)!==-1){var j=t[e]instanceof Array?t[e]:[t[e]],O=n[e]instanceof Array?n[e]:[n[e]];t[e]=[].concat(j,O)}else if(c.indexOf(e)!==-1)for(var u in n[e])if(t[e][u]){var A=t[e][u]instanceof Array?t[e][u]:[t[e][u]],I=n[e][u]instanceof Array?n[e][u]:[n[e][u]];t[e][u]=[].concat(A,I)}else t[e][u]=n[e][u];else if(e==="hook")for(var a in n[e])t[e][a]=t[e][a]?y(t[e][a],n[e][a]):n[e][a];else t[e]=n[e];return t},{})},y=function(r,t){return function(){r&&r.apply(this,arguments),t&&t.apply(this,arguments)}},v=m;const p=i(v);function g(r,t){return Object.keys(r).reduce((n,e)=>(n.push(r[e]),n),[])}return{name:"fcRadio",props:{formCreateInject:{type:Object,required:!0},value:{}},watch:{"formCreateInject.options":{handler(){this.update()},deep:!0},value(){this.update()}},data(){return{trueValue:[]}},methods:{options(){const r=this.formCreateInject.options;return Array.isArray(r)?r:[]},onInput(r){this.$emit("input",this.options().filter(t=>t.label===r).reduce((t,n)=>n.value,""))},update(){this.trueValue=this.options().filter(r=>r.value===this.value).reduce((r,t)=>t.label,"")}},created(){this.update()},render(){const r=arguments[0];return r("RadioGroup",p([{},this.formCreateInject.prop,{},{props:{value:this.trueValue}},{ref:"el",on:{input:this.onInput}}]),[this.options().map((t,n)=>{const e=f({},t);return delete e.value,r("Radio",p([{},{props:e},{key:""+n+"-"+t.value}]))}),g(this.$slots)])},mounted(){this.$emit("fc.el",this.$refs.el)}}});