/*! * FormCreate 低代码表单渲染器 * @form-create/component-elm-tree 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 f(r) { return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; } function i() { return i = Object.assign ? Object.assign.bind() : function(r) { for (var t, n = 1; n < arguments.length; n++) for (var e in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, e) && (r[e] = t[e]); return r; }, i.apply(this, arguments); } var h = ["attrs", "props", "domProps"], c = ["class", "style", "directives"], d = ["on", "nativeOn"], y = function(r) { return r.reduce(function(t, n) { for (var e in n) if (!t[e]) t[e] = n[e]; else if (h.indexOf(e) !== -1) t[e] = i({}, t[e], n[e]); else if (c.indexOf(e) !== -1) { var a = t[e] instanceof Array ? t[e] : [t[e]], u = n[e] instanceof Array ? n[e] : [n[e]]; t[e] = [].concat(a, u); } else if (d.indexOf(e) !== -1) for (var s in n[e]) if (t[e][s]) { var l = t[e][s] instanceof Array ? t[e][s] : [t[e][s]], p = n[e][s] instanceof Array ? n[e][s] : [n[e][s]]; t[e][s] = [].concat(l, p); } else t[e][s] = n[e][s]; else if (e === "hook") for (var o in n[e]) t[e][o] = t[e][o] ? g(t[e][o], n[e][o]) : n[e][o]; else t[e] = n[e]; return t; }, {}); }, g = function(r, t) { return function() { r && r.apply(this, arguments), t && t.apply(this, arguments); }; }, m = y; const v = /* @__PURE__ */ f(m); function O(r) { return Array.isArray(r) ? r : [null, void 0, ""].indexOf(r) > -1 ? [] : [r]; } function C(r, t) { return Object.keys(r).reduce((n, e) => (n.push(r[e]), n), []); } const A = "fcTree", j = { name: A, formCreateParser: { mergeProp(r) { const t = r.prop.props; t.nodeKey || (t.nodeKey = "id"), t.props || (t.props = { label: "title" }); } }, props: { formCreateInject: { type: Object, required: !0 }, type: { type: String, default: "checked" }, value: { type: [Array, String, Number], default: () => [] } }, watch: { value() { this.setValue(); } }, methods: { onChange() { this.updateValue(); }, updateValue() { if (!this.$refs.tree) return; const r = this.type.toLocaleLowerCase(); let t; r === "selected" ? t = this.$refs.tree.getCurrentKey() : t = this.$refs.tree.getCheckedKeys(), this.$emit("input", t); }, setValue() { this.type.toLocaleLowerCase() === "selected" ? this.$refs.tree.setCurrentKey(this.value) : this.$refs.tree.setCheckedKeys(O(this.value)); } }, render() { const r = arguments[0]; return r("ElTree", v([{}, this.formCreateInject.prop, { ref: "tree", on: { check: () => this.updateValue(), "node-click": () => this.updateValue() } }]), [C(this.$slots)]); }, mounted() { this.setValue(), this.$emit("fc.el", this.$refs.tree); } }; export { j as default };