UNPKG

5.97 kBTypeScriptView Raw
1import { OnChanges, EventEmitter, ChangeDetectorRef, OnInit, OnDestroy, TemplateRef } from '@angular/core';
2import { CalendarEvent, WeekDay, MonthView, MonthViewDay, ViewPeriod } from 'calendar-utils';
3import { Subject, Subscription } from 'rxjs';
4import { CalendarEventTimesChangedEvent } from '../common/calendar-event-times-changed-event.interface';
5import { CalendarUtils } from '../common/calendar-utils.provider';
6import { DateAdapter } from '../../date-adapters/date-adapter';
7import { PlacementArray } from 'positioning';
8export interface CalendarMonthViewBeforeRenderEvent {
9 header: WeekDay[];
10 body: MonthViewDay[];
11 period: ViewPeriod;
12}
13export interface CalendarMonthViewEventTimesChangedEvent<EventMetaType = any, DayMetaType = any> extends CalendarEventTimesChangedEvent<EventMetaType> {
14 day: MonthViewDay<DayMetaType>;
15}
16/**
17 * Shows all events on a given month. Example usage:
18 *
19 * ```typescript
20 * <mwl-calendar-month-view
21 * [viewDate]="viewDate"
22 * [events]="events">
23 * </mwl-calendar-month-view>
24 * ```
25 */
26export declare class CalendarMonthViewComponent implements OnChanges, OnInit, OnDestroy {
27 protected cdr: ChangeDetectorRef;
28 protected utils: CalendarUtils;
29 protected dateAdapter: DateAdapter;
30 /**
31 * The current view date
32 */
33 viewDate: Date;
34 /**
35 * An array of events to display on view.
36 * The schema is available here: https://github.com/mattlewis92/calendar-utils/blob/c51689985f59a271940e30bc4e2c4e1fee3fcb5c/src/calendarUtils.ts#L49-L63
37 */
38 events: CalendarEvent[];
39 /**
40 * An array of day indexes (0 = sunday, 1 = monday etc) that will be hidden on the view
41 */
42 excludeDays: number[];
43 /**
44 * Whether the events list for the day of the `viewDate` option is visible or not
45 */
46 activeDayIsOpen: boolean;
47 /**
48 * If set will be used to determine the day that should be open. If not set, the `viewDate` is used
49 */
50 activeDay: Date;
51 /**
52 * An observable that when emitted on will re-render the current view
53 */
54 refresh: Subject<any>;
55 /**
56 * The locale used to format dates
57 */
58 locale: string;
59 /**
60 * The placement of the event tooltip
61 */
62 tooltipPlacement: PlacementArray;
63 /**
64 * A custom template to use for the event tooltips
65 */
66 tooltipTemplate: TemplateRef<any>;
67 /**
68 * Whether to append tooltips to the body or next to the trigger element
69 */
70 tooltipAppendToBody: boolean;
71 /**
72 * The delay in milliseconds before the tooltip should be displayed. If not provided the tooltip
73 * will be displayed immediately.
74 */
75 tooltipDelay: number | null;
76 /**
77 * The start number of the week.
78 * If using the moment date adapter this option won't do anything and you'll need to set it globally like so:
79 * ```
80 * moment.updateLocale('en', {
81 * week: {
82 * dow: 1, // set start of week to monday instead
83 * doy: 0,
84 * },
85 * });
86 * ```
87 */
88 weekStartsOn: number;
89 /**
90 * A custom template to use to replace the header
91 */
92 headerTemplate: TemplateRef<any>;
93 /**
94 * A custom template to use to replace the day cell
95 */
96 cellTemplate: TemplateRef<any>;
97 /**
98 * A custom template to use for the slide down box of events for the active day
99 */
100 openDayEventsTemplate: TemplateRef<any>;
101 /**
102 * A custom template to use for event titles
103 */
104 eventTitleTemplate: TemplateRef<any>;
105 /**
106 * A custom template to use for event actions
107 */
108 eventActionsTemplate: TemplateRef<any>;
109 /**
110 * An array of day indexes (0 = sunday, 1 = monday etc) that indicate which days are weekends
111 */
112 weekendDays: number[];
113 /**
114 * An output that will be called before the view is rendered for the current month.
115 * If you add the `cssClass` property to a day in the body it will add that class to the cell element in the template
116 */
117 beforeViewRender: EventEmitter<CalendarMonthViewBeforeRenderEvent>;
118 /**
119 * Called when the day cell is clicked
120 */
121 dayClicked: EventEmitter<{
122 day: MonthViewDay<any>;
123 sourceEvent: any;
124 }>;
125 /**
126 * Called when the event title is clicked
127 */
128 eventClicked: EventEmitter<{
129 event: CalendarEvent<any>;
130 sourceEvent: any;
131 }>;
132 /**
133 * Called when a header week day is clicked. Returns ISO day number.
134 */
135 columnHeaderClicked: EventEmitter<{
136 isoDayNumber: number;
137 sourceEvent: any;
138 }>;
139 /**
140 * Called when an event is dragged and dropped
141 */
142 eventTimesChanged: EventEmitter<CalendarMonthViewEventTimesChangedEvent<any, any>>;
143 /**
144 * @hidden
145 */
146 columnHeaders: WeekDay[];
147 /**
148 * @hidden
149 */
150 view: MonthView;
151 /**
152 * @hidden
153 */
154 openRowIndex: number;
155 /**
156 * @hidden
157 */
158 openDay: MonthViewDay;
159 /**
160 * @hidden
161 */
162 refreshSubscription: Subscription;
163 /**
164 * @hidden
165 */
166 constructor(cdr: ChangeDetectorRef, utils: CalendarUtils, locale: string, dateAdapter: DateAdapter);
167 /**
168 * @hidden
169 */
170 trackByRowOffset: (index: number, offset: number) => string;
171 /**
172 * @hidden
173 */
174 trackByDate: (index: number, day: MonthViewDay<any>) => string;
175 /**
176 * @hidden
177 */
178 ngOnInit(): void;
179 /**
180 * @hidden
181 */
182 ngOnChanges(changes: any): void;
183 /**
184 * @hidden
185 */
186 ngOnDestroy(): void;
187 /**
188 * @hidden
189 */
190 toggleDayHighlight(event: CalendarEvent, isHighlighted: boolean): void;
191 /**
192 * @hidden
193 */
194 eventDropped(droppedOn: MonthViewDay, event: CalendarEvent, draggedFrom?: MonthViewDay): void;
195 protected refreshHeader(): void;
196 protected refreshBody(): void;
197 protected checkActiveDayIsOpen(): void;
198 protected refreshAll(): void;
199 protected emitBeforeViewRender(): void;
200}