| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- 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
- };
|