@weni/unnnic-system 3.14.0-alpha-teleports.0 → 3.14.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 (77) hide show
  1. package/README.md +1 -9
  2. package/dist/{es-0d53b5b2.mjs → es-91ae9eed.mjs} +1 -1
  3. package/dist/{index-d7070de8.mjs → index-3b503557.mjs} +26122 -28965
  4. package/dist/index.d.ts +1485 -4826
  5. package/dist/{pt-br-bf4e1f97.mjs → pt-br-9553a558.mjs} +1 -1
  6. package/dist/style.css +1 -1
  7. package/dist/unnnic.mjs +204 -232
  8. package/dist/unnnic.umd.js +44 -48
  9. package/package.json +2 -3
  10. package/src/assets/scss/tailwind.scss +0 -8
  11. package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +1 -1
  12. package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +1 -2
  13. package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +60 -61
  14. package/src/components/CheckboxGroup/CheckboxGroup.vue +7 -5
  15. package/src/components/Chip/Chip.vue +1 -1
  16. package/src/components/DatePicker/DatePicker.vue +1 -10
  17. package/src/components/Drawer/Drawer.vue +270 -180
  18. package/src/components/Drawer/__tests__/Drawer.spec.js +43 -32
  19. package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +19 -18
  20. package/src/components/FormElement/FormElement.vue +96 -87
  21. package/src/components/InputDatePicker/InputDatePicker.vue +73 -68
  22. package/src/components/InputDatePicker/__test__/InputDatePicker.spec.js +24 -31
  23. package/src/components/ModalDialog/ModalDialog.vue +154 -63
  24. package/src/components/ModalDialog/__tests__/ModalDialog.spec.js +210 -30
  25. package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +22 -1
  26. package/src/components/Radio/Radio.vue +12 -6
  27. package/src/components/Radio/__test__/Radio.spec.js +3 -1
  28. package/src/components/RadioGroup/RadioGroup.vue +18 -10
  29. package/src/components/Select/__tests__/SelectItem.spec.js +35 -15
  30. package/src/components/Switch/Switch.vue +10 -3
  31. package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -3
  32. package/src/components/TemplatePreview/TemplatePreview.vue +28 -25
  33. package/src/components/TemplatePreview/TemplatePreviewModal.vue +10 -10
  34. package/src/components/TemplatePreview/types.d.ts +3 -3
  35. package/src/components/Toast/Toast.vue +1 -4
  36. package/src/components/Toast/ToastManager.ts +1 -4
  37. package/src/components/Toast/__tests__/ToastManager.spec.js +6 -10
  38. package/src/components/ToolTip/ToolTip.vue +177 -25
  39. package/src/components/ToolTip/__tests__/ToolTip.spec.js +61 -339
  40. package/src/components/index.ts +0 -56
  41. package/src/components/ui/popover/PopoverContent.vue +4 -7
  42. package/src/components/ui/popover/PopoverTrigger.vue +1 -5
  43. package/src/index.ts +2 -9
  44. package/src/stories/Drawer.stories.js +1 -1
  45. package/src/stories/ModalDialog.mdx +0 -3
  46. package/src/stories/ModalDialog.stories.js +1 -96
  47. package/src/stories/TemplatePreview.stories.js +27 -27
  48. package/src/stories/TemplatePreviewModal.stories.js +31 -31
  49. package/src/components/ui/dialog/Dialog.vue +0 -19
  50. package/src/components/ui/dialog/DialogClose.vue +0 -29
  51. package/src/components/ui/dialog/DialogContent.vue +0 -140
  52. package/src/components/ui/dialog/DialogFooter.vue +0 -50
  53. package/src/components/ui/dialog/DialogHeader.vue +0 -83
  54. package/src/components/ui/dialog/DialogTitle.vue +0 -38
  55. package/src/components/ui/dialog/DialogTrigger.vue +0 -16
  56. package/src/components/ui/dialog/index.ts +0 -7
  57. package/src/components/ui/drawer/Drawer.vue +0 -27
  58. package/src/components/ui/drawer/DrawerClose.vue +0 -31
  59. package/src/components/ui/drawer/DrawerContent.vue +0 -113
  60. package/src/components/ui/drawer/DrawerDescription.vue +0 -40
  61. package/src/components/ui/drawer/DrawerFooter.vue +0 -38
  62. package/src/components/ui/drawer/DrawerHeader.vue +0 -57
  63. package/src/components/ui/drawer/DrawerOverlay.vue +0 -33
  64. package/src/components/ui/drawer/DrawerTitle.vue +0 -37
  65. package/src/components/ui/drawer/DrawerTrigger.vue +0 -31
  66. package/src/components/ui/drawer/index.ts +0 -10
  67. package/src/components/ui/tooltip/Tooltip.vue +0 -21
  68. package/src/components/ui/tooltip/TooltipContent.vue +0 -77
  69. package/src/components/ui/tooltip/TooltipTrigger.vue +0 -24
  70. package/src/components/ui/tooltip/index.ts +0 -3
  71. package/src/lib/__tests__/teleport-target.spec.ts +0 -73
  72. package/src/lib/layer-manager.ts +0 -64
  73. package/src/lib/teleport-target.ts +0 -46
  74. package/src/stories/Dialog.stories.js +0 -832
  75. package/src/stories/DrawerNext.stories.js +0 -611
  76. package/src/stories/LayerManager.docs.mdx +0 -40
  77. package/src/stories/LayerManager.stories.js +0 -407
