@weni/unnnic-system 3.11.1-alpha.1 → 3.11.1-alpha.4
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/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.map +1 -1
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +47 -911
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts.map +1 -1
- package/dist/components/Select/SelectItem.vue.d.ts +1 -1
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +1 -1
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +1 -1
- package/dist/components/Sidebar/SidebarItem.vue.d.ts +2 -2
- package/dist/components/ui/drawer/Drawer.vue.d.ts.map +1 -1
- package/dist/components/ui/drawer/DrawerClose.vue.d.ts.map +1 -1
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts.map +1 -1
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts.map +1 -1
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts.map +1 -1
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts.map +1 -1
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts.map +1 -1
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts.map +1 -1
- package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts.map +1 -1
- package/dist/{es-1e5cce64.mjs → es-fc643bdb.mjs} +1 -1
- package/dist/{index-8d75623f.mjs → index-4601aaf4.mjs} +9050 -9107
- package/dist/{pt-br-defd03da.mjs → pt-br-0b82e6d2.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +1 -1
- package/dist/unnnic.umd.js +42 -42
- package/package.json +1 -1
- package/src/components/DatePicker/DatePicker.vue +628 -516
- package/src/components/DatePicker/__tests__/DatePicker.spec.js +227 -0
- package/src/components/Drawer/Drawer.vue +6 -2
- package/src/components/Drawer/__tests__/Drawer.spec.js +11 -15
- package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +9 -9
- package/src/components/InputDatePicker/InputDatePicker.vue +149 -183
- package/src/components/InputDatePicker/__test__/InputDatePicker.spec.js +159 -0
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -1
- package/src/components/ui/drawer/Drawer.vue +4 -0
- package/src/components/ui/drawer/DrawerClose.vue +4 -0
- package/src/components/ui/drawer/DrawerContent.vue +5 -1
- package/src/components/ui/drawer/DrawerDescription.vue +4 -0
- package/src/components/ui/drawer/DrawerFooter.vue +5 -1
- package/src/components/ui/drawer/DrawerHeader.vue +5 -1
- package/src/components/ui/drawer/DrawerOverlay.vue +5 -1
- package/src/components/ui/drawer/DrawerTitle.vue +5 -1
- package/src/components/ui/drawer/DrawerTrigger.vue +4 -0
- package/src/stories/DatePicker.stories.js +71 -0
- package/src/stories/InputDatePicker.stories.js +22 -0
- package/dist/components/index.d.ts +0 -25946
- package/dist/components/index.d.ts.map +0 -1
|
@@ -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>
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
3
|
+
import InputDatePicker from '../InputDatePicker.vue';
|
|
4
|
+
|
|
5
|
+
const factory = (props = {}) =>
|
|
6
|
+
mount(InputDatePicker, {
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {
|
|
9
|
+
start: null,
|
|
10
|
+
end: null,
|
|
11
|
+
},
|
|
12
|
+
...props,
|
|
13
|
+
},
|
|
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
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('InputDatePicker.vue', () => {
|
|
31
|
+
let wrapper;
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
wrapper = factory();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('renders input and does not show datepicker by default', () => {
|
|
38
|
+
expect(wrapper.find('[data-testid="input"]').exists()).toBe(true);
|
|
39
|
+
expect(wrapper.find('[data-testid="datepicker"]').exists()).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('opens datepicker when input receives focus', async () => {
|
|
43
|
+
const input = wrapper.find('[data-testid="input"]');
|
|
44
|
+
await input.trigger('focus');
|
|
45
|
+
|
|
46
|
+
wrapper.vm.showCalendarFilter = true;
|
|
47
|
+
await wrapper.vm.$nextTick();
|
|
48
|
+
|
|
49
|
+
expect(wrapper.findComponent({ name: 'UnnnicDatePicker' }).exists()).toBe(
|
|
50
|
+
true,
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('computes filterText placeholder when there is no date selected', () => {
|
|
55
|
+
expect(wrapper.vm.filterText).toBe('mm/dd/yyyy');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('computes filterText from start and end dates', async () => {
|
|
59
|
+
const withDates = factory({
|
|
60
|
+
modelValue: {
|
|
61
|
+
start: '2025-01-10',
|
|
62
|
+
end: '2025-01-20',
|
|
63
|
+
},
|
|
64
|
+
format: 'YYYY-MM-DD',
|
|
65
|
+
inputFormat: 'MM-DD-YYYY',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(withDates.vm.filterText).toBe('01-10-2025 ~ 01-20-2025');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('computes initialStartDate and initialEndDate for DatePicker', () => {
|
|
72
|
+
const withDates = factory({
|
|
73
|
+
modelValue: {
|
|
74
|
+
start: '2025-01-10',
|
|
75
|
+
end: '2025-01-20',
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
expect(withDates.vm.initialStartDate).toBe('01 10 2025');
|
|
80
|
+
expect(withDates.vm.initialEndDate).toBe('01 20 2025');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('emits selectDate with formatted dates when DatePicker emits change', async () => {
|
|
84
|
+
wrapper.vm.showCalendarFilter = true;
|
|
85
|
+
await wrapper.vm.$nextTick();
|
|
86
|
+
|
|
87
|
+
const datePicker = wrapper.findComponent({ name: 'UnnnicDatePicker' });
|
|
88
|
+
|
|
89
|
+
const payload = {
|
|
90
|
+
startDate: '01-10-2025',
|
|
91
|
+
endDate: '01-20-2025',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
await datePicker.vm.$emit('change', payload);
|
|
95
|
+
|
|
96
|
+
const emitted = wrapper.emitted('selectDate');
|
|
97
|
+
expect(emitted).toBeTruthy();
|
|
98
|
+
|
|
99
|
+
const [formatted] = emitted[0];
|
|
100
|
+
expect(formatted).toEqual({
|
|
101
|
+
start: '2025-01-10',
|
|
102
|
+
end: '2025-01-20',
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('emits update:model-value and closes dropdown when DatePicker emits submit', async () => {
|
|
107
|
+
wrapper.vm.showCalendarFilter = true;
|
|
108
|
+
await wrapper.vm.$nextTick();
|
|
109
|
+
|
|
110
|
+
const datePicker = wrapper.findComponent({ name: 'UnnnicDatePicker' });
|
|
111
|
+
|
|
112
|
+
const payload = {
|
|
113
|
+
startDate: '01-10-2025',
|
|
114
|
+
endDate: '01-20-2025',
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
await datePicker.vm.$emit('submit', payload);
|
|
118
|
+
|
|
119
|
+
const emitted = wrapper.emitted('update:model-value');
|
|
120
|
+
expect(emitted).toBeTruthy();
|
|
121
|
+
|
|
122
|
+
const [newValue] = emitted[0];
|
|
123
|
+
expect(newValue).toEqual({
|
|
124
|
+
start: '2025-01-10',
|
|
125
|
+
end: '2025-01-20',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
expect(wrapper.vm.showCalendarFilter).toBe(false);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('passes minDate, maxDate, options and periodBaseDate down to DatePicker', async () => {
|
|
132
|
+
const props = {
|
|
133
|
+
minDate: '2025-01-01',
|
|
134
|
+
maxDate: '2025-01-31',
|
|
135
|
+
periodBaseDate: '2025-01-15',
|
|
136
|
+
options: [{ name: 'Last 7 days', id: 'last-7-days' }],
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
wrapper = factory(props);
|
|
140
|
+
wrapper.vm.showCalendarFilter = true;
|
|
141
|
+
await wrapper.vm.$nextTick();
|
|
142
|
+
|
|
143
|
+
const datePicker = wrapper.findComponent({ name: 'UnnnicDatePicker' });
|
|
144
|
+
const dpProps = datePicker.props();
|
|
145
|
+
|
|
146
|
+
expect(dpProps.minDate).toBe(props.minDate);
|
|
147
|
+
expect(dpProps.maxDate).toBe(props.maxDate);
|
|
148
|
+
expect(dpProps.periodBaseDate).toBe(props.periodBaseDate);
|
|
149
|
+
expect(dpProps.options).toEqual(props.options);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('closes dropdown on mouseout when clicking outside', () => {
|
|
153
|
+
wrapper.vm.showCalendarFilter = true;
|
|
154
|
+
|
|
155
|
+
wrapper.vm.mouseout({ target: document.createElement('div') });
|
|
156
|
+
|
|
157
|
+
expect(wrapper.vm.showCalendarFilter).toBe(false);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
@@ -4,7 +4,7 @@ exports[`Tab.vue > matches the snapshot 1`] = `
|
|
|
4
4
|
"<div data-v-b4e39fac="" class="tab size-md">
|
|
5
5
|
<header data-v-b4e39fac="" class="tab-header">
|
|
6
6
|
<ul data-v-b4e39fac="" class="tab-content">
|
|
7
|
-
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-b3d24f2b="" class="unnnic-tooltip-trigger" data-testid="tooltip-trigger" data-state="closed" data-grace-area-trigger=""><span data-v-26446d8e="" data-v-b4e39fac="" class="material-symbols-rounded unnnic-icon-scheme--
|
|
7
|
+
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-b3d24f2b="" class="unnnic-tooltip-trigger" data-testid="tooltip-trigger" data-state="closed" data-grace-area-trigger=""><span data-v-26446d8e="" data-v-b4e39fac="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--sm unnnic-icon__size--sm" data-testid="material-icon" translate="no">help</span></div>
|
|
8
8
|
<!--teleport start-->
|
|
9
9
|
<!--teleport end-->
|
|
10
10
|
</li>
|
|
@@ -3,6 +3,10 @@ import type { DrawerRootEmits, DrawerRootProps } from 'vaul-vue';
|
|
|
3
3
|
import { useForwardPropsEmits } from 'reka-ui';
|
|
4
4
|
import { DrawerRoot } from 'vaul-vue';
|
|
5
5
|
|
|
6
|
+
defineOptions({
|
|
7
|
+
name: 'UnnnicDrawerNext',
|
|
8
|
+
});
|
|
9
|
+
|
|
6
10
|
const props = withDefaults(defineProps<DrawerRootProps>(), {
|
|
7
11
|
shouldScaleBackground: true,
|
|
8
12
|
});
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { DialogContentEmits, DialogContentProps } from 'reka-ui';
|
|
3
|
-
import type
|
|
3
|
+
import { type HTMLAttributes } from 'vue';
|
|
4
4
|
import { reactiveOmit } from '@vueuse/core';
|
|
5
5
|
import { useForwardPropsEmits } from 'reka-ui';
|
|
6
6
|
import { DrawerContent, DrawerPortal } from 'vaul-vue';
|
|
7
7
|
import { cn } from '@/lib/utils';
|
|
8
8
|
import DrawerOverlay from './DrawerOverlay.vue';
|
|
9
9
|
|
|
10
|
+
defineOptions({
|
|
11
|
+
name: 'UnnnicDrawerContent',
|
|
12
|
+
});
|
|
13
|
+
|
|
10
14
|
const props = withDefaults(
|
|
11
15
|
defineProps<
|
|
12
16
|
DialogContentProps & {
|
|
@@ -5,6 +5,10 @@ import { reactiveOmit } from '@vueuse/core';
|
|
|
5
5
|
import { DrawerDescription } from 'vaul-vue';
|
|
6
6
|
import { cn } from '@/lib/utils';
|
|
7
7
|
|
|
8
|
+
defineOptions({
|
|
9
|
+
name: 'UnnnicDrawerDescription',
|
|
10
|
+
});
|
|
11
|
+
|
|
8
12
|
const props = defineProps<
|
|
9
13
|
DrawerDescriptionProps & { class?: HTMLAttributes['class'] }
|
|
10
14
|
>();
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type
|
|
2
|
+
import { type HTMLAttributes } from 'vue';
|
|
3
3
|
import { cn } from '@/lib/utils';
|
|
4
4
|
|
|
5
|
+
defineOptions({
|
|
6
|
+
name: 'UnnnicDrawerFooter',
|
|
7
|
+
});
|
|
8
|
+
|
|
5
9
|
const props = defineProps<{
|
|
6
10
|
class?: HTMLAttributes['class'];
|
|
7
11
|
}>();
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type
|
|
2
|
+
import { type HTMLAttributes } from 'vue';
|
|
3
3
|
import { cn } from '@/lib/utils';
|
|
4
4
|
import UnnnicButton from '@/components/Button/Button.vue';
|
|
5
5
|
import DrawerClose from './DrawerClose.vue';
|
|
6
6
|
|
|
7
|
+
defineOptions({
|
|
8
|
+
name: 'UnnnicDrawerHeader',
|
|
9
|
+
});
|
|
10
|
+
|
|
7
11
|
const props = defineProps<{
|
|
8
12
|
class?: HTMLAttributes['class'];
|
|
9
13
|
}>();
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { DialogOverlayProps } from 'reka-ui';
|
|
3
|
-
import type
|
|
3
|
+
import { type HTMLAttributes } from 'vue';
|
|
4
4
|
import { reactiveOmit } from '@vueuse/core';
|
|
5
5
|
import { DrawerOverlay } from 'vaul-vue';
|
|
6
6
|
import { cn } from '@/lib/utils';
|
|
7
7
|
|
|
8
|
+
defineOptions({
|
|
9
|
+
name: 'UnnnicDrawerOverlay',
|
|
10
|
+
});
|
|
11
|
+
|
|
8
12
|
const props = defineProps<
|
|
9
13
|
DialogOverlayProps & { class?: HTMLAttributes['class'] }
|
|
10
14
|
>();
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { DrawerTitleProps } from 'vaul-vue';
|
|
3
|
-
import type
|
|
3
|
+
import { type HTMLAttributes } from 'vue';
|
|
4
4
|
import { reactiveOmit } from '@vueuse/core';
|
|
5
5
|
import { DrawerTitle } from 'vaul-vue';
|
|
6
6
|
import { cn } from '@/lib/utils';
|
|
7
7
|
|
|
8
|
+
defineOptions({
|
|
9
|
+
name: 'UnnnicDrawerTitle',
|
|
10
|
+
});
|
|
11
|
+
|
|
8
12
|
const props = defineProps<
|
|
9
13
|
DrawerTitleProps & { class?: HTMLAttributes['class'] }
|
|
10
14
|
>();
|