@weni/unnnic-system 3.11.3-alpha.2 → 3.12.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 (166) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/components/Alert/Alert.vue.d.ts +3 -3
  3. package/dist/components/Alert/Version1dot1.vue.d.ts +1 -1
  4. package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +18 -109
  5. package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +36 -218
  6. package/dist/components/AvatarIcon/AvatarIcon.vue.d.ts +1 -1
  7. package/dist/components/Button/Button.vue.d.ts +2 -2
  8. package/dist/components/Card/AccountCard.vue.d.ts +2 -2
  9. package/dist/components/Card/Card.vue.d.ts +29 -120
  10. package/dist/components/Card/CardCompany.vue.d.ts +2 -2
  11. package/dist/components/Card/CardStatusesContainer.vue.d.ts +19 -110
  12. package/dist/components/Card/ContentCard.vue.d.ts +1 -1
  13. package/dist/components/Card/DashCard.vue.d.ts +2 -2
  14. package/dist/components/Card/DefaultCard.vue.d.ts +1 -1
  15. package/dist/components/Card/MarketplaceCard.vue.d.ts +1 -1
  16. package/dist/components/Card/SimpleCard.vue.d.ts +18 -109
  17. package/dist/components/Card/StatusCard.vue.d.ts +1 -1
  18. package/dist/components/Card/TitleCard.vue.d.ts +18 -109
  19. package/dist/components/CardImage/CardImage.vue.d.ts +5 -5
  20. package/dist/components/CardInformation/CardInformation.vue.d.ts +19 -110
  21. package/dist/components/CardProject/CardProject.vue.d.ts +2 -2
  22. package/dist/components/Carousel/Carousel.vue.d.ts +2 -2
  23. package/dist/components/Carousel/TagCarousel.vue.d.ts +2 -2
  24. package/dist/components/ChartBar/ChartBar.vue.d.ts +24 -115
  25. package/dist/components/ChartLine/ChartLine.vue.d.ts +18 -109
  26. package/dist/components/ChatText/ChatText.vue.d.ts +18 -109
  27. package/dist/components/ChatsContact/ChatsContact.vue.d.ts +6 -6
  28. package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +18 -109
  29. package/dist/components/ChatsUserAvatar/ChatsUserAvatar.vue.d.ts +1 -1
  30. package/dist/components/Checkbox/Checkbox.vue.d.ts +3 -3
  31. package/dist/components/DataArea/DataArea.vue.d.ts +18 -109
  32. package/dist/components/DataTable/index.vue.d.ts +1 -1
  33. package/dist/components/DataTable/index.vue.d.ts.map +1 -1
  34. package/dist/components/DateFilter/DateFilter.vue.d.ts +10 -10
  35. package/dist/components/Drawer/Drawer.vue.d.ts +207 -37
  36. package/dist/components/Drawer/Drawer.vue.d.ts.map +1 -1
  37. package/dist/components/Dropdown/Dropdown.vue.d.ts +1 -1
  38. package/dist/components/FormElement/FormElement.vue.d.ts +4 -4
  39. package/dist/components/ImportCard/ImportCard.vue.d.ts +6 -6
  40. package/dist/components/Input/Input.vue.d.ts +9 -9
  41. package/dist/components/Input/TextInput.vue.d.ts +2 -2
  42. package/dist/components/InputNext/InputNext.vue.d.ts +3 -3
  43. package/dist/components/Modal/Modal.vue.d.ts +1 -1
  44. package/dist/components/ModalDialog/ModalDialog.vue.d.ts +35 -209
  45. package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
  46. package/dist/components/ModalNext/ModalNext.vue.d.ts +15 -15
  47. package/dist/components/ModalUpload/ModalUpload.vue.d.ts +12 -12
  48. package/dist/components/MoodRating/MoodRating.vue.d.ts +18 -109
  49. package/dist/components/MultiSelect/MultiSelect.vue.d.ts +18 -18
  50. package/dist/components/Pagination/Pagination.vue.d.ts +6 -6
  51. package/dist/components/Radio/Radio.vue.d.ts +6 -6
  52. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +11 -11
  53. package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +2 -2
  54. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +5 -5
  55. package/dist/components/SelectTime/index.vue.d.ts +3 -3
  56. package/dist/components/Slider/Slider.vue.d.ts +18 -109
  57. package/dist/components/Switch/Switch.vue.d.ts +2 -2
  58. package/dist/components/Tab/Tab.vue.d.ts +18 -109
  59. package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
  60. package/dist/components/TableNext/TablePagination.vue.d.ts +6 -6
  61. package/dist/components/Tag/DefaultTag.vue.d.ts +1 -1
  62. package/dist/components/Tag/Tag.vue.d.ts +2 -2
  63. package/dist/components/TextArea/TextArea.vue.d.ts +5 -5
  64. package/dist/components/Toast/Toast.vue.d.ts +1 -1
  65. package/dist/components/Toast/Toast.vue.d.ts.map +1 -1
  66. package/dist/components/ToolTip/ToolTip.vue.d.ts +18 -109
  67. package/dist/components/ToolTip/ToolTip.vue.d.ts.map +1 -1
  68. package/dist/components/Tour/Tour.vue.d.ts +6 -6
  69. package/dist/components/Tour/TourPopover.vue.d.ts +6 -6
  70. package/dist/components/UploadArea/UploadArea.vue.d.ts +6 -6
  71. package/dist/components/ui/popover/PopoverContent.vue.d.ts +2 -2
  72. package/dist/components/ui/popover/PopoverContent.vue.d.ts.map +1 -1
  73. package/dist/{es-99b102dc.mjs → es-9756db6d.mjs} +1 -1
  74. package/dist/{index-c20fa852.mjs → index-ab280280.mjs} +51987 -54801
  75. package/dist/{pt-br-b17e69b4.mjs → pt-br-55135cbc.mjs} +1 -1
  76. package/dist/style.css +1 -1
  77. package/dist/unnnic.mjs +203 -231
  78. package/dist/unnnic.umd.js +44 -48
  79. package/package.json +1 -2
  80. package/src/assets/scss/tailwind.scss +0 -8
  81. package/src/components/Drawer/Drawer.vue +269 -190
  82. package/src/components/Drawer/__tests__/Drawer.spec.js +46 -37
  83. package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +19 -18
  84. package/src/components/ModalDialog/ModalDialog.vue +148 -64
  85. package/src/components/ModalDialog/__tests__/ModalDialog.spec.js +221 -11
  86. package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +22 -1
  87. package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -3
  88. package/src/components/Toast/Toast.vue +8 -12
  89. package/src/components/ToolTip/ToolTip.vue +188 -41
  90. package/src/components/ToolTip/__tests__/ToolTip.spec.js +61 -345
  91. package/src/components/index.ts +19 -75
  92. package/src/components/ui/popover/PopoverContent.vue +2 -0
  93. package/src/stories/Drawer.stories.js +1 -1
  94. package/src/stories/ModalDialog.mdx +0 -3
  95. package/src/stories/ModalDialog.stories.js +1 -1
  96. package/dist/components/ui/dialog/Dialog.vue.d.ts +0 -23
  97. package/dist/components/ui/dialog/Dialog.vue.d.ts.map +0 -1
  98. package/dist/components/ui/dialog/DialogClose.vue.d.ts +0 -19
  99. package/dist/components/ui/dialog/DialogClose.vue.d.ts.map +0 -1
  100. package/dist/components/ui/dialog/DialogContent.vue.d.ts +0 -43
  101. package/dist/components/ui/dialog/DialogContent.vue.d.ts.map +0 -1
  102. package/dist/components/ui/dialog/DialogFooter.vue.d.ts +0 -25
  103. package/dist/components/ui/dialog/DialogFooter.vue.d.ts.map +0 -1
  104. package/dist/components/ui/dialog/DialogHeader.vue.d.ts +0 -29
  105. package/dist/components/ui/dialog/DialogHeader.vue.d.ts.map +0 -1
  106. package/dist/components/ui/dialog/DialogTitle.vue.d.ts +0 -23
  107. package/dist/components/ui/dialog/DialogTitle.vue.d.ts.map +0 -1
  108. package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +0 -19
  109. package/dist/components/ui/dialog/DialogTrigger.vue.d.ts.map +0 -1
  110. package/dist/components/ui/dialog/index.d.ts +0 -8
  111. package/dist/components/ui/dialog/index.d.ts.map +0 -1
  112. package/dist/components/ui/drawer/Drawer.vue.d.ts +0 -35
  113. package/dist/components/ui/drawer/Drawer.vue.d.ts.map +0 -1
  114. package/dist/components/ui/drawer/DrawerClose.vue.d.ts +0 -19
  115. package/dist/components/ui/drawer/DrawerClose.vue.d.ts.map +0 -1
  116. package/dist/components/ui/drawer/DrawerContent.vue.d.ts +0 -42
  117. package/dist/components/ui/drawer/DrawerContent.vue.d.ts.map +0 -1
  118. package/dist/components/ui/drawer/DrawerDescription.vue.d.ts +0 -23
  119. package/dist/components/ui/drawer/DrawerDescription.vue.d.ts.map +0 -1
  120. package/dist/components/ui/drawer/DrawerFooter.vue.d.ts +0 -22
  121. package/dist/components/ui/drawer/DrawerFooter.vue.d.ts.map +0 -1
  122. package/dist/components/ui/drawer/DrawerHeader.vue.d.ts +0 -25
  123. package/dist/components/ui/drawer/DrawerHeader.vue.d.ts.map +0 -1
  124. package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts +0 -8
  125. package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts.map +0 -1
  126. package/dist/components/ui/drawer/DrawerTitle.vue.d.ts +0 -23
  127. package/dist/components/ui/drawer/DrawerTitle.vue.d.ts.map +0 -1
  128. package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts +0 -19
  129. package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts.map +0 -1
  130. package/dist/components/ui/drawer/index.d.ts +0 -11
  131. package/dist/components/ui/drawer/index.d.ts.map +0 -1
  132. package/dist/components/ui/tooltip/Tooltip.vue.d.ts +0 -23
  133. package/dist/components/ui/tooltip/Tooltip.vue.d.ts.map +0 -1
  134. package/dist/components/ui/tooltip/TooltipContent.vue.d.ts +0 -31
  135. package/dist/components/ui/tooltip/TooltipContent.vue.d.ts.map +0 -1
  136. package/dist/components/ui/tooltip/TooltipProvider.vue.d.ts +0 -19
  137. package/dist/components/ui/tooltip/TooltipProvider.vue.d.ts.map +0 -1
  138. package/dist/components/ui/tooltip/TooltipTrigger.vue.d.ts +0 -19
  139. package/dist/components/ui/tooltip/TooltipTrigger.vue.d.ts.map +0 -1
  140. package/dist/components/ui/tooltip/index.d.ts +0 -5
  141. package/dist/components/ui/tooltip/index.d.ts.map +0 -1
  142. package/src/components/ui/dialog/Dialog.vue +0 -19
  143. package/src/components/ui/dialog/DialogClose.vue +0 -29
  144. package/src/components/ui/dialog/DialogContent.vue +0 -134
  145. package/src/components/ui/dialog/DialogFooter.vue +0 -50
  146. package/src/components/ui/dialog/DialogHeader.vue +0 -83
  147. package/src/components/ui/dialog/DialogTitle.vue +0 -38
  148. package/src/components/ui/dialog/DialogTrigger.vue +0 -16
  149. package/src/components/ui/dialog/index.ts +0 -7
  150. package/src/components/ui/drawer/Drawer.vue +0 -27
  151. package/src/components/ui/drawer/DrawerClose.vue +0 -37
  152. package/src/components/ui/drawer/DrawerContent.vue +0 -101
  153. package/src/components/ui/drawer/DrawerDescription.vue +0 -40
  154. package/src/components/ui/drawer/DrawerFooter.vue +0 -38
  155. package/src/components/ui/drawer/DrawerHeader.vue +0 -57
  156. package/src/components/ui/drawer/DrawerOverlay.vue +0 -33
  157. package/src/components/ui/drawer/DrawerTitle.vue +0 -37
  158. package/src/components/ui/drawer/DrawerTrigger.vue +0 -31
  159. package/src/components/ui/drawer/index.ts +0 -10
  160. package/src/components/ui/tooltip/Tooltip.vue +0 -15
  161. package/src/components/ui/tooltip/TooltipContent.vue +0 -73
  162. package/src/components/ui/tooltip/TooltipProvider.vue +0 -15
  163. package/src/components/ui/tooltip/TooltipTrigger.vue +0 -22
  164. package/src/components/ui/tooltip/index.ts +0 -4
  165. package/src/stories/Dialog.stories.js +0 -832
  166. package/src/stories/DrawerNext.stories.js +0 -610
