| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- import { i as Y, n as de, u as Z, h as ce, d as p, o as se, ac as q, _ as P, c as ee, a1 as z, a3 as b, j as D, a4 as $, P as J, f as ie, bA as re, bB as ue, bC as fe, bD as ve } from "./index2.js";
- import { createVNode as N, defineComponent as te, ref as T, computed as h, watchEffect as ye, watch as M, onUpdated as Ke, nextTick as he } from "vue";
- import { u as pe, T as xe, r as ke, t as be, V as me } from "./index11.js";
- import { e as Q, f as Ee, c as Te, g as Ne } from "./useMaxLevel.js";
- const X = 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 + X}px`,
- [c]: 0
- };
- switch (r) {
- case -1:
- v.top = "-3px";
- break;
- case 1:
- v.bottom = "-3px";
- break;
- default:
- v.bottom = "-3px", v[d] = `${l + X}px`;
- break;
- }
- return N("div", {
- style: v,
- class: `${a}-drop-indicator`
- }, null);
- }
- const ne = () => {
- const e = be();
- return p(p({}, e), {
- showLine: z([Boolean, Object]),
- /** 是否支持多选 */
- multiple: b(),
- /** 是否自动展开父节点 */
- autoExpandParent: b(),
- /** checkable状态下节点选择完全受控(父子节点选中状态不再关联)*/
- checkStrictly: b(),
- /** 是否支持选中 */
- checkable: b(),
- /** 是否禁用树 */
- disabled: b(),
- /** 默认展开所有树节点 */
- defaultExpandAll: b(),
- /** 默认展开对应树节点 */
- defaultExpandParent: b(),
- /** 默认展开指定的树节点 */
- defaultExpandedKeys: D(),
- /** (受控)展开指定的树节点 */
- expandedKeys: D(),
- /** (受控)选中复选框的树节点 */
- checkedKeys: z([Array, Object]),
- /** 默认选中复选框的树节点 */
- defaultCheckedKeys: D(),
- /** (受控)设置选中的树节点 */
- selectedKeys: D(),
- /** 默认选中的树节点 */
- defaultSelectedKeys: D(),
- selectable: b(),
- loadedKeys: D(),
- draggable: b(),
- showIcon: b(),
- icon: $(),
- switcherIcon: J.any,
- prefixCls: String,
- /**
- * @default{title,key,children}
- * deprecated, please use `fieldNames` instead
- * 替换treeNode中 title,key,children字段为treeData中对应的字段
- */
- replaceFields: ie(),
- blockNode: b(),
- openAnimation: J.any,
- onDoubleclick: e.onDblclick,
- "onUpdate:selectedKeys": $(),
- "onUpdate:checkedKeys": $(),
- "onUpdate:expandedKeys": $()
- });
- }, A = te({
- compatConfig: {
- MODE: 3
- },
- name: "ATree",
- inheritAttrs: !1,
- props: Y(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
- } = Z("tree", e), [y, E] = pe(d), i = T();
- 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;
- })
- }), ye(() => {
- 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: V = 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 ? q(u.default()) : void 0;
- return y(N(xe, P(P({}, C), {}, {
- virtual: v.value,
- motion: V,
- 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) => ke(d.value, F, g, u.leafIcon, f),
- onCheck: j,
- onExpand: S,
- onSelect: _,
- onDblclick: K || o,
- children: x
- }), p(p({}, u), {
- checkable: () => N("span", {
- class: `${d.value}-checkbox-inner`
- }, null)
- })));
- };
- }
- });
- var m;
- (function(e) {
- e[e.None = 0] = "None", e[e.Start = 1] = "Start", e[e.End = 2] = "End";
- })(m || (m = {}));
- function G(e, r, s) {
- function a(l) {
- const u = l[r.key], d = l[r.children];
- s(u, l) !== !1 && G(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 = m.None;
- if (a && a === l)
- return [a];
- if (!a || !l)
- return [];
- function v(y) {
- return y === a || y === l;
- }
- return G(r, u, (y) => {
- if (c === m.End)
- return !1;
- if (v(y)) {
- if (d.push(y), c === m.None)
- c = m.Start;
- else if (c === m.Start)
- return c = m.End, !1;
- } else c === m.Start && d.push(y);
- return s.includes(y);
- }), d;
- }
- function H(e, r, s) {
- const a = [...r], l = [];
- return G(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 ? N(ue, null, null) : s ? N(fe, null, null) : N(ve, null, null);
- }
- const R = te({
- compatConfig: {
- MODE: 3
- },
- name: "ADirectoryTree",
- inheritAttrs: !1,
- props: Y(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 = T(e.treeData || Q(q((d = a.default) === null || d === void 0 ? void 0 : d.call(a))));
- M(() => e.treeData, () => {
- c.value = e.treeData;
- }), Ke(() => {
- he(() => {
- var t;
- e.treeData === void 0 && a.default && (c.value = Q(q((t = a.default) === null || t === void 0 ? void 0 : t.call(a))));
- });
- });
- const v = T(), y = T(), E = h(() => Ee(e.fieldNames)), i = T();
- 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
- } = Te(c.value, {
- fieldNames: E.value
- });
- let o;
- return e.defaultExpandAll ? o = Object.keys(t) : e.defaultExpandParent ? o = Ne(e.expandedKeys || e.defaultExpandedKeys || [], t) : o = e.expandedKeys || e.defaultExpandedKeys, o;
- }, S = T(e.selectedKeys || e.defaultSelectedKeys || []), _ = T(j());
- M(() => e.selectedKeys, () => {
- e.selectedKeys !== void 0 && (S.value = e.selectedKeys);
- }, {
- immediate: !0
- }), M(() => e.expandedKeys, () => {
- e.expandedKeys !== void 0 && (_.value = e.expandedKeys);
- }, {
- immediate: !0
- });
- const f = re((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: V
- } = Z("tree", e);
- return () => {
- const t = ee(`${w.value}-directory`, {
- [`${w.value}-directory-rtl`]: V.value === "rtl"
- }, s.class), {
- icon: o = a.icon,
- blockNode: K = !0
- } = e, C = De(e, ["icon", "blockNode"]);
- return N(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, $e = 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 {
- $e as T,
- R as _
- };
|