@saasmakers/ui 2.0.38 → 2.0.40
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/app/components/bases/BaseEmoji.vue +1 -1
- package/app/components/bases/BaseToast.vue +9 -1
- package/app/components/layout/LayoutBottomSheet.vue +2 -2
- package/app/components/layout/LayoutModal.vue +2 -2
- package/app/components/layout/LayoutToasts.vue +1 -0
- package/app/composables/useToasts.ts +35 -5
- package/app/types/bases.d.ts +1 -0
- package/app/types/layout.d.ts +2 -2
- package/package.json +1 -1
|
@@ -65,7 +65,7 @@ function onKeyDown(event: KeyboardEvent) {
|
|
|
65
65
|
'h-2.5 w-2.5': size === '3xs',
|
|
66
66
|
'h-3 w-3': size === '2xs',
|
|
67
67
|
'h-3.5 w-3.5': size === 'xs',
|
|
68
|
-
'h-4 w-4': size === 'sm',
|
|
68
|
+
'h-4.5 w-4.5': size === 'sm',
|
|
69
69
|
'h-5 w-5': size === 'base',
|
|
70
70
|
'h-5.5 w-5.5': size === 'lg',
|
|
71
71
|
'h-6 w-6': size === 'xl',
|
|
@@ -38,7 +38,15 @@ function onClose(event: KeyboardEvent | MouseEvent) {
|
|
|
38
38
|
@keydown.space.prevent="onClose"
|
|
39
39
|
>
|
|
40
40
|
<div class="pointer-events-none flex items-center flex-initial">
|
|
41
|
+
<BaseEmoji
|
|
42
|
+
v-if="emoji"
|
|
43
|
+
:clickable="false"
|
|
44
|
+
:emoji="emoji"
|
|
45
|
+
size="sm"
|
|
46
|
+
/>
|
|
47
|
+
|
|
41
48
|
<BaseIcon
|
|
49
|
+
v-else
|
|
42
50
|
size="xl"
|
|
43
51
|
:status="status"
|
|
44
52
|
/>
|
|
@@ -79,7 +87,7 @@ function onClose(event: KeyboardEvent | MouseEvent) {
|
|
|
79
87
|
|
|
80
88
|
<template v-if="hasClose">
|
|
81
89
|
<BaseIcon
|
|
82
|
-
class="ml-
|
|
90
|
+
class="ml-1.5 text-gray-400 transition-colors flex-initial dark:text-gray-500"
|
|
83
91
|
:class="{
|
|
84
92
|
'group-hover:text-red-600 dark:group-hover:text-red-400': status === 'error',
|
|
85
93
|
'group-hover:text-indigo-600 dark:group-hover:text-indigo-400': status === 'info',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { LayoutBottomSheet } from '../../types/layout'
|
|
3
3
|
|
|
4
|
-
withDefaults(defineProps<LayoutBottomSheet>(), {
|
|
4
|
+
const props = withDefaults(defineProps<LayoutBottomSheet>(), { 'aria-label': undefined })
|
|
5
5
|
|
|
6
6
|
defineSlots<{
|
|
7
7
|
default?: () => VNode[]
|
|
@@ -199,7 +199,7 @@ watch(visible, (isVisible) => {
|
|
|
199
199
|
<div
|
|
200
200
|
v-if="visible"
|
|
201
201
|
ref="panelRef"
|
|
202
|
-
:aria-label="
|
|
202
|
+
:aria-label="props['aria-label']"
|
|
203
203
|
aria-modal="true"
|
|
204
204
|
class="layout-bottom-sheet fixed bottom-0 left-0 right-0 z-[60] mx-auto max-h-[85dvh] max-w-screen-md flex flex-col rounded-t-2xl bg-white text-gray-900 app-text shadow-lg outline-none safe-bottom dark:bg-gray-900 dark:text-gray-100"
|
|
205
205
|
:class="{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { LayoutModal } from '../../types/layout'
|
|
3
3
|
|
|
4
|
-
withDefaults(defineProps<LayoutModal>(), {
|
|
4
|
+
const props = withDefaults(defineProps<LayoutModal>(), { 'aria-label': undefined })
|
|
5
5
|
|
|
6
6
|
defineSlots<{
|
|
7
7
|
default?: () => VNode[]
|
|
@@ -39,7 +39,7 @@ function onClose() {
|
|
|
39
39
|
>
|
|
40
40
|
<div
|
|
41
41
|
ref="panelRef"
|
|
42
|
-
:aria-label="
|
|
42
|
+
:aria-label="props['aria-label']"
|
|
43
43
|
aria-modal="true"
|
|
44
44
|
class="scroll-y-stable pointer-events-auto max-h-[85dvh] max-w-md w-full rounded-2xl bg-white p-5 text-gray-900 app-text shadow-lg outline-none dark:bg-gray-900 dark:text-gray-100"
|
|
45
45
|
role="dialog"
|
|
@@ -30,6 +30,7 @@ function onToastClose(_event: KeyboardEvent | MouseEvent, toast: BaseToast) {
|
|
|
30
30
|
:id="toast.id"
|
|
31
31
|
:key="toast.id"
|
|
32
32
|
:action="toast.action"
|
|
33
|
+
:emoji="toast.emoji"
|
|
33
34
|
:has-active-shortcut="toast.id === activeShortcutToastId"
|
|
34
35
|
:status="toast.status"
|
|
35
36
|
:text="toast.text"
|
|
@@ -19,6 +19,7 @@ export default function useToast() {
|
|
|
19
19
|
|
|
20
20
|
const createToast = (params: {
|
|
21
21
|
action?: BaseToastAction
|
|
22
|
+
emoji?: string
|
|
22
23
|
i18nParams?: Record<string, number | string>
|
|
23
24
|
message: string
|
|
24
25
|
replaceAll?: boolean
|
|
@@ -36,8 +37,18 @@ export default function useToast() {
|
|
|
36
37
|
? params.message
|
|
37
38
|
: nuxtApp.$i18n.t(`toasts.${params.message}`, params.i18nParams ?? {})
|
|
38
39
|
|
|
39
|
-
const fingerprint = getFingerprint(
|
|
40
|
-
|
|
40
|
+
const fingerprint = getFingerprint({
|
|
41
|
+
actionLabel: params.action?.label,
|
|
42
|
+
emoji: params.emoji,
|
|
43
|
+
status: params.status,
|
|
44
|
+
text,
|
|
45
|
+
})
|
|
46
|
+
const existingToast = toasts.value.find(item => getFingerprint({
|
|
47
|
+
actionLabel: item.action?.label,
|
|
48
|
+
emoji: item.emoji,
|
|
49
|
+
status: item.status,
|
|
50
|
+
text: item.text,
|
|
51
|
+
}) === fingerprint)
|
|
41
52
|
|
|
42
53
|
if (existingToast) {
|
|
43
54
|
if (params.action) {
|
|
@@ -51,6 +62,7 @@ export default function useToast() {
|
|
|
51
62
|
|
|
52
63
|
const toast: BaseToast = {
|
|
53
64
|
action: params.action,
|
|
65
|
+
emoji: params.emoji,
|
|
54
66
|
id: crypto.randomUUID(),
|
|
55
67
|
status: params.status ?? 'success',
|
|
56
68
|
text,
|
|
@@ -86,10 +98,28 @@ function closeToast(toastId: string) {
|
|
|
86
98
|
toasts.value = toasts.value.filter(item => item.id !== toastId)
|
|
87
99
|
}
|
|
88
100
|
|
|
89
|
-
function getFingerprint(
|
|
90
|
-
|
|
101
|
+
function getFingerprint(params: {
|
|
102
|
+
actionLabel?: BaseTextText
|
|
103
|
+
emoji?: string
|
|
104
|
+
status?: BaseStatus
|
|
105
|
+
text: BaseTextText
|
|
106
|
+
}): string {
|
|
107
|
+
const normalize = (value: BaseTextText) => typeof value === 'string' ? value : JSON.stringify(value)
|
|
108
|
+
|
|
109
|
+
const parts = [
|
|
110
|
+
params.status ?? 'success',
|
|
111
|
+
normalize(params.text),
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
if (params.actionLabel) {
|
|
115
|
+
parts.push(normalize(params.actionLabel))
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (params.emoji) {
|
|
119
|
+
parts.push(params.emoji)
|
|
120
|
+
}
|
|
91
121
|
|
|
92
|
-
return
|
|
122
|
+
return parts.join(':')
|
|
93
123
|
}
|
|
94
124
|
|
|
95
125
|
function scheduleDismiss(toastId: string, hasAction: boolean) {
|
package/app/types/bases.d.ts
CHANGED
package/app/types/layout.d.ts
CHANGED