@@ -1,5 +1,5 @@
1
1
  import { mount } from '@vue/test-utils';
2
- import { describe, it } from 'vitest';
2
+ import { describe, it, vi } from 'vitest';
3
3
  import ModalDialog from '../ModalDialog.vue';
4
4
 
5
5
  describe('ModalDialog.vue', () => {
@@ -16,12 +16,7 @@ describe('ModalDialog.vue', () => {
16
16
  'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }),
17
17
  },
18
18
  global: {
19
- stubs: [
20
- 'teleport',
21
- 'UnnnicIcon',
22
- 'UnnnicButton',
23
- 'UnnnicDialogContent',
24
- ],
19
+ stubs: ['UnnnicIcon', 'UnnnicButton'],
25
20
  },
26
21
  });
27
22
  });
@@ -31,16 +26,231 @@ describe('ModalDialog.vue', () => {
31
26
  expect(wrapper.html()).toMatchSnapshot();
32
27
  });
33
28
 
29
+ it('should render correctly when modelValue is true', () => {
30
+ const modal = wrapper.find('[data-testid="modal-dialog"]');
31
+ expect(modal.exists()).toBe(true);
32
+ });
33
+
34
+ it('should not render when modelValue is false', async () => {
35
+ await wrapper.setProps({ modelValue: false });
36
+
37
+ const modal = wrapper.find('[data-testid="modal-dialog"]');
38
+ expect(modal.exists()).toBe(false);
39
+ });
40
+
34
41
  it('should apply the correct size class based on the size prop', async () => {
35
- const modalContainer = wrapper.find('[data-testid="modal-dialog"]');
42
+ const modalContainer = wrapper.find('[data-testid="modal-container"]');
43
+ const defaultClass = 'unnnic-modal-dialog__container';
36
44
 
37
- expect(modalContainer.attributes('size')).toContain('medium');
45
+ expect(modalContainer.classes()).toContain(defaultClass + '--md');
38
46
 
39
47
  await wrapper.setProps({ size: 'lg' });
40
- expect(modalContainer.attributes('size')).toContain('large');
48
+ expect(modalContainer.classes()).toContain(defaultClass + '--lg');
41
49
 
42
50
  await wrapper.setProps({ size: 'sm' });
43
- expect(modalContainer.attributes('size')).toContain('small');
51
+ expect(modalContainer.classes()).toContain(defaultClass + '--sm');
52
+ });
53
+
54
+ it('should render the icon and title when provided', () => {
55
+ const title = wrapper.find('[data-testid="title-text"]');
56
+ expect(title.exists()).toBe(true);
57
+ expect(title.text()).toBe('Test Title');
58
+
59
+ const icon = wrapper.findComponent('[data-testid="title-icon"]');
60
+ expect(icon.exists()).toBe(true);
61
+ expect(icon.props('icon')).toBe('test-icon');
62
+ });
63
+
64
+ it('should render the icon from iconsMapper when type prop is provided', async () => {
65
+ await wrapper.setProps({
66
+ type: 'success',
67
+ icon: '',
68
+ });
69
+
70
+ const icon = wrapper.findComponent('[data-testid="title-icon"]');
71
+ expect(icon.exists()).toBe(true);
72
+ expect(icon.props().icon).toBe(wrapper.vm.iconsMapper['success'].icon);
73
+ });
74
+
75
+ it('should not render the icon when both icon and type props are not provided', async () => {
76
+ await wrapper.setProps({
77
+ icon: '',
78
+ type: '',
79
+ });
80
+
81
+ const icon = wrapper.find('[data-testid="title-icon"]');
82
+ expect(icon.exists()).toBe(false);
83
+ });
84
+
85
+ it('should render the close icon when showCloseIcon is true', () => {
86
+ const closeIcon = wrapper.find('[data-testid="close-icon"]');
87
+ expect(closeIcon.exists()).toBe(true);
88
+ });
89
+
90
+ it('should not render buttons when primaryButtonProps is not provided', async () => {
91
+ await wrapper.setProps({ primaryButtonProps: undefined });
92
+
93
+ const primaryButton = wrapper.find('[data-testid="primary-button"]');
94
+ const secondaryButton = wrapper.find('[data-testid="secondary-button"]');
95
+ expect(primaryButton.exists()).toBe(false);
96
+ expect(secondaryButton.exists()).toBe(false);
97
+ });
98
+ });
99
+
100
+ describe('Overlay behavior', () => {
101
+ it('should close the modal when clicking on the overlay if persistent is false', async () => {
102
+ expect(wrapper.props().modelValue).toBe(true);
103
+
104
+ const overlay = wrapper.find('[data-testid="modal-overlay"]');
105
+ await overlay.trigger('click');
106
+
107
+ expect(wrapper.emitted('update:modelValue')).toBeTruthy();
108
+ expect(wrapper.emitted('update:modelValue')[0]).toEqual([false]);
109
+ expect(wrapper.props().modelValue).toBe(false);
110
+ });
111
+
112
+ it('should not close the modal when clicking on the overlay if persistent is true', async () => {
113
+ await wrapper.setProps({ persistent: true });
114
+
115
+ const overlay = wrapper.find('[data-testid="modal-overlay"]');
116
+ await overlay.trigger('click');
117
+
118
+ expect(wrapper.emitted('update:modelValue')).toBeFalsy();
119
+ expect(wrapper.props().modelValue).toBe(true);
120
+ });
121
+ });
122
+
123
+ describe('Slot rendering', () => {
124
+ it('should render leftSidebar slot when provided', () => {
125
+ const wrapper = mount(ModalDialog, {
126
+ props: {
127
+ modelValue: true,
128
+ },
129
+ slots: {
130
+ leftSidebar:
131
+ '<div data-testid="left-sidebar">Left Sidebar Content</div>',
132
+ },
133
+ });
134
+
135
+ const leftSidebar = wrapper.find('[data-testid="left-sidebar"]');
136
+ expect(leftSidebar.exists()).toBe(true);
137
+ expect(leftSidebar.text()).toBe('Left Sidebar Content');
138
+ });
139
+
140
+ it('should render default slot content', () => {
141
+ const wrapper = mount(ModalDialog, {
142
+ props: {
143
+ modelValue: true,
144
+ },
145
+ slots: {
146
+ default: '<div data-testid="default-slot">Default Slot Content</div>',
147
+ },
148
+ });
149
+
150
+ const defaultSlot = wrapper.find('[data-testid="default-slot"]');
151
+ expect(defaultSlot.exists()).toBe(true);
152
+ expect(defaultSlot.text()).toBe('Default Slot Content');
153
+ });
154
+ });
155
+
156
+ describe('Buttons actions', () => {
157
+ it('should close the modal when clicking on close icon', async () => {
158
+ const closeIcon = wrapper.find('[data-testid="close-icon"]');
159
+ await closeIcon.trigger('click');
160
+
161
+ expect(wrapper.emitted('update:modelValue')).toBeTruthy();
162
+ expect(wrapper.emitted('update:modelValue')[0]).toEqual([false]);
163
+ expect(wrapper.props().modelValue).toBe(false);
164
+ });
165
+
166
+ it('should emit primaryButtonClick event when the primary button is clicked', async () => {
167
+ const primaryButton = wrapper.find('[data-testid="primary-button"]');
168
+ await primaryButton.trigger('click');
169
+
170
+ expect(wrapper.emitted('primaryButtonClick')).toBeTruthy();
171
+ });
172
+
173
+ it('should emit secondaryButtonClick event when the secondary button is clicked', async () => {
174
+ await wrapper.setProps({
175
+ secondaryButtonProps: { text: 'Cancel' },
176
+ });
177
+
178
+ const secondaryButton = wrapper.find('[data-testid="secondary-button"]');
179
+ await secondaryButton.trigger('click');
180
+
181
+ expect(wrapper.emitted('secondaryButtonClick')).toBeTruthy();
182
+ });
183
+
184
+ it('should close the modal when the secondary button is clicked and no secondaryButtonClick event is provided', async () => {
185
+ const secondaryButton = wrapper.find('[data-testid="secondary-button"]');
186
+ await secondaryButton.trigger('click');
187
+
188
+ const emittedValue = wrapper.emitted('update:modelValue');
189
+
190
+ expect(emittedValue).toBeTruthy();
191
+ expect(emittedValue[0][0]).toEqual(false);
192
+ });
193
+ });
194
+
195
+ describe('Actions and appearance', () => {
196
+ it('should not render the secondary button when hideSecondaryButton is true', async () => {
197
+ await wrapper.setProps({
198
+ hideSecondaryButton: true,
199
+ });
200
+ const secondaryButton = wrapper.find('[data-testid="secondary-button"]');
201
+ expect(secondaryButton.exists()).toBe(false);
202
+ });
203
+
204
+ it('should apply a divider class to the actions section when showActionsDivider is true', async () => {
205
+ await wrapper.setProps({
206
+ showActionsDivider: true,
207
+ });
208
+
209
+ const actionsSection = wrapper.find('[data-testid="actions-section"]');
210
+ expect(actionsSection.classes()).toContain(
211
+ 'unnnic-modal-dialog__container__actions--divider',
212
+ );
213
+ });
214
+ });
215
+
216
+ describe('Body overflow', () => {
217
+ it('should toggle body overflow based on modal visibility', async () => {
218
+ await wrapper.setProps({ modelValue: false });
219
+ const updateBodyOverflowSpy = vi.spyOn(wrapper.vm, 'updateBodyOverflow');
220
+
221
+ await wrapper.setProps({ modelValue: true });
222
+ expect(updateBodyOverflowSpy).toHaveBeenCalledWith(true);
223
+
224
+ await wrapper.setProps({ modelValue: false });
225
+ expect(updateBodyOverflowSpy).toHaveBeenCalledWith(false);
226
+ });
227
+ });
228
+
229
+ describe('Validators', () => {
230
+ describe('type prop validator', () => {
231
+ it('should validate type prop when a valid value is provided', () => {
232
+ const validTypes = ['success', 'warning', 'attention'];
233
+ validTypes.forEach((validType) => {
234
+ expect(ModalDialog.props.type.validate(validType)).toBe(true);
235
+ });
236
+ });
237
+
238
+ it('should invalidate type prop when an invalid value is provided', () => {
239
+ expect(ModalDialog.props.type.validate('invalidType')).toBe(false);
240
+ });
241
+ });
242
+
243
+ describe('size prop validator', () => {
244
+ it('should validate size prop when a valid value is provided', () => {
245
+ const validSizes = ['sm', 'md', 'lg'];
246
+ validSizes.forEach((validSize) => {
247
+ expect(ModalDialog.props.size.validate(validSize)).toBe(true);
248
+ });
249
+ });
250
+
251
+ it('should invalidate size prop when an invalid value is provided', () => {
252
+ expect(ModalDialog.props.size.validate('invalidSize')).toBe(false);
253
+ });
44
254
  });
45
255
  });
