@apptegy/nuxt-navigation 0.1.112 → 0.1.113-test.0

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,7 +4,7 @@
4
4
  "nuxt": ">=3.0.0"
5
5
  },
6
6
  "configKey": "@apptegy/nuxt-navigation",
7
- "version": "0.1.112",
7
+ "version": "0.1.113-test.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.1",
10
10
  "unbuild": "unknown"
@@ -55,12 +55,12 @@
55
55
  <ul class="navbar-applications">
56
56
  <li v-for="application of applications" :key="application.id">
57
57
  <NavSidebarSection
58
- v-if="expanded || currentApplication === application.text || isMobile"
58
+ v-if="expanded || isCurrentApplication(application) || isMobile"
59
59
  :application="application"
60
- :active="currentApplication === application.text"
60
+ :active="isCurrentApplication(application)"
61
61
  :collapsed="!expanded && !isMobile"
62
62
  >
63
- <slot v-if="currentApplication === application.text" />
63
+ <slot v-if="isCurrentApplication(application)" />
64
64
  </NavSidebarSection>
65
65
  </li>
66
66
  </ul>
@@ -94,6 +94,7 @@
94
94
 
95
95
  <script setup>
96
96
  import { useSidebar, useBranding, useNuxtApp, ref, watch, computed, onMounted, onBeforeUnmount, nextTick } from "#imports";
97
+ import { isSameApplication } from "../../utils/application";
97
98
  import ApptegyLogo from "./Icons/ApptegyLogo.vue";
98
99
  import { useWindowSize } from "@vueuse/core";
99
100
  import Unpinned from "./Icons/Unpinned.vue";
@@ -127,6 +128,7 @@ const props = defineProps({
127
128
  showCollapseButton: { type: Boolean, required: false, default: false }
128
129
  });
129
130
  const emit = defineEmits(["toggle-expand"]);
131
+ const isCurrentApplication = (application) => isSameApplication(props.currentApplication, application.text);
130
132
  const { state: expanded } = useSidebar();
131
133
  const { brand, getBrandingStyles } = await useBranding(props.clientId);
132
134
  const brandLogo = ref(brand.value?.logo_light);
@@ -31,7 +31,7 @@
31
31
 
32
32
  <script setup>
33
33
  import { useSidebar, computed, ref } from "#imports";
34
- const ENGAGE_APP_TEXT = "engage";
34
+ import { isEngageApplication, rewriteEngageUrl } from "../../utils/application";
35
35
  const NEWSLETTERS_APP_TEXT = "Newsletters";
36
36
  const props = defineProps({
37
37
  application: { type: Object, required: true },
@@ -40,22 +40,21 @@ const props = defineProps({
40
40
  });
41
41
  const { state: expanded } = useSidebar();
42
42
  const isOpen = ref(true);
43
- const isEngageApplication = computed(() => {
44
- const { text } = props.application || {};
45
- return text.toLowerCase() === ENGAGE_APP_TEXT;
46
- });
43
+ const isEngageApp = computed(() => isEngageApplication(props.application?.text, props.application?.id));
47
44
  const appText = computed(() => {
48
45
  const { text } = props.application || {};
49
- if (isEngageApplication.value) {
46
+ if (isEngageApp.value) {
50
47
  return NEWSLETTERS_APP_TEXT;
51
48
  }
52
49
  return text.replace("_", " ");
53
50
  });
54
51
  const applicationUrl = computed(() => {
55
52
  const { url } = props.application || {};
56
- if (props.active) return "";
57
- if (isEngageApplication.value) {
58
- return url.replace(/\/engage(?=[/?#]|$)/i, "/newsletters");
53
+ if (props.active || !url) {
54
+ return "";
55
+ }
56
+ if (isEngageApp.value) {
57
+ return rewriteEngageUrl(url);
59
58
  }
60
59
  return url;
61
60
  });
@@ -0,0 +1,5 @@
1
+ export declare const ENGAGE_APP_ID = 12;
2
+ export declare function normalizeApplicationKey(text?: string | null): string;
3
+ export declare function isSameApplication(currentApplication?: string | null, applicationText?: string | null): boolean;
4
+ export declare function isEngageApplication(text?: string | null, id?: number | null): boolean;
5
+ export declare function rewriteEngageUrl(url: string): string;
@@ -0,0 +1,21 @@
1
+ const ENGAGE_ALIASES = /* @__PURE__ */ new Set(["engage", "newsletters"]);
2
+ export const ENGAGE_APP_ID = 12;
3
+ export function normalizeApplicationKey(text) {
4
+ const normalized = text?.toLowerCase() ?? "";
5
+ if (ENGAGE_ALIASES.has(normalized)) {
6
+ return "engage";
7
+ }
8
+ return normalized;
9
+ }
10
+ export function isSameApplication(currentApplication, applicationText) {
11
+ return normalizeApplicationKey(currentApplication) === normalizeApplicationKey(applicationText);
12
+ }
13
+ export function isEngageApplication(text, id) {
14
+ if (id === ENGAGE_APP_ID) {
15
+ return true;
16
+ }
17
+ return ENGAGE_ALIASES.has(text?.toLowerCase() ?? "");
18
+ }
19
+ export function rewriteEngageUrl(url) {
20
+ return url.replace(/\/engage(?=[/?#]|$)/i, "/newsletters");
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apptegy/nuxt-navigation",
3
- "version": "0.1.112",
3
+ "version": "0.1.113-test.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -36,20 +36,20 @@
36
36
  "primevue": "^4.2.5"
37
37
  },
38
38
  "devDependencies": {
39
- "@nuxt/devtools": "^2.6.2",
40
- "@nuxt/eslint-config": "^1.6.0",
41
- "@nuxt/module-builder": "^1.0.1",
42
- "@nuxt/schema": "^3.17.0",
43
- "@nuxt/test-utils": "^3.17.0",
44
- "@types/node": "^22.0.0",
45
- "eslint": "^9.31.0",
46
- "nuxt": "^3.17.0",
39
+ "@nuxt/devtools": "catalog:",
40
+ "@nuxt/eslint-config": "catalog:",
41
+ "@nuxt/module-builder": "catalog:",
42
+ "@nuxt/schema": "catalog:",
43
+ "@nuxt/test-utils": "catalog:",
44
+ "@types/node": "catalog:",
45
+ "eslint": "catalog:",
46
+ "nuxt": "catalog:",
47
47
  "primevue": "^4.5.4",
48
- "sass": "^1.89.2",
49
- "typescript": "~5.8.0",
50
- "vitest": "^3.2.4",
51
- "vue": "^3.5.13",
52
- "vue-tsc": "^3.0.3"
48
+ "sass": "catalog:",
49
+ "typescript": "catalog:",
50
+ "vitest": "catalog:",
51
+ "vue": "catalog:",
52
+ "vue-tsc": "catalog:"
53
53
  },
54
54
  "gitHead": "cbb3596d2eefade7ab3126e47dccbed676cdcc80"
55
55
  }