@weni/unnnic-system 3.6.0 → 3.7.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 +8 -1
- package/dist/components/Accordion/Accordion.vue.d.ts +1 -1
- package/dist/components/Alert/Alert.vue.d.ts +18 -117
- 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 +3 -3
- 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 +1 -1
- 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 +5 -5
- package/dist/components/Card/BlankCard.vue.d.ts +1 -1
- package/dist/components/Card/Card.vue.d.ts +27 -27
- package/dist/components/Card/CardCompany.vue.d.ts +5 -5
- package/dist/components/Card/CardData.vue.d.ts +1 -1
- package/dist/components/Card/CardStatusesContainer.vue.d.ts +5 -5
- package/dist/components/Card/ContentCard.vue.d.ts +3 -3
- package/dist/components/Card/DashCard.vue.d.ts +5 -5
- 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 +3 -3
- package/dist/components/CardImage/CardImage.vue.d.ts +24 -31
- package/dist/components/CardInformation/CardInformation.vue.d.ts +5 -5
- package/dist/components/CardProject/CardProject.vue.d.ts +3 -3
- package/dist/components/Carousel/Carousel.vue.d.ts +7 -7
- package/dist/components/Carousel/TagCarousel.vue.d.ts +6 -6
- package/dist/components/ChartBar/ChartBar.vue.d.ts +5 -5
- 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 +27 -34
- 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 +19 -26
- package/dist/components/Checkbox/Checkbox.vue.d.ts.map +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts +28 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts.map +1 -0
- 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 +253 -43
- package/dist/components/DatePicker/DatePicker.vue.d.ts +4 -4
- package/dist/components/Drawer/Drawer.vue.d.ts +4 -4
- 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 +51 -28
- package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
- package/dist/components/Icon.vue.d.ts +1 -1
- package/dist/components/Icon.vue.d.ts.map +1 -1
- package/dist/components/IconLoading/IconLoading.vue.d.ts +1 -1
- package/dist/components/ImportCard/ImportCard.vue.d.ts +4 -4
- package/dist/components/Input/BaseInput.vue.d.ts +33 -2
- package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/Input/Input.vue.d.ts +253 -43
- package/dist/components/Input/Input.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts +86 -26
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +259 -49
- package/dist/components/InputNext/InputNext.vue.d.ts +5 -5
- 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 +199 -34
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
- package/dist/components/ModalNext/ModalNext.vue.d.ts +258 -48
- package/dist/components/ModalUpload/ModalUpload.vue.d.ts +8 -8
- 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 +3 -3
- 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 +115 -62
- package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +5 -5
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +21 -28
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts.map +1 -1
- package/dist/components/SelectTime/index.vue.d.ts +87 -27
- package/dist/components/SkeletonLoading/skeletonTheme.vue.d.ts +2 -2
- 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 +55 -21
- 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 +3 -3
- package/dist/components/TabsExpanded/TabsExpanded.vue.d.ts +1 -1
- package/dist/components/Tag/BrandTag.vue.d.ts +1 -1
- package/dist/components/Tag/DefaultTag.vue.d.ts +1 -1
- package/dist/components/Tag/IndicatorTag.vue.d.ts +2 -2
- package/dist/components/Tag/Tag.vue.d.ts +5 -5
- package/dist/components/TextArea/TextArea.vue.d.ts +66 -30
- 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 +3 -3
- package/dist/components/Tour/TourPopover.vue.d.ts +3 -3
- package/dist/components/UploadArea/UploadArea.vue.d.ts +4 -4
- package/dist/components/index.d.ts +4057 -1342
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/ui/dialog/Dialog.vue.d.ts +23 -0
- package/dist/components/ui/dialog/Dialog.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogClose.vue.d.ts +19 -0
- package/dist/components/ui/dialog/DialogClose.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogContent.vue.d.ts +40 -0
- package/dist/components/ui/dialog/DialogContent.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts +25 -0
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts +29 -0
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts +23 -0
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +19 -0
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/index.d.ts +8 -0
- package/dist/components/ui/dialog/index.d.ts.map +1 -0
- 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-92fbe460.mjs → es-3d0df246.mjs} +1 -1
- package/dist/{index-0da47957.mjs → index-8cf13f7a.mjs} +19106 -10952
- 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-c29b6c9a.mjs → pt-br-b04d6fba.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +195 -172
- package/dist/unnnic.umd.js +56 -50
- package/dist/utils/call.d.ts +2 -1
- package/dist/utils/call.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/assets/icons/checkbox-checked-disabled.svg +3 -0
- package/src/assets/icons/checkbox-checked.svg +3 -0
- package/src/assets/icons/checkbox-less-disabled.svg +3 -0
- package/src/assets/icons/checkbox-less.svg +3 -0
- 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/scss/tailwind.scss +8 -0
- package/src/components/Alert/Alert.vue +26 -135
- package/src/components/Alert/SIMPLE_MIGRATION_GUIDE.md +152 -0
- package/src/components/Alert/Version1dot1.vue +0 -36
- package/src/components/Alert/__tests__/Alert.spec.js +2 -45
- package/src/components/Alert/__tests__/Version1dot1.spec.js +0 -21
- 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 +72 -117
- package/src/components/Button/types.ts +0 -1
- package/src/components/Checkbox/Checkbox.vue +98 -64
- package/src/components/Checkbox/__tests__/Checkbox.spec.js +6 -21
- package/src/components/CheckboxGroup/CheckboxGroup.vue +96 -0
- package/src/components/FormElement/FormElement.vue +63 -93
- package/src/components/Icon.vue +26 -1
- package/src/components/Input/BaseInput.vue +33 -14
- package/src/components/Input/Input.scss +19 -21
- package/src/components/Input/Input.vue +77 -56
- package/src/components/Input/TextInput.vue +80 -68
- package/src/components/Input/__test__/TextInput.spec.js +6 -8
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +14 -5
- package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +1 -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 +60 -146
- package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +1 -22
- 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 +142 -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/SelectSmart/SelectSmart.vue +4 -3
- package/src/components/Switch/Switch.vue +123 -96
- package/src/components/Switch/__tests__/Switch.spec.js +8 -75
- package/src/components/Switch/__tests__/__snapshots__/Switch.spec.js.snap +5 -6
- 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/TextArea/TextArea.vue +34 -11
- package/src/components/TextArea/__test__/__snapshots__/TextArea.spec.js.snap +11 -3
- package/src/components/Toast/Toast.vue +246 -0
- package/src/components/Toast/ToastManager.ts +110 -0
- package/src/components/Toast/__tests__/Toast.spec.js +284 -0
- package/src/components/Toast/__tests__/ToastManager.spec.js +294 -0
- package/src/components/Toast/types.ts +57 -0
- package/src/components/index.ts +58 -9
- package/src/components/ui/dialog/Dialog.vue +15 -0
- package/src/components/ui/dialog/DialogClose.vue +25 -0
- package/src/components/ui/dialog/DialogContent.vue +114 -0
- package/src/components/ui/dialog/DialogFooter.vue +46 -0
- package/src/components/ui/dialog/DialogHeader.vue +78 -0
- package/src/components/ui/dialog/DialogTitle.vue +34 -0
- package/src/components/ui/dialog/DialogTrigger.vue +12 -0
- package/src/components/ui/dialog/index.ts +7 -0
- package/src/components/ui/popover/Popover.vue +19 -0
- package/src/components/ui/popover/PopoverContent.vue +98 -0
- package/src/components/ui/popover/PopoverTrigger.vue +23 -0
- package/src/components/ui/popover/index.ts +4 -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/stories/Alert.stories.js +6 -67
- package/src/stories/Button.stories.js +29 -39
- package/src/stories/Checkbox.stories.js +11 -4
- package/src/stories/CheckboxGroup.stories.js +105 -0
- package/src/stories/Dialog.stories.js +832 -0
- package/src/stories/Icon.stories.js +24 -15
- package/src/stories/Input.stories.js +71 -76
- package/src/stories/Label.stories.js +7 -0
- package/src/stories/ModalDialog.mdx +3 -0
- package/src/stories/ModalDialog.stories.js +1 -1
- package/src/stories/Popover.stories.js +306 -0
- package/src/stories/RadioGroup.stories.js +144 -0
- package/src/stories/Select.stories.js +158 -0
- package/src/stories/Switch.stories.js +10 -5
- package/src/stories/Tab.stories.js +11 -4
- package/src/stories/TextArea.stories.js +13 -2
- 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
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
class="tab-head"
|
|
10
10
|
:class="{
|
|
11
11
|
'tab-head--active': localValue === tab,
|
|
12
|
+
'tab-head--disabled': disabledTabs?.includes(tab),
|
|
12
13
|
}"
|
|
13
14
|
@click="change(tab)"
|
|
14
15
|
>
|
|
@@ -20,10 +21,9 @@
|
|
|
20
21
|
side="bottom"
|
|
21
22
|
>
|
|
22
23
|
<UnnnicIcon
|
|
23
|
-
icon="
|
|
24
|
+
icon="help"
|
|
24
25
|
:size="size === 'sm' ? 'xs' : 'sm'"
|
|
25
|
-
|
|
26
|
-
scheme="neutral-cleanest"
|
|
26
|
+
scheme="fg-base"
|
|
27
27
|
/>
|
|
28
28
|
</UnnnicToolTip>
|
|
29
29
|
</li>
|
|
@@ -65,6 +65,13 @@ export default {
|
|
|
65
65
|
tabs: {
|
|
66
66
|
type: Array,
|
|
67
67
|
default: null,
|
|
68
|
+
validator: (tabs) => {
|
|
69
|
+
return tabs.every((tab) => typeof tab === 'string') && tabs.length <= 5;
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
disabledTabs: {
|
|
73
|
+
type: Array,
|
|
74
|
+
default: null,
|
|
68
75
|
},
|
|
69
76
|
},
|
|
70
77
|
emits: ['change'],
|
|
@@ -105,6 +112,10 @@ export default {
|
|
|
105
112
|
return '';
|
|
106
113
|
},
|
|
107
114
|
change(value) {
|
|
115
|
+
if (this.disabledTabs?.includes(value)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
108
119
|
this.localValue = value;
|
|
109
120
|
this.$emit('change', this.localValue);
|
|
110
121
|
},
|
|
@@ -119,18 +130,15 @@ export default {
|
|
|
119
130
|
display: flex;
|
|
120
131
|
align-items: flex-start;
|
|
121
132
|
justify-content: space-between;
|
|
122
|
-
color: $unnnic-color-
|
|
123
|
-
font
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
|
|
127
|
-
margin-bottom: $unnnic-inset-sm;
|
|
128
|
-
border-bottom: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
|
|
133
|
+
color: $unnnic-color-fg-base;
|
|
134
|
+
font: $unnnic-font-action;
|
|
135
|
+
margin-bottom: $unnnic-space-4;
|
|
136
|
+
border-bottom: $unnnic-border-width-thinner solid $unnnic-color-border-base;
|
|
129
137
|
}
|
|
130
138
|
|
|
131
139
|
.tab-content {
|
|
132
140
|
display: flex;
|
|
133
|
-
gap: $unnnic-
|
|
141
|
+
gap: $unnnic-space-6;
|
|
134
142
|
|
|
135
143
|
margin: 0;
|
|
136
144
|
padding: 0;
|
|
@@ -139,27 +147,24 @@ export default {
|
|
|
139
147
|
|
|
140
148
|
.tab-head {
|
|
141
149
|
display: flex;
|
|
142
|
-
gap: $unnnic-
|
|
150
|
+
gap: $unnnic-space-2;
|
|
143
151
|
align-items: center;
|
|
144
152
|
|
|
145
153
|
cursor: pointer;
|
|
146
|
-
|
|
154
|
+
padding: $unnnic-space-2 $unnnic-space-4;
|
|
147
155
|
|
|
148
156
|
.unnnic-tooltip {
|
|
149
157
|
display: flex;
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
&:hover {
|
|
153
|
-
color: $unnnic-color-
|
|
161
|
+
color: $unnnic-color-fg-emphasized;
|
|
154
162
|
}
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
.tab-head--active {
|
|
158
|
-
|
|
159
|
-
font
|
|
160
|
-
color: $unnnic-color-neutral-black;
|
|
161
|
-
font-size: $unnnic-font-size-body-lg;
|
|
162
|
-
line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
|
|
166
|
+
color: $unnnic-color-fg-emphasized;
|
|
167
|
+
font: $unnnic-font-action;
|
|
163
168
|
transition: 0.4s;
|
|
164
169
|
|
|
165
170
|
position: relative;
|
|
@@ -168,14 +173,23 @@ export default {
|
|
|
168
173
|
content: '';
|
|
169
174
|
|
|
170
175
|
position: absolute;
|
|
171
|
-
bottom:
|
|
172
|
-
left:
|
|
176
|
+
bottom: 0;
|
|
177
|
+
left: 0;
|
|
173
178
|
|
|
174
179
|
display: block;
|
|
175
180
|
|
|
176
|
-
width:
|
|
181
|
+
width: 100%;
|
|
177
182
|
|
|
178
|
-
border-bottom: $unnnic-border-width-thin solid $unnnic-color-
|
|
183
|
+
border-bottom: $unnnic-border-width-thin solid $unnnic-color-border-active;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.tab-head--disabled {
|
|
188
|
+
color: $unnnic-color-fg-muted;
|
|
189
|
+
cursor: default;
|
|
190
|
+
|
|
191
|
+
&:hover {
|
|
192
|
+
color: $unnnic-color-fg-muted;
|
|
179
193
|
}
|
|
180
194
|
}
|
|
181
195
|
|
|
@@ -4,7 +4,7 @@ exports[`Tab.vue > matches the snapshot 1`] = `
|
|
|
4
4
|
"<div data-v-b4e39fac="" class="tab size-md">
|
|
5
5
|
<header data-v-b4e39fac="" class="tab-header">
|
|
6
6
|
<ul data-v-b4e39fac="" class="tab-content">
|
|
7
|
-
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-bf0cf546="" data-v-b4e39fac="" class="unnnic-tooltip"><span data-v-26446d8e="" data-v-b4e39fac="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--
|
|
7
|
+
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-bf0cf546="" data-v-b4e39fac="" class="unnnic-tooltip"><span data-v-26446d8e="" data-v-b4e39fac="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--sm unnnic-icon__size--sm" data-testid="material-icon" translate="no">help</span><span data-v-bf0cf546="" class="unnnic-tooltip-label unnnic-tooltip-label-bottom" data-testid="tooltip-label" style="left: 0px; top: 8px;">Tooltip text <br data-v-bf0cf546=""><!--v-if--></span></div>
|
|
8
8
|
</li>
|
|
9
9
|
<li data-v-b4e39fac="" class="tab-head tab-head--active">tab2
|
|
10
10
|
<!--v-if-->
|
|
@@ -42,7 +42,7 @@ exports[`TableNext.vue > matches the snapshot 1`] = `
|
|
|
42
42
|
<p data-v-e29458bb="" class="table-pagination__count" data-testid="count">1 - 1 of 1</p>
|
|
43
43
|
<div data-v-0eeff8cb="" data-v-e29458bb="" class="pagination"><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="previous-button" disabled="" class="unnnic-button unnnic-button--size-small unnnic-button--tertiary unnnic-button--icon-on-center">
|
|
44
44
|
<!--v-if-->
|
|
45
|
-
<!--v-if--><span data-v-26446d8e="" data-v-ceff2a60="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-clean unnnic-icon-size--
|
|
45
|
+
<!--v-if--><span data-v-26446d8e="" data-v-ceff2a60="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-clean unnnic-icon-size--ant unnnic-icon__size--ant" data-testid="icon-center" translate="no" style="visibility: visible;">chevron_left</span><span data-v-ceff2a60="" class="unnnic-button__label" style="visibility: visible;" data-testid="button-label"> </span>
|
|
46
46
|
<!--v-if-->
|
|
47
47
|
</button><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="page-button" class="unnnic-button unnnic-button--size-small unnnic-button--secondary">
|
|
48
48
|
<!--v-if-->
|
|
@@ -51,7 +51,7 @@ exports[`TableNext.vue > matches the snapshot 1`] = `
|
|
|
51
51
|
<!--v-if-->
|
|
52
52
|
</button><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="next-button" disabled="" class="unnnic-button unnnic-button--size-small unnnic-button--tertiary unnnic-button--icon-on-center">
|
|
53
53
|
<!--v-if-->
|
|
54
|
-
<!--v-if--><span data-v-26446d8e="" data-v-ceff2a60="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-clean unnnic-icon-size--
|
|
54
|
+
<!--v-if--><span data-v-26446d8e="" data-v-ceff2a60="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-clean unnnic-icon-size--ant unnnic-icon__size--ant" data-testid="icon-center" translate="no" style="visibility: visible;">chevron_right</span><span data-v-ceff2a60="" class="unnnic-button__label" style="visibility: visible;" data-testid="button-label"> </span>
|
|
55
55
|
<!--v-if-->
|
|
56
56
|
</button></div>
|
|
57
57
|
</section>
|
|
@@ -5,7 +5,7 @@ exports[`TablePagination.vue > matches the snapshot 1`] = `
|
|
|
5
5
|
<p data-v-e29458bb="" class="table-pagination__count" data-testid="count">1 - 10 of 100</p>
|
|
6
6
|
<div data-v-0eeff8cb="" data-v-e29458bb="" class="pagination"><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="previous-button" disabled="" class="unnnic-button unnnic-button--size-small unnnic-button--tertiary unnnic-button--icon-on-center">
|
|
7
7
|
<!--v-if-->
|
|
8
|
-
<!--v-if--><span data-v-26446d8e="" data-v-ceff2a60="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-clean unnnic-icon-size--
|
|
8
|
+
<!--v-if--><span data-v-26446d8e="" data-v-ceff2a60="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-clean unnnic-icon-size--ant unnnic-icon__size--ant" data-testid="icon-center" translate="no" style="visibility: visible;">chevron_left</span><span data-v-ceff2a60="" class="unnnic-button__label" style="visibility: visible;" data-testid="button-label"> </span>
|
|
9
9
|
<!--v-if-->
|
|
10
10
|
</button><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="page-button" class="unnnic-button unnnic-button--size-small unnnic-button--secondary">
|
|
11
11
|
<!--v-if-->
|
|
@@ -34,7 +34,7 @@ exports[`TablePagination.vue > matches the snapshot 1`] = `
|
|
|
34
34
|
<!--v-if-->
|
|
35
35
|
</button><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="next-button" class="unnnic-button unnnic-button--size-small unnnic-button--tertiary unnnic-button--icon-on-center">
|
|
36
36
|
<!--v-if-->
|
|
37
|
-
<!--v-if--><span data-v-26446d8e="" data-v-ceff2a60="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-dark unnnic-icon-size--
|
|
37
|
+
<!--v-if--><span data-v-26446d8e="" data-v-ceff2a60="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--neutral-dark unnnic-icon-size--ant unnnic-icon__size--ant" data-testid="icon-center" translate="no" style="visibility: visible;">chevron_right</span><span data-v-ceff2a60="" class="unnnic-button__label" style="visibility: visible;" data-testid="button-label"> </span>
|
|
38
38
|
<!--v-if-->
|
|
39
39
|
</button></div>
|
|
40
40
|
</section>"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
:size="size"
|
|
5
5
|
:disabled="disabled"
|
|
6
6
|
:message="message"
|
|
7
|
-
:error="
|
|
7
|
+
:error="computedError"
|
|
8
8
|
>
|
|
9
9
|
<textarea
|
|
10
10
|
ref="textarea"
|
|
@@ -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
|
|
|
@@ -43,6 +44,14 @@ export default {
|
|
|
43
44
|
default: 'md',
|
|
44
45
|
},
|
|
45
46
|
|
|
47
|
+
resize: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: 'vertical',
|
|
50
|
+
validator(value) {
|
|
51
|
+
return ['none', 'vertical'].indexOf(value) !== -1;
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
46
55
|
label: {
|
|
47
56
|
type: String,
|
|
48
57
|
},
|
|
@@ -83,6 +92,16 @@ export default {
|
|
|
83
92
|
},
|
|
84
93
|
emits: ['update:modelValue'],
|
|
85
94
|
|
|
95
|
+
computed: {
|
|
96
|
+
computedError() {
|
|
97
|
+
if (Array.isArray(this.errors)) {
|
|
98
|
+
return this.errors.join(', ') || this.type === 'error';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this.errors || this.type === 'error';
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
|
|
86
105
|
methods: {
|
|
87
106
|
fullySanitize,
|
|
88
107
|
focus() {
|
|
@@ -96,31 +115,35 @@ export default {
|
|
|
96
115
|
@use '@/assets/scss/unnnic' as *;
|
|
97
116
|
@use '@/components/Input/Input' as *;
|
|
98
117
|
|
|
118
|
+
* {
|
|
119
|
+
margin: 0;
|
|
120
|
+
padding: 0;
|
|
121
|
+
box-sizing: border-box;
|
|
122
|
+
}
|
|
123
|
+
|
|
99
124
|
.unnnic-text-area {
|
|
100
125
|
&__textarea {
|
|
101
126
|
@include input-base;
|
|
102
127
|
|
|
103
128
|
display: block;
|
|
104
129
|
width: 100%;
|
|
105
|
-
|
|
106
|
-
|
|
130
|
+
|
|
131
|
+
resize: v-bind(resize);
|
|
107
132
|
|
|
108
133
|
scrollbar-width: thin;
|
|
109
134
|
|
|
135
|
+
padding: $unnnic-space-3 $unnnic-space-4;
|
|
136
|
+
|
|
110
137
|
&--size-md {
|
|
111
138
|
@include input-md-font;
|
|
112
139
|
|
|
113
|
-
min-height:
|
|
114
|
-
padding: ($unnnic-spacing-ant - $unnnic-border-width-thinner)
|
|
115
|
-
($unnnic-spacing-sm - $unnnic-border-width-thinner);
|
|
140
|
+
min-height: 90px;
|
|
116
141
|
}
|
|
117
142
|
|
|
118
143
|
&--size-sm {
|
|
119
144
|
@include input-sm-font;
|
|
120
145
|
|
|
121
|
-
min-height:
|
|
122
|
-
padding: ($unnnic-spacing-xs)
|
|
123
|
-
($unnnic-spacing-sm - $unnnic-border-width-thinner);
|
|
146
|
+
min-height: $unnnic-space-20;
|
|
124
147
|
}
|
|
125
148
|
|
|
126
149
|
&.unnnic-text-area__textarea--type-error {
|
|
@@ -2,8 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`TextArea.vue > matches the snapshot 1`] = `
|
|
4
4
|
"<section data-v-9f8d6c86="" data-v-735b3c51="" class="unnnic-form-element">
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
<section data-v-7f222291="" data-v-9f8d6c86="" class="unnnic-label unnnic-form-element__label">
|
|
6
|
+
<p data-v-7f222291="" class="unnnic-label__label">Description</p>
|
|
7
|
+
<!--v-if-->
|
|
8
|
+
</section><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>
|
|
9
|
+
<section data-v-9f8d6c86="" class="unnnic-form-element__hints-container">
|
|
10
|
+
<section data-v-9f8d6c86="" class="unnnic-form-element__message-container">
|
|
11
|
+
<!--v-if-->
|
|
12
|
+
<!--v-if-->
|
|
13
|
+
</section>
|
|
14
|
+
<p data-v-9f8d6c86="">0/200</p>
|
|
15
|
+
</section>
|
|
8
16
|
</section>"
|
|
9
17
|
`;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Transition
|
|
3
|
+
name="toast-slide"
|
|
4
|
+
appear
|
|
5
|
+
data-testid="toast-transition"
|
|
6
|
+
@after-leave="$emit('destroy')"
|
|
7
|
+
>
|
|
8
|
+
<aside
|
|
9
|
+
v-if="isVisible"
|
|
10
|
+
:class="['unnnic-toast', `unnnic-toast--${type}`]"
|
|
11
|
+
:role="type === 'error' ? 'alert' : 'status'"
|
|
12
|
+
:aria-live="type === 'error' ? 'assertive' : 'polite'"
|
|
13
|
+
data-testid="toast"
|
|
14
|
+
>
|
|
15
|
+
<section
|
|
16
|
+
class="unnnic-toast__content"
|
|
17
|
+
data-testid="toast-content"
|
|
18
|
+
>
|
|
19
|
+
<header
|
|
20
|
+
class="unnnic-toast__header"
|
|
21
|
+
data-testid="toast-header"
|
|
22
|
+
>
|
|
23
|
+
<UnnnicIcon
|
|
24
|
+
:icon="typeConfig.icon"
|
|
25
|
+
:scheme="typeConfig.scheme"
|
|
26
|
+
size="ant"
|
|
27
|
+
data-testid="toast-type-icon"
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<h3
|
|
31
|
+
class="unnnic-toast__title"
|
|
32
|
+
data-testid="toast-title"
|
|
33
|
+
>
|
|
34
|
+
{{ title }}
|
|
35
|
+
</h3>
|
|
36
|
+
|
|
37
|
+
<UnnnicIcon
|
|
38
|
+
icon="close"
|
|
39
|
+
scheme="neutral-dark"
|
|
40
|
+
size="ant"
|
|
41
|
+
clickable
|
|
42
|
+
class="unnnic-toast__close"
|
|
43
|
+
data-testid="toast-close-icon"
|
|
44
|
+
@click="handleClose"
|
|
45
|
+
@keydown.enter="handleClose"
|
|
46
|
+
/>
|
|
47
|
+
</header>
|
|
48
|
+
|
|
49
|
+
<p
|
|
50
|
+
v-if="description"
|
|
51
|
+
data-testid="toast-text"
|
|
52
|
+
class="unnnic-toast__text"
|
|
53
|
+
>
|
|
54
|
+
{{ description }}
|
|
55
|
+
</p>
|
|
56
|
+
</section>
|
|
57
|
+
|
|
58
|
+
<UnnnicButton
|
|
59
|
+
v-if="button"
|
|
60
|
+
type="tertiary"
|
|
61
|
+
:text="button.text"
|
|
62
|
+
class="unnnic-toast__action-button"
|
|
63
|
+
data-testid="toast-action-button"
|
|
64
|
+
@click="handleAction"
|
|
65
|
+
@keydown.enter="handleAction"
|
|
66
|
+
@keydown.space.prevent="handleAction"
|
|
67
|
+
/>
|
|
68
|
+
</aside>
|
|
69
|
+
</Transition>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup lang="ts">
|
|
73
|
+
import { ref, computed, onMounted, onUnmounted } from 'vue';
|
|
74
|
+
|
|
75
|
+
import UnnnicIcon from '@/components/Icon.vue';
|
|
76
|
+
import UnnnicButton from '@/components/Button/Button.vue';
|
|
77
|
+
|
|
78
|
+
import type { ToastProps, ToastEmits } from './types';
|
|
79
|
+
import type { SchemeColor } from '@/types/scheme-colors';
|
|
80
|
+
|
|
81
|
+
defineOptions({
|
|
82
|
+
name: 'UnnnicToast',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const props = withDefaults(defineProps<ToastProps>(), {
|
|
86
|
+
title: '',
|
|
87
|
+
description: '',
|
|
88
|
+
button: undefined,
|
|
89
|
+
timeout: 5000,
|
|
90
|
+
type: 'informational',
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const emit = defineEmits<ToastEmits>();
|
|
94
|
+
|
|
95
|
+
const isVisible = ref(false);
|
|
96
|
+
let timeoutId: number | null = null;
|
|
97
|
+
|
|
98
|
+
const typeConfig = computed(() => {
|
|
99
|
+
const configMap = {
|
|
100
|
+
informational: { icon: 'info', scheme: 'blue-500' },
|
|
101
|
+
attention: { icon: 'error', scheme: 'yellow-500' },
|
|
102
|
+
success: { icon: 'check_circle', scheme: 'green-500' },
|
|
103
|
+
error: { icon: 'cancel', scheme: 'red-500' },
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return configMap[props.type || 'informational'] as {
|
|
107
|
+
icon: string;
|
|
108
|
+
scheme: SchemeColor;
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const handleClose = () => {
|
|
113
|
+
isVisible.value = false;
|
|
114
|
+
emit('close');
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const handleAction = () => {
|
|
118
|
+
if (props.button?.action) {
|
|
119
|
+
props.button.action();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const startTimeout = () => {
|
|
124
|
+
if (props.timeout > 0) {
|
|
125
|
+
timeoutId = window.setTimeout(() => {
|
|
126
|
+
handleClose();
|
|
127
|
+
}, props.timeout);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const clearTimeout = () => {
|
|
132
|
+
if (timeoutId) {
|
|
133
|
+
window.clearTimeout(timeoutId);
|
|
134
|
+
timeoutId = null;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
onMounted(() => {
|
|
139
|
+
isVisible.value = true;
|
|
140
|
+
startTimeout();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
onUnmounted(() => {
|
|
144
|
+
clearTimeout();
|
|
145
|
+
});
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<style lang="scss" scoped>
|
|
149
|
+
@use '@/assets/scss/unnnic' as *;
|
|
150
|
+
|
|
151
|
+
.unnnic-toast {
|
|
152
|
+
position: fixed;
|
|
153
|
+
bottom: $unnnic-space-4;
|
|
154
|
+
right: $unnnic-space-4;
|
|
155
|
+
z-index: 9999;
|
|
156
|
+
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: flex-end;
|
|
159
|
+
flex-direction: column;
|
|
160
|
+
gap: $unnnic-space-2;
|
|
161
|
+
|
|
162
|
+
min-width: 250px;
|
|
163
|
+
max-width: 450px;
|
|
164
|
+
padding: $unnnic-space-4;
|
|
165
|
+
|
|
166
|
+
border-radius: $unnnic-radius-2;
|
|
167
|
+
box-shadow: $unnnic-shadow-2;
|
|
168
|
+
border: 1px solid $unnnic-color-border-base;
|
|
169
|
+
|
|
170
|
+
&--informational {
|
|
171
|
+
border-color: $unnnic-color-border-info;
|
|
172
|
+
background-color: $unnnic-color-bg-info;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
&--attention {
|
|
176
|
+
border-color: $unnnic-color-border-warning;
|
|
177
|
+
background-color: $unnnic-color-bg-warning;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&--success {
|
|
181
|
+
border-color: $unnnic-color-border-success;
|
|
182
|
+
background-color: $unnnic-color-bg-success;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&--error {
|
|
186
|
+
border-color: $unnnic-color-border-critical;
|
|
187
|
+
background-color: $unnnic-color-bg-critical;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
&__content,
|
|
191
|
+
&__header {
|
|
192
|
+
width: 100%;
|
|
193
|
+
|
|
194
|
+
display: flex;
|
|
195
|
+
gap: $unnnic-space-2;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&__content {
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: $unnnic-space-2;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&__header {
|
|
204
|
+
align-items: center;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
&__title {
|
|
208
|
+
flex: 1;
|
|
209
|
+
|
|
210
|
+
margin: 0;
|
|
211
|
+
|
|
212
|
+
font: $unnnic-font-action;
|
|
213
|
+
color: $unnnic-color-fg-emphasized;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
&__text {
|
|
217
|
+
margin: 0;
|
|
218
|
+
margin-left: $unnnic-space-7;
|
|
219
|
+
|
|
220
|
+
font: $unnnic-font-caption-2;
|
|
221
|
+
color: $unnnic-color-fg-emphasized;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Animations
|
|
226
|
+
.toast-slide-enter-active,
|
|
227
|
+
.toast-slide-leave-active {
|
|
228
|
+
transition: all 0.3s ease;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.toast-slide-enter-from {
|
|
232
|
+
transform: translateY(100%);
|
|
233
|
+
opacity: 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.toast-slide-leave-to {
|
|
237
|
+
transform: translateY(100%);
|
|
238
|
+
opacity: 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.toast-slide-enter-to,
|
|
242
|
+
.toast-slide-leave-from {
|
|
243
|
+
transform: translateY(0);
|
|
244
|
+
opacity: 1;
|
|
245
|
+
}
|
|
246
|
+
</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;
|