@keyblade/pro-components 1.15.0-alpha.2 → 1.15.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/pro-layout/hooks.js +95 -100
- package/es/pro-reuse-tabs/pro-reuse-tabs.vue.js +15 -15
- package/package.json +1 -1
package/es/pro-layout/hooks.js
CHANGED
|
@@ -2,194 +2,189 @@ var V = Object.defineProperty, X = Object.defineProperties;
|
|
|
2
2
|
var Y = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var x = Object.getOwnPropertySymbols;
|
|
4
4
|
var Z = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var J = (c, s,
|
|
6
|
-
for (var
|
|
7
|
-
Z.call(s,
|
|
5
|
+
var J = (c, s, n) => s in c ? V(c, s, { enumerable: !0, configurable: !0, writable: !0, value: n }) : c[s] = n, O = (c, s) => {
|
|
6
|
+
for (var n in s || (s = {}))
|
|
7
|
+
Z.call(s, n) && J(c, n, s[n]);
|
|
8
8
|
if (x)
|
|
9
|
-
for (var
|
|
10
|
-
$.call(s,
|
|
9
|
+
for (var n of x(s))
|
|
10
|
+
$.call(s, n) && J(c, n, s[n]);
|
|
11
11
|
return c;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var p = (
|
|
12
|
+
}, A = (c, s) => X(c, Y(s));
|
|
13
|
+
var D = (c, s, n) => new Promise((K, b) => {
|
|
14
|
+
var p = (f) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
o(n.next(f));
|
|
17
17
|
} catch (d) {
|
|
18
|
-
|
|
18
|
+
b(d);
|
|
19
19
|
}
|
|
20
|
-
}, M = (
|
|
20
|
+
}, M = (f) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
o(n.throw(f));
|
|
23
23
|
} catch (d) {
|
|
24
|
-
|
|
24
|
+
b(d);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, o = (f) => f.done ? K(f.value) : Promise.resolve(f.value).then(p, M);
|
|
27
|
+
o((n = n.apply(c, s)).next());
|
|
28
28
|
});
|
|
29
|
-
import { ref as v, computed as _, watch as
|
|
29
|
+
import { ref as v, computed as _, watch as E } from "vue";
|
|
30
30
|
import { useRoute as I, useRouter as m } from "vue-router";
|
|
31
|
-
import { ProLayoutMode as
|
|
32
|
-
const
|
|
33
|
-
const s = I(),
|
|
31
|
+
import { ProLayoutMode as k, ProLayoutMenuType as L } from "./enum.js";
|
|
32
|
+
const ne = (c) => {
|
|
33
|
+
const s = I(), n = m(), K = v([]), b = v([]), p = v([]), M = v([]), o = v(), f = v([]), d = v({}), N = v([]), h = v([]), T = v([]), S = v([]), y = v([]), g = _(() => {
|
|
34
34
|
const e = [...c.menuItems], a = (t) => {
|
|
35
35
|
t.forEach((l) => {
|
|
36
36
|
if (l != null && l.children && l.children.length > 0) {
|
|
37
37
|
if ((l == null ? void 0 : l.topChildrenMenu) !== void 0)
|
|
38
|
-
l.children = l.children.map((
|
|
38
|
+
l.children = l.children.map((i) => A(O({}, i), { topMenu: l == null ? void 0 : l.topChildrenMenu }));
|
|
39
39
|
else {
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const i = l.children.find((u) => u.topMenu !== void 0);
|
|
41
|
+
i && (l.topChildrenMenu = i.topMenu, l.children = l.children.map((u) => A(O({}, u), { topMenu: i.topMenu })));
|
|
42
42
|
}
|
|
43
43
|
a(l.children);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
-
return c.layout ===
|
|
48
|
-
}),
|
|
47
|
+
return c.layout === k.mix && a(e), e;
|
|
48
|
+
}), R = (e) => {
|
|
49
49
|
var a;
|
|
50
50
|
if (K.value = [e.name], !(e != null && e.children) || ((a = e == null ? void 0 : e.children) == null ? void 0 : a.length) === 0)
|
|
51
|
-
y.value = [],
|
|
51
|
+
y.value = [], n == null || n.push({ path: e.path });
|
|
52
52
|
else if (y.value = e.children, e != null && e.redirect)
|
|
53
53
|
if (typeof e.redirect == "string")
|
|
54
|
-
|
|
54
|
+
n == null || n.push({ path: e.redirect });
|
|
55
55
|
else if (typeof e.redirect == "function") {
|
|
56
56
|
const t = e.redirect(s);
|
|
57
|
-
|
|
57
|
+
n == null || n.push(t);
|
|
58
58
|
} else
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
e != null && e.name ?
|
|
62
|
-
},
|
|
59
|
+
n == null || n.push(e.redirect);
|
|
60
|
+
}, W = (e) => {
|
|
61
|
+
e != null && e.name ? n == null || n.push({ name: e.name }) : n == null || n.push({ path: e.path }), b.value = [e.name];
|
|
62
|
+
}, B = (e, a) => D(null, null, function* () {
|
|
63
63
|
if (a != null && a.path && !(c != null && c.onMenuItemClick && !(yield c.onMenuItemClick(a)))) {
|
|
64
64
|
if (a.path.startsWith("http") || a.path.startsWith("https")) {
|
|
65
65
|
window.open(a.path);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
e ===
|
|
68
|
+
e === L.top ? R(a) : W(a);
|
|
69
69
|
}
|
|
70
70
|
}), H = (e, a) => {
|
|
71
|
-
e ===
|
|
71
|
+
e === L.top ? p.value = a : M.value = a;
|
|
72
72
|
}, j = () => {
|
|
73
73
|
const e = [], a = (t) => {
|
|
74
74
|
var l;
|
|
75
|
-
for (const
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
return e.unshift(
|
|
75
|
+
for (const i in t) {
|
|
76
|
+
const u = t[i];
|
|
77
|
+
if (u.name === ((l = o == null ? void 0 : o.value) == null ? void 0 : l.name) || u.children && u.children.length > 0 && a(u.children))
|
|
78
|
+
return e.unshift(u), !0;
|
|
79
79
|
}
|
|
80
80
|
return !1;
|
|
81
81
|
};
|
|
82
|
-
a(JSON.parse(JSON.stringify(
|
|
82
|
+
a(JSON.parse(JSON.stringify(g.value))), f.value = e;
|
|
83
83
|
}, q = () => {
|
|
84
84
|
var a, t, l;
|
|
85
|
-
const e = (a =
|
|
86
|
-
|
|
85
|
+
const e = (a = f.value) == null ? void 0 : a.map((i) => ({ path: i == null ? void 0 : i.path, label: i == null ? void 0 : i.title }));
|
|
86
|
+
N.value = (t = o.value) != null && t.breadcrumbs ? (l = o.value) == null ? void 0 : l.breadcrumbs : e.length !== 0 ? e : [];
|
|
87
87
|
};
|
|
88
88
|
function z() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
var P, C;
|
|
90
|
+
if (!o.value || o.value.noAffix) {
|
|
91
|
+
h.value.forEach((r) => {
|
|
92
|
+
r.active = !1;
|
|
92
93
|
});
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
|
-
const { name: e, title: a } =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
n.active = !1, n.name === e && (t = o);
|
|
96
|
+
const { name: e, title: a } = o.value;
|
|
97
|
+
h.value.forEach((r) => {
|
|
98
|
+
r.active = !1;
|
|
99
99
|
});
|
|
100
|
-
const l = {
|
|
100
|
+
const t = (P = s.meta) == null ? void 0 : P.getTitle, l = typeof t == "function" ? t(s) : void 0, i = {
|
|
101
101
|
name: e,
|
|
102
|
-
parentNames:
|
|
103
|
-
title:
|
|
102
|
+
parentNames: f.value.map((r) => r.name),
|
|
103
|
+
title: (C = l != null ? l : a) != null ? C : e,
|
|
104
104
|
fullPath: s.fullPath,
|
|
105
105
|
active: !0
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const n = f.value[t];
|
|
109
|
-
n.fullPath === s.fullPath ? (n.active = !0, n.fullPath = s.fullPath) : (f.value.splice(t, 1), setTimeout(() => {
|
|
110
|
-
f.value.push(l);
|
|
111
|
-
}));
|
|
112
|
-
} else
|
|
113
|
-
f.value.push(l);
|
|
106
|
+
}, u = h.value.findIndex((r) => r.fullPath === s.fullPath);
|
|
107
|
+
u >= 0 ? h.value[u].active = !0 : h.value.push(i);
|
|
114
108
|
}
|
|
115
109
|
const F = (e) => {
|
|
116
|
-
const a =
|
|
117
|
-
|
|
110
|
+
const a = h.value.find((t) => t.fullPath === e);
|
|
111
|
+
a && n.push(a.fullPath);
|
|
118
112
|
}, G = (e) => {
|
|
119
113
|
let a = -1, t = -1;
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
}),
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
if (h.value.forEach((i, u) => {
|
|
115
|
+
i.fullPath === e && (t = u), i.active && (a = u);
|
|
116
|
+
}), t === -1) return;
|
|
117
|
+
if (a === t) {
|
|
118
|
+
let i;
|
|
119
|
+
t === 0 ? i = h.value[t + 1] : i = h.value[t - 1], i && (i.active = !0, n.push(i.fullPath));
|
|
125
120
|
}
|
|
126
|
-
const l =
|
|
121
|
+
const l = h.value.splice(t, 1);
|
|
127
122
|
U(l[0]);
|
|
128
123
|
}, Q = () => {
|
|
129
124
|
var a;
|
|
130
125
|
if (c != null && c.disableKeepAlive || (a = s == null ? void 0 : s.meta) != null && a.ignoreCache)
|
|
131
126
|
return;
|
|
132
|
-
const e = new Set(
|
|
133
|
-
|
|
127
|
+
const e = new Set(T.value);
|
|
128
|
+
f.value.forEach((t) => {
|
|
134
129
|
t.name && e.add(t.name);
|
|
135
|
-
}),
|
|
130
|
+
}), T.value = Array.from(e.values());
|
|
136
131
|
}, U = (e) => {
|
|
137
|
-
const a = new Set(
|
|
132
|
+
const a = new Set(T.value);
|
|
138
133
|
e.parentNames.forEach((t) => {
|
|
139
134
|
a.delete(t);
|
|
140
|
-
}),
|
|
135
|
+
}), h.value.forEach((t) => {
|
|
141
136
|
t.parentNames.forEach((l) => {
|
|
142
|
-
const
|
|
143
|
-
|
|
137
|
+
const i = d.value[l];
|
|
138
|
+
i && (i != null && i.ignoreCache || a.add(i.name));
|
|
144
139
|
});
|
|
145
|
-
}),
|
|
140
|
+
}), T.value = Array.from(a.values());
|
|
146
141
|
};
|
|
147
|
-
return
|
|
142
|
+
return E(() => g.value, () => {
|
|
148
143
|
const e = {}, a = (t) => {
|
|
149
144
|
t.forEach((l) => {
|
|
150
145
|
l.children && l.children.length > 0 && a(l.children), delete l.children, e[l.name] = l;
|
|
151
146
|
});
|
|
152
147
|
};
|
|
153
|
-
a(JSON.parse(JSON.stringify(
|
|
154
|
-
}, { immediate: !0 }),
|
|
148
|
+
a(JSON.parse(JSON.stringify(g.value))), d.value = e;
|
|
149
|
+
}, { immediate: !0 }), E(() => [c.layout, g.value], () => {
|
|
155
150
|
var e, a, t;
|
|
156
|
-
if (
|
|
157
|
-
y.value =
|
|
158
|
-
else if (c.layout ===
|
|
159
|
-
const l = (t =
|
|
160
|
-
(l == null ? void 0 : l.length) === 0 ? y.value =
|
|
151
|
+
if (S.value = [], y.value = [], p.value = [...((e = c.menuProps) == null ? void 0 : e.defaultOpenKeys) || [], ...p.value], M.value = [...((a = c.menuProps) == null ? void 0 : a.defaultOpenKeys) || [], ...M.value], c.layout === k.side)
|
|
152
|
+
y.value = g.value;
|
|
153
|
+
else if (c.layout === k.mix) {
|
|
154
|
+
const l = (t = g.value) == null ? void 0 : t.filter((i) => i.topMenu);
|
|
155
|
+
(l == null ? void 0 : l.length) === 0 ? y.value = g.value : S.value = l;
|
|
161
156
|
}
|
|
162
|
-
}, { immediate: !0 }),
|
|
163
|
-
var t, l,
|
|
157
|
+
}, { immediate: !0 }), E(() => [s == null ? void 0 : s.name, s == null ? void 0 : s.fullPath], () => {
|
|
158
|
+
var t, l, i;
|
|
164
159
|
const e = s == null ? void 0 : s.name;
|
|
165
|
-
|
|
166
|
-
const a =
|
|
167
|
-
if (a.length > 0 &&
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
}), p.value = Array.from(/* @__PURE__ */ new Set([...p.value, ...
|
|
160
|
+
o.value = d.value[e], j();
|
|
161
|
+
const a = f.value.filter((u) => u.topMenu);
|
|
162
|
+
if (a.length > 0 && S.value.length > 0 && (y.value = ((t = a[a.length - 1]) == null ? void 0 : t.children) || []), K.value = o != null && o.value ? [...a.map((u) => u.name), ...((l = o.value) == null ? void 0 : l.activatedKeys) || []] : [], b.value = o != null && o.value ? [o.value.name, ...((i = o.value) == null ? void 0 : i.activatedKeys) || []] : [], o.value) {
|
|
163
|
+
const u = f.value.filter((r, w) => w < f.value.length - 1), P = u.filter((r) => r.topMenu).map((r) => r.name), C = u.filter((r) => !r.topMenu).map((r) => r.name);
|
|
164
|
+
o.value.activatedKeys && o.value.activatedKeys.length > 0 && o.value.activatedKeys.forEach((r) => {
|
|
165
|
+
const w = d.value[r];
|
|
166
|
+
w && (w.topMenu ? P.push(r) : C.push(r));
|
|
167
|
+
}), p.value = Array.from(/* @__PURE__ */ new Set([...p.value, ...P])), M.value = Array.from(/* @__PURE__ */ new Set([...M.value, ...C]));
|
|
173
168
|
}
|
|
174
169
|
q(), c.hideTabs || z(), Q();
|
|
175
170
|
}, { immediate: !0 }), {
|
|
176
|
-
topMenuItems:
|
|
171
|
+
topMenuItems: S,
|
|
177
172
|
siderMenuItems: y,
|
|
178
173
|
topMenuSelectedKeys: K,
|
|
179
|
-
siderMenuSelectedKeys:
|
|
174
|
+
siderMenuSelectedKeys: b,
|
|
180
175
|
topMenuOpenKeys: p,
|
|
181
176
|
siderMenuOpenKeys: M,
|
|
182
|
-
activeMenuItem:
|
|
177
|
+
activeMenuItem: o,
|
|
183
178
|
menuItemMap: d,
|
|
184
|
-
breadcrumbItems:
|
|
185
|
-
tabs:
|
|
186
|
-
keepAliveInclude:
|
|
187
|
-
onProMenuItemClick:
|
|
179
|
+
breadcrumbItems: N,
|
|
180
|
+
tabs: h,
|
|
181
|
+
keepAliveInclude: T,
|
|
182
|
+
onProMenuItemClick: B,
|
|
188
183
|
onProMenuOpenKeysChange: H,
|
|
189
184
|
onTabClick: F,
|
|
190
185
|
onTabDelete: G
|
|
191
186
|
};
|
|
192
187
|
};
|
|
193
188
|
export {
|
|
194
|
-
|
|
189
|
+
ne as useHooks
|
|
195
190
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as f, computed as y, createElementBlock as n, openBlock as i, normalizeClass as m, createVNode as p, unref as d, withCtx as k, Fragment as g, renderList as h, createBlock as v } from "vue";
|
|
2
2
|
import { Tabs as S, TabPane as T } from "@arco-design/web-vue";
|
|
3
|
-
const z = "keyblade-pro-reuse-tabs",
|
|
3
|
+
const z = "keyblade-pro-reuse-tabs", q = /* @__PURE__ */ f({
|
|
4
4
|
__name: "pro-reuse-tabs",
|
|
5
5
|
props: {
|
|
6
6
|
tabs: {
|
|
@@ -30,31 +30,31 @@ const z = "keyblade-pro-reuse-tabs", x = /* @__PURE__ */ m({
|
|
|
30
30
|
"tab-delete": (e) => !0
|
|
31
31
|
},
|
|
32
32
|
setup(e, { emit: s }) {
|
|
33
|
-
const o = e,
|
|
33
|
+
const o = e, l = s, u = y(() => {
|
|
34
34
|
var t, r;
|
|
35
|
-
return (r = (t = o.tabs.find((a) => a.active)) == null ? void 0 : t.
|
|
36
|
-
}),
|
|
37
|
-
|
|
35
|
+
return (r = (t = o.tabs.find((a) => a.active)) == null ? void 0 : t.fullPath) != null ? r : void 0;
|
|
36
|
+
}), c = (t) => {
|
|
37
|
+
l("tab-click", String(t));
|
|
38
38
|
}, b = (t) => {
|
|
39
|
-
|
|
39
|
+
l("tab-delete", String(t));
|
|
40
40
|
};
|
|
41
|
-
return (t, r) => (
|
|
42
|
-
class:
|
|
41
|
+
return (t, r) => (i(), n("div", {
|
|
42
|
+
class: m(z)
|
|
43
43
|
}, [
|
|
44
|
-
p(
|
|
45
|
-
"active-key":
|
|
44
|
+
p(d(S), {
|
|
45
|
+
"active-key": u.value,
|
|
46
46
|
size: e.tabsSize,
|
|
47
47
|
type: e.tabsType,
|
|
48
48
|
"header-padding": e.tabsHeaderPadding,
|
|
49
49
|
editable: e.tabs.length > 1,
|
|
50
50
|
"hide-content": "",
|
|
51
51
|
"destroy-on-hide": "",
|
|
52
|
-
onTabClick:
|
|
52
|
+
onTabClick: c,
|
|
53
53
|
onDelete: b
|
|
54
54
|
}, {
|
|
55
55
|
default: k(() => [
|
|
56
|
-
(
|
|
57
|
-
key: a.
|
|
56
|
+
(i(!0), n(g, null, h(e.tabs, (a) => (i(), v(d(T), {
|
|
57
|
+
key: a.fullPath,
|
|
58
58
|
title: a.title
|
|
59
59
|
}, null, 8, ["title"]))), 128))
|
|
60
60
|
]),
|
|
@@ -64,5 +64,5 @@ const z = "keyblade-pro-reuse-tabs", x = /* @__PURE__ */ m({
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
export {
|
|
67
|
-
|
|
67
|
+
q as default
|
|
68
68
|
};
|
package/package.json
CHANGED