|
2 | 2 | <div :class="calendarParentClass">
|
3 | 3 | <div ref="calendarWrapRef" :class="calendarWrapClass" role="grid">
|
4 | 4 | <div class="dp__calendar_header" role="row">
|
5 |
| - <div v-if="weekNumbers" class="dp__calendar_header_item" role="columnheader"> |
| 5 | + <div v-if="weekNumbers" class="dp__calendar_header_item" role="gridcell"> |
6 | 6 | {{ weekNumName }}
|
7 | 7 | </div>
|
8 | 8 | <div
|
9 | 9 | v-for="(dayVal, i) in weekDays"
|
10 | 10 | :key="i"
|
11 | 11 | class="dp__calendar_header_item"
|
12 |
| - role="columnheader" |
| 12 | + role="gridcell" |
13 | 13 | data-test="calendar-header"
|
14 | 14 | :aria-label="defaultedAriaLabels?.weekDay?.(i)"
|
15 | 15 | >
|
|
23 | 23 | <transition :name="transitionName" :css="!!transitions">
|
24 | 24 | <div v-if="showCalendar" class="dp__calendar" role="rowgroup" @mouseleave="isMouseDown = false">
|
25 | 25 | <div v-for="(week, weekInd) in calendarWeeks" :key="weekInd" class="dp__calendar_row" role="row">
|
26 |
| - <div v-if="weekNumbers" class="dp__calendar_item dp__week_num" role="cell"> |
| 26 | + <div v-if="weekNumbers" class="dp__calendar_item dp__week_num" role="gridcell"> |
27 | 27 | <div class="dp__cell_inner">
|
28 | 28 | {{ getWeekNum(week.days) }}
|
29 | 29 | </div>
|
|
258 | 258 |
|
259 | 259 | const showDay = computed(() => (day: ICalendarDay) => (props.hideOffsetDates ? day.current : true));
|
260 | 260 |
|
| 261 | + const positionTooltip = async (el: HTMLElement, day: ICalendarDay) => { |
| 262 | + const { width, height } = el.getBoundingClientRect(); |
| 263 | + showMakerTooltip.value = day.value; |
| 264 | + let defaultPosition: { left?: string; right?: string } = { left: `${width / 2}px` }; |
| 265 | + let transform = -50; |
| 266 | + await nextTick(); |
| 267 | +
|
| 268 | + if (activeTooltip.value[0]) { |
| 269 | + const { left, width: tpWidth } = activeTooltip.value[0].getBoundingClientRect(); |
| 270 | + if (left < 0) { |
| 271 | + defaultPosition = { left: `0` }; |
| 272 | + transform = 0; |
| 273 | + tpArrowStyle.value.left = `${width / 2}px`; |
| 274 | + } |
| 275 | +
|
| 276 | + if (window.innerWidth < left + tpWidth) { |
| 277 | + defaultPosition = { right: `0` }; |
| 278 | + transform = 0; |
| 279 | + tpArrowStyle.value.left = `${tpWidth - width / 2}px`; |
| 280 | + } |
| 281 | + } |
| 282 | +
|
| 283 | + markerTooltipStyle.value = { |
| 284 | + bottom: `${height}px`, |
| 285 | + ...defaultPosition, |
| 286 | + transform: `translateX(${transform}%)`, |
| 287 | + }; |
| 288 | + }; |
| 289 | +
|
261 | 290 | const handleTooltip = async (day: UnwrapRef<ICalendarDay>, weekInd: number, dayInd: number) => {
|
262 | 291 | const el = unrefElement(dayRefs.value[weekInd][dayInd]);
|
263 | 292 | if (el) {
|
264 | 293 | if (day.marker?.customPosition && day.marker?.tooltip?.length) {
|
265 | 294 | markerTooltipStyle.value = day.marker.customPosition(el);
|
266 | 295 | } else {
|
267 |
| - const { width, height } = el.getBoundingClientRect(); |
268 |
| - showMakerTooltip.value = day.value; |
269 |
| - let defaultPosition: { left?: string; right?: string } = { left: `${width / 2}px` }; |
270 |
| - let transform = -50; |
271 |
| - await nextTick(); |
272 |
| -
|
273 |
| - if (activeTooltip.value[0]) { |
274 |
| - const { left, width: tpWidth } = activeTooltip.value[0].getBoundingClientRect(); |
275 |
| - if (left < 0) { |
276 |
| - defaultPosition = { left: `0` }; |
277 |
| - transform = 0; |
278 |
| - tpArrowStyle.value.left = `${width / 2}px`; |
279 |
| - } |
280 |
| -
|
281 |
| - if (window.innerWidth < left + tpWidth) { |
282 |
| - defaultPosition = { right: `0` }; |
283 |
| - transform = 0; |
284 |
| - tpArrowStyle.value.left = `${tpWidth - width / 2}px`; |
285 |
| - } |
286 |
| - } |
287 |
| -
|
288 |
| - markerTooltipStyle.value = { |
289 |
| - bottom: `${height}px`, |
290 |
| - ...defaultPosition, |
291 |
| - transform: `translateX(${transform}%)`, |
292 |
| - }; |
| 296 | + await positionTooltip(el, day); |
293 | 297 | }
|
294 | 298 |
|
295 | 299 | emit('tooltip-open', day.marker);
|
|
0 commit comments