design-system-next 2.11.11 → 2.11.17
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 +9372 -8159
- 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/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 +20 -0
- 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/date-picker/date-range-picker/date-range-picker.ts +193 -0
- package/src/components/date-picker/date-range-picker/date-range-picker.vue +412 -0
- package/src/components/date-picker/date-range-picker/use-date-range-picker.ts +957 -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/list/ladderized-list/use-ladderized-list.ts +92 -9
- package/src/components/list/list.ts +1 -1
- package/src/components/list/list.vue +95 -73
- package/src/components/list/use-list.ts +214 -77
- 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-ladderized/select-ladderized.ts +2 -0
- package/src/components/select/select-ladderized/select-ladderized.vue +2 -2
- package/src/components/select/select-ladderized/use-select-ladderized.ts +53 -3
- package/src/components/select/select-multiple/select-multiple.ts +1 -1
- package/src/components/select/select.ts +144 -144
- package/src/components/sidenav/sidenav.ts +173 -173
- 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/tabs/use-tabs.ts +16 -2
- 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 +46 -46
- 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
|
@@ -0,0 +1,193 @@
|
|
|
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
|
+
export 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 dateRangePickerPropTypes = {
|
|
27
|
+
id: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
default: 'date-range-picker',
|
|
31
|
+
},
|
|
32
|
+
modelValue: {
|
|
33
|
+
type: Object as PropType<DateRangeType>,
|
|
34
|
+
default: () => ({
|
|
35
|
+
startDate: '',
|
|
36
|
+
endDate: '',
|
|
37
|
+
}),
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
label: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: '',
|
|
43
|
+
},
|
|
44
|
+
active: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
disabled: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false,
|
|
51
|
+
},
|
|
52
|
+
readonly: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false,
|
|
55
|
+
},
|
|
56
|
+
error: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false,
|
|
59
|
+
},
|
|
60
|
+
currentYear: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: new Date().getFullYear().toString(),
|
|
63
|
+
},
|
|
64
|
+
minMaxYear: {
|
|
65
|
+
type: Object as PropType<MinMaxYearType>,
|
|
66
|
+
default: () => ({
|
|
67
|
+
min: 1900,
|
|
68
|
+
max: new Date().getFullYear(),
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
restDays: {
|
|
72
|
+
type: Array as PropType<RestDayType[]>,
|
|
73
|
+
validator: (value: RestDayType[]): boolean => {
|
|
74
|
+
return value.every((val) => REST_DAYS_TYPES.includes(val));
|
|
75
|
+
},
|
|
76
|
+
default: [],
|
|
77
|
+
},
|
|
78
|
+
disabledDates: {
|
|
79
|
+
type: Object as PropType<DisabledDatesType>,
|
|
80
|
+
},
|
|
81
|
+
displayHelper: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false,
|
|
84
|
+
},
|
|
85
|
+
helperText: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: '',
|
|
88
|
+
},
|
|
89
|
+
helperIcon: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: null,
|
|
92
|
+
},
|
|
93
|
+
width: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: '100%',
|
|
96
|
+
},
|
|
97
|
+
popperStrategy: {
|
|
98
|
+
type: String,
|
|
99
|
+
validator: (value: 'fixed' | 'absolute') => POPPER_STRATEGY_TYPES.includes(value),
|
|
100
|
+
default: 'absolute',
|
|
101
|
+
},
|
|
102
|
+
placement: {
|
|
103
|
+
type: String as PropType<(typeof PLACEMENTS_TYPES)[number]>,
|
|
104
|
+
validator: (value: (typeof PLACEMENTS_TYPES)[number]) => PLACEMENTS_TYPES.includes(value),
|
|
105
|
+
default: 'bottom',
|
|
106
|
+
},
|
|
107
|
+
format: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: 'MM-DD-YYYY',
|
|
110
|
+
},
|
|
111
|
+
separator: {
|
|
112
|
+
type: String,
|
|
113
|
+
default: 'to',
|
|
114
|
+
description: 'Text separator between start and end date inputs',
|
|
115
|
+
},
|
|
116
|
+
allowSameDay: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: false,
|
|
119
|
+
description: 'Allow selecting the same day for start and end date',
|
|
120
|
+
},
|
|
121
|
+
maxRange: {
|
|
122
|
+
type: Number,
|
|
123
|
+
default: null,
|
|
124
|
+
description: 'Maximum number of days allowed in the range',
|
|
125
|
+
},
|
|
126
|
+
minRange: {
|
|
127
|
+
type: Number,
|
|
128
|
+
default: 1,
|
|
129
|
+
description: 'Minimum number of days required in the range',
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type RestDayType = (typeof REST_DAYS_TYPES)[number];
|
|
134
|
+
|
|
135
|
+
export type DateRangeType = {
|
|
136
|
+
startDate: string;
|
|
137
|
+
endDate: string;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type DisabledDatesType = {
|
|
141
|
+
to?: string;
|
|
142
|
+
from?: string;
|
|
143
|
+
pastDates?: boolean | string;
|
|
144
|
+
futureDates?: boolean | string;
|
|
145
|
+
selectedDates?: Array<string>;
|
|
146
|
+
weekends?: boolean;
|
|
147
|
+
weekdays?: boolean;
|
|
148
|
+
selectedDays?: Array<string>;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export type MinMaxYearType = {
|
|
152
|
+
min: number;
|
|
153
|
+
max: number;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const dateRangePickerEmitTypes = {
|
|
157
|
+
'update:modelValue': (value: DateRangeType) => typeof value === 'object' && value !== null,
|
|
158
|
+
getInputValue: (value: DateRangeType | null) => value === null || typeof value === 'object',
|
|
159
|
+
getDateFormats: (value: Record<string, DateRangeType>) => {
|
|
160
|
+
return (
|
|
161
|
+
typeof value === 'object' &&
|
|
162
|
+
value !== null &&
|
|
163
|
+
!Array.isArray(value) &&
|
|
164
|
+
Object.keys(value).every((key) => typeof value[key] === 'object')
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
getMonthList: (value: Array<object>) => Array.isArray(value),
|
|
168
|
+
getYearList: (value: Array<number>) => Array.isArray(value),
|
|
169
|
+
getDateErrors: (value: Array<{ title: string; message: string }>) => {
|
|
170
|
+
return (
|
|
171
|
+
Array.isArray(value) &&
|
|
172
|
+
value.every(
|
|
173
|
+
(item) =>
|
|
174
|
+
item !== null &&
|
|
175
|
+
typeof item === 'object' &&
|
|
176
|
+
typeof item.title === 'string' &&
|
|
177
|
+
typeof item.message === 'string',
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
rangeChange: (value: { startDate: string; endDate: string; isValid: boolean }) => {
|
|
182
|
+
return (
|
|
183
|
+
typeof value === 'object' &&
|
|
184
|
+
value !== null &&
|
|
185
|
+
typeof value.startDate === 'string' &&
|
|
186
|
+
typeof value.endDate === 'string' &&
|
|
187
|
+
typeof value.isValid === 'boolean'
|
|
188
|
+
);
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export type DateRangePickerPropTypes = ExtractPropTypes<typeof dateRangePickerPropTypes>;
|
|
193
|
+
export type DateRangePickerEmitTypes = typeof dateRangePickerEmitTypes;
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<Menu
|
|
4
|
+
v-model:shown="datePopperState"
|
|
5
|
+
aria-id="date-range-picker-wrapper"
|
|
6
|
+
distance="4"
|
|
7
|
+
:placement="finalPlacement"
|
|
8
|
+
:triggers="[]"
|
|
9
|
+
:popper-hide-triggers="[]"
|
|
10
|
+
:auto-hide="false"
|
|
11
|
+
:disabled="isDateRangePickerPopperDisabled"
|
|
12
|
+
:container="`#${props.id}`"
|
|
13
|
+
:reference="activeInputRef"
|
|
14
|
+
:strategy="
|
|
15
|
+
props.popperStrategy === 'fixed' || props.popperStrategy === 'absolute' ? props.popperStrategy : 'absolute'
|
|
16
|
+
"
|
|
17
|
+
:delay="0"
|
|
18
|
+
:auto-placement="!isUsingCustomSlot"
|
|
19
|
+
:style="{
|
|
20
|
+
width: props.width,
|
|
21
|
+
}"
|
|
22
|
+
>
|
|
23
|
+
<div :id="props.id" class="spr-grid spr-gap-size-spacing-4xs">
|
|
24
|
+
<label v-if="props.label" :for="props.id" :class="dateRangePickerClasses.labelClasses">
|
|
25
|
+
{{ props.label }}
|
|
26
|
+
</label>
|
|
27
|
+
|
|
28
|
+
<!-- Date Range Input Container -->
|
|
29
|
+
<div class="spr-flex spr-items-center spr-gap-2 spr-w-full">
|
|
30
|
+
<slot :handle-click="handleCustomComponentClick">
|
|
31
|
+
<!-- fallback: original input fields -->
|
|
32
|
+
<!-- Start Date Input -->
|
|
33
|
+
<div ref="startDateContainerRef" :class="['spr-flex-1', dateRangePickerClasses.dateRangePickerBaseInputClasses]" @click.stop="handleStartDateClick" >
|
|
34
|
+
<div class="spr-flex spr-h-full spr-items-center spr-gap-1.5">
|
|
35
|
+
<input
|
|
36
|
+
:id="`${props.id}-start-month`"
|
|
37
|
+
ref="startMonthInputRef"
|
|
38
|
+
v-model="startMonthInput"
|
|
39
|
+
:class="['spr-w-[38px] spr-min-w-[38px] spr-uppercase', dateRangePickerClasses.dateRangePickerInputClasses]"
|
|
40
|
+
type="text"
|
|
41
|
+
placeholder="MMM"
|
|
42
|
+
maxlength="3"
|
|
43
|
+
:disabled="props.disabled"
|
|
44
|
+
:readonly="props.readonly"
|
|
45
|
+
@input="handleStartMonthInput"
|
|
46
|
+
@keyup="handleStartMonthInput"
|
|
47
|
+
@keydown="handleBackspace('start-month', $event)"
|
|
48
|
+
/>
|
|
49
|
+
<span class="spr-text-color-strong spr-font-size-200 spr-text-color-weak">/</span>
|
|
50
|
+
<input
|
|
51
|
+
:id="`${props.id}-start-date`"
|
|
52
|
+
ref="startDateInputRef"
|
|
53
|
+
v-model="startDateInput"
|
|
54
|
+
:class="['spr-w-[24px] spr-min-w-[24px] spr-text-center', dateRangePickerClasses.dateRangePickerInputClasses]"
|
|
55
|
+
type="text"
|
|
56
|
+
placeholder="DD"
|
|
57
|
+
maxlength="2"
|
|
58
|
+
:disabled="props.disabled"
|
|
59
|
+
:readonly="props.readonly"
|
|
60
|
+
@input="handleStartDateInput"
|
|
61
|
+
@keyup="handleStartDateInput"
|
|
62
|
+
@keydown="handleBackspace('start-date', $event)"
|
|
63
|
+
/>
|
|
64
|
+
<span class="spr-text-color-strong spr-font-size-200 spr-text-color-weak">/</span>
|
|
65
|
+
<input
|
|
66
|
+
:id="`${props.id}-start-year`"
|
|
67
|
+
ref="startYearInputRef"
|
|
68
|
+
v-model="startYearInput"
|
|
69
|
+
:class="['spr-w-[42px] spr-min-w-[42px]', dateRangePickerClasses.dateRangePickerInputClasses]"
|
|
70
|
+
type="text"
|
|
71
|
+
placeholder="YYYY"
|
|
72
|
+
maxlength="4"
|
|
73
|
+
:disabled="props.disabled"
|
|
74
|
+
:readonly="props.readonly"
|
|
75
|
+
@input="handleStartYearInput"
|
|
76
|
+
@keyup="handleStartYearInput"
|
|
77
|
+
@keydown="handleBackspace('start-year', $event)"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="spr-flex spr-items-center spr-justify-center">
|
|
81
|
+
<Icon class="spr-text-color-supporting spr-h-4 spr-w-4" icon="ph:calendar-blank" />
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
<!-- Separator -->
|
|
85
|
+
<span class="spr-text-color-strong spr-font-size-200 spr-text-color-weak">{{ props.separator }}</span>
|
|
86
|
+
<!-- End Date Input -->
|
|
87
|
+
<div ref="endDateContainerRef" :class="['spr-flex-1', dateRangePickerClasses.dateRangePickerBaseInputClasses]" @click.stop="handleEndDateClick">
|
|
88
|
+
<div class="spr-flex spr-h-full spr-items-center spr-gap-1.5">
|
|
89
|
+
<input
|
|
90
|
+
:id="`${props.id}-end-month`"
|
|
91
|
+
ref="endMonthInputRef"
|
|
92
|
+
v-model="endMonthInput"
|
|
93
|
+
:class="['spr-w-[38px] spr-min-w-[38px] spr-uppercase', dateRangePickerClasses.dateRangePickerInputClasses]"
|
|
94
|
+
type="text"
|
|
95
|
+
placeholder="MMM"
|
|
96
|
+
maxlength="3"
|
|
97
|
+
:disabled="props.disabled"
|
|
98
|
+
:readonly="props.readonly"
|
|
99
|
+
@input="handleEndMonthInput"
|
|
100
|
+
@keyup="handleEndMonthInput"
|
|
101
|
+
@keydown="handleBackspace('end-month', $event)"
|
|
102
|
+
/>
|
|
103
|
+
<span class="spr-text-color-strong spr-font-size-200 spr-text-color-weak">/</span>
|
|
104
|
+
<input
|
|
105
|
+
:id="`${props.id}-end-date`"
|
|
106
|
+
ref="endDateInputRef"
|
|
107
|
+
v-model="endDateInput"
|
|
108
|
+
:class="['spr-w-[24px] spr-min-w-[24px] spr-text-center', dateRangePickerClasses.dateRangePickerInputClasses]"
|
|
109
|
+
type="text"
|
|
110
|
+
placeholder="DD"
|
|
111
|
+
maxlength="2"
|
|
112
|
+
:disabled="props.disabled"
|
|
113
|
+
:readonly="props.readonly"
|
|
114
|
+
@input="handleEndDateInput"
|
|
115
|
+
@keyup="handleEndDateInput"
|
|
116
|
+
@keydown="handleBackspace('end-date', $event)"
|
|
117
|
+
/>
|
|
118
|
+
<span class="spr-text-color-strong spr-font-size-200 spr-text-color-weak">/</span>
|
|
119
|
+
<input
|
|
120
|
+
:id="`${props.id}-end-year`"
|
|
121
|
+
ref="endYearInputRef"
|
|
122
|
+
v-model="endYearInput"
|
|
123
|
+
:class="['spr-w-[42px] spr-min-w-[42px]', dateRangePickerClasses.dateRangePickerInputClasses]"
|
|
124
|
+
type="text"
|
|
125
|
+
placeholder="YYYY"
|
|
126
|
+
maxlength="4"
|
|
127
|
+
:disabled="props.disabled"
|
|
128
|
+
:readonly="props.readonly"
|
|
129
|
+
@input="handleEndYearInput"
|
|
130
|
+
@keyup="handleEndYearInput"
|
|
131
|
+
@keydown="handleBackspace('end-year', $event)"
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
<div class="spr-flex spr-items-center spr-justify-center">
|
|
135
|
+
<Icon class="spr-text-color-supporting spr-h-4 spr-w-4" icon="ph:calendar-blank" />
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</slot>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<template #popper>
|
|
143
|
+
<div ref="dateRangePickerRef">
|
|
144
|
+
<div
|
|
145
|
+
:class="[
|
|
146
|
+
'spr-flex spr-justify-between spr-gap-2 spr-px-4 spr-py-3',
|
|
147
|
+
'spr-border spr-border-x-0 spr-border-b spr-border-t-0 spr-border-solid spr-border-mushroom-200',
|
|
148
|
+
]"
|
|
149
|
+
>
|
|
150
|
+
<!-- Tabs -->
|
|
151
|
+
<div class="spr-flex spr-gap-1">
|
|
152
|
+
<spr-button
|
|
153
|
+
:class="getTabClasses('tab-months')"
|
|
154
|
+
variant="secondary"
|
|
155
|
+
size="small"
|
|
156
|
+
@click="handleTabClick('tab-months')"
|
|
157
|
+
>
|
|
158
|
+
{{ getMonthObject('monthValue', calendarTabPageData.selectedMonth)?.fullText }}
|
|
159
|
+
</spr-button>
|
|
160
|
+
<spr-button
|
|
161
|
+
:class="getTabClasses('tab-years')"
|
|
162
|
+
variant="secondary"
|
|
163
|
+
size="small"
|
|
164
|
+
@click="handleTabClick('tab-years')"
|
|
165
|
+
>
|
|
166
|
+
{{ calendarTabPageData.selectedYear }}
|
|
167
|
+
</spr-button>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<!-- Next & Previous Buttons -->
|
|
171
|
+
<div v-if="currentTab === 'tab-calendar'" class="spr-flex spr-gap-1">
|
|
172
|
+
<spr-button
|
|
173
|
+
class="spr-cursor-pointer"
|
|
174
|
+
variant="secondary"
|
|
175
|
+
size="small"
|
|
176
|
+
:disabled="calendarTabIsMinMonth"
|
|
177
|
+
@click="calendarTabPrevMonth"
|
|
178
|
+
>
|
|
179
|
+
<Icon icon="ph:caret-left" />
|
|
180
|
+
</spr-button>
|
|
181
|
+
<spr-button
|
|
182
|
+
class="spr-cursor-pointer"
|
|
183
|
+
variant="secondary"
|
|
184
|
+
size="small"
|
|
185
|
+
:disabled="calendarTabIsMaxMonth"
|
|
186
|
+
@click="calendarTabNextMonth"
|
|
187
|
+
>
|
|
188
|
+
<Icon icon="ph:caret-right" />
|
|
189
|
+
</spr-button>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div v-if="currentTab === 'tab-years'" class="spr-flex spr-gap-1">
|
|
193
|
+
<spr-button
|
|
194
|
+
class="spr-cursor-pointer"
|
|
195
|
+
variant="secondary"
|
|
196
|
+
size="small"
|
|
197
|
+
:disabled="yearTabIsPreviousButtonDisabled"
|
|
198
|
+
@click="yearTabGoToPreviousPage"
|
|
199
|
+
>
|
|
200
|
+
<Icon icon="ph:caret-left" />
|
|
201
|
+
</spr-button>
|
|
202
|
+
<spr-button
|
|
203
|
+
class="spr-cursor-pointer"
|
|
204
|
+
variant="secondary"
|
|
205
|
+
size="small"
|
|
206
|
+
:disabled="yearTabIsNextButtonDisabled"
|
|
207
|
+
@click="yearTabGoToNextPage"
|
|
208
|
+
>
|
|
209
|
+
<Icon icon="ph:caret-right" />
|
|
210
|
+
</spr-button>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
<div class="spr-px-4 spr-pb-4 spr-pt-2">
|
|
214
|
+
<!-- Calendar Tab -->
|
|
215
|
+
<div v-if="currentTab === 'tab-calendar'" class="spr-grid spr-grid-cols-7">
|
|
216
|
+
<div
|
|
217
|
+
v-for="(dayOfWeek, dayOfWeekIndex) in daysOfWeek"
|
|
218
|
+
:key="dayOfWeekIndex"
|
|
219
|
+
class="spr-py-1 spr-text-center spr-font-semibold"
|
|
220
|
+
>
|
|
221
|
+
{{ dayOfWeek.text }}
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<template v-for="day in calendarTabPageData.calendarDays" :key="day.date">
|
|
225
|
+
<div
|
|
226
|
+
v-if="minMaxYear.min <= day.date.year() && minMaxYear.max >= day.date.year()"
|
|
227
|
+
:class="[
|
|
228
|
+
dateRangePickerClasses.calendarTabItemsBaseClasses,
|
|
229
|
+
{
|
|
230
|
+
// Rest Days
|
|
231
|
+
'spr-background-color-disabled': calendarTabIsRestDay(day),
|
|
232
|
+
|
|
233
|
+
// Today Indicator - only apply green color if not selected
|
|
234
|
+
'spr-text-green-600': calendarTabIsTodayIndicator(day) && !calendarTabIsSelectedDate(day),
|
|
235
|
+
|
|
236
|
+
// Active Month Dates - only apply if not selected and not today
|
|
237
|
+
'spr-text-color-strong':
|
|
238
|
+
calendarTabIsActiveMonthDates(day) &&
|
|
239
|
+
!calendarTabIsSelectedDate(day) &&
|
|
240
|
+
!calendarTabIsTodayIndicator(day) &&
|
|
241
|
+
!calendarTabIsInRange(day),
|
|
242
|
+
|
|
243
|
+
// Inactive Month Dates (Past/Future)
|
|
244
|
+
'spr-text-color-disabled': calendarTabIsInactiveMonthDates(day),
|
|
245
|
+
|
|
246
|
+
// Selected Date (Start or End) - Use brand color scheme from date picker
|
|
247
|
+
'spr-background-color-brand-base active:spr-background-color-brand-pressed spr-text-color-inverted-strong !spr-text-white-50 active:spr-scale-95 spr-font-medium':
|
|
248
|
+
calendarTabIsSelectedDate(day),
|
|
249
|
+
|
|
250
|
+
// In Range (between start and end) - Light green background with brand outline, no border, using spr- prefix
|
|
251
|
+
'spr-bg-green-100 spr-cursor-pointer spr-outline spr-outline-1 spr-outline-offset-[-0.5px] spr-outline-kangkong-700':
|
|
252
|
+
calendarTabIsInRange(day),
|
|
253
|
+
|
|
254
|
+
// Unselected Date - Gray border, no hover effects
|
|
255
|
+
'spr-cursor-pointer spr-border spr-border-solid spr-border-gray-300':
|
|
256
|
+
calendarTabIsUnSelectedDate(day) && !calendarTabIsInRange(day),
|
|
257
|
+
|
|
258
|
+
// Disabled Dates
|
|
259
|
+
'spr-cursor-not-allowed spr-opacity-30': calendarTabIsDateIsDisabled(day),
|
|
260
|
+
},
|
|
261
|
+
]"
|
|
262
|
+
@click="!calendarTabIsDateIsDisabled(day) ? calendarTabHandleDateInput(day) : null"
|
|
263
|
+
>
|
|
264
|
+
<span>{{ day.date.date() }}</span>
|
|
265
|
+
<div
|
|
266
|
+
v-if="calendarTabIsTodayIndicator(day)"
|
|
267
|
+
class="spr-bg-green-600 spr-absolute spr-bottom-1 spr-m-auto spr-h-1 spr-w-1 spr-rounded-full"
|
|
268
|
+
></div>
|
|
269
|
+
</div>
|
|
270
|
+
<div v-else></div>
|
|
271
|
+
</template>
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
<!-- Months Tab -->
|
|
275
|
+
<div v-if="currentTab === 'tab-months'" class="spr-grid spr-grid-cols-4 spr-gap-2">
|
|
276
|
+
<div
|
|
277
|
+
v-for="(month, monthIndex) in monthsList"
|
|
278
|
+
:key="monthIndex"
|
|
279
|
+
:class="[
|
|
280
|
+
dateRangePickerClasses.monthsTabItemsBaseClasses,
|
|
281
|
+
{
|
|
282
|
+
'spr-text-color-brand-base': month.monthValue === currentDate.month(),
|
|
283
|
+
'spr-border-color-weak hover:spr-background-color-hover active:spr-background-color-pressed':
|
|
284
|
+
month.text.toLowerCase() !== startMonthInput.toLowerCase() && month.text.toLowerCase() !== endMonthInput.toLowerCase(),
|
|
285
|
+
'spr-border-color-brand-base spr-background-color-single-active':
|
|
286
|
+
month.text.toLowerCase() === startMonthInput.toLowerCase() || month.text.toLowerCase() === endMonthInput.toLowerCase(),
|
|
287
|
+
},
|
|
288
|
+
]"
|
|
289
|
+
@click="monthTabHandleSelectedMonth(month)"
|
|
290
|
+
>
|
|
291
|
+
<span>{{ month.text }}</span>
|
|
292
|
+
|
|
293
|
+
<div
|
|
294
|
+
v-if="month.monthValue === currentDate.month()"
|
|
295
|
+
class="spr-background-color-brand-base spr-absolute spr-bottom-2 spr-m-auto spr-h-1 spr-w-1 spr-rounded-full"
|
|
296
|
+
></div>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
<!-- Years Tab -->
|
|
301
|
+
<div v-if="currentTab === 'tab-years'" class="spr-grid spr-grid-cols-4 spr-gap-2">
|
|
302
|
+
<div
|
|
303
|
+
v-for="(year, index) in yearTabCurrentYearPage"
|
|
304
|
+
:key="index"
|
|
305
|
+
:class="[
|
|
306
|
+
dateRangePickerClasses.yearsTabItemsBaseClasses,
|
|
307
|
+
{
|
|
308
|
+
'spr-text-color-brand-base': year === currentDate.year(),
|
|
309
|
+
'spr-border-color-weak hover:spr-background-color-hover active:spr-background-color-pressed':
|
|
310
|
+
year !== Number(startYearInput) && year !== Number(endYearInput),
|
|
311
|
+
'spr-border-color-brand-base spr-background-color-single-active': year === Number(startYearInput) || year === Number(endYearInput),
|
|
312
|
+
},
|
|
313
|
+
]"
|
|
314
|
+
@click="yearTabHandleSelectedYear(String(year))"
|
|
315
|
+
>
|
|
316
|
+
<span>{{ year }}</span>
|
|
317
|
+
<div
|
|
318
|
+
v-if="year === currentDate.year()"
|
|
319
|
+
class="spr-background-color-brand-base spr-absolute spr-bottom-2 spr-m-auto spr-h-1 spr-w-1 spr-rounded-full"
|
|
320
|
+
></div>
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</template>
|
|
326
|
+
</Menu>
|
|
327
|
+
|
|
328
|
+
<div v-if="props.displayHelper" :class="dateRangePickerClasses.dateRangePickerInputHelperClasses">
|
|
329
|
+
<slot name="helperMessage">
|
|
330
|
+
<Icon v-if="props.helperIcon" :icon="props.helperIcon" width="20px" height="20px" />
|
|
331
|
+
<span>{{ props.helperText }}</span>
|
|
332
|
+
</slot>
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
</template>
|
|
336
|
+
|
|
337
|
+
<script lang="ts" setup>
|
|
338
|
+
import { Menu } from 'floating-vue';
|
|
339
|
+
import { Icon } from '@iconify/vue';
|
|
340
|
+
|
|
341
|
+
import 'floating-vue/dist/style.css';
|
|
342
|
+
|
|
343
|
+
import { dateRangePickerPropTypes, dateRangePickerEmitTypes } from './date-range-picker';
|
|
344
|
+
import { useDateRangePicker } from './use-date-range-picker';
|
|
345
|
+
|
|
346
|
+
import SprButton from '@/components/button/button.vue';
|
|
347
|
+
|
|
348
|
+
const props = defineProps(dateRangePickerPropTypes);
|
|
349
|
+
const emit = defineEmits(dateRangePickerEmitTypes);
|
|
350
|
+
|
|
351
|
+
const {
|
|
352
|
+
dateRangePickerClasses,
|
|
353
|
+
dateRangePickerRef,
|
|
354
|
+
startMonthInputRef,
|
|
355
|
+
startDateInputRef,
|
|
356
|
+
startYearInputRef,
|
|
357
|
+
endMonthInputRef,
|
|
358
|
+
endDateInputRef,
|
|
359
|
+
endYearInputRef,
|
|
360
|
+
startDateContainerRef,
|
|
361
|
+
endDateContainerRef,
|
|
362
|
+
activeInputRef,
|
|
363
|
+
datePopperState,
|
|
364
|
+
currentTab,
|
|
365
|
+
currentDate,
|
|
366
|
+
daysOfWeek,
|
|
367
|
+
monthsList,
|
|
368
|
+
startMonthInput,
|
|
369
|
+
startDateInput,
|
|
370
|
+
startYearInput,
|
|
371
|
+
endMonthInput,
|
|
372
|
+
endDateInput,
|
|
373
|
+
endYearInput,
|
|
374
|
+
calendarTabPageData,
|
|
375
|
+
calendarTabIsMinMonth,
|
|
376
|
+
calendarTabIsMaxMonth,
|
|
377
|
+
calendarTabIsRestDay,
|
|
378
|
+
calendarTabIsTodayIndicator,
|
|
379
|
+
calendarTabIsActiveMonthDates,
|
|
380
|
+
calendarTabIsInactiveMonthDates,
|
|
381
|
+
calendarTabIsSelectedDate,
|
|
382
|
+
calendarTabIsInRange,
|
|
383
|
+
calendarTabIsUnSelectedDate,
|
|
384
|
+
calendarTabIsDateIsDisabled,
|
|
385
|
+
calendarTabHandleDateInput,
|
|
386
|
+
getMonthObject,
|
|
387
|
+
getTabClasses,
|
|
388
|
+
isDateRangePickerPopperDisabled,
|
|
389
|
+
calendarTabPrevMonth,
|
|
390
|
+
calendarTabNextMonth,
|
|
391
|
+
monthTabHandleSelectedMonth,
|
|
392
|
+
yearTabCurrentYearPage,
|
|
393
|
+
yearTabGoToPreviousPage,
|
|
394
|
+
yearTabGoToNextPage,
|
|
395
|
+
yearTabIsPreviousButtonDisabled,
|
|
396
|
+
yearTabIsNextButtonDisabled,
|
|
397
|
+
yearTabHandleSelectedYear,
|
|
398
|
+
handleStartMonthInput,
|
|
399
|
+
handleStartDateInput,
|
|
400
|
+
handleStartYearInput,
|
|
401
|
+
handleEndMonthInput,
|
|
402
|
+
handleEndDateInput,
|
|
403
|
+
handleEndYearInput,
|
|
404
|
+
handleTabClick,
|
|
405
|
+
handleBackspace,
|
|
406
|
+
isUsingCustomSlot,
|
|
407
|
+
finalPlacement,
|
|
408
|
+
handleStartDateClick,
|
|
409
|
+
handleEndDateClick,
|
|
410
|
+
handleCustomComponentClick,
|
|
411
|
+
} = useDateRangePicker(props, emit);
|
|
412
|
+
</script>
|