@@ -1,199 +1,198 @@
1
1
  <template>
2
- <Drawer
2
+ <aside
3
+ v-if="modelValue"
3
4
  class="unnnic-drawer"
4
5
  data-testid="drawer"
5
- :open="modelValue"
6
- @update:open="$event ? () => {} : back()"
7
6
  >
8
- <DrawerContent
9
- v-bind="$attrs"
10
- :showOverlay="!withoutOverlay"
11
- data-testid="drawer-container"
12
- :size="mappedSize"
13
- :class="[
14
- 'unnnic-drawer__container',
15
- `unnnic-drawer__container--${size}`,
16
- props.class,
17
- ].filter(Boolean).join(' ')"
7
+ <section
8
+ v-if="!withoutOverlay"
9
+ class="unnnic-drawer__overlay"
10
+ data-testid="overlay"
11
+ @click.stop="close"
12
+ />
13
+ <Transition
14
+ appear
15
+ name="drawer"
18
16
  >
19
- <DrawerHeader class="unnnic-drawer__header">
20
- <section class="unnnic-drawer__title-container">
21
- <slot
22
- v-if="$slots.title"
23
- name="title"
24
- />
25
-
26
- <template v-else>
27
- <DrawerTitle
28
- class="unnnic-drawer__title"
29
- data-testid="drawer-title"
30
- >
31
- {{ title }}
32
- </DrawerTitle>
33
- <DrawerDescription
34
- v-if="description"
35
- class="unnnic-drawer__description"
36
- data-testid="drawer-description"
37
- >
38
- {{ description }}
39
- </DrawerDescription>
40
- </template>
41
- </section>
42
- <template #close>
43
- <DrawerClose>
44
- <UnnnicButton
45
- class="unnnic-drawer__close-icon"
46
- data-testid="close-icon"
47
- :iconCenter="closeIcon"
48
- size="small"
49
- type="tertiary"
50
- @click="back"
17
+ <section
18
+ v-if="showDrawer"
19
+ data-testid="drawer-container"
20
+ :class="[
21
+ 'unnnic-drawer__container',
22
+ `unnnic-drawer__container--${size}`,
23
+ ]"
24
+ >
25
+ <header class="unnnic-drawer__header">
26
+ <section class="unnnic-drawer__title-container">
27
+ <slot
28
+ v-if="$slots.title"
29
+ name="title"
51
30
  />
