import { i as Q, l as de, u as X, j as ce, d as p, o as se, a1 as Y, _ as P, c as ee, M as $, P as z, O as m, e as ie, h as D, N as Z, bY as re, bZ as ue, b_ as fe } from "./index2.js"; import { createVNode as T, defineComponent as te, ref as N, computed as h, watchEffect as ve, watch as V, onUpdated as ye, nextTick as Ke } from "vue"; import { u as he, T as pe, r as xe, t as ke, V as me } from "./index20.js"; import { d as be } from "./debounce.js"; import { e as G, f as Ee, c as Ne, g as Te } from "./useMaxLevel.js"; const J = 4; function _e(e) { const { dropPosition: r, dropLevelOffset: s, prefixCls: a, indent: l, direction: u = "ltr" } = e, d = u === "ltr" ? "left" : "right", c = u === "ltr" ? "right" : "left", v = { [d]: `${-s * l + J}px`, [c]: 0 }; switch (r) { case -1: v.top = "-3px"; break; case 1: v.bottom = "-3px"; break; default: v.bottom = "-3px", v[d] = `${l + J}px`; break; } return T("div", { style: v, class: `${a}-drop-indicator` }, null); } const ne = () => { const e = ke(); return p(p({}, e), { showLine: Z([Boolean, Object]), /** 是否支持多选 */ multiple: m(), /** 是否自动展开父节点 */ autoExpandParent: m(), /** checkable状态下节点选择完全受控(父子节点选中状态不再关联)*/ checkStrictly: m(), /** 是否支持选中 */ checkable: m(), /** 是否禁用树 */ disabled: m(), /** 默认展开所有树节点 */ defaultExpandAll: m(), /** 默认展开对应树节点 */ defaultExpandParent: m(), /** 默认展开指定的树节点 */ defaultExpandedKeys: D(), /** (受控)展开指定的树节点 */ expandedKeys: D(), /** (受控)选中复选框的树节点 */ checkedKeys: Z([Array, Object]), /** 默认选中复选框的树节点 */ defaultCheckedKeys: D(), /** (受控)设置选中的树节点 */ selectedKeys: D(), /** 默认选中的树节点 */ defaultSelectedKeys: D(), selectable: m(), loadedKeys: D(), draggable: m(), showIcon: m(), icon: $(), switcherIcon: z.any, prefixCls: String, /** * @default{title,key,children} * deprecated, please use `fieldNames` instead * 替换treeNode中 title,key,children字段为treeData中对应的字段 */ replaceFields: ie(), blockNode: m(), openAnimation: z.any, onDoubleclick: e.onDblclick, "onUpdate:selectedKeys": $(), "onUpdate:checkedKeys": $(), "onUpdate:expandedKeys": $() }); }, A = te({ compatConfig: { MODE: 3 }, name: "ATree", inheritAttrs: !1, props: Q(ne(), { checkable: !1, selectable: !0, showIcon: !1, blockNode: !1 }), slots: Object, setup(e, r) { let { attrs: s, expose: a, emit: l, slots: u } = r; de(!(e.treeData === void 0 && u.default), "`children` of Tree is deprecated. Please use `treeData` instead."); const { prefixCls: d, direction: c, virtual: v } = X("tree", e), [y, E] = he(d), i = N(); a({ treeRef: i, onNodeExpand: function() { var n; (n = i.value) === null || n === void 0 || n.onNodeExpand(...arguments); }, scrollTo: (n) => { var f; (f = i.value) === null || f === void 0 || f.scrollTo(n); }, selectedKeys: h(() => { var n; return (n = i.value) === null || n === void 0 ? void 0 : n.selectedKeys; }), checkedKeys: h(() => { var n; return (n = i.value) === null || n === void 0 ? void 0 : n.checkedKeys; }), halfCheckedKeys: h(() => { var n; return (n = i.value) === null || n === void 0 ? void 0 : n.halfCheckedKeys; }), loadedKeys: h(() => { var n; return (n = i.value) === null || n === void 0 ? void 0 : n.loadedKeys; }), loadingKeys: h(() => { var n; return (n = i.value) === null || n === void 0 ? void 0 : n.loadingKeys; }), expandedKeys: h(() => { var n; return (n = i.value) === null || n === void 0 ? void 0 : n.expandedKeys; }) }), ve(() => { ce(e.replaceFields === void 0, "Tree", "`replaceFields` is deprecated, please use fieldNames instead"); }); const j = (n, f) => { l("update:checkedKeys", n), l("check", n, f); }, S = (n, f) => { l("update:expandedKeys", n), l("expand", n, f); }, _ = (n, f) => { l("update:selectedKeys", n), l("select", n, f); }; return () => { const { showIcon: n, showLine: f, switcherIcon: F = u.switcherIcon, icon: U = u.icon, blockNode: L, checkable: B, selectable: O, fieldNames: w = e.replaceFields, motion: M = e.openAnimation, itemHeight: t = 28, onDoubleclick: o, onDblclick: K } = e, C = p(p(p({}, s), se(e, ["onUpdate:checkedKeys", "onUpdate:expandedKeys", "onUpdate:selectedKeys", "onDoubleclick"])), { showLine: !!f, dropIndicatorRender: _e, fieldNames: w, icon: U, itemHeight: t }), x = u.default ? Y(u.default()) : void 0; return y(T(pe, P(P({}, C), {}, { virtual: v.value, motion: M, ref: i, prefixCls: d.value, class: ee({ [`${d.value}-icon-hide`]: !n, [`${d.value}-block-node`]: L, [`${d.value}-unselectable`]: !O, [`${d.value}-rtl`]: c.value === "rtl" }, s.class, E.value), direction: c.value, checkable: B, selectable: O, switcherIcon: (g) => xe(d.value, F, g, u.leafIcon, f), onCheck: j, onExpand: S, onSelect: _, onDblclick: K || o, children: x }), p(p({}, u), { checkable: () => T("span", { class: `${d.value}-checkbox-inner` }, null) }))); }; } }); var b; (function(e) { e[e.None = 0] = "None", e[e.Start = 1] = "Start", e[e.End = 2] = "End"; })(b || (b = {})); function q(e, r, s) { function a(l) { const u = l[r.key], d = l[r.children]; s(u, l) !== !1 && q(d || [], r, s); } e.forEach(a); } function ge(e) { let { treeData: r, expandedKeys: s, startKey: a, endKey: l, fieldNames: u = { title: "title", key: "key", children: "children" } } = e; const d = []; let c = b.None; if (a && a === l) return [a]; if (!a || !l) return []; function v(y) { return y === a || y === l; } return q(r, u, (y) => { if (c === b.End) return !1; if (v(y)) { if (d.push(y), c === b.None) c = b.Start; else if (c === b.Start) return c = b.End, !1; } else c === b.Start && d.push(y); return s.includes(y); }), d; } function H(e, r, s) { const a = [...r], l = []; return q(e, s, (u, d) => { const c = a.indexOf(u); return c !== -1 && (l.push(d), a.splice(c, 1)), !!a.length; }), l; } var De = function(e, r) { var s = {}; for (var a in e) Object.prototype.hasOwnProperty.call(e, a) && r.indexOf(a) < 0 && (s[a] = e[a]); if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var l = 0, a = Object.getOwnPropertySymbols(e); l < a.length; l++) r.indexOf(a[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, a[l]) && (s[a[l]] = e[a[l]]); return s; }; const Se = () => p(p({}, ne()), { expandAction: Z([Boolean, String]) }); function we(e) { const { isLeaf: r, expanded: s } = e; return r ? T(re, null, null) : s ? T(ue, null, null) : T(fe, null, null); } const R = te({ compatConfig: { MODE: 3 }, name: "ADirectoryTree", inheritAttrs: !1, props: Q(Se(), { showIcon: !0, expandAction: "click" }), slots: Object, // emits: [ // 'update:selectedKeys', // 'update:checkedKeys', // 'update:expandedKeys', // 'expand', // 'select', // 'check', // 'doubleclick', // 'dblclick', // 'click', // ], setup(e, r) { let { attrs: s, slots: a, emit: l, expose: u } = r; var d; const c = N(e.treeData || G(Y((d = a.default) === null || d === void 0 ? void 0 : d.call(a)))); V(() => e.treeData, () => { c.value = e.treeData; }), ye(() => { Ke(() => { var t; e.treeData === void 0 && a.default && (c.value = G(Y((t = a.default) === null || t === void 0 ? void 0 : t.call(a)))); }); }); const v = N(), y = N(), E = h(() => Ee(e.fieldNames)), i = N(); u({ scrollTo: (t) => { var o; (o = i.value) === null || o === void 0 || o.scrollTo(t); }, selectedKeys: h(() => { var t; return (t = i.value) === null || t === void 0 ? void 0 : t.selectedKeys; }), checkedKeys: h(() => { var t; return (t = i.value) === null || t === void 0 ? void 0 : t.checkedKeys; }), halfCheckedKeys: h(() => { var t; return (t = i.value) === null || t === void 0 ? void 0 : t.halfCheckedKeys; }), loadedKeys: h(() => { var t; return (t = i.value) === null || t === void 0 ? void 0 : t.loadedKeys; }), loadingKeys: h(() => { var t; return (t = i.value) === null || t === void 0 ? void 0 : t.loadingKeys; }), expandedKeys: h(() => { var t; return (t = i.value) === null || t === void 0 ? void 0 : t.expandedKeys; }) }); const j = () => { const { keyEntities: t } = Ne(c.value, { fieldNames: E.value }); let o; return e.defaultExpandAll ? o = Object.keys(t) : e.defaultExpandParent ? o = Te(e.expandedKeys || e.defaultExpandedKeys || [], t) : o = e.expandedKeys || e.defaultExpandedKeys, o; }, S = N(e.selectedKeys || e.defaultSelectedKeys || []), _ = N(j()); V(() => e.selectedKeys, () => { e.selectedKeys !== void 0 && (S.value = e.selectedKeys); }, { immediate: !0 }), V(() => e.expandedKeys, () => { e.expandedKeys !== void 0 && (_.value = e.expandedKeys); }, { immediate: !0 }); const f = be((t, o) => { const { isLeaf: K } = o; K || t.shiftKey || t.metaKey || t.ctrlKey || i.value.onNodeExpand(t, o); }, 200, { leading: !0 }), F = (t, o) => { e.expandedKeys === void 0 && (_.value = t), l("update:expandedKeys", t), l("expand", t, o); }, U = (t, o) => { const { expandAction: K } = e; K === "click" && f(t, o), l("click", t, o); }, L = (t, o) => { const { expandAction: K } = e; (K === "dblclick" || K === "doubleclick") && f(t, o), l("doubleclick", t, o), l("dblclick", t, o); }, B = (t, o) => { const { multiple: K } = e, { node: C, nativeEvent: x } = o, g = C[E.value.key], I = p(p({}, o), { selected: !0 }), ae = (x == null ? void 0 : x.ctrlKey) || (x == null ? void 0 : x.metaKey), oe = x == null ? void 0 : x.shiftKey; let k; K && ae ? (k = t, v.value = g, y.value = k, I.selectedNodes = H(c.value, k, E.value)) : K && oe ? (k = Array.from(/* @__PURE__ */ new Set([...y.value || [], ...ge({ treeData: c.value, expandedKeys: _.value, startKey: g, endKey: v.value, fieldNames: E.value })])), I.selectedNodes = H(c.value, k, E.value)) : (k = [g], v.value = g, y.value = k, I.selectedNodes = H(c.value, k, E.value)), l("update:selectedKeys", k), l("select", k, I), e.selectedKeys === void 0 && (S.value = k); }, O = (t, o) => { l("update:checkedKeys", t), l("check", t, o); }, { prefixCls: w, direction: M } = X("tree", e); return () => { const t = ee(`${w.value}-directory`, { [`${w.value}-directory-rtl`]: M.value === "rtl" }, s.class), { icon: o = a.icon, blockNode: K = !0 } = e, C = De(e, ["icon", "blockNode"]); return T(A, P(P(P({}, s), {}, { icon: o || we, ref: i, blockNode: K }, C), {}, { prefixCls: w.value, class: t, expandedKeys: _.value, selectedKeys: S.value, onSelect: B, onClick: U, onDblclick: L, onExpand: F, onCheck: O }), a); }; } }), W = me, Ae = p(A, { DirectoryTree: R, TreeNode: W, install: (e) => (e.component(A.name, A), e.component(W.name, W), e.component(R.name, R), e) }); export { Ae as T, R as _ };