design-system-next 2.11.17 → 2.11.18
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 +6609 -6718
- 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 +49 -1
- 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/assets/styles/tailwind.css +6 -18
- 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/calendar/calendar.ts +89 -89
- 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/dropdown/__tests__/dropdown-fixes.spec.ts +106 -106
- package/src/components/dropdown/__tests__/dropdown-value-types.spec.ts +213 -213
- package/src/components/dropdown/dropdown.ts +4 -0
- package/src/components/dropdown/dropdown.vue +2 -0
- 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/list/list.ts +4 -0
- package/src/components/list/list.vue +33 -24
- 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 +61 -61
- 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 +172 -173
- package/src/components/sidenav/sidenav.vue +211 -126
- package/src/components/sidenav/use-sidenav.ts +85 -76
- package/src/components/sidepanel/sidepanel.ts +100 -100
- 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/tooltip.ts +44 -46
- package/src/components/tooltip/tooltip.vue +4 -1
- 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 +0 -6
|
@@ -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
|
+
});
|
|
@@ -1,157 +1,157 @@
|
|
|
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 REST_DAYS_TYPES = ['su', 'mo', 'tu', 'we', 'th', 'fr', 'sa'] as const;
|
|
6
|
-
|
|
7
|
-
const POPPER_STRATEGY_TYPES = ['fixed', 'absolute'] as const;
|
|
8
|
-
const PLACEMENTS_TYPES = [
|
|
9
|
-
'auto',
|
|
10
|
-
'auto-start',
|
|
11
|
-
'auto-end',
|
|
12
|
-
'top',
|
|
13
|
-
'top-start',
|
|
14
|
-
'top-end',
|
|
15
|
-
'right',
|
|
16
|
-
'right-start',
|
|
17
|
-
'right-end',
|
|
18
|
-
'bottom',
|
|
19
|
-
'bottom-start',
|
|
20
|
-
'bottom-end',
|
|
21
|
-
'left',
|
|
22
|
-
'left-start',
|
|
23
|
-
'left-end',
|
|
24
|
-
] as const;
|
|
25
|
-
|
|
26
|
-
export const datePickerPropTypes = {
|
|
27
|
-
id: {
|
|
28
|
-
type: String,
|
|
29
|
-
required: true,
|
|
30
|
-
default: 'date-picker',
|
|
31
|
-
},
|
|
32
|
-
modelValue: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: '',
|
|
35
|
-
required: true,
|
|
36
|
-
},
|
|
37
|
-
label: {
|
|
38
|
-
type: String,
|
|
39
|
-
default: '',
|
|
40
|
-
},
|
|
41
|
-
active: {
|
|
42
|
-
type: Boolean,
|
|
43
|
-
default: false,
|
|
44
|
-
},
|
|
45
|
-
disabled: {
|
|
46
|
-
type: Boolean,
|
|
47
|
-
default: false,
|
|
48
|
-
},
|
|
49
|
-
readonly: {
|
|
50
|
-
type: Boolean,
|
|
51
|
-
default: false,
|
|
52
|
-
},
|
|
53
|
-
error: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: false,
|
|
56
|
-
},
|
|
57
|
-
currentYear: {
|
|
58
|
-
type: String,
|
|
59
|
-
default: new Date().getFullYear().toString(),
|
|
60
|
-
},
|
|
61
|
-
minMaxYear: {
|
|
62
|
-
type: Object as PropType<MinMaxYearType>,
|
|
63
|
-
default: () => ({
|
|
64
|
-
min: 1900,
|
|
65
|
-
max: new Date().getFullYear(),
|
|
66
|
-
}),
|
|
67
|
-
},
|
|
68
|
-
restDays: {
|
|
69
|
-
type: Array as PropType<RestDayType[]>,
|
|
70
|
-
validator: (value: RestDayType[]): boolean => {
|
|
71
|
-
return value.every((val) => REST_DAYS_TYPES.includes(val));
|
|
72
|
-
},
|
|
73
|
-
default: [],
|
|
74
|
-
},
|
|
75
|
-
disabledDates: {
|
|
76
|
-
type: Object as PropType<DisabledDatesType>,
|
|
77
|
-
},
|
|
78
|
-
displayHelper: {
|
|
79
|
-
type: Boolean,
|
|
80
|
-
default: false,
|
|
81
|
-
},
|
|
82
|
-
helperText: {
|
|
83
|
-
type: String,
|
|
84
|
-
default: '',
|
|
85
|
-
},
|
|
86
|
-
helperIcon: {
|
|
87
|
-
type: String,
|
|
88
|
-
default: null,
|
|
89
|
-
},
|
|
90
|
-
width: {
|
|
91
|
-
type: String,
|
|
92
|
-
default: '100%',
|
|
93
|
-
},
|
|
94
|
-
popperStrategy: {
|
|
95
|
-
type: String,
|
|
96
|
-
validator: (value: 'fixed' | 'absolute') => POPPER_STRATEGY_TYPES.includes(value),
|
|
97
|
-
default: 'absolute',
|
|
98
|
-
},
|
|
99
|
-
placement: {
|
|
100
|
-
type: String as PropType<(typeof PLACEMENTS_TYPES)[number]>,
|
|
101
|
-
validator: (value: (typeof PLACEMENTS_TYPES)[number]) => PLACEMENTS_TYPES.includes(value),
|
|
102
|
-
default: 'bottom',
|
|
103
|
-
},
|
|
104
|
-
format: {
|
|
105
|
-
type: String,
|
|
106
|
-
default: 'MM-DD-YYYY',
|
|
107
|
-
description: 'Format for the selected date. For example: MM/DD/YYYY, YYYY-MM-DD, etc.',
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export type RestDayType = (typeof REST_DAYS_TYPES)[number];
|
|
112
|
-
|
|
113
|
-
export type DisabledDatesType = {
|
|
114
|
-
to: string;
|
|
115
|
-
from: string;
|
|
116
|
-
pastDates: boolean | string;
|
|
117
|
-
futureDates: boolean | string;
|
|
118
|
-
selectedDates: Array<string>;
|
|
119
|
-
weekends: boolean;
|
|
120
|
-
weekdays: boolean;
|
|
121
|
-
selectedDays: Array<string>;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export type MinMaxYearType = {
|
|
125
|
-
min: number;
|
|
126
|
-
max: number;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export const datePickerEmitTypes = {
|
|
130
|
-
'update:modelValue': (value: string) => typeof value === 'string',
|
|
131
|
-
getInputValue: (value: string | null) => value === null || typeof value === 'string',
|
|
132
|
-
getDateFormats: (value: Record<string, string>) => {
|
|
133
|
-
return (
|
|
134
|
-
typeof value === 'object' &&
|
|
135
|
-
value !== null &&
|
|
136
|
-
!Array.isArray(value) &&
|
|
137
|
-
Object.keys(value).every((key) => typeof value[key] === 'string')
|
|
138
|
-
);
|
|
139
|
-
},
|
|
140
|
-
getMonthList: (value: Array<object>) => Array.isArray(value),
|
|
141
|
-
getYearList: (value: Array<number>) => Array.isArray(value),
|
|
142
|
-
getDateErrors: (value: Array<{ title: string; message: string }>) => {
|
|
143
|
-
return (
|
|
144
|
-
Array.isArray(value) &&
|
|
145
|
-
value.every(
|
|
146
|
-
(item) =>
|
|
147
|
-
item !== null &&
|
|
148
|
-
typeof item === 'object' &&
|
|
149
|
-
typeof item.title === 'string' &&
|
|
150
|
-
typeof item.message === 'string',
|
|
151
|
-
)
|
|
152
|
-
);
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export type DatePickerPropTypes = ExtractPropTypes<typeof datePickerPropTypes>;
|
|
157
|
-
export type DatePickerEmitTypes = typeof datePickerEmitTypes;
|
|
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 REST_DAYS_TYPES = ['su', 'mo', 'tu', 'we', 'th', 'fr', 'sa'] as const;
|
|
6
|
+
|
|
7
|
+
const POPPER_STRATEGY_TYPES = ['fixed', 'absolute'] as const;
|
|
8
|
+
const PLACEMENTS_TYPES = [
|
|
9
|
+
'auto',
|
|
10
|
+
'auto-start',
|
|
11
|
+
'auto-end',
|
|
12
|
+
'top',
|
|
13
|
+
'top-start',
|
|
14
|
+
'top-end',
|
|
15
|
+
'right',
|
|
16
|
+
'right-start',
|
|
17
|
+
'right-end',
|
|
18
|
+
'bottom',
|
|
19
|
+
'bottom-start',
|
|
20
|
+
'bottom-end',
|
|
21
|
+
'left',
|
|
22
|
+
'left-start',
|
|
23
|
+
'left-end',
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
export const datePickerPropTypes = {
|
|
27
|
+
id: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
default: 'date-picker',
|
|
31
|
+
},
|
|
32
|
+
modelValue: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: '',
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
label: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: '',
|
|
40
|
+
},
|
|
41
|
+
active: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
disabled: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: false,
|
|
48
|
+
},
|
|
49
|
+
readonly: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
error: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false,
|
|
56
|
+
},
|
|
57
|
+
currentYear: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: new Date().getFullYear().toString(),
|
|
60
|
+
},
|
|
61
|
+
minMaxYear: {
|
|
62
|
+
type: Object as PropType<MinMaxYearType>,
|
|
63
|
+
default: () => ({
|
|
64
|
+
min: 1900,
|
|
65
|
+
max: new Date().getFullYear(),
|
|
66
|
+
}),
|
|
67
|
+
},
|
|
68
|
+
restDays: {
|
|
69
|
+
type: Array as PropType<RestDayType[]>,
|
|
70
|
+
validator: (value: RestDayType[]): boolean => {
|
|
71
|
+
return value.every((val) => REST_DAYS_TYPES.includes(val));
|
|
72
|
+
},
|
|
73
|
+
default: [],
|
|
74
|
+
},
|
|
75
|
+
disabledDates: {
|
|
76
|
+
type: Object as PropType<DisabledDatesType>,
|
|
77
|
+
},
|
|
78
|
+
displayHelper: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false,
|
|
81
|
+
},
|
|
82
|
+
helperText: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: '',
|
|
85
|
+
},
|
|
86
|
+
helperIcon: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: null,
|
|
89
|
+
},
|
|
90
|
+
width: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: '100%',
|
|
93
|
+
},
|
|
94
|
+
popperStrategy: {
|
|
95
|
+
type: String,
|
|
96
|
+
validator: (value: 'fixed' | 'absolute') => POPPER_STRATEGY_TYPES.includes(value),
|
|
97
|
+
default: 'absolute',
|
|
98
|
+
},
|
|
99
|
+
placement: {
|
|
100
|
+
type: String as PropType<(typeof PLACEMENTS_TYPES)[number]>,
|
|
101
|
+
validator: (value: (typeof PLACEMENTS_TYPES)[number]) => PLACEMENTS_TYPES.includes(value),
|
|
102
|
+
default: 'bottom',
|
|
103
|
+
},
|
|
104
|
+
format: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: 'MM-DD-YYYY',
|
|
107
|
+
description: 'Format for the selected date. For example: MM/DD/YYYY, YYYY-MM-DD, etc.',
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type RestDayType = (typeof REST_DAYS_TYPES)[number];
|
|
112
|
+
|
|
113
|
+
export type DisabledDatesType = {
|
|
114
|
+
to: string;
|
|
115
|
+
from: string;
|
|
116
|
+
pastDates: boolean | string;
|
|
117
|
+
futureDates: boolean | string;
|
|
118
|
+
selectedDates: Array<string>;
|
|
119
|
+
weekends: boolean;
|
|
120
|
+
weekdays: boolean;
|
|
121
|
+
selectedDays: Array<string>;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type MinMaxYearType = {
|
|
125
|
+
min: number;
|
|
126
|
+
max: number;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const datePickerEmitTypes = {
|
|
130
|
+
'update:modelValue': (value: string) => typeof value === 'string',
|
|
131
|
+
getInputValue: (value: string | null) => value === null || typeof value === 'string',
|
|
132
|
+
getDateFormats: (value: Record<string, string>) => {
|
|
133
|
+
return (
|
|
134
|
+
typeof value === 'object' &&
|
|
135
|
+
value !== null &&
|
|
136
|
+
!Array.isArray(value) &&
|
|
137
|
+
Object.keys(value).every((key) => typeof value[key] === 'string')
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
getMonthList: (value: Array<object>) => Array.isArray(value),
|
|
141
|
+
getYearList: (value: Array<number>) => Array.isArray(value),
|
|
142
|
+
getDateErrors: (value: Array<{ title: string; message: string }>) => {
|
|
143
|
+
return (
|
|
144
|
+
Array.isArray(value) &&
|
|
145
|
+
value.every(
|
|
146
|
+
(item) =>
|
|
147
|
+
item !== null &&
|
|
148
|
+
typeof item === 'object' &&
|
|
149
|
+
typeof item.title === 'string' &&
|
|
150
|
+
typeof item.message === 'string',
|
|
151
|
+
)
|
|
152
|
+
);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export type DatePickerPropTypes = ExtractPropTypes<typeof datePickerPropTypes>;
|
|
157
|
+
export type DatePickerEmitTypes = typeof datePickerEmitTypes;
|