@keyblade/pro-components 1.15.0-alpha.3 → 1.15.0-alpha.5

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.
@@ -2,188 +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 = (s, c, i) => c in s ? V(s, c, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[c] = i, w = (s, c) => {
6
- for (var i in c || (c = {}))
7
- Z.call(c, i) && J(s, i, c[i]);
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 i of x(c))
10
- $.call(c, i) && J(s, i, c[i]);
11
- return s;
12
- }, O = (s, c) => X(s, Y(c));
13
- var L = (s, c, i) => new Promise((K, g) => {
14
- var p = (u) => {
9
+ for (var n of x(s))
10
+ $.call(s, n) && J(c, n, s[n]);
11
+ return c;
12
+ }, A = (c, s) => X(c, Y(s));
13
+ var W = (c, s, n) => new Promise((K, P) => {
14
+ var p = (f) => {
15
15
  try {
16
- r(i.next(u));
16
+ u(n.next(f));
17
17
  } catch (d) {
18
- g(d);
18
+ P(d);
19
19
  }
20
- }, M = (u) => {
20
+ }, M = (f) => {
21
21
  try {
22
- r(i.throw(u));
22
+ u(n.throw(f));
23
23
  } catch (d) {
24
- g(d);
24
+ P(d);
25
25
  }
26
- }, r = (u) => u.done ? K(u.value) : Promise.resolve(u.value).then(p, M);
27
- r((i = i.apply(s, c)).next());
26
+ }, u = (f) => f.done ? K(f.value) : Promise.resolve(f.value).then(p, M);
27
+ u((n = n.apply(c, s)).next());
28
28
  });
29
- import { ref as v, computed as _, watch as A } from "vue";
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 E, ProLayoutMenuType as R } from "./enum.js";
32
- const te = (s) => {
33
- const c = I(), i = m(), K = v([]), g = v([]), p = v([]), M = v([]), r = v(), u = v([]), d = v({}), k = v([]), f = v([]), P = v([]), T = v([]), y = v([]), b = _(() => {
34
- const e = [...s.menuItems], a = (t) => {
31
+ import { ProLayoutMode as k, ProLayoutMenuType as D } from "./enum.js";
32
+ const ne = (c) => {
33
+ const s = I(), n = m(), K = v([]), P = v([]), p = v([]), M = v([]), u = v(), f = v([]), d = v({}), N = v([]), h = v([]), T = v([]), S = v([]), y = v([]), g = _(() => {
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((n) => O(w({}, n), { topMenu: l == null ? void 0 : l.topChildrenMenu }));
38
+ l.children = l.children.map((i) => A(O({}, i), { topMenu: l == null ? void 0 : l.topChildrenMenu }));
39
39
  else {
40
- const n = l.children.find((o) => o.topMenu !== void 0);
41
- n && (l.topChildrenMenu = n.topMenu, l.children = l.children.map((o) => O(w({}, o), { topMenu: n.topMenu })));
40
+ const i = l.children.find((o) => o.topMenu !== void 0);
41
+ i && (l.topChildrenMenu = i.topMenu, l.children = l.children.map((o) => A(O({}, o), { topMenu: i.topMenu })));
42
42
  }
43
43
  a(l.children);
44
44
  }
45
45
  });
46
46
  };
47
- return s.layout === E.mix && a(e), e;
48
- }), W = (e) => {
47
+ return c.layout === k.mix && a(e), e;
48
+ }), L = (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 = [], i == null || i.push({ path: e.path });
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
- i == null || i.push({ path: e.redirect });
54
+ n == null || n.push({ path: e.redirect });
55
55
  else if (typeof e.redirect == "function") {
56
- const t = e.redirect(c);
57
- i == null || i.push(t);
56
+ const t = e.redirect(s);
57
+ n == null || n.push(t);
58
58
  } else
59
- i == null || i.push(e.redirect);
60
- }, B = (e) => {
61
- e != null && e.name ? i == null || i.push({ name: e.name }) : i == null || i.push({ path: e.path }), g.value = [e.name];
62
- }, D = (e, a) => L(null, null, function* () {
63
- if (a != null && a.path && !(s != null && s.onMenuItemClick && !(yield s.onMenuItemClick(a)))) {
59
+ n == null || n.push(e.redirect);
60
+ }, R = (e) => {
61
+ e != null && e.name ? n == null || n.push({ name: e.name }) : n == null || n.push({ path: e.path }), P.value = [e.name];
62
+ }, B = (e, a) => W(null, null, function* () {
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 === R.top ? W(a) : B(a);
68
+ e === D.top ? L(a) : R(a);
69
69
  }
70
70
  }), H = (e, a) => {
71
- e === R.top ? p.value = a : M.value = a;
71
+ e === D.top ? p.value = a : M.value = a;
72
72
  }, j = () => {
73
73
  const e = [], a = (t) => {
74
74
  var l;
75
- for (const n in t) {
76
- const o = t[n];
77
- if (o.name === ((l = r == null ? void 0 : r.value) == null ? void 0 : l.name) || o.children && o.children.length > 0 && a(o.children))
75
+ for (const i in t) {
76
+ const o = t[i];
77
+ if (o.name === ((l = u == null ? void 0 : u.value) == null ? void 0 : l.name) || o.children && o.children.length > 0 && a(o.children))
78
78
  return e.unshift(o), !0;
79
79
  }
80
80
  return !1;
81
81
  };
82
- a(JSON.parse(JSON.stringify(b.value))), u.value = e;
82
+ a(JSON.parse(JSON.stringify(g.value))), f.value = e;
83
83
  }, q = () => {
84
84
  var a, t, l;
85
- const e = (a = u.value) == null ? void 0 : a.map((n) => ({ path: n == null ? void 0 : n.path, label: n == null ? void 0 : n.title }));
86
- k.value = (t = r.value) != null && t.breadcrumbs ? (l = r.value) == null ? void 0 : l.breadcrumbs : e.length !== 0 ? e : [];
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 = u.value) != null && t.breadcrumbs ? (l = u.value) == null ? void 0 : l.breadcrumbs : e.length !== 0 ? e : [];
87
87
  };
88
88
  function z() {
89
- if (!r.value || r.value.noAffix) {
90
- f.value.forEach((n) => {
91
- n.active = !1;
89
+ var b, C;
90
+ if (!u.value || u.value.noAffix) {
91
+ h.value.forEach((r) => {
92
+ r.active = !1;
92
93
  });
93
94
  return;
94
95
  }
95
- const { name: e, title: a } = r.value;
96
- f.value.forEach((n) => {
97
- n.active = !1;
96
+ const { name: e, title: a } = u.value;
97
+ h.value.forEach((r) => {
98
+ r.active = !1;
98
99
  });
99
- const t = {
100
+ const t = (b = s.meta) == null ? void 0 : b.getTitle, l = typeof t == "function" ? t(s) : void 0, i = {
100
101
  name: e,
101
- parentNames: u.value.map((n) => n.name),
102
- title: a != null ? a : e,
103
- fullPath: c.fullPath,
102
+ parentNames: f.value.map((r) => r.name),
103
+ title: (C = l != null ? l : a) != null ? C : e,
104
+ fullPath: s.fullPath,
104
105
  active: !0
105
- }, l = f.value.findIndex((n) => n.fullPath === c.fullPath);
106
- ~l ? f.value[l].active = !0 : f.value.push(t);
106
+ }, o = h.value.findIndex((r) => r.fullPath.startsWith(s.path));
107
+ o >= 0 ? (h.value[o].active = !0, h.value[o].fullPath = s.fullPath) : h.value.push(i);
107
108
  }
108
109
  const F = (e) => {
109
- const a = f.value.find((t) => t.fullPath === e);
110
- a && i.push(a.fullPath);
110
+ const a = h.value.find((t) => t.fullPath === e);
111
+ a && n.push(a.fullPath);
111
112
  }, G = (e) => {
112
113
  let a = -1, t = -1;
113
- if (f.value.forEach((n, o) => {
114
- n.fullPath === e && (t = o), n.active && (a = o);
114
+ if (h.value.forEach((i, o) => {
115
+ i.fullPath === e && (t = o), i.active && (a = o);
115
116
  }), t === -1) return;
116
117
  if (a === t) {
117
- let n;
118
- t === 0 ? n = f.value[t + 1] : n = f.value[t - 1], n && (n.active = !0, i.push(n.fullPath));
118
+ let i;
119
+ t === 0 ? i = h.value[t + 1] : i = h.value[t - 1], i && (i.active = !0, n.push(i.fullPath));
119
120
  }
120
- const l = f.value.splice(t, 1);
121
+ const l = h.value.splice(t, 1);
121
122
  U(l[0]);
122
123
  }, Q = () => {
123
124
  var a;
124
- if (s != null && s.disableKeepAlive || (a = c == null ? void 0 : c.meta) != null && a.ignoreCache)
125
+ if (c != null && c.disableKeepAlive || (a = s == null ? void 0 : s.meta) != null && a.ignoreCache)
125
126
  return;
126
- const e = new Set(P.value);
127
- u.value.forEach((t) => {
127
+ const e = new Set(T.value);
128
+ f.value.forEach((t) => {
128
129
  t.name && e.add(t.name);
129
- }), P.value = Array.from(e.values());
130
+ }), T.value = Array.from(e.values());
130
131
  }, U = (e) => {
131
- const a = new Set(P.value);
132
+ const a = new Set(T.value);
132
133
  e.parentNames.forEach((t) => {
133
134
  a.delete(t);
134
- }), f.value.forEach((t) => {
135
+ }), h.value.forEach((t) => {
135
136
  t.parentNames.forEach((l) => {
136
- const n = d.value[l];
137
- n && (n != null && n.ignoreCache || a.add(n.name));
137
+ const i = d.value[l];
138
+ i && (i != null && i.ignoreCache || a.add(i.name));
138
139
  });
139
- }), P.value = Array.from(a.values());
140
+ }), T.value = Array.from(a.values());
140
141
  };
141
- return A(() => b.value, () => {
142
+ return E(() => g.value, () => {
142
143
  const e = {}, a = (t) => {
143
144
  t.forEach((l) => {
144
145
  l.children && l.children.length > 0 && a(l.children), delete l.children, e[l.name] = l;
145
146
  });
146
147
  };
147
- a(JSON.parse(JSON.stringify(b.value))), d.value = e;
148
- }, { immediate: !0 }), A(() => [s.layout, b.value], () => {
148
+ a(JSON.parse(JSON.stringify(g.value))), d.value = e;
149
+ }, { immediate: !0 }), E(() => [c.layout, g.value], () => {
149
150
  var e, a, t;
150
- if (T.value = [], y.value = [], p.value = [...((e = s.menuProps) == null ? void 0 : e.defaultOpenKeys) || [], ...p.value], M.value = [...((a = s.menuProps) == null ? void 0 : a.defaultOpenKeys) || [], ...M.value], s.layout === E.side)
151
- y.value = b.value;
152
- else if (s.layout === E.mix) {
153
- const l = (t = b.value) == null ? void 0 : t.filter((n) => n.topMenu);
154
- (l == null ? void 0 : l.length) === 0 ? y.value = b.value : T.value = l;
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;
155
156
  }
156
- }, { immediate: !0 }), A(() => c == null ? void 0 : c.name, () => {
157
- var t, l, n;
158
- const e = c == null ? void 0 : c.name;
159
- r.value = d.value[e], j();
160
- const a = u.value.filter((o) => o.topMenu);
161
- if (a.length > 0 && T.value.length > 0 && (y.value = ((t = a[a.length - 1]) == null ? void 0 : t.children) || []), K.value = r != null && r.value ? [...a.map((o) => o.name), ...((l = r.value) == null ? void 0 : l.activatedKeys) || []] : [], g.value = r != null && r.value ? [r.value.name, ...((n = r.value) == null ? void 0 : n.activatedKeys) || []] : [], r.value) {
162
- const o = u.value.filter((h, C) => C < u.value.length - 1), S = o.filter((h) => h.topMenu).map((h) => h.name), N = o.filter((h) => !h.topMenu).map((h) => h.name);
163
- r.value.activatedKeys && r.value.activatedKeys.length > 0 && r.value.activatedKeys.forEach((h) => {
164
- const C = d.value[h];
165
- C && (C.topMenu ? S.push(h) : N.push(h));
166
- }), p.value = Array.from(/* @__PURE__ */ new Set([...p.value, ...S])), M.value = Array.from(/* @__PURE__ */ new Set([...M.value, ...N]));
157
+ }, { immediate: !0 }), E(() => [s == null ? void 0 : s.name, s == null ? void 0 : s.fullPath], () => {
158
+ var t, l, i;
159
+ const e = s == null ? void 0 : s.name;
160
+ u.value = d.value[e], j();
161
+ const a = f.value.filter((o) => o.topMenu);
162
+ if (a.length > 0 && S.value.length > 0 && (y.value = ((t = a[a.length - 1]) == null ? void 0 : t.children) || []), K.value = u != null && u.value ? [...a.map((o) => o.name), ...((l = u.value) == null ? void 0 : l.activatedKeys) || []] : [], P.value = u != null && u.value ? [u.value.name, ...((i = u.value) == null ? void 0 : i.activatedKeys) || []] : [], u.value) {
163
+ const o = f.value.filter((r, w) => w < f.value.length - 1), b = o.filter((r) => r.topMenu).map((r) => r.name), C = o.filter((r) => !r.topMenu).map((r) => r.name);
164
+ u.value.activatedKeys && u.value.activatedKeys.length > 0 && u.value.activatedKeys.forEach((r) => {
165
+ const w = d.value[r];
166
+ w && (w.topMenu ? b.push(r) : C.push(r));
167
+ }), p.value = Array.from(/* @__PURE__ */ new Set([...p.value, ...b])), M.value = Array.from(/* @__PURE__ */ new Set([...M.value, ...C]));
167
168
  }
168
- q(), s.hideTabs || z(), Q();
169
+ q(), c.hideTabs || z(), Q();
169
170
  }, { immediate: !0 }), {
170
- topMenuItems: T,
171
+ topMenuItems: S,
171
172
  siderMenuItems: y,
172
173
  topMenuSelectedKeys: K,
173
- siderMenuSelectedKeys: g,
174
+ siderMenuSelectedKeys: P,
174
175
  topMenuOpenKeys: p,
175
176
  siderMenuOpenKeys: M,
176
- activeMenuItem: r,
177
+ activeMenuItem: u,
177
178
  menuItemMap: d,
178
- breadcrumbItems: k,
179
- tabs: f,
180
- keepAliveInclude: P,
181
- onProMenuItemClick: D,
179
+ breadcrumbItems: N,
180
+ tabs: h,
181
+ keepAliveInclude: T,
182
+ onProMenuItemClick: B,
182
183
  onProMenuOpenKeysChange: H,
183
184
  onTabClick: F,
184
185
  onTabDelete: G
185
186
  };
186
187
  };
187
188
  export {
188
- te as useHooks
189
+ ne as useHooks
189
190
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@keyblade/pro-components",
3
3
  "description": "KeyBlade Pro Components",
4
4
  "author": "yangshuai <704807396@qq.com>",
5
- "version": "1.15.0-alpha.03",
5
+ "version": "1.15.0-alpha.05",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",