UNPKG

@form-create/component-ivu-radio

Version:

@form-create/iview 内置组件

121 lines (120 loc) 3.44 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. */ var m = Object.defineProperty; var a = Object.getOwnPropertySymbols; var v = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable; var u = (n, e, r) => e in n ? m(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r, l = (n, e) => { for (var r in e || (e = {})) v.call(e, r) && u(n, r, e[r]); if (a) for (var r of a(e)) y.call(e, r) && u(n, r, e[r]); return n; }; function g(n) { return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n; } function i() { return i = Object.assign ? Object.assign.bind() : function(n) { for (var e, r = 1; r < arguments.length; r++) for (var t in e = arguments[r], e) Object.prototype.hasOwnProperty.call(e, t) && (n[t] = e[t]); return n; }, i.apply(this, arguments); } var O = ["attrs", "props", "domProps"], j = ["class", "style", "directives"], A = ["on", "nativeOn"], I = function(n) { return n.reduce(function(e, r) { for (var t in r) if (!e[t]) e[t] = r[t]; else if (O.indexOf(t) !== -1) e[t] = i({}, e[t], r[t]); else if (j.indexOf(t) !== -1) { var f = e[t] instanceof Array ? e[t] : [e[t]], d = r[t] instanceof Array ? r[t] : [r[t]]; e[t] = [].concat(f, d); } else if (A.indexOf(t) !== -1) for (var o in r[t]) if (e[t][o]) { var h = e[t][o] instanceof Array ? e[t][o] : [e[t][o]], c = r[t][o] instanceof Array ? r[t][o] : [r[t][o]]; e[t][o] = [].concat(h, c); } else e[t][o] = r[t][o]; else if (t === "hook") for (var s in r[t]) e[t][s] = e[t][s] ? C(e[t][s], r[t][s]) : r[t][s]; else e[t] = r[t]; return e; }, {}); }, C = function(n, e) { return function() { n && n.apply(this, arguments), e && e.apply(this, arguments); }; }, M = I; const p = /* @__PURE__ */ g(M); function P(n, e) { return Object.keys(n).reduce((r, t) => (r.push(n[t]), r), []); } const x = "fcRadio", _ = { name: x, props: { formCreateInject: { type: Object, required: !0 }, value: {} }, watch: { "formCreateInject.options": { handler() { this.update(); }, deep: !0 }, value() { this.update(); } }, data() { return { trueValue: [] }; }, methods: { options() { const n = this.formCreateInject.options; return Array.isArray(n) ? n : []; }, onInput(n) { this.$emit("input", this.options().filter((e) => e.label === n).reduce((e, r) => r.value, "")); }, update() { this.trueValue = this.options().filter((n) => n.value === this.value).reduce((n, e) => e.label, ""); } }, created() { this.update(); }, render() { const n = arguments[0]; return n("RadioGroup", p([{}, this.formCreateInject.prop, {}, { props: { value: this.trueValue } }, { ref: "el", on: { input: this.onInput } }]), [this.options().map((e, r) => { const t = l({}, e); return delete t.value, n("Radio", p([{}, { props: t }, { key: "" + r + "-" + e.value }])); }), P(this.$slots)]); }, mounted() { this.$emit("fc.el", this.$refs.el); } }; export { _ as default };