@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 CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.0.20"
7
+ "version": "0.0.22"
8
8
  }
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
- const piniaRuntime = find(nuxt2.plugins, (object) => {
154
- return object.src.includes("@pinia");
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
- nuxt2.plugins = remove(nuxt2.plugins, (object) => {
157
- return !object.src.includes("@pinia");
158
- });
159
- nuxt2.plugins.unshift(piniaRuntime);
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
+ };
@@ -5,4 +5,5 @@ export declare type NavigationConfig = {
5
5
  order?: number;
6
6
  slug?: string;
7
7
  type?: string;
8
+ url?: string;
8
9
  };
@@ -1,7 +1,9 @@
1
1
  import { NavigationConfig } from "../models/navigationConfig";
2
2
  export interface NavigationConfigState {
3
- data: null | NavigationConfig;
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: null
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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icvdeveloper/common-module",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {