@weni/unnnic-system 3.30.0 → 3.31.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/dist/style.css +1 -1
- package/dist/unnnic.mjs +3637 -3631
- package/dist/unnnic.umd.js +27 -27
- package/package.json +1 -1
- package/src/components/InputDatePicker/InputDatePicker.vue +9 -1
- package/src/components/InputDatePicker/__test__/InputDatePicker.spec.js +43 -1
- package/src/stories/InputDatePicker.stories.js +50 -0
package/package.json
CHANGED
|
@@ -42,13 +42,17 @@
|
|
|
42
42
|
@change="emitSelectDate"
|
|
43
43
|
@submit="changeDate"
|
|
44
44
|
/>
|
|
45
|
+
|
|
46
|
+
<UnnnicPopoverFooter v-if="hasFooterSlot">
|
|
47
|
+
<slot name="footer" />
|
|
48
|
+
</UnnnicPopoverFooter>
|
|
45
49
|
</UnnnicPopoverContent>
|
|
46
50
|
</UnnnicPopover>
|
|
47
51
|
</div>
|
|
48
52
|
</template>
|
|
49
53
|
|
|
50
54
|
<script setup lang="ts">
|
|
51
|
-
import { computed, ref } from 'vue';
|
|
55
|
+
import { computed, ref, useSlots } from 'vue';
|
|
52
56
|
import moment from 'moment';
|
|
53
57
|
|
|
54
58
|
import UnnnicInput from '../Input/Input.vue';
|
|
@@ -56,6 +60,7 @@ import UnnnicDatePicker from '../DatePicker/DatePicker.vue';
|
|
|
56
60
|
import {
|
|
57
61
|
Popover as UnnnicPopover,
|
|
58
62
|
PopoverContent as UnnnicPopoverContent,
|
|
63
|
+
PopoverFooter as UnnnicPopoverFooter,
|
|
59
64
|
PopoverTrigger as UnnnicPopoverTrigger,
|
|
60
65
|
} from '../ui/popover';
|
|
61
66
|
|
|
@@ -63,6 +68,9 @@ defineOptions({
|
|
|
63
68
|
name: 'UnnnicInputDatePicker',
|
|
64
69
|
});
|
|
65
70
|
|
|
71
|
+
const slots = useSlots();
|
|
72
|
+
const hasFooterSlot = computed(() => Boolean(slots.footer));
|
|
73
|
+
|
|
66
74
|
type DateRangeValue = {
|
|
67
75
|
start: string | null;
|
|
68
76
|
end: string | null;
|
|
@@ -3,7 +3,13 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
3
3
|
|
|
4
4
|
import InputDatePicker from '../InputDatePicker.vue';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const inlineSlot = { template: '<div><slot /></div>' };
|
|
7
|
+
const portalStubs = {
|
|
8
|
+
PopoverPortal: inlineSlot,
|
|
9
|
+
PopoverContent: inlineSlot,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const factory = (props = {}, { slots = {}, stubs = {} } = {}) =>
|
|
7
13
|
mount(InputDatePicker, {
|
|
8
14
|
props: {
|
|
9
15
|
modelValue: {
|
|
@@ -12,7 +18,11 @@ const factory = (props = {}) =>
|
|
|
12
18
|
},
|
|
13
19
|
...props,
|
|
14
20
|
},
|
|
21
|
+
slots,
|
|
15
22
|
attachTo: document.body,
|
|
23
|
+
global: {
|
|
24
|
+
stubs,
|
|
25
|
+
},
|
|
16
26
|
});
|
|
17
27
|
|
|
18
28
|
describe('InputDatePicker.vue', () => {
|
|
@@ -163,4 +173,36 @@ describe('InputDatePicker.vue', () => {
|
|
|
163
173
|
|
|
164
174
|
rightWrapper.unmount();
|
|
165
175
|
});
|
|
176
|
+
|
|
177
|
+
it('does not render PopoverFooter when the footer slot is empty', async () => {
|
|
178
|
+
wrapper.vm.isPopoverOpen = true;
|
|
179
|
+
await wrapper.vm.$nextTick();
|
|
180
|
+
|
|
181
|
+
expect(
|
|
182
|
+
wrapper.findComponent({ name: 'UnnnicPopoverFooter' }).exists(),
|
|
183
|
+
).toBe(false);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('renders the footer slot content inside PopoverFooter', async () => {
|
|
187
|
+
const withFooter = factory(
|
|
188
|
+
{},
|
|
189
|
+
{
|
|
190
|
+
slots: {
|
|
191
|
+
footer: '<p data-testid="custom-footer">Archive notice</p>',
|
|
192
|
+
},
|
|
193
|
+
stubs: portalStubs,
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
withFooter.vm.isPopoverOpen = true;
|
|
198
|
+
await withFooter.vm.$nextTick();
|
|
199
|
+
|
|
200
|
+
const footer = withFooter.findComponent({ name: 'UnnnicPopoverFooter' });
|
|
201
|
+
const customFooter = withFooter.find('[data-testid="custom-footer"]');
|
|
202
|
+
|
|
203
|
+
expect(footer.exists()).toBe(true);
|
|
204
|
+
expect(customFooter.text()).toBe('Archive notice');
|
|
205
|
+
|
|
206
|
+
withFooter.unmount();
|
|
207
|
+
});
|
|
166
208
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import UnnnicInputDatePicker from '../components/InputDatePicker/InputDatePicker.vue';
|
|
2
|
+
import UnnnicDisclaimer from '../components/Disclaimer/Disclaimer.vue';
|
|
2
3
|
import moment from 'moment';
|
|
3
4
|
export default {
|
|
4
5
|
title: 'Form/InputDatePicker',
|
|
@@ -103,3 +104,52 @@ export const WithDisableShowOverwrittenValue = {
|
|
|
103
104
|
disableShowOverwrittenValue: true,
|
|
104
105
|
},
|
|
105
106
|
};
|
|
107
|
+
|
|
108
|
+
export const WithFooter = {
|
|
109
|
+
args: {
|
|
110
|
+
size: 'sm',
|
|
111
|
+
next: true,
|
|
112
|
+
iconPosition: 'right',
|
|
113
|
+
fillW: true,
|
|
114
|
+
maxDate: moment().format('YYYY-MM-DD'),
|
|
115
|
+
minDate: moment().subtract(89, 'days').format('YYYY-MM-DD'),
|
|
116
|
+
options: [
|
|
117
|
+
{ name: 'Last 7 days', id: 'last-7-days' },
|
|
118
|
+
{ name: 'Last 14 days', id: 'last-14-days' },
|
|
119
|
+
{ name: 'Last 30 days', id: 'last-30-days' },
|
|
120
|
+
{ name: 'Last 90 days', id: 'last-90-days' },
|
|
121
|
+
{ name: 'Current month', id: 'current-month' },
|
|
122
|
+
{ name: 'Custom', id: 'custom' },
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
render: (args) => ({
|
|
126
|
+
components: {
|
|
127
|
+
UnnnicInputDatePicker,
|
|
128
|
+
UnnnicDisclaimer,
|
|
129
|
+
},
|
|
130
|
+
setup() {
|
|
131
|
+
return { args };
|
|
132
|
+
},
|
|
133
|
+
data() {
|
|
134
|
+
return {
|
|
135
|
+
dates: {
|
|
136
|
+
start: null,
|
|
137
|
+
end: null,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
template: `
|
|
142
|
+
<div style="max-width: 200px">
|
|
143
|
+
<pre>v-model: {{ dates }}</pre>
|
|
144
|
+
<UnnnicInputDatePicker v-bind="args" v-model="dates">
|
|
145
|
+
<template #footer>
|
|
146
|
+
<UnnnicDisclaimer
|
|
147
|
+
type="neutral"
|
|
148
|
+
description="Conversations older than 90 days are archived and can't be shown. To access them, contact support."
|
|
149
|
+
/>
|
|
150
|
+
</template>
|
|
151
|
+
</UnnnicInputDatePicker>
|
|
152
|
+
</div>
|
|
153
|
+
`,
|
|
154
|
+
}),
|
|
155
|
+
};
|