@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
|
@@ -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
|
-
Drawer: templateSlot,
|
|
14
|
-
DrawerContent: templateSlot,
|
|
15
|
-
DrawerFooter: templateSlot,
|
|
16
|
-
DrawerClose: templateSlot,
|
|
17
|
-
DrawerTitle: templateSlot,
|
|
18
|
-
DrawerDescription: 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:
|
|
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().
|
|
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().
|
|
47
|
+
expect(drawer().exists()).toBe(false);
|
|
60
48
|
});
|
|
61
49
|
|
|
62
50
|
it('should render the overlay when withoutOverlay is false', () => {
|
|
63
|
-
|
|
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(
|
|
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('
|
|
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
|
-
"<
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</
|
|
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
|
`;
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
<UnnnicInput
|
|
7
7
|
:class="['input', { 'date-picker-input-next': next }]"
|
|
8
8
|
:size="size"
|
|
9
|
-
:iconLeft="iconPosition === 'left'
|
|
10
|
-
:iconRight="iconPosition === 'right'
|
|
9
|
+
:iconLeft="iconPosition === 'left' ? 'calendar_month' : undefined"
|
|
10
|
+
:iconRight="iconPosition === 'right' ? 'calendar_month' : undefined"
|
|
11
11
|
hasCloudyColor
|
|
12
12
|
readonly
|
|
13
|
-
:modelValue="overwrittenValue || filterText"
|
|
13
|
+
:modelValue="overwrittenValue || filterText || ''"
|
|
14
14
|
@focus="showCalendarFilter = true"
|
|
15
15
|
/>
|
|
16
16
|
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
:months="months"
|
|
28
28
|
:days="days"
|
|
29
29
|
:options="options"
|
|
30
|
+
:periodBaseDate="periodBaseDate"
|
|
30
31
|
:initialStartDate="initialStartDate"
|
|
31
32
|
:initialEndDate="initialEndDate"
|
|
32
33
|
:minDate="minDate"
|
|
@@ -39,191 +40,156 @@
|
|
|
39
40
|
</div>
|
|
40
41
|
</template>
|
|
41
42
|
|
|
42
|
-
<script>
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
|
43
45
|
import moment from 'moment';
|
|
46
|
+
|
|
44
47
|
import UnnnicInput from '../Input/Input.vue';
|
|
45
48
|
import UnnnicDatePicker from '../DatePicker/DatePicker.vue';
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
props: {
|
|
57
|
-
modelValue: {
|
|
58
|
-
type: Object,
|
|
59
|
-
required: true,
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
iconPosition: {
|
|
63
|
-
type: String,
|
|
64
|
-
default: 'left',
|
|
65
|
-
validator(position) {
|
|
66
|
-
return ['left', 'right'].includes(position);
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
minDate: { type: String, default: '' },
|
|
71
|
-
maxDate: { type: String, default: '' },
|
|
72
|
-
|
|
73
|
-
fillW: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: false,
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
type: {
|
|
79
|
-
type: String,
|
|
80
|
-
default: 'day',
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
size: {
|
|
84
|
-
type: String,
|
|
85
|
-
default: 'md',
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
clearText: {
|
|
89
|
-
type: String,
|
|
90
|
-
default: 'Clear',
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
actionText: {
|
|
94
|
-
type: String,
|
|
95
|
-
default: 'Filter',
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
months: {
|
|
99
|
-
type: Array,
|
|
100
|
-
default: () => [],
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
days: {
|
|
104
|
-
type: Array,
|
|
105
|
-
default: () => [],
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
options: {
|
|
109
|
-
type: Array,
|
|
110
|
-
default: () => [],
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
next: {
|
|
114
|
-
type: Boolean,
|
|
115
|
-
default: false,
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
format: {
|
|
119
|
-
type: String,
|
|
120
|
-
default: 'YYYY-MM-DD',
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
inputFormat: {
|
|
124
|
-
type: String,
|
|
125
|
-
default: 'MM-DD-YYYY',
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
position: {
|
|
129
|
-
type: String,
|
|
130
|
-
default: 'left',
|
|
131
|
-
},
|
|
132
|
-
disableClear: {
|
|
133
|
-
type: Boolean,
|
|
134
|
-
default: false,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
emits: ['update:model-value', 'selectDate'],
|
|
139
|
-
|
|
140
|
-
data() {
|
|
141
|
-
return {
|
|
142
|
-
showCalendarFilter: false,
|
|
143
|
-
overwrittenValue: '',
|
|
144
|
-
};
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
computed: {
|
|
148
|
-
filterText() {
|
|
149
|
-
const dates = [];
|
|
150
|
-
|
|
151
|
-
if (this.modelValue?.start) {
|
|
152
|
-
dates.push(
|
|
153
|
-
moment(this.modelValue?.start, this.format).format(this.inputFormat),
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (this.modelValue?.end) {
|
|
158
|
-
dates.push(
|
|
159
|
-
moment(this.modelValue?.end, this.format).format(this.inputFormat),
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (!dates.length) {
|
|
164
|
-
return String(this.inputFormat).replaceAll('-', '/').toLowerCase();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return dates.join(' ~ ');
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
initialStartDate() {
|
|
171
|
-
return this.modelValue.start
|
|
172
|
-
? moment(this.modelValue.start, this.format).format('MM DD YYYY')
|
|
173
|
-
: null;
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
initialEndDate() {
|
|
177
|
-
return this.modelValue.end
|
|
178
|
-
? moment(this.modelValue.end, this.format).format('MM DD YYYY')
|
|
179
|
-
: null;
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
mounted() {
|
|
184
|
-
window.document.body.addEventListener('click', this.mouseout);
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
beforeUnmount() {
|
|
188
|
-
window.document.body.removeEventListener('click', this.mouseout);
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
methods: {
|
|
192
|
-
emitSelectDate(date) {
|
|
193
|
-
const { startDate, endDate } = date;
|
|
194
|
-
const formattedDates = {
|
|
195
|
-
start: moment(startDate, 'MM-DD-YYYY').format(this.format),
|
|
196
|
-
end: moment(endDate, 'MM-DD-YYYY').format(this.format),
|
|
197
|
-
};
|
|
198
|
-
this.$emit('selectDate', formattedDates);
|
|
199
|
-
},
|
|
200
|
-
mouseout(event) {
|
|
201
|
-
if (this.$refs.dropdown?.contains(event.target)) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
this.showCalendarFilter = false;
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
changeDate(value) {
|
|
209
|
-
const startDate = value.startDate.replace(
|
|
210
|
-
/(\d+)-(\d+)-(\d+)/,
|
|
211
|
-
'$3-$1-$2',
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
const endDate = value.endDate.replace(/(\d+)-(\d+)-(\d+)/, '$3-$1-$2');
|
|
215
|
-
|
|
216
|
-
this.showCalendarFilter = false;
|
|
217
|
-
|
|
218
|
-
this.$emit('update:model-value', {
|
|
219
|
-
start: startDate
|
|
220
|
-
? moment(startDate, 'YYYY-MM-DD').format(this.format)
|
|
221
|
-
: null,
|
|
222
|
-
end: endDate ? moment(endDate, 'YYYY-MM-DD').format(this.format) : null,
|
|
223
|
-
});
|
|
224
|
-
},
|
|
225
|
-
},
|
|
50
|
+
defineOptions({
|
|
51
|
+
name: 'UnnnicInputDatePicker',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
type DateRangeValue = {
|
|
55
|
+
start: string | null;
|
|
56
|
+
end: string | null;
|
|
226
57
|
};
|
|
58
|
+
|
|
59
|
+
interface InputDatePickerProps {
|
|
60
|
+
modelValue: DateRangeValue;
|
|
61
|
+
|
|
62
|
+
iconPosition?: 'left' | 'right';
|
|
63
|
+
|
|
64
|
+
minDate?: string;
|
|
65
|
+
maxDate?: string;
|
|
66
|
+
|
|
67
|
+
fillW?: boolean;
|
|
68
|
+
|
|
69
|
+
type?: 'day' | 'month' | 'year';
|
|
70
|
+
size?: string;
|
|
71
|
+
|
|
72
|
+
clearText?: string;
|
|
73
|
+
actionText?: string;
|
|
74
|
+
|
|
75
|
+
months?: string[];
|
|
76
|
+
days?: string[];
|
|
77
|
+
options?: Array<{ name: string; id: string }>;
|
|
78
|
+
|
|
79
|
+
next?: boolean;
|
|
80
|
+
|
|
81
|
+
format?: string;
|
|
82
|
+
inputFormat?: string | null;
|
|
83
|
+
|
|
84
|
+
position?: 'left' | 'right';
|
|
85
|
+
disableClear?: boolean;
|
|
86
|
+
|
|
87
|
+
periodBaseDate?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const props = withDefaults(defineProps<InputDatePickerProps>(), {
|
|
91
|
+
iconPosition: 'left',
|
|
92
|
+
minDate: '',
|
|
93
|
+
maxDate: '',
|
|
94
|
+
fillW: false,
|
|
95
|
+
type: 'day',
|
|
96
|
+
size: 'md',
|
|
97
|
+
clearText: 'Clear',
|
|
98
|
+
actionText: 'Filter',
|
|
99
|
+
months: () => [],
|
|
100
|
+
days: () => [],
|
|
101
|
+
options: () => [],
|
|
102
|
+
next: false,
|
|
103
|
+
format: 'YYYY-MM-DD',
|
|
104
|
+
inputFormat: 'MM-DD-YYYY',
|
|
105
|
+
position: 'left',
|
|
106
|
+
disableClear: false,
|
|
107
|
+
periodBaseDate: '',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const emit = defineEmits<{
|
|
111
|
+
(e: 'update:model-value', value: DateRangeValue): void;
|
|
112
|
+
(e: 'selectDate', value: DateRangeValue): void;
|
|
113
|
+
}>();
|
|
114
|
+
|
|
115
|
+
const dropdown = ref<HTMLElement | null>(null);
|
|
116
|
+
const showCalendarFilter = ref(false);
|
|
117
|
+
const overwrittenValue = ref('');
|
|
118
|
+
|
|
119
|
+
const filterText = computed(() => {
|
|
120
|
+
const dates: string[] = [];
|
|
121
|
+
|
|
122
|
+
const { start, end } = props.modelValue || {};
|
|
123
|
+
|
|
124
|
+
if (start) {
|
|
125
|
+
dates.push(moment(start, props.format).format(props.inputFormat || ''));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (end) {
|
|
129
|
+
dates.push(moment(end, props.format).format(props.inputFormat || ''));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (!dates.length) {
|
|
133
|
+
return String(props.inputFormat || '')
|
|
134
|
+
.replaceAll('-', '/')
|
|
135
|
+
.toLowerCase();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return dates.join(' ~ ');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const initialStartDate = computed<string | undefined>(() => {
|
|
142
|
+
return props.modelValue.start
|
|
143
|
+
? moment(props.modelValue.start, props.format).format('MM DD YYYY')
|
|
144
|
+
: undefined;
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const initialEndDate = computed<string | undefined>(() => {
|
|
148
|
+
return props.modelValue.end
|
|
149
|
+
? moment(props.modelValue.end, props.format).format('MM DD YYYY')
|
|
150
|
+
: undefined;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
function emitSelectDate(date: { startDate: string; endDate: string }) {
|
|
154
|
+
const { startDate, endDate } = date;
|
|
155
|
+
const formattedDates: DateRangeValue = {
|
|
156
|
+
start: moment(startDate, 'MM-DD-YYYY').format(props.format),
|
|
157
|
+
end: moment(endDate, 'MM-DD-YYYY').format(props.format),
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
emit('selectDate', formattedDates);
|
|
161
|
+
}
|
|
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
|
+
|
|
171
|
+
function changeDate(value: { startDate: string; endDate: string }) {
|
|
172
|
+
const startDate = value.startDate.replace(/(\d+)-(\d+)-(\d+)/, '$3-$1-$2');
|
|
173
|
+
|
|
174
|
+
const endDate = value.endDate.replace(/(\d+)-(\d+)-(\d+)/, '$3-$1-$2');
|
|
175
|
+
|
|
176
|
+
showCalendarFilter.value = false;
|
|
177
|
+
|
|
178
|
+
emit('update:model-value', {
|
|
179
|
+
start: startDate
|
|
180
|
+
? moment(startDate, 'YYYY-MM-DD').format(props.format)
|
|
181
|
+
: null,
|
|
182
|
+
end: endDate ? moment(endDate, 'YYYY-MM-DD').format(props.format) : null,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
onMounted(() => {
|
|
187
|
+
window.document.body.addEventListener('click', mouseout as any);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
onBeforeUnmount(() => {
|
|
191
|
+
window.document.body.removeEventListener('click', mouseout as any);
|
|
192
|
+
});
|
|
227
193
|
</script>
|
|
228
194
|
|
|
229
195
|
<style lang="scss" scoped>
|