srcdev-nuxt-components 9.2.9 → 9.2.10
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.
|
@@ -24,7 +24,6 @@ html {
|
|
|
24
24
|
color: var(--colour-text-default);
|
|
25
25
|
font-family: var(--font-family);
|
|
26
26
|
font-size: var(--step-4);
|
|
27
|
-
/* min-height: 100dvh; */
|
|
28
27
|
transition:
|
|
29
28
|
background-color 0.4s ease,
|
|
30
29
|
color 0.4s ease;
|
|
@@ -33,12 +32,11 @@ html {
|
|
|
33
32
|
|
|
34
33
|
#__nuxt {
|
|
35
34
|
height: 100%;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
35
|
+
.page-layout {
|
|
36
|
+
min-block-size: 100svh;
|
|
37
|
+
display: grid;
|
|
38
|
+
grid-template-rows: auto 1fr auto;
|
|
39
|
+
align-items: start;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="expanding-panel" :class="[elementClasses, { 'content-is-on-top': contentIsOnTop }]">
|
|
2
|
+
<div ref="rootEl" class="expanding-panel" :class="[elementClasses, { 'content-is-on-top': contentIsOnTop }]">
|
|
3
3
|
<details class="expanding-panel-details" :name :open @toggle="onDetailsToggle">
|
|
4
4
|
<summary
|
|
5
5
|
:id="`id-${name}-trigger`"
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
</template>
|
|
33
33
|
|
|
34
34
|
<script setup lang="ts">
|
|
35
|
+
import { onClickOutside } from "@vueuse/core";
|
|
36
|
+
|
|
35
37
|
interface Props {
|
|
36
38
|
name?: string;
|
|
37
39
|
animationDuration?: number;
|
|
@@ -56,6 +58,17 @@ const open = computed(() => props.forceOpened || isPanelOpen.value);
|
|
|
56
58
|
|
|
57
59
|
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
|
|
58
60
|
|
|
61
|
+
// contentIsOnTop panels behave like a dropdown/overlay (e.g. ContentDocs' mobile nav) rather
|
|
62
|
+
// than an inline accordion — clicking outside is the expected way to dismiss those, matching
|
|
63
|
+
// native <select>/menu behaviour. Not wanted for ordinary accordions (forceOpened is always
|
|
64
|
+
// false here too — a forceOpened panel isn't meant to be dismissible by any interaction).
|
|
65
|
+
const rootEl = ref<HTMLElement | null>(null);
|
|
66
|
+
onClickOutside(rootEl, () => {
|
|
67
|
+
if (props.contentIsOnTop && !props.forceOpened && isPanelOpen.value) {
|
|
68
|
+
isPanelOpen.value = false;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
59
72
|
if (import.meta.dev) {
|
|
60
73
|
watch(
|
|
61
74
|
() => props.contentIsOnTop,
|
|
@@ -97,10 +110,9 @@ const onDetailsToggle = (event: Event) => {
|
|
|
97
110
|
cursor: pointer;
|
|
98
111
|
}
|
|
99
112
|
.expanding-panel-summary {
|
|
100
|
-
display:
|
|
113
|
+
display: grid;
|
|
101
114
|
align-items: center;
|
|
102
|
-
|
|
103
|
-
flex-direction: row;
|
|
115
|
+
grid-template-columns: 1fr auto;
|
|
104
116
|
gap: var(--expanding-panel-summary-gap, 1rem);
|
|
105
117
|
list-style: none;
|
|
106
118
|
user-select: none;
|
|
@@ -427,6 +427,53 @@ describe("ExpandingPanel", () => {
|
|
|
427
427
|
expect(vm.isPanelOpen).toBe(true);
|
|
428
428
|
});
|
|
429
429
|
|
|
430
|
+
it("closes an open contentIsOnTop panel on outside click", async () => {
|
|
431
|
+
const wrapper = await mountSuspended(ExpandingPanel, {
|
|
432
|
+
props: { name: "content-on-top-outside-click", contentIsOnTop: true },
|
|
433
|
+
attachTo: document.body,
|
|
434
|
+
});
|
|
435
|
+
const vm = wrapper.vm as unknown as ExpandingPanelInstance;
|
|
436
|
+
|
|
437
|
+
await wrapper.find("summary").trigger("click");
|
|
438
|
+
expect(vm.isPanelOpen).toBe(true);
|
|
439
|
+
|
|
440
|
+
document.body.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
441
|
+
await nextTick();
|
|
442
|
+
|
|
443
|
+
expect(vm.isPanelOpen).toBe(false);
|
|
444
|
+
wrapper.unmount();
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it("does not close on outside click when contentIsOnTop is false (ordinary accordion)", async () => {
|
|
448
|
+
const wrapper = await mountSuspended(ExpandingPanel, {
|
|
449
|
+
props: { name: "content-on-top-outside-click-inline" },
|
|
450
|
+
attachTo: document.body,
|
|
451
|
+
});
|
|
452
|
+
const vm = wrapper.vm as unknown as ExpandingPanelInstance;
|
|
453
|
+
|
|
454
|
+
await wrapper.find("summary").trigger("click");
|
|
455
|
+
expect(vm.isPanelOpen).toBe(true);
|
|
456
|
+
|
|
457
|
+
document.body.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
458
|
+
await nextTick();
|
|
459
|
+
|
|
460
|
+
expect(vm.isPanelOpen).toBe(true);
|
|
461
|
+
wrapper.unmount();
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it("does not close a forceOpened contentIsOnTop panel on outside click", async () => {
|
|
465
|
+
const wrapper = await mountSuspended(ExpandingPanel, {
|
|
466
|
+
props: { name: "content-on-top-outside-click-forced", contentIsOnTop: true, forceOpened: true },
|
|
467
|
+
attachTo: document.body,
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
document.body.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
471
|
+
await nextTick();
|
|
472
|
+
|
|
473
|
+
expect(wrapper.find("details").attributes("open")).toBeDefined();
|
|
474
|
+
wrapper.unmount();
|
|
475
|
+
});
|
|
476
|
+
|
|
430
477
|
// ─── name prop / useId fallback ───────────────────────────────────────────
|
|
431
478
|
|
|
432
479
|
it("uses the provided name in ARIA attributes", async () => {
|