@icvdeveloper/common-module 0.0.21 → 0.0.23
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/dist/module.json +1 -1
- package/dist/module.mjs +0 -1
- package/dist/runtime/composables/useNavigation.d.ts +13 -0
- package/dist/runtime/composables/useNavigation.mjs +31 -0
- package/dist/runtime/composables/useRouteHelpers.d.ts +5 -0
- package/dist/runtime/composables/useRouteHelpers.mjs +10 -0
- package/dist/runtime/models/navigationConfig.d.ts +1 -0
- package/dist/runtime/store/navigationConfig.d.ts +4 -2
- package/dist/runtime/store/navigationConfig.mjs +13 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NavigationConfig } from "../models/navigationConfig";
|
|
2
|
+
interface UseNavigationMethods {
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a given nav item is external.
|
|
5
|
+
*/
|
|
6
|
+
isExternalLink: (navItem: NavigationConfig) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* generates a href link.
|
|
9
|
+
*/
|
|
10
|
+
formatLink: (navItem: NavigationConfig) => string;
|
|
11
|
+
}
|
|
12
|
+
export declare const useNavigation: () => UseNavigationMethods;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { storeToRefs } from "pinia";
|
|
2
|
+
import { useConferencesStore } from "../store/index.mjs";
|
|
3
|
+
import { useConferenceHelpers } from "./useConferenceHelpers.mjs";
|
|
4
|
+
export const useNavigation = () => {
|
|
5
|
+
const { currentConference } = storeToRefs(useConferencesStore());
|
|
6
|
+
const { getConferenceWebcastUrl } = useConferenceHelpers(currentConference);
|
|
7
|
+
const isExternalLink = (navItem) => {
|
|
8
|
+
const url = formatLink(navItem);
|
|
9
|
+
return url.startsWith("http") === true;
|
|
10
|
+
};
|
|
11
|
+
const formatLink = (navItem) => {
|
|
12
|
+
let link = "/" + navItem.name;
|
|
13
|
+
if (navItem.name === "home") {
|
|
14
|
+
link = "/";
|
|
15
|
+
}
|
|
16
|
+
if (navItem.type === "custom-page") {
|
|
17
|
+
link = "/page/" + navItem.slug;
|
|
18
|
+
}
|
|
19
|
+
if (navItem.type === "link") {
|
|
20
|
+
link = navItem.url;
|
|
21
|
+
}
|
|
22
|
+
if (navItem.name === "webcast") {
|
|
23
|
+
link = getConferenceWebcastUrl();
|
|
24
|
+
}
|
|
25
|
+
return link;
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
isExternalLink,
|
|
29
|
+
formatLink
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { NavigationConfig } from "../models/navigationConfig";
|
|
2
2
|
export interface NavigationConfigState {
|
|
3
|
-
data:
|
|
3
|
+
data: NavigationConfig[];
|
|
4
4
|
}
|
|
5
|
-
export declare const useNavigationConfigStore: import("pinia").StoreDefinition<"navigationConfig", NavigationConfigState, {
|
|
5
|
+
export declare const useNavigationConfigStore: import("pinia").StoreDefinition<"navigationConfig", NavigationConfigState, {
|
|
6
|
+
getEnabled: (state: NavigationConfigState) => (sorted?: boolean) => any;
|
|
7
|
+
}, {
|
|
6
8
|
setNavigationConfig(payload: any): Promise<NavigationConfigState>;
|
|
7
9
|
}>;
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { defineStore } from "pinia";
|
|
2
|
+
import { filter, sortBy } from "lodash-es";
|
|
2
3
|
export const useNavigationConfigStore = defineStore("navigationConfig", {
|
|
3
4
|
state: () => ({
|
|
4
|
-
data:
|
|
5
|
+
data: []
|
|
5
6
|
}),
|
|
7
|
+
getters: {
|
|
8
|
+
getEnabled: (state) => {
|
|
9
|
+
return (sorted = true) => {
|
|
10
|
+
const filtered = filter(state.data, { enabled: true });
|
|
11
|
+
if (sorted) {
|
|
12
|
+
return sortBy(filtered, ["order"]);
|
|
13
|
+
}
|
|
14
|
+
return filtered;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
},
|
|
6
18
|
actions: {
|
|
7
19
|
setNavigationConfig(payload) {
|
|
8
20
|
return new Promise((resolve) => {
|