@form-create/component-elm-select
Version:
@form-create/element-ui 内置组件
108 lines (107 loc) • 3.37 kB
JavaScript
/*!
* FormCreate 低代码表单渲染器
* @form-create/component-elm-select 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 p(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function y() {
return y = Object.assign ? Object.assign.bind() : function(e) {
for (var t, n = 1; n < arguments.length; n++) for (var r in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
return e;
}, y.apply(this, arguments);
}
var m = ["attrs", "props", "domProps"], d = ["class", "style", "directives"], g = ["on", "nativeOn"], O = function(e) {
return e.reduce(function(t, n) {
for (var r in n) if (!t[r]) t[r] = n[r];
else if (m.indexOf(r) !== -1) t[r] = y({}, t[r], n[r]);
else if (d.indexOf(r) !== -1) {
var a = t[r] instanceof Array ? t[r] : [t[r]], s = n[r] instanceof Array ? n[r] : [n[r]];
t[r] = [].concat(a, s);
} else if (g.indexOf(r) !== -1)
for (var o in n[r]) if (t[r][o]) {
var i = t[r][o] instanceof Array ? t[r][o] : [t[r][o]], c = n[r][o] instanceof Array ? n[r][o] : [n[r][o]];
t[r][o] = [].concat(i, c);
} else t[r][o] = n[r][o];
else if (r === "hook") for (var l in n[r]) t[r][l] = t[r][l] ? A(t[r][l], n[r][l]) : n[r][l];
else t[r] = n[r];
return t;
}, {});
}, A = function(e, t) {
return function() {
e && e.apply(this, arguments), t && t.apply(this, arguments);
};
}, j = O;
const f = /* @__PURE__ */ p(j), u = {
type(e, t) {
return Object.prototype.toString.call(e) === "[object " + t + "]";
},
Undef(e) {
return e == null;
},
Element(e) {
return typeof e == "object" && e !== null && e.nodeType === 1 && !u.Object(e);
},
trueArray(e) {
return Array.isArray(e) && e.length > 0;
},
Function(e) {
const t = this.getType(e);
return t === "Function" || t === "AsyncFunction";
},
getType(e) {
const t = Object.prototype.toString.call(e);
return /^\[object (.*)\]$/.exec(t)[1];
},
empty(e) {
return e == null || Array.isArray(e) && Array.isArray(e) && !e.length ? !0 : typeof e == "string" && !e;
}
};
["Date", "Object", "String", "Boolean", "Array", "Number"].forEach((e) => {
u[e] = function(t) {
return u.type(t, e);
};
});
function h(e, t) {
return {}.hasOwnProperty.call(e, t);
}
const E = "fcSelect", P = {
name: E,
functional: !0,
props: {
formCreateInject: {
type: Object,
required: !0
}
},
render(e, t) {
const n = (s, o) => {
const i = s.slot;
return e("ElOption", f([{}, {
props: s
}, {
key: "" + o + "-" + s.value
}]), [i ? e("template", {
slot: s.slotName || "default"
}, [u.Function(i) ? s.slot(e) : i]) : null]);
}, r = (s, o) => e("ElOptionGroup", {
attrs: {
label: s.label
},
key: "" + o + "-" + s.label
}, [u.trueArray(s.options) && s.options.map((i, c) => n(i, c))]), a = t.props.formCreateInject.options;
return e("ElSelect", f([{}, t.data, {
ref: "el"
}]), [(Array.isArray(a) ? a : []).map((s, o) => h(s || "", "options") ? r(s, o) : n(s, o)), t.children]);
},
mounted() {
this.$emit("fc.el", this.$refs.el);
}
};
export {
P as default
};