|
15 | 15 | > |
16 | 16 | <div :class="disabledReadonlyOverlay" v-if="(disabled || readonly) && inline"></div> |
17 | 17 | <div :class="arrowClass" v-if="!inline"></div> |
18 | | - <div class="dp__instance_calendar" ref="calendarWrapperRef" role="document"> |
19 | | - <div :class="menuCalendarClassWrapper"> |
20 | | - <div v-for="instance in calendarAmm" :key="instance" :class="calendarInstanceClassWrapper"> |
| 18 | + <div :class="presetRanges.length ? 'dp__menu_content_wrapper' : null"> |
| 19 | + <div class="dp__preset_ranges" v-if="presetRanges.length"> |
| 20 | + <div |
| 21 | + v-for="(preset, i) in presetRanges" |
| 22 | + :key="i" |
| 23 | + class="dp__preset_range" |
| 24 | + @click="presetDateRange(preset.range)" |
| 25 | + > |
| 26 | + {{ preset.label }} |
| 27 | + </div> |
| 28 | + </div> |
| 29 | + <div class="dp__instance_calendar" ref="calendarWrapperRef" role="document"> |
| 30 | + <div :class="menuCalendarClassWrapper"> |
| 31 | + <div v-for="instance in calendarAmm" :key="instance" :class="calendarInstanceClassWrapper"> |
| 32 | + <component |
| 33 | + :is="monthYearComponent ? monthYearComponent : MonthYearInput" |
| 34 | + v-if="!disableMonthYearSelect && !timePicker" |
| 35 | + v-bind="{ |
| 36 | + months, |
| 37 | + years, |
| 38 | + filters, |
| 39 | + monthPicker, |
| 40 | + month: month(instance), |
| 41 | + year: year(instance), |
| 42 | + customProps, |
| 43 | + multiCalendars, |
| 44 | + multiCalendarsSolo, |
| 45 | + instance, |
| 46 | + minDate, |
| 47 | + maxDate, |
| 48 | + }" |
| 49 | + @update:month="updateMonthYear(instance, $event, true)" |
| 50 | + @update:year="updateMonthYear(instance, $event, false)" |
| 51 | + @month-year-select="monthYearSelect" |
| 52 | + > |
| 53 | + <template v-for="(slot, i) in monthYearSlots" #[slot]="args" :key="i"> |
| 54 | + <slot :name="slot" v-bind="args" /> |
| 55 | + </template> |
| 56 | + </component> |
| 57 | + <Calendar |
| 58 | + v-bind="calendarProps" |
| 59 | + :instance="instance" |
| 60 | + :mapped-dates="mappedDates(instance)" |
| 61 | + :month="month(instance)" |
| 62 | + :year="year(instance)" |
| 63 | + :month-year-component="monthYearComponent" |
| 64 | + @select-date="selectDate($event, !isFirstInstance(instance))" |
| 65 | + @set-hover-date="setHoverDate($event)" |
| 66 | + @handle-scroll="handleScroll($event, instance)" |
| 67 | + > |
| 68 | + <template v-for="(slot, i) in calendarSlots" #[slot]="args" :key="i"> |
| 69 | + <slot :name="slot" v-bind="{ ...args }" /> |
| 70 | + </template> |
| 71 | + </Calendar> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + <div> |
21 | 75 | <component |
22 | | - :is="monthYearComponent ? monthYearComponent : MonthYearInput" |
23 | | - v-if="!disableMonthYearSelect && !timePicker" |
| 76 | + v-if="enableTimePicker && !monthPicker" |
| 77 | + :is="timePickerComponent ? timePickerComponent : TimePickerCmp" |
| 78 | + ref="timePickerRef" |
24 | 79 | v-bind="{ |
25 | | - months, |
26 | | - years, |
| 80 | + is24, |
| 81 | + hoursIncrement, |
| 82 | + minutesIncrement, |
| 83 | + hoursGridIncrement, |
| 84 | + secondsIncrement, |
| 85 | + minutesGridIncrement, |
| 86 | + secondsGridIncrement, |
| 87 | + noHoursOverlay, |
| 88 | + noMinutesOverlay, |
| 89 | + noSecondsOverlay, |
| 90 | + range, |
27 | 91 | filters, |
28 | | - monthPicker, |
29 | | - month: month(instance), |
30 | | - year: year(instance), |
| 92 | + timePicker, |
| 93 | + hours, |
| 94 | + minutes, |
| 95 | + seconds, |
31 | 96 | customProps, |
32 | | - multiCalendars, |
33 | | - multiCalendarsSolo, |
34 | | - instance, |
35 | | - minDate, |
36 | | - maxDate, |
| 97 | + enableSeconds, |
37 | 98 | }" |
38 | | - @update:month="updateMonthYear(instance, $event, true)" |
39 | | - @update:year="updateMonthYear(instance, $event, false)" |
40 | | - @month-year-select="monthYearSelect" |
| 99 | + @update:hours="updateTime($event)" |
| 100 | + @update:minutes="updateTime($event, false)" |
| 101 | + @update:seconds="updateTime($event, false, true)" |
41 | 102 | > |
42 | | - <template v-for="(slot, i) in monthYearSlots" #[slot]="args" :key="i"> |
| 103 | + <template v-for="(slot, i) in timePickerSlots" #[slot]="args" :key="i"> |
43 | 104 | <slot :name="slot" v-bind="args" /> |
44 | 105 | </template> |
45 | 106 | </component> |
46 | | - <Calendar |
47 | | - v-bind="calendarProps" |
48 | | - :instance="instance" |
49 | | - :mapped-dates="mappedDates(instance)" |
50 | | - :month="month(instance)" |
51 | | - :year="year(instance)" |
52 | | - :month-year-component="monthYearComponent" |
53 | | - @select-date="selectDate($event, !isFirstInstance(instance))" |
54 | | - @set-hover-date="setHoverDate($event)" |
55 | | - @handle-scroll="handleScroll($event, instance)" |
56 | | - > |
57 | | - <template v-for="(slot, i) in calendarSlots" #[slot]="args" :key="i"> |
58 | | - <slot :name="slot" v-bind="{ ...args }" /> |
59 | | - </template> |
60 | | - </Calendar> |
61 | 107 | </div> |
62 | 108 | </div> |
63 | | - <div> |
64 | | - <component |
65 | | - v-if="enableTimePicker && !monthPicker" |
66 | | - :is="timePickerComponent ? timePickerComponent : TimePickerCmp" |
67 | | - ref="timePickerRef" |
68 | | - v-bind="{ |
69 | | - is24, |
70 | | - hoursIncrement, |
71 | | - minutesIncrement, |
72 | | - hoursGridIncrement, |
73 | | - secondsIncrement, |
74 | | - minutesGridIncrement, |
75 | | - secondsGridIncrement, |
76 | | - noHoursOverlay, |
77 | | - noMinutesOverlay, |
78 | | - noSecondsOverlay, |
79 | | - range, |
80 | | - filters, |
81 | | - timePicker, |
82 | | - hours, |
83 | | - minutes, |
84 | | - seconds, |
85 | | - customProps, |
86 | | - enableSeconds, |
87 | | - }" |
88 | | - @update:hours="updateTime($event)" |
89 | | - @update:minutes="updateTime($event, false)" |
90 | | - @update:seconds="updateTime($event, false, true)" |
| 109 | + <div class="dp__now_wrap" v-if="showNowButton"> |
| 110 | + <slot name="now-button" v-if="$slots['now-button']" :selectCurrentDate="selectCurrentDate" /> |
| 111 | + <button |
| 112 | + v-if="!$slots['now-button']" |
| 113 | + type="button" |
| 114 | + role="button" |
| 115 | + class="dp__now_button" |
| 116 | + @click="selectCurrentDate" |
91 | 117 | > |
92 | | - <template v-for="(slot, i) in timePickerSlots" #[slot]="args" :key="i"> |
93 | | - <slot :name="slot" v-bind="args" /> |
94 | | - </template> |
95 | | - </component> |
| 118 | + {{ nowButtonLabel }} |
| 119 | + </button> |
96 | 120 | </div> |
97 | 121 | </div> |
98 | | - <div class="dp__now_wrap" v-if="showNowButton"> |
99 | | - <slot name="now-button" v-if="$slots['now-button']" :selectCurrentDate="selectCurrentDate" /> |
100 | | - <button |
101 | | - v-if="!$slots['now-button']" |
102 | | - type="button" |
103 | | - role="button" |
104 | | - class="dp__now_button" |
105 | | - @click="selectCurrentDate" |
106 | | - > |
107 | | - {{ nowButtonLabel }} |
108 | | - </button> |
109 | | - </div> |
110 | 122 | <component |
111 | 123 | v-if="!autoApply" |
112 | 124 | :is="actionRowComponent ? actionRowComponent : ActionRow" |
|
167 | 179 | IMarker, |
168 | 180 | InternalModuleValue, |
169 | 181 | ITimeValue, |
| 182 | + PresetRange, |
170 | 183 | WeekStartNum, |
171 | 184 | WeekStartStr, |
172 | 185 | } from '../interfaces'; |
|
251 | 264 | disabled: { type: Boolean as PropType<boolean>, default: false }, |
252 | 265 | readonly: { type: Boolean as PropType<boolean>, default: false }, |
253 | 266 | multiDates: { type: Boolean as PropType<boolean>, default: false }, |
| 267 | + presetRanges: { type: Array as PropType<PresetRange[]>, default: () => [] }, |
254 | 268 | }); |
255 | 269 | const slots = useSlots(); |
256 | 270 | const calendarWrapperRef = ref(null); |
|
307 | 321 | selectCurrentDate, |
308 | 322 | isHoverDateStartEnd, |
309 | 323 | isHoverDate, |
| 324 | + presetDateRange, |
310 | 325 | } = useCalendar(props, emit); |
311 | 326 |
|
312 | 327 | const calendarSlots = mapSlots(slots, 'calendar'); |
|
0 commit comments