| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- /*!
- * FormCreate 低代码表单渲染器
- * @form-create/component-elm-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 y = Object.defineProperty;
- var a = Object.getOwnPropertySymbols;
- var m = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable;
- var p = (n, e, r) => e in n ? y(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r, l = (n, e) => {
- for (var r in e || (e = {}))
- m.call(e, r) && p(n, r, e[r]);
- if (a)
- for (var r of a(e))
- v.call(e, r) && p(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"], x = ["on", "nativeOn"], A = 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 (x.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 = A;
- const h = /* @__PURE__ */ g(k);
- function I(n, e) {
- return Object.keys(n).reduce((r, t) => (r.push(n[t]), r), []);
- }
- const E = "fcCheckbox", P = {
- name: E,
- props: {
- formCreateInject: {
- type: Object,
- required: !0
- },
- value: {
- type: Array,
- default: () => []
- },
- 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) => 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("ElCheckboxGroup", h([{}, this.formCreateInject.prop, {}, {
- props: {
- value: this.trueValue
- }
- }, {
- ref: "el",
- on: {
- input: this.onInput
- }
- }]), [this.options().map((e, r) => {
- const t = l({}, e), i = this.type === "button" ? "ElCheckboxButton" : "ElCheckbox";
- return delete t.value, n(i, h([{}, {
- props: t
- }, {
- key: i + r + "-" + e.value
- }]));
- }), I(this.$slots)]);
- },
- mounted() {
- this.$emit("fc.el", this.$refs.el);
- }
- };
- export {
- P as default
- };
|