@datametria/vue-components 1.1.2 → 1.2.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/README.md +657 -472
- package/dist/index.es.js +1916 -675
- package/dist/index.umd.js +74 -1
- package/dist/vue-components.css +1 -1
- package/package.json +98 -98
- package/src/components/DatametriaAlert.vue +137 -123
- package/src/components/DatametriaBadge.vue +98 -90
- package/src/components/DatametriaButton.vue +165 -157
- package/src/components/DatametriaChip.vue +149 -149
- package/src/components/DatametriaMenu.vue +620 -0
- package/src/components/DatametriaNavbar.vue +252 -227
- package/src/components/DatametriaSkeleton.vue +240 -0
- package/src/components/DatametriaSlider.vue +408 -0
- package/src/components/DatametriaTimePicker.vue +286 -0
- package/src/components/DatametriaToast.vue +176 -163
- package/src/components/DatametriaTooltip.vue +409 -0
- package/src/components/__tests__/DatametriaAlert.test.js +36 -0
- package/src/components/__tests__/DatametriaBadge.test.js +30 -0
- package/src/components/__tests__/DatametriaButton.test.js +31 -0
- package/src/components/__tests__/DatametriaChip.test.js +39 -0
- package/src/components/__tests__/DatametriaNavbar.test.js +49 -0
- package/src/components/__tests__/DatametriaToast.test.js +49 -0
- package/src/composables/useAccessibilityScale.ts +95 -0
- package/src/composables/useBreakpoints.ts +83 -0
- package/src/composables/useHapticFeedback.ts +440 -0
- package/src/composables/useRipple.ts +219 -0
- package/src/index.ts +61 -52
- package/src/stories/Variants.stories.js +96 -0
- package/src/styles/design-tokens.css +623 -31
- package/ACCESSIBILITY.md +0 -78
- package/DESIGN-SYSTEM.md +0 -70
- package/PROGRESS.md +0 -327
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="dm-time-picker" :class="{ 'dm-time-picker--disabled': disabled }">
|
|
3
|
+
<label v-if="label" :for="inputId" class="dm-time-picker__label">
|
|
4
|
+
{{ label }}
|
|
5
|
+
<span v-if="required" class="dm-time-picker__required" aria-label="obrigatório">*</span>
|
|
6
|
+
</label>
|
|
7
|
+
|
|
8
|
+
<div class="dm-time-picker__wrapper">
|
|
9
|
+
<input
|
|
10
|
+
:id="inputId"
|
|
11
|
+
ref="inputRef"
|
|
12
|
+
v-model="displayValue"
|
|
13
|
+
type="time"
|
|
14
|
+
class="dm-time-picker__input"
|
|
15
|
+
:class="{
|
|
16
|
+
'dm-time-picker__input--error': hasError,
|
|
17
|
+
'dm-time-picker__input--success': hasSuccess
|
|
18
|
+
}"
|
|
19
|
+
:disabled="disabled"
|
|
20
|
+
:required="required"
|
|
21
|
+
:min="min"
|
|
22
|
+
:max="max"
|
|
23
|
+
:step="step"
|
|
24
|
+
:aria-describedby="ariaDescribedBy"
|
|
25
|
+
:aria-invalid="hasError"
|
|
26
|
+
@input="handleInput"
|
|
27
|
+
@blur="handleBlur"
|
|
28
|
+
@focus="handleFocus"
|
|
29
|
+
/>
|
|
30
|
+
|
|
31
|
+
<div v-if="hasError || hasSuccess" class="dm-time-picker__icon">
|
|
32
|
+
<svg v-if="hasError" class="dm-time-picker__icon--error" viewBox="0 0 20 20" fill="currentColor">
|
|
33
|
+
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
|
|
34
|
+
</svg>
|
|
35
|
+
<svg v-else-if="hasSuccess" class="dm-time-picker__icon--success" viewBox="0 0 20 20" fill="currentColor">
|
|
36
|
+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
|
37
|
+
</svg>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div v-if="errorMessage || successMessage || helperText" class="dm-time-picker__messages">
|
|
42
|
+
<p v-if="errorMessage" :id="`${inputId}-error`" class="dm-time-picker__error" role="alert">
|
|
43
|
+
{{ errorMessage }}
|
|
44
|
+
</p>
|
|
45
|
+
<p v-else-if="successMessage" :id="`${inputId}-success`" class="dm-time-picker__success">
|
|
46
|
+
{{ successMessage }}
|
|
47
|
+
</p>
|
|
48
|
+
<p v-else-if="helperText" :id="`${inputId}-helper`" class="dm-time-picker__helper">
|
|
49
|
+
{{ helperText }}
|
|
50
|
+
</p>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { ref, computed, watch, nextTick } from 'vue'
|
|
57
|
+
|
|
58
|
+
interface Props {
|
|
59
|
+
modelValue?: string
|
|
60
|
+
label?: string
|
|
61
|
+
placeholder?: string
|
|
62
|
+
disabled?: boolean
|
|
63
|
+
required?: boolean
|
|
64
|
+
errorMessage?: string
|
|
65
|
+
successMessage?: string
|
|
66
|
+
helperText?: string
|
|
67
|
+
min?: string
|
|
68
|
+
max?: string
|
|
69
|
+
step?: number
|
|
70
|
+
format24h?: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface Emits {
|
|
74
|
+
(e: 'update:modelValue', value: string): void
|
|
75
|
+
(e: 'blur', event: FocusEvent): void
|
|
76
|
+
(e: 'focus', event: FocusEvent): void
|
|
77
|
+
(e: 'change', value: string): void
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
81
|
+
modelValue: '',
|
|
82
|
+
step: 60,
|
|
83
|
+
format24h: true
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const emit = defineEmits<Emits>()
|
|
87
|
+
|
|
88
|
+
// Refs
|
|
89
|
+
const inputRef = ref<HTMLInputElement>()
|
|
90
|
+
|
|
91
|
+
// Computed
|
|
92
|
+
const inputId = computed(() => `dm-time-picker-${Math.random().toString(36).substr(2, 9)}`)
|
|
93
|
+
|
|
94
|
+
const hasError = computed(() => !!props.errorMessage)
|
|
95
|
+
const hasSuccess = computed(() => !!props.successMessage && !hasError.value)
|
|
96
|
+
|
|
97
|
+
const ariaDescribedBy = computed(() => {
|
|
98
|
+
const ids = []
|
|
99
|
+
if (props.errorMessage) ids.push(`${inputId.value}-error`)
|
|
100
|
+
else if (props.successMessage) ids.push(`${inputId.value}-success`)
|
|
101
|
+
else if (props.helperText) ids.push(`${inputId.value}-helper`)
|
|
102
|
+
return ids.length > 0 ? ids.join(' ') : undefined
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const displayValue = computed({
|
|
106
|
+
get: () => props.modelValue,
|
|
107
|
+
set: (value: string) => {
|
|
108
|
+
emit('update:modelValue', value)
|
|
109
|
+
emit('change', value)
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
// Methods
|
|
114
|
+
const handleInput = (event: Event) => {
|
|
115
|
+
const target = event.target as HTMLInputElement
|
|
116
|
+
displayValue.value = target.value
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const handleBlur = (event: FocusEvent) => {
|
|
120
|
+
emit('blur', event)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const handleFocus = (event: FocusEvent) => {
|
|
124
|
+
emit('focus', event)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const focus = () => {
|
|
128
|
+
nextTick(() => {
|
|
129
|
+
inputRef.value?.focus()
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const blur = () => {
|
|
134
|
+
inputRef.value?.blur()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Watch for external changes
|
|
138
|
+
watch(() => props.modelValue, (newValue) => {
|
|
139
|
+
if (inputRef.value && inputRef.value.value !== newValue) {
|
|
140
|
+
inputRef.value.value = newValue
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
// Expose methods
|
|
145
|
+
defineExpose({
|
|
146
|
+
focus,
|
|
147
|
+
blur,
|
|
148
|
+
inputRef
|
|
149
|
+
})
|
|
150
|
+
</script>
|
|
151
|
+
|
|
152
|
+
<style scoped>
|
|
153
|
+
.dm-time-picker {
|
|
154
|
+
@apply w-full;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.dm-time-picker--disabled {
|
|
158
|
+
@apply opacity-60 cursor-not-allowed;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.dm-time-picker__label {
|
|
162
|
+
@apply block text-sm font-medium text-gray-700 mb-1;
|
|
163
|
+
color: var(--dm-gray-700);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
[data-theme="dark"] .dm-time-picker__label {
|
|
167
|
+
color: var(--dm-text-secondary);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.dm-time-picker__required {
|
|
171
|
+
@apply text-red-500 ml-1;
|
|
172
|
+
color: var(--dm-error);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.dm-time-picker__wrapper {
|
|
176
|
+
@apply relative;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.dm-time-picker__input {
|
|
180
|
+
@apply w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm;
|
|
181
|
+
@apply focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500;
|
|
182
|
+
@apply disabled:bg-gray-50 disabled:cursor-not-allowed;
|
|
183
|
+
@apply transition-colors duration-200;
|
|
184
|
+
|
|
185
|
+
border-color: var(--dm-gray-300, #d1d5db);
|
|
186
|
+
background-color: var(--dm-bg-primary, #ffffff);
|
|
187
|
+
color: var(--dm-text-primary);
|
|
188
|
+
border-radius: var(--dm-radius);
|
|
189
|
+
transition: var(--dm-transition);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.dm-time-picker__input:focus {
|
|
193
|
+
box-shadow: var(--dm-focus-ring);
|
|
194
|
+
border-color: var(--dm-primary);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.dm-time-picker__input--error {
|
|
198
|
+
@apply border-red-500 focus:ring-red-500 focus:border-red-500;
|
|
199
|
+
border-color: var(--dm-error);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.dm-time-picker__input--error:focus {
|
|
203
|
+
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.dm-time-picker__input--success {
|
|
207
|
+
@apply border-green-500 focus:ring-green-500 focus:border-green-500;
|
|
208
|
+
border-color: var(--dm-success);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.dm-time-picker__input--success:focus {
|
|
212
|
+
box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
[data-theme="dark"] .dm-time-picker__input {
|
|
216
|
+
background-color: var(--dm-bg-secondary);
|
|
217
|
+
border-color: var(--dm-gray-600, #4b5563);
|
|
218
|
+
color: var(--dm-text-primary);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[data-theme="dark"] .dm-time-picker__input:disabled {
|
|
222
|
+
background-color: var(--dm-gray-700, #374151);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.dm-time-picker__icon {
|
|
226
|
+
@apply absolute right-3 top-1/2 transform -translate-y-1/2 pointer-events-none;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.dm-time-picker__icon--error {
|
|
230
|
+
@apply w-5 h-5 text-red-500;
|
|
231
|
+
color: var(--dm-error);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.dm-time-picker__icon--success {
|
|
235
|
+
@apply w-5 h-5 text-green-500;
|
|
236
|
+
color: var(--dm-success);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.dm-time-picker__messages {
|
|
240
|
+
@apply mt-1;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.dm-time-picker__error {
|
|
244
|
+
@apply text-sm text-red-600;
|
|
245
|
+
color: var(--dm-error);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.dm-time-picker__success {
|
|
249
|
+
@apply text-sm text-green-600;
|
|
250
|
+
color: var(--dm-success);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.dm-time-picker__helper {
|
|
254
|
+
@apply text-sm text-gray-500;
|
|
255
|
+
color: var(--dm-gray-500, #6b7280);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
[data-theme="dark"] .dm-time-picker__helper {
|
|
259
|
+
color: var(--dm-text-secondary);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* Responsive adjustments */
|
|
263
|
+
@media (max-width: 640px) {
|
|
264
|
+
.dm-time-picker__input {
|
|
265
|
+
@apply text-base; /* Prevent zoom on iOS */
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* High contrast mode support */
|
|
270
|
+
@media (prefers-contrast: high) {
|
|
271
|
+
.dm-time-picker__input {
|
|
272
|
+
@apply border-2;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.dm-time-picker__input:focus {
|
|
276
|
+
@apply border-4;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/* Reduced motion support */
|
|
281
|
+
@media (prefers-reduced-motion: reduce) {
|
|
282
|
+
.dm-time-picker__input {
|
|
283
|
+
@apply transition-none;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
</style>
|
|
@@ -1,163 +1,176 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Teleport to="body">
|
|
3
|
-
<Transition name="dm-toast">
|
|
4
|
-
<div
|
|
5
|
-
v-if="isVisible"
|
|
6
|
-
class="dm-toast"
|
|
7
|
-
:class="`dm-toast--${variant}`"
|
|
8
|
-
role="alert"
|
|
9
|
-
:aria-live="variant === 'error' ? 'assertive' : 'polite'"
|
|
10
|
-
>
|
|
11
|
-
<div class="dm-toast__content">
|
|
12
|
-
<span class="dm-toast__message">{{ message }}</span>
|
|
13
|
-
<button
|
|
14
|
-
v-if="closable"
|
|
15
|
-
class="dm-toast__close"
|
|
16
|
-
@click="close"
|
|
17
|
-
aria-label="Fechar"
|
|
18
|
-
>×</button>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</Transition>
|
|
22
|
-
</Teleport>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script setup lang="ts">
|
|
26
|
-
import { ref, watch, onMounted } from 'vue'
|
|
27
|
-
|
|
28
|
-
interface Props {
|
|
29
|
-
message: string
|
|
30
|
-
variant?: 'success' | 'error' | 'warning' | 'info'
|
|
31
|
-
duration?: number
|
|
32
|
-
closable?: boolean
|
|
33
|
-
modelValue?: boolean
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
37
|
-
variant: 'info',
|
|
38
|
-
duration: 3000,
|
|
39
|
-
closable: true,
|
|
40
|
-
modelValue: false
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.dm-toast__close
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<Teleport to="body">
|
|
3
|
+
<Transition name="dm-toast">
|
|
4
|
+
<div
|
|
5
|
+
v-if="isVisible"
|
|
6
|
+
class="dm-toast"
|
|
7
|
+
:class="`dm-toast--${variant}`"
|
|
8
|
+
role="alert"
|
|
9
|
+
:aria-live="variant === 'error' ? 'assertive' : 'polite'"
|
|
10
|
+
>
|
|
11
|
+
<div class="dm-toast__content">
|
|
12
|
+
<span class="dm-toast__message">{{ message }}</span>
|
|
13
|
+
<button
|
|
14
|
+
v-if="closable"
|
|
15
|
+
class="dm-toast__close"
|
|
16
|
+
@click="close"
|
|
17
|
+
aria-label="Fechar"
|
|
18
|
+
>×</button>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</Transition>
|
|
22
|
+
</Teleport>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { ref, watch, onMounted } from 'vue'
|
|
27
|
+
|
|
28
|
+
interface Props {
|
|
29
|
+
message: string
|
|
30
|
+
variant?: 'success' | 'error' | 'warning' | 'info' | 'primary'
|
|
31
|
+
duration?: number
|
|
32
|
+
closable?: boolean
|
|
33
|
+
modelValue?: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
37
|
+
variant: 'info',
|
|
38
|
+
duration: 3000,
|
|
39
|
+
closable: true,
|
|
40
|
+
modelValue: false
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// Validação em desenvolvimento
|
|
44
|
+
if (process.env.NODE_ENV === 'development') {
|
|
45
|
+
const validVariants = ['success', 'error', 'warning', 'info', 'primary']
|
|
46
|
+
if (!validVariants.includes(props.variant)) {
|
|
47
|
+
console.warn(`[DatametriaToast] Invalid variant "${props.variant}". Valid options: ${validVariants.join(', ')}`)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const emit = defineEmits<{
|
|
52
|
+
'update:modelValue': [value: boolean]
|
|
53
|
+
close: []
|
|
54
|
+
}>()
|
|
55
|
+
|
|
56
|
+
const isVisible = ref(props.modelValue)
|
|
57
|
+
let timer: ReturnType<typeof setTimeout> | null = null
|
|
58
|
+
|
|
59
|
+
watch(() => props.modelValue, (newValue) => {
|
|
60
|
+
isVisible.value = newValue
|
|
61
|
+
if (newValue && props.duration > 0) {
|
|
62
|
+
startTimer()
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const startTimer = () => {
|
|
67
|
+
if (timer) clearTimeout(timer)
|
|
68
|
+
timer = setTimeout(() => {
|
|
69
|
+
close()
|
|
70
|
+
}, props.duration)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const close = () => {
|
|
74
|
+
isVisible.value = false
|
|
75
|
+
emit('update:modelValue', false)
|
|
76
|
+
emit('close')
|
|
77
|
+
if (timer) clearTimeout(timer)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onMounted(() => {
|
|
81
|
+
if (isVisible.value && props.duration > 0) {
|
|
82
|
+
startTimer()
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<style scoped>
|
|
88
|
+
.dm-toast {
|
|
89
|
+
position: fixed;
|
|
90
|
+
top: var(--dm-space-4);
|
|
91
|
+
right: var(--dm-space-4);
|
|
92
|
+
min-width: 300px;
|
|
93
|
+
max-width: 500px;
|
|
94
|
+
padding: var(--dm-space-4);
|
|
95
|
+
border-radius: var(--dm-radius);
|
|
96
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
97
|
+
z-index: 9999;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.dm-toast--success {
|
|
101
|
+
background: var(--dm-success);
|
|
102
|
+
color: var(--dm-white);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.dm-toast--error {
|
|
106
|
+
background: var(--dm-error);
|
|
107
|
+
color: var(--dm-white);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.dm-toast--warning {
|
|
111
|
+
background: var(--dm-warning);
|
|
112
|
+
color: var(--dm-gray-900);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.dm-toast--primary {
|
|
116
|
+
background: var(--dm-primary);
|
|
117
|
+
color: var(--dm-white);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.dm-toast--info {
|
|
121
|
+
background: var(--dm-gray-600);
|
|
122
|
+
color: var(--dm-white);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.dm-toast__content {
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: var(--dm-space-3);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.dm-toast__message {
|
|
132
|
+
flex: 1;
|
|
133
|
+
font-size: var(--dm-text-sm);
|
|
134
|
+
line-height: 1.5;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.dm-toast__close {
|
|
138
|
+
width: 24px;
|
|
139
|
+
height: 24px;
|
|
140
|
+
border: none;
|
|
141
|
+
background: transparent;
|
|
142
|
+
color: inherit;
|
|
143
|
+
font-size: 24px;
|
|
144
|
+
line-height: 1;
|
|
145
|
+
cursor: pointer;
|
|
146
|
+
opacity: 0.8;
|
|
147
|
+
transition: var(--dm-transition);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.dm-toast__close:hover {
|
|
151
|
+
opacity: 1;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.dm-toast-enter-active,
|
|
155
|
+
.dm-toast-leave-active {
|
|
156
|
+
transition: all 0.3s ease;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.dm-toast-enter-from {
|
|
160
|
+
opacity: 0;
|
|
161
|
+
transform: translateX(100%);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.dm-toast-leave-to {
|
|
165
|
+
opacity: 0;
|
|
166
|
+
transform: translateY(-20px);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@media (max-width: 640px) {
|
|
170
|
+
.dm-toast {
|
|
171
|
+
left: var(--dm-space-4);
|
|
172
|
+
right: var(--dm-space-4);
|
|
173
|
+
min-width: auto;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
</style>
|