@weni/unnnic-system 3.5.3-alpha.2 → 3.6.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.
Files changed (260) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/components/Accordion/Accordion.vue.d.ts +1 -1
  3. package/dist/components/Alert/Alert.vue.d.ts +117 -18
  4. package/dist/components/Alert/Alert.vue.d.ts.map +1 -1
  5. package/dist/components/Alert/Version1dot1.vue.d.ts +38 -2
  6. package/dist/components/Alert/Version1dot1.vue.d.ts.map +1 -1
  7. package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +2 -2
  8. package/dist/components/AudioRecorder/AudioPlayer.vue.d.ts +1 -1
  9. package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +5 -5
  10. package/dist/components/AvatarIcon/AvatarIcon.vue.d.ts +2 -2
  11. package/dist/components/Banner/Banner.vue.d.ts +1 -1
  12. package/dist/components/Banner/InfoBanner.vue.d.ts +1 -1
  13. package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +1 -1
  14. package/dist/components/Button/Button.vue.d.ts +1 -1
  15. package/dist/components/Button/Button.vue.d.ts.map +1 -1
  16. package/dist/components/Button/ButtonIcon.vue.d.ts +1 -1
  17. package/dist/components/Button/types.d.ts +1 -1
  18. package/dist/components/Button/types.d.ts.map +1 -1
  19. package/dist/components/Card/AccountCard.vue.d.ts +3 -3
  20. package/dist/components/Card/BlankCard.vue.d.ts +1 -1
  21. package/dist/components/Card/Card.vue.d.ts +21 -21
  22. package/dist/components/Card/CardCompany.vue.d.ts +8 -8
  23. package/dist/components/Card/CardData.vue.d.ts +1 -1
  24. package/dist/components/Card/CardStatusesContainer.vue.d.ts +4 -4
  25. package/dist/components/Card/ContentCard.vue.d.ts +2 -2
  26. package/dist/components/Card/DashCard.vue.d.ts +4 -4
  27. package/dist/components/Card/DefaultCard.vue.d.ts +1 -1
  28. package/dist/components/Card/MarketplaceCard.vue.d.ts +2 -2
  29. package/dist/components/Card/SimpleCard.vue.d.ts +3 -3
  30. package/dist/components/Card/StatusCard.vue.d.ts +2 -2
  31. package/dist/components/Card/TitleCard.vue.d.ts +2 -2
  32. package/dist/components/CardImage/CardImage.vue.d.ts +31 -24
  33. package/dist/components/CardInformation/CardInformation.vue.d.ts +4 -4
  34. package/dist/components/CardProject/CardProject.vue.d.ts +3 -3
  35. package/dist/components/Carousel/Carousel.vue.d.ts +11 -11
  36. package/dist/components/Carousel/TagCarousel.vue.d.ts +9 -9
  37. package/dist/components/ChartBar/ChartBar.vue.d.ts +5 -5
  38. package/dist/components/ChartLine/ChartLine.vue.d.ts +1 -1
  39. package/dist/components/ChatText/ChatText.vue.d.ts +2 -2
  40. package/dist/components/ChatsContact/ChatsContact.vue.d.ts +38 -31
  41. package/dist/components/ChatsDashboardTagLive/ChatsDashboardTagLive.vue.d.ts +1 -1
  42. package/dist/components/ChatsHeader/ChatsHeader.vue.d.ts +1 -1
  43. package/dist/components/ChatsHeader/ChatsHeader.vue.d.ts.map +1 -1
  44. package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +5 -5
  45. package/dist/components/ChatsMessage/ChatsMessageStatusBackdrop.vue.d.ts +2 -2
  46. package/dist/components/ChatsNavbar/ChatsNavbar.vue.d.ts +1 -1
  47. package/dist/components/ChatsUserAvatar/ChatsUserAvatar.vue.d.ts +2 -2
  48. package/dist/components/Checkbox/Checkbox.vue.d.ts +26 -19
  49. package/dist/components/Checkbox/Checkbox.vue.d.ts.map +1 -1
  50. package/dist/components/Comment/Comment.vue.d.ts +1 -1
  51. package/dist/components/DataArea/DataArea.vue.d.ts +2 -2
  52. package/dist/components/DataTable/index.vue.d.ts +1 -1
  53. package/dist/components/DataTable/index.vue.d.ts.map +1 -1
  54. package/dist/components/DateFilter/DateFilter.vue.d.ts +29 -176
  55. package/dist/components/DatePicker/DatePicker.vue.d.ts +3 -3
  56. package/dist/components/Drawer/Drawer.vue.d.ts +4 -4
  57. package/dist/components/Dropdown/Dropdown.vue.d.ts +1 -1
  58. package/dist/components/Dropdown/LanguageSelect.vue.d.ts +3 -3
  59. package/dist/components/Flag.vue.d.ts +2 -2
  60. package/dist/components/FormElement/FormElement.vue.d.ts +30 -38
  61. package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
  62. package/dist/components/Icon.vue.d.ts +1 -1
  63. package/dist/components/Icon.vue.d.ts.map +1 -1
  64. package/dist/components/IconLoading/IconLoading.vue.d.ts +1 -1
  65. package/dist/components/ImportCard/ImportCard.vue.d.ts +4 -4
  66. package/dist/components/Input/BaseInput.vue.d.ts +1 -32
  67. package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
  68. package/dist/components/Input/Input.vue.d.ts +29 -176
  69. package/dist/components/Input/Input.vue.d.ts.map +1 -1
  70. package/dist/components/Input/TextInput.vue.d.ts +14 -83
  71. package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
  72. package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +33 -180
  73. package/dist/components/InputNext/InputNext.vue.d.ts +4 -4
  74. package/dist/components/Label/Label.vue.d.ts +15 -9
  75. package/dist/components/Label/Label.vue.d.ts.map +1 -1
  76. package/dist/components/Modal/Modal.vue.d.ts +2 -2
  77. package/dist/components/ModalDialog/ModalDialog.vue.d.ts +34 -199
  78. package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
  79. package/dist/components/ModalNext/ModalNext.vue.d.ts +34 -181
  80. package/dist/components/ModalUpload/ModalUpload.vue.d.ts +8 -8
  81. package/dist/components/MoodRating/MoodRating.vue.d.ts +1 -1
  82. package/dist/components/MultiSelect/MultiSelect.vue.d.ts +14 -20
  83. package/dist/components/Pagination/Pagination.vue.d.ts +3 -3
  84. package/dist/components/ProgressBar/ProgressBar.vue.d.ts +1 -1
  85. package/dist/components/Radio/Radio.vue.d.ts +6 -8
  86. package/dist/components/Radio/Radio.vue.d.ts.map +1 -1
  87. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +51 -113
  88. package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +8 -8
  89. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +27 -20
  90. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts.map +1 -1
  91. package/dist/components/SelectTime/index.vue.d.ts +14 -83
  92. package/dist/components/SkeletonLoading/skeletonTheme.vue.d.ts +2 -2
  93. package/dist/components/Slider/Slider.vue.d.ts +2 -2
  94. package/dist/components/StarRating/StarRating.vue.d.ts +1 -1
  95. package/dist/components/Switch/Switch.vue.d.ts +21 -55
  96. package/dist/components/Switch/Switch.vue.d.ts.map +1 -1
  97. package/dist/components/Tab/Tab.vue.d.ts +2 -13
  98. package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
  99. package/dist/components/TableNext/TablePagination.vue.d.ts +3 -3
  100. package/dist/components/TabsExpanded/TabsExpanded.vue.d.ts +1 -1
  101. package/dist/components/Tag/BrandTag.vue.d.ts +2 -2
  102. package/dist/components/Tag/DefaultTag.vue.d.ts +2 -2
  103. package/dist/components/Tag/IndicatorTag.vue.d.ts +2 -2
  104. package/dist/components/Tag/Tag.vue.d.ts +8 -8
  105. package/dist/components/TextArea/TextArea.vue.d.ts +30 -38
  106. package/dist/components/TextArea/TextArea.vue.d.ts.map +1 -1
  107. package/dist/components/ToolTip/ToolTip.vue.d.ts +1 -1
  108. package/dist/components/Tour/Tour.vue.d.ts +3 -3
  109. package/dist/components/Tour/TourPopover.vue.d.ts +3 -3
  110. package/dist/components/UploadArea/UploadArea.vue.d.ts +4 -4
  111. package/dist/components/index.d.ts +1217 -3357
  112. package/dist/components/index.d.ts.map +1 -1
  113. package/dist/{es-dea507ea.mjs → es-92fbe460.mjs} +1 -1
  114. package/dist/{index-25e40316.mjs → index-0da47957.mjs} +11143 -19278
  115. package/dist/locales/en.json.d.ts +1 -2
  116. package/dist/locales/es.json.d.ts +1 -2
  117. package/dist/locales/pt_br.json.d.ts +1 -2
  118. package/dist/{pt-br-8720ec19.mjs → pt-br-c29b6c9a.mjs} +1 -1
  119. package/dist/style.css +1 -1
  120. package/dist/unnnic.mjs +172 -195
  121. package/dist/unnnic.umd.js +50 -56
  122. package/dist/utils/call.d.ts +1 -2
  123. package/dist/utils/call.d.ts.map +1 -1
  124. package/package.json +2 -4
  125. package/src/assets/scss/tailwind.scss +0 -8
  126. package/src/components/Alert/Alert.vue +135 -26
  127. package/src/components/Alert/AlertBanner.vue +182 -0
  128. package/src/components/Alert/AlertCaller.vue +49 -0
  129. package/src/components/Alert/Version1dot1.vue +36 -0
  130. package/src/components/Alert/__tests__/Alert.spec.js +45 -2
  131. package/src/components/Alert/__tests__/AlertBanner.spec.js +89 -0
  132. package/src/components/Alert/__tests__/AlertCaller.spec.js +98 -0
  133. package/src/components/Alert/__tests__/Version1dot1.spec.js +21 -0
  134. package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +7 -11
  135. package/src/components/Alert/__tests__/__snapshots__/Version1dot1.spec.js.snap +2 -2
  136. package/src/components/Button/Button.vue +107 -64
  137. package/src/components/Button/types.ts +1 -0
  138. package/src/components/Checkbox/Checkbox.vue +64 -98
  139. package/src/components/Checkbox/__tests__/Checkbox.spec.js +21 -6
  140. package/src/components/FormElement/FormElement.vue +91 -51
  141. package/src/components/Icon.vue +1 -23
  142. package/src/components/Input/BaseInput.vue +14 -31
  143. package/src/components/Input/Input.scss +21 -19
  144. package/src/components/Input/Input.vue +30 -94
  145. package/src/components/Input/TextInput.vue +58 -82
  146. package/src/components/Input/__test__/TextInput.spec.js +5 -5
  147. package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +3 -16
  148. package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +1 -7
  149. package/src/components/Label/Label.vue +21 -52
  150. package/src/components/Label/__tests__/Label.spec.js +1 -1
  151. package/src/components/Label/__tests__/__snapshots__/Label.spec.js.snap +1 -1
  152. package/src/components/ModalDialog/ModalDialog.vue +146 -60
  153. package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +22 -1
  154. package/src/components/Radio/Radio.vue +67 -80
  155. package/src/components/Radio/__test__/Radio.spec.js +20 -14
  156. package/src/components/Radio/__test__/__snapshots__/Radio.spec.js.snap +3 -3
  157. package/src/components/Switch/Switch.vue +97 -120
  158. package/src/components/Switch/__tests__/Switch.spec.js +75 -8
  159. package/src/components/Switch/__tests__/__snapshots__/Switch.spec.js.snap +6 -5
  160. package/src/components/Tab/Tab.vue +23 -37
  161. package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -1
  162. package/src/components/TableNext/__test__/__snapshots__/TableNext.spec.js.snap +2 -2
  163. package/src/components/TableNext/__test__/__snapshots__/TablePagination.spec.js.snap +2 -2
  164. package/src/components/TextArea/TextArea.vue +9 -13
  165. package/src/components/TextArea/__test__/__snapshots__/TextArea.spec.js.snap +2 -7
  166. package/src/components/index.ts +9 -58
  167. package/src/locales/en.json +1 -2
  168. package/src/locales/es.json +1 -2
  169. package/src/locales/pt_br.json +1 -2
  170. package/src/stories/Alert.stories.js +67 -6
  171. package/src/stories/Button.stories.js +17 -2
  172. package/src/stories/Checkbox.stories.js +4 -11
  173. package/src/stories/Icon.stories.js +15 -24
  174. package/src/stories/Input.stories.js +3 -16
  175. package/src/stories/Label.stories.js +0 -7
  176. package/src/stories/ModalDialog.mdx +0 -3
  177. package/src/stories/ModalDialog.stories.js +1 -1
  178. package/src/stories/Switch.stories.js +5 -10
  179. package/src/stories/Tab.stories.js +4 -11
  180. package/src/types/scheme-colors.d.ts +0 -1
  181. package/src/utils/call.js +18 -46
  182. package/dist/assets/tokens/iconSizeTokens.d.ts +0 -2
  183. package/dist/assets/tokens/iconSizeTokens.d.ts.map +0 -1
  184. package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts +0 -28
  185. package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts.map +0 -1
  186. package/dist/components/Toast/Toast.vue.d.ts +0 -16
  187. package/dist/components/Toast/Toast.vue.d.ts.map +0 -1
  188. package/dist/components/Toast/ToastManager.d.ts +0 -14
  189. package/dist/components/Toast/ToastManager.d.ts.map +0 -1
  190. package/dist/components/Toast/types.d.ts +0 -35
  191. package/dist/components/Toast/types.d.ts.map +0 -1
  192. package/dist/components/ui/dialog/Dialog.vue.d.ts +0 -23
  193. package/dist/components/ui/dialog/Dialog.vue.d.ts.map +0 -1
  194. package/dist/components/ui/dialog/DialogClose.vue.d.ts +0 -19
  195. package/dist/components/ui/dialog/DialogClose.vue.d.ts.map +0 -1
  196. package/dist/components/ui/dialog/DialogContent.vue.d.ts +0 -40
  197. package/dist/components/ui/dialog/DialogContent.vue.d.ts.map +0 -1
  198. package/dist/components/ui/dialog/DialogFooter.vue.d.ts +0 -25
  199. package/dist/components/ui/dialog/DialogFooter.vue.d.ts.map +0 -1
  200. package/dist/components/ui/dialog/DialogHeader.vue.d.ts +0 -29
  201. package/dist/components/ui/dialog/DialogHeader.vue.d.ts.map +0 -1
  202. package/dist/components/ui/dialog/DialogTitle.vue.d.ts +0 -23
  203. package/dist/components/ui/dialog/DialogTitle.vue.d.ts.map +0 -1
  204. package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +0 -19
  205. package/dist/components/ui/dialog/DialogTrigger.vue.d.ts.map +0 -1
  206. package/dist/components/ui/dialog/index.d.ts +0 -8
  207. package/dist/components/ui/dialog/index.d.ts.map +0 -1
  208. package/dist/components/ui/popover/Popover.vue.d.ts +0 -23
  209. package/dist/components/ui/popover/Popover.vue.d.ts.map +0 -1
  210. package/dist/components/ui/popover/PopoverContent.vue.d.ts +0 -43
  211. package/dist/components/ui/popover/PopoverContent.vue.d.ts.map +0 -1
  212. package/dist/components/ui/popover/PopoverTrigger.vue.d.ts +0 -19
  213. package/dist/components/ui/popover/PopoverTrigger.vue.d.ts.map +0 -1
  214. package/dist/components/ui/popover/index.d.ts +0 -5
  215. package/dist/components/ui/popover/index.d.ts.map +0 -1
  216. package/src/assets/icons/checkbox-checked-disabled.svg +0 -3
  217. package/src/assets/icons/checkbox-checked.svg +0 -3
  218. package/src/assets/icons/checkbox-less-disabled.svg +0 -3
  219. package/src/assets/icons/checkbox-less.svg +0 -3
  220. package/src/assets/icons/radio-checked.svg +0 -3
  221. package/src/assets/icons/switch-checked-disabled.svg +0 -3
  222. package/src/assets/icons/switch-checked.svg +0 -3
  223. package/src/assets/tokens/iconSizeTokens.ts +0 -10
  224. package/src/components/CheckboxGroup/CheckboxGroup.vue +0 -96
  225. package/src/components/Popover/__tests__/Popover.spec.js +0 -147
  226. package/src/components/Popover/__tests__/__snapshots__/Popover.spec.js.snap +0 -8
  227. package/src/components/Popover/index.vue +0 -146
  228. package/src/components/RadioGroup/RadioGroup.vue +0 -142
  229. package/src/components/Select/SelectOption.vue +0 -65
  230. package/src/components/Select/__tests__/Select.spec.js +0 -412
  231. package/src/components/Select/__tests__/SelectItem.spec.js +0 -330
  232. package/src/components/Select/__tests__/SelectOption.spec.js +0 -174
  233. package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +0 -97
  234. package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +0 -15
  235. package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +0 -25
  236. package/src/components/Select/index.vue +0 -245
  237. package/src/components/Toast/Toast.vue +0 -246
  238. package/src/components/Toast/ToastManager.ts +0 -110
  239. package/src/components/Toast/__tests__/Toast.spec.js +0 -284
  240. package/src/components/Toast/__tests__/ToastManager.spec.js +0 -294
  241. package/src/components/Toast/types.ts +0 -57
  242. package/src/components/ui/dialog/Dialog.vue +0 -15
  243. package/src/components/ui/dialog/DialogClose.vue +0 -25
  244. package/src/components/ui/dialog/DialogContent.vue +0 -114
  245. package/src/components/ui/dialog/DialogFooter.vue +0 -46
  246. package/src/components/ui/dialog/DialogHeader.vue +0 -78
  247. package/src/components/ui/dialog/DialogTitle.vue +0 -34
  248. package/src/components/ui/dialog/DialogTrigger.vue +0 -12
  249. package/src/components/ui/dialog/index.ts +0 -7
  250. package/src/components/ui/popover/Popover.vue +0 -19
  251. package/src/components/ui/popover/PopoverContent.vue +0 -98
  252. package/src/components/ui/popover/PopoverTrigger.vue +0 -23
  253. package/src/components/ui/popover/index.ts +0 -4
  254. package/src/stories/CheckboxGroup.stories.js +0 -105
  255. package/src/stories/Dialog.stories.js +0 -832
  256. package/src/stories/Popover.stories.js +0 -306
  257. package/src/stories/RadioGroup.stories.js +0 -144
  258. package/src/stories/Select.stories.js +0 -158
  259. package/src/stories/Toast.mdx +0 -123
  260. package/src/stories/Toast.stories.js +0 -126
