|
1 | 1 | import {ComponentChildren, RenderableProps} from 'preact'; |
2 | 2 | import {HElementSignals, computed, effect} from '@zui/core'; |
3 | | -import {createDate, type DateLike, getDateTime} from '@zui/helpers'; |
| 3 | +import {createDate, type DateLike, formatDate, getDateTime} from '@zui/helpers'; |
4 | 4 | import type {CalendarCategory, CalendarEvent, CalendarProps, CalendarState} from '../types'; |
5 | 5 | import {CalendarHeader} from './calendar-header'; |
6 | 6 | import {CalendarMonthView} from './calendar-month-view'; |
@@ -97,10 +97,20 @@ export class Calendar<P extends CalendarProps = CalendarProps> extends HElementS |
97 | 97 | this.props.onClickEvent?.call(this, event, category!, mouseEvent); |
98 | 98 | } |
99 | 99 |
|
| 100 | + clickDay(dateStr: string, mouseEvent: MouseEvent) { |
| 101 | + const date = createDate(dateStr); |
| 102 | + this.props.onClickDay?.call(this, date, mouseEvent); |
| 103 | + } |
| 104 | + |
100 | 105 | getEvent(eventID: string) { |
101 | 106 | return this.events.find(event => String(event.id) === String(eventID)); |
102 | 107 | } |
103 | 108 |
|
| 109 | + getDayEvents(date: DateLike) { |
| 110 | + const dateStr = formatDate(date, 'yyyy-MM-dd'); |
| 111 | + return this.events.filter(event => formatDate(event.start, 'yyyy-MM-dd') === dateStr); |
| 112 | + } |
| 113 | + |
104 | 114 | getCategory(categoryID: string) { |
105 | 115 | return this.categories.find(category => String(category.id) === String(categoryID)); |
106 | 116 | } |
|
0 commit comments