52
- </DrawerClose>
53
- </template>
54
- </DrawerHeader>
55
31
 
56
- <section class="unnnic-drawer__content">
57
- <slot name="content"></slot>
32
+ <template v-else>
33
+ <h1
34
+ class="unnnic-drawer__title"
35
+ data-testid="drawer-title"
36
+ >
37
+ {{ title }}
38
+ </h1>
39
+ <p
40
+ v-if="description"
41
+ class="unnnic-drawer__description"
42
+ data-testid="drawer-description"
43
+ >
44
+ {{ description }}
45
+ </p>
46
+ </template>
47
+ </section>
48
+ <UnnnicIcon
49
+ class="unnnic-drawer__close"
50
+ data-testid="close-icon"
51
+ :icon="closeIcon"
52
+ size="avatar-nano"
53
+ clickable
54
+ @click="back"
55
+ />
56
+ </header>
57
+ <section class="unnnic-drawer__content">
58
+ <slot name="content"></slot>
59
+ </section>
60
+ <footer
61
+ v-if="showFooter"
62
+ class="unnnic-drawer__footer"
63
+ data-testid="footer"
64
+ >
65
+ <UnnnicButton
66
+ v-if="secondaryButtonText"
67
+ data-testid="secondary-button"
68
+ size="large"
69
+ type="tertiary"
70
+ :disabled="disabledSecondaryButton"
71
+ :loading="loadingSecondaryButton"
72
+ :text="secondaryButtonText"
73
+ @click="$emit('secondaryButtonClick')"
74
+ />
75
+ <UnnnicButton
76
+ v-if="primaryButtonText"
77
+ data-testid="primary-button"
78
+ size="large"
79
+ :disabled="disabledPrimaryButton"
80
+ :loading="loadingPrimaryButton"
81
+ :type="primaryButtonType"
82
+ :text="primaryButtonText"
83
+ @click="$emit('primaryButtonClick')"
84
+ />
85
+ </footer>
58
86
  </section>
59
-
60
- <DrawerFooter
61
- v-if="showFooter"
62
- class="unnnic-drawer__footer"
63
- data-testid="footer"
64
- >
65
- <UnnnicButton
66
- v-if="secondaryButtonText"
67
- data-testid="secondary-button"
68
- size="large"
69
- type="tertiary"
70
- :disabled="disabledSecondaryButton"
71
- :loading="loadingSecondaryButton"
72
- :text="secondaryButtonText"
73
- @click="$emit('secondaryButtonClick')"
74
- />
75
- <UnnnicButton
76
- v-if="primaryButtonText"
77
- data-testid="primary-button"
78
- size="large"
79
- :disabled="disabledPrimaryButton"
80
- :loading="loadingPrimaryButton"
81
- :type="primaryButtonType"
82
- :text="primaryButtonText"
83
- @click="$emit('primaryButtonClick')"
84
- />
85
- </DrawerFooter>
86
- </DrawerContent>
87
- </Drawer>
87
+ </Transition>
88
+ </aside>
88
89
  </template>
89
90
 
90
- <script setup>
91
- import { computed } from 'vue';
92
-
91
+ <script>
92
+ import UnnnicIcon from '../Icon.vue';
93
93
  import UnnnicButton from '../Button/Button.vue';
94
- import {
95
- Drawer,
96
- DrawerContent,
97
- DrawerHeader,
98
- DrawerFooter,
99
- DrawerClose,
100
- DrawerTitle,
101
- DrawerDescription,
102
- } from '../ui/drawer';
103
-
104
- defineOptions({
105
- name: 'UnnnicDrawer',
106
- inheritAttrs: false,
107
- });
108
94
 
