@hitachivantara/app-shell-navigation 1.2.2 → 1.2.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.
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
if (!t.has(s))
|
|
5
|
-
throw TypeError("Cannot " + e);
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var o = (s) => {
|
|
3
|
+
throw TypeError(s);
|
|
6
4
|
};
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
import { useHvAppShellConfig as g } from "@hitachivantara/app-shell-shared";
|
|
15
|
-
function m(s) {
|
|
5
|
+
var f = (s, t, e) => t in s ? p(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
6
|
+
var i = (s, t, e) => f(s, typeof t != "symbol" ? t + "" : t, e), r = (s, t, e) => t.has(s) || o("Cannot " + e);
|
|
7
|
+
var c = (s, t, e) => (r(s, t, "read from private field"), e ? e.call(s) : t.get(s)), u = (s, t, e) => t.has(s) ? o("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), m = (s, t, e, n) => (r(s, t, "write to private field"), n ? n.call(s, e) : t.set(s, e), e);
|
|
8
|
+
import { useMemo as d } from "react";
|
|
9
|
+
import { useLocation as w, matchRoutes as g } from "react-router-dom";
|
|
10
|
+
import { useHvAppShellConfig as v } from "@hitachivantara/app-shell-shared";
|
|
11
|
+
function l(s) {
|
|
16
12
|
return s.map((t) => {
|
|
17
13
|
const e = t.route.slice(1);
|
|
18
14
|
return e === "" && (t.views == null || t.views.length === 0) ? {
|
|
@@ -21,41 +17,41 @@ function m(s) {
|
|
|
21
17
|
} : {
|
|
22
18
|
path: e,
|
|
23
19
|
view: t,
|
|
24
|
-
children: t.views ?
|
|
20
|
+
children: t.views ? l(t.views) : void 0
|
|
25
21
|
};
|
|
26
22
|
});
|
|
27
23
|
}
|
|
28
24
|
var a;
|
|
29
|
-
class
|
|
25
|
+
class x {
|
|
30
26
|
constructor(t, e) {
|
|
31
27
|
i(this, "state");
|
|
32
28
|
i(this, "key");
|
|
33
29
|
i(this, "pathname");
|
|
34
30
|
i(this, "search");
|
|
35
31
|
i(this, "hash");
|
|
36
|
-
|
|
32
|
+
u(this, a);
|
|
37
33
|
i(this, "matches", null);
|
|
38
|
-
this.state = t.state, this.key = t.key, this.pathname = t.pathname, this.search = t.search, this.hash = t.hash,
|
|
34
|
+
this.state = t.state, this.key = t.key, this.pathname = t.pathname, this.search = t.search, this.hash = t.hash, m(this, a, e ?? []);
|
|
39
35
|
}
|
|
40
36
|
get views() {
|
|
41
37
|
var t;
|
|
42
38
|
if (this.matches == null) {
|
|
43
|
-
const e =
|
|
44
|
-
this.matches = ((t =
|
|
39
|
+
const e = l(c(this, a));
|
|
40
|
+
this.matches = ((t = g(e, this)) == null ? void 0 : t.map((n) => n.route.view)) ?? [];
|
|
45
41
|
}
|
|
46
42
|
return this.matches;
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
a = new WeakMap();
|
|
50
|
-
const
|
|
46
|
+
const L = () => {
|
|
51
47
|
var n;
|
|
52
|
-
const s =
|
|
53
|
-
return
|
|
48
|
+
const s = w(), t = v();
|
|
49
|
+
return d(() => {
|
|
54
50
|
var h;
|
|
55
|
-
return new
|
|
51
|
+
return new x(s, (h = t.mainPanel) == null ? void 0 : h.views);
|
|
56
52
|
}, [s, (n = t.mainPanel) == null ? void 0 : n.views]);
|
|
57
|
-
},
|
|
53
|
+
}, H = L;
|
|
58
54
|
export {
|
|
59
|
-
|
|
55
|
+
H as default
|
|
60
56
|
};
|
|
61
57
|
//# sourceMappingURL=useLocation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocation.js","sources":["../../../../src/lib/hooks/useLocation.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n matchRoutes,\n useLocation as useLocationReactRouter,\n Location\n} from \"react-router-dom\";\n\nimport {\n HvAppShellViewsConfig,\n useHvAppShellConfig\n} from \"@hitachivantara/app-shell-shared\";\n\ninterface IndexedView {\n path: string;\n children?: IndexedView[];\n view: HvAppShellViewsConfig;\n}\n\nfunction indexViews(views: HvAppShellViewsConfig[]): IndexedView[] {\n return views.map(view => {\n // remove prefix slash from view.route\n const path = view.route.slice(1);\n const isIndex =\n path === \"\" && (view.views == null || view.views.length === 0);\n\n if (isIndex) {\n return {\n path,\n view\n };\n }\n\n return {\n path,\n view,\n children: view.views ? indexViews(view.views) : undefined\n };\n });\n}\n\nclass LocationWithViews<State = unknown> implements Location<State> {\n state: State;\n\n key: string;\n\n pathname: string;\n\n search: string;\n\n hash: string;\n\n #configViews: HvAppShellViewsConfig[];\n\n private matches: HvAppShellViewsConfig[] | null = null;\n\n constructor(\n location: Location<State>,\n views: HvAppShellViewsConfig[] | undefined | null\n ) {\n this.state = location.state;\n this.key = location.key;\n this.pathname = location.pathname;\n this.search = location.search;\n this.hash = location.hash;\n\n this.#configViews = views ?? [];\n }\n\n get views() {\n if (this.matches == null) {\n const indexedViews = indexViews(this.#configViews);\n this.matches =\n matchRoutes(indexedViews, this)?.map(match => match.route.view) ?? [];\n }\n\n return this.matches;\n }\n}\n\nconst useLocation = () => {\n const location = useLocationReactRouter();\n const config = useHvAppShellConfig();\n const toReturn = useMemo(() => {\n return new LocationWithViews(location, config.mainPanel?.views);\n }, [location, config.mainPanel?.views]);\n\n return toReturn;\n};\nexport default useLocation;\n"],"names":["indexViews","views","map","view","path","route","slice","length","children","undefined","LocationWithViews","constructor","location","state","key","pathname","search","hash","__privateAdd","_configViews","matches","__privateSet","indexedViews","__privateGet","matchRoutes","match","useLocation","useLocationReactRouter","config","useHvAppShellConfig","toReturn","useMemo","mainPanel","useHvLocation"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocation.js","sources":["../../../../src/lib/hooks/useLocation.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport {\n matchRoutes,\n useLocation as useLocationReactRouter,\n Location\n} from \"react-router-dom\";\n\nimport {\n HvAppShellViewsConfig,\n useHvAppShellConfig\n} from \"@hitachivantara/app-shell-shared\";\n\ninterface IndexedView {\n path: string;\n children?: IndexedView[];\n view: HvAppShellViewsConfig;\n}\n\nfunction indexViews(views: HvAppShellViewsConfig[]): IndexedView[] {\n return views.map(view => {\n // remove prefix slash from view.route\n const path = view.route.slice(1);\n const isIndex =\n path === \"\" && (view.views == null || view.views.length === 0);\n\n if (isIndex) {\n return {\n path,\n view\n };\n }\n\n return {\n path,\n view,\n children: view.views ? indexViews(view.views) : undefined\n };\n });\n}\n\nclass LocationWithViews<State = unknown> implements Location<State> {\n state: State;\n\n key: string;\n\n pathname: string;\n\n search: string;\n\n hash: string;\n\n #configViews: HvAppShellViewsConfig[];\n\n private matches: HvAppShellViewsConfig[] | null = null;\n\n constructor(\n location: Location<State>,\n views: HvAppShellViewsConfig[] | undefined | null\n ) {\n this.state = location.state;\n this.key = location.key;\n this.pathname = location.pathname;\n this.search = location.search;\n this.hash = location.hash;\n\n this.#configViews = views ?? [];\n }\n\n get views() {\n if (this.matches == null) {\n const indexedViews = indexViews(this.#configViews);\n this.matches =\n matchRoutes(indexedViews, this)?.map(match => match.route.view) ?? [];\n }\n\n return this.matches;\n }\n}\n\nconst useLocation = () => {\n const location = useLocationReactRouter();\n const config = useHvAppShellConfig();\n const toReturn = useMemo(() => {\n return new LocationWithViews(location, config.mainPanel?.views);\n }, [location, config.mainPanel?.views]);\n\n return toReturn;\n};\nexport default useLocation;\n"],"names":["indexViews","views","map","view","path","route","slice","length","children","undefined","LocationWithViews","constructor","location","state","key","pathname","search","hash","__privateAdd","_configViews","matches","__privateSet","indexedViews","__privateGet","matchRoutes","match","useLocation","useLocationReactRouter","config","useHvAppShellConfig","toReturn","useMemo","mainPanel","useHvLocation"],"mappings":";;;;;;;;;;AAkBA,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AAAA,EAAkB3B,KAAK;AAAA,KAC7D,CAACW,IAAUgB,IAAAA,EAAOI,cAAPJ,gBAAAA,EAAkB3B,KAAK,CAAC;AAGxC,GACAgC,IAAeP;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/app-shell-navigation",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "AppShell Navigation",
|
|
5
5
|
"author": "Hitachi Vantara - Boba Fett Team",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"coverage": "vitest run --coverage"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@hitachivantara/app-shell-shared": "1.2.
|
|
38
|
+
"@hitachivantara/app-shell-shared": "1.2.2",
|
|
39
39
|
"path-to-regexp": "^6.2.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"vite-plugin-dts": "^3.6.4",
|
|
57
57
|
"vite-tsconfig-paths": "^4.0.5"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "d53c73bcb11dd17fb2f61b727c6442706c33ac5d"
|
|
60
60
|
}
|