@saasmakers/ui 0.1.49 → 0.1.50
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.
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { BaseAlert } from '../../types/bases'
|
|
3
|
+
import { Preferences } from '@capacitor/preferences'
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(defineProps<BaseAlert>(), {
|
|
6
|
+
closingId: '',
|
|
7
|
+
isClosable: false,
|
|
8
|
+
size: 'base',
|
|
9
|
+
status: 'info',
|
|
10
|
+
text: '',
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const emit = defineEmits<{
|
|
14
|
+
close: [event: MouseEvent]
|
|
15
|
+
}>()
|
|
16
|
+
|
|
17
|
+
const { t } = useI18n()
|
|
18
|
+
|
|
19
|
+
const isClosed = ref(false)
|
|
20
|
+
|
|
21
|
+
const buttonColor = computed((): BaseColor => {
|
|
22
|
+
if (props.status === 'error') {
|
|
23
|
+
return 'red'
|
|
24
|
+
}
|
|
25
|
+
else if (props.status === 'success') {
|
|
26
|
+
return 'green'
|
|
27
|
+
}
|
|
28
|
+
else if (props.status === 'warning') {
|
|
29
|
+
return 'orange'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return 'indigo'
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
onBeforeMount(async () => {
|
|
36
|
+
if (props.closingId) {
|
|
37
|
+
const { value } = await Preferences.get({ key: `alerts:${props.closingId}` })
|
|
38
|
+
|
|
39
|
+
isClosed.value = value === 'true'
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
async function onClose(event: MouseEvent) {
|
|
44
|
+
isClosed.value = true
|
|
45
|
+
|
|
46
|
+
if (props.closingId) {
|
|
47
|
+
await Preferences.set({
|
|
48
|
+
key: `alerts:${props.closingId}`,
|
|
49
|
+
value: 'true',
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
emit('close', event)
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<div
|
|
59
|
+
v-if="!isClosed"
|
|
60
|
+
class="relative flex flex-col gap-2.5 border rounded p-3 text-center"
|
|
61
|
+
:class="{
|
|
62
|
+
'border-red-600 dark:border-red-400 text-red-600 dark:text-red-400': status === 'error',
|
|
63
|
+
'border-indigo-600 dark:border-indigo-400 text-indigo-600 dark:text-indigo-400': status === 'info',
|
|
64
|
+
'border-green-600 dark:border-green-400 text-green-600 dark:text-green-400': status === 'success',
|
|
65
|
+
'border-orange-600 dark:border-orange-400 text-orange-600 dark:text-orange-400': status === 'warning',
|
|
66
|
+
}"
|
|
67
|
+
>
|
|
68
|
+
<BaseText
|
|
69
|
+
v-if="text"
|
|
70
|
+
:size="size"
|
|
71
|
+
>
|
|
72
|
+
{{ text }}
|
|
73
|
+
</BaseText>
|
|
74
|
+
|
|
75
|
+
<div
|
|
76
|
+
v-if="$slots.buttons || isClosable"
|
|
77
|
+
class="flex flex-col items-center justify-center gap-2 sm:flex-row"
|
|
78
|
+
>
|
|
79
|
+
<slot name="buttons" />
|
|
80
|
+
|
|
81
|
+
<BaseButton
|
|
82
|
+
v-if="isClosable"
|
|
83
|
+
:color="buttonColor"
|
|
84
|
+
:icon="getIcon('closeCircle')"
|
|
85
|
+
light
|
|
86
|
+
size="xs"
|
|
87
|
+
:text="t('closeThisMessage')"
|
|
88
|
+
@click="onClose"
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<slot v-else />
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
|
|
96
|
+
<i18n lang="json">
|
|
97
|
+
{
|
|
98
|
+
"en": {
|
|
99
|
+
"closeThisMessage": "Close this message"
|
|
100
|
+
},
|
|
101
|
+
"fr": {
|
|
102
|
+
"closeThisMessage": "Fermer ce message"
|
|
103
|
+
},
|
|
104
|
+
"ja": {
|
|
105
|
+
"closeThisMessage": "このメッセージを閉じる"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
</i18n>
|
package/app/types/bases.d.ts
CHANGED
|
@@ -27,6 +27,14 @@ export type BaseStatus
|
|
|
27
27
|
| 'success'
|
|
28
28
|
| 'warning'
|
|
29
29
|
|
|
30
|
+
export interface BaseAlert {
|
|
31
|
+
closingId?: string
|
|
32
|
+
isClosable?: boolean
|
|
33
|
+
size?: BaseSize
|
|
34
|
+
status?: BaseStatus
|
|
35
|
+
text?: BaseTextText
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
export interface BaseBordered {
|
|
31
39
|
background?: BaseBackground
|
|
32
40
|
borderColor?: BaseBorderedColor
|
package/app/types/global.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare global {
|
|
|
5
5
|
type RouteLocationNamedI18n = import('vue-router').RouteLocationNamedI18n
|
|
6
6
|
|
|
7
7
|
// Bases
|
|
8
|
+
type BaseAlert = Bases.BaseAlert
|
|
8
9
|
type BaseBackground = Bases.BaseBackground
|
|
9
10
|
type BaseBordered = Bases.BaseBordered
|
|
10
11
|
type BaseBorderedColor = Bases.BaseBorderedColor
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saasmakers/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.50",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Reusable Nuxt UI components for SaaS Makers projects",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"nuxt": "4.2.1"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@capacitor/preferences": "7.0.2",
|
|
33
34
|
"@nuxt/icon": "2.1.0",
|
|
34
35
|
"@nuxtjs/color-mode": "3.5.2",
|
|
35
36
|
"@nuxtjs/i18n": "10.2.0",
|