109
- const props = defineProps({
110
- title: {
111
- type: String,
112
- required: true,
113
- },
114
- description: {
115
- type: String,
116
- default: '',
117
- },
118
- disabledPrimaryButton: {
119
- type: Boolean,
120
- default: false,
121
- },
122
- disabledSecondaryButton: {
123
- type: Boolean,
124
- default: false,
125
- },
126
- loadingPrimaryButton: {
127
- type: Boolean,
128
- default: false,
129
- },
130
- loadingSecondaryButton: {
131
- type: Boolean,
132
- default: false,
133
- },
134
- primaryButtonText: {
135
- type: String,
136
- default: '',
137
- },
138
- primaryButtonType: {
139
- type: String,
140
- default: 'primary',
141
- },
142
- secondaryButtonText: {
143
- type: String,
144
- default: '',
95
+ export default {
96
+ name: 'UnnnicDrawer',
97
+ components: {
98
+ UnnnicIcon,
99
+ UnnnicButton,
145
100
  },
146
- size: {
147
- type: String,
148
- default: 'md',
149
- validator(val) {
150
- return ['md', 'lg', 'xl', 'gt'].includes(val);
101
+ props: {
102
+ title: {
103
+ type: String,
104
+ required: true,
105
+ },
106
+ description: {
107
+ type: String,
108
+ default: '',
109
+ },
110
+ disabledPrimaryButton: {
111
+ type: Boolean,
112
+ default: false,
113
+ },
114
+ disabledSecondaryButton: {
115
+ type: Boolean,
116
+ default: false,
117
+ },
118
+ loadingPrimaryButton: {
119
+ type: Boolean,
120
+ default: false,
121
+ },
122
+ loadingSecondaryButton: {
123
+ type: Boolean,
124
+ default: false,
125
+ },
126
+ primaryButtonText: {
127
+ type: String,
128
+ default: '',
129
+ },
130
+ primaryButtonType: {
131
+ type: String,
132
+ default: 'primary',
133
+ },
134
+ secondaryButtonText: {
135
+ type: String,
136
+ default: '',
137
+ },
138
+ size: {
139
+ type: String,
140
+ default: 'md',
141
+ validator(val) {
142
+ return ['md', 'lg', 'xl', 'gt'].includes(val);
143
+ },
144
+ },
145
+ wide: {
146
+ type: Boolean,
147
+ default: false,
148
+ },
149
+ modelValue: {
150
+ type: Boolean,
151
+ required: true,
152
+ },
153
+ withoutOverlay: {
154
+ type: Boolean,
155
+ default: false,
156
+ },
157
+ closeIcon: {
158
+ type: String,
159
+ default: 'arrow_back',
160
+ },
161
+ distinctCloseBack: {
162
+ type: Boolean,
163
+ default: false,
151
164
  },
152
165
  },
153
- modelValue: {
154
- type: Boolean,
155
- required: true,
156
- },
157
- withoutOverlay: {
158
- type: Boolean,
159
- default: false,
160
- },
161
- closeIcon: {
162
- type: String,
163
- default: 'arrow_forward',
166
+ emits: ['primaryButtonClick', 'secondaryButtonClick', 'close', 'back'],
167
+ data() {
168
+ return {
169
+ showDrawer: true,
170
+ };
164
171
  },
165
- distinctCloseBack: {
166
- type: Boolean,
167
- default: false,
172
+ computed: {
173
+ showFooter() {
174
+ return !!(this.primaryButtonText || this.secondaryButtonText);
175
+ },
168
176
  },
169
- class: {
170
- type: String,
171
- default: '',
177
+ methods: {
178
+ transitionClose(callback) {
179
+ this.showDrawer = false;
180
+ setTimeout(() => {
181
+ callback?.();
182
+ this.showDrawer = true;
183
+ }, 200);
184
+ },
185
+ close() {
186
+ this.transitionClose(() => this.$emit('close'));
187
+ },
188
+ back() {
189
+ if (this.distinctCloseBack) {
190
+ this.transitionClose(() => this.$emit('back'));
191
+ } else {
192
+ this.close();
193
+ }
194
+ },
172
195
  },
173
- });
174
-
175
- const emit = defineEmits(['primaryButtonClick', 'secondaryButtonClick', 'close', 'back']);
176
- const showFooter = computed(() => !!(props.primaryButtonText || props.secondaryButtonText));
177
- const mappedSize = computed(() => {
178
- const sizes = {
179
- md: 'medium',
180
- lg: 'large',
181
- xl: 'extra-large',
182
- gt: 'giant',
183
- }
184
- return sizes[props.size] || 'medium';
185
- });
186
-
187
- const close = () => {
188
- emit('close');
189
- };
190
-
191
- const back = () => {
192
- if (props.distinctCloseBack) {
193
- emit('back');
194
- } else {
195
- close();
196
- }
197
196
  };
198
197
  </script>
199
198
 
@@ -205,16 +204,107 @@ const back = () => {
205
204
  box-sizing: border-box;
206
205
  }
207
206
 
207
+ @keyframes drawerOpen {
208
+ from {
209
+ transform: translateX(100%);
210
+ }
211
+ to {
212
+ transform: translateX(0);
213
+ }
214
+ }
215
+
216
+ @keyframes drawerClose {
217
+ from {
218
+ transform: translateX(0);
219
+ }
220
+ to {
221
+ transform: translateX(100%);
222
+ }
223
+ }
224
+
225
+ .drawer-enter-active,
226
+ .drawer-enter-to {
227
+ animation: drawerOpen 200ms ease-in;
228
+ }
229
+
230
+ .drawer-leave-active,
231
+ .drawer-leave-to {
232
+ display: none;
233
+ animation: drawerClose 200ms ease-in;
234
+ }
235
+
208
236
  .unnnic-drawer {
237
+ width: 100vw;
238
+ height: 100vh;
239
+ position: fixed;
240
+ left: 0;
241
+ top: 0;
209
242
  z-index: 8;
210
243
  }
211
244
 
245
+ .unnnic-drawer__overlay {
246
+ z-index: 9;
247
+ background-color: rgba(0, 0, 0, 0.4);
248
+ width: 100%;
249
+ height: 100%;
250
+ }
251
+
212
252
  .unnnic-drawer__container {
213
253
  z-index: 10;
254
+ top: 0;
255
+ right: 0;
256
+ position: fixed;
257
+ display: flex;
258
+ flex-direction: column;
259
+ font-family: $unnnic-font-family-secondary;
260
+ justify-content: space-between;
261
+ height: 100%;
262
+ background-color: $unnnic-color-neutral-white;
263
+
264
+ &--md {
265
+ width: calc(100% / 3);
266
+ }
267
+
268
+ &--lg {
269
+ width: 50%;
270
+ }
214
271
 
215
- .unnnic-drawer__close-icon {
216
- margin: $unnnic-spacing-nano;
272
+ &--xl {
273
+ width: 66%;
274
+ }
275
+
276
+ &--gt {
277
+ width: 75%;
278
+ }
279
+
280
+ .unnnic-drawer__header {
217
281
  display: flex;
282
+ justify-content: space-between;
283
+ border-bottom: 1px solid $unnnic-color-neutral-soft;
284
+ padding: $unnnic-spacing-md;
285
+ .unnnic-drawer__title-container {
286
+ .unnnic-drawer__title {
287
+ color: $unnnic-color-neutral-darkest;
288
+ font-family: $unnnic-font-family-secondary;
289
+ font-size: $unnnic-font-size-title-sm;
290
+ font-weight: $unnnic-font-weight-black;
291
+ line-height: $unnnic-line-height-large * 1.75;
292
+ }
293
+
294
+ .unnnic-drawer__description {
295
+ color: $unnnic-color-neutral-cloudy;
296
+ font-family: $unnnic-font-family-secondary;
297
+ font-size: $unnnic-font-size-body-gt;
298
+ font-weight: $unnnic-font-weight-regular;
299
+ line-height: $unnnic-line-height-large * 1.375;
300
+ }
301
+ }
302
+
303
+ .unnnic-drawer__close {
304
+ margin: $unnnic-spacing-nano;
305
+ transform: rotate(180deg);
306
+ display: flex;
307
+ }
218
308
  }
219
309
 
220
310
  .unnnic-drawer__content {
@@ -5,19 +5,6 @@ import Drawer from '../Drawer.vue';
5
5
  describe('Drawer.vue', () => {
6
6
  let wrapper;
7
7
 
8
- const templateSlot = { template: `<div><slot /></div>` };
9
- const globalStubs = {
10
- UnnnicIcon: true,
11
- UnnnicButton: true,
12
- Teleport: templateSlot,
13
- UnnnicDrawerNext: templateSlot,
14
- UnnnicDrawerContent: templateSlot,
15
- UnnnicDrawerFooter: templateSlot,
16
- UnnnicDrawerClose: templateSlot,
17
- UnnnicDrawerTitle: templateSlot,
18
- UnnnicDrawerDescription: templateSlot,
19
- };
20
-
21
8
  beforeEach(() => {
22
9
  wrapper = mount(Drawer, {
23
10
  props: {
@@ -28,7 +15,7 @@ describe('Drawer.vue', () => {
28
15
  secondaryButtonText: 'Secondary Action',
29
16
  },
30
17
  global: {
31
- stubs: globalStubs,
18
+ stubs: ['UnnnicIcon', 'UnnnicButton'],
32
19
  },
33
20
  });
34
21
  });
@@ -36,6 +23,7 @@ describe('Drawer.vue', () => {
36
23
  const element = (id) => wrapper.find(`[data-testid="${id}"]`);
37
24
  const component = (id) => wrapper.findComponent(`[data-testid="${id}"]`);
38
25
  const drawer = () => element('drawer');
26
+ const overlay = () => element('overlay');
39
27
  const title = () => element('drawer-title');
40
28
  const description = () => element('drawer-description');
41
29
  const primaryButton = () => component('primary-button');
@@ -51,23 +39,21 @@ describe('Drawer.vue', () => {
51
39
  });
52
40
 
53
41
  it('should render the drawer when modelValue is true', () => {
54
- expect(drawer().attributes('open')).toBe('true');
42
+ expect(drawer().exists()).toBe(true);
55
43
  });
56
44
 
57
45
  it('should not render the drawer when modelValue is false', async () => {
58
46
  await wrapper.setProps({ modelValue: false });
59
- expect(drawer().attributes('open')).toBe('false');
47
+ expect(drawer().exists()).toBe(false);
60
48
  });
61
49
 
62
50
  it('should render the overlay when withoutOverlay is false', () => {
63
- console.log('wrapper.html()', wrapper.html());
64
-
65
- expect(drawerContainer().attributes('showoverlay')).toBe('true');
51
+ expect(overlay().exists()).toBe(true);
66
52
  });
67
53
 
68
54
  it('should not render the overlay when withoutOverlay is true', async () => {
69
55
  await wrapper.setProps({ withoutOverlay: true });
70
- expect(drawerContainer().attributes('showoverlay')).toBe('false');
56
+ expect(overlay().exists()).toBe(false);
71
57
  });
72
58
 
73
59
  it('should display the title and description correctly', () => {
@@ -89,11 +75,7 @@ describe('Drawer.vue', () => {
89
75
  slots: {
90
76
  content: '<div data-testid="slot-content">Slot Content</div>',
91
77
  },
92
- global: {
93
- stubs: globalStubs,
94
- },
95
78
  });
96
-
97
79
  expect(wrapper.find('[data-testid="slot-content"]').exists()).toBe(
98
80
  true,
99
81
  );
@@ -111,9 +93,6 @@ describe('Drawer.vue', () => {
111
93
  slots: {
112
94
  title: '<h2 data-testid="custom-title">Custom Title Content</h2>',
113
95
  },
114
- global: {
115
- stubs: globalStubs,
116
- },
117
96
  });
118
97
 
119
98
  expect(title().exists()).toBe(false);
@@ -134,9 +113,6 @@ describe('Drawer.vue', () => {
134
113
  slots: {
135
114
  title: '<div data-testid="custom-title">Slot Title</div>',
136
115
  },
137
- global: {
138
- stubs: globalStubs,
139
- },
140
116
  });
141
117
 
142
118
  expect(title().exists()).toBe(false);
@@ -188,7 +164,7 @@ describe('Drawer.vue', () => {
188
164
  });
189
165
  });
190
166
 
191
- describe('Interactions', () => {
167
+ describe('Interactions and Transitions', () => {
192
168
  beforeEach(() => {
193
169
  vi.useFakeTimers();
194
170
  });
@@ -198,6 +174,9 @@ describe('Drawer.vue', () => {
198
174
 
199
175
  it('should close the drawer when the close icon is clicked', async () => {
200
176
  await closeIcon().trigger('click');
177
+
178
+ vi.advanceTimersByTime(200);
179
+
201
180
  expect(wrapper.emitted('close')).toBeTruthy();
202
181
  });
203
182
 
@@ -205,6 +184,8 @@ describe('Drawer.vue', () => {
205
184
  await wrapper.setProps({ distinctCloseBack: true });
206
185
  await closeIcon().trigger('click');
207
186
 
187
+ vi.advanceTimersByTime(200);
188
+
208
189
  expect(wrapper.emitted('back')).toBeTruthy();
209
190
  });
210
191
 
@@ -212,6 +193,36 @@ describe('Drawer.vue', () => {
212
193
  await closeIcon().trigger('click');
213
194
  expect(wrapper.emitted('back')).toBeUndefined();
214
195
  });
196
+
197
+ it('should correctly handle transitions when closing the drawer', async () => {
198
+ await wrapper.vm.close();
199
+ expect(wrapper.vm.showDrawer).toBe(false);
200
+
201
+ setTimeout(() => {
202
+ expect(drawer().exists()).toBe(false);
203
+ }, 200);
204
+ });
205
+
206
+ it('should handle overlay clicks to close the drawer when withoutOverlay is false', async () => {
207
+ expect(overlay().exists()).toBe(true);
208
+ await overlay().trigger('click');
209
+
210
+ vi.advanceTimersByTime(200);
211
+
212
+ expect(wrapper.emitted('close')).toBeTruthy();
213
+ });
214
+
215
+ it('should execute the callback after 200ms timeout and reset showDrawer', async () => {
216
+ const callbackMock = vi.fn();
217
+ wrapper.vm.transitionClose(callbackMock);
218
+
219
+ expect(wrapper.vm.showDrawer).toBe(false);
220
+
221
+ vi.advanceTimersByTime(200);
222
+
223
+ expect(callbackMock).toHaveBeenCalled();
224
+ expect(wrapper.vm.showDrawer).toBe(true);
225
+ });
215
226
  });
216
227
 
217
228
  describe('Props and Computed Properties', () => {
@@ -264,7 +275,7 @@ describe('Drawer.vue', () => {
264
275
 
265
276
  it('should use correct icon for close button based on closeIcon prop', async () => {
266
277
  await wrapper.setProps({ closeIcon: 'custom_close_icon' });
267
- expect(closeIcon().props('iconCenter')).toBe('custom_close_icon');
278
+ expect(closeIcon().props('icon')).toBe('custom_close_icon');
268
279
  });
269
280
 
270
281
  it('should validate all size prop values correctly', () => {
@@ -1,22 +1,23 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`Drawer.vue > Component Rendering > Component Rendering > matches the snapshot 1`] = `
4
- "<div data-v-196de012="" class="unnnic-drawer" data-testid="drawer" open="true">
5
- <div data-v-196de012="" showoverlay="true" data-testid="drawer-container" size="medium" class="unnnic-drawer__container unnnic-drawer__container--md">
6
- <header data-v-39d0dfb8="" data-v-196de012="" class="unnnic-drawer__header unnnic-drawer__header">
7
- <section data-v-196de012="" class="unnnic-drawer__title-container">
8
- <div data-v-196de012="" class="unnnic-drawer__title" data-testid="drawer-title">Test Title</div>
9
- <div data-v-196de012="" class="unnnic-drawer__description" data-testid="drawer-description">Test Description</div>
10
- </section>
11
- <div data-v-196de012="">
12
- <unnnic-button-stub data-v-196de012="" size="small" text="" type="tertiary" float="false" iconleft="" iconright="" iconcenter="arrow_forward" iconsfilled="false" disabled="false" loading="false" class="unnnic-drawer__close-icon" data-testid="close-icon"></unnnic-button-stub>
13
- </div>
14
- </header>
15
- <section data-v-196de012="" class="unnnic-drawer__content"></section>
16
- <div data-v-196de012="" class="unnnic-drawer__footer" data-testid="footer">
17
- <unnnic-button-stub data-v-196de012="" size="large" text="Secondary Action" type="tertiary" float="false" iconleft="" iconright="" iconcenter="" iconsfilled="false" disabled="false" loading="false" data-testid="secondary-button"></unnnic-button-stub>
18
- <unnnic-button-stub data-v-196de012="" size="large" text="Primary Action" type="primary" float="false" iconleft="" iconright="" iconcenter="" iconsfilled="false" disabled="false" loading="false" data-testid="primary-button"></unnnic-button-stub>
19
- </div>
20
- </div>
21
- </div>"
4
+ "<aside data-v-196de012="" class="unnnic-drawer" data-testid="drawer">
5
+ <section data-v-196de012="" class="unnnic-drawer__overlay" data-testid="overlay"></section>
6
+ <transition-stub data-v-196de012="" name="drawer" appear="true" persisted="false" css="true">
7
+ <section data-v-196de012="" data-testid="drawer-container" class="unnnic-drawer__container unnnic-drawer__container--md">
8
+ <header data-v-196de012="" class="unnnic-drawer__header">
9
+ <section data-v-196de012="" class="unnnic-drawer__title-container">
10
+ <h1 data-v-196de012="" class="unnnic-drawer__title" data-testid="drawer-title">Test Title</h1>
11
+ <p data-v-196de012="" class="unnnic-drawer__description" data-testid="drawer-description">Test Description</p>
12
+ </section>
13
+ <unnnic-icon-stub data-v-196de012="" filled="false" icon="arrow_back" clickable="true" size="avatar-nano" scheme="neutral-darkest" class="unnnic-drawer__close" data-testid="close-icon"></unnnic-icon-stub>
14
+ </header>
15
+ <section data-v-196de012="" class="unnnic-drawer__content"></section>
16
+ <footer data-v-196de012="" class="unnnic-drawer__footer" data-testid="footer">
17
+ <unnnic-button-stub data-v-196de012="" size="large" text="Secondary Action" type="tertiary" float="false" iconleft="" iconright="" iconcenter="" iconsfilled="false" disabled="false" loading="false" data-testid="secondary-button"></unnnic-button-stub>
18
+ <unnnic-button-stub data-v-196de012="" size="large" text="Primary Action" type="primary" float="false" iconleft="" iconright="" iconcenter="" iconsfilled="false" disabled="false" loading="false" data-testid="primary-button"></unnnic-button-stub>
19
+ </footer>
20
+ </section>
21
+ </transition-stub>
22
+ </aside>"
22
23
  `;