@icvdeveloper/common-module 0.0.20 → 0.0.22
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 +16 -8
- package/dist/runtime/composables/useNavigation.d.ts +13 -0
- package/dist/runtime/composables/useNavigation.mjs +31 -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
|
@@ -2,7 +2,6 @@ import { join, resolve } from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { defineNuxtModule, useLogger, installModule, addPlugin, addAutoImportDir, addComponentsDir } from '@nuxt/kit';
|
|
4
4
|
import svgLoader from 'vite-svg-loader';
|
|
5
|
-
import { find, remove } from 'lodash-es';
|
|
6
5
|
|
|
7
6
|
// -- Unbuild CommonJS Shims --
|
|
8
7
|
import __cjs_url__ from 'url';
|
|
@@ -149,14 +148,23 @@ const module = defineNuxtModule({
|
|
|
149
148
|
extensions: ["vue"],
|
|
150
149
|
prefix: "Common"
|
|
151
150
|
});
|
|
152
|
-
nuxt.hook("app:resolve", (nuxt2) => {
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
nuxt.hook("app:resolve", async (nuxt2) => {
|
|
152
|
+
let index = 0;
|
|
153
|
+
const piniaRuntime = nuxt2.plugins.find((object, i) => {
|
|
154
|
+
const containsPinia = object.src.includes("@pinia");
|
|
155
|
+
if (containsPinia) {
|
|
156
|
+
index = i;
|
|
157
|
+
return true;
|
|
158
|
+
} else {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
155
161
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
if (piniaRuntime) {
|
|
163
|
+
nuxt2.plugins.splice(index, 1);
|
|
164
|
+
nuxt2.plugins.unshift(piniaRuntime);
|
|
165
|
+
} else {
|
|
166
|
+
console.warn("[V3plus Common Module]: Could not find Pinia");
|
|
167
|
+
}
|
|
160
168
|
});
|
|
161
169
|
}
|
|
162
170
|
});
|
|
@@ -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) => {
|