@weni/unnnic-system 3.3.3 → 3.4.1-alpha.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/CHANGELOG.md +35 -1
- package/dist/components/Accordion/Accordion.vue.d.ts +1 -1
- package/dist/components/Alert/Alert.vue.d.ts +18 -119
- package/dist/components/Alert/Alert.vue.d.ts.map +1 -1
- package/dist/components/Alert/Version1dot1.vue.d.ts +2 -38
- package/dist/components/Alert/Version1dot1.vue.d.ts.map +1 -1
- package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +2 -2
- package/dist/components/AudioRecorder/AudioPlayer.vue.d.ts +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +5 -5
- package/dist/components/AvatarIcon/AvatarIcon.vue.d.ts +2 -2
- package/dist/components/Banner/Banner.vue.d.ts +1 -1
- package/dist/components/Banner/InfoBanner.vue.d.ts +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +1 -1
- package/dist/components/Button/Button.vue.d.ts +2 -2
- package/dist/components/Button/Button.vue.d.ts.map +1 -1
- package/dist/components/Button/ButtonIcon.vue.d.ts +1 -1
- package/dist/components/Button/types.d.ts +1 -1
- package/dist/components/Button/types.d.ts.map +1 -1
- package/dist/components/Card/AccountCard.vue.d.ts +3 -3
- package/dist/components/Card/BlankCard.vue.d.ts +1 -1
- package/dist/components/Card/Card.vue.d.ts +21 -21
- package/dist/components/Card/CardCompany.vue.d.ts +8 -8
- package/dist/components/Card/CardData.vue.d.ts +1 -1
- package/dist/components/Card/CardStatusesContainer.vue.d.ts +4 -4
- package/dist/components/Card/ContentCard.vue.d.ts +2 -2
- package/dist/components/Card/DashCard.vue.d.ts +4 -4
- package/dist/components/Card/DefaultCard.vue.d.ts +1 -1
- package/dist/components/Card/MarketplaceCard.vue.d.ts +2 -2
- package/dist/components/Card/SimpleCard.vue.d.ts +3 -3
- package/dist/components/Card/StatusCard.vue.d.ts +2 -2
- package/dist/components/Card/TitleCard.vue.d.ts +2 -2
- package/dist/components/CardImage/CardImage.vue.d.ts +8 -8
- package/dist/components/CardInformation/CardInformation.vue.d.ts +4 -4
- package/dist/components/CardProject/CardProject.vue.d.ts +3 -3
- package/dist/components/Carousel/Carousel.vue.d.ts +11 -11
- package/dist/components/Carousel/TagCarousel.vue.d.ts +9 -9
- package/dist/components/ChartBar/ChartBar.vue.d.ts +8 -8
- package/dist/components/ChartLine/ChartLine.vue.d.ts +1 -1
- package/dist/components/ChatText/ChatText.vue.d.ts +2 -2
- package/dist/components/ChatsContact/ChatsContact.vue.d.ts +15 -15
- package/dist/components/ChatsDashboardTagLive/ChatsDashboardTagLive.vue.d.ts +1 -1
- package/dist/components/ChatsHeader/ChatsHeader.vue.d.ts +1 -1
- package/dist/components/ChatsHeader/ChatsHeader.vue.d.ts.map +1 -1
- package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +5 -5
- package/dist/components/ChatsMessage/ChatsMessageStatusBackdrop.vue.d.ts +2 -2
- package/dist/components/ChatsNavbar/ChatsNavbar.vue.d.ts +1 -1
- package/dist/components/ChatsUserAvatar/ChatsUserAvatar.vue.d.ts +2 -2
- package/dist/components/Checkbox/Checkbox.vue.d.ts +3 -3
- package/dist/components/Comment/Comment.vue.d.ts +1 -1
- package/dist/components/DataArea/DataArea.vue.d.ts +2 -2
- package/dist/components/DataTable/index.vue.d.ts +1 -1
- package/dist/components/DataTable/index.vue.d.ts.map +1 -1
- package/dist/components/DateFilter/DateFilter.vue.d.ts +176 -29
- package/dist/components/DatePicker/DatePicker.vue.d.ts +8 -8
- package/dist/components/Drawer/Drawer.vue.d.ts +7 -7
- package/dist/components/Dropdown/Dropdown.vue.d.ts +1 -1
- package/dist/components/Dropdown/LanguageSelect.vue.d.ts +3 -3
- package/dist/components/Flag.vue.d.ts +2 -2
- package/dist/components/FormElement/FormElement.vue.d.ts +38 -32
- package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
- package/dist/components/Icon.vue.d.ts +1 -1
- package/dist/components/IconLoading/IconLoading.vue.d.ts +1 -1
- package/dist/components/ImportCard/ImportCard.vue.d.ts +7 -7
- package/dist/components/Input/BaseInput.vue.d.ts +32 -1
- package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/Input/Input.vue.d.ts +176 -29
- package/dist/components/Input/Input.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts +83 -14
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +186 -39
- package/dist/components/InputNext/InputNext.vue.d.ts +4 -4
- package/dist/components/Label/Label.vue.d.ts +9 -15
- package/dist/components/Label/Label.vue.d.ts.map +1 -1
- package/dist/components/Modal/Modal.vue.d.ts +2 -2
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts +9 -9
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
- package/dist/components/ModalNext/ModalNext.vue.d.ts +184 -37
- package/dist/components/ModalUpload/ModalUpload.vue.d.ts +14 -14
- package/dist/components/MoodRating/MoodRating.vue.d.ts +1 -1
- package/dist/components/MultiSelect/MultiSelect.vue.d.ts +20 -14
- package/dist/components/Pagination/Pagination.vue.d.ts +6 -6
- package/dist/components/ProgressBar/ProgressBar.vue.d.ts +1 -1
- package/dist/components/Radio/Radio.vue.d.ts +8 -6
- package/dist/components/Radio/Radio.vue.d.ts.map +1 -1
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +97 -28
- package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +8 -8
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +4 -4
- package/dist/components/SelectTime/index.vue.d.ts +83 -14
- package/dist/components/SkeletonLoading/skeletonTheme.vue.d.ts +1 -1
- package/dist/components/Slider/Slider.vue.d.ts +2 -2
- package/dist/components/StarRating/StarRating.vue.d.ts +1 -1
- package/dist/components/Switch/Switch.vue.d.ts +24 -25
- package/dist/components/Switch/Switch.vue.d.ts.map +1 -1
- package/dist/components/Tab/Tab.vue.d.ts +13 -2
- package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
- package/dist/components/TableNext/TablePagination.vue.d.ts +6 -6
- package/dist/components/TabsExpanded/TabsExpanded.vue.d.ts +1 -1
- package/dist/components/Tag/BrandTag.vue.d.ts +2 -2
- package/dist/components/Tag/DefaultTag.vue.d.ts +2 -2
- package/dist/components/Tag/IndicatorTag.vue.d.ts +2 -2
- package/dist/components/Tag/Tag.vue.d.ts +8 -8
- package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts +9 -0
- package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts.map +1 -0
- package/dist/components/TemplatePreview/TemplatePreviewModal.vue.d.ts +15 -0
- package/dist/components/TemplatePreview/TemplatePreviewModal.vue.d.ts.map +1 -0
- package/dist/components/TextArea/TextArea.vue.d.ts +38 -32
- package/dist/components/TextArea/TextArea.vue.d.ts.map +1 -1
- package/dist/components/Toast/Toast.vue.d.ts +16 -0
- package/dist/components/Toast/Toast.vue.d.ts.map +1 -0
- package/dist/components/Toast/ToastManager.d.ts +14 -0
- package/dist/components/Toast/ToastManager.d.ts.map +1 -0
- package/dist/components/Toast/types.d.ts +35 -0
- package/dist/components/Toast/types.d.ts.map +1 -0
- package/dist/components/ToolTip/ToolTip.vue.d.ts +1 -1
- package/dist/components/Tour/Tour.vue.d.ts +6 -6
- package/dist/components/Tour/TourPopover.vue.d.ts +6 -6
- package/dist/components/UploadArea/UploadArea.vue.d.ts +7 -7
- package/dist/components/index.d.ts +2402 -1146
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/ui/popover/Popover.vue.d.ts +23 -0
- package/dist/components/ui/popover/Popover.vue.d.ts.map +1 -0
- package/dist/components/ui/popover/PopoverContent.vue.d.ts +43 -0
- package/dist/components/ui/popover/PopoverContent.vue.d.ts.map +1 -0
- package/dist/components/ui/popover/PopoverTrigger.vue.d.ts +19 -0
- package/dist/components/ui/popover/PopoverTrigger.vue.d.ts.map +1 -0
- package/dist/components/ui/popover/index.d.ts +5 -0
- package/dist/components/ui/popover/index.d.ts.map +1 -0
- package/dist/{es-54ddaf5a.mjs → es-479daf92.mjs} +1 -1
- package/dist/{index-a34da30f.mjs → index-a8aa7094.mjs} +18284 -11956
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/locales/en.json.d.ts +2 -1
- package/dist/locales/es.json.d.ts +2 -1
- package/dist/locales/pt_br.json.d.ts +2 -1
- package/dist/main.d.ts +0 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/{pt-br-ff00f945.mjs → pt-br-32c84cc8.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +141 -129
- package/dist/unnnic.umd.js +53 -50
- package/dist/utils/call.d.ts +2 -1
- package/dist/utils/call.d.ts.map +1 -1
- package/package.json +14 -2
- package/src/assets/icons/radio-checked.svg +3 -0
- package/src/assets/icons/switch-checked-disabled.svg +3 -0
- package/src/assets/icons/switch-checked.svg +3 -0
- package/src/assets/img/previews/doc-preview.png +0 -0
- package/src/assets/img/previews/image-preview.png +0 -0
- package/src/assets/img/previews/video-preview.png +0 -0
- package/src/assets/scss/colors-hsl.scss +119 -0
- package/src/assets/scss/scheme-colors.scss +115 -238
- package/src/assets/scss/tailwind.scss +96 -0
- package/src/components/Alert/Alert.vue +26 -135
- package/src/components/Alert/Version1dot1.vue +0 -36
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +11 -7
- package/src/components/Alert/__tests__/__snapshots__/Version1dot1.spec.js.snap +2 -2
- package/src/components/Button/Button.vue +60 -108
- package/src/components/Button/types.ts +0 -1
- package/src/components/FormElement/FormElement.vue +51 -91
- package/src/components/Input/BaseInput.vue +31 -14
- package/src/components/Input/Input.scss +19 -21
- package/src/components/Input/Input.vue +94 -30
- package/src/components/Input/TextInput.vue +82 -58
- package/src/components/Input/__test__/TextInput.spec.js +5 -5
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +16 -3
- package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +7 -1
- package/src/components/Label/Label.vue +52 -21
- package/src/components/Label/__tests__/Label.spec.js +1 -1
- package/src/components/Label/__tests__/__snapshots__/Label.spec.js.snap +1 -1
- package/src/components/ModalDialog/ModalDialog.vue +1 -0
- package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +1 -1
- package/src/components/Popover/__tests__/Popover.spec.js +147 -0
- package/src/components/Popover/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
- package/src/components/Popover/index.vue +146 -0
- package/src/components/Radio/Radio.vue +80 -67
- package/src/components/Radio/__test__/Radio.spec.js +14 -20
- package/src/components/Radio/__test__/__snapshots__/Radio.spec.js.snap +3 -3
- package/src/components/RadioGroup/RadioGroup.vue +110 -0
- package/src/components/Select/SelectOption.vue +65 -0
- package/src/components/Select/__tests__/Select.spec.js +412 -0
- package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
- package/src/components/Select/__tests__/SelectOption.spec.js +174 -0
- package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +97 -0
- package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +15 -0
- package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +25 -0
- package/src/components/Select/index.vue +245 -0
- package/src/components/Switch/Switch.vue +91 -99
- package/src/components/Switch/__tests__/Switch.spec.js +8 -74
- package/src/components/Switch/__tests__/__snapshots__/Switch.spec.js.snap +3 -5
- package/src/components/Tab/Tab.vue +37 -23
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -1
- package/src/components/TableNext/__test__/__snapshots__/TableNext.spec.js.snap +2 -2
- package/src/components/TableNext/__test__/__snapshots__/TablePagination.spec.js.snap +2 -2
- package/src/components/TemplatePreview/TemplatePreview.vue +252 -0
- package/src/components/TemplatePreview/TemplatePreviewModal.vue +51 -0
- package/src/components/TemplatePreview/types.d.ts +16 -0
- package/src/components/TextArea/TextArea.vue +13 -9
- package/src/components/TextArea/__test__/__snapshots__/TextArea.spec.js.snap +7 -2
- package/src/components/Toast/Toast.vue +236 -0
- package/src/components/Toast/ToastManager.ts +110 -0
- package/src/components/Toast/types.ts +57 -0
- package/src/components/index.ts +30 -4
- package/src/components/ui/popover/Popover.vue +15 -0
- package/src/components/ui/popover/PopoverContent.vue +98 -0
- package/src/components/ui/popover/PopoverTrigger.vue +12 -0
- package/src/components/ui/popover/index.ts +4 -0
- package/src/index.ts +1 -0
- package/src/lib/utils.ts +7 -0
- package/src/locales/en.json +2 -1
- package/src/locales/es.json +2 -1
- package/src/locales/pt_br.json +2 -1
- package/src/main.ts +1 -0
- package/src/stories/Alert.stories.js +6 -67
- package/src/stories/Button.stories.js +2 -17
- package/src/stories/Input.stories.js +22 -3
- package/src/stories/Label.stories.js +7 -0
- package/src/stories/Popover.stories.js +306 -0
- package/src/stories/RadioGroup.stories.js +139 -0
- package/src/stories/Select.stories.js +158 -0
- package/src/stories/Switch.stories.js +4 -5
- package/src/stories/Tab.stories.js +11 -4
- package/src/stories/TemplatePreview.stories.js +94 -0
- package/src/stories/TemplatePreviewModal.stories.js +110 -0
- package/src/stories/Toast.mdx +123 -0
- package/src/stories/Toast.stories.js +126 -0
- package/src/types/scheme-colors.d.ts +1 -0
- package/src/utils/call.js +46 -18
- package/src/components/Alert/AlertBanner.vue +0 -182
- package/src/components/Alert/AlertCaller.vue +0 -49
- package/src/components/Alert/__tests__/AlertBanner.spec.js +0 -89
- package/src/components/Alert/__tests__/AlertCaller.spec.js +0 -98
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Transition
|
|
3
|
+
name="toast-slide"
|
|
4
|
+
appear
|
|
5
|
+
@after-leave="$emit('destroy')"
|
|
6
|
+
>
|
|
7
|
+
<aside
|
|
8
|
+
v-if="isVisible"
|
|
9
|
+
:class="['unnnic-toast', `unnnic-toast--${type}`]"
|
|
10
|
+
:role="type === 'error' ? 'alert' : 'status'"
|
|
11
|
+
:aria-live="type === 'error' ? 'assertive' : 'polite'"
|
|
12
|
+
data-testid="unnnic-toast"
|
|
13
|
+
>
|
|
14
|
+
<section class="unnnic-toast__content">
|
|
15
|
+
<header class="unnnic-toast__header">
|
|
16
|
+
<UnnnicIcon
|
|
17
|
+
:icon="typeConfig.icon"
|
|
18
|
+
:scheme="typeConfig.scheme"
|
|
19
|
+
size="ant"
|
|
20
|
+
data-testid="toast-type-icon"
|
|
21
|
+
/>
|
|
22
|
+
|
|
23
|
+
<h3 class="unnnic-toast__title">
|
|
24
|
+
{{ title }}
|
|
25
|
+
</h3>
|
|
26
|
+
|
|
27
|
+
<UnnnicIcon
|
|
28
|
+
icon="close"
|
|
29
|
+
scheme="neutral-dark"
|
|
30
|
+
size="ant"
|
|
31
|
+
clickable
|
|
32
|
+
class="unnnic-toast__close"
|
|
33
|
+
data-testid="toast-close-button"
|
|
34
|
+
@click="handleClose"
|
|
35
|
+
@keydown.enter="handleClose"
|
|
36
|
+
@keydown.space.prevent="handleClose"
|
|
37
|
+
/>
|
|
38
|
+
</header>
|
|
39
|
+
|
|
40
|
+
<p
|
|
41
|
+
v-if="description"
|
|
42
|
+
class="unnnic-toast__text"
|
|
43
|
+
>
|
|
44
|
+
{{ description }}
|
|
45
|
+
</p>
|
|
46
|
+
</section>
|
|
47
|
+
|
|
48
|
+
<UnnnicButton
|
|
49
|
+
v-if="button"
|
|
50
|
+
type="tertiary"
|
|
51
|
+
:text="button.text"
|
|
52
|
+
class="unnnic-toast__action-button"
|
|
53
|
+
data-testid="toast-action-button"
|
|
54
|
+
@click="handleAction"
|
|
55
|
+
@keydown.enter="handleAction"
|
|
56
|
+
@keydown.space.prevent="handleAction"
|
|
57
|
+
/>
|
|
58
|
+
</aside>
|
|
59
|
+
</Transition>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { ref, computed, onMounted, onUnmounted } from 'vue';
|
|
64
|
+
|
|
65
|
+
import UnnnicIcon from '@/components/Icon.vue';
|
|
66
|
+
import UnnnicButton from '@/components/Button/Button.vue';
|
|
67
|
+
|
|
68
|
+
import type { ToastProps, ToastEmits } from './types';
|
|
69
|
+
import type { SchemeColor } from '@/types/scheme-colors';
|
|
70
|
+
|
|
71
|
+
defineOptions({
|
|
72
|
+
name: 'UnnnicToast',
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const props = withDefaults(defineProps<ToastProps>(), {
|
|
76
|
+
title: '',
|
|
77
|
+
description: '',
|
|
78
|
+
button: undefined,
|
|
79
|
+
timeout: 5000,
|
|
80
|
+
type: 'informational',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const emit = defineEmits<ToastEmits>();
|
|
84
|
+
|
|
85
|
+
const isVisible = ref(false);
|
|
86
|
+
let timeoutId: number | null = null;
|
|
87
|
+
|
|
88
|
+
const typeConfig = computed(() => {
|
|
89
|
+
const configMap = {
|
|
90
|
+
informational: { icon: 'info', scheme: 'blue-500' },
|
|
91
|
+
attention: { icon: 'error', scheme: 'yellow-500' },
|
|
92
|
+
success: { icon: 'check_circle', scheme: 'green-500' },
|
|
93
|
+
error: { icon: 'cancel', scheme: 'red-500' },
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return configMap[props.type || 'informational'] as {
|
|
97
|
+
icon: string;
|
|
98
|
+
scheme: SchemeColor;
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const handleClose = () => {
|
|
103
|
+
isVisible.value = false;
|
|
104
|
+
emit('close');
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const handleAction = () => {
|
|
108
|
+
if (props.button?.action) {
|
|
109
|
+
props.button.action();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const startTimeout = () => {
|
|
114
|
+
if (props.timeout > 0) {
|
|
115
|
+
timeoutId = window.setTimeout(() => {
|
|
116
|
+
handleClose();
|
|
117
|
+
}, props.timeout);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const clearTimeout = () => {
|
|
122
|
+
if (timeoutId) {
|
|
123
|
+
window.clearTimeout(timeoutId);
|
|
124
|
+
timeoutId = null;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
onMounted(() => {
|
|
129
|
+
isVisible.value = true;
|
|
130
|
+
startTimeout();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
onUnmounted(() => {
|
|
134
|
+
clearTimeout();
|
|
135
|
+
});
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<style lang="scss" scoped>
|
|
139
|
+
@use '@/assets/scss/unnnic' as *;
|
|
140
|
+
|
|
141
|
+
.unnnic-toast {
|
|
142
|
+
position: fixed;
|
|
143
|
+
bottom: $unnnic-space-4;
|
|
144
|
+
right: $unnnic-space-4;
|
|
145
|
+
z-index: 9999;
|
|
146
|
+
|
|
147
|
+
display: flex;
|
|
148
|
+
align-items: flex-end;
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
gap: $unnnic-space-5;
|
|
151
|
+
|
|
152
|
+
min-width: 250px;
|
|
153
|
+
max-width: 450px;
|
|
154
|
+
padding: $unnnic-space-4;
|
|
155
|
+
|
|
156
|
+
border-radius: $unnnic-radius-2;
|
|
157
|
+
box-shadow: $unnnic-shadow-2;
|
|
158
|
+
border: 1px solid $unnnic-color-border-base;
|
|
159
|
+
|
|
160
|
+
&--informational {
|
|
161
|
+
border-color: $unnnic-color-border-info;
|
|
162
|
+
background-color: $unnnic-color-bg-info;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&--attention {
|
|
166
|
+
border-color: $unnnic-color-border-warning;
|
|
167
|
+
background-color: $unnnic-color-bg-warning;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
&--success {
|
|
171
|
+
border-color: $unnnic-color-border-success;
|
|
172
|
+
background-color: $unnnic-color-bg-success;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
&--error {
|
|
176
|
+
border-color: $unnnic-color-border-critical;
|
|
177
|
+
background-color: $unnnic-color-bg-critical;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&__content,
|
|
181
|
+
&__header {
|
|
182
|
+
width: 100%;
|
|
183
|
+
|
|
184
|
+
display: flex;
|
|
185
|
+
gap: $unnnic-space-2;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&__content {
|
|
189
|
+
flex-direction: column;
|
|
190
|
+
gap: $unnnic-space-2;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&__header {
|
|
194
|
+
align-items: center;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
&__title {
|
|
198
|
+
flex: 1;
|
|
199
|
+
|
|
200
|
+
margin: 0;
|
|
201
|
+
|
|
202
|
+
font: $unnnic-font-action;
|
|
203
|
+
color: $unnnic-color-fg-emphasized;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&__text {
|
|
207
|
+
margin: 0;
|
|
208
|
+
margin-left: $unnnic-space-7;
|
|
209
|
+
|
|
210
|
+
font: $unnnic-font-caption-2;
|
|
211
|
+
color: $unnnic-color-fg-emphasized;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Animations
|
|
216
|
+
.toast-slide-enter-active,
|
|
217
|
+
.toast-slide-leave-active {
|
|
218
|
+
transition: all 0.3s ease;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.toast-slide-enter-from {
|
|
222
|
+
transform: translateY(100%);
|
|
223
|
+
opacity: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.toast-slide-leave-to {
|
|
227
|
+
transform: translateY(100%);
|
|
228
|
+
opacity: 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.toast-slide-enter-to,
|
|
232
|
+
.toast-slide-leave-from {
|
|
233
|
+
transform: translateY(0);
|
|
234
|
+
opacity: 1;
|
|
235
|
+
}
|
|
236
|
+
</style>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createApp } from 'vue';
|
|
2
|
+
import Toast from './Toast.vue';
|
|
3
|
+
import type {
|
|
4
|
+
ToastProps,
|
|
5
|
+
ToastInstance,
|
|
6
|
+
ToastOptions,
|
|
7
|
+
ToastCall,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
class ToastManager implements ToastManager {
|
|
11
|
+
private toasts: Map<string, ToastInstance> = new Map();
|
|
12
|
+
private container: HTMLElement | null = null;
|
|
13
|
+
private nextId = 0;
|
|
14
|
+
|
|
15
|
+
private createContainer(): HTMLElement {
|
|
16
|
+
if (this.container) {
|
|
17
|
+
return this.container;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.container = document.createElement('div');
|
|
21
|
+
this.container.setAttribute('unnnic-toast-container', 'true');
|
|
22
|
+
|
|
23
|
+
document.body.appendChild(this.container);
|
|
24
|
+
return this.container;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private generateId(): string {
|
|
28
|
+
return `toast-${++this.nextId}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
show(props: ToastProps): ToastInstance {
|
|
32
|
+
const id = this.generateId();
|
|
33
|
+
const container = this.createContainer();
|
|
34
|
+
|
|
35
|
+
const toastWrapper = document.createElement('div');
|
|
36
|
+
|
|
37
|
+
// Create promise that resolves when toast is destroyed
|
|
38
|
+
let resolvePromise: () => void;
|
|
39
|
+
const promise = new Promise<void>((resolve) => {
|
|
40
|
+
resolvePromise = resolve;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const app = createApp(Toast, {
|
|
44
|
+
...props,
|
|
45
|
+
onClose: () => {
|
|
46
|
+
this.close(id);
|
|
47
|
+
},
|
|
48
|
+
onDestroy: () => {
|
|
49
|
+
app.unmount();
|
|
50
|
+
toastWrapper.remove();
|
|
51
|
+
resolvePromise(); // Resolve the promise when toast is destroyed
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
app.mount(toastWrapper);
|
|
56
|
+
container.appendChild(toastWrapper);
|
|
57
|
+
|
|
58
|
+
const toastInstance: ToastInstance = {
|
|
59
|
+
id,
|
|
60
|
+
props,
|
|
61
|
+
close: () => this.close(id),
|
|
62
|
+
promise,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
this.toasts.set(id, toastInstance);
|
|
66
|
+
return toastInstance;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
close(id: string): void {
|
|
70
|
+
const toast = this.toasts.get(id);
|
|
71
|
+
if (toast) {
|
|
72
|
+
this.toasts.delete(id);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const toastManager = new ToastManager();
|
|
78
|
+
|
|
79
|
+
export const toast: ToastCall = {
|
|
80
|
+
info: (title: string, description?: string, options?: ToastOptions) =>
|
|
81
|
+
toastManager.show({
|
|
82
|
+
title,
|
|
83
|
+
description,
|
|
84
|
+
...options,
|
|
85
|
+
type: 'informational',
|
|
86
|
+
}).promise,
|
|
87
|
+
success: (title: string, description?: string, options?: ToastOptions) =>
|
|
88
|
+
toastManager.show({
|
|
89
|
+
title,
|
|
90
|
+
description,
|
|
91
|
+
...options,
|
|
92
|
+
type: 'success',
|
|
93
|
+
}).promise,
|
|
94
|
+
attention: (title: string, description?: string, options?: ToastOptions) =>
|
|
95
|
+
toastManager.show({
|
|
96
|
+
title,
|
|
97
|
+
description,
|
|
98
|
+
...options,
|
|
99
|
+
type: 'attention',
|
|
100
|
+
}).promise,
|
|
101
|
+
error: (title: string, description?: string, options?: ToastOptions) =>
|
|
102
|
+
toastManager.show({
|
|
103
|
+
title,
|
|
104
|
+
description,
|
|
105
|
+
...options,
|
|
106
|
+
type: 'error',
|
|
107
|
+
}).promise,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default toastManager;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface ToastManager {
|
|
2
|
+
show: (props: ToastProps) => ToastInstance;
|
|
3
|
+
close: (id: string) => void;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ToastButton {
|
|
7
|
+
text: string;
|
|
8
|
+
action: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type ToastType = 'informational' | 'attention' | 'success' | 'error';
|
|
12
|
+
|
|
13
|
+
export interface ToastProps extends ToastOptions {
|
|
14
|
+
title: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ToastOptions {
|
|
19
|
+
type?: ToastType;
|
|
20
|
+
button?: ToastButton;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ToastEmits {
|
|
25
|
+
close: [];
|
|
26
|
+
destroy: [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ToastInstance {
|
|
30
|
+
id: string;
|
|
31
|
+
props: ToastProps;
|
|
32
|
+
close: () => void;
|
|
33
|
+
promise: Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ToastCall {
|
|
37
|
+
info: (
|
|
38
|
+
title: string,
|
|
39
|
+
description?: string,
|
|
40
|
+
options?: ToastOptions,
|
|
41
|
+
) => Promise<void>;
|
|
42
|
+
success: (
|
|
43
|
+
title: string,
|
|
44
|
+
description?: string,
|
|
45
|
+
options?: ToastOptions,
|
|
46
|
+
) => Promise<void>;
|
|
47
|
+
attention: (
|
|
48
|
+
title: string,
|
|
49
|
+
description?: string,
|
|
50
|
+
options?: ToastOptions,
|
|
51
|
+
) => Promise<void>;
|
|
52
|
+
error: (
|
|
53
|
+
title: string,
|
|
54
|
+
description?: string,
|
|
55
|
+
options?: ToastOptions,
|
|
56
|
+
) => Promise<void>;
|
|
57
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -88,8 +88,15 @@ import ModalDialog from './ModalDialog/ModalDialog.vue';
|
|
|
88
88
|
import Tour from './Tour/Tour.vue';
|
|
89
89
|
import Navigator from './Navigator/index.vue';
|
|
90
90
|
import SelectTime from './SelectTime/index.vue';
|
|
91
|
+
import TemplatePreview from './TemplatePreview/TemplatePreview.vue';
|
|
92
|
+
import TemplatePreviewModal from './TemplatePreview/TemplatePreviewModal.vue';
|
|
91
93
|
import DataTable from './DataTable/index.vue';
|
|
92
94
|
import Chip from './Chip/Chip.vue';
|
|
95
|
+
import Toast from './Toast/Toast.vue';
|
|
96
|
+
import { toast } from './Toast/ToastManager';
|
|
97
|
+
import Popover from './ui/popover/Popover.vue';
|
|
98
|
+
import PopoverContent from './ui/popover/PopoverContent.vue';
|
|
99
|
+
import PopoverTrigger from './ui/popover/PopoverTrigger.vue';
|
|
93
100
|
|
|
94
101
|
type VueComponent = Component;
|
|
95
102
|
|
|
@@ -188,8 +195,15 @@ export const components: ComponentsMap = {
|
|
|
188
195
|
unnnicTour: Tour,
|
|
189
196
|
unnnicNavigator: Navigator,
|
|
190
197
|
unnnicSelectTime: SelectTime,
|
|
198
|
+
unnnicTemplatePreview: TemplatePreview,
|
|
199
|
+
unnnicTemplatePreviewModal: TemplatePreviewModal,
|
|
191
200
|
unnnicDataTable: DataTable,
|
|
192
201
|
unnnicChip: Chip,
|
|
202
|
+
unnnicToast: Toast,
|
|
203
|
+
unnnicToastManager: toast,
|
|
204
|
+
unnnicPopover: Popover,
|
|
205
|
+
unnnicPopoverContent: PopoverContent,
|
|
206
|
+
unnnicPopoverTrigger: PopoverTrigger,
|
|
193
207
|
};
|
|
194
208
|
|
|
195
209
|
export const unnnicFontSize = fontSize;
|
|
@@ -241,7 +255,7 @@ export const unnnicAccordion = accordion;
|
|
|
241
255
|
export const unnnicIndicator = indicator;
|
|
242
256
|
export const unnnicSkeletonLoading = skeletonLoading;
|
|
243
257
|
export const unnnicCarousel = carousel;
|
|
244
|
-
export const unnnicLabel = label;
|
|
258
|
+
export const unnnicLabel = label as VueComponent;
|
|
245
259
|
export const unnnicTab = tab;
|
|
246
260
|
export const unnnicTabsExpanded = tabsExpanded;
|
|
247
261
|
export const unnnicBanner = banner;
|
|
@@ -282,9 +296,14 @@ export const unnnicDrawer = Drawer;
|
|
|
282
296
|
export const unnnicTableNext = TableNext;
|
|
283
297
|
export const unnnicTour = Tour;
|
|
284
298
|
export const unnnicNavigator = Navigator;
|
|
285
|
-
export const unnnicDataTable = DataTable as VueComponent;
|
|
286
299
|
export const unnnicSelectTime = SelectTime as VueComponent;
|
|
300
|
+
export const unnnicTemplatePreview = TemplatePreview as VueComponent;
|
|
301
|
+
export const unnnicTemplatePreviewModal = TemplatePreviewModal as VueComponent;
|
|
302
|
+
export const unnnicDataTable = DataTable as VueComponent;
|
|
287
303
|
export const unnnicChip = Chip;
|
|
304
|
+
export const unnnicPopover = Popover;
|
|
305
|
+
export const unnnicPopoverContent = PopoverContent;
|
|
306
|
+
export const unnnicPopoverTrigger = PopoverTrigger;
|
|
288
307
|
|
|
289
308
|
export const UnnnicFontSize = fontSize;
|
|
290
309
|
export const UnnnicFormElement = formElement;
|
|
@@ -335,7 +354,7 @@ export const UnnnicAccordion = accordion;
|
|
|
335
354
|
export const UnnnicIndicator = indicator;
|
|
336
355
|
export const UnnnicSkeletonLoading = skeletonLoading;
|
|
337
356
|
export const UnnnicCarousel = carousel;
|
|
338
|
-
export const UnnnicLabel = label;
|
|
357
|
+
export const UnnnicLabel = label as VueComponent;
|
|
339
358
|
export const UnnnicTab = tab;
|
|
340
359
|
export const UnnnicTabsExpanded = tabsExpanded;
|
|
341
360
|
export const UnnnicBanner = banner;
|
|
@@ -376,6 +395,13 @@ export const UnnnicDrawer = Drawer;
|
|
|
376
395
|
export const UnnnicTableNext = TableNext;
|
|
377
396
|
export const UnnnicTour = Tour;
|
|
378
397
|
export const UnnnicNavigator = Navigator;
|
|
379
|
-
export const UnnnicDataTable = DataTable as VueComponent;
|
|
380
398
|
export const UnnnicSelectTime = SelectTime as VueComponent;
|
|
399
|
+
export const UnnnicTemplatePreview = TemplatePreview as VueComponent;
|
|
400
|
+
export const UnnnicTemplatePreviewModal = TemplatePreviewModal as VueComponent;
|
|
401
|
+
export const UnnnicDataTable = DataTable as VueComponent;
|
|
381
402
|
export const UnnnicChip = Chip;
|
|
403
|
+
export const UnnnicToast = Toast;
|
|
404
|
+
export const UnnnicToastManager = toast;
|
|
405
|
+
export const UnnnicPopover = Popover;
|
|
406
|
+
export const UnnnicPopoverContent = PopoverContent;
|
|
407
|
+
export const UnnnicPopoverTrigger = PopoverTrigger;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PopoverRootEmits, PopoverRootProps } from 'reka-ui';
|
|
3
|
+
import { PopoverRoot, useForwardPropsEmits } from 'reka-ui';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<PopoverRootProps>();
|
|
6
|
+
const emits = defineEmits<PopoverRootEmits>();
|
|
7
|
+
|
|
8
|
+
const forwarded = useForwardPropsEmits(props, emits);
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<PopoverRoot v-bind="forwarded">
|
|
13
|
+
<slot />
|
|
14
|
+
</PopoverRoot>
|
|
15
|
+
</template>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PopoverPortal>
|
|
3
|
+
<PopoverContent
|
|
4
|
+
v-bind="{ ...forwarded, ...$attrs }"
|
|
5
|
+
:class="
|
|
6
|
+
cn(
|
|
7
|
+
'unnnic-popover',
|
|
8
|
+
`unnnic-popover--size-${props.size}`,
|
|
9
|
+
'bg-popover text-popover-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
|
10
|
+
)
|
|
11
|
+
"
|
|
12
|
+
>
|
|
13
|
+
<section :class="`unnnic-popover__content ${props.class || ''}`">
|
|
14
|
+
<slot />
|
|
15
|
+
</section>
|
|
16
|
+
|
|
17
|
+
<footer
|
|
18
|
+
v-if="$slots.footer"
|
|
19
|
+
class="unnnic-popover__footer"
|
|
20
|
+
>
|
|
21
|
+
<slot name="footer" />
|
|
22
|
+
</footer>
|
|
23
|
+
</PopoverContent>
|
|
24
|
+
</PopoverPortal>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import type { PopoverContentEmits, PopoverContentProps } from 'reka-ui';
|
|
29
|
+
import type { HTMLAttributes } from 'vue';
|
|
30
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
31
|
+
import { PopoverContent, PopoverPortal, useForwardPropsEmits } from 'reka-ui';
|
|
32
|
+
import { cn } from '@/lib/utils';
|
|
33
|
+
|
|
34
|
+
defineOptions({
|
|
35
|
+
inheritAttrs: false,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const props = withDefaults(
|
|
39
|
+
defineProps<
|
|
40
|
+
PopoverContentProps & {
|
|
41
|
+
class?: HTMLAttributes['class'];
|
|
42
|
+
size?: 'small' | 'medium' | 'large';
|
|
43
|
+
}
|
|
44
|
+
>(),
|
|
45
|
+
{
|
|
46
|
+
align: 'center',
|
|
47
|
+
sideOffset: 4,
|
|
48
|
+
size: 'medium',
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
const emits = defineEmits<PopoverContentEmits>();
|
|
52
|
+
|
|
53
|
+
const delegatedProps = reactiveOmit(props, 'class', 'size');
|
|
54
|
+
|
|
55
|
+
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<style lang="scss">
|
|
59
|
+
@use '@/assets/scss/unnnic' as *;
|
|
60
|
+
|
|
61
|
+
$popover-space: $unnnic-space-4;
|
|
62
|
+
|
|
63
|
+
.unnnic-popover {
|
|
64
|
+
z-index: 10000;
|
|
65
|
+
|
|
66
|
+
border-radius: $unnnic-radius-2;
|
|
67
|
+
box-shadow: $unnnic-shadow-1;
|
|
68
|
+
|
|
69
|
+
&--size-small {
|
|
70
|
+
width: 240px;
|
|
71
|
+
}
|
|
72
|
+
&--size-medium {
|
|
73
|
+
width: 320px;
|
|
74
|
+
}
|
|
75
|
+
&--size-large {
|
|
76
|
+
width: 400px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&__content {
|
|
80
|
+
padding: $popover-space;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&__footer {
|
|
84
|
+
border-top: 1px solid $unnnic-color-border-soft;
|
|
85
|
+
|
|
86
|
+
padding: $popover-space;
|
|
87
|
+
|
|
88
|
+
display: flex;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
align-items: center;
|
|
91
|
+
gap: $unnnic-space-2;
|
|
92
|
+
|
|
93
|
+
> * {
|
|
94
|
+
width: 100%;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PopoverTriggerProps } from 'reka-ui';
|
|
3
|
+
import { PopoverTrigger } from 'reka-ui';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<PopoverTriggerProps>();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<PopoverTrigger v-bind="props">
|
|
10
|
+
<slot />
|
|
11
|
+
</PopoverTrigger>
|
|
12
|
+
</template>
|
package/src/index.ts
CHANGED
package/src/lib/utils.ts
ADDED
package/src/locales/en.json
CHANGED
package/src/locales/es.json
CHANGED
package/src/locales/pt_br.json
CHANGED