UNPKG

@form-create/component-elm-radio

Version:

@form-create/element-ui 内置组件

123 lines (122 loc) 3.52 kB
/*! * FormCreate 低代码表单渲染器 * @form-create/component-elm-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 y = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable; var l = (n, e, r) => e in n ? m(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r, p = (n, e) => { for (var r in e || (e = {})) y.call(e, r) && l(n, r, e[r]); if (a) for (var r of a(e)) v.call(e, r) && l(n, r, e[r]); return n; }; function g(n) { return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n; } function u() { return u = 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; }, u.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] = u({}, e[t], r[t]); else if (j.indexOf(t) !== -1) { var i = e[t] instanceof Array ? e[t] : [e[t]], f = r[t] instanceof Array ? r[t] : [r[t]]; e[t] = [].concat(i, f); } 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); }; }, E = I; const d = /* @__PURE__ */ g(E); function M(n, e) { return Object.keys(n).reduce((r, t) => (r.push(n[t]), r), []); } const P = "fcRadio", x = { name: P, props: { formCreateInject: { type: Object, required: !0 }, value: {}, type: String }, 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("ElRadioGroup", d([{}, this.formCreateInject.prop, { ref: "el" }, { props: { value: this.trueValue } }, { on: { input: this.onInput } }]), [this.options().map((e, r) => { const t = p({}, e), i = this.type === "button" ? "ElRadioButton" : "ElRadio"; return delete t.value, n(i, d([{}, { props: t }, { key: i + r + "-" + e.value }])); }), M(this.$slots)]); }, mounted() { this.$emit("fc.el", this.$refs.el); } }; export { x as default };