var G = (e, f, d) => new Promise((a, l) => { var i = (r) => { try { c(d.next(r)); } catch (y) { l(y); } }, o = (r) => { try { c(d.throw(r)); } catch (y) { l(y); } }, c = (r) => r.done ? a(r.value) : Promise.resolve(r.value).then(i, o); c((d = d.apply(e, f)).next()); }); import { createVNode as S, defineComponent as oe, ref as E, computed as K, watchEffect as fe, watch as Q, onUpdated as ve, nextTick as ye, onMounted as he, openBlock as W, createElementBlock as ee, withCtx as F, createElementVNode as te, normalizeClass as pe, toDisplayString as j, createBlock as Ke, createTextVNode as xe } from "vue"; import { b as de, w as me, j as ce, d as ke, _ as m, o as be, $ as X, a as P, m as se, F as Y, D as g, T as C, C as B, P as ne, e as _e, aQ as ge, aR as Ee, aS as we, r as Te, H as Ne } from "./index2.js"; import { d as Se } from "./debounce.js"; import { u as De, T as Ce, r as Oe, t as Ie, V as Pe } from "./index8.js"; import { b as le, f as Ae, c as $e, d as Fe } from "./index4.js"; const ae = 4; function je(e) { const { dropPosition: f, dropLevelOffset: d, prefixCls: a, indent: l, direction: i = "ltr" } = e, o = i === "ltr" ? "left" : "right", c = i === "ltr" ? "right" : "left", r = { [o]: `${-d * l + ae}px`, [c]: 0 }; switch (f) { case -1: r.top = "-3px"; break; case 1: r.bottom = "-3px"; break; default: r.bottom = "-3px", r[o] = `${l + ae}px`; break; } return S("div", { style: r, class: `${a}-drop-indicator` }, null); } const ie = () => { const e = Ie(); return m(m({}, e), { showLine: Y([Boolean, Object]), /** 是否支持多选 */ multiple: g(), /** 是否自动展开父节点 */ autoExpandParent: g(), /** checkable状态下节点选择完全受控(父子节点选中状态不再关联)*/ checkStrictly: g(), /** 是否支持选中 */ checkable: g(), /** 是否禁用树 */ disabled: g(), /** 默认展开所有树节点 */ defaultExpandAll: g(), /** 默认展开对应树节点 */ defaultExpandParent: g(), /** 默认展开指定的树节点 */ defaultExpandedKeys: C(), /** (受控)展开指定的树节点 */ expandedKeys: C(), /** (受控)选中复选框的树节点 */ checkedKeys: Y([Array, Object]), /** 默认选中复选框的树节点 */ defaultCheckedKeys: C(), /** (受控)设置选中的树节点 */ selectedKeys: C(), /** 默认选中的树节点 */ defaultSelectedKeys: C(), selectable: g(), loadedKeys: C(), draggable: g(), showIcon: g(), icon: B(), switcherIcon: ne.any, prefixCls: String, /** * @default{title,key,children} * deprecated, please use `fieldNames` instead * 替换treeNode中 title,key,children字段为treeData中对应的字段 */ replaceFields: _e(), blockNode: g(), openAnimation: ne.any, onDoubleclick: e.onDblclick, "onUpdate:selectedKeys": B(), "onUpdate:checkedKeys": B(), "onUpdate:expandedKeys": B() }); }, U = oe({ compatConfig: { MODE: 3 }, name: "ATree", inheritAttrs: !1, props: de(ie(), { checkable: !1, selectable: !0, showIcon: !1, blockNode: !1 }), slots: Object, setup(e, f) { let { attrs: d, expose: a, emit: l, slots: i } = f; me(!(e.treeData === void 0 && i.default), "`children` of Tree is deprecated. Please use `treeData` instead."); const { prefixCls: o, direction: c, virtual: r } = ce("tree", e), [y, w] = De(o), u = E(); a({ treeRef: u, onNodeExpand: function() { var n; (n = u.value) === null || n === void 0 || n.onNodeExpand(...arguments); }, scrollTo: (n) => { var h; (h = u.value) === null || h === void 0 || h.scrollTo(n); }, selectedKeys: K(() => { var n; return (n = u.value) === null || n === void 0 ? void 0 : n.selectedKeys; }), checkedKeys: K(() => { var n; return (n = u.value) === null || n === void 0 ? void 0 : n.checkedKeys; }), halfCheckedKeys: K(() => { var n; return (n = u.value) === null || n === void 0 ? void 0 : n.halfCheckedKeys; }), loadedKeys: K(() => { var n; return (n = u.value) === null || n === void 0 ? void 0 : n.loadedKeys; }), loadingKeys: K(() => { var n; return (n = u.value) === null || n === void 0 ? void 0 : n.loadingKeys; }), expandedKeys: K(() => { var n; return (n = u.value) === null || n === void 0 ? void 0 : n.expandedKeys; }) }), fe(() => { ke(e.replaceFields === void 0, "Tree", "`replaceFields` is deprecated, please use fieldNames instead"); }); const v = (n, h) => { l("update:checkedKeys", n), l("check", n, h); }, T = (n, h) => { l("update:expandedKeys", n), l("expand", n, h); }, k = (n, h) => { l("update:selectedKeys", n), l("select", n, h); }; return () => { const { showIcon: n, showLine: h, switcherIcon: L = i.switcherIcon, icon: R = i.icon, blockNode: M, checkable: H, selectable: A, fieldNames: O = e.replaceFields, motion: z = e.openAnimation, itemHeight: t = 28, onDoubleclick: s, onDblclick: p } = e, I = m(m(m({}, d), be(e, ["onUpdate:checkedKeys", "onUpdate:expandedKeys", "onUpdate:selectedKeys", "onDoubleclick"])), { showLine: !!h, dropIndicatorRender: je, fieldNames: O, icon: R, itemHeight: t }), b = i.default ? X(i.default()) : void 0; return y(S(Ce, P(P({}, I), {}, { virtual: r.value, motion: z, ref: u, prefixCls: o.value, class: se({ [`${o.value}-icon-hide`]: !n, [`${o.value}-block-node`]: M, [`${o.value}-unselectable`]: !A, [`${o.value}-rtl`]: c.value === "rtl" }, d.class, w.value), direction: c.value, checkable: H, selectable: A, switcherIcon: (D) => Oe(o.value, L, D, i.leafIcon, h), onCheck: v, onExpand: T, onSelect: k, onDblclick: p || s, children: b }), m(m({}, i), { checkable: () => S("span", { class: `${o.value}-checkbox-inner` }, null) }))); }; } }); var N; (function(e) { e[e.None = 0] = "None", e[e.Start = 1] = "Start", e[e.End = 2] = "End"; })(N || (N = {})); function Z(e, f, d) { function a(l) { const i = l[f.key], o = l[f.children]; d(i, l) !== !1 && Z(o || [], f, d); } e.forEach(a); } function Be(e) { let { treeData: f, expandedKeys: d, startKey: a, endKey: l, fieldNames: i = { title: "title", key: "key", children: "children" } } = e; const o = []; let c = N.None; if (a && a === l) return [a]; if (!a || !l) return []; function r(y) { return y === a || y === l; } return Z(f, i, (y) => { if (c === N.End) return !1; if (r(y)) { if (o.push(y), c === N.None) c = N.Start; else if (c === N.Start) return c = N.End, !1; } else c === N.Start && o.push(y); return d.includes(y); }), o; } function q(e, f, d) { const a = [...f], l = []; return Z(e, d, (i, o) => { const c = a.indexOf(i); return c !== -1 && (l.push(o), a.splice(c, 1)), !!a.length; }), l; } var Ue = function(e, f) { var d = {}; for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && f.indexOf(a) < 0 && (d[a] = e[a]); if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var l = 0, a = Object.getOwnPropertySymbols(e); l < a.length; l++) f.indexOf(a[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, a[l]) && (d[a[l]] = e[a[l]]); return d; }; const Ve = () => m(m({}, ie()), { expandAction: Y([Boolean, String]) }); function Le(e) { const { isLeaf: f, expanded: d } = e; return f ? S(ge, null, null) : d ? S(Ee, null, null) : S(we, null, null); } const V = oe({ compatConfig: { MODE: 3 }, name: "ADirectoryTree", inheritAttrs: !1, props: de(Ve(), { showIcon: !0, expandAction: "click" }), slots: Object, // emits: [ // 'update:selectedKeys', // 'update:checkedKeys', // 'update:expandedKeys', // 'expand', // 'select', // 'check', // 'doubleclick', // 'dblclick', // 'click', // ], setup(e, f) { let { attrs: d, slots: a, emit: l, expose: i } = f; var o; const c = E(e.treeData || le(X((o = a.default) === null || o === void 0 ? void 0 : o.call(a)))); Q(() => e.treeData, () => { c.value = e.treeData; }), ve(() => { ye(() => { var t; e.treeData === void 0 && a.default && (c.value = le(X((t = a.default) === null || t === void 0 ? void 0 : t.call(a)))); }); }); const r = E(), y = E(), w = K(() => Ae(e.fieldNames)), u = E(); i({ scrollTo: (t) => { var s; (s = u.value) === null || s === void 0 || s.scrollTo(t); }, selectedKeys: K(() => { var t; return (t = u.value) === null || t === void 0 ? void 0 : t.selectedKeys; }), checkedKeys: K(() => { var t; return (t = u.value) === null || t === void 0 ? void 0 : t.checkedKeys; }), halfCheckedKeys: K(() => { var t; return (t = u.value) === null || t === void 0 ? void 0 : t.halfCheckedKeys; }), loadedKeys: K(() => { var t; return (t = u.value) === null || t === void 0 ? void 0 : t.loadedKeys; }), loadingKeys: K(() => { var t; return (t = u.value) === null || t === void 0 ? void 0 : t.loadingKeys; }), expandedKeys: K(() => { var t; return (t = u.value) === null || t === void 0 ? void 0 : t.expandedKeys; }) }); const v = () => { const { keyEntities: t } = $e(c.value, { fieldNames: w.value }); let s; return e.defaultExpandAll ? s = Object.keys(t) : e.defaultExpandParent ? s = Fe(e.expandedKeys || e.defaultExpandedKeys || [], t) : s = e.expandedKeys || e.defaultExpandedKeys, s; }, T = E(e.selectedKeys || e.defaultSelectedKeys || []), k = E(v()); Q(() => e.selectedKeys, () => { e.selectedKeys !== void 0 && (T.value = e.selectedKeys); }, { immediate: !0 }), Q(() => e.expandedKeys, () => { e.expandedKeys !== void 0 && (k.value = e.expandedKeys); }, { immediate: !0 }); const h = Se((t, s) => { const { isLeaf: p } = s; p || t.shiftKey || t.metaKey || t.ctrlKey || u.value.onNodeExpand(t, s); }, 200, { leading: !0 }), L = (t, s) => { e.expandedKeys === void 0 && (k.value = t), l("update:expandedKeys", t), l("expand", t, s); }, R = (t, s) => { const { expandAction: p } = e; p === "click" && h(t, s), l("click", t, s); }, M = (t, s) => { const { expandAction: p } = e; (p === "dblclick" || p === "doubleclick") && h(t, s), l("doubleclick", t, s), l("dblclick", t, s); }, H = (t, s) => { const { multiple: p } = e, { node: I, nativeEvent: b } = s, D = I[w.value.key], $ = m(m({}, s), { selected: !0 }), re = (b == null ? void 0 : b.ctrlKey) || (b == null ? void 0 : b.metaKey), ue = b == null ? void 0 : b.shiftKey; let _; p && re ? (_ = t, r.value = D, y.value = _, $.selectedNodes = q(c.value, _, w.value)) : p && ue ? (_ = Array.from(/* @__PURE__ */ new Set([...y.value || [], ...Be({ treeData: c.value, expandedKeys: k.value, startKey: D, endKey: r.value, fieldNames: w.value })])), $.selectedNodes = q(c.value, _, w.value)) : (_ = [D], r.value = D, y.value = _, $.selectedNodes = q(c.value, _, w.value)), l("update:selectedKeys", _), l("select", _, $), e.selectedKeys === void 0 && (T.value = _); }, A = (t, s) => { l("update:checkedKeys", t), l("check", t, s); }, { prefixCls: O, direction: z } = ce("tree", e); return () => { const t = se(`${O.value}-directory`, { [`${O.value}-directory-rtl`]: z.value === "rtl" }, d.class), { icon: s = a.icon, blockNode: p = !0 } = e, I = Ue(e, ["icon", "blockNode"]); return S(U, P(P(P({}, d), {}, { icon: s || Le, ref: u, blockNode: p }, I), {}, { prefixCls: O.value, class: t, expandedKeys: k.value, selectedKeys: T.value, onSelect: H, onClick: R, onDblclick: M, onExpand: L, onCheck: A }), a); }; } }), J = Pe; m(U, { DirectoryTree: V, TreeNode: J, install: (e) => (e.component(U.name, U), e.component(J.name, J), e.component(V.name, V), e) }); const Re = { class: "s-tree-common" }, Me = { class: "node-title" }, He = { key: 1, class: "node-title" }, ze = { __name: "STree", props: { // 是否展开所有节点 expandAll: { type: Boolean, default: !1 }, // 树节点属性 props: { type: Object, default: () => ({ children: "children", label: "name", value: "value" }) }, // 是否添加复选框 checkable: { type: Boolean, default: !1 }, // 树高度 height: { type: Number, default: 300 }, // 获取一级节点数据 levelOneChildren: { type: Function, default: () => { } }, // 获取二级节点数据 levelTwoChildren: { type: Function, default: () => { } }, // 默认选中项,支持 v-model 双向绑定 modelValue: { type: [String, Array], default() { return ""; } }, // 默认选中第一个节点 selectFirstOne: { type: Boolean, default: !1 }, // 是否显示图标 showIcon: { type: Boolean, default: !1 }, // 显示字数长度 超过15字符显示省略号并且鼠标悬浮tooltip显示 showLength: { type: [Number, String], default: 15 } }, emits: ["select:modelValue"], setup(e, { emit: f }) { const d = e, a = f, l = E([]), i = E([]), o = E([]), c = E([]), r = (x, v) => G(this, null, function* () { v.expanded && (!v.node.dataRef.children || v.node.dataRef.children.length === 0) && (v.node.dataRef.children = yield d.levelOneChildren(v.node.dataRef.id)), x.value = x; }), y = (x, v) => { a("select:modelValue", x, v); }, w = () => G(this, null, function* () { var x, v, T, k; o.value = [], l.value = yield d.levelTwoChildren(), (x = l.value) != null && x.length && ((T = (v = l.value[0]) == null ? void 0 : v.children[0]) != null && T.length) && (d.selectFirstOne && (l.value[0].selected = !0, i.value.push(((k = l.value[0]) == null ? void 0 : k.id) || ""), a("select:modelValue", l.value[0].id || "", l.value[0])), o.value = [l.value[0].id]); }), u = (x) => ["D", "G", "C", "D"][x]; return he(() => { w(); }), (x, v) => { const T = Ne, k = V; return W(), ee("div", Re, [ S(k, { selectedKeys: i.value, "onUpdate:selectedKeys": v[0] || (v[0] = (n) => i.value = n), checkedKeys: o.value, "onUpdate:checkedKeys": v[1] || (v[1] = (n) => o.value = n), expandedKeys: c.value, "onUpdate:expandedKeys": v[2] || (v[2] = (n) => c.value = n), "default-expand-all": e.expandAll, checkable: e.checkable, "tree-data": l.value, showIcon: e.showIcon, height: e.height, onExpand: r, onSelect: y }, { icon: F((n) => [ te("div", { class: pe(["node-icon", u(n.type)]) }, j(u(n.type)), 3) ]), title: F((n) => [ n.title.length > 15 ? (W(), Ke(T, { key: 0, placement: "topLeft" }, { title: F(() => [ xe(j(n.title), 1) ]), default: F(() => [ te("div", Me, j(n.title.slice(0, 15)) + "... ", 1) ]), _: 2 }, 1024)) : (W(), ee("div", He, j(n.title), 1)) ]), _: 1 }, 8, ["selectedKeys", "checkedKeys", "expandedKeys", "default-expand-all", "checkable", "tree-data", "showIcon", "height"]) ]); }; } }, Ye = /* @__PURE__ */ Te(ze, [["__scopeId", "data-v-aa1c998c"]]); export { Ye as default };