adminforth 4.12.5 → 4.13.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/spa/src/App.vue
CHANGED
|
@@ -131,15 +131,7 @@
|
|
|
131
131
|
</div>
|
|
132
132
|
</div>
|
|
133
133
|
<AcceptModal />
|
|
134
|
-
<
|
|
135
|
-
<transition-group
|
|
136
|
-
name="fade"
|
|
137
|
-
tag="div"
|
|
138
|
-
class="flex flex-col-reverse gap-1"
|
|
139
|
-
>
|
|
140
|
-
<Toast :toast="t" @close="toastStore.removeToast(t)" v-for="(t,i) in toastStore.toasts" :key="`t-${t.id}`" ></Toast>
|
|
141
|
-
</transition-group>
|
|
142
|
-
</div>
|
|
134
|
+
<ToastStack :style="{ right: `${appPaddingRight}px` }" />
|
|
143
135
|
|
|
144
136
|
|
|
145
137
|
<div v-if="sideBarOpen"
|
|
@@ -171,22 +163,6 @@
|
|
|
171
163
|
animation: blink 2s ease-in-out infinite;
|
|
172
164
|
}
|
|
173
165
|
|
|
174
|
-
.fade-leave-active {
|
|
175
|
-
@apply transition-opacity duration-500;
|
|
176
|
-
}
|
|
177
|
-
.fade-leave-to {
|
|
178
|
-
@apply opacity-0;
|
|
179
|
-
}
|
|
180
|
-
.fade-enter-active {
|
|
181
|
-
@apply transition-opacity duration-500;
|
|
182
|
-
}
|
|
183
|
-
.fade-enter-from {
|
|
184
|
-
@apply opacity-0;
|
|
185
|
-
}
|
|
186
|
-
.fade-enter-to {
|
|
187
|
-
@apply opacity-100;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
166
|
@media (max-width: 640px) {
|
|
191
167
|
.af-content-wrapper {
|
|
192
168
|
margin-left: 0 !important;
|
|
@@ -209,15 +185,13 @@ import Sidebar from './components/Sidebar.vue';
|
|
|
209
185
|
import { useRoute, useRouter } from 'vue-router';
|
|
210
186
|
import { createHead } from 'unhead'
|
|
211
187
|
import { getCustomComponent, handleNotAuthorized } from '@/utils';
|
|
212
|
-
import
|
|
213
|
-
import {useToastStore} from '@/stores/toast';
|
|
188
|
+
import ToastStack from './components/ToastStack.vue';
|
|
214
189
|
import adminforth, { initFrontedAPI, useAdminforth } from '@/adminforth';
|
|
215
190
|
import UserMenuSettingsButton from './components/UserMenuSettingsButton.vue';
|
|
216
191
|
import { Tooltip, Spinner, DropdownMenu, DropdownMenuItem } from '@/afcl'
|
|
217
192
|
import { USER_MENU_ITEM_CLASSES } from '@/utils/userMenu';
|
|
218
193
|
|
|
219
194
|
const coreStore = useCoreStore();
|
|
220
|
-
const toastStore = useToastStore();
|
|
221
195
|
const userStore = useUserStore();
|
|
222
196
|
|
|
223
197
|
const { menu } = useAdminforth();
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
<div class="afcl-toast flex items-center w-full p-3 pe-4 rounded-lg shadow-popover dark:shadow-darkPopover dark:text-darkToastText dark:bg-darkToastBackground bg-lightToastBackground text-lightToastText"
|
|
5
5
|
role="alert"
|
|
6
|
-
@mouseenter="pauseTimer"
|
|
7
|
-
@mouseleave="resumeTimer"
|
|
8
6
|
>
|
|
9
7
|
<div class="relative w-8 h-8 flex items-center justify-center">
|
|
10
8
|
<div class="absolute af-toast-icon inline-flex items-center justify-center flex-shrink-0 rounded-lg w-full h-full" :class="variantConfig.iconClass">
|
|
@@ -48,7 +46,7 @@
|
|
|
48
46
|
</template>
|
|
49
47
|
|
|
50
48
|
<script setup lang="ts">
|
|
51
|
-
import {
|
|
49
|
+
import { onUnmounted, computed, ref, watch } from 'vue';
|
|
52
50
|
import { useToastStore } from '@/stores/toast';
|
|
53
51
|
import { IconInfo, IconCircleX, IconTriangleAlert, IconCircleCheck, IconX } from '@iconify-prerendered/vue-lucide';
|
|
54
52
|
|
|
@@ -62,7 +60,8 @@ const props = defineProps<{
|
|
|
62
60
|
id: string;
|
|
63
61
|
timeout?: number|'unlimited';
|
|
64
62
|
buttons?: { value: any; label: string }[];
|
|
65
|
-
}
|
|
63
|
+
};
|
|
64
|
+
paused: boolean;
|
|
66
65
|
}>();
|
|
67
66
|
|
|
68
67
|
const VARIANT_CONFIGS = {
|
|
@@ -134,9 +133,7 @@ function onButtonClick(value: any) {
|
|
|
134
133
|
emit('close');
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
|
|
138
|
-
resumeTimer();
|
|
139
|
-
});
|
|
136
|
+
watch(() => props.paused, (paused) => paused ? pauseTimer() : resumeTimer(), { immediate: true });
|
|
140
137
|
|
|
141
138
|
onUnmounted(() => {
|
|
142
139
|
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- the padding leaves room for the shadows, the list scrolls inside max-h -->
|
|
3
|
+
<div class="af-toast-stack fixed bottom-0 z-[100] flex flex-col-reverse max-h-[50vh] overflow-y-auto p-5 pointer-events-none [scrollbar-width:none] [mask-image:linear-gradient(transparent,black_1.25rem)]">
|
|
4
|
+
<TransitionGroup
|
|
5
|
+
tag="ol"
|
|
6
|
+
class="relative shrink-0 w-96 max-w-[calc(100vw-2.5rem)] pointer-events-auto transition-[height] duration-300 ease-out"
|
|
7
|
+
:style="{ height: `${stack.height}px` }"
|
|
8
|
+
enter-active-class="transition duration-300 ease-out"
|
|
9
|
+
enter-from-class="translate-y-full opacity-0"
|
|
10
|
+
leave-active-class="transition-opacity duration-300"
|
|
11
|
+
leave-to-class="opacity-0"
|
|
12
|
+
@mouseenter="expanded = true"
|
|
13
|
+
@mouseleave="expanded = false"
|
|
14
|
+
>
|
|
15
|
+
<li
|
|
16
|
+
v-for="item in stack.items"
|
|
17
|
+
:key="item.toast.id"
|
|
18
|
+
:ref="(el) => measure(item.toast, el as HTMLElement | null)"
|
|
19
|
+
class="absolute inset-x-0 bottom-0"
|
|
20
|
+
>
|
|
21
|
+
<Toast
|
|
22
|
+
:toast="item.toast"
|
|
23
|
+
:paused="expanded"
|
|
24
|
+
class="origin-top overflow-hidden transition-[transform,height,opacity] duration-300 ease-out *:transition-opacity *:duration-300"
|
|
25
|
+
:class="item.class"
|
|
26
|
+
:style="item.style"
|
|
27
|
+
@close="toastStore.removeToast(item.toast)"
|
|
28
|
+
/>
|
|
29
|
+
</li>
|
|
30
|
+
</TransitionGroup>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup lang="ts">
|
|
35
|
+
import { computed, reactive, ref } from 'vue';
|
|
36
|
+
import Toast from './Toast.vue';
|
|
37
|
+
import { useToastStore } from '@/stores/toast';
|
|
38
|
+
|
|
39
|
+
// collapsed, toasts lie on each other with the newest in front, hover spreads them into a list
|
|
40
|
+
const PEEK_PX = 12; // how much a toast shows above the one in front of it
|
|
41
|
+
const SCALE_STEP = 0.05;
|
|
42
|
+
const STACK_DEPTH = 3; // toasts drawn in the collapsed stack, the older ones wait hidden behind them
|
|
43
|
+
const GAP_PX = 8;
|
|
44
|
+
|
|
45
|
+
const toastStore = useToastStore();
|
|
46
|
+
const expanded = ref(false);
|
|
47
|
+
// natural height of a toast, measured on mount: in the collapsed stack the toasts behind take the height of the front one
|
|
48
|
+
const heights = reactive(new WeakMap<object, number>());
|
|
49
|
+
|
|
50
|
+
function measure(toast: object, el: HTMLElement | null) {
|
|
51
|
+
if (el && !heights.has(toast)) {
|
|
52
|
+
heights.set(toast, el.offsetHeight);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const stack = computed(() => {
|
|
57
|
+
const fromFront = [...toastStore.toasts].reverse();
|
|
58
|
+
const frontHeight = heights.get(fromFront[0]);
|
|
59
|
+
let listOffset = 0;
|
|
60
|
+
const layouts = fromFront.map((toast, i) => {
|
|
61
|
+
const height = heights.get(toast);
|
|
62
|
+
const depth = Math.min(i, STACK_DEPTH - 1);
|
|
63
|
+
const layout = expanded.value
|
|
64
|
+
? { toast, offset: listOffset, height, scale: 1, class: '' }
|
|
65
|
+
: {
|
|
66
|
+
toast,
|
|
67
|
+
offset: depth * PEEK_PX,
|
|
68
|
+
height: i ? frontHeight : height,
|
|
69
|
+
scale: 1 - depth * SCALE_STEP,
|
|
70
|
+
class: i === 0 ? '' : i < STACK_DEPTH ? '*:opacity-0' : 'opacity-0 *:opacity-0',
|
|
71
|
+
};
|
|
72
|
+
listOffset += (height ?? 0) + GAP_PX;
|
|
73
|
+
return layout;
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
height: Math.max(0, ...layouts.map((l) => l.offset + (l.height ?? 0))),
|
|
77
|
+
// older toasts go first in the DOM, so the newer ones are painted over them
|
|
78
|
+
items: layouts.reverse().map((l) => ({
|
|
79
|
+
toast: l.toast,
|
|
80
|
+
class: l.class,
|
|
81
|
+
style: {
|
|
82
|
+
transform: `translateY(-${l.offset}px) scale(${l.scale})`,
|
|
83
|
+
height: l.height === undefined ? undefined : `${l.height}px`,
|
|
84
|
+
},
|
|
85
|
+
})),
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
</script>
|