@tlmgo/tui-calendar 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -183
- package/dist/toastui-calendar.css +1117 -1117
- package/dist/toastui-calendar.ie11.js +1074 -1074
- package/dist/toastui-calendar.ie11.min.js +1 -1
- package/dist/toastui-calendar.js +1074 -1074
- package/dist/toastui-calendar.min.css +1 -1
- package/dist/toastui-calendar.min.js +1 -1
- package/dist/toastui-calendar.mjs +1 -1
- package/package.json +108 -108
- package/types/factory/calendar.d.ts +14 -14
- package/types/factory/calendarCore.d.ts +504 -504
- package/types/factory/day.d.ts +7 -7
- package/types/factory/month.d.ts +11 -11
- package/types/factory/week.d.ts +7 -7
- package/types/index.d.ts +11 -11
- package/types/time/date.d.ts +206 -206
- package/types/types/eventBus.d.ts +40 -40
- package/types/types/events.d.ts +141 -141
- package/types/types/options.d.ts +82 -82
- package/types/types/template.d.ts +97 -97
- package/types/types/theme.d.ts +140 -140
|
@@ -1,504 +1,504 @@
|
|
|
1
|
-
import type { ComponentChild } from 'preact';
|
|
2
|
-
import type { DeepPartial } from 'ts-essentials';
|
|
3
|
-
import EventModel from "../model/eventModel";
|
|
4
|
-
import TZDate from "../time/date";
|
|
5
|
-
import type { EventBus } from "../utils/eventBus";
|
|
6
|
-
import type { ExternalEventTypes, InternalEventTypes, ScrollBehaviorOptions } from "../types/eventBus";
|
|
7
|
-
import type { DateType, EventObject } from "../types/events";
|
|
8
|
-
import type { CalendarColor, CalendarInfo, Options, ViewType } from "../types/options";
|
|
9
|
-
import type { CalendarState, CalendarStore, Dispatchers, InternalStoreAPI } from "../types/store";
|
|
10
|
-
import type { ThemeState, ThemeStore } from "../types/theme";
|
|
11
|
-
/**
|
|
12
|
-
* {@link https://nhn.github.io/tui.code-snippet/latest/CustomEvents CustomEvents} document at {@link https://github.com/nhn/tui.code-snippet tui-code-snippet}
|
|
13
|
-
* @typedef {CustomEvents} CustomEvents
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* Define Calendars to group events.
|
|
17
|
-
*
|
|
18
|
-
* @typedef {object} CalendarInfo
|
|
19
|
-
* @property {string} id - Calendar id.
|
|
20
|
-
* @property {string} name - Calendar name.
|
|
21
|
-
* @property {string} color - Text color of events.
|
|
22
|
-
* @property {string} borderColor - Left border color of events.
|
|
23
|
-
* @property {string} backgroundColor - Background color of events.
|
|
24
|
-
* @property {string} dragBackgroundColor - Background color of events during dragging.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Timezone options of the calendar instance.
|
|
28
|
-
*
|
|
29
|
-
* For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md#timezone|Timezone options} in guide.
|
|
30
|
-
*
|
|
31
|
-
* @typedef {object} TimezoneOptions
|
|
32
|
-
* @example
|
|
33
|
-
* const calendar = new Calendar('#container', {
|
|
34
|
-
* timezone: {
|
|
35
|
-
* // @property {string} zones[].timezoneName - Timezone name. it should be one of IANA timezone names.
|
|
36
|
-
* // @property {string} [zones[].displayLabel] - Display label of timezone.
|
|
37
|
-
* // @property {string} [zones[].tooltip] - Tooltip of the element of the display label.
|
|
38
|
-
* zones: [
|
|
39
|
-
* {
|
|
40
|
-
* timezoneName: 'Asia/Seoul',
|
|
41
|
-
* displayLabel: 'UTC+9:00',
|
|
42
|
-
* tooltip: 'Seoul'
|
|
43
|
-
* },
|
|
44
|
-
* {
|
|
45
|
-
* timezoneName: 'Europe/London',
|
|
46
|
-
* displayLabel: 'UTC+1:00',
|
|
47
|
-
* tooltip: 'BST'
|
|
48
|
-
* }
|
|
49
|
-
* ],
|
|
50
|
-
* // This function will be called for rendering components for each timezone.
|
|
51
|
-
* // You don't have to use it if you're able to `Intl.DateTimeFormat` API with `timeZone` option.
|
|
52
|
-
* // this function should return timezone offset from UTC.
|
|
53
|
-
* // for instance, using moment-timezone:
|
|
54
|
-
* customOffsetCalculator: (timezoneName, timestamp) => {
|
|
55
|
-
* return moment.tz(timezoneName).utcOffset(timestamp);
|
|
56
|
-
* }
|
|
57
|
-
* }
|
|
58
|
-
* });
|
|
59
|
-
* @property {Array.<object>} zones - Timezone data.
|
|
60
|
-
* @property {string} zones[].timezoneName - Timezone name. it should be one of IANA timezone names.
|
|
61
|
-
* @property {string} [zones[].displayLabel] - Display label of timezone.
|
|
62
|
-
* @property {string} [zones[].tooltip] - Tooltip of the element of the display label.
|
|
63
|
-
* @property {function} customOffsetCalculator - Custom offset calculator when you're not able to leverage `Intl.DateTimeFormat` API.
|
|
64
|
-
*/
|
|
65
|
-
/**
|
|
66
|
-
* Object to create/modify events.
|
|
67
|
-
* @typedef {object} EventObject
|
|
68
|
-
* @property {string} [id] - Event id.
|
|
69
|
-
* @property {string} [calendarId] - Calendar id.
|
|
70
|
-
* @property {string} [title] - Event title.
|
|
71
|
-
* @property {string} [body] - Body content of the event.
|
|
72
|
-
* @property {string} [isAllday] - Whether the event is all day or not.
|
|
73
|
-
* @property {string|number|Date|TZDate} [start] - Start time of the event.
|
|
74
|
-
* @property {string|number|Date|TZDate} [end] - End time of the event.
|
|
75
|
-
* @property {number} [goingDuration] - Travel time which is taken to go in minutes.
|
|
76
|
-
* @property {number} [comingDuration] - Travel time which is taken to come back in minutes.
|
|
77
|
-
* @property {string} [location] - Location of the event.
|
|
78
|
-
* @property {Array.<string>} [attendees] - Attendees of the event.
|
|
79
|
-
* @property {string} [category] - Category of the event. Available categories are 'milestone', 'task', 'time' and 'allday'.
|
|
80
|
-
* @property {string} [dueDateClass] - Classification of work events. (before work, before lunch, before work)
|
|
81
|
-
* @property {string} [recurrenceRule] - Recurrence rule of the event.
|
|
82
|
-
* @property {string} [state] - State of the event. Available states are 'Busy', 'Free'.
|
|
83
|
-
* @property {boolean} [isVisible] - Whether the event is visible or not.
|
|
84
|
-
* @property {boolean} [isPending] - Whether the event is pending or not.
|
|
85
|
-
* @property {boolean} [isFocused] - Whether the event is focused or not.
|
|
86
|
-
* @property {boolean} [isReadOnly] - Whether the event is read only or not.
|
|
87
|
-
* @property {boolean} [isPrivate] - Whether the event is private or not.
|
|
88
|
-
* @property {string} [color] - Text color of the event.
|
|
89
|
-
* @property {string} [backgroundColor] - Background color of the event.
|
|
90
|
-
* @property {string} [dragBackgroundColor] - Background color of the event during dragging.
|
|
91
|
-
* @property {string} [borderColor] - Left border color of the event.
|
|
92
|
-
* @property {object} [customStyle] - Custom style of the event. The key of CSS property should be camelCase (e.g. {'fontSize': '12px'})
|
|
93
|
-
* @property {*} [raw] - Raw data of the event. it's an arbitrary property for anything.
|
|
94
|
-
*/
|
|
95
|
-
/**
|
|
96
|
-
* CalendarCore class
|
|
97
|
-
*
|
|
98
|
-
* @class CalendarCore
|
|
99
|
-
* @mixes CustomEvents
|
|
100
|
-
* @param {string|Element} container - container element or selector.
|
|
101
|
-
* @param {object} options - calendar options. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/calendar.md|Calendar options} in guide.
|
|
102
|
-
* @param {string} [options.defaultView="week"] - Initial view type. Available values are: 'day', 'week', 'month'.
|
|
103
|
-
* @param {boolean} [options.useFormPopup=false] - Whether to use the default form popup when creating/modifying events.
|
|
104
|
-
* @param {boolean} [options.useDetailPopup=false] - Whether to use the default detail popup when clicking events.
|
|
105
|
-
* @param {boolean} [options.isReadOnly=false] - Whether the calendar is read-only.
|
|
106
|
-
* @param {boolean} [options.usageStatistics=true] - Whether to allow collect hostname and send the information to google analytics.
|
|
107
|
-
* For more information, check out the {@link https://github.com/nhn/tui.calendar/blob/main/apps/calendar/README.md#collect-statistics-on-the-use-of-open-source|documentation}.
|
|
108
|
-
* @param {function} [options.eventFilter] - A function that returns true if the event should be displayed. The default filter checks if the event's `isVisible` property is true.
|
|
109
|
-
* @param {object} [options.week] - Week option of the calendar instance.
|
|
110
|
-
* @param {number} [options.week.startDayOfWeek=0] - Start day of the week. Available values are 0 (Sunday) to 6 (Saturday).
|
|
111
|
-
* @param {Array.<string>} [options.week.dayNames] - Names of days of the week. Should be 7 items starting from Sunday to Saturday. If not specified, the default names are used.
|
|
112
|
-
* Default values are ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].
|
|
113
|
-
* @param {boolean} [options.week.workweek=false] - Whether to exclude Saturday and Sunday.
|
|
114
|
-
* @param {boolean} [options.week.showTimezoneCollapseButton=true] - Whether to show the timezone collapse button.
|
|
115
|
-
* @param {boolean} [options.week.timezonesCollapsed=false] - Whether to collapse the timezones.
|
|
116
|
-
* @param {number} [options.week.hourStart=0] - Start hour of the day. Available values are 0 to 24.
|
|
117
|
-
* @param {number} [options.week.hourEnd=24] - End hour of the day. Available values are 0 to 24. Must be greater than `hourStart`.
|
|
118
|
-
* @param {boolean} [options.week.narrowWeekend=false] - Whether to narrow down width of weekends to half.
|
|
119
|
-
* @param {boolean|Array.<string>} [options.week.eventView=true] - Determine which view to display events. Available values are 'allday' and 'time'. set to `false` to disable event view.
|
|
120
|
-
* @param {boolean|Array.<string>} [options.week.taskView=true] - Determine which view to display tasks. Available values are 'milestone' and 'task'. set to `false` to disable task view.
|
|
121
|
-
* @param {boolean|object} [options.week.collapseDuplicateEvents=false] - Whether to collapse duplicate events. If you want to filter duplicate events and choose the main event based on your requirements, set `getDuplicateEvents` and `getMainEvent`. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md#weekcollapseduplicateevents|Options} in guide.
|
|
122
|
-
* @param {object} options.month - Month option of the calendar instance.
|
|
123
|
-
* @param {number} [options.month.startDayOfWeek=0] - Start day of the week. Available values are 0 (Sunday) to 6 (Saturday).
|
|
124
|
-
* @param {Array.<string>} [options.month.dayNames] - Names of days of the week. Should be 7 items starting from Sunday to Saturday. If not specified, the default names are used.
|
|
125
|
-
* Default values are ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].
|
|
126
|
-
* @param {boolean} [options.month.workweek=false] - Whether to exclude Saturday and Sunday.
|
|
127
|
-
* @param {boolean} [options.month.narrowWeekend=false] - Whether to narrow down width of weekends to half.
|
|
128
|
-
* @param {number} [options.month.visibleWeeksCount=0] - Number of weeks to display. 0 means display all weeks.
|
|
129
|
-
* @param {Array.<CalendarInfo>} [options.calendars] - Calendars to group events.
|
|
130
|
-
* @param {boolean|object} [options.gridSelection=true] - Whether to enable grid selection. or it's option. it's enabled when the value is `true` and object and will be disabled when `isReadOnly` is true.
|
|
131
|
-
* @param {boolean} options.gridSelection.enableDbClick - Whether to enable double click to select area.
|
|
132
|
-
* @param {boolean} options.gridSelection.enableClick - Whether to enable click to select area.
|
|
133
|
-
* @param {TimezoneOptions} options.timezone - Timezone option of the calendar instance. For more information about timezone, check out the {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md|Options} in guide.
|
|
134
|
-
* @param {Theme} options.theme - Theme option of the calendar instance. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/theme.md|Theme} in guide.
|
|
135
|
-
* @param {TemplateConfig} options.template - Template option of the calendar instance. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/template.md|Template} in guide.
|
|
136
|
-
*/
|
|
137
|
-
export default abstract class CalendarCore implements EventBus<ExternalEventTypes & InternalEventTypes> {
|
|
138
|
-
protected container: Element | null;
|
|
139
|
-
/**
|
|
140
|
-
* start and end date of weekly, monthly
|
|
141
|
-
* @private
|
|
142
|
-
*/
|
|
143
|
-
protected renderRange: {
|
|
144
|
-
start: TZDate;
|
|
145
|
-
end: TZDate;
|
|
146
|
-
};
|
|
147
|
-
protected eventBus: EventBus<ExternalEventTypes & InternalEventTypes>;
|
|
148
|
-
protected theme: InternalStoreAPI<ThemeStore>;
|
|
149
|
-
protected store: InternalStoreAPI<CalendarStore>;
|
|
150
|
-
constructor(container: string | Element, options?: Options);
|
|
151
|
-
protected abstract getComponent(): ComponentChild;
|
|
152
|
-
protected getStoreState(): CalendarState;
|
|
153
|
-
protected getStoreState<Group extends keyof CalendarState>(group: Group): CalendarState[Group];
|
|
154
|
-
protected getStoreDispatchers(): Dispatchers;
|
|
155
|
-
protected getStoreDispatchers<Group extends keyof Dispatchers>(group: Group): Dispatchers[Group];
|
|
156
|
-
/**
|
|
157
|
-
* Destroys the instance.
|
|
158
|
-
*/
|
|
159
|
-
destroy(): void;
|
|
160
|
-
private calculateMonthRenderDate;
|
|
161
|
-
private calculateWeekRenderDate;
|
|
162
|
-
private calculateDayRenderDate;
|
|
163
|
-
/**
|
|
164
|
-
* Move the rendered date to the next/prev range.
|
|
165
|
-
*
|
|
166
|
-
* The range of movement differs depending on the current view, Basically:
|
|
167
|
-
* - In month view, it moves to the next/prev month.
|
|
168
|
-
* - In week view, it moves to the next/prev week.
|
|
169
|
-
* - In day view, it moves to the next/prev day.
|
|
170
|
-
*
|
|
171
|
-
* Also, the range depends on the options like how many visible weeks/months should be rendered.
|
|
172
|
-
*
|
|
173
|
-
* @param {number} offset The offset to move by.
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* // Move to the next month in month view.
|
|
177
|
-
* calendar.move(1);
|
|
178
|
-
*
|
|
179
|
-
* // Move to the next year in month view.
|
|
180
|
-
* calendar.move(12);
|
|
181
|
-
*
|
|
182
|
-
* // Move to yesterday in day view.
|
|
183
|
-
* calendar.move(-1);
|
|
184
|
-
*/
|
|
185
|
-
move(offset: number): void;
|
|
186
|
-
/**********
|
|
187
|
-
* CRUD Methods
|
|
188
|
-
**********/
|
|
189
|
-
/**
|
|
190
|
-
* Create events and render calendar.
|
|
191
|
-
* @param {Array.<EventObject>} events - list of {@link EventObject}
|
|
192
|
-
* @example
|
|
193
|
-
* calendar.createEvents([
|
|
194
|
-
* {
|
|
195
|
-
* id: '1',
|
|
196
|
-
* calendarId: '1',
|
|
197
|
-
* title: 'my event',
|
|
198
|
-
* category: 'time',
|
|
199
|
-
* dueDateClass: '',
|
|
200
|
-
* start: '2018-01-18T22:30:00+09:00',
|
|
201
|
-
* end: '2018-01-19T02:30:00+09:00',
|
|
202
|
-
* },
|
|
203
|
-
* {
|
|
204
|
-
* id: '2',
|
|
205
|
-
* calendarId: '1',
|
|
206
|
-
* title: 'second event',
|
|
207
|
-
* category: 'time',
|
|
208
|
-
* dueDateClass: '',
|
|
209
|
-
* start: '2018-01-18T17:30:00+09:00',
|
|
210
|
-
* end: '2018-01-19T17:31:00+09:00',
|
|
211
|
-
* },
|
|
212
|
-
* ]);
|
|
213
|
-
*/
|
|
214
|
-
createEvents(events: EventObject[]): void;
|
|
215
|
-
protected getEventModel(eventId: string, calendarId: string): EventModel | null;
|
|
216
|
-
/**
|
|
217
|
-
* Get an {@link EventObject} with event's id and calendar's id.
|
|
218
|
-
*
|
|
219
|
-
* @param {string} eventId - event's id
|
|
220
|
-
* @param {string} calendarId - calendar's id of the event
|
|
221
|
-
* @returns {EventObject|null} event. If the event can't be found, it returns null.
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* const event = calendar.getEvent(eventId, calendarId);
|
|
225
|
-
*
|
|
226
|
-
* console.log(event.title);
|
|
227
|
-
*/
|
|
228
|
-
getEvent(eventId: string, calendarId: string): import("../types/events").EventObjectWithDefaultValues | null;
|
|
229
|
-
/**
|
|
230
|
-
* Update an event.
|
|
231
|
-
*
|
|
232
|
-
* @param {string} eventId - ID of an event to update
|
|
233
|
-
* @param {string} calendarId - The calendarId of the event to update
|
|
234
|
-
* @param {EventObject} changes - The new {@link EventObject} data to apply to the event
|
|
235
|
-
*
|
|
236
|
-
* @example
|
|
237
|
-
* calendar.on('beforeUpdateEvent', function ({ event, changes }) {
|
|
238
|
-
* const { id, calendarId } = event;
|
|
239
|
-
*
|
|
240
|
-
* calendar.updateEvent(id, calendarId, changes);
|
|
241
|
-
* });
|
|
242
|
-
*/
|
|
243
|
-
updateEvent(eventId: string, calendarId: string, changes: EventObject): void;
|
|
244
|
-
/**
|
|
245
|
-
* Delete an event.
|
|
246
|
-
*
|
|
247
|
-
* @param {string} eventId - event's id to delete
|
|
248
|
-
* @param {string} calendarId - The CalendarId of the event to delete
|
|
249
|
-
*/
|
|
250
|
-
deleteEvent(eventId: string, calendarId: string): void;
|
|
251
|
-
/**********
|
|
252
|
-
* General Methods
|
|
253
|
-
**********/
|
|
254
|
-
/**
|
|
255
|
-
* Set events' visibility by calendar ID
|
|
256
|
-
*
|
|
257
|
-
* @param {string|Array.<string>} calendarId - The calendar id or ids to change visibility
|
|
258
|
-
* @param {boolean} isVisible - If set to true, show the events. If set to false, hide the events.
|
|
259
|
-
*/
|
|
260
|
-
setCalendarVisibility(calendarId: string | string[], isVisible: boolean): void;
|
|
261
|
-
/**
|
|
262
|
-
* Render the calendar.
|
|
263
|
-
*
|
|
264
|
-
* @example
|
|
265
|
-
* calendar.render();
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* // Re-render the calendar when resizing a window.
|
|
269
|
-
* window.addEventListener('resize', () => {
|
|
270
|
-
* calendar.render();
|
|
271
|
-
* });
|
|
272
|
-
*/
|
|
273
|
-
render(): this;
|
|
274
|
-
/**
|
|
275
|
-
* For SSR(Server Side Rendering), Return the HTML string of the whole calendar.
|
|
276
|
-
*
|
|
277
|
-
* @returns {string} HTML string
|
|
278
|
-
*/
|
|
279
|
-
renderToString(): string;
|
|
280
|
-
/**
|
|
281
|
-
* Delete all events and clear view
|
|
282
|
-
*
|
|
283
|
-
* @example
|
|
284
|
-
* calendar.clear();
|
|
285
|
-
*/
|
|
286
|
-
clear(): void;
|
|
287
|
-
/**
|
|
288
|
-
* Scroll to current time on today in case of daily, weekly view.
|
|
289
|
-
* Nothing happens in the monthly view.
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* function onNewEvents(events) {
|
|
293
|
-
* calendar.createEvents(events);
|
|
294
|
-
* calendar.scrollToNow('smooth');
|
|
295
|
-
* }
|
|
296
|
-
*/
|
|
297
|
-
scrollToNow(scrollBehavior?: ScrollBehaviorOptions): void;
|
|
298
|
-
private calculateRenderRange;
|
|
299
|
-
/**
|
|
300
|
-
* Move to today.
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* function onClickTodayBtn() {
|
|
304
|
-
* calendar.today();
|
|
305
|
-
* }
|
|
306
|
-
*/
|
|
307
|
-
today(): void;
|
|
308
|
-
/**
|
|
309
|
-
* Move to specific date.
|
|
310
|
-
*
|
|
311
|
-
* @param {Date|string|number|TZDate} date - The date to move. it should be eligible parameter to create a `Date` instance if `date` is string or number.
|
|
312
|
-
* @example
|
|
313
|
-
* calendar.on('clickDayName', (event) => {
|
|
314
|
-
* if (calendar.getViewName() === 'week') {
|
|
315
|
-
* const dateToMove = new Date(event.date);
|
|
316
|
-
*
|
|
317
|
-
* calendar.setDate(dateToMove);
|
|
318
|
-
* calendar.changeView('day');
|
|
319
|
-
* }
|
|
320
|
-
* });
|
|
321
|
-
*/
|
|
322
|
-
setDate(date: DateType): void;
|
|
323
|
-
/**
|
|
324
|
-
* Move the calendar forward to the next range.
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* function moveToNextOrPrevRange(offset) {
|
|
328
|
-
* if (offset === -1) {
|
|
329
|
-
* calendar.prev();
|
|
330
|
-
* } else if (offset === 1) {
|
|
331
|
-
* calendar.next();
|
|
332
|
-
* }
|
|
333
|
-
* }
|
|
334
|
-
*/
|
|
335
|
-
next(): void;
|
|
336
|
-
/**
|
|
337
|
-
* Move the calendar backward to the previous range.
|
|
338
|
-
*
|
|
339
|
-
* @example
|
|
340
|
-
* function moveToNextOrPrevRange(offset) {
|
|
341
|
-
* if (offset === -1) {
|
|
342
|
-
* calendar.prev();
|
|
343
|
-
* } else if (offset === 1) {
|
|
344
|
-
* calendar.next();
|
|
345
|
-
* }
|
|
346
|
-
* }
|
|
347
|
-
*/
|
|
348
|
-
prev(): void;
|
|
349
|
-
/**
|
|
350
|
-
* Change color values of events belong to a certain calendar.
|
|
351
|
-
*
|
|
352
|
-
* @param {string} calendarId - The calendar ID
|
|
353
|
-
* @param {object} colorOptions - The color values of the calendar
|
|
354
|
-
* @param {string} colorOptions.color - The text color of the events
|
|
355
|
-
* @param {string} colorOptions.borderColor - Left border color of events
|
|
356
|
-
* @param {string} colorOptions.backgroundColor - Background color of events
|
|
357
|
-
* @param {string} colorOptions.dragBackgroundColor - Background color of events during dragging
|
|
358
|
-
*
|
|
359
|
-
* @example
|
|
360
|
-
* calendar.setCalendarColor('1', {
|
|
361
|
-
* color: '#e8e8e8',
|
|
362
|
-
* backgroundColor: '#585858',
|
|
363
|
-
* borderColor: '#a1b56c',
|
|
364
|
-
* dragBackgroundColor: '#585858',
|
|
365
|
-
* });
|
|
366
|
-
* calendar.setCalendarColor('2', {
|
|
367
|
-
* color: '#282828',
|
|
368
|
-
* backgroundColor: '#dc9656',
|
|
369
|
-
* borderColor: '#a1b56c',
|
|
370
|
-
* dragBackgroundColor: '#dc9656',
|
|
371
|
-
* });
|
|
372
|
-
* calendar.setCalendarColor('3', {
|
|
373
|
-
* color: '#a16946',
|
|
374
|
-
* backgroundColor: '#ab4642',
|
|
375
|
-
* borderColor: '#a1b56c',
|
|
376
|
-
* dragBackgroundColor: '#ab4642',
|
|
377
|
-
* });
|
|
378
|
-
*/
|
|
379
|
-
setCalendarColor(calendarId: string, colorOptions: CalendarColor): void;
|
|
380
|
-
/**
|
|
381
|
-
* Change current view type.
|
|
382
|
-
*
|
|
383
|
-
* @param {string} viewName - The new view name to change to. Available values are 'month', 'week', 'day'.
|
|
384
|
-
*
|
|
385
|
-
* @example
|
|
386
|
-
* // change to daily view
|
|
387
|
-
* calendar.changeView('day');
|
|
388
|
-
*
|
|
389
|
-
* // change to weekly view
|
|
390
|
-
* calendar.changeView('week');
|
|
391
|
-
*
|
|
392
|
-
* // change to monthly view
|
|
393
|
-
* calendar.changeView('month');
|
|
394
|
-
*/
|
|
395
|
-
changeView(viewName: ViewType): void;
|
|
396
|
-
/**
|
|
397
|
-
* Get the DOM element of the event by event id and calendar id
|
|
398
|
-
*
|
|
399
|
-
* @param {string} eventId - ID of event
|
|
400
|
-
* @param {string} calendarId - calendarId of event
|
|
401
|
-
* @returns {HTMLElement} event element if found or null
|
|
402
|
-
*
|
|
403
|
-
* @example
|
|
404
|
-
* const element = calendar.getElement(eventId, calendarId);
|
|
405
|
-
*
|
|
406
|
-
* console.log(element);
|
|
407
|
-
*/
|
|
408
|
-
getElement(eventId: string, calendarId: string): Element | null;
|
|
409
|
-
/**
|
|
410
|
-
* Set the theme of the calendar.
|
|
411
|
-
*
|
|
412
|
-
* @param {Theme} theme - The theme object to apply. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/theme.md|Theme} in guide.
|
|
413
|
-
*
|
|
414
|
-
* @example
|
|
415
|
-
* calendar.setTheme({
|
|
416
|
-
* common: {
|
|
417
|
-
* gridSelection: {
|
|
418
|
-
* backgroundColor: '#333',
|
|
419
|
-
* },
|
|
420
|
-
* },
|
|
421
|
-
* week: {
|
|
422
|
-
* nowIndicatorLabel: {
|
|
423
|
-
* color: '#00FF00',
|
|
424
|
-
* },
|
|
425
|
-
* },
|
|
426
|
-
* month: {
|
|
427
|
-
* dayName: {
|
|
428
|
-
* borderLeft: '1px solid #e5e5e5',
|
|
429
|
-
* },
|
|
430
|
-
* },
|
|
431
|
-
* });
|
|
432
|
-
*/
|
|
433
|
-
setTheme(theme: DeepPartial<ThemeState>): void;
|
|
434
|
-
/**
|
|
435
|
-
* Get current options.
|
|
436
|
-
*
|
|
437
|
-
* @returns {Options} - The current options of the instance
|
|
438
|
-
*/
|
|
439
|
-
getOptions(): {
|
|
440
|
-
template: import("../types/template").Template;
|
|
441
|
-
theme: {
|
|
442
|
-
common: import("../types/theme").CommonTheme;
|
|
443
|
-
week: import("../types/theme").WeekTheme;
|
|
444
|
-
month: import("../types/theme").MonthTheme;
|
|
445
|
-
};
|
|
446
|
-
week: import("../types/options").WeekOptions;
|
|
447
|
-
month: import("../types/options").MonthOptions;
|
|
448
|
-
isReadOnly: boolean;
|
|
449
|
-
gridSelection: (boolean | import("../types/options").GridSelectionOptions) & import("../types/options").GridSelectionOptions;
|
|
450
|
-
defaultView: ViewType;
|
|
451
|
-
useFormPopup: boolean;
|
|
452
|
-
useDetailPopup: boolean;
|
|
453
|
-
usageStatistics: boolean;
|
|
454
|
-
eventFilter: (event: EventObject) => boolean;
|
|
455
|
-
timezone: import("../types/options").TimezoneOptions;
|
|
456
|
-
};
|
|
457
|
-
/**
|
|
458
|
-
* Set options of calendar. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md|Options} in guide.
|
|
459
|
-
*
|
|
460
|
-
* @param {Options} options - The options to set
|
|
461
|
-
*/
|
|
462
|
-
setOptions(options: Options): void;
|
|
463
|
-
/**
|
|
464
|
-
* Get current rendered date. (see {@link TZDate} for further information)
|
|
465
|
-
*
|
|
466
|
-
* @returns {TZDate}
|
|
467
|
-
*/
|
|
468
|
-
getDate(): TZDate;
|
|
469
|
-
/**
|
|
470
|
-
* Start time of rendered date range. (see {@link TZDate} for further information)
|
|
471
|
-
*
|
|
472
|
-
* @returns {TZDate}
|
|
473
|
-
*/
|
|
474
|
-
getDateRangeStart(): TZDate;
|
|
475
|
-
/**
|
|
476
|
-
* End time of rendered date range. (see {@link TZDate} for further information)
|
|
477
|
-
*
|
|
478
|
-
* @returns {TZDate}
|
|
479
|
-
*/
|
|
480
|
-
getDateRangeEnd(): TZDate;
|
|
481
|
-
/**
|
|
482
|
-
* Get current view name('day', 'week', 'month').
|
|
483
|
-
*
|
|
484
|
-
* @returns {string} current view name ('day', 'week', 'month')
|
|
485
|
-
*/
|
|
486
|
-
getViewName(): ViewType;
|
|
487
|
-
/**
|
|
488
|
-
* Set calendar list.
|
|
489
|
-
*
|
|
490
|
-
* @param {CalendarInfo[]} calendars - list of calendars
|
|
491
|
-
*/
|
|
492
|
-
setCalendars(calendars: CalendarInfo[]): void;
|
|
493
|
-
/**
|
|
494
|
-
* Open event form popup with predefined form values.
|
|
495
|
-
*
|
|
496
|
-
* @param {EventObject} event - The predefined {@link EventObject} data to show in form.
|
|
497
|
-
*/
|
|
498
|
-
openFormPopup(event: EventObject): void;
|
|
499
|
-
clearGridSelections(): void;
|
|
500
|
-
fire<EventName extends keyof ExternalEventTypes>(eventName: EventName, ...args: Parameters<ExternalEventTypes[EventName]>): EventBus<ExternalEventTypes>;
|
|
501
|
-
off<EventName extends keyof ExternalEventTypes>(eventName?: EventName, handler?: ExternalEventTypes[EventName]): EventBus<ExternalEventTypes>;
|
|
502
|
-
on<EventName extends keyof ExternalEventTypes>(eventName: EventName, handler: ExternalEventTypes[EventName]): EventBus<ExternalEventTypes>;
|
|
503
|
-
once<EventName extends keyof ExternalEventTypes>(eventName: EventName, handler: ExternalEventTypes[EventName]): EventBus<ExternalEventTypes>;
|
|
504
|
-
}
|
|
1
|
+
import type { ComponentChild } from 'preact';
|
|
2
|
+
import type { DeepPartial } from 'ts-essentials';
|
|
3
|
+
import EventModel from "../model/eventModel";
|
|
4
|
+
import TZDate from "../time/date";
|
|
5
|
+
import type { EventBus } from "../utils/eventBus";
|
|
6
|
+
import type { ExternalEventTypes, InternalEventTypes, ScrollBehaviorOptions } from "../types/eventBus";
|
|
7
|
+
import type { DateType, EventObject } from "../types/events";
|
|
8
|
+
import type { CalendarColor, CalendarInfo, Options, ViewType } from "../types/options";
|
|
9
|
+
import type { CalendarState, CalendarStore, Dispatchers, InternalStoreAPI } from "../types/store";
|
|
10
|
+
import type { ThemeState, ThemeStore } from "../types/theme";
|
|
11
|
+
/**
|
|
12
|
+
* {@link https://nhn.github.io/tui.code-snippet/latest/CustomEvents CustomEvents} document at {@link https://github.com/nhn/tui.code-snippet tui-code-snippet}
|
|
13
|
+
* @typedef {CustomEvents} CustomEvents
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Define Calendars to group events.
|
|
17
|
+
*
|
|
18
|
+
* @typedef {object} CalendarInfo
|
|
19
|
+
* @property {string} id - Calendar id.
|
|
20
|
+
* @property {string} name - Calendar name.
|
|
21
|
+
* @property {string} color - Text color of events.
|
|
22
|
+
* @property {string} borderColor - Left border color of events.
|
|
23
|
+
* @property {string} backgroundColor - Background color of events.
|
|
24
|
+
* @property {string} dragBackgroundColor - Background color of events during dragging.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Timezone options of the calendar instance.
|
|
28
|
+
*
|
|
29
|
+
* For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md#timezone|Timezone options} in guide.
|
|
30
|
+
*
|
|
31
|
+
* @typedef {object} TimezoneOptions
|
|
32
|
+
* @example
|
|
33
|
+
* const calendar = new Calendar('#container', {
|
|
34
|
+
* timezone: {
|
|
35
|
+
* // @property {string} zones[].timezoneName - Timezone name. it should be one of IANA timezone names.
|
|
36
|
+
* // @property {string} [zones[].displayLabel] - Display label of timezone.
|
|
37
|
+
* // @property {string} [zones[].tooltip] - Tooltip of the element of the display label.
|
|
38
|
+
* zones: [
|
|
39
|
+
* {
|
|
40
|
+
* timezoneName: 'Asia/Seoul',
|
|
41
|
+
* displayLabel: 'UTC+9:00',
|
|
42
|
+
* tooltip: 'Seoul'
|
|
43
|
+
* },
|
|
44
|
+
* {
|
|
45
|
+
* timezoneName: 'Europe/London',
|
|
46
|
+
* displayLabel: 'UTC+1:00',
|
|
47
|
+
* tooltip: 'BST'
|
|
48
|
+
* }
|
|
49
|
+
* ],
|
|
50
|
+
* // This function will be called for rendering components for each timezone.
|
|
51
|
+
* // You don't have to use it if you're able to `Intl.DateTimeFormat` API with `timeZone` option.
|
|
52
|
+
* // this function should return timezone offset from UTC.
|
|
53
|
+
* // for instance, using moment-timezone:
|
|
54
|
+
* customOffsetCalculator: (timezoneName, timestamp) => {
|
|
55
|
+
* return moment.tz(timezoneName).utcOffset(timestamp);
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
* @property {Array.<object>} zones - Timezone data.
|
|
60
|
+
* @property {string} zones[].timezoneName - Timezone name. it should be one of IANA timezone names.
|
|
61
|
+
* @property {string} [zones[].displayLabel] - Display label of timezone.
|
|
62
|
+
* @property {string} [zones[].tooltip] - Tooltip of the element of the display label.
|
|
63
|
+
* @property {function} customOffsetCalculator - Custom offset calculator when you're not able to leverage `Intl.DateTimeFormat` API.
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* Object to create/modify events.
|
|
67
|
+
* @typedef {object} EventObject
|
|
68
|
+
* @property {string} [id] - Event id.
|
|
69
|
+
* @property {string} [calendarId] - Calendar id.
|
|
70
|
+
* @property {string} [title] - Event title.
|
|
71
|
+
* @property {string} [body] - Body content of the event.
|
|
72
|
+
* @property {string} [isAllday] - Whether the event is all day or not.
|
|
73
|
+
* @property {string|number|Date|TZDate} [start] - Start time of the event.
|
|
74
|
+
* @property {string|number|Date|TZDate} [end] - End time of the event.
|
|
75
|
+
* @property {number} [goingDuration] - Travel time which is taken to go in minutes.
|
|
76
|
+
* @property {number} [comingDuration] - Travel time which is taken to come back in minutes.
|
|
77
|
+
* @property {string} [location] - Location of the event.
|
|
78
|
+
* @property {Array.<string>} [attendees] - Attendees of the event.
|
|
79
|
+
* @property {string} [category] - Category of the event. Available categories are 'milestone', 'task', 'time' and 'allday'.
|
|
80
|
+
* @property {string} [dueDateClass] - Classification of work events. (before work, before lunch, before work)
|
|
81
|
+
* @property {string} [recurrenceRule] - Recurrence rule of the event.
|
|
82
|
+
* @property {string} [state] - State of the event. Available states are 'Busy', 'Free'.
|
|
83
|
+
* @property {boolean} [isVisible] - Whether the event is visible or not.
|
|
84
|
+
* @property {boolean} [isPending] - Whether the event is pending or not.
|
|
85
|
+
* @property {boolean} [isFocused] - Whether the event is focused or not.
|
|
86
|
+
* @property {boolean} [isReadOnly] - Whether the event is read only or not.
|
|
87
|
+
* @property {boolean} [isPrivate] - Whether the event is private or not.
|
|
88
|
+
* @property {string} [color] - Text color of the event.
|
|
89
|
+
* @property {string} [backgroundColor] - Background color of the event.
|
|
90
|
+
* @property {string} [dragBackgroundColor] - Background color of the event during dragging.
|
|
91
|
+
* @property {string} [borderColor] - Left border color of the event.
|
|
92
|
+
* @property {object} [customStyle] - Custom style of the event. The key of CSS property should be camelCase (e.g. {'fontSize': '12px'})
|
|
93
|
+
* @property {*} [raw] - Raw data of the event. it's an arbitrary property for anything.
|
|
94
|
+
*/
|
|
95
|
+
/**
|
|
96
|
+
* CalendarCore class
|
|
97
|
+
*
|
|
98
|
+
* @class CalendarCore
|
|
99
|
+
* @mixes CustomEvents
|
|
100
|
+
* @param {string|Element} container - container element or selector.
|
|
101
|
+
* @param {object} options - calendar options. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/calendar.md|Calendar options} in guide.
|
|
102
|
+
* @param {string} [options.defaultView="week"] - Initial view type. Available values are: 'day', 'week', 'month'.
|
|
103
|
+
* @param {boolean} [options.useFormPopup=false] - Whether to use the default form popup when creating/modifying events.
|
|
104
|
+
* @param {boolean} [options.useDetailPopup=false] - Whether to use the default detail popup when clicking events.
|
|
105
|
+
* @param {boolean} [options.isReadOnly=false] - Whether the calendar is read-only.
|
|
106
|
+
* @param {boolean} [options.usageStatistics=true] - Whether to allow collect hostname and send the information to google analytics.
|
|
107
|
+
* For more information, check out the {@link https://github.com/nhn/tui.calendar/blob/main/apps/calendar/README.md#collect-statistics-on-the-use-of-open-source|documentation}.
|
|
108
|
+
* @param {function} [options.eventFilter] - A function that returns true if the event should be displayed. The default filter checks if the event's `isVisible` property is true.
|
|
109
|
+
* @param {object} [options.week] - Week option of the calendar instance.
|
|
110
|
+
* @param {number} [options.week.startDayOfWeek=0] - Start day of the week. Available values are 0 (Sunday) to 6 (Saturday).
|
|
111
|
+
* @param {Array.<string>} [options.week.dayNames] - Names of days of the week. Should be 7 items starting from Sunday to Saturday. If not specified, the default names are used.
|
|
112
|
+
* Default values are ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].
|
|
113
|
+
* @param {boolean} [options.week.workweek=false] - Whether to exclude Saturday and Sunday.
|
|
114
|
+
* @param {boolean} [options.week.showTimezoneCollapseButton=true] - Whether to show the timezone collapse button.
|
|
115
|
+
* @param {boolean} [options.week.timezonesCollapsed=false] - Whether to collapse the timezones.
|
|
116
|
+
* @param {number} [options.week.hourStart=0] - Start hour of the day. Available values are 0 to 24.
|
|
117
|
+
* @param {number} [options.week.hourEnd=24] - End hour of the day. Available values are 0 to 24. Must be greater than `hourStart`.
|
|
118
|
+
* @param {boolean} [options.week.narrowWeekend=false] - Whether to narrow down width of weekends to half.
|
|
119
|
+
* @param {boolean|Array.<string>} [options.week.eventView=true] - Determine which view to display events. Available values are 'allday' and 'time'. set to `false` to disable event view.
|
|
120
|
+
* @param {boolean|Array.<string>} [options.week.taskView=true] - Determine which view to display tasks. Available values are 'milestone' and 'task'. set to `false` to disable task view.
|
|
121
|
+
* @param {boolean|object} [options.week.collapseDuplicateEvents=false] - Whether to collapse duplicate events. If you want to filter duplicate events and choose the main event based on your requirements, set `getDuplicateEvents` and `getMainEvent`. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md#weekcollapseduplicateevents|Options} in guide.
|
|
122
|
+
* @param {object} options.month - Month option of the calendar instance.
|
|
123
|
+
* @param {number} [options.month.startDayOfWeek=0] - Start day of the week. Available values are 0 (Sunday) to 6 (Saturday).
|
|
124
|
+
* @param {Array.<string>} [options.month.dayNames] - Names of days of the week. Should be 7 items starting from Sunday to Saturday. If not specified, the default names are used.
|
|
125
|
+
* Default values are ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].
|
|
126
|
+
* @param {boolean} [options.month.workweek=false] - Whether to exclude Saturday and Sunday.
|
|
127
|
+
* @param {boolean} [options.month.narrowWeekend=false] - Whether to narrow down width of weekends to half.
|
|
128
|
+
* @param {number} [options.month.visibleWeeksCount=0] - Number of weeks to display. 0 means display all weeks.
|
|
129
|
+
* @param {Array.<CalendarInfo>} [options.calendars] - Calendars to group events.
|
|
130
|
+
* @param {boolean|object} [options.gridSelection=true] - Whether to enable grid selection. or it's option. it's enabled when the value is `true` and object and will be disabled when `isReadOnly` is true.
|
|
131
|
+
* @param {boolean} options.gridSelection.enableDbClick - Whether to enable double click to select area.
|
|
132
|
+
* @param {boolean} options.gridSelection.enableClick - Whether to enable click to select area.
|
|
133
|
+
* @param {TimezoneOptions} options.timezone - Timezone option of the calendar instance. For more information about timezone, check out the {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md|Options} in guide.
|
|
134
|
+
* @param {Theme} options.theme - Theme option of the calendar instance. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/theme.md|Theme} in guide.
|
|
135
|
+
* @param {TemplateConfig} options.template - Template option of the calendar instance. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/template.md|Template} in guide.
|
|
136
|
+
*/
|
|
137
|
+
export default abstract class CalendarCore implements EventBus<ExternalEventTypes & InternalEventTypes> {
|
|
138
|
+
protected container: Element | null;
|
|
139
|
+
/**
|
|
140
|
+
* start and end date of weekly, monthly
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
protected renderRange: {
|
|
144
|
+
start: TZDate;
|
|
145
|
+
end: TZDate;
|
|
146
|
+
};
|
|
147
|
+
protected eventBus: EventBus<ExternalEventTypes & InternalEventTypes>;
|
|
148
|
+
protected theme: InternalStoreAPI<ThemeStore>;
|
|
149
|
+
protected store: InternalStoreAPI<CalendarStore>;
|
|
150
|
+
constructor(container: string | Element, options?: Options);
|
|
151
|
+
protected abstract getComponent(): ComponentChild;
|
|
152
|
+
protected getStoreState(): CalendarState;
|
|
153
|
+
protected getStoreState<Group extends keyof CalendarState>(group: Group): CalendarState[Group];
|
|
154
|
+
protected getStoreDispatchers(): Dispatchers;
|
|
155
|
+
protected getStoreDispatchers<Group extends keyof Dispatchers>(group: Group): Dispatchers[Group];
|
|
156
|
+
/**
|
|
157
|
+
* Destroys the instance.
|
|
158
|
+
*/
|
|
159
|
+
destroy(): void;
|
|
160
|
+
private calculateMonthRenderDate;
|
|
161
|
+
private calculateWeekRenderDate;
|
|
162
|
+
private calculateDayRenderDate;
|
|
163
|
+
/**
|
|
164
|
+
* Move the rendered date to the next/prev range.
|
|
165
|
+
*
|
|
166
|
+
* The range of movement differs depending on the current view, Basically:
|
|
167
|
+
* - In month view, it moves to the next/prev month.
|
|
168
|
+
* - In week view, it moves to the next/prev week.
|
|
169
|
+
* - In day view, it moves to the next/prev day.
|
|
170
|
+
*
|
|
171
|
+
* Also, the range depends on the options like how many visible weeks/months should be rendered.
|
|
172
|
+
*
|
|
173
|
+
* @param {number} offset The offset to move by.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* // Move to the next month in month view.
|
|
177
|
+
* calendar.move(1);
|
|
178
|
+
*
|
|
179
|
+
* // Move to the next year in month view.
|
|
180
|
+
* calendar.move(12);
|
|
181
|
+
*
|
|
182
|
+
* // Move to yesterday in day view.
|
|
183
|
+
* calendar.move(-1);
|
|
184
|
+
*/
|
|
185
|
+
move(offset: number): void;
|
|
186
|
+
/**********
|
|
187
|
+
* CRUD Methods
|
|
188
|
+
**********/
|
|
189
|
+
/**
|
|
190
|
+
* Create events and render calendar.
|
|
191
|
+
* @param {Array.<EventObject>} events - list of {@link EventObject}
|
|
192
|
+
* @example
|
|
193
|
+
* calendar.createEvents([
|
|
194
|
+
* {
|
|
195
|
+
* id: '1',
|
|
196
|
+
* calendarId: '1',
|
|
197
|
+
* title: 'my event',
|
|
198
|
+
* category: 'time',
|
|
199
|
+
* dueDateClass: '',
|
|
200
|
+
* start: '2018-01-18T22:30:00+09:00',
|
|
201
|
+
* end: '2018-01-19T02:30:00+09:00',
|
|
202
|
+
* },
|
|
203
|
+
* {
|
|
204
|
+
* id: '2',
|
|
205
|
+
* calendarId: '1',
|
|
206
|
+
* title: 'second event',
|
|
207
|
+
* category: 'time',
|
|
208
|
+
* dueDateClass: '',
|
|
209
|
+
* start: '2018-01-18T17:30:00+09:00',
|
|
210
|
+
* end: '2018-01-19T17:31:00+09:00',
|
|
211
|
+
* },
|
|
212
|
+
* ]);
|
|
213
|
+
*/
|
|
214
|
+
createEvents(events: EventObject[]): void;
|
|
215
|
+
protected getEventModel(eventId: string, calendarId: string): EventModel | null;
|
|
216
|
+
/**
|
|
217
|
+
* Get an {@link EventObject} with event's id and calendar's id.
|
|
218
|
+
*
|
|
219
|
+
* @param {string} eventId - event's id
|
|
220
|
+
* @param {string} calendarId - calendar's id of the event
|
|
221
|
+
* @returns {EventObject|null} event. If the event can't be found, it returns null.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* const event = calendar.getEvent(eventId, calendarId);
|
|
225
|
+
*
|
|
226
|
+
* console.log(event.title);
|
|
227
|
+
*/
|
|
228
|
+
getEvent(eventId: string, calendarId: string): import("../types/events").EventObjectWithDefaultValues | null;
|
|
229
|
+
/**
|
|
230
|
+
* Update an event.
|
|
231
|
+
*
|
|
232
|
+
* @param {string} eventId - ID of an event to update
|
|
233
|
+
* @param {string} calendarId - The calendarId of the event to update
|
|
234
|
+
* @param {EventObject} changes - The new {@link EventObject} data to apply to the event
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* calendar.on('beforeUpdateEvent', function ({ event, changes }) {
|
|
238
|
+
* const { id, calendarId } = event;
|
|
239
|
+
*
|
|
240
|
+
* calendar.updateEvent(id, calendarId, changes);
|
|
241
|
+
* });
|
|
242
|
+
*/
|
|
243
|
+
updateEvent(eventId: string, calendarId: string, changes: EventObject): void;
|
|
244
|
+
/**
|
|
245
|
+
* Delete an event.
|
|
246
|
+
*
|
|
247
|
+
* @param {string} eventId - event's id to delete
|
|
248
|
+
* @param {string} calendarId - The CalendarId of the event to delete
|
|
249
|
+
*/
|
|
250
|
+
deleteEvent(eventId: string, calendarId: string): void;
|
|
251
|
+
/**********
|
|
252
|
+
* General Methods
|
|
253
|
+
**********/
|
|
254
|
+
/**
|
|
255
|
+
* Set events' visibility by calendar ID
|
|
256
|
+
*
|
|
257
|
+
* @param {string|Array.<string>} calendarId - The calendar id or ids to change visibility
|
|
258
|
+
* @param {boolean} isVisible - If set to true, show the events. If set to false, hide the events.
|
|
259
|
+
*/
|
|
260
|
+
setCalendarVisibility(calendarId: string | string[], isVisible: boolean): void;
|
|
261
|
+
/**
|
|
262
|
+
* Render the calendar.
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* calendar.render();
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* // Re-render the calendar when resizing a window.
|
|
269
|
+
* window.addEventListener('resize', () => {
|
|
270
|
+
* calendar.render();
|
|
271
|
+
* });
|
|
272
|
+
*/
|
|
273
|
+
render(): this;
|
|
274
|
+
/**
|
|
275
|
+
* For SSR(Server Side Rendering), Return the HTML string of the whole calendar.
|
|
276
|
+
*
|
|
277
|
+
* @returns {string} HTML string
|
|
278
|
+
*/
|
|
279
|
+
renderToString(): string;
|
|
280
|
+
/**
|
|
281
|
+
* Delete all events and clear view
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* calendar.clear();
|
|
285
|
+
*/
|
|
286
|
+
clear(): void;
|
|
287
|
+
/**
|
|
288
|
+
* Scroll to current time on today in case of daily, weekly view.
|
|
289
|
+
* Nothing happens in the monthly view.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* function onNewEvents(events) {
|
|
293
|
+
* calendar.createEvents(events);
|
|
294
|
+
* calendar.scrollToNow('smooth');
|
|
295
|
+
* }
|
|
296
|
+
*/
|
|
297
|
+
scrollToNow(scrollBehavior?: ScrollBehaviorOptions): void;
|
|
298
|
+
private calculateRenderRange;
|
|
299
|
+
/**
|
|
300
|
+
* Move to today.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* function onClickTodayBtn() {
|
|
304
|
+
* calendar.today();
|
|
305
|
+
* }
|
|
306
|
+
*/
|
|
307
|
+
today(): void;
|
|
308
|
+
/**
|
|
309
|
+
* Move to specific date.
|
|
310
|
+
*
|
|
311
|
+
* @param {Date|string|number|TZDate} date - The date to move. it should be eligible parameter to create a `Date` instance if `date` is string or number.
|
|
312
|
+
* @example
|
|
313
|
+
* calendar.on('clickDayName', (event) => {
|
|
314
|
+
* if (calendar.getViewName() === 'week') {
|
|
315
|
+
* const dateToMove = new Date(event.date);
|
|
316
|
+
*
|
|
317
|
+
* calendar.setDate(dateToMove);
|
|
318
|
+
* calendar.changeView('day');
|
|
319
|
+
* }
|
|
320
|
+
* });
|
|
321
|
+
*/
|
|
322
|
+
setDate(date: DateType): void;
|
|
323
|
+
/**
|
|
324
|
+
* Move the calendar forward to the next range.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* function moveToNextOrPrevRange(offset) {
|
|
328
|
+
* if (offset === -1) {
|
|
329
|
+
* calendar.prev();
|
|
330
|
+
* } else if (offset === 1) {
|
|
331
|
+
* calendar.next();
|
|
332
|
+
* }
|
|
333
|
+
* }
|
|
334
|
+
*/
|
|
335
|
+
next(): void;
|
|
336
|
+
/**
|
|
337
|
+
* Move the calendar backward to the previous range.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* function moveToNextOrPrevRange(offset) {
|
|
341
|
+
* if (offset === -1) {
|
|
342
|
+
* calendar.prev();
|
|
343
|
+
* } else if (offset === 1) {
|
|
344
|
+
* calendar.next();
|
|
345
|
+
* }
|
|
346
|
+
* }
|
|
347
|
+
*/
|
|
348
|
+
prev(): void;
|
|
349
|
+
/**
|
|
350
|
+
* Change color values of events belong to a certain calendar.
|
|
351
|
+
*
|
|
352
|
+
* @param {string} calendarId - The calendar ID
|
|
353
|
+
* @param {object} colorOptions - The color values of the calendar
|
|
354
|
+
* @param {string} colorOptions.color - The text color of the events
|
|
355
|
+
* @param {string} colorOptions.borderColor - Left border color of events
|
|
356
|
+
* @param {string} colorOptions.backgroundColor - Background color of events
|
|
357
|
+
* @param {string} colorOptions.dragBackgroundColor - Background color of events during dragging
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* calendar.setCalendarColor('1', {
|
|
361
|
+
* color: '#e8e8e8',
|
|
362
|
+
* backgroundColor: '#585858',
|
|
363
|
+
* borderColor: '#a1b56c',
|
|
364
|
+
* dragBackgroundColor: '#585858',
|
|
365
|
+
* });
|
|
366
|
+
* calendar.setCalendarColor('2', {
|
|
367
|
+
* color: '#282828',
|
|
368
|
+
* backgroundColor: '#dc9656',
|
|
369
|
+
* borderColor: '#a1b56c',
|
|
370
|
+
* dragBackgroundColor: '#dc9656',
|
|
371
|
+
* });
|
|
372
|
+
* calendar.setCalendarColor('3', {
|
|
373
|
+
* color: '#a16946',
|
|
374
|
+
* backgroundColor: '#ab4642',
|
|
375
|
+
* borderColor: '#a1b56c',
|
|
376
|
+
* dragBackgroundColor: '#ab4642',
|
|
377
|
+
* });
|
|
378
|
+
*/
|
|
379
|
+
setCalendarColor(calendarId: string, colorOptions: CalendarColor): void;
|
|
380
|
+
/**
|
|
381
|
+
* Change current view type.
|
|
382
|
+
*
|
|
383
|
+
* @param {string} viewName - The new view name to change to. Available values are 'month', 'week', 'day'.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* // change to daily view
|
|
387
|
+
* calendar.changeView('day');
|
|
388
|
+
*
|
|
389
|
+
* // change to weekly view
|
|
390
|
+
* calendar.changeView('week');
|
|
391
|
+
*
|
|
392
|
+
* // change to monthly view
|
|
393
|
+
* calendar.changeView('month');
|
|
394
|
+
*/
|
|
395
|
+
changeView(viewName: ViewType): void;
|
|
396
|
+
/**
|
|
397
|
+
* Get the DOM element of the event by event id and calendar id
|
|
398
|
+
*
|
|
399
|
+
* @param {string} eventId - ID of event
|
|
400
|
+
* @param {string} calendarId - calendarId of event
|
|
401
|
+
* @returns {HTMLElement} event element if found or null
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* const element = calendar.getElement(eventId, calendarId);
|
|
405
|
+
*
|
|
406
|
+
* console.log(element);
|
|
407
|
+
*/
|
|
408
|
+
getElement(eventId: string, calendarId: string): Element | null;
|
|
409
|
+
/**
|
|
410
|
+
* Set the theme of the calendar.
|
|
411
|
+
*
|
|
412
|
+
* @param {Theme} theme - The theme object to apply. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/theme.md|Theme} in guide.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* calendar.setTheme({
|
|
416
|
+
* common: {
|
|
417
|
+
* gridSelection: {
|
|
418
|
+
* backgroundColor: '#333',
|
|
419
|
+
* },
|
|
420
|
+
* },
|
|
421
|
+
* week: {
|
|
422
|
+
* nowIndicatorLabel: {
|
|
423
|
+
* color: '#00FF00',
|
|
424
|
+
* },
|
|
425
|
+
* },
|
|
426
|
+
* month: {
|
|
427
|
+
* dayName: {
|
|
428
|
+
* borderLeft: '1px solid #e5e5e5',
|
|
429
|
+
* },
|
|
430
|
+
* },
|
|
431
|
+
* });
|
|
432
|
+
*/
|
|
433
|
+
setTheme(theme: DeepPartial<ThemeState>): void;
|
|
434
|
+
/**
|
|
435
|
+
* Get current options.
|
|
436
|
+
*
|
|
437
|
+
* @returns {Options} - The current options of the instance
|
|
438
|
+
*/
|
|
439
|
+
getOptions(): {
|
|
440
|
+
template: import("../types/template").Template;
|
|
441
|
+
theme: {
|
|
442
|
+
common: import("../types/theme").CommonTheme;
|
|
443
|
+
week: import("../types/theme").WeekTheme;
|
|
444
|
+
month: import("../types/theme").MonthTheme;
|
|
445
|
+
};
|
|
446
|
+
week: import("../types/options").WeekOptions;
|
|
447
|
+
month: import("../types/options").MonthOptions;
|
|
448
|
+
isReadOnly: boolean;
|
|
449
|
+
gridSelection: (boolean | import("../types/options").GridSelectionOptions) & import("../types/options").GridSelectionOptions;
|
|
450
|
+
defaultView: ViewType;
|
|
451
|
+
useFormPopup: boolean;
|
|
452
|
+
useDetailPopup: boolean;
|
|
453
|
+
usageStatistics: boolean;
|
|
454
|
+
eventFilter: (event: EventObject) => boolean;
|
|
455
|
+
timezone: import("../types/options").TimezoneOptions;
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Set options of calendar. For more information, see {@link https://github.com/nhn/tui.calendar/blob/main/docs/en/apis/options.md|Options} in guide.
|
|
459
|
+
*
|
|
460
|
+
* @param {Options} options - The options to set
|
|
461
|
+
*/
|
|
462
|
+
setOptions(options: Options): void;
|
|
463
|
+
/**
|
|
464
|
+
* Get current rendered date. (see {@link TZDate} for further information)
|
|
465
|
+
*
|
|
466
|
+
* @returns {TZDate}
|
|
467
|
+
*/
|
|
468
|
+
getDate(): TZDate;
|
|
469
|
+
/**
|
|
470
|
+
* Start time of rendered date range. (see {@link TZDate} for further information)
|
|
471
|
+
*
|
|
472
|
+
* @returns {TZDate}
|
|
473
|
+
*/
|
|
474
|
+
getDateRangeStart(): TZDate;
|
|
475
|
+
/**
|
|
476
|
+
* End time of rendered date range. (see {@link TZDate} for further information)
|
|
477
|
+
*
|
|
478
|
+
* @returns {TZDate}
|
|
479
|
+
*/
|
|
480
|
+
getDateRangeEnd(): TZDate;
|
|
481
|
+
/**
|
|
482
|
+
* Get current view name('day', 'week', 'month').
|
|
483
|
+
*
|
|
484
|
+
* @returns {string} current view name ('day', 'week', 'month')
|
|
485
|
+
*/
|
|
486
|
+
getViewName(): ViewType;
|
|
487
|
+
/**
|
|
488
|
+
* Set calendar list.
|
|
489
|
+
*
|
|
490
|
+
* @param {CalendarInfo[]} calendars - list of calendars
|
|
491
|
+
*/
|
|
492
|
+
setCalendars(calendars: CalendarInfo[]): void;
|
|
493
|
+
/**
|
|
494
|
+
* Open event form popup with predefined form values.
|
|
495
|
+
*
|
|
496
|
+
* @param {EventObject} event - The predefined {@link EventObject} data to show in form.
|
|
497
|
+
*/
|
|
498
|
+
openFormPopup(event: EventObject): void;
|
|
499
|
+
clearGridSelections(): void;
|
|
500
|
+
fire<EventName extends keyof ExternalEventTypes>(eventName: EventName, ...args: Parameters<ExternalEventTypes[EventName]>): EventBus<ExternalEventTypes>;
|
|
501
|
+
off<EventName extends keyof ExternalEventTypes>(eventName?: EventName, handler?: ExternalEventTypes[EventName]): EventBus<ExternalEventTypes>;
|
|
502
|
+
on<EventName extends keyof ExternalEventTypes>(eventName: EventName, handler: ExternalEventTypes[EventName]): EventBus<ExternalEventTypes>;
|
|
503
|
+
once<EventName extends keyof ExternalEventTypes>(eventName: EventName, handler: ExternalEventTypes[EventName]): EventBus<ExternalEventTypes>;
|
|
504
|
+
}
|