46
256
  });
@@ -1,3 +1,24 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
- exports[`ModalDialog.vue > Elements rendering > matches the snapshot 1`] = `"<unnnic-dialog-content-stub data-v-68ebadeb="" forcemount="false" disableoutsidepointerevents="false" aschild="false" parentclass="unnnic-modal-dialog," class="unnnic-modal-dialog__container" size="medium" data-testid="modal-dialog"></unnnic-dialog-content-stub>"`;
3
+ exports[`ModalDialog.vue > Elements rendering > matches the snapshot 1`] = `
4
+ "<section data-v-68ebadeb="" class="unnnic-modal-dialog" data-testid="modal-dialog">
5
+ <section data-v-68ebadeb="" class="unnnic-modal-dialog__overlay" data-testid="modal-overlay"></section>
6
+ <section data-v-68ebadeb="" class="unnnic-modal-dialog__container unnnic-modal-dialog__container--md" data-testid="modal-container">
7
+ <!--v-if-->
8
+ <section data-v-68ebadeb="" class="unnnic-modal-dialog__container__body">
9
+ <header data-v-68ebadeb="" class="unnnic-modal-dialog__container__header">
10
+ <section data-v-68ebadeb="" class="unnnic-modal-dialog__container__title-container">
11
+ <unnnic-icon-stub data-v-68ebadeb="" filled="false" icon="test-icon" clickable="false" size="md" scheme="neutral-darkest" data-testid="title-icon" class="unnnic-modal-dialog__container__title-icon"></unnnic-icon-stub>
12
+ <h1 data-v-68ebadeb="" class="unnnic-modal-dialog__container__title-text" data-testid="title-text">Test Title</h1>
13
+ </section>
14
+ <unnnic-icon-stub data-v-68ebadeb="" filled="false" icon="close" clickable="true" size="md" scheme="neutral-cloudy" data-testid="close-icon"></unnnic-icon-stub>
15
+ </header>
16
+ <section data-v-68ebadeb="" class="unnnic-modal-dialog__container__content"></section>
17
+ <section data-v-68ebadeb="" data-testid="actions-section" class="unnnic-modal-dialog__container__actions">
18
+ <unnnic-button-stub data-v-68ebadeb="" size="large" text="Cancel" type="tertiary" float="false" iconleft="" iconright="" iconcenter="" iconsfilled="false" disabled="false" loading="false" data-testid="secondary-button" class="unnnic-modal-dialog__container__actions__secondary-button"></unnnic-button-stub>
19
+ <unnnic-button-stub data-v-68ebadeb="" size="large" text="Confirm" type="primary" float="false" iconleft="" iconright="" iconcenter="" iconsfilled="false" disabled="false" loading="false" data-testid="primary-button" class="unnnic-modal-dialog__container__actions__primary-button"></unnnic-button-stub>
20
+ </section>
21
+ </section>
22
+ </section>
23
+ </section>"
24
+ `;
@@ -4,9 +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-b3d24f2b="" class="unnnic-tooltip-trigger" data-testid="tooltip-trigger" data-state="closed" data-grace-area-trigger=""><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></div>
8
- <!--teleport start-->
9
- <!--teleport end-->
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>
10
8
  </li>
