UNPKG

@form-create/component-ivu-checkbox

Version:

@form-create/iview 内置组件

126 lines (125 loc) 3.6 kB
/*! * FormCreate 低代码表单渲染器 * @form-create/component-ivu-checkbox 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 u = (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) && u(n, r, e[r]); if (a) for (var r of a(e)) v.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"], x = 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]], h = r[t] instanceof Array ? r[t] : [r[t]]; e[t] = [].concat(f, h); } else if (A.indexOf(t) !== -1) for (var o in r[t]) if (e[t][o]) { var c = e[t][o] instanceof Array ? e[t][o] : [e[t][o]], d = r[t][o] instanceof Array ? r[t][o] : [r[t][o]]; e[t][o] = [].concat(c, d); } 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); }; }, k = x; const l = /* @__PURE__ */ g(k); function I(n, e) { return Object.keys(n).reduce((r, t) => (r.push(n[t]), r), []); } const M = "fcCheckbox", _ = { name: M, props: { formCreateInject: { type: Object, required: !0 }, value: { type: Array, default: () => [] } }, 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) => n.indexOf(e.label) !== -1).map((e) => e.value).filter((e) => e !== void 0)); }, update() { const n = Array.isArray(this.value) ? this.value : [this.value]; this.trueValue = this.options().filter((e) => n.indexOf(e.value) !== -1).map((e) => e.label); } }, created() { this.update(); }, render() { const n = arguments[0]; return n("CheckboxGroup", l([{}, this.formCreateInject.prop, { ref: "el" }, { props: { value: this.trueValue } }, { on: { input: this.onInput } }]), [this.options().map((e, r) => { const t = p({}, e); return delete t.value, n("Checkbox", l([{}, { props: t }, { key: "" + r + "-" + e.value }])); }), I(this.$slots)]); }, mounted() { this.$emit("fc.el", this.$refs.el); } }; export { _ as default };