@weni/unnnic-system 3.14.0-alpha-teleports.0 → 3.15.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 +11 -0
- package/README.md +1 -9
- package/dist/{es-0d53b5b2.mjs → es-b51fb49d.mjs} +1 -1
- package/dist/{index-d7070de8.mjs → index-88ec0352.mjs} +26529 -29321
- package/dist/index.d.ts +1485 -4826
- package/dist/{pt-br-bf4e1f97.mjs → pt-br-cd9f0dbc.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +204 -232
- package/dist/unnnic.umd.js +46 -50
- package/package.json +2 -3
- package/src/assets/scss/tailwind.scss +0 -8
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +1 -1
- package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +1 -2
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +60 -61
- package/src/components/CheckboxGroup/CheckboxGroup.vue +7 -5
- package/src/components/Chip/Chip.vue +1 -1
- package/src/components/DatePicker/DatePicker.vue +1 -10
- package/src/components/Drawer/Drawer.vue +270 -180
- package/src/components/Drawer/__tests__/Drawer.spec.js +43 -32
- package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +19 -18
- package/src/components/FormElement/FormElement.vue +96 -87
- package/src/components/InputDatePicker/InputDatePicker.vue +73 -68
- package/src/components/InputDatePicker/__test__/InputDatePicker.spec.js +24 -31
- package/src/components/ModalDialog/ModalDialog.vue +154 -63
- package/src/components/ModalDialog/__tests__/ModalDialog.spec.js +210 -30
- package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +22 -1
- package/src/components/Radio/Radio.vue +12 -6
- package/src/components/Radio/__test__/Radio.spec.js +3 -1
- package/src/components/RadioGroup/RadioGroup.vue +18 -10
- package/src/components/Select/__tests__/Select.spec.js +74 -0
- package/src/components/Select/__tests__/SelectItem.spec.js +35 -15
- package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +18 -0
- package/src/components/Select/index.vue +131 -22
- package/src/components/Switch/Switch.vue +10 -3
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -3
- package/src/components/TemplatePreview/TemplatePreview.vue +28 -25
- package/src/components/TemplatePreview/TemplatePreviewModal.vue +10 -10
- package/src/components/TemplatePreview/types.d.ts +3 -3
- package/src/components/Toast/Toast.vue +1 -4
- package/src/components/Toast/ToastManager.ts +1 -4
- package/src/components/Toast/__tests__/ToastManager.spec.js +6 -10
- package/src/components/ToolTip/ToolTip.vue +177 -25
- package/src/components/ToolTip/__tests__/ToolTip.spec.js +61 -339
- package/src/components/index.ts +0 -56
- package/src/components/ui/popover/PopoverContent.vue +4 -7
- package/src/components/ui/popover/PopoverTrigger.vue +1 -5
- package/src/index.ts +2 -9
- package/src/stories/Drawer.stories.js +1 -1
- package/src/stories/ModalDialog.mdx +0 -3
- package/src/stories/ModalDialog.stories.js +1 -96
- package/src/stories/Select.stories.js +86 -0
- package/src/stories/TemplatePreview.stories.js +27 -27
- package/src/stories/TemplatePreviewModal.stories.js +31 -31
- 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 -113
- 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 -77
- package/src/components/ui/tooltip/TooltipTrigger.vue +0 -24
- package/src/components/ui/tooltip/index.ts +0 -3
- package/src/lib/__tests__/teleport-target.spec.ts +0 -73
- package/src/lib/layer-manager.ts +0 -64
- package/src/lib/teleport-target.ts +0 -46
- 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 -407
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<section
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<section
|
|
3
|
+
class="unnnic-form-element"
|
|
4
|
+
:class="{ 'unnnic-form-element--disabled': disabled }"
|
|
5
|
+
>
|
|
6
|
+
<UnnnicLabel
|
|
7
|
+
v-if="label"
|
|
8
|
+
:label="label"
|
|
6
9
|
:tooltip="tooltip"
|
|
7
10
|
:class="[
|
|
8
11
|
'unnnic-form-element__label',
|
|
9
12
|
{
|
|
10
13
|
'unnnic-form-element__label--fixed': fixedLabel,
|
|
11
14
|
},
|
|
12
|
-
]"
|
|
15
|
+
]"
|
|
13
16
|
/>
|
|
14
17
|
|
|
15
18
|
<slot></slot>
|
|
16
19
|
|
|
17
|
-
<section
|
|
20
|
+
<section
|
|
18
21
|
class="unnnic-form-element__hints-container"
|
|
19
22
|
v-if="message || error || !!$slots.rightMessage"
|
|
20
23
|
>
|
|
21
24
|
<section class="unnnic-form-element__message-container">
|
|
22
|
-
<p
|
|
25
|
+
<p
|
|
26
|
+
v-if="message"
|
|
27
|
+
class="unnnic-form-element__message"
|
|
28
|
+
>
|
|
23
29
|
{{ fullySanitize(message) }}
|
|
24
30
|
</p>
|
|
25
|
-
<p
|
|
31
|
+
<p
|
|
32
|
+
v-if="!!error?.length"
|
|
33
|
+
class="unnnic-form-element__message error"
|
|
34
|
+
>
|
|
26
35
|
{{ Array.isArray(error) ? error.join(', ') : error }}
|
|
27
36
|
</p>
|
|
28
37
|
</section>
|
|
@@ -34,104 +43,104 @@
|
|
|
34
43
|
</template>
|
|
35
44
|
|
|
36
45
|
<script lang="js">
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
import { fullySanitize } from '../../utils/sanitize';
|
|
47
|
+
import UnnnicLabel from '../Label/Label.vue';
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
components: {
|
|
51
|
+
UnnnicLabel,
|
|
52
|
+
},
|
|
53
|
+
props: {
|
|
54
|
+
size: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: 'md',
|
|
57
|
+
validator: (size) => ['md', 'sm'].includes(size),
|
|
43
58
|
},
|
|
44
|
-
props: {
|
|
45
|
-
size: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: 'md',
|
|
48
|
-
validator: (size) => ['md', 'sm'].includes(size),
|
|
49
|
-
},
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
label: { type: String, default: '' },
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
fixedLabel: { type: Boolean, default: false },
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
error: {
|
|
65
|
+
type: [Boolean, String],
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
message: { type: String, default: '' },
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
disabled: { type: Boolean, default: false },
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
tooltip: { type: String, default: '' },
|
|
74
|
+
},
|
|
75
|
+
methods: {
|
|
76
|
+
fullySanitize,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
70
79
|
</script>
|
|
71
80
|
|
|
72
81
|
<style lang="scss" scoped>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
@use '@/assets/scss/unnnic' as *;
|
|
83
|
+
|
|
84
|
+
* {
|
|
85
|
+
margin: $unnnic-space-0;
|
|
86
|
+
padding: $unnnic-space-0;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.unnnic-form-element {
|
|
91
|
+
&__label {
|
|
92
|
+
font: $unnnic-font-body;
|
|
93
|
+
color: $unnnic-color-neutral-cloudy;
|
|
94
|
+
margin-bottom: $unnnic-space-1;
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: $unnnic-space-2;
|
|
98
|
+
|
|
99
|
+
&--fixed {
|
|
100
|
+
margin-top: -$unnnic-font-size-body-gt - $unnnic-space-2 + $unnnic-space-1;
|
|
101
|
+
}
|
|
80
102
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
margin-
|
|
86
|
-
display: flex;
|
|
87
|
-
align-items: center;
|
|
88
|
-
gap: $unnnic-space-2;
|
|
89
|
-
|
|
90
|
-
&--fixed {
|
|
91
|
-
margin-top: -$unnnic-font-size-body-gt - $unnnic-space-2 + $unnnic-space-1;
|
|
92
|
-
}
|
|
103
|
+
&--fixed {
|
|
104
|
+
margin-bottom: $unnnic-space-0;
|
|
105
|
+
position: absolute;
|
|
106
|
+
padding: $unnnic-space-0 $unnnic-space-1;
|
|
107
|
+
margin-left: $unnnic-space-2;
|
|
93
108
|
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
&:after {
|
|
110
|
+
content: ' ';
|
|
96
111
|
position: absolute;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
position: absolute;
|
|
103
|
-
left: $unnnic-space-0;
|
|
104
|
-
bottom: $unnnic-space-1 - $unnnic-border-width-thinner;
|
|
105
|
-
width: 100%;
|
|
106
|
-
height: $unnnic-border-width-thinner;
|
|
107
|
-
background-color: $unnnic-color-white;
|
|
108
|
-
}
|
|
112
|
+
left: $unnnic-space-0;
|
|
113
|
+
bottom: $unnnic-space-1 - $unnnic-border-width-thinner;
|
|
114
|
+
width: 100%;
|
|
115
|
+
height: $unnnic-border-width-thinner;
|
|
116
|
+
background-color: $unnnic-color-white;
|
|
109
117
|
}
|
|
110
118
|
}
|
|
119
|
+
}
|
|
111
120
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
121
|
+
&__message {
|
|
122
|
+
&.error {
|
|
123
|
+
color: $unnnic-color-fg-critical;
|
|
116
124
|
}
|
|
125
|
+
}
|
|
117
126
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
&__hints-container {
|
|
128
|
+
display: flex;
|
|
129
|
+
justify-content: space-between;
|
|
130
|
+
margin-top: $unnnic-space-1;
|
|
131
|
+
font: $unnnic-font-caption-2;
|
|
132
|
+
color: $unnnic-color-fg-base;
|
|
133
|
+
}
|
|
125
134
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
&__message-container {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
gap: $unnnic-space-1;
|
|
139
|
+
}
|
|
131
140
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
141
|
+
&--disabled .unnnic-form-element__label,
|
|
142
|
+
&--disabled .unnnic-form-element__message {
|
|
143
|
+
user-select: none;
|
|
136
144
|
}
|
|
145
|
+
}
|
|
137
146
|
</style>
|
|
@@ -1,61 +1,51 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@change="emitSelectDate"
|
|
41
|
-
@submit="changeDate"
|
|
42
|
-
/>
|
|
43
|
-
</UnnnicPopoverContent>
|
|
44
|
-
</UnnnicPopover>
|
|
2
|
+
<div
|
|
3
|
+
ref="dropdown"
|
|
4
|
+
:class="['dropdown', { active: showCalendarFilter, 'fill-w': fillW }]"
|
|
5
|
+
>
|
|
6
|
+
<UnnnicInput
|
|
7
|
+
:class="['input', { 'date-picker-input-next': next }]"
|
|
8
|
+
:size="size"
|
|
9
|
+
:iconLeft="iconPosition === 'left' ? 'calendar_month' : undefined"
|
|
10
|
+
:iconRight="iconPosition === 'right' ? 'calendar_month' : undefined"
|
|
11
|
+
hasCloudyColor
|
|
12
|
+
readonly
|
|
13
|
+
:modelValue="overwrittenValue || filterText || ''"
|
|
14
|
+
@focus="showCalendarFilter = true"
|
|
15
|
+
/>
|
|
16
|
+
|
|
17
|
+
<div
|
|
18
|
+
class="dropdown-data"
|
|
19
|
+
:style="{ [position]: '0' }"
|
|
20
|
+
>
|
|
21
|
+
<UnnnicDatePicker
|
|
22
|
+
v-if="showCalendarFilter"
|
|
23
|
+
v-model:equivalentOption="overwrittenValue"
|
|
24
|
+
:type="type"
|
|
25
|
+
:clearLabel="clearText"
|
|
26
|
+
:actionLabel="actionText"
|
|
27
|
+
:months="months"
|
|
28
|
+
:days="days"
|
|
29
|
+
:options="options"
|
|
30
|
+
:periodBaseDate="periodBaseDate"
|
|
31
|
+
:initialStartDate="initialStartDate"
|
|
32
|
+
:initialEndDate="initialEndDate"
|
|
33
|
+
:minDate="minDate"
|
|
34
|
+
:maxDate="maxDate"
|
|
35
|
+
:disableClear="disableClear"
|
|
36
|
+
@change="emitSelectDate"
|
|
37
|
+
@submit="changeDate"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
45
40
|
</div>
|
|
46
41
|
</template>
|
|
47
42
|
|
|
48
43
|
<script setup lang="ts">
|
|
49
|
-
import { computed, ref } from 'vue';
|
|
44
|
+
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
|
50
45
|
import moment from 'moment';
|
|
51
46
|
|
|
52
47
|
import UnnnicInput from '../Input/Input.vue';
|
|
53
48
|
import UnnnicDatePicker from '../DatePicker/DatePicker.vue';
|
|
54
|
-
import {
|
|
55
|
-
Popover as UnnnicPopover,
|
|
56
|
-
PopoverContent as UnnnicPopoverContent,
|
|
57
|
-
PopoverTrigger as UnnnicPopoverTrigger,
|
|
58
|
-
} from '../ui/popover';
|
|
59
49
|
|
|
60
50
|
defineOptions({
|
|
61
51
|
name: 'UnnnicInputDatePicker',
|
|
@@ -122,11 +112,9 @@ const emit = defineEmits<{
|
|
|
122
112
|
(e: 'selectDate', value: DateRangeValue): void;
|
|
123
113
|
}>();
|
|
124
114
|
|
|
125
|
-
const
|
|
115
|
+
const dropdown = ref<HTMLElement | null>(null);
|
|
116
|
+
const showCalendarFilter = ref(false);
|
|
126
117
|
const overwrittenValue = ref('');
|
|
127
|
-
const popoverAlign = computed<'start' | 'end'>(() =>
|
|
128
|
-
props.position === 'right' ? 'end' : 'start',
|
|
129
|
-
);
|
|
130
118
|
|
|
131
119
|
const filterText = computed(() => {
|
|
132
120
|
const dates: string[] = [];
|
|
@@ -172,12 +160,20 @@ function emitSelectDate(date: { startDate: string; endDate: string }) {
|
|
|
172
160
|
emit('selectDate', formattedDates);
|
|
173
161
|
}
|
|
174
162
|
|
|
163
|
+
function mouseout(event: MouseEvent | { target: EventTarget | null }) {
|
|
164
|
+
if (dropdown.value?.contains(event.target as Node)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
showCalendarFilter.value = false;
|
|
169
|
+
}
|
|
170
|
+
|
|
175
171
|
function changeDate(value: { startDate: string; endDate: string }) {
|
|
176
172
|
const startDate = value.startDate.replace(/(\d+)-(\d+)-(\d+)/, '$3-$1-$2');
|
|
177
173
|
|
|
178
174
|
const endDate = value.endDate.replace(/(\d+)-(\d+)-(\d+)/, '$3-$1-$2');
|
|
179
175
|
|
|
180
|
-
|
|
176
|
+
showCalendarFilter.value = false;
|
|
181
177
|
|
|
182
178
|
emit('update:model-value', {
|
|
183
179
|
start: startDate
|
|
@@ -187,30 +183,39 @@ function changeDate(value: { startDate: string; endDate: string }) {
|
|
|
187
183
|
});
|
|
188
184
|
}
|
|
189
185
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
</script>
|
|
194
|
-
|
|
195
|
-
<style lang="scss">
|
|
196
|
-
@use '@/assets/scss/unnnic' as *;
|
|
186
|
+
onMounted(() => {
|
|
187
|
+
window.document.body.addEventListener('click', mouseout as any);
|
|
188
|
+
});
|
|
197
189
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
</style>
|
|
190
|
+
onBeforeUnmount(() => {
|
|
191
|
+
window.document.body.removeEventListener('click', mouseout as any);
|
|
192
|
+
});
|
|
193
|
+
</script>
|
|
204
194
|
|
|
205
195
|
<style lang="scss" scoped>
|
|
206
196
|
@use '@/assets/scss/unnnic' as *;
|
|
207
197
|
.fill-w {
|
|
208
198
|
width: 100%;
|
|
209
199
|
}
|
|
210
|
-
|
|
211
200
|
.dropdown {
|
|
201
|
+
position: relative;
|
|
212
202
|
display: inline-block;
|
|
213
203
|
|
|
204
|
+
.dropdown-data {
|
|
205
|
+
position: absolute;
|
|
206
|
+
pointer-events: none;
|
|
207
|
+
display: none;
|
|
208
|
+
top: 100%;
|
|
209
|
+
z-index: 2;
|
|
210
|
+
margin-top: $unnnic-spacing-stack-nano;
|
|
211
|
+
width: max-content;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&.active .dropdown-data {
|
|
215
|
+
pointer-events: auto;
|
|
216
|
+
display: block;
|
|
217
|
+
}
|
|
218
|
+
|
|
214
219
|
.input {
|
|
215
220
|
display: inline-block;
|
|
216
221
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
4
3
|
import InputDatePicker from '../InputDatePicker.vue';
|
|
5
4
|
|
|
6
5
|
const factory = (props = {}) =>
|
|
@@ -12,7 +11,20 @@ const factory = (props = {}) =>
|
|
|
12
11
|
},
|
|
13
12
|
...props,
|
|
14
13
|
},
|
|
15
|
-
|
|
14
|
+
global: {
|
|
15
|
+
stubs: {
|
|
16
|
+
UnnnicInput: {
|
|
17
|
+
name: 'UnnnicInput',
|
|
18
|
+
template:
|
|
19
|
+
'<input data-testid="input" v-bind="$attrs" @focus="$emit(\'focus\', $event)" />',
|
|
20
|
+
},
|
|
21
|
+
UnnnicDatePicker: {
|
|
22
|
+
name: 'UnnnicDatePicker',
|
|
23
|
+
props: ['minDate', 'maxDate', 'periodBaseDate', 'options'],
|
|
24
|
+
template: '<div data-testid="datepicker"></div>',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
16
28
|
});
|
|
17
29
|
|
|
18
30
|
describe('InputDatePicker.vue', () => {
|
|
@@ -22,12 +34,6 @@ describe('InputDatePicker.vue', () => {
|
|
|
22
34
|
wrapper = factory();
|
|
23
35
|
});
|
|
24
36
|
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
if (wrapper) {
|
|
27
|
-
wrapper.unmount();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
37
|
it('renders input and does not show datepicker by default', () => {
|
|
32
38
|
expect(wrapper.find('[data-testid="input"]').exists()).toBe(true);
|
|
33
39
|
expect(wrapper.find('[data-testid="datepicker"]').exists()).toBe(false);
|
|
@@ -36,23 +42,13 @@ describe('InputDatePicker.vue', () => {
|
|
|
36
42
|
it('opens datepicker when input receives focus', async () => {
|
|
37
43
|
const input = wrapper.find('[data-testid="input"]');
|
|
38
44
|
await input.trigger('focus');
|
|
39
|
-
await wrapper.vm.$nextTick();
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
true,
|
|
43
|
-
);
|
|
44
|
-
expect(wrapper.vm.isPopoverOpen).toBe(true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('opens datepicker when input receives click', async () => {
|
|
48
|
-
const input = wrapper.find('[data-testid="input"]');
|
|
49
|
-
await input.trigger('click');
|
|
46
|
+
wrapper.vm.showCalendarFilter = true;
|
|
50
47
|
await wrapper.vm.$nextTick();
|
|
51
48
|
|
|
52
49
|
expect(wrapper.findComponent({ name: 'UnnnicDatePicker' }).exists()).toBe(
|
|
53
50
|
true,
|
|
54
51
|
);
|
|
55
|
-
expect(wrapper.vm.isPopoverOpen).toBe(true);
|
|
56
52
|
});
|
|
57
53
|
|
|
58
54
|
it('computes filterText placeholder when there is no date selected', () => {
|
|
@@ -70,7 +66,6 @@ describe('InputDatePicker.vue', () => {
|
|
|
70
66
|
});
|
|
71
67
|
|
|
72
68
|
expect(withDates.vm.filterText).toBe('01-10-2025 ~ 01-20-2025');
|
|
73
|
-
withDates.unmount();
|
|
74
69
|
});
|
|
75
70
|
|
|
76
71
|
it('computes initialStartDate and initialEndDate for DatePicker', () => {
|
|
@@ -83,11 +78,10 @@ describe('InputDatePicker.vue', () => {
|
|
|
83
78
|
|
|
84
79
|
expect(withDates.vm.initialStartDate).toBe('01 10 2025');
|
|
85
80
|
expect(withDates.vm.initialEndDate).toBe('01 20 2025');
|
|
86
|
-
withDates.unmount();
|
|
87
81
|
});
|
|
88
82
|
|
|
89
83
|
it('emits selectDate with formatted dates when DatePicker emits change', async () => {
|
|
90
|
-
wrapper.vm.
|
|
84
|
+
wrapper.vm.showCalendarFilter = true;
|
|
91
85
|
await wrapper.vm.$nextTick();
|
|
92
86
|
|
|
93
87
|
const datePicker = wrapper.findComponent({ name: 'UnnnicDatePicker' });
|
|
@@ -110,7 +104,7 @@ describe('InputDatePicker.vue', () => {
|
|
|
110
104
|
});
|
|
111
105
|
|
|
112
106
|
it('emits update:model-value and closes dropdown when DatePicker emits submit', async () => {
|
|
113
|
-
wrapper.vm.
|
|
107
|
+
wrapper.vm.showCalendarFilter = true;
|
|
114
108
|
await wrapper.vm.$nextTick();
|
|
115
109
|
|
|
116
110
|
const datePicker = wrapper.findComponent({ name: 'UnnnicDatePicker' });
|
|
@@ -131,7 +125,7 @@ describe('InputDatePicker.vue', () => {
|
|
|
131
125
|
end: '2025-01-20',
|
|
132
126
|
});
|
|
133
127
|
|
|
134
|
-
expect(wrapper.vm.
|
|
128
|
+
expect(wrapper.vm.showCalendarFilter).toBe(false);
|
|
135
129
|
});
|
|
136
130
|
|
|
137
131
|
it('passes minDate, maxDate, options and periodBaseDate down to DatePicker', async () => {
|
|
@@ -143,7 +137,7 @@ describe('InputDatePicker.vue', () => {
|
|
|
143
137
|
};
|
|
144
138
|
|
|
145
139
|
wrapper = factory(props);
|
|
146
|
-
wrapper.vm.
|
|
140
|
+
wrapper.vm.showCalendarFilter = true;
|
|
147
141
|
await wrapper.vm.$nextTick();
|
|
148
142
|
|
|
149
143
|
const datePicker = wrapper.findComponent({ name: 'UnnnicDatePicker' });
|
|
@@ -153,14 +147,13 @@ describe('InputDatePicker.vue', () => {
|
|
|
153
147
|
expect(dpProps.maxDate).toBe(props.maxDate);
|
|
154
148
|
expect(dpProps.periodBaseDate).toBe(props.periodBaseDate);
|
|
155
149
|
expect(dpProps.options).toEqual(props.options);
|
|
156
|
-
expect(dpProps.variant).toBe('popover');
|
|
157
150
|
});
|
|
158
151
|
|
|
159
|
-
it('
|
|
160
|
-
|
|
152
|
+
it('closes dropdown on mouseout when clicking outside', () => {
|
|
153
|
+
wrapper.vm.showCalendarFilter = true;
|
|
161
154
|
|
|
162
|
-
|
|
155
|
+
wrapper.vm.mouseout({ target: document.createElement('div') });
|
|
163
156
|
|
|
164
|
-
|
|
157
|
+
expect(wrapper.vm.showCalendarFilter).toBe(false);
|
|
165
158
|
});
|
|
166
159
|
});
|