@weni/unnnic-system 3.2.9 → 3.3.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 +13 -0
- 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/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue.d.ts.map +1 -1
- package/dist/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue.d.ts +43 -0
- package/dist/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue.d.ts.map +1 -0
- 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 +8 -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 +2 -2
- 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 +2136 -1114
- package/dist/components/index.d.ts.map +1 -1
- package/dist/{es-1ca6f2cf.mjs → es-94ab560e.mjs} +1 -1
- package/dist/{index-ca7d12b1.mjs → index-5caf403e.mjs} +8860 -8453
- 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/{pt-br-2d5000b1.mjs → pt-br-3002df05.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +126 -120
- package/dist/unnnic.umd.js +42 -41
- package/dist/utils/call.d.ts +2 -1
- package/dist/utils/call.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/assets/icons/radio-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/scheme-colors.scss +115 -111
- package/src/assets/tokens/colors.json +2 -2
- 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/ChartFunnel/ChartFunnel.vue +4 -0
- package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +8 -2
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelBaseRow.vue +1 -1
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +64 -0
- package/src/components/DataTable/index.vue +25 -10
- 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/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 +18 -4
- package/src/locales/en.json +2 -1
- package/src/locales/es.json +2 -1
- package/src/locales/pt_br.json +2 -1
- package/src/stories/Alert.stories.js +6 -67
- package/src/stories/Button.stories.js +2 -17
- package/src/stories/ChartFunnel.stories.js +19 -0
- package/src/stories/DataTable.stories.js +60 -0
- package/src/stories/Input.stories.js +22 -3
- package/src/stories/Label.stories.js +7 -0
- package/src/stories/Popover.stories.js +39 -0
- package/src/stories/RadioGroup.stories.js +139 -0
- package/src/stories/Select.stories.js +158 -0
- 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 +120 -14
- 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,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UnnnicModalDialog
|
|
3
|
+
:modelValue="modelValue"
|
|
4
|
+
:title="defaultTranslations.title[props.locale]"
|
|
5
|
+
:showCloseIcon="true"
|
|
6
|
+
class="unnnic-template-preview-modal"
|
|
7
|
+
@update:model-value="$event === false && $emit('close')"
|
|
8
|
+
>
|
|
9
|
+
<UnnnicTemplatePreview :template="template" />
|
|
10
|
+
</UnnnicModalDialog>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts" setup>
|
|
14
|
+
import UnnnicTemplatePreview from './TemplatePreview.vue';
|
|
15
|
+
import UnnnicModalDialog from '../ModalDialog/ModalDialog.vue';
|
|
16
|
+
|
|
17
|
+
import type { Template } from './types';
|
|
18
|
+
|
|
19
|
+
const defaultTranslations = {
|
|
20
|
+
title: {
|
|
21
|
+
'pt-br': 'Visualizar modelo',
|
|
22
|
+
en: 'Template preview',
|
|
23
|
+
es: 'Vista previa de plantilla',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface Props {
|
|
28
|
+
locale?: string;
|
|
29
|
+
template: Template;
|
|
30
|
+
modelValue: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
34
|
+
locale: 'en',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
defineEmits<{
|
|
38
|
+
close: void;
|
|
39
|
+
}>();
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<style lang="scss" scoped>
|
|
43
|
+
@use '@/assets/scss/unnnic' as *;
|
|
44
|
+
|
|
45
|
+
:deep(.unnnic-modal-dialog__container__content) {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
background-color: $unnnic-color-neutral-lightest;
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Template {
|
|
2
|
+
header: {
|
|
3
|
+
type: 'TEXT' | 'MEDIA';
|
|
4
|
+
mediaType?: 'IMAGE' | 'VIDEO' | 'DOCUMENT';
|
|
5
|
+
text?: string | null;
|
|
6
|
+
src?: string | null;
|
|
7
|
+
};
|
|
8
|
+
body?: string;
|
|
9
|
+
footer?: string;
|
|
10
|
+
buttons?: Array<{
|
|
11
|
+
type: 'QUICK_REPLY' | 'PHONE_NUMBER';
|
|
12
|
+
text: string;
|
|
13
|
+
countryCode?: string;
|
|
14
|
+
phoneNumber?: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
:disabled="disabled"
|
|
19
19
|
:value="modelValue"
|
|
20
20
|
@input="$emit('update:modelValue', fullySanitize($event.target.value))"
|
|
21
|
-
|
|
21
|
+
/>
|
|
22
22
|
|
|
23
23
|
<template
|
|
24
24
|
v-if="maxLength"
|
|
25
25
|
#rightMessage
|
|
26
|
-
>{{ modelValue.length }}/{{ maxLength }}</template
|
|
27
26
|
>
|
|
27
|
+
{{ modelValue.length }}/{{ maxLength }}
|
|
28
|
+
</template>
|
|
28
29
|
</UnnnicFormElement>
|
|
29
30
|
</template>
|
|
30
31
|
|
|
@@ -96,6 +97,12 @@ export default {
|
|
|
96
97
|
@use '@/assets/scss/unnnic' as *;
|
|
97
98
|
@use '@/components/Input/Input' as *;
|
|
98
99
|
|
|
100
|
+
* {
|
|
101
|
+
margin: 0;
|
|
102
|
+
padding: 0;
|
|
103
|
+
box-sizing: border-box;
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
.unnnic-text-area {
|
|
100
107
|
&__textarea {
|
|
101
108
|
@include input-base;
|
|
@@ -103,24 +110,21 @@ export default {
|
|
|
103
110
|
display: block;
|
|
104
111
|
width: 100%;
|
|
105
112
|
resize: vertical;
|
|
106
|
-
box-sizing: border-box;
|
|
107
113
|
|
|
108
114
|
scrollbar-width: thin;
|
|
109
115
|
|
|
116
|
+
padding: $unnnic-space-3 $unnnic-space-4;
|
|
117
|
+
|
|
110
118
|
&--size-md {
|
|
111
119
|
@include input-md-font;
|
|
112
120
|
|
|
113
|
-
min-height:
|
|
114
|
-
padding: ($unnnic-spacing-ant - $unnnic-border-width-thinner)
|
|
115
|
-
($unnnic-spacing-sm - $unnnic-border-width-thinner);
|
|
121
|
+
min-height: 100px;
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
&--size-sm {
|
|
119
125
|
@include input-sm-font;
|
|
120
126
|
|
|
121
|
-
min-height:
|
|
122
|
-
padding: ($unnnic-spacing-xs)
|
|
123
|
-
($unnnic-spacing-sm - $unnnic-border-width-thinner);
|
|
127
|
+
min-height: $unnnic-space-20;
|
|
124
128
|
}
|
|
125
129
|
|
|
126
130
|
&.unnnic-text-area__textarea--type-error {
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
exports[`TextArea.vue > matches the snapshot 1`] = `
|
|
4
4
|
"<section data-v-9f8d6c86="" data-v-735b3c51="" class="unnnic-form-element">
|
|
5
5
|
<p data-v-9f8d6c86="" class="unnnic-form-element__label">Description</p><textarea data-v-735b3c51="" class="unnnic-text-area__textarea unnnic-text-area__textarea--size-md unnnic-text-area__textarea--type-normal" placeholder="Enter text" maxlength="200" value=""></textarea>
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
<section data-v-9f8d6c86="" class="unnnic-form-element__hints-container">
|
|
7
|
+
<section data-v-9f8d6c86="" class="unnnic-form-element__message-container">
|
|
8
|
+
<!--v-if-->
|
|
9
|
+
<!--v-if-->
|
|
10
|
+
</section>
|
|
11
|
+
<p data-v-9f8d6c86="">0/200</p>
|
|
12
|
+
</section>
|
|
8
13
|
</section>"
|
|
9
14
|
`;
|
|
@@ -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,12 @@ 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';
|
|
93
97
|
|
|
94
98
|
type VueComponent = Component;
|
|
95
99
|
|
|
@@ -188,8 +192,12 @@ export const components: ComponentsMap = {
|
|
|
188
192
|
unnnicTour: Tour,
|
|
189
193
|
unnnicNavigator: Navigator,
|
|
190
194
|
unnnicSelectTime: SelectTime,
|
|
195
|
+
unnnicTemplatePreview: TemplatePreview,
|
|
196
|
+
unnnicTemplatePreviewModal: TemplatePreviewModal,
|
|
191
197
|
unnnicDataTable: DataTable,
|
|
192
198
|
unnnicChip: Chip,
|
|
199
|
+
unnnicToast: Toast,
|
|
200
|
+
unnnicToastManager: toast,
|
|
193
201
|
};
|
|
194
202
|
|
|
195
203
|
export const unnnicFontSize = fontSize;
|
|
@@ -241,7 +249,7 @@ export const unnnicAccordion = accordion;
|
|
|
241
249
|
export const unnnicIndicator = indicator;
|
|
242
250
|
export const unnnicSkeletonLoading = skeletonLoading;
|
|
243
251
|
export const unnnicCarousel = carousel;
|
|
244
|
-
export const unnnicLabel = label;
|
|
252
|
+
export const unnnicLabel = label as VueComponent;
|
|
245
253
|
export const unnnicTab = tab;
|
|
246
254
|
export const unnnicTabsExpanded = tabsExpanded;
|
|
247
255
|
export const unnnicBanner = banner;
|
|
@@ -282,8 +290,10 @@ export const unnnicDrawer = Drawer;
|
|
|
282
290
|
export const unnnicTableNext = TableNext;
|
|
283
291
|
export const unnnicTour = Tour;
|
|
284
292
|
export const unnnicNavigator = Navigator;
|
|
285
|
-
export const unnnicDataTable = DataTable as VueComponent;
|
|
286
293
|
export const unnnicSelectTime = SelectTime as VueComponent;
|
|
294
|
+
export const unnnicTemplatePreview = TemplatePreview as VueComponent;
|
|
295
|
+
export const unnnicTemplatePreviewModal = TemplatePreviewModal as VueComponent;
|
|
296
|
+
export const unnnicDataTable = DataTable as VueComponent;
|
|
287
297
|
export const unnnicChip = Chip;
|
|
288
298
|
|
|
289
299
|
export const UnnnicFontSize = fontSize;
|
|
@@ -335,7 +345,7 @@ export const UnnnicAccordion = accordion;
|
|
|
335
345
|
export const UnnnicIndicator = indicator;
|
|
336
346
|
export const UnnnicSkeletonLoading = skeletonLoading;
|
|
337
347
|
export const UnnnicCarousel = carousel;
|
|
338
|
-
export const UnnnicLabel = label;
|
|
348
|
+
export const UnnnicLabel = label as VueComponent;
|
|
339
349
|
export const UnnnicTab = tab;
|
|
340
350
|
export const UnnnicTabsExpanded = tabsExpanded;
|
|
341
351
|
export const UnnnicBanner = banner;
|
|
@@ -376,6 +386,10 @@ export const UnnnicDrawer = Drawer;
|
|
|
376
386
|
export const UnnnicTableNext = TableNext;
|
|
377
387
|
export const UnnnicTour = Tour;
|
|
378
388
|
export const UnnnicNavigator = Navigator;
|
|
379
|
-
export const UnnnicDataTable = DataTable as VueComponent;
|
|
380
389
|
export const UnnnicSelectTime = SelectTime as VueComponent;
|
|
390
|
+
export const UnnnicTemplatePreview = TemplatePreview as VueComponent;
|
|
391
|
+
export const UnnnicTemplatePreviewModal = TemplatePreviewModal as VueComponent;
|
|
392
|
+
export const UnnnicDataTable = DataTable as VueComponent;
|
|
381
393
|
export const UnnnicChip = Chip;
|
|
394
|
+
export const UnnnicToast = Toast;
|
|
395
|
+
export const UnnnicToastManager = toast;
|
package/src/locales/en.json
CHANGED
package/src/locales/es.json
CHANGED