@ulu/frontend-vue 0.2.0-beta.7 → 0.2.0-beta.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../lib/utils/router.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;GAQG;AACH,qCAJW,MAAM,iBACN,MAAM,GACJ,MAAM,GAAC,SAAS,CAW5B;AAED;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,uCANW,GAAC,WAET;IAAwB,SAAS,EAAzB,MAAM;IACU,IAAI,EAApB,MAAM;CACd,GAAU,KAAK,CAAE,aAAa,CAAC,CAgCjC;AAED;;;;GAIG;AACH,kCAHW,KAAK,CAAC,aAAa,CAAC,GAClB,KAAK,CAAC,aAAa,CAAC,CAgBhC;AAED;;;;;;;;GAQG;AACH,0CAPW,GAAC,eACD,GAAC,WAET;IAAyB,YAAY;IACb,IAAI,EAApB,MAAM;CACd,GAAU,KAAK,CAAE,aAAa,CAAC,CA4BjC;AAED;;;;GAIG;AACH,qDAFa,MAAM,CAIlB;AAED;;;;;;;;GAQG;AACH,sCAPW,MAAM,aACN,MAAM,uBAEd;IAA0B,MAAM;IACN,SAAS;CACnC,GAAU,aAAa,CAuBzB;AAED;;;;GAIG;AACH,qCAHW,MAAM,WAKhB;AAED;;;;GAIG;AACH,yCAHW,MAAM,WAMhB;AAED;;;;GAIG;AACH,yCAHW,MAAM,SACN,MAAM,QAYhB;AAED;;;;GAIG;AACH,yCAHW,MAAM,2BACJ,KAAK,CAAC,MAAM,CAAC,GAAC,SAAS,CAInC;AAED;;;;;GAKG;AACH,uCAJW,MAAM,WACN,MAAM,GACL,MAAM,OAAK,CAUtB;AAUD;;;;;;;;;;GAUG;AACH,0CAPW,MAAM,WAEd;IAAwB,MAAM,EAAtB,MAAM;IACW,YAAY;IACb,IAAI,EAApB,MAAM;CACd,GAAU,KAAK,CAAE,aAAa,CAAC,CAgBjC;AAED;;;;;;;;GAQG;AACH,yCAHW,MAAM,GACJ,KAAK,CAAE;IAAC,KAAK,SAAS;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,UAAS;CAAC,CAAC,CA6BjE"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../lib/utils/router.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;GAQG;AACH,qCAJW,MAAM,iBACN,MAAM,GACJ,MAAM,GAAC,SAAS,CAW5B;AAED;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,uCANW,GAAC,WAET;IAAwB,SAAS,EAAzB,MAAM;IACU,IAAI,EAApB,MAAM;CACd,GAAU,KAAK,CAAE,aAAa,CAAC,CAgCjC;AAED;;;;GAIG;AACH,kCAHW,KAAK,CAAC,aAAa,CAAC,GAClB,KAAK,CAAC,aAAa,CAAC,CAgBhC;AAED;;;;;;;;GAQG;AACH,0CAPW,GAAC,eACD,GAAC,WAET;IAAyB,YAAY;IACb,IAAI,EAApB,MAAM;CACd,GAAU,KAAK,CAAE,aAAa,CAAC,CA4BjC;AAED;;;;GAIG;AACH,qDAFa,MAAM,CAIlB;AAED;;;;;;;;GAQG;AACH,sCAPW,MAAM,aACN,MAAM,uBAEd;IAA0B,MAAM;IACN,SAAS;CACnC,GAAU,aAAa,CAuBzB;AAED;;;;GAIG;AACH,qCAHW,MAAM,WAKhB;AAED;;;;GAIG;AACH,yCAHW,MAAM,WAMhB;AAED;;;;GAIG;AACH,yCAHW,MAAM,SACN,MAAM,QAYhB;AAED;;;;GAIG;AACH,yCAHW,MAAM,2BACJ,KAAK,CAAC,MAAM,CAAC,GAAC,SAAS,CAInC;AAED;;;;;GAKG;AACH,uCAJW,MAAM,WACN,MAAM,GACL,MAAM,OAAK,CAUtB;AAUD;;;;;;;;;;GAUG;AACH,0CAPW,MAAM,WAEd;IAAwB,MAAM,EAAtB,MAAM;IACW,YAAY;IACb,IAAI,EAApB,MAAM;CACd,GAAU,KAAK,CAAE,aAAa,CAAC,CAgBjC;AAED;;;;;;;;GAQG;AACH,yCAHW,MAAM,GACJ,KAAK,CAAE;IAAC,KAAK,SAAS;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,UAAS;CAAC,CAAC,CAmCjE"}
@@ -2,63 +2,63 @@ function m(t, e) {
2
2
  let n = (t?.meta || {}).title;
3
3
  return typeof n == "function" && (n = n(e || t)), n;
4
4
  }
