srcdev-nuxt-components 6.1.5 → 6.1.7
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.
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="display-prompt-core"
|
|
4
|
-
:class="[{ dismissed: hide }, { 'use-local-style-overrides': useLocalStyleOverrides }]"
|
|
5
|
-
:data-test-id="`display-prompt-core-${theme}`"
|
|
6
|
-
>
|
|
2
|
+
<div class="display-prompt-core" :class="[{ dismissed: hide }]" :data-test-id="`display-prompt-core-${theme}`">
|
|
7
3
|
<div class="display-prompt-wrapper" :data-theme="theme" :class="[elementClasses]" data-test-id="display-prompt">
|
|
8
4
|
<div class="display-prompt-inner">
|
|
9
5
|
<div class="display-prompt-icon" data-test-id="prompt-icon">
|
|
@@ -47,7 +43,7 @@ const props = defineProps({
|
|
|
47
43
|
type: String,
|
|
48
44
|
default: "error",
|
|
49
45
|
validator(value: string) {
|
|
50
|
-
return ["error", "info", "success", "warning"
|
|
46
|
+
return ["primary", "secondary", "tertiary", "ghost", "error", "info", "success", "warning"].includes(value)
|
|
51
47
|
},
|
|
52
48
|
},
|
|
53
49
|
styleClassPassthrough: {
|
|
@@ -61,10 +57,6 @@ const props = defineProps({
|
|
|
61
57
|
return ["dark-grey", "white"].includes(value)
|
|
62
58
|
},
|
|
63
59
|
},
|
|
64
|
-
useLocalStyleOverrides: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
default: false,
|
|
67
|
-
},
|
|
68
60
|
displayPromptIcons: {
|
|
69
61
|
type: Object as PropType<Record<string, string>>,
|
|
70
62
|
default: () => ({
|
|
@@ -154,12 +154,22 @@ const props = defineProps({
|
|
|
154
154
|
},
|
|
155
155
|
})
|
|
156
156
|
|
|
157
|
-
const slots = useSlots()
|
|
158
157
|
const collapseNavigationBelowWidth = computed(
|
|
159
158
|
() => props.collapseBreakpoint !== null || props.collapseAtMainNavIntersection
|
|
160
159
|
)
|
|
161
160
|
const collapseBreakpoint = ref(props.collapseBreakpoint)
|
|
162
|
-
|
|
161
|
+
|
|
162
|
+
// Use global navigation state for caching between route changes
|
|
163
|
+
const {
|
|
164
|
+
navLoaded,
|
|
165
|
+
navigationInitialized,
|
|
166
|
+
navigationWrapperRects: cachedNavigationWrapperRects,
|
|
167
|
+
secondaryNavRects: cachedSecondaryNavRects,
|
|
168
|
+
clearNavigationCache,
|
|
169
|
+
} = useNavigationState()
|
|
170
|
+
|
|
171
|
+
const slots = useSlots()
|
|
172
|
+
|
|
163
173
|
const navigationWrapperRef = useTemplateRef("navigationWrapper")
|
|
164
174
|
|
|
165
175
|
const closeAllNavigationDetails = () => {
|
|
@@ -215,6 +225,7 @@ const handleSummaryAction = (event: MouseEvent | KeyboardEvent) => {
|
|
|
215
225
|
toggleDetailsElement(event)
|
|
216
226
|
}
|
|
217
227
|
|
|
228
|
+
// Initialize main navigation state
|
|
218
229
|
const mainNavigationState = ref<ResponsiveHeaderState>({
|
|
219
230
|
navListVisibility: {
|
|
220
231
|
firstNav: false,
|
|
@@ -230,7 +241,13 @@ const setNavRef = (key: string, el: HTMLUListElement | null) => {
|
|
|
230
241
|
navRefs.value[key] = el
|
|
231
242
|
}
|
|
232
243
|
|
|
233
|
-
const navigationWrapperRects =
|
|
244
|
+
const navigationWrapperRects = computed({
|
|
245
|
+
get: () => cachedNavigationWrapperRects.value,
|
|
246
|
+
set: (value: IFlooredRect | null) => {
|
|
247
|
+
cachedNavigationWrapperRects.value = value
|
|
248
|
+
},
|
|
249
|
+
})
|
|
250
|
+
|
|
234
251
|
const firstNavRef = ref<HTMLUListElement | null>(null)
|
|
235
252
|
const firstNavRects = ref<IFlooredRect | null>(null)
|
|
236
253
|
|
|
@@ -238,7 +255,12 @@ const secondNavRef = ref<HTMLUListElement | null>(null)
|
|
|
238
255
|
const secondNavRects = ref<IFlooredRect | null>(null)
|
|
239
256
|
|
|
240
257
|
const secondaryNavRef = useTemplateRef("secondaryNav")
|
|
241
|
-
const secondaryNavRects =
|
|
258
|
+
const secondaryNavRects = computed({
|
|
259
|
+
get: () => cachedSecondaryNavRects.value,
|
|
260
|
+
set: (value: IFlooredRect | null) => {
|
|
261
|
+
cachedSecondaryNavRects.value = value
|
|
262
|
+
},
|
|
263
|
+
})
|
|
242
264
|
|
|
243
265
|
const mainNavigationItemsRefs = useTemplateRef<HTMLLIElement[]>("mainNavigationItems")
|
|
244
266
|
|
|
@@ -323,7 +345,8 @@ const determineNavigationItemVisibility = (rect: DOMRect) => {
|
|
|
323
345
|
const initMainNavigationState = () => {
|
|
324
346
|
if (!mainNavigationItemsRefs.value) return
|
|
325
347
|
|
|
326
|
-
mainNavigationItemsRefs.value.forEach((item, index) => {
|
|
348
|
+
mainNavigationItemsRefs.value.forEach(async (item, index) => {
|
|
349
|
+
// await nextTick()
|
|
327
350
|
const rect = item.getBoundingClientRect()
|
|
328
351
|
|
|
329
352
|
const groupKey = item.dataset.groupKey
|
|
@@ -362,10 +385,14 @@ const initMainNavigationState = () => {
|
|
|
362
385
|
}
|
|
363
386
|
|
|
364
387
|
onMounted(async () => {
|
|
388
|
+
// If navigation is already initialized and loaded, skip the setup
|
|
389
|
+
if (navigationInitialized.value && navLoaded.value) {
|
|
390
|
+
return
|
|
391
|
+
}
|
|
392
|
+
|
|
365
393
|
await initTemplateRefs().then(() => {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}, 100)
|
|
394
|
+
navLoaded.value = true
|
|
395
|
+
navigationInitialized.value = true
|
|
369
396
|
})
|
|
370
397
|
|
|
371
398
|
navigationDetailsRefs.value?.forEach((element, index) => {
|
|
@@ -465,7 +492,7 @@ watch(
|
|
|
465
492
|
}
|
|
466
493
|
|
|
467
494
|
.main-navigation-item {
|
|
468
|
-
width: var(--_main-navigation-item-width);
|
|
495
|
+
/* width: var(--_main-navigation-item-width); */
|
|
469
496
|
overflow: hidden;
|
|
470
497
|
transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
|
|
471
498
|
padding-block: var(--_link-focus-visible-outline-width);
|
|
@@ -478,7 +505,7 @@ watch(
|
|
|
478
505
|
color: inherit;
|
|
479
506
|
text-decoration: none;
|
|
480
507
|
margin-inline-start: 0;
|
|
481
|
-
transition: var(--_link-visibility-transition);
|
|
508
|
+
/* transition: var(--_link-visibility-transition); */
|
|
482
509
|
|
|
483
510
|
padding-block: var(--_link-padding-block);
|
|
484
511
|
padding-inline: var(--_link-padding-inline);
|
|
@@ -496,7 +523,7 @@ watch(
|
|
|
496
523
|
--_icon-transform: scaleY(1);
|
|
497
524
|
|
|
498
525
|
margin-inline-start: 0;
|
|
499
|
-
transition: var(--_link-visibility-transition);
|
|
526
|
+
/* transition: var(--_link-visibility-transition); */
|
|
500
527
|
|
|
501
528
|
&[open] {
|
|
502
529
|
--_icon-transform: scaleY(-1);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IFlooredRect } from "@/types/responsiveHeader"
|
|
2
|
+
|
|
3
|
+
export const useNavigationState = () => {
|
|
4
|
+
// Simple reactive refs that persist across route changes using useState
|
|
5
|
+
const navLoaded = useState<boolean>("nav-loaded", () => false)
|
|
6
|
+
const navigationInitialized = useState<boolean>("nav-initialized", () => false)
|
|
7
|
+
|
|
8
|
+
// Navigation rects cache
|
|
9
|
+
const navigationWrapperRects = useState<IFlooredRect | null>("nav-wrapper-rects", () => null)
|
|
10
|
+
const secondaryNavRects = useState<IFlooredRect | null>("secondary-nav-rects", () => null)
|
|
11
|
+
|
|
12
|
+
const clearNavigationCache = () => {
|
|
13
|
+
navLoaded.value = false
|
|
14
|
+
navigationInitialized.value = false
|
|
15
|
+
navigationWrapperRects.value = null
|
|
16
|
+
secondaryNavRects.value = null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
navLoaded,
|
|
21
|
+
navigationInitialized,
|
|
22
|
+
navigationWrapperRects,
|
|
23
|
+
secondaryNavRects,
|
|
24
|
+
clearNavigationCache,
|
|
25
|
+
}
|
|
26
|
+
}
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED