@witchcraft/ui 0.3.10 → 0.3.11
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 +1 -1
- package/dist/runtime/components/LibNotifications/LibNotification.d.vue.ts +7 -1
- package/dist/runtime/components/LibNotifications/LibNotification.vue +20 -1
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +7 -1
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +2 -2
- package/package.json +1 -1
- package/src/runtime/components/LibNotifications/LibNotification.vue +28 -1
- package/src/runtime/components/LibNotifications/LibNotifications.vue +2 -2
package/dist/module.json
CHANGED
|
@@ -11,7 +11,13 @@ Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>, RealProps {
|
|
|
11
11
|
}
|
|
12
12
|
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<Props, {
|
|
13
13
|
focus: () => void;
|
|
14
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}
|
|
14
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
15
|
+
pause: (notification: NotificationEntry) => any;
|
|
16
|
+
resume: (notification: NotificationEntry) => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
18
|
+
onPause?: ((notification: NotificationEntry) => any) | undefined;
|
|
19
|
+
onResume?: ((notification: NotificationEntry) => any) | undefined;
|
|
20
|
+
}>, {
|
|
15
21
|
handler: NotificationHandler;
|
|
16
22
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
17
23
|
top?: (props: {
|
|
@@ -20,13 +20,16 @@
|
|
|
20
20
|
p-1
|
|
21
21
|
text-sm
|
|
22
22
|
focus:border-accent-500
|
|
23
|
+
focus-within:border-accent-500
|
|
23
24
|
`,
|
|
24
25
|
$attrs.class
|
|
25
26
|
)"
|
|
26
27
|
v-bind="{ ...$attrs, class: void 0 }"
|
|
27
28
|
tabindex="0"
|
|
29
|
+
:data-id="notification.id"
|
|
28
30
|
ref="notificationEl"
|
|
29
31
|
@keydown.enter.self="NotificationHandler.resolveToDefault(notification)"
|
|
32
|
+
@pointerenter="notification.timeout && !notification.isPaused && emit('pause', notification)"
|
|
30
33
|
>
|
|
31
34
|
<slot
|
|
32
35
|
name="top"
|
|
@@ -148,7 +151,7 @@
|
|
|
148
151
|
</template>
|
|
149
152
|
|
|
150
153
|
<script setup>
|
|
151
|
-
import { computed, onMounted, ref, useAttrs } from "vue";
|
|
154
|
+
import { computed, onBeforeUnmount, onMounted, ref, useAttrs } from "vue";
|
|
152
155
|
import IFa6RegularCopy from "~icons/fa6-regular/copy";
|
|
153
156
|
import IFa6SolidXmark from "~icons/fa6-solid/xmark";
|
|
154
157
|
import { useSlotVars } from "../../composables/useSlotVars.js";
|
|
@@ -167,13 +170,29 @@ const props = defineProps({
|
|
|
167
170
|
notification: { type: null, required: true },
|
|
168
171
|
handler: { type: Object, required: false, default: void 0 }
|
|
169
172
|
});
|
|
173
|
+
const emit = defineEmits(["pause", "resume"]);
|
|
170
174
|
const getColor = (notification, option) => {
|
|
171
175
|
return notification.dangerous.includes(option) ? "danger" : notification.default === option ? "primary" : "secondary";
|
|
172
176
|
};
|
|
173
177
|
const buttonColors = computed(() => props.notification.options.map((option) => getColor(props.notification, option)));
|
|
174
178
|
const notificationEl = ref(null);
|
|
179
|
+
const mousedownAbortController = new AbortController();
|
|
175
180
|
onMounted(() => {
|
|
176
181
|
notificationEl.value?.focus();
|
|
182
|
+
if (props.notification.timeout) {
|
|
183
|
+
window.addEventListener("pointerdown", (e) => {
|
|
184
|
+
if (!e.target || !(e.target instanceof HTMLElement)) return;
|
|
185
|
+
if (e.target === notificationEl.value || notificationEl.value?.contains(e.target)) {
|
|
186
|
+
if (props.notification.isPaused) return;
|
|
187
|
+
emit("pause", props.notification);
|
|
188
|
+
} else {
|
|
189
|
+
emit("resume", props.notification);
|
|
190
|
+
}
|
|
191
|
+
}, { signal: mousedownAbortController.signal });
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
onBeforeUnmount(() => {
|
|
195
|
+
mousedownAbortController.abort();
|
|
177
196
|
});
|
|
178
197
|
defineExpose({
|
|
179
198
|
focus: () => {
|
|
@@ -11,7 +11,13 @@ Partial<Omit<HTMLAttributes, "class"> & TailwindClassProp>, RealProps {
|
|
|
11
11
|
}
|
|
12
12
|
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<Props, {
|
|
13
13
|
focus: () => void;
|
|
14
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}
|
|
14
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
15
|
+
pause: (notification: NotificationEntry) => any;
|
|
16
|
+
resume: (notification: NotificationEntry) => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
18
|
+
onPause?: ((notification: NotificationEntry) => any) | undefined;
|
|
19
|
+
onResume?: ((notification: NotificationEntry) => any) | undefined;
|
|
20
|
+
}>, {
|
|
15
21
|
handler: NotificationHandler;
|
|
16
22
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
17
23
|
top?: (props: {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
class="overflow-hidden my-2"
|
|
33
33
|
v-for="notification of notifications"
|
|
34
34
|
:key="notification.id"
|
|
35
|
-
@
|
|
36
|
-
@
|
|
35
|
+
@pause="handler.pause(notification)"
|
|
36
|
+
@resume="handler.resume(notification)"
|
|
37
37
|
>
|
|
38
38
|
<template #top>
|
|
39
39
|
<LibProgressBar
|
package/package.json
CHANGED
|
@@ -19,12 +19,15 @@
|
|
|
19
19
|
p-1
|
|
20
20
|
text-sm
|
|
21
21
|
focus:border-accent-500
|
|
22
|
+
focus-within:border-accent-500
|
|
22
23
|
`,
|
|
23
24
|
($attrs as any).class)"
|
|
24
25
|
v-bind="{ ...$attrs, class: undefined }"
|
|
25
26
|
tabindex="0"
|
|
27
|
+
:data-id="notification.id"
|
|
26
28
|
ref="notificationEl"
|
|
27
29
|
@keydown.enter.self="NotificationHandler.resolveToDefault(notification)"
|
|
30
|
+
@pointerenter="notification.timeout && !notification.isPaused && emit('pause', notification)"
|
|
28
31
|
>
|
|
29
32
|
<slot
|
|
30
33
|
name="top"
|
|
@@ -145,7 +148,7 @@
|
|
|
145
148
|
</template>
|
|
146
149
|
|
|
147
150
|
<script setup lang="ts">
|
|
148
|
-
import { computed, type HTMLAttributes, onMounted, ref, useAttrs } from "vue"
|
|
151
|
+
import { computed, type HTMLAttributes, onBeforeUnmount, onMounted, ref, useAttrs } from "vue"
|
|
149
152
|
|
|
150
153
|
import IFa6RegularCopy from "~icons/fa6-regular/copy"
|
|
151
154
|
import IFa6SolidXmark from "~icons/fa6-solid/xmark"
|
|
@@ -171,6 +174,11 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
171
174
|
handler: undefined
|
|
172
175
|
})
|
|
173
176
|
|
|
177
|
+
const emit = defineEmits<{
|
|
178
|
+
(e: "pause", notification: NotificationEntry): void
|
|
179
|
+
(e: "resume", notification: NotificationEntry): void
|
|
180
|
+
}>()
|
|
181
|
+
|
|
174
182
|
const getColor = (notification: NotificationEntry, option: string): "ok" | "primary" | "danger" | "secondary" => {
|
|
175
183
|
return notification.dangerous.includes(option)
|
|
176
184
|
? "danger"
|
|
@@ -184,9 +192,28 @@ const getColor = (notification: NotificationEntry, option: string): "ok" | "prim
|
|
|
184
192
|
const buttonColors = computed(() => props.notification.options.map((option: any /* what ??? */) => getColor(props.notification, option)))
|
|
185
193
|
|
|
186
194
|
const notificationEl = ref<null | HTMLElement>(null)
|
|
195
|
+
|
|
196
|
+
const mousedownAbortController = new AbortController()
|
|
197
|
+
|
|
187
198
|
onMounted(() => {
|
|
188
199
|
notificationEl.value?.focus()
|
|
200
|
+
if (props.notification.timeout) {
|
|
201
|
+
window.addEventListener("pointerdown", e => {
|
|
202
|
+
if (!e.target || !(e.target instanceof HTMLElement)) return
|
|
203
|
+
if (e.target === notificationEl.value || notificationEl.value?.contains(e.target)) {
|
|
204
|
+
if (props.notification.isPaused) return
|
|
205
|
+
emit("pause", props.notification)
|
|
206
|
+
} else {
|
|
207
|
+
emit("resume", props.notification)
|
|
208
|
+
}
|
|
209
|
+
}, { signal: mousedownAbortController.signal })
|
|
210
|
+
}
|
|
189
211
|
})
|
|
212
|
+
|
|
213
|
+
onBeforeUnmount(() => {
|
|
214
|
+
mousedownAbortController.abort()
|
|
215
|
+
})
|
|
216
|
+
|
|
190
217
|
defineExpose({
|
|
191
218
|
focus: () => {
|
|
192
219
|
notificationEl.value?.focus()
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
class="overflow-hidden my-2"
|
|
33
33
|
v-for="notification of notifications"
|
|
34
34
|
:key="notification.id"
|
|
35
|
-
@
|
|
36
|
-
@
|
|
35
|
+
@pause="handler.pause(notification)"
|
|
36
|
+
@resume="handler.resume(notification)"
|
|
37
37
|
>
|
|
38
38
|
<template #top>
|
|
39
39
|
<LibProgressBar
|