@weni/unnnic-system 3.12.8-alpha.0 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/{es-52edeb71.mjs → es-41fceca9.mjs} +1 -1
- package/dist/{index-756fe685.mjs → index-cca96b43.mjs} +26458 -29323
- package/dist/index.d.ts +1652 -4902
- package/dist/{pt-br-24583c8c.mjs → pt-br-a3088529.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +204 -232
- package/dist/unnnic.umd.js +44 -48
- package/package.json +2 -3
- package/src/assets/scss/scheme-colors.scss +223 -223
- package/src/assets/scss/tailwind.scss +0 -8
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +1 -1
- package/src/components/Checkbox/Checkbox.vue +1 -1
- package/src/components/Drawer/Drawer.vue +269 -190
- package/src/components/Drawer/__tests__/Drawer.spec.js +46 -37
- package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +19 -18
- package/src/components/FormElement/FormElement.vue +1 -1
- package/src/components/Input/Input.scss +2 -0
- package/src/components/ModalDialog/ModalDialog.vue +148 -64
- package/src/components/ModalDialog/__tests__/ModalDialog.spec.js +221 -11
- package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +22 -1
- package/src/components/MultiSelect/MultiSelect.vue +297 -0
- package/src/components/Radio/Radio.vue +1 -1
- package/src/components/Select/index.vue +3 -3
- package/src/components/Switch/Switch.vue +1 -1
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -3
- package/src/components/TemplatePreview/TemplatePreview.vue +2 -2
- package/src/components/TemplatePreview/TemplatePreviewModal.vue +1 -1
- package/src/components/Toast/Toast.vue +9 -16
- package/src/components/ToolTip/ToolTip.vue +177 -25
- package/src/components/ToolTip/__tests__/ToolTip.spec.js +61 -339
- package/src/components/index.ts +2 -58
- package/src/components/ui/popover/PopoverContent.vue +4 -5
- package/src/components/ui/popover/PopoverTrigger.vue +1 -5
- package/src/stories/Drawer.stories.js +1 -1
- package/src/stories/ModalDialog.mdx +0 -3
- package/src/stories/ModalDialog.stories.js +1 -1
- package/src/stories/MultiSelect.stories.js +45 -143
- package/src/components/MultiSelect/MultSelectOption.vue +0 -49
- package/src/components/MultiSelect/__tests__/MultiSelect.spec.js +0 -557
- package/src/components/MultiSelect/__tests__/MultiSelectOption.spec.js +0 -229
- package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +0 -87
- package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +0 -51
- package/src/components/MultiSelect/index.vue +0 -265
- package/src/components/ui/dialog/Dialog.vue +0 -19
- package/src/components/ui/dialog/DialogClose.vue +0 -29
- package/src/components/ui/dialog/DialogContent.vue +0 -140
- package/src/components/ui/dialog/DialogFooter.vue +0 -50
- package/src/components/ui/dialog/DialogHeader.vue +0 -83
- package/src/components/ui/dialog/DialogTitle.vue +0 -38
- package/src/components/ui/dialog/DialogTrigger.vue +0 -16
- package/src/components/ui/dialog/index.ts +0 -7
- package/src/components/ui/drawer/Drawer.vue +0 -27
- package/src/components/ui/drawer/DrawerClose.vue +0 -31
- package/src/components/ui/drawer/DrawerContent.vue +0 -111
- package/src/components/ui/drawer/DrawerDescription.vue +0 -40
- package/src/components/ui/drawer/DrawerFooter.vue +0 -38
- package/src/components/ui/drawer/DrawerHeader.vue +0 -57
- package/src/components/ui/drawer/DrawerOverlay.vue +0 -33
- package/src/components/ui/drawer/DrawerTitle.vue +0 -37
- package/src/components/ui/drawer/DrawerTrigger.vue +0 -31
- package/src/components/ui/drawer/index.ts +0 -10
- package/src/components/ui/tooltip/Tooltip.vue +0 -21
- package/src/components/ui/tooltip/TooltipContent.vue +0 -74
- package/src/components/ui/tooltip/TooltipTrigger.vue +0 -26
- package/src/components/ui/tooltip/index.ts +0 -3
- package/src/lib/layer-manager.ts +0 -92
- package/src/stories/Dialog.stories.js +0 -832
- package/src/stories/DrawerNext.stories.js +0 -611
- package/src/stories/LayerManager.docs.mdx +0 -40
- package/src/stories/LayerManager.stories.js +0 -364
|
@@ -1,210 +1,198 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
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
|
-
<
|
|
9
|
-
v-
|
|
10
|
-
|
|
11
|
-
data-testid="
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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"
|
|
16
|
+
>
|
|
17
|
+
<section
|
|
18
|
+
v-if="showDrawer"
|
|
19
|
+
data-testid="drawer-container"
|
|
20
|
+
:class="[
|
|
15
21
|
'unnnic-drawer__container',
|
|
16
22
|
`unnnic-drawer__container--${size}`,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<section class="unnnic-drawer__title-container">
|
|
25
|
-
<slot
|
|
26
|
-
v-if="$slots.title"
|
|
27
|
-
name="title"
|
|
28
|
-
/>
|
|
29
|
-
|
|
30
|
-
<template v-else>
|
|
31
|
-
<DrawerTitle
|
|
32
|
-
class="unnnic-drawer__title"
|
|
33
|
-
data-testid="drawer-title"
|
|
34
|
-
>
|
|
35
|
-
{{ title }}
|
|
36
|
-
</DrawerTitle>
|
|
37
|
-
<DrawerDescription
|
|
38
|
-
v-if="description"
|
|
39
|
-
class="unnnic-drawer__description"
|
|
40
|
-
data-testid="drawer-description"
|
|
41
|
-
>
|
|
42
|
-
{{ description }}
|
|
43
|
-
</DrawerDescription>
|
|
44
|
-
</template>
|
|
45
|
-
</section>
|
|
46
|
-
<template #close>
|
|
47
|
-
<DrawerClose>
|
|
48
|
-
<UnnnicButton
|
|
49
|
-
class="unnnic-drawer__close-icon"
|
|
50
|
-
data-testid="close-icon"
|
|
51
|
-
:iconCenter="closeIcon"
|
|
52
|
-
size="small"
|
|
53
|
-
type="tertiary"
|
|
54
|
-
@click="back"
|
|
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"
|
|
55
30
|
/>
|
|
56
|
-
</DrawerClose>
|
|
57
|
-
</template>
|
|
58
|
-
</DrawerHeader>
|
|
59
31
|
|
|
60
|
-
|
|
61
|
-
|
|
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>
|
|
62
86
|
</section>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
v-if="showFooter"
|
|
66
|
-
class="unnnic-drawer__footer"
|
|
67
|
-
data-testid="footer"
|
|
68
|
-
>
|
|
69
|
-
<UnnnicButton
|
|
70
|
-
v-if="secondaryButtonText"
|
|
71
|
-
data-testid="secondary-button"
|
|
72
|
-
size="large"
|
|
73
|
-
type="tertiary"
|
|
74
|
-
:disabled="disabledSecondaryButton"
|
|
75
|
-
:loading="loadingSecondaryButton"
|
|
76
|
-
:text="secondaryButtonText"
|
|
77
|
-
@click="$emit('secondaryButtonClick')"
|
|
78
|
-
/>
|
|
79
|
-
<UnnnicButton
|
|
80
|
-
v-if="primaryButtonText"
|
|
81
|
-
data-testid="primary-button"
|
|
82
|
-
size="large"
|
|
83
|
-
:disabled="disabledPrimaryButton"
|
|
84
|
-
:loading="loadingPrimaryButton"
|
|
85
|
-
:type="primaryButtonType"
|
|
86
|
-
:text="primaryButtonText"
|
|
87
|
-
@click="$emit('primaryButtonClick')"
|
|
88
|
-
/>
|
|
89
|
-
</DrawerFooter>
|
|
90
|
-
</DrawerContent>
|
|
91
|
-
</Drawer>
|
|
87
|
+
</Transition>
|
|
88
|
+
</aside>
|
|
92
89
|
</template>
|
|
93
90
|
|
|
94
|
-
<script
|
|
95
|
-
import
|
|
96
|
-
|
|
91
|
+
<script>
|
|
92
|
+
import UnnnicIcon from '../Icon.vue';
|
|
97
93
|
import UnnnicButton from '../Button/Button.vue';
|
|
98
|
-
import {
|
|
99
|
-
Drawer,
|
|
100
|
-
DrawerContent,
|
|
101
|
-
DrawerHeader,
|
|
102
|
-
DrawerFooter,
|
|
103
|
-
DrawerClose,
|
|
104
|
-
DrawerTitle,
|
|
105
|
-
DrawerDescription,
|
|
106
|
-
} from '../ui/drawer';
|
|
107
|
-
|
|
108
|
-
defineOptions({
|
|
109
|
-
name: 'UnnnicDrawer',
|
|
110
|
-
inheritAttrs: false,
|
|
111
|
-
});
|
|
112
94
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
description: {
|
|
119
|
-
type: String,
|
|
120
|
-
default: '',
|
|
121
|
-
},
|
|
122
|
-
disabledPrimaryButton: {
|
|
123
|
-
type: Boolean,
|
|
124
|
-
default: false,
|
|
125
|
-
},
|
|
126
|
-
disabledSecondaryButton: {
|
|
127
|
-
type: Boolean,
|
|
128
|
-
default: false,
|
|
129
|
-
},
|
|
130
|
-
loadingPrimaryButton: {
|
|
131
|
-
type: Boolean,
|
|
132
|
-
default: false,
|
|
133
|
-
},
|
|
134
|
-
loadingSecondaryButton: {
|
|
135
|
-
type: Boolean,
|
|
136
|
-
default: false,
|
|
137
|
-
},
|
|
138
|
-
primaryButtonText: {
|
|
139
|
-
type: String,
|
|
140
|
-
default: '',
|
|
141
|
-
},
|
|
142
|
-
primaryButtonType: {
|
|
143
|
-
type: String,
|
|
144
|
-
default: 'primary',
|
|
145
|
-
},
|
|
146
|
-
secondaryButtonText: {
|
|
147
|
-
type: String,
|
|
148
|
-
default: '',
|
|
95
|
+
export default {
|
|
96
|
+
name: 'UnnnicDrawer',
|
|
97
|
+
components: {
|
|
98
|
+
UnnnicIcon,
|
|
99
|
+
UnnnicButton,
|
|
149
100
|
},
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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,
|
|
155
164
|
},
|
|
156
165
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
type: Boolean,
|
|
163
|
-
default: false,
|
|
164
|
-
},
|
|
165
|
-
closeIcon: {
|
|
166
|
-
type: String,
|
|
167
|
-
default: 'arrow_forward',
|
|
166
|
+
emits: ['primaryButtonClick', 'secondaryButtonClick', 'close', 'back'],
|
|
167
|
+
data() {
|
|
168
|
+
return {
|
|
169
|
+
showDrawer: true,
|
|
170
|
+
};
|
|
168
171
|
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
computed: {
|
|
173
|
+
showFooter() {
|
|
174
|
+
return !!(this.primaryButtonText || this.secondaryButtonText);
|
|
175
|
+
},
|
|
172
176
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
+
},
|
|
176
195
|
},
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const emit = defineEmits([
|
|
180
|
-
'primaryButtonClick',
|
|
181
|
-
'secondaryButtonClick',
|
|
182
|
-
'close',
|
|
183
|
-
'back',
|
|
184
|
-
]);
|
|
185
|
-
const showFooter = computed(
|
|
186
|
-
() => !!(props.primaryButtonText || props.secondaryButtonText),
|
|
187
|
-
);
|
|
188
|
-
const mappedSize = computed(() => {
|
|
189
|
-
const sizes = {
|
|
190
|
-
md: 'medium',
|
|
191
|
-
lg: 'large',
|
|
192
|
-
xl: 'extra-large',
|
|
193
|
-
gt: 'giant',
|
|
194
|
-
};
|
|
195
|
-
return sizes[props.size] || 'medium';
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
const close = () => {
|
|
199
|
-
emit('close');
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const back = () => {
|
|
203
|
-
if (props.distinctCloseBack) {
|
|
204
|
-
emit('back');
|
|
205
|
-
} else {
|
|
206
|
-
close();
|
|
207
|
-
}
|
|
208
196
|
};
|
|
209
197
|
</script>
|
|
210
198
|
|
|
@@ -216,16 +204,107 @@ const back = () => {
|
|
|
216
204
|
box-sizing: border-box;
|
|
217
205
|
}
|
|
218
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
|
+
|
|
219
236
|
.unnnic-drawer {
|
|
237
|
+
width: 100vw;
|
|
238
|
+
height: 100vh;
|
|
239
|
+
position: fixed;
|
|
240
|
+
left: 0;
|
|
241
|
+
top: 0;
|
|
220
242
|
z-index: 8;
|
|
221
243
|
}
|
|
222
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
|
+
|
|
223
252
|
.unnnic-drawer__container {
|
|
224
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
|
+
}
|
|
225
271
|
|
|
226
|
-
|
|
227
|
-
|
|
272
|
+
&--xl {
|
|
273
|
+
width: 66%;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
&--gt {
|
|
277
|
+
width: 75%;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.unnnic-drawer__header {
|
|
228
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
|
+
}
|
|
229
308
|
}
|
|
230
309
|
|
|
231
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,14 +15,15 @@ describe('Drawer.vue', () => {
|
|
|
28
15
|
secondaryButtonText: 'Secondary Action',
|
|
29
16
|
},
|
|
30
17
|
global: {
|
|
31
|
-
stubs:
|
|
18
|
+
stubs: ['UnnnicIcon', 'UnnnicButton'],
|
|
32
19
|
},
|
|
33
20
|
});
|
|
34
21
|
});
|
|
35
22
|
|
|
36
23
|
const element = (id) => wrapper.find(`[data-testid="${id}"]`);
|
|
37
24
|
const component = (id) => wrapper.findComponent(`[data-testid="${id}"]`);
|
|
38
|
-
const
|
|
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');
|
|
@@ -43,8 +31,6 @@ describe('Drawer.vue', () => {
|
|
|
43
31
|
const footer = () => element('footer');
|
|
44
32
|
const closeIcon = () => component('close-icon');
|
|
45
33
|
const drawerContainer = () => element('drawer-container');
|
|
46
|
-
const drawerContentComponent = () =>
|
|
47
|
-
wrapper.findComponent({ name: 'UnnnicDrawerContent' });
|
|
48
34
|
|
|
49
35
|
describe('Component Rendering', () => {
|
|
50
36
|
describe('Component Rendering', () => {
|
|
@@ -53,21 +39,21 @@ describe('Drawer.vue', () => {
|
|
|
53
39
|
});
|
|
54
40
|
|
|
55
41
|
it('should render the drawer when modelValue is true', () => {
|
|
56
|
-
expect(
|
|
42
|
+
expect(drawer().exists()).toBe(true);
|
|
57
43
|
});
|
|
58
44
|
|
|
59
45
|
it('should not render the drawer when modelValue is false', async () => {
|
|
60
46
|
await wrapper.setProps({ modelValue: false });
|
|
61
|
-
expect(
|
|
47
|
+
expect(drawer().exists()).toBe(false);
|
|
62
48
|
});
|
|
63
49
|
|
|
64
50
|
it('should render the overlay when withoutOverlay is false', () => {
|
|
65
|
-
expect(
|
|
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(
|
|
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,21 +193,49 @@ 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', () => {
|
|
218
229
|
it('should render the correct size class based on size prop', async () => {
|
|
219
230
|
await wrapper.setProps({ size: 'lg' });
|
|
220
|
-
expect(
|
|
231
|
+
expect(drawerContainer().classes()).toContain(
|
|
221
232
|
'unnnic-drawer__container--lg',
|
|
222
233
|
);
|
|
223
|
-
expect(drawerContentComponent().props('size')).toBe('large');
|
|
224
234
|
|
|
225
235
|
await wrapper.setProps({ size: 'xl' });
|
|
226
|
-
expect(
|
|
236
|
+
expect(drawerContainer().classes()).toContain(
|
|
227
237
|
'unnnic-drawer__container--xl',
|
|
228
238
|
);
|
|
229
|
-
expect(drawerContentComponent().props('size')).toBe('extra-large');
|
|
230
239
|
});
|
|
231
240
|
|
|
232
241
|
it('should display footer if either primaryButtonText or secondaryButtonText is provided', async () => {
|
|
@@ -266,7 +275,7 @@ describe('Drawer.vue', () => {
|
|
|
266
275
|
|
|
267
276
|
it('should use correct icon for close button based on closeIcon prop', async () => {
|
|
268
277
|
await wrapper.setProps({ closeIcon: 'custom_close_icon' });
|
|
269
|
-
expect(closeIcon().props('
|
|
278
|
+
expect(closeIcon().props('icon')).toBe('custom_close_icon');
|
|
270
279
|
});
|
|
271
280
|
|
|
272
281
|
it('should validate all size prop values correctly', () => {
|