11
9
  <li data-v-b4e39fac="" class="tab-head tab-head--active">tab2
12
10
  <!--v-if-->
@@ -7,9 +7,9 @@
7
7
  >
8
8
  <aside
9
9
  v-if="isVisible"
10
- :class="['unnnic-toast', `unnnic-toast--${validType}`]"
11
- :role="validType === 'error' ? 'alert' : 'status'"
12
- :aria-live="validType === 'error' ? 'assertive' : 'polite'"
10
+ :class="['unnnic-toast', `unnnic-toast--${type}`]"
11
+ :role="type === 'error' ? 'alert' : 'status'"
12
+ :aria-live="type === 'error' ? 'assertive' : 'polite'"
13
13
  data-testid="toast"
14
14
  >
15
15
  <section
@@ -22,7 +22,7 @@
22
22
  >
23
23
  <UnnnicIcon
24
24
  :icon="typeConfig.icon"
25
- :scheme="typeConfig.scheme as SchemeColor"
25
+ :scheme="typeConfig.scheme"
26
26
  size="ant"
27
27
  data-testid="toast-type-icon"
28
28
  />
@@ -95,13 +95,6 @@ const emit = defineEmits<ToastEmits>();
95
95
  const isVisible = ref(false);
96
96
  let timeoutId: number | null = null;
