@weni/unnnic-system 3.11.1-alpha.2 → 3.11.2
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 +32 -0
- package/dist/components/Alert/Alert.vue.d.ts +3 -3
- package/dist/components/Alert/Version1dot1.vue.d.ts +1 -1
- package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +18 -109
- package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +36 -218
- package/dist/components/AvatarIcon/AvatarIcon.vue.d.ts +1 -1
- package/dist/components/Button/Button.vue.d.ts +2 -2
- package/dist/components/Card/AccountCard.vue.d.ts +2 -2
- package/dist/components/Card/Card.vue.d.ts +29 -120
- package/dist/components/Card/CardCompany.vue.d.ts +2 -2
- package/dist/components/Card/CardStatusesContainer.vue.d.ts +19 -110
- package/dist/components/Card/ContentCard.vue.d.ts +1 -1
- package/dist/components/Card/DashCard.vue.d.ts +2 -2
- package/dist/components/Card/DefaultCard.vue.d.ts +1 -1
- package/dist/components/Card/MarketplaceCard.vue.d.ts +1 -1
- package/dist/components/Card/SimpleCard.vue.d.ts +18 -109
- package/dist/components/Card/StatusCard.vue.d.ts +1 -1
- package/dist/components/Card/TitleCard.vue.d.ts +18 -109
- package/dist/components/CardImage/CardImage.vue.d.ts +5 -5
- package/dist/components/CardInformation/CardInformation.vue.d.ts +19 -110
- package/dist/components/CardProject/CardProject.vue.d.ts +2 -2
- package/dist/components/Carousel/Carousel.vue.d.ts +2 -2
- package/dist/components/Carousel/TagCarousel.vue.d.ts +2 -2
- package/dist/components/ChartBar/ChartBar.vue.d.ts +24 -115
- package/dist/components/ChartLine/ChartLine.vue.d.ts +18 -109
- package/dist/components/ChatText/ChatText.vue.d.ts +18 -109
- package/dist/components/ChatsContact/ChatsContact.vue.d.ts +6 -6
- package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +18 -109
- package/dist/components/ChatsUserAvatar/ChatsUserAvatar.vue.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.vue.d.ts +3 -3
- package/dist/components/DataArea/DataArea.vue.d.ts +18 -109
- package/dist/components/DataTable/index.vue.d.ts +1 -1
- package/dist/components/DataTable/index.vue.d.ts.map +1 -1
- package/dist/components/DateFilter/DateFilter.vue.d.ts +10 -10
- package/dist/components/DatePicker/DatePicker.vue.d.ts +69 -249
- package/dist/components/DatePicker/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/Drawer/Drawer.vue.d.ts +207 -35
- package/dist/components/Drawer/Drawer.vue.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.vue.d.ts +1 -1
- package/dist/components/FormElement/FormElement.vue.d.ts +4 -4
- package/dist/components/ImportCard/ImportCard.vue.d.ts +6 -6
- package/dist/components/Input/Input.vue.d.ts +9 -9
- package/dist/components/Input/TextInput.vue.d.ts +2 -2
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +47 -911
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts.map +1 -1
- package/dist/components/InputNext/InputNext.vue.d.ts +3 -3
- package/dist/components/Modal/Modal.vue.d.ts +1 -1
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts +35 -209
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
- package/dist/components/ModalNext/ModalNext.vue.d.ts +15 -15
- package/dist/components/ModalUpload/ModalUpload.vue.d.ts +12 -12
- package/dist/components/MoodRating/MoodRating.vue.d.ts +18 -109
- package/dist/components/MultiSelect/MultiSelect.vue.d.ts +18 -18
- package/dist/components/Pagination/Pagination.vue.d.ts +6 -6
- package/dist/components/Radio/Radio.vue.d.ts +6 -6
- package/dist/components/Select/SelectItem.vue.d.ts +1 -1
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +12 -12
- package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +2 -2
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +6 -6
- package/dist/components/SelectTime/index.vue.d.ts +3 -3
- package/dist/components/Sidebar/SidebarItem.vue.d.ts +2 -2
- package/dist/components/Slider/Slider.vue.d.ts +18 -109
- package/dist/components/Switch/Switch.vue.d.ts +2 -2
- package/dist/components/Tab/Tab.vue.d.ts +18 -109
- package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
- package/dist/components/TableNext/TablePagination.vue.d.ts +6 -6
- package/dist/components/Tag/DefaultTag.vue.d.ts +1 -1
- package/dist/components/Tag/Tag.vue.d.ts +2 -2
- package/dist/components/TextArea/TextArea.vue.d.ts +5 -5
- package/dist/components/Toast/Toast.vue.d.ts +1 -1
- package/dist/components/ToolTip/ToolTip.vue.d.ts +18 -109
- package/dist/components/ToolTip/ToolTip.vue.d.ts.map +1 -1
- package/dist/components/Tour/Tour.vue.d.ts +6 -6
- package/dist/components/Tour/TourPopover.vue.d.ts +6 -6
- package/dist/components/UploadArea/UploadArea.vue.d.ts +6 -6
- package/dist/components/ui/popover/PopoverContent.vue.d.ts +2 -2
- package/dist/components/ui/popover/PopoverContent.vue.d.ts.map +1 -1
- package/dist/components/ui/tabs/TabsTrigger.vue.d.ts.map +1 -1
- package/dist/{es-2f0d1dd1.mjs → es-042a0d15.mjs} +1 -1
- package/dist/{index-7d496127.mjs → index-fd0ea6b9.mjs} +51896 -54819
- package/dist/{pt-br-ec24bd23.mjs → pt-br-3b7cced5.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +196 -232
- package/dist/unnnic.umd.js +46 -50
- package/package.json +1 -2
- package/src/assets/scss/tailwind.scss +0 -8
- package/src/components/DatePicker/DatePicker.vue +628 -516
- package/src/components/DatePicker/__tests__/DatePicker.spec.js +227 -0
- package/src/components/Drawer/Drawer.vue +270 -177
- 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/InputDatePicker/InputDatePicker.vue +149 -183
- package/src/components/InputDatePicker/__test__/InputDatePicker.spec.js +159 -0
- package/src/components/ModalDialog/ModalDialog.vue +148 -62
- 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/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -3
- package/src/components/ToolTip/ToolTip.vue +188 -41
- package/src/components/ToolTip/__tests__/ToolTip.spec.js +61 -345
- package/src/components/index.ts +12 -86
- package/src/components/ui/tabs/TabsTrigger.vue +20 -4
- package/src/stories/DatePicker.stories.js +71 -0
- package/src/stories/Drawer.stories.js +1 -1
- package/src/stories/InputDatePicker.stories.js +22 -0
- package/src/stories/ModalDialog.mdx +0 -3
- package/src/stories/ModalDialog.stories.js +1 -1
- package/src/stories/Tabs.stories.js +1 -1
- package/dist/components/index.d.ts +0 -25946
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/ui/dialog/Dialog.vue.d.ts +0 -23
- package/dist/components/ui/dialog/Dialog.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogClose.vue.d.ts +0 -19
- package/dist/components/ui/dialog/DialogClose.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogContent.vue.d.ts +0 -43
- package/dist/components/ui/dialog/DialogContent.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts +0 -25
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts +0 -29
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts +0 -23
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +0 -19
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/index.d.ts +0 -8
- package/dist/components/ui/dialog/index.d.ts.map +0 -1
- package/dist/components/ui/drawer/Drawer.vue.d.ts +0 -35
- package/dist/components/ui/drawer/Drawer.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerClose.vue.d.ts +0 -19
- package/dist/components/ui/drawer/DrawerClose.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts +0 -42
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts +0 -23
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts +0 -22
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts +0 -25
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts +0 -8
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts +0 -23
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts +0 -19
- package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/index.d.ts +0 -11
- package/dist/components/ui/drawer/index.d.ts.map +0 -1
- package/dist/components/ui/segmented-control/SegmentedControlList.vue.d.ts +0 -26
- package/dist/components/ui/segmented-control/SegmentedControlList.vue.d.ts.map +0 -1
- package/dist/components/ui/segmented-control/SegmentedControlTrigger.vue.d.ts +0 -24
- package/dist/components/ui/segmented-control/SegmentedControlTrigger.vue.d.ts.map +0 -1
- package/dist/components/ui/segmented-control/index.d.ts +0 -5
- package/dist/components/ui/segmented-control/index.d.ts.map +0 -1
- package/dist/components/ui/tooltip/Tooltip.vue.d.ts +0 -23
- package/dist/components/ui/tooltip/Tooltip.vue.d.ts.map +0 -1
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts +0 -31
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts.map +0 -1
- package/dist/components/ui/tooltip/TooltipProvider.vue.d.ts +0 -19
- package/dist/components/ui/tooltip/TooltipProvider.vue.d.ts.map +0 -1
- package/dist/components/ui/tooltip/TooltipTrigger.vue.d.ts +0 -19
- package/dist/components/ui/tooltip/TooltipTrigger.vue.d.ts.map +0 -1
- package/dist/components/ui/tooltip/index.d.ts +0 -5
- package/dist/components/ui/tooltip/index.d.ts.map +0 -1
- package/src/components/ui/dialog/Dialog.vue +0 -15
- package/src/components/ui/dialog/DialogClose.vue +0 -25
- package/src/components/ui/dialog/DialogContent.vue +0 -133
- package/src/components/ui/dialog/DialogFooter.vue +0 -46
- package/src/components/ui/dialog/DialogHeader.vue +0 -79
- package/src/components/ui/dialog/DialogTitle.vue +0 -34
- package/src/components/ui/dialog/DialogTrigger.vue +0 -12
- 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 -37
- package/src/components/ui/drawer/DrawerContent.vue +0 -102
- 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 -34
- 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/segmented-control/SegmentedControlList.vue +0 -51
- package/src/components/ui/segmented-control/SegmentedControlTrigger.vue +0 -81
- package/src/components/ui/segmented-control/index.ts +0 -4
- package/src/components/ui/tooltip/Tooltip.vue +0 -15
- package/src/components/ui/tooltip/TooltipContent.vue +0 -73
- package/src/components/ui/tooltip/TooltipProvider.vue +0 -15
- package/src/components/ui/tooltip/TooltipTrigger.vue +0 -22
- package/src/components/ui/tooltip/index.ts +0 -4
- package/src/stories/Dialog.stories.js +0 -832
- package/src/stories/DrawerNext.stories.js +0 -610
- package/src/stories/SegmentedControl.stories.js +0 -253
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
3
|
+
import DatePicker from '../DatePicker.vue';
|
|
4
|
+
|
|
5
|
+
const factory = (props = {}) =>
|
|
6
|
+
mount(DatePicker, {
|
|
7
|
+
props: {
|
|
8
|
+
size: 'large',
|
|
9
|
+
type: 'day',
|
|
10
|
+
...props,
|
|
11
|
+
},
|
|
12
|
+
global: {
|
|
13
|
+
mocks: {
|
|
14
|
+
$i18n: { locale: 'en-us' },
|
|
15
|
+
},
|
|
16
|
+
stubs: {
|
|
17
|
+
UnnnicButton: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const findFirstSelectableDay = (wrapper) =>
|
|
23
|
+
wrapper
|
|
24
|
+
.findAll('[data-testid="date-picker-day"]')
|
|
25
|
+
.find((day) => day.classes().includes('selectable'));
|
|
26
|
+
|
|
27
|
+
describe('DatePicker.vue', () => {
|
|
28
|
+
let wrapper;
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
wrapper = factory({
|
|
32
|
+
options: [
|
|
33
|
+
{ name: 'Last 7 days', id: 'last-7-days' },
|
|
34
|
+
{ name: 'Custom', id: 'custom' },
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('renders day view with two months and options', () => {
|
|
40
|
+
expect(wrapper.find('[data-testid="date-picker-root"]').exists()).toBe(
|
|
41
|
+
true,
|
|
42
|
+
);
|
|
43
|
+
expect(
|
|
44
|
+
wrapper.findAll('[data-testid="date-picker-month-container"]').length,
|
|
45
|
+
).toBe(2);
|
|
46
|
+
expect(wrapper.findAll('[data-testid="date-picker-option"]').length).toBe(
|
|
47
|
+
2,
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('selects a date range and emits change', async () => {
|
|
52
|
+
const first = findFirstSelectableDay(wrapper);
|
|
53
|
+
const second = wrapper
|
|
54
|
+
.findAll('[data-testid="date-picker-day"]')
|
|
55
|
+
.reverse()
|
|
56
|
+
.find((day) => day.classes().includes('selectable'));
|
|
57
|
+
|
|
58
|
+
await first.trigger('click');
|
|
59
|
+
await second.trigger('click');
|
|
60
|
+
|
|
61
|
+
const emittedChange = wrapper.emitted('change');
|
|
62
|
+
expect(emittedChange).toBeTruthy();
|
|
63
|
+
const [{ startDate, endDate }] = emittedChange.pop();
|
|
64
|
+
expect(startDate).not.toBe('');
|
|
65
|
+
expect(endDate).not.toBe('');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('clears selection when clear button is clicked', async () => {
|
|
69
|
+
const day = findFirstSelectableDay(wrapper);
|
|
70
|
+
await day.trigger('click');
|
|
71
|
+
|
|
72
|
+
await wrapper.find('[data-testid="date-picker-clear"]').trigger('click');
|
|
73
|
+
|
|
74
|
+
expect(wrapper.vm.startDate).toBe('');
|
|
75
|
+
expect(wrapper.vm.endDate).toBe('');
|
|
76
|
+
expect(wrapper.vm.optionSelected).toBe('');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('submits with selected period and emits equivalent option name', async () => {
|
|
80
|
+
await wrapper.vm.autoSelect('last-7-days');
|
|
81
|
+
await wrapper.find('[data-testid="date-picker-submit"]').trigger('click');
|
|
82
|
+
|
|
83
|
+
const submit = wrapper.emitted('submit');
|
|
84
|
+
const updateEquivalent = wrapper.emitted('update:equivalentOption');
|
|
85
|
+
|
|
86
|
+
expect(submit).toBeTruthy();
|
|
87
|
+
expect(submit[0][0]).toHaveProperty('startDate');
|
|
88
|
+
expect(submit[0][0]).toHaveProperty('endDate');
|
|
89
|
+
|
|
90
|
+
expect(updateEquivalent[0][0]).toBe('Last 7 days');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('submits with custom selection and clears equivalent option', async () => {
|
|
94
|
+
wrapper.vm.optionSelected = 'custom';
|
|
95
|
+
await wrapper.find('[data-testid="date-picker-submit"]').trigger('click');
|
|
96
|
+
|
|
97
|
+
const updateEquivalent = wrapper.emitted('update:equivalentOption');
|
|
98
|
+
expect(updateEquivalent[0][0]).toBe('');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('uses periodBaseDate to compute relative ranges', async () => {
|
|
102
|
+
const base = '2025-01-15';
|
|
103
|
+
wrapper = factory({
|
|
104
|
+
periodBaseDate: base,
|
|
105
|
+
options: [{ name: 'Last 7 days', id: 'last-7-days' }],
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
await wrapper.vm.autoSelect('last-7-days');
|
|
109
|
+
|
|
110
|
+
const [year, month, day] = base.split('-');
|
|
111
|
+
const baseDate = new Date(Number(year), Number(month) - 1, Number(day));
|
|
112
|
+
const expectedEnd = wrapper.vm.dateToString(baseDate);
|
|
113
|
+
|
|
114
|
+
expect(wrapper.vm.endDate).toBe(expectedEnd);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('renders month view and selects a month', async () => {
|
|
118
|
+
wrapper = factory({
|
|
119
|
+
type: 'month',
|
|
120
|
+
options: [{ name: 'Last 12 months', id: 'last-12-months' }],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const monthCell = wrapper.find('[data-testid="date-picker-month-cell"]');
|
|
124
|
+
await monthCell.trigger('click');
|
|
125
|
+
|
|
126
|
+
expect(wrapper.vm.startDate).not.toBe('');
|
|
127
|
+
expect(wrapper.vm.endDate).not.toBe('');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('renders year view and selects a year', async () => {
|
|
131
|
+
wrapper = factory({
|
|
132
|
+
type: 'year',
|
|
133
|
+
options: [{ name: 'Previous year', id: 'previous-year' }],
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const yearCell = wrapper.find('[data-testid="date-picker-year-cell"]');
|
|
137
|
+
await yearCell.trigger('click');
|
|
138
|
+
|
|
139
|
+
expect(wrapper.vm.startDate).not.toBe('');
|
|
140
|
+
expect(wrapper.vm.endDate).not.toBe('');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('hides options when size is small and respects disableClear', async () => {
|
|
144
|
+
wrapper = factory({
|
|
145
|
+
size: 'small',
|
|
146
|
+
options: [{ name: 'Last 7 days', id: 'last-7-days' }],
|
|
147
|
+
});
|
|
148
|
+
expect(wrapper.find('[data-testid="date-picker-options"]').exists()).toBe(
|
|
149
|
+
false,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
wrapper = factory({
|
|
153
|
+
disableClear: true,
|
|
154
|
+
options: [{ name: 'Last 7 days', id: 'last-7-days' }],
|
|
155
|
+
});
|
|
156
|
+
expect(wrapper.find('[data-testid="date-picker-clear"]').exists()).toBe(
|
|
157
|
+
false,
|
|
158
|
+
);
|
|
159
|
+
expect(wrapper.find('[data-testid="date-picker-submit"]').exists()).toBe(
|
|
160
|
+
true,
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('navigates between months using navigation buttons', async () => {
|
|
165
|
+
const initialReference = wrapper.vm.referenceDate;
|
|
166
|
+
|
|
167
|
+
const nextButton = wrapper.find('[data-testid="date-picker-nav-right"]');
|
|
168
|
+
await nextButton.trigger('click');
|
|
169
|
+
|
|
170
|
+
expect(wrapper.vm.referenceDate).not.toBe(initialReference);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('exposes i18n helper compatible with previous mixin', () => {
|
|
174
|
+
const text = wrapper.vm.i18n('clean', 'Clean');
|
|
175
|
+
expect(text).toBeTruthy();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('computes previous-month period correctly based on periodBaseDate', () => {
|
|
179
|
+
const base = '2025-03-15';
|
|
180
|
+
wrapper = factory({
|
|
181
|
+
periodBaseDate: base,
|
|
182
|
+
options: [{ name: 'Previous month', id: 'previous-month' }],
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const { startDate, endDate } =
|
|
186
|
+
wrapper.vm.getStartAndEndDateByPeriod('previous-month');
|
|
187
|
+
|
|
188
|
+
const baseDate = new Date(base);
|
|
189
|
+
const firstPrevMonth = new Date(
|
|
190
|
+
baseDate.getFullYear(),
|
|
191
|
+
baseDate.getMonth() - 1,
|
|
192
|
+
1,
|
|
193
|
+
);
|
|
194
|
+
const lastPrevMonth = new Date(
|
|
195
|
+
firstPrevMonth.getFullYear(),
|
|
196
|
+
firstPrevMonth.getMonth() + 1,
|
|
197
|
+
0,
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const expectedStart = wrapper.vm.dateToString(firstPrevMonth);
|
|
201
|
+
const expectedEnd = wrapper.vm.dateToString(lastPrevMonth);
|
|
202
|
+
|
|
203
|
+
expect(startDate).toBe(expectedStart);
|
|
204
|
+
expect(endDate).toBe(expectedEnd);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('marks dates outside minDate and maxDate as out of range', () => {
|
|
208
|
+
const min = '2025-02-10';
|
|
209
|
+
const max = '2025-02-20';
|
|
210
|
+
|
|
211
|
+
wrapper = factory({
|
|
212
|
+
minDate: min,
|
|
213
|
+
maxDate: max,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const [year, month] = min.split('-');
|
|
217
|
+
const reference = `${Number(month)} 1 ${year}`;
|
|
218
|
+
|
|
219
|
+
const dates = wrapper.vm.getDatesOfTheMonth(reference);
|
|
220
|
+
|
|
221
|
+
const hasOutOfRange = dates.some((d) =>
|
|
222
|
+
d.properties.includes('out of range'),
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
expect(hasOutOfRange).toBe(true);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
@@ -1,196 +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="$emit('update:modelValue', $event)"
|
|
7
6
|
>
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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"
|
|
13
16
|
>
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
</DrawerTitle>
|
|
28
|
-
<DrawerDescription
|
|
29
|
-
v-if="description"
|
|
30
|
-
class="unnnic-drawer__description"
|
|
31
|
-
data-testid="drawer-description"
|
|
32
|
-
>
|
|
33
|
-
{{ description }}
|
|
34
|
-
</DrawerDescription>
|
|
35
|
-
</template>
|
|
36
|
-
</section>
|
|
37
|
-
<template #close>
|
|
38
|
-
<DrawerClose>
|
|
39
|
-
<UnnnicButton
|
|
40
|
-
class="unnnic-drawer__close-icon"
|
|
41
|
-
data-testid="close-icon"
|
|
42
|
-
:iconCenter="closeIcon"
|
|
43
|
-
size="small"
|
|
44
|
-
type="tertiary"
|
|
45
|
-
@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"
|
|
46
30
|
/>
|
|
47
|
-
</DrawerClose>
|
|
48
|
-
</template>
|
|
49
|
-
</DrawerHeader>
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
|
|
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>
|
|
53
86
|
</section>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
v-if="showFooter"
|
|
57
|
-
class="unnnic-drawer__footer"
|
|
58
|
-
data-testid="footer"
|
|
59
|
-
>
|
|
60
|
-
<UnnnicButton
|
|
61
|
-
v-if="secondaryButtonText"
|
|
62
|
-
data-testid="secondary-button"
|
|
63
|
-
size="large"
|
|
64
|
-
type="tertiary"
|
|
65
|
-
:disabled="disabledSecondaryButton"
|
|
66
|
-
:loading="loadingSecondaryButton"
|
|
67
|
-
:text="secondaryButtonText"
|
|
68
|
-
@click="$emit('secondaryButtonClick')"
|
|
69
|
-
/>
|
|
70
|
-
<UnnnicButton
|
|
71
|
-
v-if="primaryButtonText"
|
|
72
|
-
data-testid="primary-button"
|
|
73
|
-
size="large"
|
|
74
|
-
:disabled="disabledPrimaryButton"
|
|
75
|
-
:loading="loadingPrimaryButton"
|
|
76
|
-
:type="primaryButtonType"
|
|
77
|
-
:text="primaryButtonText"
|
|
78
|
-
@click="$emit('primaryButtonClick')"
|
|
79
|
-
/>
|
|
80
|
-
</DrawerFooter>
|
|
81
|
-
</DrawerContent>
|
|
82
|
-
</Drawer>
|
|
87
|
+
</Transition>
|
|
88
|
+
</aside>
|
|
83
89
|
</template>
|
|
84
90
|
|
|
85
|
-
<script
|
|
86
|
-
import
|
|
87
|
-
|
|
91
|
+
<script>
|
|
92
|
+
import UnnnicIcon from '../Icon.vue';
|
|
88
93
|
import UnnnicButton from '../Button/Button.vue';
|
|
89
|
-
import {
|
|
90
|
-
Drawer,
|
|
91
|
-
DrawerContent,
|
|
92
|
-
DrawerHeader,
|
|
93
|
-
DrawerFooter,
|
|
94
|
-
DrawerClose,
|
|
95
|
-
DrawerTitle,
|
|
96
|
-
DrawerDescription,
|
|
97
|
-
} from '../ui/drawer';
|
|
98
|
-
|
|
99
|
-
defineOptions({
|
|
100
|
-
name: 'UnnnicDrawer',
|
|
101
|
-
});
|
|
102
94
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
description: {
|
|
109
|
-
type: String,
|
|
110
|
-
default: '',
|
|
111
|
-
},
|
|
112
|
-
disabledPrimaryButton: {
|
|
113
|
-
type: Boolean,
|
|
114
|
-
default: false,
|
|
115
|
-
},
|
|
116
|
-
disabledSecondaryButton: {
|
|
117
|
-
type: Boolean,
|
|
118
|
-
default: false,
|
|
119
|
-
},
|
|
120
|
-
loadingPrimaryButton: {
|
|
121
|
-
type: Boolean,
|
|
122
|
-
default: false,
|
|
123
|
-
},
|
|
124
|
-
loadingSecondaryButton: {
|
|
125
|
-
type: Boolean,
|
|
126
|
-
default: false,
|
|
127
|
-
},
|
|
128
|
-
primaryButtonText: {
|
|
129
|
-
type: String,
|
|
130
|
-
default: '',
|
|
131
|
-
},
|
|
132
|
-
primaryButtonType: {
|
|
133
|
-
type: String,
|
|
134
|
-
default: 'primary',
|
|
135
|
-
},
|
|
136
|
-
secondaryButtonText: {
|
|
137
|
-
type: String,
|
|
138
|
-
default: '',
|
|
95
|
+
export default {
|
|
96
|
+
name: 'UnnnicDrawer',
|
|
97
|
+
components: {
|
|
98
|
+
UnnnicIcon,
|
|
99
|
+
UnnnicButton,
|
|
139
100
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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,
|
|
145
164
|
},
|
|
146
165
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
type: Boolean,
|
|
153
|
-
default: false,
|
|
166
|
+
emits: ['primaryButtonClick', 'secondaryButtonClick', 'close', 'back'],
|
|
167
|
+
data() {
|
|
168
|
+
return {
|
|
169
|
+
showDrawer: true,
|
|
170
|
+
};
|
|
154
171
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
172
|
+
computed: {
|
|
173
|
+
showFooter() {
|
|
174
|
+
return !!(this.primaryButtonText || this.secondaryButtonText);
|
|
175
|
+
},
|
|
158
176
|
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
+
},
|
|
162
195
|
},
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const emit = defineEmits([
|
|
166
|
-
'primaryButtonClick',
|
|
167
|
-
'secondaryButtonClick',
|
|
168
|
-
'close',
|
|
169
|
-
'back',
|
|
170
|
-
]);
|
|
171
|
-
const showFooter = computed(
|
|
172
|
-
() => !!(props.primaryButtonText || props.secondaryButtonText),
|
|
173
|
-
);
|
|
174
|
-
const mappedSize = computed(() => {
|
|
175
|
-
const sizes = {
|
|
176
|
-
md: 'medium',
|
|
177
|
-
lg: 'large',
|
|
178
|
-
xl: 'extra-large',
|
|
179
|
-
gt: 'giant',
|
|
180
|
-
};
|
|
181
|
-
return sizes[props.size] || 'medium';
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
const close = () => {
|
|
185
|
-
emit('close');
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const back = () => {
|
|
189
|
-
if (props.distinctCloseBack) {
|
|
190
|
-
emit('back');
|
|
191
|
-
} else {
|
|
192
|
-
close();
|
|
193
|
-
}
|
|
194
196
|
};
|
|
195
197
|
</script>
|
|
196
198
|
|
|
@@ -202,16 +204,107 @@ const back = () => {
|
|
|
202
204
|
box-sizing: border-box;
|
|
203
205
|
}
|
|
204
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
|
+
|
|
205
236
|
.unnnic-drawer {
|
|
237
|
+
width: 100vw;
|
|
238
|
+
height: 100vh;
|
|
239
|
+
position: fixed;
|
|
240
|
+
left: 0;
|
|
241
|
+
top: 0;
|
|
206
242
|
z-index: 8;
|
|
207
243
|
}
|
|
208
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
|
+
|
|
209
252
|
.unnnic-drawer__container {
|
|
210
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;
|
|
211
263
|
|
|
212
|
-
|
|
213
|
-
|
|
264
|
+
&--md {
|
|
265
|
+
width: calc(100% / 3);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
&--lg {
|
|
269
|
+
width: 50%;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
&--xl {
|
|
273
|
+
width: 66%;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
&--gt {
|
|
277
|
+
width: 75%;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.unnnic-drawer__header {
|
|
214
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
|
+
}
|
|
215
308
|
}
|
|
216
309
|
|
|
217
310
|
.unnnic-drawer__content {
|