@apptegy/nuxt-navigation 0.1.81 → 0.1.84

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.81",
7
+ "version": "0.1.84",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.1",
10
10
  "unbuild": "unknown"
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { useDropdown, useNuxtApp, useAppConfig, computed, ref, watch } from "#imports";
2
+ import { useDropdown, useNuxtApp, useAppConfig, computed, ref, watch, onBeforeUpdate } from "#imports";
3
3
  import { vOnClickOutside } from "@vueuse/components";
4
4
  const { $t } = useNuxtApp();
5
5
  const appConfig = useAppConfig();
@@ -7,7 +7,7 @@ const zIndex = computed(() => appConfig?.navigation?.zIndex || 100);
7
7
  const emit = defineEmits(["update:model-value"]);
8
8
  const dropdownTriggerRef = ref();
9
9
  const inputRef = ref();
10
- const optionRef = ref();
10
+ const optionRefs = ref([]);
11
11
  const props = defineProps({
12
12
  orgs: { type: Array, required: true },
13
13
  modelValue: { type: Number, required: true }
@@ -29,7 +29,7 @@ const {
29
29
  keydownActionsOnTrigger,
30
30
  handleKeydown,
31
31
  handleDropdownSearch
32
- } = useDropdown(props.orgs, optionRef, inputRef, {
32
+ } = useDropdown(props.orgs, optionRefs, inputRef, {
33
33
  searchable: true,
34
34
  trackBy: "name"
35
35
  });
@@ -50,7 +50,17 @@ const highlightedOrg = computed(() => {
50
50
  }
51
51
  return null;
52
52
  });
53
+ onBeforeUpdate(() => {
54
+ optionRefs.value = [];
55
+ });
56
+ function setOptionRef(el, option) {
57
+ if (el) {
58
+ const index = props.orgs.findIndex((org) => org.id === option.id);
59
+ optionRefs.value[index] = el;
60
+ }
61
+ }
53
62
  function handleSelectedOrg($event, orgId) {
63
+ const orgIndex = props.orgs.findIndex((org) => org.id === orgId);
54
64
  if ($event.type == "click") {
55
65
  localSelectedOrgId.value = orgId;
56
66
  emit("update:model-value", orgId);
@@ -61,7 +71,7 @@ function handleSelectedOrg($event, orgId) {
61
71
  localSelectedOrgId.value = orgId;
62
72
  emit("update:model-value", orgId);
63
73
  }
64
- handleKeydown(keyEvent, orgId);
74
+ handleKeydown(keyEvent, orgIndex);
65
75
  }
66
76
  }
67
77
  </script>
@@ -110,7 +120,7 @@ function handleSelectedOrg($event, orgId) {
110
120
  <div
111
121
  v-for="option in sortedOrgs"
112
122
  :key="option.id"
113
- ref="optionRef"
123
+ :ref="(el) => setOptionRef(el, option)"
114
124
  v-on-click-outside="onClickOutsideHandler"
115
125
  role="option"
116
126
  class="org-option"
@@ -119,7 +129,7 @@ function handleSelectedOrg($event, orgId) {
119
129
  highlighted: highlightedOrg && option.id === highlightedOrg.id
120
130
  }"
121
131
  :aria-selected="option.id === localSelectedOrgId"
122
- tabindex="-1"
132
+ tabindex="0"
123
133
  @keydown="handleSelectedOrg($event, option.id)"
124
134
  @click="handleSelectedOrg($event, option.id)"
125
135
  >
@@ -44,7 +44,7 @@
44
44
  <button v-if="!lockedExpanded && allowCollapse && expanded" class="hamburger-button" @click="lockSidebar" v-tooltip.bottom="'Pin menu open'">
45
45
  <Unpinned />
46
46
  </button>
47
- <button v-if="!lockedExpanded && allowCollapse && !expanded" class="hamburger-button">
47
+ <button v-if="!lockedExpanded && allowCollapse && !expanded" ref="hamburgerButtonRef" class="hamburger-button">
48
48
  <a-icon icon="24:hamburger" />
49
49
  </button>
50
50
  </div>
@@ -93,9 +93,9 @@
93
93
  </template>
94
94
 
95
95
  <script setup>
96
- import { useSidebar, useBranding, useNuxtApp, ref, watch, computed, onMounted, onBeforeUnmount } from "#imports";
96
+ import { useSidebar, useBranding, useNuxtApp, ref, watch, computed, onMounted, onBeforeUnmount, nextTick } from "#imports";
97
97
  import ApptegyLogo from "./Icons/ApptegyLogo.vue";
98
- import { useBreakpoints, breakpointsTailwind } from "@vueuse/core";
98
+ import { useWindowSize } from "@vueuse/core";
99
99
  import Unpinned from "./Icons/Unpinned.vue";
100
100
  import Pinned from "./Icons/Pinned.vue";
101
101
  const { $t } = useNuxtApp();
@@ -134,11 +134,13 @@ const brandLogoRef = ref(null);
134
134
  const brandLogoWidthPx = ref(0);
135
135
  let brandLogoResizeObserver = null;
136
136
  const _brandLogoWidth = computed(() => brandLogoWidthPx.value);
137
- const breakpoints = useBreakpoints(breakpointsTailwind);
138
- const isMobile = breakpoints.smaller("md");
137
+ const { width: windowWidth } = useWindowSize();
138
+ const isMobile = computed(() => windowWidth.value < 600);
139
139
  const lockedExpanded = ref(true);
140
140
  const allowCollapse = ref(false);
141
141
  let focusOutTimeout = null;
142
+ const hamburgerButtonRef = ref(null);
143
+ let ignoreNextFocusIn = false;
142
144
  function updateBrandLogoWidth() {
143
145
  brandLogoWidthPx.value = brandLogoRef.value?.clientWidth ?? 0;
144
146
  }
@@ -180,6 +182,10 @@ function onHoverLeave() {
180
182
  }
181
183
  }
182
184
  function onFocusEnter() {
185
+ if (ignoreNextFocusIn) {
186
+ ignoreNextFocusIn = false;
187
+ return;
188
+ }
183
189
  if (focusOutTimeout) {
184
190
  clearTimeout(focusOutTimeout);
185
191
  focusOutTimeout = null;
@@ -196,10 +202,15 @@ function onFocusLeave() {
196
202
  focusOutTimeout = null;
197
203
  }, 100);
198
204
  }
199
- function closeSidebar() {
205
+ async function closeSidebar() {
200
206
  expanded.value = false;
201
207
  lockedExpanded.value = false;
202
208
  allowCollapse.value = true;
209
+ ignoreNextFocusIn = true;
210
+ await nextTick();
211
+ if (hamburgerButtonRef.value) {
212
+ hamburgerButtonRef.value.focus();
213
+ }
203
214
  }
204
215
  function lockSidebar() {
205
216
  lockedExpanded.value = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apptegy/nuxt-navigation",
3
- "version": "0.1.81",
3
+ "version": "0.1.84",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -46,5 +46,5 @@
46
46
  "vue": "^3.5.13",
47
47
  "vue-tsc": "^3.0.3"
48
48
  },
49
- "gitHead": "de3fb4f51bb236aaf3bfa98134b73e5ee4f0fbc0"
49
+ "gitHead": "97655b67d2683cf60fcd1321f80c68c8edcba87a"
50
50
  }