@saasmakers/ui 2.0.39 → 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.
@@ -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-2 text-gray-400 transition-colors flex-initial dark:text-gray-500"
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',
@@ -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(params.status, text, params.action?.label)
40
- const existingToast = toasts.value.find(item => getFingerprint(item.status, item.text, item.action?.label) === fingerprint)
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(status: BaseStatus | undefined, text: BaseTextText, actionLabel?: BaseTextText): string {
90
- const normalize = (t: BaseTextText) => typeof t === 'string' ? t : JSON.stringify(t)
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 `${status ?? 'success'}:${normalize(text)}:${actionLabel ? normalize(actionLabel) : ''}`
122
+ return parts.join(':')
93
123
  }
94
124
 
95
125
  function scheduleDismiss(toastId: string, hasAction: boolean) {
@@ -398,6 +398,7 @@ export type BaseTextText = string | {
398
398
 
399
399
  export interface BaseToast {
400
400
  action?: BaseToastAction
401
+ emoji?: string
401
402
  hasActiveShortcut?: boolean
402
403
  hasClose?: boolean
403
404
  id: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasmakers/ui",
3
- "version": "2.0.39",
3
+ "version": "2.0.40",
4
4
  "private": false,
5
5
  "description": "Reusable Nuxt UI components for SaaS Makers projects",
6
6
  "license": "MIT",