|
43 | 43 | :class="theme" |
44 | 44 | :style="menuPosition" |
45 | 45 | v-bind="{ |
46 | | - weekNumbers, |
47 | | - weekStart, |
48 | | - disableMonthYearSelect, |
49 | | - menuClassName, |
50 | | - calendarClassName, |
51 | | - yearRange, |
52 | | - range, |
| 46 | + ...passCommonProps($props), |
53 | 47 | multiCalendars: multiCalendarDefault, |
54 | | - multiCalendarsSolo, |
55 | | - calendarCellClassName, |
56 | | - enableTimePicker, |
57 | | - is24, |
58 | | - hoursIncrement, |
59 | | - minutesIncrement, |
60 | | - hoursGridIncrement, |
61 | | - minutesGridIncrement, |
62 | | - minDate, |
63 | | - maxDate, |
64 | | - autoApply, |
65 | | - selectText, |
66 | | - cancelText, |
67 | 48 | previewFormat: previewFormatDefault, |
68 | | - locale, |
69 | | - weekNumName, |
70 | | - disabledDates, |
71 | 49 | filters: defaultFilters, |
72 | | - minTime, |
73 | | - maxTime, |
74 | | - inline, |
75 | 50 | openOnTop, |
76 | | - monthPicker, |
77 | | - timePicker, |
78 | | - monthNameFormat, |
79 | | - startDate, |
80 | 51 | startTime: defaultStartTime, |
81 | | - monthYearComponent, |
82 | | - timePickerComponent, |
83 | | - actionRowComponent, |
84 | | - customProps, |
85 | | - hideOffsetDates, |
86 | | - autoRange, |
87 | | - noToday, |
88 | | - noHoursOverlay, |
89 | | - noMinutesOverlay, |
90 | | - disabledWeekDays, |
91 | | - allowedDates, |
92 | | - showNowButton, |
93 | | - nowButtonLabel, |
94 | | - monthChangeOnScroll, |
95 | | - markers, |
96 | | - uid, |
97 | | - modeHeight, |
98 | | - enableSeconds, |
99 | | - secondsIncrement, |
100 | | - secondsGridIncrement, |
101 | | - noSecondsOverlay, |
102 | | - escClose, |
103 | | - spaceConfirm, |
104 | | - monthChangeOnArrows, |
105 | | - textInput, |
106 | | - disabled, |
107 | | - readonly, |
108 | | - multiDates, |
109 | | - presetRanges, |
110 | | - flow, |
111 | | - preventMinMaxNavigation, |
112 | | - minRange, |
113 | | - maxRange, |
114 | | - fixedStart, |
115 | | - fixedEnd, |
116 | | - multiDatesLimit, |
117 | | - reverseYears, |
118 | | - keepActionRow, |
119 | | - weekPicker, |
120 | 52 | }" |
121 | 53 | v-model:internalModelValue="internalModelValue" |
122 | 54 | @close-picker="closeMenu" |
|
136 | 68 | </template> |
137 | 69 |
|
138 | 70 | <script lang="ts" setup> |
139 | | - import { |
140 | | - computed, |
141 | | - DefineComponent, |
142 | | - onMounted, |
143 | | - onUnmounted, |
144 | | - PropType, |
145 | | - provide, |
146 | | - ref, |
147 | | - toRef, |
148 | | - useSlots, |
149 | | - watch, |
150 | | - } from 'vue'; |
| 71 | + import { computed, onMounted, onUnmounted, PropType, provide, ref, toRef, useSlots, watch } from 'vue'; |
151 | 72 | import { getHours, getMinutes, getSeconds, Locale } from 'date-fns'; |
152 | 73 |
|
153 | 74 | import DatepickerInput from './components/DatepickerInput.vue'; |
|
161 | 82 | ITextInputOptions, |
162 | 83 | ModelValue, |
163 | 84 | ITimeValue, |
164 | | - WeekStartNum, |
165 | | - WeekStartStr, |
166 | | - IMarker, |
167 | 85 | ITransition, |
168 | | - IDisableDates, |
169 | 86 | AltPosition, |
170 | | - PresetRange, |
171 | | - Flow, |
172 | 87 | } from './interfaces'; |
173 | 88 | import { getDefaultPattern, isValidTime } from './utils/date-utils'; |
174 | 89 | import { getDefaultTextInputOptions, getDefaultFilters, mergeDefaultTransitions } from './utils/util'; |
|
177 | 92 | import { isString } from './utils/type-guard'; |
178 | 93 | import { mapSlots } from './components/composition/slots'; |
179 | 94 | import { onClickOutside } from './directives/clickOutside'; |
| 95 | + import { CommonProps, passCommonProps } from './utils/props'; |
180 | 96 |
|
181 | 97 | const emit = defineEmits([ |
182 | 98 | 'update:modelValue', |
|
192 | 108 | 'updateMonthYear', |
193 | 109 | ]); |
194 | 110 | const props = defineProps({ |
195 | | - uid: { type: String as PropType<string>, default: null }, |
| 111 | + ...CommonProps, |
196 | 112 | name: { type: String as PropType<string>, default: null }, |
197 | | - is24: { type: Boolean as PropType<boolean>, default: true }, |
198 | | - enableTimePicker: { type: Boolean as PropType<boolean>, default: true }, |
199 | | - locale: { type: String as PropType<string>, default: 'en-US' }, |
200 | | - range: { type: Boolean as PropType<boolean>, default: false }, |
201 | 113 | multiCalendars: { type: [Boolean, Number, String] as PropType<boolean | number | string>, default: null }, |
202 | | - multiCalendarsSolo: { type: Boolean as PropType<boolean>, default: false }, |
203 | 114 | modelValue: { type: [String, Date, Array, Object] as PropType<ModelValue>, default: null }, |
204 | 115 | position: { type: String as PropType<OpenPosition>, default: 'center' }, |
205 | 116 | placeholder: { type: String as PropType<string>, default: null }, |
206 | | - weekNumbers: { type: Boolean as PropType<boolean>, default: false }, |
207 | 117 | dark: { type: Boolean as PropType<boolean>, default: false }, |
208 | | - hoursIncrement: { type: [String, Number] as PropType<string | number>, default: 1 }, |
209 | | - minutesIncrement: { type: [String, Number] as PropType<string | number>, default: 1 }, |
210 | | - secondsIncrement: { type: [String, Number] as PropType<string | number>, default: 1 }, |
211 | | - hoursGridIncrement: { type: [String, Number] as PropType<string | number>, default: 1 }, |
212 | | - minutesGridIncrement: { type: [String, Number] as PropType<string | number>, default: 5 }, |
213 | | - secondsGridIncrement: { type: [String, Number] as PropType<string | number>, default: 5 }, |
214 | | - minDate: { type: [Date, String] as PropType<Date | string>, default: null }, |
215 | | - maxDate: { type: [Date, String] as PropType<Date | string>, default: null }, |
216 | | - minTime: { type: Object as PropType<ITimeValue>, default: null }, |
217 | | - maxTime: { type: Object as PropType<ITimeValue>, default: null }, |
218 | | - weekStart: { type: [String, Number] as PropType<WeekStartNum | WeekStartStr>, default: 1 }, |
219 | | - disabled: { type: Boolean as PropType<boolean>, default: false }, |
220 | | - readonly: { type: Boolean as PropType<boolean>, default: false }, |
221 | 118 | required: { type: Boolean as PropType<boolean>, default: false }, |
222 | | - monthNameFormat: { type: String as PropType<'long' | 'short'>, default: 'short' }, |
223 | | - weekNumName: { type: String as PropType<string>, default: 'W' }, |
224 | 119 | format: { |
225 | 120 | type: [String, Function] as PropType<IFormat>, |
226 | 121 | default: () => null, |
|
230 | 125 | default: () => null, |
231 | 126 | }, |
232 | 127 | inputClassName: { type: String as PropType<string>, default: null }, |
233 | | - menuClassName: { type: String as PropType<string>, default: null }, |
234 | | - calendarClassName: { type: String as PropType<string>, default: null }, |
235 | | - calendarCellClassName: { type: String as PropType<string>, default: null }, |
236 | 128 | hideInputIcon: { type: Boolean as PropType<boolean>, default: false }, |
237 | 129 | state: { type: Boolean as PropType<boolean>, default: null }, |
238 | 130 | clearable: { type: Boolean as PropType<boolean>, default: true }, |
239 | 131 | closeOnScroll: { type: Boolean as PropType<boolean>, default: false }, |
240 | | - autoApply: { type: Boolean as PropType<boolean>, default: false }, |
241 | 132 | filters: { type: Object as PropType<IDateFilter>, default: () => ({}) }, |
242 | | - disableMonthYearSelect: { type: Boolean as PropType<boolean>, default: false }, |
243 | | - yearRange: { type: Array as PropType<number[]>, default: () => [1900, 2100] }, |
244 | | - disabledDates: { type: [Array, Function] as PropType<Date[] | string[] | IDisableDates>, default: () => [] }, |
245 | | - disabledWeekDays: { type: Array as PropType<string[] | number[]>, default: () => [] }, |
246 | | - inline: { type: Boolean as PropType<boolean>, default: false }, |
247 | 133 | inlineWithInput: { type: Boolean as PropType<boolean>, default: false }, |
248 | | - selectText: { type: String as PropType<string>, default: 'Select' }, |
249 | | - cancelText: { type: String as PropType<string>, default: 'Cancel' }, |
250 | 134 | autoPosition: { type: Boolean as PropType<boolean>, default: true }, |
251 | | - monthPicker: { type: Boolean as PropType<boolean>, default: false }, |
252 | | - timePicker: { type: Boolean as PropType<boolean>, default: false }, |
253 | 135 | closeOnAutoApply: { type: Boolean as PropType<boolean>, default: true }, |
254 | | - textInput: { type: Boolean as PropType<boolean>, default: false }, |
255 | 136 | textInputOptions: { type: Object as PropType<ITextInputOptions>, default: () => ({}) }, |
256 | 137 | teleport: { type: String as PropType<string>, default: 'body' }, |
257 | | - startDate: { type: [Date, String] as PropType<string | Date>, default: null }, |
258 | | - startTime: { type: [Object, Array] as PropType<ITimeValue | ITimeValue[]>, default: null }, |
259 | | - monthYearComponent: { type: Object as PropType<DefineComponent>, default: null }, |
260 | | - timePickerComponent: { type: Object as PropType<DefineComponent>, default: null }, |
261 | | - actionRowComponent: { type: Object as PropType<DefineComponent>, default: null }, |
262 | | - customProps: { type: Object as PropType<Record<string, unknown>>, default: null }, |
263 | | - hideOffsetDates: { type: Boolean as PropType<boolean>, default: false }, |
264 | | - autoRange: { type: [Number, String] as PropType<number | string>, default: null }, |
265 | | - noToday: { type: Boolean as PropType<boolean>, default: false }, |
266 | | - noHoursOverlay: { type: Boolean as PropType<boolean>, default: false }, |
267 | | - noMinutesOverlay: { type: Boolean as PropType<boolean>, default: false }, |
268 | | - noSecondsOverlay: { type: Boolean as PropType<boolean>, default: false }, |
269 | 138 | altPosition: { type: [Boolean, Function] as PropType<AltPosition>, default: false }, |
270 | | - allowedDates: { type: Array as PropType<string[] | Date[]>, default: () => [] }, |
271 | | - showNowButton: { type: Boolean as PropType<boolean>, default: false }, |
272 | | - nowButtonLabel: { type: String as PropType<string>, default: 'Now' }, |
273 | 139 | partialRange: { type: Boolean as PropType<boolean>, default: true }, |
274 | | - monthChangeOnScroll: { type: [Boolean, String] as PropType<boolean | 'inverse'>, default: true }, |
275 | | - markers: { type: Array as PropType<IMarker[]>, default: () => [] }, |
276 | 140 | transitions: { type: Boolean as PropType<boolean | ITransition>, default: true }, |
277 | | - modeHeight: { type: [Number, String] as PropType<number | string>, default: 255 }, |
278 | | - enableSeconds: { type: Boolean as PropType<boolean>, default: false }, |
279 | 141 | openMenuOnFocus: { type: Boolean as PropType<boolean>, default: true }, |
280 | | - escClose: { type: Boolean as PropType<boolean>, default: true }, |
281 | | - spaceConfirm: { type: Boolean as PropType<boolean>, default: true }, |
282 | | - monthChangeOnArrows: { type: Boolean as PropType<boolean>, default: true }, |
283 | 142 | formatLocale: { type: Object as PropType<Locale>, default: null }, |
284 | 143 | autocomplete: { type: String as PropType<string>, default: null }, |
285 | | - multiDates: { type: Boolean as PropType<boolean>, default: false }, |
286 | | - presetRanges: { type: Array as PropType<PresetRange[]>, default: () => [] }, |
287 | | - flow: { type: Array as PropType<Flow>, default: () => [] }, |
288 | | - preventMinMaxNavigation: { type: Boolean as PropType<boolean>, default: false }, |
289 | | - minRange: { type: [Number, String] as PropType<number | string>, default: null }, |
290 | | - maxRange: { type: [Number, String] as PropType<number | string>, default: null }, |
291 | | - fixedStart: { type: Boolean as PropType<boolean>, default: false }, |
292 | | - fixedEnd: { type: Boolean as PropType<boolean>, default: false }, |
293 | 144 | utc: { type: Boolean as PropType<boolean>, default: false }, |
294 | | - multiDatesLimit: { type: [Number, String] as PropType<number | string>, default: null }, |
295 | | - reverseYears: { type: Boolean as PropType<boolean>, default: false }, |
296 | | - keepActionRow: { type: Boolean as PropType<boolean>, default: false }, |
297 | | - weekPicker: { type: Boolean as PropType<boolean>, default: false }, |
298 | 145 | }); |
299 | 146 | const slots = useSlots(); |
300 | 147 | const isOpen = ref(false); |
|
0 commit comments