@@ -1,284 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import { beforeEach, describe, expect, afterEach, test, vi } from 'vitest';
3
- import Toast from '../Toast.vue';
4
-
5
- describe('UnnnicToast', () => {
6
- let wrapper;
7
- let mockAction;
8
-
9
- beforeEach(() => {
10
- mockAction = vi.fn();
11
- vi.useFakeTimers();
12
-
13
- wrapper = shallowMount(Toast, {
14
- props: {
15
- title: 'Test Toast',
16
- },
17
- global: {
18
- stubs: {
19
- Transition: {
20
- template: '<div data-testid="toast-transition"><slot /></div>',
21
- },
22
- },
23
- },
24
- });
25
- });
26
-
27
- afterEach(() => {
28
- if (wrapper) {
29
- wrapper.unmount();
30
- }
31
- vi.useRealTimers();
32
- vi.clearAllMocks();
33
- });
34
-
35
- const transition = () =>
36
- wrapper.findComponent('[data-testid="toast-transition"]');
37
- const toast = () => wrapper.find('[data-testid="toast"]');
38
- const content = () => wrapper.find('[data-testid="toast-content"]');
39
- const header = () => wrapper.find('[data-testid="toast-header"]');
40
- const title = () => wrapper.find('[data-testid="toast-title"]');
41
- const text = () => wrapper.find('[data-testid="toast-text"]');
42
- const actionButton = () =>
43
- wrapper.findComponent('[data-testid="toast-action-button"]');
44
- const closeIcon = () =>
45
- wrapper.findComponent('[data-testid="toast-close-icon"]');
46
- const typeIcon = () =>
47
- wrapper.findComponent('[data-testid="toast-type-icon"]');
48
-
49
- describe('Rendering', () => {
50
- test('renders correctly with required props', () => {
51
- expect(transition().exists()).toBe(true);
52
- expect(header().exists()).toBe(true);
53
-
54
- expect(typeIcon().exists()).toBe(true);
55
- expect(typeIcon().props('icon')).toBe('info');
56
- expect(typeIcon().props('scheme')).toBe('blue-500');
57
- expect(typeIcon().props('size')).toBe('ant');
58
-
59
- expect(title().exists()).toBe(true);
60
- expect(title().text()).toBe('Test Toast');
61
-
62
- expect(text().exists()).toBe(false);
63
-
64
- expect(toast().exists()).toBe(true);
65
- expect(content().exists()).toBe(true);
66
- expect(actionButton().exists()).toBe(false);
67
-
68
- expect(closeIcon().exists()).toBe(true);
69
- expect(closeIcon().props('icon')).toBe('close');
70
- expect(closeIcon().props('scheme')).toBe('neutral-dark');
71
- expect(closeIcon().props('size')).toBe('ant');
72
- expect(closeIcon().props('clickable')).toBe(true);
73
- });
74
-
75
- test('renders description when provided', async () => {
76
- await wrapper.setProps({ description: 'Test description' });
77
-
78
- expect(text().exists()).toBe(true);
79
- expect(text().text()).toBe('Test description');
80
- });
81
-
82
- test('applies correct CSS class based on type', async () => {
83
- const types = ['informational', 'attention', 'success', 'error'];
84
-
85
- for (const type of types) {
86
- await wrapper.setProps({ type });
87
-
88
- expect(toast().classes()).toContain(`unnnic-toast--${type}`);
89
- }
90
- });
91
-
92
- test('sets correct ARIA attributes for different types', async () => {
93
- // Error type
94
- await wrapper.setProps({ type: 'error' });
95
- expect(toast().attributes('role')).toBe('alert');
96
- expect(toast().attributes('aria-live')).toBe('assertive');
97
-
98
- // Other types
99
- await wrapper.setProps({ type: 'informational' });
100
- expect(toast().attributes('role')).toBe('status');
101
- expect(toast().attributes('aria-live')).toBe('polite');
102
- });
103
- });
104
-
105
- describe('Icon Configuration', () => {
106
- test('displays correct icon for each type', async () => {
107
- const typeConfigs = [
108
- { type: 'informational', expectedIcon: 'info' },
109
- { type: 'attention', expectedIcon: 'error' },
110
- { type: 'success', expectedIcon: 'check_circle' },
111
- { type: 'error', expectedIcon: 'cancel' },
112
- ];
113
-
114
- for (const { type, expectedIcon } of typeConfigs) {
115
- await wrapper.setProps({ type });
116
- const icon = typeIcon();
117
- expect(icon.props('icon')).toBe(expectedIcon);
118
- }
119
- });
120
-
121
- test('displays correct scheme color for each type', async () => {
122
- const typeConfigs = [
123
- { type: 'informational', expectedScheme: 'blue-500' },
124
- { type: 'attention', expectedScheme: 'yellow-500' },
125
- { type: 'success', expectedScheme: 'green-500' },
126
- { type: 'error', expectedScheme: 'red-500' },
127
- ];
128
-
129
- for (const { type, expectedScheme } of typeConfigs) {
130
- await wrapper.setProps({ type });
131
- const icon = typeIcon();
132
- expect(icon.props('scheme')).toBe(expectedScheme);
133
- }
134
- });
135
- });
136
-
137
- describe('Close Functionality', () => {
138
- test('emits close event when close button is clicked', async () => {
139
- const closeButton = closeIcon();
140
- await closeButton.trigger('click');
141
-
142
- expect(wrapper.emitted('close')).toBeTruthy();
143
- expect(wrapper.emitted('close')).toHaveLength(1);
144
-
145
- expect(wrapper.vm.isVisible).toBe(false);
146
- });
147
-
148
- test('emits close event when close button is activated with Enter key', async () => {
149
- const closeButton = closeIcon();
150
- await closeButton.trigger('keydown.enter');
151
-
152
- expect(wrapper.emitted('close')).toBeTruthy();
153
- expect(wrapper.emitted('close')).toHaveLength(1);
154
-
155
- expect(wrapper.vm.isVisible).toBe(false);
156
- });
157
-
158
- test('hides toast when close is triggered', async () => {
159
- expect(toast().exists()).toBe(true);
160
-
161
- await wrapper.vm.handleClose();
162
- await wrapper.vm.$nextTick();
163
-
164
- expect(toast().exists()).toBe(false);
165
- });
166
- });
167
-
168
- describe('Action Button', () => {
169
- test('renders action button when provided', async () => {
170
- await wrapper.setProps({
171
- button: {
172
- text: 'Action',
173
- action: mockAction,
174
- },
175
- });
176
-
177
- expect(actionButton().exists()).toBe(true);
178
- expect(actionButton().props('text')).toBe('Action');
179
- });
180
-
181
- test('does not render action button when not provided', async () => {
182
- expect(actionButton().exists()).toBe(false);
183
- });
184
-
185
- test('calls action function when action button is clicked', async () => {
186
- await wrapper.setProps({
187
- button: {
188
- text: 'Action',
189
- action: mockAction,
190
- },
191
- });
192
-
193
- await actionButton().trigger('click');
194
-
195
- expect(mockAction).toHaveBeenCalledTimes(1);
196
- });
197
-
198
- test('calls action function when action button is activated with Enter key', async () => {
199
- await wrapper.setProps({
200
- button: {
201
- text: 'Action',
202
- action: mockAction,
203
- },
204
- });
205
-
206
- await actionButton().trigger('keydown.enter');
207
-
208
- expect(mockAction).toHaveBeenCalledTimes(1);
209
- });
210
-
211
- test('does not throw error when action button has no action function', async () => {
212
- await wrapper.setProps({
213
- button: {
214
- text: 'Action',
215
- action: undefined,
216
- },
217
- });
218
-
219
- expect(async () => {
220
- await actionButton().trigger('click');
221
- }).not.toThrow();
222
- });
223
- });
224
-
225
- describe('Timeout Functionality', () => {
226
- const createTimeoutWrapper = (timeout = 1000) => {
227
- return shallowMount(Toast, {
228
- props: { title: 'Test Toast', timeout },
229
- });
230
- };
231
-
232
- test('auto-closes after timeout period', async () => {
233
- wrapper = createTimeoutWrapper();
234
- vi.advanceTimersByTime(1000);
235
-
236
- await wrapper.vm.$nextTick();
237
- expect(wrapper.emitted('close')).toBeTruthy();
238
- });
239
-
240
- test('does not auto-close when timeout is 0', async () => {
241
- wrapper = createTimeoutWrapper(0);
242
- vi.advanceTimersByTime(5000);
243
-
244
- await wrapper.vm.$nextTick();
245
- expect(wrapper.emitted('close')).toBeFalsy();
246
- });
247
-
248
- test('does not auto-close when timeout is negative', async () => {
249
- wrapper = createTimeoutWrapper(-1);
250
- vi.advanceTimersByTime(5000);
251
-
252
- await wrapper.vm.$nextTick();
253
- expect(wrapper.emitted('close')).toBeFalsy();
254
- });
255
-
256
- test('clears timeout when component is unmounted', () => {
257
- const clearTimeoutSpy = vi.spyOn(window, 'clearTimeout');
258
- wrapper = createTimeoutWrapper();
259
-
260
- wrapper.unmount();
261
- expect(clearTimeoutSpy).toHaveBeenCalled();
262
- });
263
- });
264
-
265
- describe('Transitions', () => {
266
- test('emits destroy event after leave transition', async () => {
267
- await wrapper.vm.handleClose();
268
- await wrapper.vm.$nextTick();
269
-
270
- await transition().vm.$emit('after-leave');
271
-
272
- expect(wrapper.emitted('destroy')).toBeTruthy();
273
- });
274
- });
275
-
276
- describe('Default Props', () => {
277
- test('uses correct default values', () => {
278
- expect(wrapper.props('description')).toBe('');
279
- expect(wrapper.props('button')).toBeUndefined();
280
- expect(wrapper.props('timeout')).toBe(5000);
281
- expect(wrapper.props('type')).toBe('informational');
282
- });
283
- });
284
- });
@@ -1,294 +0,0 @@
1
- import { beforeEach, describe, expect, afterEach, test, vi } from 'vitest';
2
-
3
- vi.mock('vue', () => ({
4
- createApp: vi.fn(() => ({
5
- mount: vi.fn(),
6
- unmount: vi.fn(),
7
- })),
8
- }));
9
-
10
- vi.mock('../Toast.vue', () => ({
11
- default: {
12
- name: 'Toast',
13
- template: '<div data-testid="toast">Mock Toast</div>',
14
- },
15
- }));
16
-
17
- import toastManager, { toast } from '../ToastManager';
18
- import Toast from '../Toast.vue';
19
-
20
- describe('ToastManager', () => {
21
- let mockCreateApp;
22
- let mockMount;
23
- let mockUnmount;
24
-
25
- beforeEach(async () => {
26
- vi.clearAllMocks();
27
-
28
- document.body.innerHTML = '';
29
-
30
- const { createApp } = await import('vue');
31
- mockCreateApp = createApp;
32
- mockMount = vi.fn();
33
- mockUnmount = vi.fn();
34
-
35
- mockCreateApp.mockReturnValue({
36
- mount: mockMount,
37
- unmount: mockUnmount,
38
- });
39
-
40
- Object.defineProperty(globalThis, 'document', {
41
- value: {
42
- ...document,
43
- createElement: vi.fn((tagName) => {
44
- const element = {
45
- tagName: tagName.toUpperCase(),
46
- setAttribute: vi.fn(),
47
- appendChild: vi.fn(),
48
- remove: vi.fn(),
49
- children: [],
50
- parentNode: null,
51
- };
52
-
53
- if (tagName === 'div') {
54
- element.appendChild = vi.fn((child) => {
55
- child.parentNode = element;
56
- element.children.push(child);
57
- });
58
- }
59
-
60
- return element;
61
- }),
62
- body: {
63
- ...document.body,
64
- appendChild: vi.fn(),
65
- },
66
- },
67
- writable: true,
68
- });
69
- });
70
-
71
- afterEach(() => {
72
- if (toastManager.toasts) {
73
- toastManager.toasts.clear();
74
- }
75
-
76
- document.body.innerHTML = '';
77
-
78
- vi.clearAllMocks();
79
- });
80
-
81
- describe('Container Management', () => {
82
- test('creates container on first toast', () => {
83
- const createElementSpy = vi.spyOn(document, 'createElement');
84
- const appendChildSpy = vi.spyOn(document.body, 'appendChild');
85
-
86
- toastManager.show({ title: 'Test Toast' });
87
-
88
- expect(createElementSpy).toHaveBeenCalledWith('div');
89
- expect(appendChildSpy).toHaveBeenCalled();
90
- });
91
-
92
- test('reuses existing container', () => {
93
- const createElementSpy = vi.spyOn(document, 'createElement');
94
-
95
- toastManager.show({ title: 'First Toast' });
96
- const firstCallCount = createElementSpy.mock.calls.length;
97
-
98
- toastManager.show({ title: 'Second Toast' });
99
- const secondCallCount = createElementSpy.mock.calls.length;
100
-
101
- // First toast: container div + wrapper div = 2 calls
102
- // Second toast: only wrapper div = 1 more call
103
- // Total: 3 calls (1 container + 2 wrappers)
104
- expect(secondCallCount).toBe(firstCallCount + 1);
105
-
106
- expect(createElementSpy).toHaveBeenCalledWith('div');
107
- });
108
- });
109
-
110
- describe('Toast Instance Management', () => {
111
- test('generates unique IDs for toasts', () => {
112
- const toast1 = toastManager.show({ title: 'First Toast' });
113
- const toast2 = toastManager.show({ title: 'Second Toast' });
114
-
115
- expect(toast1.id).not.toBe(toast2.id);
116
- expect(toast1.id).toMatch(/^toast-\d+$/);
117
- expect(toast2.id).toMatch(/^toast-\d+$/);
118
- });
119
-
120
- test('stores toast instances in map', () => {
121
- const toast1 = toastManager.show({ title: 'First Toast' });
122
- const toast2 = toastManager.show({ title: 'Second Toast' });
123
-
124
- expect(toastManager.toasts.has(toast1.id)).toBe(true);
125
- expect(toastManager.toasts.has(toast2.id)).toBe(true);
126
- expect(toastManager.toasts.size).toBe(2);
127
- });
128
-
129
- test('creates toast with correct props', () => {
130
- const props = {
131
- title: 'Test Toast',
132
- description: 'Test Description',
133
- type: 'success',
134
- timeout: 3000,
135
- };
136
-
137
- toastManager.show(props);
138
-
139
- expect(mockCreateApp).toHaveBeenCalledWith(
140
- Toast,
141
- expect.objectContaining({
142
- title: 'Test Toast',
143
- description: 'Test Description',
144
- type: 'success',
145
- timeout: 3000,
146
- onClose: expect.any(Function),
147
- onDestroy: expect.any(Function),
148
- }),
149
- );
150
- });
151
-
152
- test('mounts toast app to wrapper element', () => {
153
- toastManager.show({ title: 'Test Toast' });
154
-
155
- expect(mockMount).toHaveBeenCalled();
156
- });
157
- });
158
-
159
- describe('Toast Close Functionality', () => {
160
- test('removes toast from map when closed', () => {
161
- const toastInstance = toastManager.show({ title: 'Test Toast' });
162
-
163
- expect(toastManager.toasts.has(toastInstance.id)).toBe(true);
164
-
165
- toastManager.close(toastInstance.id);
166
-
167
- expect(toastManager.toasts.has(toastInstance.id)).toBe(false);
168
- });
169
-
170
- test('handles closing non-existent toast gracefully', () => {
171
- expect(() => {
172
- toastManager.close('non-existent-id');
173
- }).not.toThrow();
174
- });
175
-
176
- test('calls close when onClose is triggered', () => {
177
- const closeSpy = vi.spyOn(toastManager, 'close');
178
-
179
- toastManager.show({ title: 'Test Toast' });
180
-
181
- const createAppCall = mockCreateApp.mock.calls[0];
182
- const props = createAppCall[1];
183
- const onCloseCallback = props.onClose;
184
-
185
- onCloseCallback();
186
-
187
- expect(closeSpy).toHaveBeenCalled();
188
- });
189
- });
190
-
191
- describe('Toast Destroy Functionality', () => {
192
- test('unmounts app and removes wrapper on destroy', () => {
193
- toastManager.show({ title: 'Test Toast' });
194
-
195
- const createAppCall = mockCreateApp.mock.calls[0];
196
- const props = createAppCall[1];
197
- const onDestroyCallback = props.onDestroy;
198
-
199
- onDestroyCallback();
200
-
201
- expect(mockUnmount).toHaveBeenCalled();
202
- });
203
-
204
- test('resolves promise when toast is destroyed', async () => {
205
- const toastInstance = toastManager.show({ title: 'Test Toast' });
206
-
207
- const createAppCall = mockCreateApp.mock.calls[0];
208
- const props = createAppCall[1];
209
- const onDestroyCallback = props.onDestroy;
210
-
211
- const promiseResolved = vi.fn();
212
- toastInstance.promise.then(promiseResolved);
213
-
214
- onDestroyCallback();
215
-
216
- await new Promise((resolve) => setTimeout(resolve, 0));
217
-
218
- expect(promiseResolved).toHaveBeenCalled();
219
- });
220
- });
221
-
222
- describe('Toast API', () => {
223
- beforeEach(() => {
224
- vi.spyOn(toastManager, 'show').mockReturnValue({
225
- id: 'mock-id',
226
- props: {},
227
- close: vi.fn(),
228
- promise: Promise.resolve(),
229
- });
230
- });
231
-
232
- test('toast.info creates informational toast', () => {
233
- toast.info('Info Title', 'Info Description', { timeout: 1000 });
234
-
235
- expect(toastManager.show).toHaveBeenCalledWith({
236
- title: 'Info Title',
237
- description: 'Info Description',
238
- timeout: 1000,
239
- type: 'informational',
240
- });
241
- });
242
-
243
- test('toast.success creates success toast', () => {
244
- toast.success('Success Title', 'Success Description');
245
-
246
- expect(toastManager.show).toHaveBeenCalledWith({
247
- title: 'Success Title',
248
- description: 'Success Description',
249
- type: 'success',
250
- });
251
- });
252
-
253
- test('toast.attention creates attention toast', () => {
254
- toast.attention('Attention Title');
255
-
256
- expect(toastManager.show).toHaveBeenCalledWith({
257
- title: 'Attention Title',
258
- type: 'attention',
259
- });
260
- });
261
-
262
- test('toast.error creates error toast', () => {
263
- toast.error('Error Title', 'Error Description', {
264
- button: { text: 'Retry', action: vi.fn() },
265
- });
266
-
267
- expect(toastManager.show).toHaveBeenCalledWith({
268
- title: 'Error Title',
269
- description: 'Error Description',
270
- button: { text: 'Retry', action: expect.any(Function) },
271
- type: 'error',
272
- });
273
- });
274
-
275
- test('toast methods return promises', async () => {
276
- const infoPromise = toast.info('Test');
277
- const successPromise = toast.success('Test');
278
- const attentionPromise = toast.attention('Test');
279
- const errorPromise = toast.error('Test');
280
-
281
- expect(infoPromise).toBeInstanceOf(Promise);
282
- expect(successPromise).toBeInstanceOf(Promise);
283
- expect(attentionPromise).toBeInstanceOf(Promise);
284
- expect(errorPromise).toBeInstanceOf(Promise);
285
-
286
- await Promise.all([
287
- infoPromise,
288
- successPromise,
289
- attentionPromise,
290
- errorPromise,
291
- ]);
292
- });
293
- });
294
- });
@@ -1,57 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
1
- <script setup lang="ts">
2
- import type { DialogRootEmits, DialogRootProps } from 'reka-ui';
3
- import { DialogRoot, useForwardPropsEmits } from 'reka-ui';
4
-
5
- const props = defineProps<DialogRootProps>();
6
- const emits = defineEmits<DialogRootEmits>();
7
-
8
- const forwarded = useForwardPropsEmits(props, emits);
9
- </script>
10
-
11
- <template>
12
- <DialogRoot v-bind="forwarded">
13
- <slot />
14
- </DialogRoot>
15
- </template>
@@ -1,25 +0,0 @@
1
- <script setup lang="ts">
2
- import type { DialogCloseProps } from 'reka-ui';
3
- import { DialogClose } from 'reka-ui';
4
-
5
- const props = defineProps<DialogCloseProps>();
6
- </script>
7
-
8
- <template>
9
- <DialogClose
10
- class="unnnic-dialog-close"
11
- v-bind="props"
12
- >
13
- <slot />
14
- </DialogClose>
15
- </template>
16
-
17
- <style lang="scss" scoped>
18
- @use '@/assets/scss/unnnic' as *;
19
-
20
- .unnnic-dialog-close {
21
- > * {
22
- width: 100%;
23
- }
24
- }
25
- </style>