design-system-next 2.11.20 → 2.12.1
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/design-system-next.es.js +7837 -7514
- package/dist/design-system-next.es.js.gz +0 -0
- package/dist/design-system-next.umd.js +12 -12
- package/dist/design-system-next.umd.js.gz +0 -0
- package/dist/main.css +1 -1
- package/dist/main.css.gz +0 -0
- package/dist/package.json.d.ts +1 -1
- package/package.json +1 -1
- package/src/App.vue +1 -49
- package/src/assets/scripts/border-radius.ts +15 -15
- package/src/assets/scripts/colors.ts +134 -134
- package/src/assets/scripts/max-width.ts +11 -11
- package/src/assets/scripts/spacing.ts +23 -23
- package/src/assets/scripts/utilities.ts +15 -15
- package/src/components/accordion/accordion.ts +43 -43
- package/src/components/accordion/use-accordion.ts +43 -43
- package/src/components/avatar/avatar.ts +64 -64
- package/src/components/badge/badge.ts +43 -43
- package/src/components/banner/banner.ts +20 -20
- package/src/components/button/button.ts +72 -72
- package/src/components/button/button.vue +15 -15
- package/src/components/card/card.ts +52 -52
- package/src/components/checkbox/checkbox.ts +45 -45
- package/src/components/chips/chips.ts +95 -95
- package/src/components/collapsible/collapsible.ts +21 -21
- package/src/components/collapsible/collapsible.vue +27 -27
- package/src/components/date-picker/__tests__/date-picker.test.ts +112 -112
- package/src/components/date-picker/date-picker.ts +157 -157
- package/src/components/date-picker/date-picker.vue +60 -53
- package/src/components/date-picker/use-date-picker.ts +6 -0
- package/src/components/dropdown/__tests__/dropdown-fixes.spec.ts +106 -106
- package/src/components/dropdown/__tests__/dropdown-value-types.spec.ts +213 -213
- package/src/components/dropdown/fix-multi-number.ts +92 -92
- package/src/components/dropdown/use-dropdown.ts +488 -488
- package/src/components/empty-state/empty-state.ts +50 -50
- package/src/components/file-upload/file-upload.ts +87 -87
- package/src/components/floating-action/floating-action.ts +12 -12
- package/src/components/input/input-contact-number/input-contact-number.ts +83 -83
- package/src/components/input/input-email/input-email.vue +17 -17
- package/src/components/input/input-password/use-input-password.ts +19 -19
- package/src/components/input/input-search/input-search.vue +13 -13
- package/src/components/input/input-url/input-url.vue +20 -20
- package/src/components/input/input-username/input-username.vue +17 -17
- package/src/components/input/input.vue +72 -72
- package/src/components/list/ladderized-list/ladderized-list.ts +39 -39
- package/src/components/logo/logo.ts +43 -43
- package/src/components/logo/logo.vue +14 -14
- package/src/components/logo/use-logo.ts +41 -41
- package/src/components/lozenge/lozenge.ts +16 -0
- package/src/components/lozenge/lozenge.vue +22 -13
- package/src/components/lozenge/use-lozenge.ts +58 -27
- package/src/components/modal/modal.ts +45 -45
- package/src/components/progress-bar/progress-bar.ts +39 -39
- package/src/components/radio/radio.ts +42 -42
- package/src/components/select/select.ts +144 -144
- package/src/components/sidenav/sidenav.ts +14 -0
- package/src/components/sidenav/sidenav.vue +36 -6
- package/src/components/sidenav/use-sidenav.ts +16 -3
- package/src/components/sidepanel/sidepanel.vue +55 -55
- package/src/components/sidepanel/stacking-sidepanel/stacking-sidepanel.ts +16 -16
- package/src/components/sidepanel/stacking-sidepanel/stacking-sidepanel.vue +39 -39
- package/src/components/slider/slider.ts +38 -38
- package/src/components/snackbar/snack/snack.ts +71 -71
- package/src/components/snackbar/use-snackbar.ts +34 -34
- package/src/components/status/status.ts +19 -19
- package/src/components/status/status.vue +13 -13
- package/src/components/stepper/step/step.ts +47 -47
- package/src/components/stepper/stepper.ts +47 -47
- package/src/components/stepper/stepper.vue +34 -34
- package/src/components/switch/switch.ts +42 -42
- package/src/components/table/table-actions/table-actions.ts +42 -42
- package/src/components/table/table-actions/table-actions.vue +40 -40
- package/src/components/table/table-chips-title/table-chips-title.ts +27 -27
- package/src/components/table/table-chips-title/table-chips-title.vue +32 -32
- package/src/components/table/table-chips-title/use-table-chips-title.ts +22 -22
- package/src/components/table/table-lozenge-title/table-lozenge-title.ts +23 -23
- package/src/components/table/table-lozenge-title/table-lozenge-title.vue +26 -26
- package/src/components/table/table-lozenge-title/use-table-lozenge-title.ts +21 -21
- package/src/components/table/table-pagination/table-pagination.ts +63 -63
- package/src/components/table/table-pagination/table-pagination.vue +72 -72
- package/src/components/table/table.ts +173 -173
- package/src/components/tabs/tabs.ts +43 -43
- package/src/components/textarea/textarea.ts +72 -72
- package/src/components/textarea/textarea.vue +45 -45
- package/src/components/time-picker/time-picker.ts +69 -69
- package/src/components/tooltip/use-tooltip.ts +13 -13
- package/src/examples/dropdown-number-multi-select.vue +76 -76
- package/src/stores/useSnackbarStore.ts +44 -44
- package/src/vite-env.d.ts +6 -0
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import type { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
-
|
|
3
|
-
export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
|
|
4
|
-
|
|
5
|
-
const CHIPS_SIZE = ['lg', 'md', 'sm'] as const;
|
|
6
|
-
export const ICON_WEIGHTS = ['regular', 'bold', 'thin', 'light', 'fill', 'duotone'] as const;
|
|
7
|
-
const CHIPS_VARIANT = ['tag', 'day'] as const;
|
|
8
|
-
const DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] as const;
|
|
9
|
-
|
|
10
|
-
export const chipsPropTypes = {
|
|
11
|
-
label: {
|
|
12
|
-
type: String,
|
|
13
|
-
default: '',
|
|
14
|
-
},
|
|
15
|
-
size: {
|
|
16
|
-
type: String,
|
|
17
|
-
validator: (value: (typeof CHIPS_SIZE)[number]) => CHIPS_SIZE.includes(value),
|
|
18
|
-
default: 'md',
|
|
19
|
-
},
|
|
20
|
-
disabled: {
|
|
21
|
-
type: Boolean,
|
|
22
|
-
default: false,
|
|
23
|
-
},
|
|
24
|
-
active: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
default: false,
|
|
27
|
-
},
|
|
28
|
-
closable: {
|
|
29
|
-
type: Boolean,
|
|
30
|
-
default: false,
|
|
31
|
-
},
|
|
32
|
-
avatarUrl: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: '',
|
|
35
|
-
},
|
|
36
|
-
avatarVariant: {
|
|
37
|
-
type: String,
|
|
38
|
-
default: '',
|
|
39
|
-
},
|
|
40
|
-
avatarInitials: {
|
|
41
|
-
type: String,
|
|
42
|
-
default: '',
|
|
43
|
-
},
|
|
44
|
-
icon: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: '',
|
|
47
|
-
},
|
|
48
|
-
iconWeight: {
|
|
49
|
-
type: String as PropType<(typeof ICON_WEIGHTS)[number]>,
|
|
50
|
-
validator: (value: (typeof ICON_WEIGHTS)[number]) => ICON_WEIGHTS.includes(value),
|
|
51
|
-
default: 'regular',
|
|
52
|
-
},
|
|
53
|
-
closeIconSize: {
|
|
54
|
-
type: Number,
|
|
55
|
-
default: 16,
|
|
56
|
-
},
|
|
57
|
-
badge: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
default: false,
|
|
60
|
-
},
|
|
61
|
-
badgeText: {
|
|
62
|
-
type: String,
|
|
63
|
-
default: '0',
|
|
64
|
-
},
|
|
65
|
-
badgeVariant: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: 'brand',
|
|
68
|
-
},
|
|
69
|
-
removable: {
|
|
70
|
-
type: Boolean,
|
|
71
|
-
default: false,
|
|
72
|
-
},
|
|
73
|
-
visible: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: true,
|
|
76
|
-
},
|
|
77
|
-
variant: {
|
|
78
|
-
type: String as PropType<(typeof CHIPS_VARIANT)[number]>,
|
|
79
|
-
validator: (value: (typeof CHIPS_VARIANT)[number]) => CHIPS_VARIANT.includes(value),
|
|
80
|
-
default: 'tag',
|
|
81
|
-
},
|
|
82
|
-
day: {
|
|
83
|
-
type: String as PropType<(typeof DAYS)[number]>,
|
|
84
|
-
default: 'Sunday',
|
|
85
|
-
validator: (value: string) => DAYS.includes(value as (typeof DAYS)[number]),
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type ChipsPropTypes = ExtractPropTypes<typeof chipsPropTypes>;
|
|
90
|
-
|
|
91
|
-
export const chipsEmitTypes = {
|
|
92
|
-
close: (evt: MouseEvent | KeyboardEvent): boolean => evt instanceof MouseEvent || evt instanceof KeyboardEvent,
|
|
93
|
-
update: (value: boolean): value is boolean => typeof value === 'boolean',
|
|
94
|
-
};
|
|
95
|
-
export type ChipsEmitTypes = typeof chipsEmitTypes;
|
|
1
|
+
import type { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
|
|
4
|
+
|
|
5
|
+
const CHIPS_SIZE = ['lg', 'md', 'sm'] as const;
|
|
6
|
+
export const ICON_WEIGHTS = ['regular', 'bold', 'thin', 'light', 'fill', 'duotone'] as const;
|
|
7
|
+
const CHIPS_VARIANT = ['tag', 'day'] as const;
|
|
8
|
+
const DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] as const;
|
|
9
|
+
|
|
10
|
+
export const chipsPropTypes = {
|
|
11
|
+
label: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: '',
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
type: String,
|
|
17
|
+
validator: (value: (typeof CHIPS_SIZE)[number]) => CHIPS_SIZE.includes(value),
|
|
18
|
+
default: 'md',
|
|
19
|
+
},
|
|
20
|
+
disabled: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false,
|
|
23
|
+
},
|
|
24
|
+
active: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
closable: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false,
|
|
31
|
+
},
|
|
32
|
+
avatarUrl: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: '',
|
|
35
|
+
},
|
|
36
|
+
avatarVariant: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: '',
|
|
39
|
+
},
|
|
40
|
+
avatarInitials: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: '',
|
|
43
|
+
},
|
|
44
|
+
icon: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: '',
|
|
47
|
+
},
|
|
48
|
+
iconWeight: {
|
|
49
|
+
type: String as PropType<(typeof ICON_WEIGHTS)[number]>,
|
|
50
|
+
validator: (value: (typeof ICON_WEIGHTS)[number]) => ICON_WEIGHTS.includes(value),
|
|
51
|
+
default: 'regular',
|
|
52
|
+
},
|
|
53
|
+
closeIconSize: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 16,
|
|
56
|
+
},
|
|
57
|
+
badge: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
61
|
+
badgeText: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: '0',
|
|
64
|
+
},
|
|
65
|
+
badgeVariant: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: 'brand',
|
|
68
|
+
},
|
|
69
|
+
removable: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
visible: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: true,
|
|
76
|
+
},
|
|
77
|
+
variant: {
|
|
78
|
+
type: String as PropType<(typeof CHIPS_VARIANT)[number]>,
|
|
79
|
+
validator: (value: (typeof CHIPS_VARIANT)[number]) => CHIPS_VARIANT.includes(value),
|
|
80
|
+
default: 'tag',
|
|
81
|
+
},
|
|
82
|
+
day: {
|
|
83
|
+
type: String as PropType<(typeof DAYS)[number]>,
|
|
84
|
+
default: 'Sunday',
|
|
85
|
+
validator: (value: string) => DAYS.includes(value as (typeof DAYS)[number]),
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type ChipsPropTypes = ExtractPropTypes<typeof chipsPropTypes>;
|
|
90
|
+
|
|
91
|
+
export const chipsEmitTypes = {
|
|
92
|
+
close: (evt: MouseEvent | KeyboardEvent): boolean => evt instanceof MouseEvent || evt instanceof KeyboardEvent,
|
|
93
|
+
update: (value: boolean): value is boolean => typeof value === 'boolean',
|
|
94
|
+
};
|
|
95
|
+
export type ChipsEmitTypes = typeof chipsEmitTypes;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { PropType, ExtractPropTypes } from "vue";
|
|
2
|
-
|
|
3
|
-
export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
|
|
4
|
-
|
|
5
|
-
export const collapsiblePropTypes = {
|
|
6
|
-
modelValue: {
|
|
7
|
-
type: Boolean,
|
|
8
|
-
required: true,
|
|
9
|
-
},
|
|
10
|
-
transitionDuration: {
|
|
11
|
-
type: Number,
|
|
12
|
-
default: 150, // Default transition duration in milliseconds
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const collapsibleEmitTypes = {
|
|
17
|
-
'update:modelValue': (value: boolean) => typeof value === 'boolean',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type CollapsibleEmitTypes = typeof collapsibleEmitTypes
|
|
21
|
-
export type CollapsibleProps = ExtractPropTypes<typeof collapsiblePropTypes>;
|
|
1
|
+
import type { PropType, ExtractPropTypes } from "vue";
|
|
2
|
+
|
|
3
|
+
export const definePropType = <T>(val: unknown): PropType<T> => val as PropType<T>;
|
|
4
|
+
|
|
5
|
+
export const collapsiblePropTypes = {
|
|
6
|
+
modelValue: {
|
|
7
|
+
type: Boolean,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
transitionDuration: {
|
|
11
|
+
type: Number,
|
|
12
|
+
default: 150, // Default transition duration in milliseconds
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const collapsibleEmitTypes = {
|
|
17
|
+
'update:modelValue': (value: boolean) => typeof value === 'boolean',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type CollapsibleEmitTypes = typeof collapsibleEmitTypes
|
|
21
|
+
export type CollapsibleProps = ExtractPropTypes<typeof collapsiblePropTypes>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="collapsibleClasses.container">
|
|
3
|
-
<slot name="trigger" :toggle-collapsible="toggleCollapsible" />
|
|
4
|
-
<Transition
|
|
5
|
-
:css="false"
|
|
6
|
-
@before-enter="onBeforeEnter"
|
|
7
|
-
@enter="onEnter"
|
|
8
|
-
@before-leave="onBeforeLeave"
|
|
9
|
-
@leave="onLeave"
|
|
10
|
-
>
|
|
11
|
-
<div v-show="modelValue" :style="contentStyle">
|
|
12
|
-
<slot />
|
|
13
|
-
</div>
|
|
14
|
-
</Transition>
|
|
15
|
-
</div>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script setup lang="ts">
|
|
19
|
-
import { collapsiblePropTypes, collapsibleEmitTypes } from './collapsible';
|
|
20
|
-
import { useCollapsible } from './use-collapsible';
|
|
21
|
-
|
|
22
|
-
const props = defineProps(collapsiblePropTypes);
|
|
23
|
-
const emit = defineEmits(collapsibleEmitTypes);
|
|
24
|
-
|
|
25
|
-
const { collapsibleClasses, contentStyle, toggleCollapsible, onBeforeEnter, onEnter, onBeforeLeave, onLeave } =
|
|
26
|
-
useCollapsible(props, emit);
|
|
27
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="collapsibleClasses.container">
|
|
3
|
+
<slot name="trigger" :toggle-collapsible="toggleCollapsible" />
|
|
4
|
+
<Transition
|
|
5
|
+
:css="false"
|
|
6
|
+
@before-enter="onBeforeEnter"
|
|
7
|
+
@enter="onEnter"
|
|
8
|
+
@before-leave="onBeforeLeave"
|
|
9
|
+
@leave="onLeave"
|
|
10
|
+
>
|
|
11
|
+
<div v-show="modelValue" :style="contentStyle">
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
</Transition>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { collapsiblePropTypes, collapsibleEmitTypes } from './collapsible';
|
|
20
|
+
import { useCollapsible } from './use-collapsible';
|
|
21
|
+
|
|
22
|
+
const props = defineProps(collapsiblePropTypes);
|
|
23
|
+
const emit = defineEmits(collapsibleEmitTypes);
|
|
24
|
+
|
|
25
|
+
const { collapsibleClasses, contentStyle, toggleCollapsible, onBeforeEnter, onEnter, onBeforeLeave, onLeave } =
|
|
26
|
+
useCollapsible(props, emit);
|
|
27
|
+
</script>
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
import { mount } from '@vue/test-utils';
|
|
2
|
-
import { describe, it, expect } from 'vitest';
|
|
3
|
-
import DatePicker from '../date-picker.vue';
|
|
4
|
-
|
|
5
|
-
describe('DatePicker', () => {
|
|
6
|
-
it('should render the component', () => {
|
|
7
|
-
const wrapper = mount(DatePicker, {
|
|
8
|
-
props: {
|
|
9
|
-
id: 'test-date-picker',
|
|
10
|
-
modelValue: '',
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
expect(wrapper.exists()).toBe(true);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should use default date format (MM-DD-YYYY) when no format prop is provided', async () => {
|
|
18
|
-
const wrapper = mount(DatePicker, {
|
|
19
|
-
props: {
|
|
20
|
-
id: 'test-date-picker',
|
|
21
|
-
modelValue: '',
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Simulate user selecting a date
|
|
26
|
-
const dateToSelect = '2023-05-15'; // ISO format
|
|
27
|
-
|
|
28
|
-
// Find the input element and simulate user input
|
|
29
|
-
const input = wrapper.find('input');
|
|
30
|
-
await input.setValue(dateToSelect);
|
|
31
|
-
await input.trigger('change');
|
|
32
|
-
|
|
33
|
-
// Check that the emitted value uses the default format MM-DD-YYYY
|
|
34
|
-
const emittedValue = wrapper.emitted('update:modelValue');
|
|
35
|
-
expect(emittedValue).toBeDefined();
|
|
36
|
-
expect(emittedValue![emittedValue!.length - 1][0]).toMatch(/\d{2}-\d{2}-\d{4}/); // MM-DD-YYYY format
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should format the date according to the specified format prop (YYYY-MM-DD)', async () => {
|
|
40
|
-
const wrapper = mount(DatePicker, {
|
|
41
|
-
props: {
|
|
42
|
-
id: 'test-date-picker',
|
|
43
|
-
modelValue: '',
|
|
44
|
-
format: 'YYYY-MM-DD',
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Simulate user selecting a date
|
|
49
|
-
const dateToSelect = '05/15/2023'; // Different format input
|
|
50
|
-
|
|
51
|
-
// Find the input element and simulate user input
|
|
52
|
-
const input = wrapper.find('input');
|
|
53
|
-
await input.setValue(dateToSelect);
|
|
54
|
-
await input.trigger('change');
|
|
55
|
-
|
|
56
|
-
// Check that the emitted value uses the specified format YYYY-MM-DD
|
|
57
|
-
const emittedValue = wrapper.emitted('update:modelValue');
|
|
58
|
-
expect(emittedValue).toBeDefined();
|
|
59
|
-
expect(emittedValue![emittedValue!.length - 1][0]).toMatch(/\d{4}-\d{2}-\d{2}/); // YYYY-MM-DD format
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should format the date according to the specified format prop (MM/DD/YYYY)', async () => {
|
|
63
|
-
const wrapper = mount(DatePicker, {
|
|
64
|
-
props: {
|
|
65
|
-
id: 'test-date-picker',
|
|
66
|
-
modelValue: '',
|
|
67
|
-
format: 'MM/DD/YYYY',
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Simulate user selecting a date
|
|
72
|
-
const dateToSelect = '2023-05-15'; // ISO format
|
|
73
|
-
|
|
74
|
-
// Find the input element and simulate user input
|
|
75
|
-
const input = wrapper.find('input');
|
|
76
|
-
await input.setValue(dateToSelect);
|
|
77
|
-
await input.trigger('change');
|
|
78
|
-
|
|
79
|
-
// Check that the emitted value uses the specified format MM/DD/YYYY
|
|
80
|
-
const emittedValue = wrapper.emitted('update:modelValue');
|
|
81
|
-
expect(emittedValue).toBeDefined();
|
|
82
|
-
expect(emittedValue![emittedValue!.length - 1][0]).toMatch(/\d{2}\/\d{2}\/\d{4}/); // MM/DD/YYYY format
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should parse dates correctly with different format (MM/DD/YYYY)', async () => {
|
|
86
|
-
const wrapper = mount(DatePicker, {
|
|
87
|
-
props: {
|
|
88
|
-
id: 'test-date-picker',
|
|
89
|
-
modelValue: '05/15/2023', // Using MM/DD/YYYY format
|
|
90
|
-
format: 'MM/DD/YYYY',
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// Check that the component correctly displays the date in the input
|
|
95
|
-
const input = wrapper.find('input');
|
|
96
|
-
expect(input.element.value).toBe('05/15/2023');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should parse dates correctly with different format (YYYY-MM-DD)', async () => {
|
|
100
|
-
const wrapper = mount(DatePicker, {
|
|
101
|
-
props: {
|
|
102
|
-
id: 'test-date-picker',
|
|
103
|
-
modelValue: '2023-05-15', // Using YYYY-MM-DD format
|
|
104
|
-
format: 'YYYY-MM-DD',
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// Check that the component correctly displays the date in the input
|
|
109
|
-
const input = wrapper.find('input');
|
|
110
|
-
expect(input.element.value).toBe('2023-05-15');
|
|
111
|
-
});
|
|
112
|
-
});
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import DatePicker from '../date-picker.vue';
|
|
4
|
+
|
|
5
|
+
describe('DatePicker', () => {
|
|
6
|
+
it('should render the component', () => {
|
|
7
|
+
const wrapper = mount(DatePicker, {
|
|
8
|
+
props: {
|
|
9
|
+
id: 'test-date-picker',
|
|
10
|
+
modelValue: '',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
expect(wrapper.exists()).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should use default date format (MM-DD-YYYY) when no format prop is provided', async () => {
|
|
18
|
+
const wrapper = mount(DatePicker, {
|
|
19
|
+
props: {
|
|
20
|
+
id: 'test-date-picker',
|
|
21
|
+
modelValue: '',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Simulate user selecting a date
|
|
26
|
+
const dateToSelect = '2023-05-15'; // ISO format
|
|
27
|
+
|
|
28
|
+
// Find the input element and simulate user input
|
|
29
|
+
const input = wrapper.find('input');
|
|
30
|
+
await input.setValue(dateToSelect);
|
|
31
|
+
await input.trigger('change');
|
|
32
|
+
|
|
33
|
+
// Check that the emitted value uses the default format MM-DD-YYYY
|
|
34
|
+
const emittedValue = wrapper.emitted('update:modelValue');
|
|
35
|
+
expect(emittedValue).toBeDefined();
|
|
36
|
+
expect(emittedValue![emittedValue!.length - 1][0]).toMatch(/\d{2}-\d{2}-\d{4}/); // MM-DD-YYYY format
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should format the date according to the specified format prop (YYYY-MM-DD)', async () => {
|
|
40
|
+
const wrapper = mount(DatePicker, {
|
|
41
|
+
props: {
|
|
42
|
+
id: 'test-date-picker',
|
|
43
|
+
modelValue: '',
|
|
44
|
+
format: 'YYYY-MM-DD',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Simulate user selecting a date
|
|
49
|
+
const dateToSelect = '05/15/2023'; // Different format input
|
|
50
|
+
|
|
51
|
+
// Find the input element and simulate user input
|
|
52
|
+
const input = wrapper.find('input');
|
|
53
|
+
await input.setValue(dateToSelect);
|
|
54
|
+
await input.trigger('change');
|
|
55
|
+
|
|
56
|
+
// Check that the emitted value uses the specified format YYYY-MM-DD
|
|
57
|
+
const emittedValue = wrapper.emitted('update:modelValue');
|
|
58
|
+
expect(emittedValue).toBeDefined();
|
|
59
|
+
expect(emittedValue![emittedValue!.length - 1][0]).toMatch(/\d{4}-\d{2}-\d{2}/); // YYYY-MM-DD format
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should format the date according to the specified format prop (MM/DD/YYYY)', async () => {
|
|
63
|
+
const wrapper = mount(DatePicker, {
|
|
64
|
+
props: {
|
|
65
|
+
id: 'test-date-picker',
|
|
66
|
+
modelValue: '',
|
|
67
|
+
format: 'MM/DD/YYYY',
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Simulate user selecting a date
|
|
72
|
+
const dateToSelect = '2023-05-15'; // ISO format
|
|
73
|
+
|
|
74
|
+
// Find the input element and simulate user input
|
|
75
|
+
const input = wrapper.find('input');
|
|
76
|
+
await input.setValue(dateToSelect);
|
|
77
|
+
await input.trigger('change');
|
|
78
|
+
|
|
79
|
+
// Check that the emitted value uses the specified format MM/DD/YYYY
|
|
80
|
+
const emittedValue = wrapper.emitted('update:modelValue');
|
|
81
|
+
expect(emittedValue).toBeDefined();
|
|
82
|
+
expect(emittedValue![emittedValue!.length - 1][0]).toMatch(/\d{2}\/\d{2}\/\d{4}/); // MM/DD/YYYY format
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should parse dates correctly with different format (MM/DD/YYYY)', async () => {
|
|
86
|
+
const wrapper = mount(DatePicker, {
|
|
87
|
+
props: {
|
|
88
|
+
id: 'test-date-picker',
|
|
89
|
+
modelValue: '05/15/2023', // Using MM/DD/YYYY format
|
|
90
|
+
format: 'MM/DD/YYYY',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Check that the component correctly displays the date in the input
|
|
95
|
+
const input = wrapper.find('input');
|
|
96
|
+
expect(input.element.value).toBe('05/15/2023');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should parse dates correctly with different format (YYYY-MM-DD)', async () => {
|
|
100
|
+
const wrapper = mount(DatePicker, {
|
|
101
|
+
props: {
|
|
102
|
+
id: 'test-date-picker',
|
|
103
|
+
modelValue: '2023-05-15', // Using YYYY-MM-DD format
|
|
104
|
+
format: 'YYYY-MM-DD',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Check that the component correctly displays the date in the input
|
|
109
|
+
const input = wrapper.find('input');
|
|
110
|
+
expect(input.element.value).toBe('2023-05-15');
|
|
111
|
+
});
|
|
112
|
+
});
|