5
- function j(t, e) {
5
+ function w(t, e) {
6
6
  const n = Object.assign({}, {
7
- qualifier(c, l) {
8
- return l ? b(c) : $(c);
7
+ qualifier(s, c) {
8
+ return c ? b(s) : $(s);
9
9
  },
10
10
  sort: p,
11
11
  item: {},
12
12
  includeChildren: !1
13
- }, e), s = (c, l) => l ? `${l}/${c.path}` : c.path, i = (c, l = null) => c.filter((u) => n.qualifier(u, l)).map((u) => {
14
- const a = u.children ? g(u.children) : u, f = u.children ? u.children.filter((d) => d.path !== "") : !1, o = h(a, s(u, l), n.item);
15
- return n.includeChildren && f.length && (o.children = i(f, o.path)), o;
13
+ }, e), r = (s, c) => c ? `${c}/${s.path}` : s.path, i = (s, c = null) => s.filter((u) => n.qualifier(u, c)).map((u) => {
14
+ const o = u.children ? g(u.children) : u, h = u.children ? u.children.filter((d) => d.path !== "") : !1, a = f(o, r(u, c), n.item);
15
+ return n.includeChildren && h.length && (a.children = i(h, a.path)), a;
16
16
  }).sort(n.sort);
17
17
  return i(t);
18
18
  }
19
- function w(t) {
20
- function e(r) {
19
+ function j(t) {
20
+ function e(l) {
21
21
  const n = [];
22
- for (const s of r) {
23
- const i = { ...s };
24
- delete i.children, n.push(i), s.children && n.push(...e(s.children));
22
+ for (const r of l) {
23
+ const i = { ...r };
24
+ delete i.children, n.push(i), r.children && n.push(...e(r.children));
25
25
  }
26
26
  return n;
27
27
  }
28
28
  return e(t);
29
29
  }
30
- function O(t, e, r) {
31
- const s = Object.assign({}, {
30
+ function O(t, e, l) {
31
+ const r = Object.assign({}, {
32
32
  includeIndex: !1,
33
33
  item: {},
34
34
  sort: p
35
- }, r), i = t.find((a) => a.path !== "/" && e.includes(a.path)), c = (a, f, o) => {
36
- if (a.children) {
37
- const d = a.children.find((x) => x.path.includes(e));
35
+ }, l), i = t.find((o) => o.path !== "/" && e.includes(o.path)), s = (o, h, a) => {
36
+ if (o.children) {
37
+ const d = o.children.find((x) => x.path.includes(e));
38
38
  if (d)
39
- return c(d, a, o + d.path);
39
+ return s(d, o, a + d.path);
40
40
  }
41
- return { route: f, path: o };
42
- }, { route: l, path: u } = c(i, i, i.path);
43
- return l.children ? l.children.filter(I(s.includeIndex)).map((a) => h(a, `${u}/${a.path}`, s.item)).sort(s.sort) : (console.warn("Unable to build menu for:", e), []);
41
+ return { route: h, path: a };
42
+ }, { route: c, path: u } = s(i, i, i.path);
43
+ return c.children ? c.children.filter(I(r.includeIndex)).map((o) => f(o, `${u}/${o.path}`, r.item)).sort(r.sort) : (console.warn("Unable to build menu for:", e), []);
44
44
  }
45
45
  function g(t) {
46
46
  return t.find((e) => e.path === "");
47
47
  }
48
- function h(t, e = t.path, r) {
49
- const s = Object.assign({}, {
48
+ function f(t, e = t.path, l) {
49
+ const r = Object.assign({}, {
50
50
  indexMeta: !0,
51
51
  modify: null
52
- }, r);
52
+ }, l);
53
53
  let i = Object.assign({}, t.meta);
54
- s.indexMeta && t.children && (i = Object.assign({}, i, g(t.children)?.meta));
55
- const c = { ...t, meta: i }, l = {
54
+ r.indexMeta && t.children && (i = Object.assign({}, i, g(t.children)?.meta));
55
+ const s = { ...t, meta: i }, c = {
56
56
  path: e,
57
- title: m(c, t) || "Missing Title",
57
+ title: m(s, t) || "Missing Title",
58
58
  weight: i?.weight || 0,
59
59
  meta: i
60
60
  };
61
- return s.modify && s.modify(l, t), l;
61
+ return r.modify && r.modify(c, t), c;
62
62
  }
63
63
  function b(t) {
64
64
  return !t.path.includes("/:");
@@ -68,18 +68,18 @@ function $(t) {
68
68
  return b(t) && e.length === 1;
69
69
  }
70
70
  function y(t, e) {
71
- const { target: r } = e, n = r.closest("a");
71
+ const { target: l } = e, n = l.closest("a");
72
72
  if (n) {
73
- let s = n.getAttribute("href");
74
- s.startsWith("/") && (t.push(s), e.preventDefault());
73
+ let r = n.getAttribute("href");
74
+ r.startsWith("/") && (t.push(r), e.preventDefault());
75
75
  }
76
76
  }
77
77
  function R(t, e = M(t)) {
78
78
  return e?.children;
79
79
  }
80
80
  function M(t, e) {
81
- const r = t.matched.length, n = r - 2;
82
- return e ? r > 1 ? t.matched[0] : null : n < 0 ? null : t.matched[n];
81
+ const l = t.matched.length, n = l - 2;
82
+ return e ? l > 1 ? t.matched[0] : null : n < 0 ? null : t.matched[n];
83
83
  }
84
84
  function I(t) {
85
85
  return (e) => t || e.path !== "";
@@ -93,32 +93,34 @@ function S(t, e) {
93
93
  includeIndex: !1,
94
94
  item: {},
95
95
  sort: p
96
- }, e), s = n.parent || M(t);
97
- return (R(t, s) || []).filter(I(n.includeIndex)).map((c) => h(c, `${s.path}/${c.path}`, n.item)).sort(n.sort);
96
+ }, e), r = n.parent || M(t);
97
+ return (R(t, r) || []).filter(I(n.includeIndex)).map((s) => f(s, `${r.path}/${s.path}`, n.item)).sort(n.sort);
98
98
  }
99
99
  function B(t) {
100
- const { matched: e, path: r } = t;
101
- let n;
102
- return e.reduce((i, c, l) => {
103
- if (c.meta?.breadcrumb === !1 || c.path === n)
100
+ const { matched: e, path: l } = t, n = e.reduce((i, s) => {
101
+ if (s.meta?.breadcrumb === !1)
104
102
  return i;
105
- const u = l === e.length - 1, a = m(c, t) || "Missing Title";
106
- return i.push({
107
- title: a,
108
- to: { path: u ? r : c.path },
109
- current: u
110
- }), n = c.path, i;
103
+ const c = i[i.length - 1];
104
+ return c && c.path === s.path || i.push(s), i;
111
105
  }, []);
106
+ return n.map((i, s) => {
107
+ const c = s === n.length - 1, u = m(i, t);
108
+ return u || console.warn("Missing route title"), {
109
+ title: u || "Missing Title",
110
+ to: { path: c ? l : i.path },
111
+ current: c
112
+ };
113
+ });
112
114
  }
113
115
  export {
114
116
  B as $createBreadcrumb,
115
117
  S as $createSectionMenu,
116
118
  M as $getParentRoute,
117
119
  R as $getRouteChildren,
118
- j as createBaseMenu,
119
- h as createMenuItem,
120
+ w as createBaseMenu,
121
+ f as createMenuItem,
120
122
  O as createSectionMenu,
121
- w as flattenMenu,
123
+ j as flattenMenu,
122
124
  g as getChildIndexRoute,
123
125
  m as getRouteTitle,
124
126
  $ as isStaticBaseRoute,
@@ -277,29 +277,35 @@ export function $createSectionMenu(route, options) {
277
277
  */
278
278
  export function $createBreadcrumb(route) {
279
279
  const { matched, path: currentPath } = route;
280
- let prevPath;
281
280
 
282
- const crumbs = matched.reduce((arr, match, index) => {
281
+ const filteredMatched = matched.reduce((acc, match) => {
283
282
  if (match.meta?.breadcrumb === false) {
284
- return arr;
283
+ return acc;
285
284
  }
286
285
 
287
- if (match.path === prevPath) {
288
- return arr;
286
+ const prevMatch = acc[acc.length - 1];
287
+ if (prevMatch && prevMatch.path === match.path) {
288
+ return acc;
289
289
  }
290
290
 
291
- const isLast = index === matched.length - 1;
292
- const title = getRouteTitle(match, route) || "Missing Title";
291
+ acc.push(match);
292
+ return acc;
293
+ }, []);
294
+
295
+ const crumbs = filteredMatched.map((match, index) => {
296
+ const isLast = index === filteredMatched.length - 1;
297
+ const title = getRouteTitle(match, route);
298
+
299
+ if (!title) {
300
+ console.warn("Missing route title");
301
+ }
293
302
 
294
- arr.push({
295
- title,
303
+ return {
304
+ title: title || "Missing Title",
296
305
  to: { path: isLast ? currentPath : match.path },
297
306
  current: isLast,
298
- });
299
-
300
- prevPath = match.path;
301
- return arr;
302
- }, []);
307
+ };
308
+ });
303
309
 
304
310
  return crumbs;
305
311
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend-vue",
3
- "version": "0.2.0-beta.7",
3
+ "version": "0.2.0-beta.8",
4
4
  "description": "A modular and tree-shakeable Vue 3 component library for the Ulu frontend",
5
5
  "type": "module",
6
6
  "files": [