97
97
 
98
- const validType = computed(() => {
99
- if (['informational', 'attention', 'success', 'error'].includes(props.type)) {
100
- return props.type;
101
- }
102
- return 'informational';
103
- });
104
-
105
98
  const typeConfig = computed(() => {
106
99
  const configMap = {
107
100
  informational: { icon: 'info', scheme: 'blue-500' },
@@ -110,7 +103,10 @@ const typeConfig = computed(() => {
110
103
  error: { icon: 'cancel', scheme: 'red-500' },
111
104
  };
112
105
 
113
- return configMap[validType.value];
106
+ return configMap[props.type || 'informational'] as {
107
+ icon: string;
108
+ scheme: SchemeColor;
109
+ };
114
110
  });
115
111
 
116
112
  const handleClose = () => {
@@ -1,53 +1,48 @@
1
1
  <template>
2
- <TooltipProvider>
3
- <Tooltip
4
- :disabled="!(enabled || forceOpen)"
5
- :open="forceOpen || undefined"
6
- data-testid="tooltip-wrapper"
2
+ <div
3
+ ref="tooltip"
4
+ :class="{
5
+ 'unnnic-tooltip': enabled || forceOpen,
6
+ 'force-open': forceOpen,
7
+ }"
8
+ @mouseover="handleResize"
9
+ >
10
+ <slot />
11
+ <span
12
+ v-show="enabled || forceOpen"
13
+ ref="label"
14
+ :class="['unnnic-tooltip-label', `unnnic-tooltip-label-${side}`]"
15
+ :style="{ maxWidth: maxWidth, left: leftPos, top: topPos }"
16
+ data-testid="tooltip-label"
7
17
  >
8
- <TooltipTrigger data-testid="tooltip-trigger">
9
- <slot />
10
- </TooltipTrigger>
11
-
12
- <TooltipContent
13
- :class="['unnnic-tooltip-label', `unnnic-tooltip-label-${side}`]"
14
- :style="{ maxWidth: maxWidth }"
15
- :side="side"
16
- data-testid="tooltip-content"
18
+ <template v-if="enableHtml">
19
+ <!-- eslint-disable-next-line vue/no-v-html -->
20
+ <section v-html="text"></section>
21
+ </template>
22
+ <template
23
+ v-for="(line, index) in text.split('\n')"
24
+ v-else
25
+ :key="index"
17
26
  >
18
- <template v-if="enableHtml">
19
- <!-- eslint-disable-next-line vue/no-v-html -->
20
- <section
21
- v-html="text"
22
- data-testid="tooltip-html-content"
23
- ></section>
24
- </template>
25
- <template
26
- v-for="(line, index) in text.split('\n')"
27
- v-else
28
- :key="index"
27
+ {{ line }}
28
+ <br />
29
+ </template>
30
+
31
+ <template v-if="shortcutText">
32
+ <span
33
+ class="unnnic-tooltip-label-shortcut"
34
+ data-testid="tooltip-label-shortcut"
29
35
  >
30
- {{ line }}
31
- <br />
32
- </template>
33
- </TooltipContent>
34
- </Tooltip>
35
- </TooltipProvider>
36
+ {{ shortcutText }}
37
+ </span>
38
+ </template>
39
+ </span>
40
+ </div>
36
41
  </template>
37
42
 
38
43
  <script>
39
- import { Tooltip, TooltipProvider } from '../ui/tooltip';
40
- import TooltipContent from '../ui/tooltip/TooltipContent.vue';
41
- import TooltipTrigger from '../ui/tooltip/TooltipTrigger.vue';
42
-
43
44
  export default {
44
45
  name: 'UnnnicTooltip',
45
- components: {
46
- Tooltip,
47
- TooltipProvider,
48
- TooltipTrigger,
49
- TooltipContent,
50
- },
51
46
  props: {
52
47
  text: {
53
48
  type: String,
@@ -72,10 +67,162 @@ export default {
72
67
  type: String,
73
68
  default: '',
74
69
  },
70
+ shortcutText: {
71
+ type: String,
72
+ default: null,
73
+ },
75
74
  enableHtml: {
76
75
  type: Boolean,
77
76
  default: false,
78
77
  },
79
78
  },
79
+ data() {
80
+ return {
81
+ topPos: null,
82
+ leftPos: null,
83
+ };
84
+ },
85
+ watch: {
86
+ side() {
87
+ this.getRightPost(this.$refs.tooltip);
88
+ },
89
+ },
90
+ mounted() {
91
+ this.handleResize();
92
+
93
+ window.addEventListener('scroll', this.handleResize);
94
+ window.addEventListener('resize', this.handleResize);
95
+ },
96
+ unmounted() {
97
+ window.removeEventListener('scroll', this.handleResize);
98
+ window.removeEventListener('resize', this.handleResize);
99
+ },
100
+ methods: {
101
+ handleResize() {
102
+ this.getRightPost(this.$refs.tooltip);
103
+ },
104
+ getRightPost(element) {
105
+ const elementPos = element.getBoundingClientRect();
106
+
107
+ if (element && this.$refs.label) {
108
+ if (this.side === 'right') {
109
+ this.leftPos = `${elementPos.x + elementPos.width + 8}px`;
110
+ this.topPos = `${elementPos.y + elementPos.height / 2 - this.$refs.label.offsetHeight / 2}px`;
111
+ } else if (this.side === 'left') {
112
+ this.leftPos = `${elementPos.x - this.$refs.label.offsetWidth - 8}px`;
113
+ this.topPos = `${elementPos.y + elementPos.height / 2 - this.$refs.label.offsetHeight / 2}px`;
114
+ } else if (this.side === 'top') {
115
+ this.leftPos = `${elementPos.x + elementPos.width / 2 - this.$refs.label.clientWidth / 2}px`;
116
+ this.topPos = `${elementPos.y - this.$refs.label.offsetHeight - 8}px`;
117
+ } else if (this.side === 'bottom') {
118
+ this.leftPos = `${elementPos.x + elementPos.width / 2 - this.$refs.label.clientWidth / 2}px`;
119
+ this.topPos = `${elementPos.y + elementPos.height + 8}px`;
120
+ }
121
+ }
122
+ },
123
+ },
80
124
  };
81
125
  </script>
126
+
127
+ <style lang="scss" scoped>
128
+ @use '@/assets/scss/unnnic' as *;
129
+
130
+ .unnnic-tooltip {
131
+ position: relative;
132
+ display: inline-block;
133
+ overflow-wrap: break-word;
134
+ }
135
+
136
+ .unnnic-tooltip-label {
137
+ z-index: 1;
138
+ visibility: hidden;
139
+ text-align: center;
140
+ position: fixed;
141
+ width: max-content;
142
+ min-width: 2 * $unnnic-font-size;
143
+ box-sizing: border-box;
144
+ width: auto;
145
+ display: flex;
146
+ justify-content: center;
147
+ gap: $unnnic-spacing-xs;
148
+ align-items: center;
149
+
150
+ background-color: $unnnic-color-neutral-black;
151
+ color: $unnnic-color-neutral-snow;
152
+ border-radius: $unnnic-border-radius-sm;
153
+ padding: $unnnic-inset-nano;
154
+ box-shadow: $unnnic-shadow-level-near;
155
+ font-size: $unnnic-font-size-body-md;
156
+ font-family: $unnnic-font-family-secondary;
157
+ font-weight: $unnnic-font-weight-regular;
158
+ line-height: ($unnnic-font-size-body-md + $unnnic-line-height-medium);
159
+
160
+ &::after {
161
+ content: '';
162
+ position: absolute;
163
+ border-width: 5px;
164
+ border-style: solid;
165
+ }
166
+
167
+ &-top {
168
+ position: fixed;
169
+ &::after {
170
+ top: 100%;
171
+ left: 50%;
172
+ margin-left: -5px;
173
+ border-color: $unnnic-color-neutral-black transparent transparent
174
+ transparent;
175
+ }
176
+ }
177
+
178
+ &-bottom {
179
+ position: fixed;
180
+ &::after {
181
+ bottom: 100%;
182
+ left: 50%;
183
+ margin-left: -5px;
184
+ border-color: transparent transparent $unnnic-color-neutral-black
185
+ transparent;
186
+ }
187
+ }
188
+ &-right {
189
+ position: fixed;
190
+ &::after {
191
+ top: 50%;
192
+ right: 100%;
193
+ margin-top: -5px;
194
+ border-color: transparent $unnnic-color-neutral-black transparent
195
+ transparent;
196
+ }
197
+ }
198
+ &-left {
199
+ position: fixed;
200
+ &::after {
201
+ top: 50%;
202
+ left: 100%;
203
+ margin-top: -5px;
204
+ border-color: transparent transparent transparent
205
+ $unnnic-color-neutral-black;
206
+ }
207
+ }
208
+
209
+ &-shortcut {
210
+ background-color: $unnnic-color-neutral-darkest;
211
+ border-radius: $unnnic-border-radius-sm;
212
+ padding: calc($unnnic-inset-nano / 2) $unnnic-inset-nano;
213
+ }
214
+ }
215
+
216
+ .unnnic-tooltip.force-open {
217
+ .unnnic-tooltip-label {
218
+ visibility: visible;
219
+ }
220
+ }
221
+
222
+ .unnnic-tooltip:hover {
223
+ .unnnic-tooltip-label {
224
+ visibility: visible;
225
+ width: auto;
226
+ }
227
+ }
228
+ </style>