react-big-schedule 5.5.2-beta.4 → 6.0.0

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.
@@ -1,44 +1,22 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _dayjs = _interopRequireDefault(require("dayjs"));
8
- var _isoWeek = _interopRequireDefault(require("dayjs/plugin/isoWeek"));
9
- var _quarterOfYear = _interopRequireDefault(require("dayjs/plugin/quarterOfYear"));
10
- var _utc = _interopRequireDefault(require("dayjs/plugin/utc"));
11
- var _weekday = _interopRequireDefault(require("dayjs/plugin/weekday"));
12
- var _rrule = require("rrule");
13
- var _default = require("../config/default");
14
- var _i18n = require("../config/i18n");
15
- var _scheduler = _interopRequireDefault(require("../config/scheduler"));
16
- var _behaviors = _interopRequireDefault(require("../helper/behaviors"));
17
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
18
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
19
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
22
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
23
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
24
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
25
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
26
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
- var SchedulerData = exports["default"] = /*#__PURE__*/function () {
28
- function SchedulerData() {
29
- var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _dayjs["default"])();
30
- var viewType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _default.ViewType.Week;
31
- var showAgenda = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
32
- var isEventPerspective = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
33
- var newConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
34
- var newBehaviors = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
35
- _classCallCheck(this, SchedulerData);
1
+ import dayjs from 'dayjs';
2
+ import isoWeek from 'dayjs/plugin/isoWeek';
3
+ import quarterOfYear from 'dayjs/plugin/quarterOfYear';
4
+ import utc from 'dayjs/plugin/utc';
5
+ import weekday from 'dayjs/plugin/weekday';
6
+ import { RRuleSet, rrulestr } from 'rrule';
7
+ import { CellUnit, DATE_FORMAT, DATETIME_FORMAT, ViewType } from '../config/default';
8
+ import { getDefaultLabels, getLabel } from '../config/i18n';
9
+ import config from '../config/scheduler';
10
+ import behaviors from '../helper/behaviors';
11
+ import { normalizeEventEnd, normalizeEventStart } from '../helper/utility';
12
+ export default class SchedulerData {
13
+ constructor(date = dayjs(), viewType = ViewType.Week, showAgenda = false, isEventPerspective = false, newConfig = undefined, newBehaviors = undefined) {
36
14
  this.resources = [];
37
15
  this.events = [];
38
16
  this.eventGroups = [];
39
17
  this.eventGroupsAutoGenerated = true;
40
18
  this.viewType = viewType;
41
- this.cellUnit = viewType === _default.ViewType.Day ? _default.CellUnit.Hour : _default.CellUnit.Day;
19
+ this.cellUnit = viewType === ViewType.Day ? CellUnit.Hour : CellUnit.Day;
42
20
  this.showAgenda = showAgenda;
43
21
  this.isEventPerspective = isEventPerspective;
44
22
  this.resizing = false;
@@ -51,15 +29,21 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
51
29
  this._batchCount = 0;
52
30
  this._versionChangeCallback = null;
53
31
  this.calendarPopoverLocale = undefined;
54
- _dayjs["default"].extend(_quarterOfYear["default"]);
55
- _dayjs["default"].extend(_weekday["default"]);
56
- _dayjs["default"].extend(_utc["default"]);
57
- _dayjs["default"].extend(_isoWeek["default"]);
58
- this.localeDayjs = _dayjs["default"];
59
- this.config = newConfig === undefined ? _scheduler["default"] : _objectSpread(_objectSpread({}, _scheduler["default"]), newConfig);
32
+ dayjs.extend(quarterOfYear);
33
+ dayjs.extend(weekday);
34
+ dayjs.extend(utc);
35
+ dayjs.extend(isoWeek);
36
+ this.localeDayjs = dayjs;
37
+ this.config = newConfig === undefined ? config : {
38
+ ...config,
39
+ ...newConfig
40
+ };
60
41
  this._updateLabelsFromI18n();
61
42
  this._validateMinuteStep(this.config.minuteStep);
62
- this.behaviors = newBehaviors === undefined ? _behaviors["default"] : _objectSpread(_objectSpread({}, _behaviors["default"]), newBehaviors);
43
+ this.behaviors = newBehaviors === undefined ? behaviors : {
44
+ ...behaviors,
45
+ ...newBehaviors
46
+ };
63
47
  this._resolveDate(0, date);
64
48
  this._createHeaders();
65
49
  this._createRenderData();
@@ -70,1314 +54,1103 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
70
54
  * This allows apps to provide localized labels via setLabelsProvider()
71
55
  * @private
72
56
  */
73
- return _createClass(SchedulerData, [{
74
- key: "_updateLabelsFromI18n",
75
- value: function _updateLabelsFromI18n(locale) {
76
- // Get labels from the i18n provider if available
77
- var defaults = (0, _i18n.getDefaultLabels)();
78
- var applyIfProvided = function applyIfProvided(key, current) {
79
- var value = (0, _i18n.getLabel)(key, locale);
80
- if (value === undefined || value === null) return current;
81
- return value !== defaults[key] ? value : current;
82
- };
83
- this.config.resourceName = applyIfProvided('resourceName', this.config.resourceName);
84
- this.config.taskName = applyIfProvided('taskName', this.config.taskName);
85
- this.config.agendaViewHeader = applyIfProvided('agendaViewHeader', this.config.agendaViewHeader);
86
- this.config.weekNumberLabel = applyIfProvided('weekNumberLabel', this.config.weekNumberLabel);
87
- }
88
- }, {
89
- key: "setVersionChangeNotifier",
90
- value: function setVersionChangeNotifier(callback) {
91
- this._versionChangeCallback = typeof callback === 'function' ? callback : null;
92
- }
93
- }, {
94
- key: "beginBatch",
95
- value: function beginBatch() {
96
- this._batchCount = (this._batchCount || 0) + 1;
97
- }
98
- }, {
99
- key: "endBatch",
100
- value: function endBatch() {
101
- if (this._batchCount === undefined || this._batchCount <= 0) {
102
- this._batchCount = 0;
103
- console.warn('SchedulerData.endBatch called without a matching beginBatch');
104
- return;
105
- }
106
- if (this._batchCount > 0) {
107
- this._batchCount -= 1;
108
- if (this._batchCount === 0 && this._pendingVersion !== undefined) {
109
- var pendingVersion = this._pendingVersion;
110
- this._pendingVersion = undefined;
111
- if (typeof this._versionChangeCallback === 'function') {
112
- this._versionChangeCallback(pendingVersion);
113
- }
57
+ _updateLabelsFromI18n(locale) {
58
+ // Get labels from the i18n provider if available
59
+ const defaults = getDefaultLabels();
60
+ const applyIfProvided = (key, current) => {
61
+ const value = getLabel(key, locale);
62
+ if (value === undefined || value === null) return current;
63
+ return value !== defaults[key] ? value : current;
64
+ };
65
+ this.config.resourceName = applyIfProvided('resourceName', this.config.resourceName);
66
+ this.config.taskName = applyIfProvided('taskName', this.config.taskName);
67
+ this.config.agendaViewHeader = applyIfProvided('agendaViewHeader', this.config.agendaViewHeader);
68
+ this.config.weekNumberLabel = applyIfProvided('weekNumberLabel', this.config.weekNumberLabel);
69
+ }
70
+ setVersionChangeNotifier(callback) {
71
+ this._versionChangeCallback = typeof callback === 'function' ? callback : null;
72
+ }
73
+ beginBatch() {
74
+ this._batchCount = (this._batchCount || 0) + 1;
75
+ }
76
+ endBatch() {
77
+ if (this._batchCount === undefined || this._batchCount <= 0) {
78
+ this._batchCount = 0;
79
+ console.warn('SchedulerData.endBatch called without a matching beginBatch');
80
+ return;
81
+ }
82
+ if (this._batchCount > 0) {
83
+ this._batchCount -= 1;
84
+ if (this._batchCount === 0 && this._pendingVersion !== undefined) {
85
+ const pendingVersion = this._pendingVersion;
86
+ this._pendingVersion = undefined;
87
+ if (typeof this._versionChangeCallback === 'function') {
88
+ this._versionChangeCallback(pendingVersion);
114
89
  }
115
90
  }
116
91
  }
117
- }, {
118
- key: "bumpVersion",
119
- value: function bumpVersion() {
120
- this.version += 1;
121
- if (this._batchCount > 0) {
122
- // Defer callback until batch ends
123
- this._pendingVersion = this.version;
124
- } else if (typeof this._versionChangeCallback === 'function') {
125
- this._versionChangeCallback(this.version);
126
- }
127
- }
128
- }, {
129
- key: "getVersion",
130
- value: function getVersion() {
131
- return this.version;
132
- }
133
- }, {
134
- key: "setSchedulerLocale",
135
- value: function setSchedulerLocale(preset) {
136
- if (!preset) return;
137
- this.localeDayjs.locale(preset);
138
- this._updateLabelsFromI18n(preset);
139
- this._shouldReloadViewType = true;
140
- this.setViewType(this.viewType, this.showAgenda, this.isEventPerspective);
141
- }
142
- }, {
143
- key: "setCalendarPopoverLocale",
144
- value: function setCalendarPopoverLocale(lang) {
145
- if (lang) {
146
- this.calendarPopoverLocale = lang;
147
- }
148
- }
149
- }, {
150
- key: "setResources",
151
- value: function setResources(resources) {
152
- this._validateResource(resources);
153
- this.resources = Array.from(new Set(resources));
154
- this._createRenderData();
155
- this.setScrollToSpecialDayjs(true);
156
- this.bumpVersion();
92
+ }
93
+ bumpVersion() {
94
+ this.version += 1;
95
+ if (this._batchCount > 0) {
96
+ // Defer callback until batch ends
97
+ this._pendingVersion = this.version;
98
+ } else if (typeof this._versionChangeCallback === 'function') {
99
+ this._versionChangeCallback(this.version);
157
100
  }
158
- }, {
159
- key: "setEventGroupsAutoGenerated",
160
- value: function setEventGroupsAutoGenerated(autoGenerated) {
161
- this.eventGroupsAutoGenerated = autoGenerated;
101
+ }
102
+ getVersion() {
103
+ return this.version;
104
+ }
105
+ setSchedulerLocale(preset) {
106
+ if (!preset) return;
107
+ this.localeDayjs.locale(preset);
108
+ this._updateLabelsFromI18n(preset);
109
+ this._shouldReloadViewType = true;
110
+ this.setViewType(this.viewType, this.showAgenda, this.isEventPerspective);
111
+ }
112
+ setCalendarPopoverLocale(lang) {
113
+ if (lang) {
114
+ this.calendarPopoverLocale = lang;
162
115
  }
116
+ }
117
+ setResources(resources) {
118
+ this._validateResource(resources);
119
+ this.resources = Array.from(new Set(resources));
120
+ this._createRenderData();
121
+ this.setScrollToSpecialDayjs(true);
122
+ this.bumpVersion();
123
+ }
124
+ setEventGroupsAutoGenerated(autoGenerated) {
125
+ this.eventGroupsAutoGenerated = autoGenerated;
126
+ }
163
127
 
164
- // optional
165
- }, {
166
- key: "setEventGroups",
167
- value: function setEventGroups(eventGroups) {
168
- this._validateEventGroups(eventGroups);
169
- this.eventGroups = Array.from(new Set(eventGroups));
170
- this.eventGroupsAutoGenerated = false;
128
+ // optional
129
+ setEventGroups(eventGroups) {
130
+ this._validateEventGroups(eventGroups);
131
+ this.eventGroups = Array.from(new Set(eventGroups));
132
+ this.eventGroupsAutoGenerated = false;
133
+ this._createRenderData();
134
+ this.setScrollToSpecialDayjs(true);
135
+ this.bumpVersion();
136
+ }
137
+ setMinuteStep(minuteStep) {
138
+ if (this.config.minuteStep !== minuteStep) {
139
+ this._validateMinuteStep(minuteStep);
140
+ this.config.minuteStep = minuteStep;
141
+ this._createHeaders();
171
142
  this._createRenderData();
172
- this.setScrollToSpecialDayjs(true);
173
143
  this.bumpVersion();
174
144
  }
175
- }, {
176
- key: "setMinuteStep",
177
- value: function setMinuteStep(minuteStep) {
178
- if (this.config.minuteStep !== minuteStep) {
179
- this._validateMinuteStep(minuteStep);
180
- this.config.minuteStep = minuteStep;
181
- this._createHeaders();
182
- this._createRenderData();
183
- this.bumpVersion();
184
- }
185
- }
186
- }, {
187
- key: "setBesidesWidth",
188
- value: function setBesidesWidth(besidesWidth) {
189
- if (besidesWidth >= 0 && this.config.besidesWidth !== besidesWidth) {
190
- this.config.besidesWidth = besidesWidth;
191
- this.bumpVersion();
192
- }
193
- }
194
- }, {
195
- key: "setUnderneathHeight",
196
- value: function setUnderneathHeight(underneathHeight) {
197
- if (underneathHeight >= 0 && this.config.underneathHeight !== underneathHeight) {
198
- this.config.underneathHeight = underneathHeight;
199
- this.bumpVersion();
200
- }
201
- }
202
- }, {
203
- key: "getMinuteStepsInHour",
204
- value: function getMinuteStepsInHour() {
205
- return 60 / this.config.minuteStep;
206
- }
207
- }, {
208
- key: "addResource",
209
- value: function addResource(resource) {
210
- var existedResources = this.resources.filter(function (x) {
211
- return x.id === resource.id;
212
- });
213
- if (existedResources.length === 0) {
214
- this.resources.push(resource);
215
- this._createRenderData();
216
- this.bumpVersion();
217
- }
218
- }
219
- }, {
220
- key: "addEventGroup",
221
- value: function addEventGroup(eventGroup) {
222
- var existedEventGroups = this.eventGroups.filter(function (x) {
223
- return x.id === eventGroup.id;
224
- });
225
- if (existedEventGroups.length === 0) {
226
- this.eventGroups.push(eventGroup);
227
- this._createRenderData();
228
- this.bumpVersion();
229
- }
230
- }
231
- }, {
232
- key: "removeEventGroupById",
233
- value: function removeEventGroupById(eventGroupId) {
234
- var index = -1;
235
- this.eventGroups.forEach(function (item, idx) {
236
- if (item.id === eventGroupId) index = idx;
237
- });
238
- if (index !== -1) {
239
- this.eventGroups.splice(index, 1);
240
- this._createRenderData();
241
- this.bumpVersion();
242
- }
243
- }
244
- }, {
245
- key: "containsEventGroupId",
246
- value: function containsEventGroupId(eventGroupId) {
247
- var index = -1;
248
- this.eventGroups.forEach(function (item, idx) {
249
- if (item.id === eventGroupId) index = idx;
250
- });
251
- return index !== -1;
252
- }
253
- }, {
254
- key: "setEvents",
255
- value: function setEvents(events) {
256
- this._validateEvents(events);
257
- this.events = Array.from(events);
258
- if (this.eventGroupsAutoGenerated) this._generateEventGroups();
259
- if (this.config.recurringEventsEnabled) this._handleRecurringEvents();
260
- this._createRenderData();
145
+ }
146
+ setBesidesWidth(besidesWidth) {
147
+ if (besidesWidth >= 0 && this.config.besidesWidth !== besidesWidth) {
148
+ this.config.besidesWidth = besidesWidth;
261
149
  this.bumpVersion();
262
150
  }
263
- }, {
264
- key: "setScrollToSpecialDayjs",
265
- value: function setScrollToSpecialDayjs(scrollToSpecialDayjs) {
266
- if (this.config.scrollToSpecialDayjsEnabled) this.scrollToSpecialDayjs = scrollToSpecialDayjs;
151
+ }
152
+ setUnderneathHeight(underneathHeight) {
153
+ if (underneathHeight >= 0 && this.config.underneathHeight !== underneathHeight) {
154
+ this.config.underneathHeight = underneathHeight;
155
+ this.bumpVersion();
267
156
  }
268
- }, {
269
- key: "prev",
270
- value: function prev() {
271
- this._resolveDate(-1);
272
- this.events = [];
273
- this._createHeaders();
157
+ }
158
+ getMinuteStepsInHour() {
159
+ return 60 / this.config.minuteStep;
160
+ }
161
+ addResource(resource) {
162
+ const existedResources = this.resources.filter(x => x.id === resource.id);
163
+ if (existedResources.length === 0) {
164
+ this.resources.push(resource);
274
165
  this._createRenderData();
275
166
  this.bumpVersion();
276
167
  }
277
- }, {
278
- key: "next",
279
- value: function next() {
280
- this._resolveDate(1);
281
- this.events = [];
282
- this._createHeaders();
168
+ }
169
+ addEventGroup(eventGroup) {
170
+ const existedEventGroups = this.eventGroups.filter(x => x.id === eventGroup.id);
171
+ if (existedEventGroups.length === 0) {
172
+ this.eventGroups.push(eventGroup);
283
173
  this._createRenderData();
284
174
  this.bumpVersion();
285
175
  }
286
- }, {
287
- key: "setDate",
288
- value: function setDate() {
289
- var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _dayjs["default"])(new Date());
290
- this._resolveDate(0, date);
291
- this.events = [];
292
- this._createHeaders();
176
+ }
177
+ removeEventGroupById(eventGroupId) {
178
+ let index = -1;
179
+ this.eventGroups.forEach((item, idx) => {
180
+ if (item.id === eventGroupId) index = idx;
181
+ });
182
+ if (index !== -1) {
183
+ this.eventGroups.splice(index, 1);
293
184
  this._createRenderData();
294
185
  this.bumpVersion();
295
186
  }
296
- }, {
297
- key: "setViewType",
298
- value: function setViewType() {
299
- var viewType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _default.ViewType.Week;
300
- var showAgenda = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
301
- var isEventPerspective = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
302
- var previousShowAgenda = this.showAgenda;
303
- var previousIsEventPerspective = this.isEventPerspective;
304
- this.showAgenda = showAgenda;
305
- this.isEventPerspective = isEventPerspective;
306
- var isCustomView = viewType === _default.ViewType.Custom || viewType === _default.ViewType.Custom1 || viewType === _default.ViewType.Custom2;
187
+ }
188
+ containsEventGroupId(eventGroupId) {
189
+ let index = -1;
190
+ this.eventGroups.forEach((item, idx) => {
191
+ if (item.id === eventGroupId) index = idx;
192
+ });
193
+ return index !== -1;
194
+ }
195
+ setEvents(events) {
196
+ this._validateEvents(events);
197
+ this.events = Array.from(events);
198
+ if (this.eventGroupsAutoGenerated) this._generateEventGroups();
199
+ if (this.config.recurringEventsEnabled) this._handleRecurringEvents();
200
+ this._createRenderData();
201
+ this.bumpVersion();
202
+ }
203
+ setScrollToSpecialDayjs(scrollToSpecialDayjs) {
204
+ if (this.config.scrollToSpecialDayjsEnabled) this.scrollToSpecialDayjs = scrollToSpecialDayjs;
205
+ }
206
+ prev() {
207
+ this._resolveDate(-1);
208
+ this.events = [];
209
+ this._createHeaders();
210
+ this._createRenderData();
211
+ this.bumpVersion();
212
+ }
213
+ next() {
214
+ this._resolveDate(1);
215
+ this.events = [];
216
+ this._createHeaders();
217
+ this._createRenderData();
218
+ this.bumpVersion();
219
+ }
220
+ setDate(date = dayjs(new Date())) {
221
+ this._resolveDate(0, date);
222
+ this.events = [];
223
+ this._createHeaders();
224
+ this._createRenderData();
225
+ this.bumpVersion();
226
+ }
227
+ setViewType(viewType = ViewType.Week, showAgenda = false, isEventPerspective = false) {
228
+ const previousShowAgenda = this.showAgenda;
229
+ const previousIsEventPerspective = this.isEventPerspective;
230
+ this.showAgenda = showAgenda;
231
+ this.isEventPerspective = isEventPerspective;
232
+ const isCustomView = viewType === ViewType.Custom || viewType === ViewType.Custom1 || viewType === ViewType.Custom2;
307
233
 
308
- // Force built-in views only; custom views can provide their own cellUnit via custom date behavior.
309
- if (!isCustomView && viewType !== _default.ViewType.Day) {
310
- this.cellUnit = _default.CellUnit.Day;
311
- }
234
+ // Force built-in views only; custom views can provide their own cellUnit via custom date behavior.
235
+ if (!isCustomView && viewType !== ViewType.Day) {
236
+ this.cellUnit = CellUnit.Day;
237
+ }
312
238
 
313
- // If showAgenda or isEventPerspective changed, force reload
314
- if (previousShowAgenda !== showAgenda || previousIsEventPerspective !== isEventPerspective) {
315
- this._shouldReloadViewType = true;
316
- }
317
- if (this.viewType !== viewType || this._shouldReloadViewType) {
318
- var date = this.startDate;
319
- if (viewType === _default.ViewType.Custom || viewType === _default.ViewType.Custom1 || viewType === _default.ViewType.Custom2) {
320
- this.viewType = viewType;
321
- this._resolveDate(0, date);
239
+ // If showAgenda or isEventPerspective changed, force reload
240
+ if (previousShowAgenda !== showAgenda || previousIsEventPerspective !== isEventPerspective) {
241
+ this._shouldReloadViewType = true;
242
+ }
243
+ if (this.viewType !== viewType || this._shouldReloadViewType) {
244
+ let date = this.startDate;
245
+ if (viewType === ViewType.Custom || viewType === ViewType.Custom1 || viewType === ViewType.Custom2) {
246
+ this.viewType = viewType;
247
+ this._resolveDate(0, date);
248
+ } else {
249
+ if (this.viewType < viewType) {
250
+ if (viewType === ViewType.Week) {
251
+ this.startDate = this.localeDayjs(new Date(date)).startOf('isoWeek');
252
+ this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('isoWeek');
253
+ } else if (viewType === ViewType.Month) {
254
+ this.startDate = this.localeDayjs(new Date(date)).startOf('month');
255
+ this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('month');
256
+ } else if (viewType === ViewType.Quarter) {
257
+ this.startDate = this.localeDayjs(new Date(date)).startOf('quarter');
258
+ this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('quarter');
259
+ } else if (viewType === ViewType.Year) {
260
+ this.startDate = this.localeDayjs(new Date(date)).startOf('year');
261
+ this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('year');
262
+ }
322
263
  } else {
323
- if (this.viewType < viewType) {
324
- if (viewType === _default.ViewType.Week) {
325
- this.startDate = this.localeDayjs(new Date(date)).startOf('isoWeek');
326
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('isoWeek');
327
- } else if (viewType === _default.ViewType.Month) {
328
- this.startDate = this.localeDayjs(new Date(date)).startOf('month');
329
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('month');
330
- } else if (viewType === _default.ViewType.Quarter) {
331
- this.startDate = this.localeDayjs(new Date(date)).startOf('quarter');
332
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('quarter');
333
- } else if (viewType === _default.ViewType.Year) {
334
- this.startDate = this.localeDayjs(new Date(date)).startOf('year');
335
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('year');
336
- }
337
- } else {
338
- var start = this.localeDayjs(new Date(this.startDate));
339
- var end = this.localeDayjs(new Date(this.endDate)).add(1, 'days');
340
- if (this.selectDate !== undefined) {
341
- var selectDate = this.localeDayjs(new Date(this.selectDate));
342
- if (selectDate >= start && selectDate < end) {
343
- date = this.selectDate;
344
- }
345
- }
346
- var now = this.localeDayjs();
347
- if (now >= start && now < end) {
348
- date = now.startOf('day');
349
- }
350
- if (viewType === _default.ViewType.Day) {
351
- this.startDate = date;
352
- this.endDate = this.startDate;
353
- this.cellUnit = _default.CellUnit.Hour;
354
- } else if (viewType === _default.ViewType.Week) {
355
- this.startDate = this.localeDayjs(new Date(date)).startOf('isoWeek');
356
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('isoWeek');
357
- } else if (viewType === _default.ViewType.Month) {
358
- this.startDate = this.localeDayjs(new Date(date)).startOf('month');
359
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('month');
360
- } else if (viewType === _default.ViewType.Quarter) {
361
- this.startDate = this.localeDayjs(new Date(date)).startOf('quarter');
362
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('quarter');
264
+ const start = this.localeDayjs(new Date(this.startDate));
265
+ const end = this.localeDayjs(new Date(this.endDate)).add(1, 'days');
266
+ if (this.selectDate !== undefined) {
267
+ const selectDate = this.localeDayjs(new Date(this.selectDate));
268
+ if (selectDate >= start && selectDate < end) {
269
+ date = this.selectDate;
363
270
  }
364
271
  }
365
- this.viewType = viewType;
366
- }
367
- this._shouldReloadViewType = false;
368
- this.events = [];
369
- this._createHeaders();
370
- this._createRenderData();
371
- this.setScrollToSpecialDayjs(true);
372
- this.bumpVersion();
373
- }
374
- }
375
- }, {
376
- key: "setSchedulerMaxHeight",
377
- value: function setSchedulerMaxHeight(newSchedulerMaxHeight) {
378
- if (newSchedulerMaxHeight < 0) {
379
- return;
380
- }
381
- if (this.config.schedulerMaxHeight !== newSchedulerMaxHeight) {
382
- this.config.schedulerMaxHeight = newSchedulerMaxHeight;
383
- this.bumpVersion();
384
- }
385
- }
386
- }, {
387
- key: "isSchedulerResponsive",
388
- value: function isSchedulerResponsive() {
389
- return !!this.config.schedulerWidth.endsWith && this.config.schedulerWidth.endsWith('%');
390
- }
391
- }, {
392
- key: "toggleExpandStatus",
393
- value: function toggleExpandStatus(slotId) {
394
- var slotEntered = false;
395
- var slotIndent = -1;
396
- var isExpanded = false;
397
- var changed = false;
398
- var expandedMap = new Map();
399
- this.renderData.forEach(function (item) {
400
- if (slotEntered === false) {
401
- if (item.slotId === slotId && item.hasChildren) {
402
- slotEntered = true;
403
- isExpanded = !item.expanded;
404
- item.expanded = isExpanded;
405
- changed = true;
406
- slotIndent = item.indent;
407
- expandedMap.set(item.indent, {
408
- expanded: item.expanded,
409
- render: item.render
410
- });
272
+ const now = this.localeDayjs();
273
+ if (now >= start && now < end) {
274
+ date = now.startOf('day');
411
275
  }
412
- } else if (item.indent > slotIndent) {
413
- var expandStatus = expandedMap.get(item.indent - 1);
414
- var newRender = expandStatus.expanded && expandStatus.render;
415
- if (item.render !== newRender) {
416
- item.render = newRender;
417
- changed = true;
276
+ if (viewType === ViewType.Day) {
277
+ this.startDate = this.localeDayjs(new Date(date)).startOf('day');
278
+ this.endDate = this.startDate;
279
+ this.cellUnit = CellUnit.Hour;
280
+ } else if (viewType === ViewType.Week) {
281
+ this.startDate = this.localeDayjs(new Date(date)).startOf('isoWeek');
282
+ this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('isoWeek');
283
+ } else if (viewType === ViewType.Month) {
284
+ this.startDate = this.localeDayjs(new Date(date)).startOf('month');
285
+ this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('month');
286
+ } else if (viewType === ViewType.Quarter) {
287
+ this.startDate = this.localeDayjs(new Date(date)).startOf('quarter');
288
+ this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('quarter');
418
289
  }
419
- if (item.hasChildren) {
420
- expandedMap.set(item.indent, {
421
- expanded: item.expanded,
422
- render: item.render
423
- });
424
- }
425
- } else {
426
- slotEntered = false;
427
290
  }
428
- });
429
- if (changed) {
430
- this.bumpVersion();
291
+ this.viewType = viewType;
431
292
  }
432
- }
433
- }, {
434
- key: "isResourceViewResponsive",
435
- value: function isResourceViewResponsive() {
436
- var resourceTableWidth = this.getResourceTableConfigWidth();
437
- return !!resourceTableWidth.endsWith && resourceTableWidth.endsWith('%');
438
- }
439
- }, {
440
- key: "isContentViewResponsive",
441
- value: function isContentViewResponsive() {
442
- var contentCellWidth = this.getContentCellConfigWidth();
443
- return !!contentCellWidth.endsWith && contentCellWidth.endsWith('%');
444
- }
445
- }, {
446
- key: "getSchedulerWidth",
447
- value: function getSchedulerWidth() {
448
- var baseWidth = this.documentWidth - this.config.besidesWidth > 0 ? this.documentWidth - this.config.besidesWidth : 0;
449
- return this.isSchedulerResponsive() ? parseInt(baseWidth * Number(this.config.schedulerWidth.slice(0, -1)) / 100, 10) : this.config.schedulerWidth;
450
- }
451
- }, {
452
- key: "getSchedulerHeight",
453
- value: function getSchedulerHeight() {
454
- var _this$config$schedule, _this$config$schedule2;
455
- // Use the header height tracked in SchedulerData (set via _setSchedulerHeaderHeight)
456
- var headerHeight = this.schedulerHeaderHeight || 0;
457
- var baseHeight = this.documentHeight - headerHeight - this.config.tableHeaderHeight - (this.config.underneathHeight || 0);
458
- var validBaseHeight = baseHeight > 0 ? baseHeight : 0;
459
- if (this.isSchedulerResponsive() && (_this$config$schedule = this.config.schedulerHeight) !== null && _this$config$schedule !== void 0 && (_this$config$schedule2 = _this$config$schedule.endsWith) !== null && _this$config$schedule2 !== void 0 && _this$config$schedule2.call(_this$config$schedule, '%')) {
460
- return parseInt(validBaseHeight * Number(this.config.schedulerHeight.slice(0, -1)) / 100, 10);
461
- }
462
- // fallback to max height if set, else just use base height
463
- return this.config.schedulerMaxHeight || validBaseHeight;
464
- }
465
- }, {
466
- key: "getResourceTableWidth",
467
- value: function getResourceTableWidth() {
468
- var resourceTableConfigWidth = this.getResourceTableConfigWidth();
469
- var schedulerWidth = this.getSchedulerWidth();
470
- var resourceTableWidth = this.isResourceViewResponsive() ? parseInt(schedulerWidth * Number(resourceTableConfigWidth.slice(0, -1)) / 100, 10) : resourceTableConfigWidth;
471
- if (this.isSchedulerResponsive() && this.getContentTableWidth() + resourceTableWidth < schedulerWidth) resourceTableWidth = schedulerWidth - this.getContentTableWidth();
472
- return resourceTableWidth;
473
- }
474
- }, {
475
- key: "getContentCellWidth",
476
- value: function getContentCellWidth() {
477
- var contentCellConfigWidth = this.getContentCellConfigWidth();
478
- var schedulerWidth = this.getSchedulerWidth();
479
- return this.isContentViewResponsive() ? parseInt(schedulerWidth * Number(contentCellConfigWidth.slice(0, -1)) / 100, 10) : contentCellConfigWidth;
480
- }
481
- }, {
482
- key: "getContentTableWidth",
483
- value: function getContentTableWidth() {
484
- return this.headers.length * this.getContentCellWidth();
485
- }
486
- }, {
487
- key: "getScrollToSpecialDayjs",
488
- value: function getScrollToSpecialDayjs() {
489
- if (this.config.scrollToSpecialDayjsEnabled) return this.scrollToSpecialDayjs;
490
- return false;
491
- }
492
- }, {
493
- key: "getSlots",
494
- value: function getSlots() {
495
- return this.isEventPerspective ? this.eventGroups : this.resources;
496
- }
497
- }, {
498
- key: "getSlotById",
499
- value: function getSlotById(slotId) {
500
- var slots = this.getSlots();
501
- var slot;
502
- slots.forEach(function (item) {
503
- if (item.id === slotId) slot = item;
504
- });
505
- return slot;
506
- }
507
- }, {
508
- key: "getResourceById",
509
- value: function getResourceById(resourceId) {
510
- var resource;
511
- this.resources.forEach(function (item) {
512
- if (item.id === resourceId) resource = item;
513
- });
514
- return resource;
515
- }
516
- }, {
517
- key: "getTableHeaderHeight",
518
- value: function getTableHeaderHeight() {
519
- return this.config.tableHeaderHeight;
520
- }
521
- }, {
522
- key: "getSchedulerContentDesiredHeight",
523
- value: function getSchedulerContentDesiredHeight() {
524
- var height = 0;
525
- this.renderData.forEach(function (item) {
526
- if (item.render) height += item.rowHeight;
527
- });
528
- return height;
529
- }
530
- }, {
531
- key: "getCellMaxEvents",
532
- value: function getCellMaxEvents() {
533
- var viewConfigMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, _default.ViewType.Week, 'weekMaxEvents'), _default.ViewType.Day, 'dayMaxEvents'), _default.ViewType.Month, 'monthMaxEvents'), _default.ViewType.Year, 'yearMaxEvents'), _default.ViewType.Quarter, 'quarterMaxEvents');
534
- var configProperty = viewConfigMap[this.viewType] || 'customMaxEvents';
535
- return this.config[configProperty];
536
- }
537
- }, {
538
- key: "getCalendarPopoverLocale",
539
- value: function getCalendarPopoverLocale() {
540
- return this.calendarPopoverLocale;
541
- }
542
- }, {
543
- key: "getSelectedDate",
544
- value: function getSelectedDate() {
545
- return this.selectDate.format(_default.DATE_FORMAT);
546
- }
547
- }, {
548
- key: "getViewStartDate",
549
- value: function getViewStartDate() {
550
- return this.startDate;
551
- }
552
- }, {
553
- key: "getViewEndDate",
554
- value: function getViewEndDate() {
555
- return this.endDate;
556
- }
557
- }, {
558
- key: "getViewDates",
559
- value: function getViewDates() {
560
- return {
561
- startDate: this.startDate,
562
- endDate: this.endDate
563
- };
564
- }
565
- }, {
566
- key: "getDateLabel",
567
- value: function getDateLabel() {
568
- var start = this.localeDayjs(new Date(this.startDate));
569
- var end = this.localeDayjs(new Date(this.endDate));
570
- var dateLabel = start.format('LL');
571
- if (start !== end) dateLabel = "".concat(start.format('LL'), "-").concat(end.format('LL'));
572
- if (this.behaviors.getDateLabelFunc) dateLabel = this.behaviors.getDateLabelFunc(this, this.viewType, this.startDate, this.endDate);
573
- return dateLabel;
574
- }
575
- }, {
576
- key: "addEvent",
577
- value: function addEvent(newEvent) {
578
- this._attachEvent(newEvent);
579
- if (this.eventGroupsAutoGenerated) this._generateEventGroups();
293
+ this._shouldReloadViewType = false;
294
+ this.events = [];
295
+ this._createHeaders();
580
296
  this._createRenderData();
297
+ this.setScrollToSpecialDayjs(true);
581
298
  this.bumpVersion();
582
299
  }
583
- }, {
584
- key: "updateEventStart",
585
- value: function updateEventStart(event, newStart) {
586
- this._detachEvent(event);
587
- event.start = newStart;
588
- this._attachEvent(event);
589
- this._createRenderData();
590
- this.bumpVersion();
300
+ }
301
+ setSchedulerMaxHeight(newSchedulerMaxHeight) {
302
+ if (newSchedulerMaxHeight < 0) {
303
+ return;
591
304
  }
592
- }, {
593
- key: "updateEventEnd",
594
- value: function updateEventEnd(event, newEnd) {
595
- event.end = newEnd;
596
- this._createRenderData();
305
+ if (this.config.schedulerMaxHeight !== newSchedulerMaxHeight) {
306
+ this.config.schedulerMaxHeight = newSchedulerMaxHeight;
597
307
  this.bumpVersion();
598
308
  }
599
- }, {
600
- key: "swapEvent",
601
- value: function swapEvent(eventSource, eventDest) {
602
- // Swap group or resource IDs
603
- if (this.isEventPerspective) {
604
- var _ref = [eventDest.groupId, eventSource.groupId];
605
- eventSource.groupId = _ref[0];
606
- eventDest.groupId = _ref[1];
607
- var _ref2 = [eventDest.groupName, eventSource.groupName];
608
- eventSource.groupName = _ref2[0];
609
- eventDest.groupName = _ref2[1];
309
+ }
310
+ isSchedulerResponsive() {
311
+ return !!this.config.schedulerWidth.endsWith && this.config.schedulerWidth.endsWith('%');
312
+ }
313
+ toggleExpandStatus(slotId) {
314
+ let slotEntered = false;
315
+ let slotIndent = -1;
316
+ let isExpanded = false;
317
+ let changed = false;
318
+ const expandedMap = new Map();
319
+ this.renderData.forEach(item => {
320
+ if (slotEntered === false) {
321
+ if (item.slotId === slotId && item.hasChildren) {
322
+ slotEntered = true;
323
+ isExpanded = !item.expanded;
324
+ item.expanded = isExpanded;
325
+ changed = true;
326
+ slotIndent = item.indent;
327
+ expandedMap.set(item.indent, {
328
+ expanded: item.expanded,
329
+ render: item.render
330
+ });
331
+ }
332
+ } else if (item.indent > slotIndent) {
333
+ const expandStatus = expandedMap.get(item.indent - 1);
334
+ const newRender = expandStatus.expanded && expandStatus.render;
335
+ if (item.render !== newRender) {
336
+ item.render = newRender;
337
+ changed = true;
338
+ }
339
+ if (item.hasChildren) {
340
+ expandedMap.set(item.indent, {
341
+ expanded: item.expanded,
342
+ render: item.render
343
+ });
344
+ }
610
345
  } else {
611
- var _ref3 = [eventDest.resourceId, eventSource.resourceId];
612
- eventSource.resourceId = _ref3[0];
613
- eventDest.resourceId = _ref3[1];
346
+ slotEntered = false;
614
347
  }
615
-
616
- // Swap start and end times
617
- var _ref4 = [eventDest.start, eventSource.start];
618
- eventSource.start = _ref4[0];
619
- eventDest.start = _ref4[1];
620
- // Update the events
621
- var _ref5 = [eventDest.end, eventSource.end];
622
- eventSource.end = _ref5[0];
623
- eventDest.end = _ref5[1];
624
- this._detachEvent(eventSource);
625
- this._detachEvent(eventDest);
626
- this._attachEvent(eventSource);
627
- this._attachEvent(eventDest);
628
- this._createRenderData();
348
+ });
349
+ if (changed) {
629
350
  this.bumpVersion();
630
351
  }
631
- }, {
632
- key: "swapEvent2",
633
- value: function swapEvent2(eventSource, eventDest) {
634
- var tempEventSource = _objectSpread({}, eventSource);
635
- var tempEventDest = _objectSpread({}, eventDest);
636
- this._detachEvent(eventSource);
637
- this._detachEvent(eventDest);
638
- if (this.isEventPerspective) {
639
- tempEventSource.groupId = eventDest.groupId;
640
- tempEventSource.groupName = eventDest.groupName;
641
- tempEventDest.groupId = eventSource.groupId;
642
- tempEventDest.groupName = eventSource.groupName;
643
- } else {
644
- tempEventSource.resourceId = eventDest.resourceId;
645
- tempEventDest.resourceId = eventSource.resourceId;
646
- }
647
- tempEventSource.end = eventDest.end;
648
- tempEventSource.start = eventDest.start;
649
- tempEventDest.end = eventSource.end;
650
- tempEventDest.start = eventSource.start;
651
- this._attachEvent(tempEventSource);
652
- this._attachEvent(tempEventDest);
352
+ }
353
+ isResourceViewResponsive() {
354
+ const resourceTableWidth = this.getResourceTableConfigWidth();
355
+ return !!resourceTableWidth.endsWith && resourceTableWidth.endsWith('%');
356
+ }
357
+ isContentViewResponsive() {
358
+ const contentCellWidth = this.getContentCellConfigWidth();
359
+ return !!contentCellWidth.endsWith && contentCellWidth.endsWith('%');
360
+ }
361
+ getSchedulerWidth() {
362
+ const baseWidth = this.documentWidth - this.config.besidesWidth > 0 ? this.documentWidth - this.config.besidesWidth : 0;
363
+ return this.isSchedulerResponsive() ? parseInt(baseWidth * Number(this.config.schedulerWidth.slice(0, -1)) / 100, 10) : this.config.schedulerWidth;
364
+ }
365
+ getSchedulerHeight() {
366
+ // Use the header height tracked in SchedulerData (set via _setSchedulerHeaderHeight)
367
+ const headerHeight = this.schedulerHeaderHeight || 0;
368
+ const baseHeight = this.documentHeight - headerHeight - this.config.tableHeaderHeight - (this.config.underneathHeight || 0);
369
+ const validBaseHeight = baseHeight > 0 ? baseHeight : 0;
370
+ if (this.isSchedulerResponsive() && this.config.schedulerHeight?.endsWith?.('%')) {
371
+ return parseInt(validBaseHeight * Number(this.config.schedulerHeight.slice(0, -1)) / 100, 10);
372
+ }
373
+ // fallback to max height if set, else just use base height
374
+ return this.config.schedulerMaxHeight || validBaseHeight;
375
+ }
376
+ getResourceTableWidth() {
377
+ const resourceTableConfigWidth = this.getResourceTableConfigWidth();
378
+ const schedulerWidth = this.getSchedulerWidth();
379
+ let resourceTableWidth = this.isResourceViewResponsive() ? parseInt(schedulerWidth * Number(resourceTableConfigWidth.slice(0, -1)) / 100, 10) : resourceTableConfigWidth;
380
+ if (this.isSchedulerResponsive() && this.getContentTableWidth() + resourceTableWidth < schedulerWidth) resourceTableWidth = schedulerWidth - this.getContentTableWidth();
381
+ return resourceTableWidth;
382
+ }
383
+ getContentCellWidth() {
384
+ const contentCellConfigWidth = this.getContentCellConfigWidth();
385
+ const schedulerWidth = this.getSchedulerWidth();
386
+ return this.isContentViewResponsive() ? parseInt(schedulerWidth * Number(contentCellConfigWidth.slice(0, -1)) / 100, 10) : contentCellConfigWidth;
387
+ }
388
+ getContentTableWidth() {
389
+ return this.headers.length * this.getContentCellWidth();
390
+ }
391
+ getScrollToSpecialDayjs() {
392
+ if (this.config.scrollToSpecialDayjsEnabled) return this.scrollToSpecialDayjs;
393
+ return false;
394
+ }
395
+ getSlots() {
396
+ return this.isEventPerspective ? this.eventGroups : this.resources;
397
+ }
398
+ getSlotById(slotId) {
399
+ const slots = this.getSlots();
400
+ let slot;
401
+ slots.forEach(item => {
402
+ if (item.id === slotId) slot = item;
403
+ });
404
+ return slot;
405
+ }
406
+ getResourceById(resourceId) {
407
+ let resource;
408
+ this.resources.forEach(item => {
409
+ if (item.id === resourceId) resource = item;
410
+ });
411
+ return resource;
412
+ }
413
+ getTableHeaderHeight() {
414
+ return this.config.tableHeaderHeight;
415
+ }
416
+ getSchedulerContentDesiredHeight() {
417
+ let height = 0;
418
+ this.renderData.forEach(item => {
419
+ if (item.render) height += item.rowHeight;
420
+ });
421
+ return height;
422
+ }
423
+ getCellMaxEvents() {
424
+ const viewConfigMap = {
425
+ [ViewType.Week]: 'weekMaxEvents',
426
+ [ViewType.Day]: 'dayMaxEvents',
427
+ [ViewType.Month]: 'monthMaxEvents',
428
+ [ViewType.Year]: 'yearMaxEvents',
429
+ [ViewType.Quarter]: 'quarterMaxEvents'
430
+ };
431
+ const configProperty = viewConfigMap[this.viewType] || 'customMaxEvents';
432
+ return this.config[configProperty];
433
+ }
434
+ getCalendarPopoverLocale() {
435
+ return this.calendarPopoverLocale;
436
+ }
437
+ getSelectedDate() {
438
+ return this.selectDate.format(DATE_FORMAT);
439
+ }
440
+ getViewStartDate() {
441
+ return this.startDate;
442
+ }
443
+ getViewEndDate() {
444
+ return this.endDate;
445
+ }
446
+ getViewDates() {
447
+ return {
448
+ startDate: this.startDate,
449
+ endDate: this.endDate
450
+ };
451
+ }
452
+ getDateLabel() {
453
+ const start = this.localeDayjs(new Date(this.startDate));
454
+ const end = this.localeDayjs(new Date(this.endDate));
455
+ let dateLabel = start.format('LL');
456
+ if (start !== end) dateLabel = `${start.format('LL')}-${end.format('LL')}`;
457
+ if (this.behaviors.getDateLabelFunc) dateLabel = this.behaviors.getDateLabelFunc(this, this.viewType, this.startDate, this.endDate);
458
+ return dateLabel;
459
+ }
460
+ addEvent(newEvent) {
461
+ this._attachEvent(newEvent);
462
+ if (this.eventGroupsAutoGenerated) this._generateEventGroups();
463
+ this._createRenderData();
464
+ this.bumpVersion();
465
+ }
466
+ updateEventStart(event, newStart) {
467
+ this._detachEvent(event);
468
+ event.start = newStart;
469
+ this._attachEvent(event);
470
+ this._createRenderData();
471
+ this.bumpVersion();
472
+ }
473
+ updateEventEnd(event, newEnd) {
474
+ event.end = newEnd;
475
+ this._createRenderData();
476
+ this.bumpVersion();
477
+ }
478
+ swapEvent(eventSource, eventDest) {
479
+ // Swap group or resource IDs
480
+ if (this.isEventPerspective) {
481
+ [eventSource.groupId, eventDest.groupId] = [eventDest.groupId, eventSource.groupId];
482
+ [eventSource.groupName, eventDest.groupName] = [eventDest.groupName, eventSource.groupName];
483
+ } else {
484
+ [eventSource.resourceId, eventDest.resourceId] = [eventDest.resourceId, eventSource.resourceId];
485
+ }
486
+
487
+ // Swap start and end times
488
+ [eventSource.start, eventDest.start] = [eventDest.start, eventSource.start];
489
+ [eventSource.end, eventDest.end] = [eventDest.end, eventSource.end];
490
+
491
+ // Update the events
492
+ this._detachEvent(eventSource);
493
+ this._detachEvent(eventDest);
494
+ this._attachEvent(eventSource);
495
+ this._attachEvent(eventDest);
496
+ this._createRenderData();
497
+ this.bumpVersion();
498
+ }
499
+ swapEvent2(eventSource, eventDest) {
500
+ const tempEventSource = {
501
+ ...eventSource
502
+ };
503
+ const tempEventDest = {
504
+ ...eventDest
505
+ };
506
+ this._detachEvent(eventSource);
507
+ this._detachEvent(eventDest);
508
+ if (this.isEventPerspective) {
509
+ tempEventSource.groupId = eventDest.groupId;
510
+ tempEventSource.groupName = eventDest.groupName;
511
+ tempEventDest.groupId = eventSource.groupId;
512
+ tempEventDest.groupName = eventSource.groupName;
513
+ } else {
514
+ tempEventSource.resourceId = eventDest.resourceId;
515
+ tempEventDest.resourceId = eventSource.resourceId;
516
+ }
517
+ tempEventSource.end = eventDest.end;
518
+ tempEventSource.start = eventDest.start;
519
+ tempEventDest.end = eventSource.end;
520
+ tempEventDest.start = eventSource.start;
521
+ this._attachEvent(tempEventSource);
522
+ this._attachEvent(tempEventDest);
523
+ this._createRenderData();
524
+ this.bumpVersion();
525
+ }
526
+ moveEvent(event, newSlotId, newSlotName, newStart, newEnd) {
527
+ this._detachEvent(event);
528
+ if (this.isEventPerspective) {
529
+ event.groupId = newSlotId;
530
+ event.groupName = newSlotName;
531
+ } else event.resourceId = newSlotId;
532
+ event.end = newEnd;
533
+ event.start = newStart;
534
+ this._attachEvent(event);
535
+ this._createRenderData();
536
+ this.bumpVersion();
537
+ }
538
+ isEventInTimeWindow(eventStart, eventEnd, windowStart, windowEnd) {
539
+ return eventStart < windowEnd && eventEnd > windowStart;
540
+ }
541
+ removeEvent(event) {
542
+ const index = this.events.indexOf(event);
543
+ if (index !== -1) {
544
+ this.events.splice(index, 1);
653
545
  this._createRenderData();
654
546
  this.bumpVersion();
655
547
  }
656
- }, {
657
- key: "moveEvent",
658
- value: function moveEvent(event, newSlotId, newSlotName, newStart, newEnd) {
659
- this._detachEvent(event);
660
- if (this.isEventPerspective) {
661
- event.groupId = newSlotId;
662
- event.groupName = newSlotName;
663
- } else event.resourceId = newSlotId;
664
- event.end = newEnd;
665
- event.start = newStart;
666
- this._attachEvent(event);
548
+ }
549
+ removeEventById(eventId) {
550
+ let index = -1;
551
+ this.events.forEach((item, idx) => {
552
+ if (item.id === eventId) index = idx;
553
+ });
554
+ if (index !== -1) {
555
+ this.events.splice(index, 1);
667
556
  this._createRenderData();
668
557
  this.bumpVersion();
669
558
  }
670
- }, {
671
- key: "isEventInTimeWindow",
672
- value: function isEventInTimeWindow(eventStart, eventEnd, windowStart, windowEnd) {
673
- return eventStart < windowEnd && eventEnd > windowStart;
674
- }
675
- }, {
676
- key: "removeEvent",
677
- value: function removeEvent(event) {
678
- var index = this.events.indexOf(event);
679
- if (index !== -1) {
680
- this.events.splice(index, 1);
681
- this._createRenderData();
682
- this.bumpVersion();
683
- }
684
- }
685
- }, {
686
- key: "removeEventById",
687
- value: function removeEventById(eventId) {
688
- var index = -1;
689
- this.events.forEach(function (item, idx) {
690
- if (item.id === eventId) index = idx;
691
- });
692
- if (index !== -1) {
693
- this.events.splice(index, 1);
694
- this._createRenderData();
695
- this.bumpVersion();
696
- }
559
+ }
560
+ getResourceTableConfigWidth() {
561
+ if (this.showAgenda) {
562
+ return this.config.agendaResourceTableWidth;
563
+ }
564
+ const viewConfigMap = {
565
+ [ViewType.Week]: 'weekResourceTableWidth',
566
+ [ViewType.Day]: 'dayResourceTableWidth',
567
+ [ViewType.Month]: 'monthResourceTableWidth',
568
+ [ViewType.Year]: 'yearResourceTableWidth',
569
+ [ViewType.Quarter]: 'quarterResourceTableWidth'
570
+ };
571
+ const configProperty = viewConfigMap[this.viewType] || 'customResourceTableWidth';
572
+ return this.config[configProperty];
573
+ }
574
+ getContentCellConfigWidth() {
575
+ const viewConfigMap = {
576
+ [ViewType.Week]: 'weekCellWidth',
577
+ [ViewType.Day]: 'dayCellWidth',
578
+ [ViewType.Month]: 'monthCellWidth',
579
+ [ViewType.Year]: 'yearCellWidth',
580
+ [ViewType.Quarter]: 'quarterCellWidth'
581
+ };
582
+ const configProperty = viewConfigMap[this.viewType] || 'customCellWidth';
583
+ return this.config[configProperty];
584
+ }
585
+ _setDocumentWidth(documentWidth) {
586
+ if (documentWidth >= 0 && documentWidth !== this.documentWidth) {
587
+ this.documentWidth = documentWidth;
588
+ this.bumpVersion();
697
589
  }
698
- }, {
699
- key: "getResourceTableConfigWidth",
700
- value: function getResourceTableConfigWidth() {
701
- if (this.showAgenda) {
702
- return this.config.agendaResourceTableWidth;
703
- }
704
- var viewConfigMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, _default.ViewType.Week, 'weekResourceTableWidth'), _default.ViewType.Day, 'dayResourceTableWidth'), _default.ViewType.Month, 'monthResourceTableWidth'), _default.ViewType.Year, 'yearResourceTableWidth'), _default.ViewType.Quarter, 'quarterResourceTableWidth');
705
- var configProperty = viewConfigMap[this.viewType] || 'customResourceTableWidth';
706
- return this.config[configProperty];
590
+ }
591
+ _setDocumentHeight(documentHeight) {
592
+ if (documentHeight >= 0 && documentHeight !== this.documentHeight) {
593
+ this.documentHeight = documentHeight;
594
+ this.bumpVersion();
707
595
  }
708
- }, {
709
- key: "getContentCellConfigWidth",
710
- value: function getContentCellConfigWidth() {
711
- var viewConfigMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, _default.ViewType.Week, 'weekCellWidth'), _default.ViewType.Day, 'dayCellWidth'), _default.ViewType.Month, 'monthCellWidth'), _default.ViewType.Year, 'yearCellWidth'), _default.ViewType.Quarter, 'quarterCellWidth');
712
- var configProperty = viewConfigMap[this.viewType] || 'customCellWidth';
713
- return this.config[configProperty];
596
+ }
597
+ _setSchedulerHeaderHeight(schedulerHeaderHeight) {
598
+ if (schedulerHeaderHeight >= 0 && schedulerHeaderHeight !== this.schedulerHeaderHeight) {
599
+ this.schedulerHeaderHeight = schedulerHeaderHeight;
600
+ this.bumpVersion();
714
601
  }
715
- }, {
716
- key: "_setDocumentWidth",
717
- value: function _setDocumentWidth(documentWidth) {
718
- if (documentWidth >= 0 && documentWidth !== this.documentWidth) {
719
- this.documentWidth = documentWidth;
720
- this.bumpVersion();
602
+ }
603
+ _detachEvent(event) {
604
+ const index = this.events.indexOf(event);
605
+ if (index !== -1) this.events.splice(index, 1);
606
+ }
607
+ _attachEvent(event) {
608
+ let pos = 0;
609
+ const eventStart = this.localeDayjs(new Date(event.start));
610
+ this.events.forEach((item, index) => {
611
+ const start = this.localeDayjs(new Date(item.start));
612
+ if (eventStart >= start) pos = index + 1;
613
+ });
614
+ this.events.splice(pos, 0, event);
615
+ }
616
+ _handleRecurringEvents() {
617
+ const recurringEvents = this.events.filter(x => !!x.rrule);
618
+ recurringEvents.forEach(item => {
619
+ this._detachEvent(item);
620
+ });
621
+ recurringEvents.forEach(item => {
622
+ const windowStart = this.startDate;
623
+ const windowEnd = this.endDate.add(1, 'days');
624
+ const oldStart = this.localeDayjs(new Date(item.start));
625
+ const oldEnd = this.localeDayjs(new Date(item.end));
626
+ let rule = rrulestr(item.rrule);
627
+ let oldDtstart;
628
+ const oldUntil = rule.origOptions.until || windowEnd.toDate();
629
+ if (rule.origOptions.dtstart) {
630
+ oldDtstart = this.localeDayjs(new Date(rule.origOptions.dtstart));
721
631
  }
722
- }
723
- }, {
724
- key: "_setDocumentHeight",
725
- value: function _setDocumentHeight(documentHeight) {
726
- if (documentHeight >= 0 && documentHeight !== this.documentHeight) {
727
- this.documentHeight = documentHeight;
728
- this.bumpVersion();
632
+ // rule.origOptions.dtstart = oldStart.toDate();
633
+ if (windowEnd < oldUntil) {
634
+ rule.origOptions.until = windowEnd.toDate();
729
635
  }
730
- }
731
- }, {
732
- key: "_setSchedulerHeaderHeight",
733
- value: function _setSchedulerHeaderHeight(schedulerHeaderHeight) {
734
- if (schedulerHeaderHeight >= 0 && schedulerHeaderHeight !== this.schedulerHeaderHeight) {
735
- this.schedulerHeaderHeight = schedulerHeaderHeight;
736
- this.bumpVersion();
636
+
637
+ // reload
638
+ rule = rrulestr(rule.toString());
639
+ if (item.exdates || item.exrule) {
640
+ const rruleSet = new RRuleSet();
641
+ rruleSet.rrule(rule);
642
+ if (item.exrule) {
643
+ rruleSet.exrule(rrulestr(item.exrule));
644
+ }
645
+ if (item.exdates) {
646
+ item.exdates.forEach(exdate => {
647
+ rruleSet.exdate(this.localeDayjs(exdate).toDate());
648
+ });
649
+ }
650
+ rule = rruleSet;
737
651
  }
738
- }
739
- }, {
740
- key: "_detachEvent",
741
- value: function _detachEvent(event) {
742
- var index = this.events.indexOf(event);
743
- if (index !== -1) this.events.splice(index, 1);
744
- }
745
- }, {
746
- key: "_attachEvent",
747
- value: function _attachEvent(event) {
748
- var _this = this;
749
- var pos = 0;
750
- var eventStart = this.localeDayjs(new Date(event.start));
751
- this.events.forEach(function (item, index) {
752
- var start = _this.localeDayjs(new Date(item.start));
753
- if (eventStart >= start) pos = index + 1;
754
- });
755
- this.events.splice(pos, 0, event);
756
- }
757
- }, {
758
- key: "_handleRecurringEvents",
759
- value: function _handleRecurringEvents() {
760
- var _this2 = this;
761
- var recurringEvents = this.events.filter(function (x) {
762
- return !!x.rrule;
763
- });
764
- recurringEvents.forEach(function (item) {
765
- _this2._detachEvent(item);
766
- });
767
- recurringEvents.forEach(function (item) {
768
- var windowStart = _this2.startDate;
769
- var windowEnd = _this2.endDate.add(1, 'days');
770
- var oldStart = _this2.localeDayjs(new Date(item.start));
771
- var oldEnd = _this2.localeDayjs(new Date(item.end));
772
- var rule = (0, _rrule.rrulestr)(item.rrule);
773
- var oldDtstart;
774
- var oldUntil = rule.origOptions.until || windowEnd.toDate();
775
- if (rule.origOptions.dtstart) {
776
- oldDtstart = _this2.localeDayjs(new Date(rule.origOptions.dtstart));
652
+ const all = rule.between(new Date(windowStart), new Date(windowEnd));
653
+ all.forEach((time, index) => {
654
+ const newEvent = {
655
+ ...item,
656
+ recurringEventId: item.id,
657
+ recurringEventStart: item.start,
658
+ recurringEventEnd: item.end,
659
+ id: `${item.id}-${index}`,
660
+ start: rule.origOptions.tzid ? this.localeDayjs.utc(time).utcOffset(this.localeDayjs(new Date()).utcOffset(), true).format(DATETIME_FORMAT) : this.localeDayjs(new Date(time)).format(DATETIME_FORMAT),
661
+ end: rule.origOptions.tzid ? this.localeDayjs.utc(time).utcOffset(this.localeDayjs(new Date()).utcOffset(), true).add(oldEnd.diff(oldStart), 'ms').add(this.localeDayjs(new Date(oldUntil)).utcOffset() - this.localeDayjs(new Date(item.start)).utcOffset(), 'm').format(DATETIME_FORMAT) : this.localeDayjs(new Date(time)).add(oldEnd.diff(oldStart), 'ms').format(DATETIME_FORMAT)
662
+ };
663
+ const eventStart = normalizeEventStart(newEvent.start);
664
+ const eventEnd = normalizeEventEnd(newEvent.end);
665
+ if (this.isEventInTimeWindow(eventStart, eventEnd, windowStart, windowEnd) && (!oldDtstart || eventStart >= oldDtstart)) {
666
+ this._attachEvent(newEvent);
777
667
  }
778
- // rule.origOptions.dtstart = oldStart.toDate();
779
- if (windowEnd < oldUntil) {
780
- rule.origOptions.until = windowEnd.toDate();
668
+ });
669
+ });
670
+ }
671
+ _resolveDate(num, date = undefined) {
672
+ if (date !== undefined) {
673
+ this.selectDate = this.localeDayjs(date);
674
+ }
675
+ const setStartAndEndDates = unit => {
676
+ this.startDate = date !== undefined ? this.selectDate.startOf(unit) : this.startDate.add(num, `${unit}s`);
677
+ this.endDate = this.startDate.endOf(unit);
678
+ };
679
+ switch (this.viewType) {
680
+ case ViewType.Week:
681
+ if (date !== undefined) {
682
+ this.startDate = this.selectDate.startOf('isoWeek');
683
+ } else {
684
+ this.startDate = this.startDate.add(num, 'weeks');
781
685
  }
782
-
783
- // reload
784
- rule = (0, _rrule.rrulestr)(rule.toString());
785
- if (item.exdates || item.exrule) {
786
- var rruleSet = new _rrule.RRuleSet();
787
- rruleSet.rrule(rule);
788
- if (item.exrule) {
789
- rruleSet.exrule((0, _rrule.rrulestr)(item.exrule));
686
+ this.endDate = this.startDate.endOf('isoWeek');
687
+ break;
688
+ case ViewType.Day:
689
+ this.startDate = (date !== undefined ? this.selectDate : this.startDate.add(num, 'days')).startOf('day');
690
+ this.endDate = this.startDate;
691
+ break;
692
+ case ViewType.Month:
693
+ setStartAndEndDates('month');
694
+ break;
695
+ case ViewType.Quarter:
696
+ setStartAndEndDates('quarter');
697
+ break;
698
+ case ViewType.Year:
699
+ setStartAndEndDates('year');
700
+ break;
701
+ case ViewType.Custom:
702
+ case ViewType.Custom1:
703
+ case ViewType.Custom2:
704
+ if (this.behaviors.getCustomDateFunc !== undefined) {
705
+ const customDate = this.behaviors.getCustomDateFunc(this, num, date);
706
+ this.startDate = this.localeDayjs(customDate.startDate);
707
+ this.endDate = this.localeDayjs(customDate.endDate);
708
+ if (customDate.cellUnit) {
709
+ this.cellUnit = customDate.cellUnit;
790
710
  }
791
- if (item.exdates) {
792
- item.exdates.forEach(function (exdate) {
793
- rruleSet.exdate(_this2.localeDayjs(exdate).toDate());
794
- });
795
- }
796
- rule = rruleSet;
711
+ } else {
712
+ throw new Error('This is a custom view type, set behaviors.getCustomDateFunc func ' + 'to resolve the time window (startDate and endDate) yourself');
797
713
  }
798
- var all = rule.between(new Date(windowStart), new Date(windowEnd));
799
- all.forEach(function (time, index) {
800
- var newEvent = _objectSpread(_objectSpread({}, item), {}, {
801
- recurringEventId: item.id,
802
- recurringEventStart: item.start,
803
- recurringEventEnd: item.end,
804
- id: "".concat(item.id, "-").concat(index),
805
- start: rule.origOptions.tzid ? _this2.localeDayjs.utc(time).utcOffset(_this2.localeDayjs(new Date()).utcOffset(), true).format(_default.DATETIME_FORMAT) : _this2.localeDayjs(new Date(time)).format(_default.DATETIME_FORMAT),
806
- end: rule.origOptions.tzid ? _this2.localeDayjs.utc(time).utcOffset(_this2.localeDayjs(new Date()).utcOffset(), true).add(oldEnd.diff(oldStart), 'ms').add(_this2.localeDayjs(new Date(oldUntil)).utcOffset() - _this2.localeDayjs(new Date(item.start)).utcOffset(), 'm').format(_default.DATETIME_FORMAT) : _this2.localeDayjs(new Date(time)).add(oldEnd.diff(oldStart), 'ms').format(_default.DATETIME_FORMAT)
807
- });
808
- var eventStart = _this2.localeDayjs(newEvent.start);
809
- var eventEnd = _this2.localeDayjs(newEvent.end);
810
- if (_this2.isEventInTimeWindow(eventStart, eventEnd, windowStart, windowEnd) && (!oldDtstart || eventStart >= oldDtstart)) {
811
- _this2._attachEvent(newEvent);
812
- }
813
- });
814
- });
714
+ break;
715
+ default:
716
+ break;
815
717
  }
816
- }, {
817
- key: "_resolveDate",
818
- value: function _resolveDate(num) {
819
- var _this3 = this;
820
- var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
821
- if (date !== undefined) {
822
- this.selectDate = this.localeDayjs(date);
718
+ }
719
+
720
+ // Previous Code
721
+ _createHeaders() {
722
+ const headers = [];
723
+ let start = this.localeDayjs(new Date(this.startDate));
724
+ let end = this.localeDayjs(new Date(this.endDate));
725
+ let header = start;
726
+ if (this.showAgenda) {
727
+ headers.push({
728
+ time: header.format(DATETIME_FORMAT),
729
+ nonWorkingTime: false
730
+ });
731
+ } else if (this.cellUnit === CellUnit.Hour) {
732
+ if (start.hour() === 0) {
733
+ start = start.hour(this.config.dayStartFrom);
823
734
  }
824
- var setStartAndEndDates = function setStartAndEndDates(unit) {
825
- _this3.startDate = date !== undefined ? _this3.selectDate.startOf(unit) : _this3.startDate.add(num, "".concat(unit, "s"));
826
- _this3.endDate = _this3.startDate.endOf(unit);
827
- };
828
- switch (this.viewType) {
829
- case _default.ViewType.Week:
830
- if (date !== undefined) {
831
- this.startDate = this.selectDate.startOf('isoWeek');
832
- } else {
833
- this.startDate = this.startDate.add(num, 'weeks');
834
- }
835
- this.endDate = this.startDate.endOf('isoWeek');
836
- break;
837
- case _default.ViewType.Day:
838
- this.startDate = date !== undefined ? this.selectDate : this.startDate.add(num, 'days');
839
- this.endDate = this.startDate;
840
- break;
841
- case _default.ViewType.Month:
842
- setStartAndEndDates('month');
843
- break;
844
- case _default.ViewType.Quarter:
845
- setStartAndEndDates('quarter');
846
- break;
847
- case _default.ViewType.Year:
848
- setStartAndEndDates('year');
849
- break;
850
- case _default.ViewType.Custom:
851
- case _default.ViewType.Custom1:
852
- case _default.ViewType.Custom2:
853
- if (this.behaviors.getCustomDateFunc !== undefined) {
854
- var customDate = this.behaviors.getCustomDateFunc(this, num, date);
855
- this.startDate = this.localeDayjs(customDate.startDate);
856
- this.endDate = this.localeDayjs(customDate.endDate);
857
- if (customDate.cellUnit) {
858
- this.cellUnit = customDate.cellUnit;
859
- }
860
- } else {
861
- throw new Error('This is a custom view type, set behaviors.getCustomDateFunc func ' + 'to resolve the time window (startDate and endDate) yourself');
862
- }
863
- break;
864
- default:
865
- break;
735
+ if (end.hour() === 0) {
736
+ end = end.hour(this.config.dayStopTo);
866
737
  }
867
- }
868
-
869
- // Previous Code
870
- }, {
871
- key: "_createHeaders",
872
- value: function _createHeaders() {
873
- var headers = [];
874
- var start = this.localeDayjs(new Date(this.startDate));
875
- var end = this.localeDayjs(new Date(this.endDate));
876
- var header = start;
877
- if (this.showAgenda) {
878
- headers.push({
879
- time: header.format(_default.DATETIME_FORMAT),
880
- nonWorkingTime: false
881
- });
882
- } else if (this.cellUnit === _default.CellUnit.Hour) {
883
- if (start.hour() === 0) {
884
- start = start.add(this.config.dayStartFrom, 'hours');
885
- }
886
- if (end.hour() === 0) {
887
- end = end.add(this.config.dayStopTo, 'hours');
888
- }
889
- header = start;
890
- var prevHour = -1;
891
- while (header >= start && header <= end) {
892
- // prevent doubled hours on time change
893
- if (header.hour() === prevHour) {
894
- header = header.add(1, 'hours');
895
- continue;
896
- }
897
- prevHour = header.hour();
898
- var minuteSteps = this.getMinuteStepsInHour();
899
- for (var i = 0; i < minuteSteps; i += 1) {
900
- var hour = header.hour();
901
- if (hour >= this.config.dayStartFrom && hour <= this.config.dayStopTo) {
902
- var time = header.format(_default.DATETIME_FORMAT);
903
- var nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, time);
904
- headers.push({
905
- time: time,
906
- nonWorkingTime: nonWorkingTime
907
- });
908
- }
909
- header = header.add(this.config.minuteStep, 'minutes');
910
- }
738
+ header = start;
739
+ let prevHour = -1;
740
+ while (header >= start && header <= end) {
741
+ // prevent doubled hours on time change
742
+ if (header.hour() === prevHour) {
743
+ header = header.add(1, 'hours');
744
+ continue;
911
745
  }
912
- } else if (this.cellUnit === _default.CellUnit.Day) {
913
- while (header >= start && header <= end) {
914
- var _time = header.format(_default.DATETIME_FORMAT);
915
- var dayOfWeek = header.day();
916
- if (this.config.displayWeekend || dayOfWeek !== 0 && dayOfWeek !== 6) {
917
- var _nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, _time);
746
+ prevHour = header.hour();
747
+ const minuteSteps = this.getMinuteStepsInHour();
748
+ for (let i = 0; i < minuteSteps; i += 1) {
749
+ const hour = header.hour();
750
+ if (hour >= this.config.dayStartFrom && hour <= this.config.dayStopTo) {
751
+ const time = header.format(DATETIME_FORMAT);
752
+ const nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, time);
918
753
  headers.push({
919
- time: _time,
920
- nonWorkingTime: _nonWorkingTime
754
+ time,
755
+ nonWorkingTime
921
756
  });
922
757
  }
923
- header = header.add(1, 'days');
924
- }
925
- } else if (this.cellUnit === _default.CellUnit.Week) {
926
- while (header >= start && header <= end) {
927
- var _time2 = header.format(_default.DATE_FORMAT);
928
- headers.push({
929
- time: _time2
930
- });
931
- header = header.add(1, 'weeks').startOf('isoWeek');
932
- }
933
- } else if (this.cellUnit === _default.CellUnit.Month) {
934
- while (header >= start && header <= end) {
935
- var _time3 = header.format(_default.DATE_FORMAT);
936
- headers.push({
937
- time: _time3
938
- });
939
- header = header.add(1, 'months').startOf('month');
758
+ header = header.add(this.config.minuteStep, 'minutes');
940
759
  }
941
- } else if (this.cellUnit === _default.CellUnit.Year) {
942
- while (header >= start && header <= end) {
943
- var _time4 = header.format(_default.DATE_FORMAT);
760
+ }
761
+ } else if (this.cellUnit === CellUnit.Day) {
762
+ while (header >= start && header <= end) {
763
+ const time = header.format(DATETIME_FORMAT);
764
+ const dayOfWeek = header.day();
765
+ if (this.config.displayWeekend || dayOfWeek !== 0 && dayOfWeek !== 6) {
766
+ const nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, time);
944
767
  headers.push({
945
- time: _time4
768
+ time,
769
+ nonWorkingTime
946
770
  });
947
- header = header.add(1, 'years').startOf('year');
948
771
  }
772
+ header = header.add(1, 'days');
949
773
  }
950
- this.headers = headers;
951
- }
952
- }, {
953
- key: "_createInitHeaderEvents",
954
- value: function _createInitHeaderEvents(header) {
955
- var start = this.localeDayjs(new Date(header.time));
956
- var startValue = start.format(_default.DATETIME_FORMAT);
957
- var endValue;
958
- if (this.showAgenda) {
959
- var incrementUnit = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, _default.ViewType.Day, 'days'), _default.ViewType.Week, 'weeks'), _default.ViewType.Month, 'months'), _default.ViewType.Year, 'years'), _default.ViewType.Quarter, 'quarters')[this.viewType] || 'days';
960
- if (incrementUnit === 'days') {
961
- endValue = this.localeDayjs(new Date(this.endDate)).add(1, 'days').format(_default.DATETIME_FORMAT);
962
- } else {
963
- endValue = start.add(1, incrementUnit).format(_default.DATETIME_FORMAT);
964
- }
965
- } else {
966
- var _incrementUnit = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, _default.CellUnit.Hour, 'minutes'), _default.CellUnit.Week, 'weeks'), _default.CellUnit.Month, 'months'), _default.CellUnit.Year, 'years')[this.cellUnit] || 'days';
967
- endValue = start.add(_incrementUnit === 'minutes' ? this.config.minuteStep : 1, _incrementUnit).format(this.cellUnit === _default.CellUnit.Year || this.cellUnit === _default.CellUnit.Month || this.cellUnit === _default.CellUnit.Week ? _default.DATE_FORMAT : _default.DATETIME_FORMAT);
774
+ } else if (this.cellUnit === CellUnit.Week) {
775
+ while (header >= start && header <= end) {
776
+ const time = header.format(DATE_FORMAT);
777
+ headers.push({
778
+ time
779
+ });
780
+ header = header.add(1, 'weeks').startOf('isoWeek');
968
781
  }
969
- return {
970
- time: header.time,
971
- nonWorkingTime: header.nonWorkingTime,
972
- start: startValue,
973
- end: endValue,
974
- count: 0,
975
- addMore: 0,
976
- addMoreIndex: 0,
977
- events: Array(3)
978
- };
979
- }
980
- }, {
981
- key: "_createHeaderEvent",
982
- value: function _createHeaderEvent(render, span, eventItem) {
983
- return {
984
- render: render,
985
- span: span,
986
- eventItem: eventItem
987
- };
988
- }
989
- }, {
990
- key: "_getEventSlotId",
991
- value: function _getEventSlotId(event) {
992
- if (this.isEventPerspective) {
993
- return this._getEventGroupId(event);
782
+ } else if (this.cellUnit === CellUnit.Month) {
783
+ while (header >= start && header <= end) {
784
+ const time = header.format(DATE_FORMAT);
785
+ headers.push({
786
+ time
787
+ });
788
+ header = header.add(1, 'months').startOf('month');
994
789
  }
995
- // Support for multi-resource events
996
- if (event.resourceIds && event.resourceIds.length > 0) {
997
- // For multi-resource events, return the first resourceId for backward compatibility
998
- // The rendering logic will handle showing on multiple rows
999
- return event.resourceIds[0];
790
+ } else if (this.cellUnit === CellUnit.Year) {
791
+ while (header >= start && header <= end) {
792
+ const time = header.format(DATE_FORMAT);
793
+ headers.push({
794
+ time
795
+ });
796
+ header = header.add(1, 'years').startOf('year');
1000
797
  }
1001
- // Fallback to single resourceId
1002
- return event.resourceId;
1003
- }
1004
- }, {
1005
- key: "_getEventGroupId",
1006
- value: function _getEventGroupId(event) {
1007
- return event.groupId ? event.groupId.toString() : event.id.toString();
1008
- }
1009
- }, {
1010
- key: "_getEventGroupName",
1011
- value: function _getEventGroupName(event) {
1012
- return event.groupName ? event.groupName : event.title;
1013
- }
1014
- }, {
1015
- key: "_generateEventGroups",
1016
- value: function _generateEventGroups() {
1017
- var _this4 = this;
1018
- var eventGroups = [];
1019
- var set = new Set();
1020
- this.events.forEach(function (item) {
1021
- var groupId = _this4._getEventGroupId(item);
1022
- var groupName = _this4._getEventGroupName(item);
1023
- if (!set.has(groupId)) {
1024
- eventGroups.push({
1025
- id: groupId,
1026
- name: groupName,
1027
- state: item
1028
- });
1029
- set.add(groupId);
1030
- }
1031
- });
1032
- this.eventGroups = eventGroups;
1033
798
  }
1034
- }, {
1035
- key: "_createInitRenderData",
1036
- value: function _createInitRenderData(isEventPerspective, eventGroups, resources, headers) {
1037
- var _this5 = this;
1038
- var slots = isEventPerspective ? eventGroups : resources;
1039
- var slotTree = [];
1040
- var slotMap = new Map();
1041
- slots.forEach(function (slot) {
1042
- var headerEvents = headers.map(function (header) {
1043
- return _this5._createInitHeaderEvents(header);
1044
- });
1045
- var slotRenderData = _objectSpread(_objectSpread({}, slot), {}, {
1046
- slotId: slot.id,
1047
- slotName: slot.name,
1048
- slotTitle: slot.title,
1049
- parentId: slot.parentId,
1050
- groupOnly: slot.groupOnly,
1051
- hasSummary: false,
1052
- rowMaxCount: 0,
1053
- rowHeight: _this5.config.nonAgendaSlotMinHeight !== 0 ? _this5.config.nonAgendaSlotMinHeight : _this5.config.eventItemLineHeight + 2,
1054
- headerItems: headerEvents,
1055
- indent: 0,
1056
- hasChildren: false,
1057
- expanded: true,
1058
- render: true
799
+ this.headers = headers;
800
+ }
801
+ _createInitHeaderEvents(header) {
802
+ const start = this.localeDayjs(new Date(header.time));
803
+ const startValue = start.format(DATETIME_FORMAT);
804
+ let endValue;
805
+ if (this.showAgenda) {
806
+ const incrementUnit = {
807
+ [ViewType.Day]: 'days',
808
+ [ViewType.Week]: 'weeks',
809
+ [ViewType.Month]: 'months',
810
+ [ViewType.Year]: 'years',
811
+ [ViewType.Quarter]: 'quarters'
812
+ }[this.viewType] || 'days';
813
+ if (incrementUnit === 'days') {
814
+ endValue = this.localeDayjs(new Date(this.endDate)).add(1, 'days').format(DATETIME_FORMAT);
815
+ } else {
816
+ endValue = start.add(1, incrementUnit).format(DATETIME_FORMAT);
817
+ }
818
+ } else {
819
+ const {
820
+ amount,
821
+ unit
822
+ } = this._getCellStep();
823
+
824
+ // Keep the full timestamp so cell bounds match _getSpan/normalizeEventEnd in every time zone.
825
+ endValue = start.add(amount, unit).format(DATETIME_FORMAT);
826
+ }
827
+ return {
828
+ time: header.time,
829
+ nonWorkingTime: header.nonWorkingTime,
830
+ start: startValue,
831
+ end: endValue,
832
+ count: 0,
833
+ addMore: 0,
834
+ addMoreIndex: 0,
835
+ events: Array(3)
836
+ };
837
+ }
838
+ _createHeaderEvent(render, span, eventItem) {
839
+ return {
840
+ render,
841
+ span,
842
+ eventItem
843
+ };
844
+ }
845
+ _getEventSlotId(event) {
846
+ if (this.isEventPerspective) {
847
+ return this._getEventGroupId(event);
848
+ }
849
+ // Support for multi-resource events
850
+ if (event.resourceIds && event.resourceIds.length > 0) {
851
+ // For multi-resource events, return the first resourceId for backward compatibility
852
+ // The rendering logic will handle showing on multiple rows
853
+ return event.resourceIds[0];
854
+ }
855
+ // Fallback to single resourceId
856
+ return event.resourceId;
857
+ }
858
+ _getEventGroupId(event) {
859
+ return event.groupId ? event.groupId.toString() : event.id.toString();
860
+ }
861
+ _getEventGroupName(event) {
862
+ return event.groupName ? event.groupName : event.title;
863
+ }
864
+ _generateEventGroups() {
865
+ const eventGroups = [];
866
+ const set = new Set();
867
+ this.events.forEach(item => {
868
+ const groupId = this._getEventGroupId(item);
869
+ const groupName = this._getEventGroupName(item);
870
+ if (!set.has(groupId)) {
871
+ eventGroups.push({
872
+ id: groupId,
873
+ name: groupName,
874
+ state: item
1059
875
  });
1060
- var id = slot.id;
1061
- var value;
1062
- if (slotMap.has(id)) {
1063
- value = slotMap.get(id);
1064
- value.data = slotRenderData;
876
+ set.add(groupId);
877
+ }
878
+ });
879
+ this.eventGroups = eventGroups;
880
+ }
881
+ _createInitRenderData(isEventPerspective, eventGroups, resources, headers) {
882
+ const slots = isEventPerspective ? eventGroups : resources;
883
+ const slotTree = [];
884
+ const slotMap = new Map();
885
+ slots.forEach(slot => {
886
+ const headerEvents = headers.map(header => this._createInitHeaderEvents(header));
887
+ const slotRenderData = {
888
+ ...slot,
889
+ slotId: slot.id,
890
+ slotName: slot.name,
891
+ slotTitle: slot.title,
892
+ parentId: slot.parentId,
893
+ groupOnly: slot.groupOnly,
894
+ hasSummary: false,
895
+ rowMaxCount: 0,
896
+ rowHeight: this.config.nonAgendaSlotMinHeight !== 0 ? this.config.nonAgendaSlotMinHeight : this.config.eventItemLineHeight + 2,
897
+ headerItems: headerEvents,
898
+ indent: 0,
899
+ hasChildren: false,
900
+ expanded: true,
901
+ render: true
902
+ };
903
+ const {
904
+ id
905
+ } = slot;
906
+ let value;
907
+ if (slotMap.has(id)) {
908
+ value = slotMap.get(id);
909
+ value.data = slotRenderData;
910
+ } else {
911
+ value = {
912
+ data: slotRenderData,
913
+ children: []
914
+ };
915
+ slotMap.set(id, value);
916
+ }
917
+ const {
918
+ parentId
919
+ } = slot;
920
+ if (!parentId || parentId === id) {
921
+ slotTree.push(value);
922
+ } else {
923
+ let parentValue;
924
+ if (slotMap.has(parentId)) {
925
+ parentValue = slotMap.get(parentId);
1065
926
  } else {
1066
- value = {
1067
- data: slotRenderData,
927
+ parentValue = {
928
+ data: undefined,
1068
929
  children: []
1069
930
  };
1070
- slotMap.set(id, value);
931
+ slotMap.set(parentId, parentValue);
1071
932
  }
1072
- var parentId = slot.parentId;
1073
- if (!parentId || parentId === id) {
1074
- slotTree.push(value);
1075
- } else {
1076
- var parentValue;
1077
- if (slotMap.has(parentId)) {
1078
- parentValue = slotMap.get(parentId);
1079
- } else {
1080
- parentValue = {
1081
- data: undefined,
1082
- children: []
1083
- };
1084
- slotMap.set(parentId, parentValue);
1085
- }
1086
- parentValue.children.push(value);
1087
- }
1088
- });
1089
- var slotStack = [];
1090
- var i;
1091
- for (i = slotTree.length - 1; i >= 0; i -= 1) {
1092
- slotStack.push(slotTree[i]);
933
+ parentValue.children.push(value);
1093
934
  }
1094
- var initRenderData = [];
1095
- var currentNode;
1096
- while (slotStack.length > 0) {
1097
- currentNode = slotStack.pop();
1098
- if (currentNode.data.indent > 0) {
1099
- currentNode.data.render = this.config.defaultExpanded;
1100
- }
1101
- if (currentNode.children.length > 0) {
1102
- currentNode.data.hasChildren = true;
1103
- currentNode.data.expanded = this.config.defaultExpanded;
1104
- }
1105
- initRenderData.push(currentNode.data);
1106
- for (i = currentNode.children.length - 1; i >= 0; i -= 1) {
1107
- currentNode.children[i].data.indent = currentNode.data.indent + 1;
1108
- slotStack.push(currentNode.children[i]);
1109
- }
935
+ });
936
+ const slotStack = [];
937
+ let i;
938
+ for (i = slotTree.length - 1; i >= 0; i -= 1) {
939
+ slotStack.push(slotTree[i]);
940
+ }
941
+ const initRenderData = [];
942
+ let currentNode;
943
+ while (slotStack.length > 0) {
944
+ currentNode = slotStack.pop();
945
+ if (currentNode.data.indent > 0) {
946
+ currentNode.data.render = this.config.defaultExpanded;
1110
947
  }
1111
- return initRenderData;
1112
- }
1113
- }, {
1114
- key: "_getSpan",
1115
- value: function _getSpan(startTime, endTime, headers) {
1116
- if (this.showAgenda) return 1;
1117
- var timeBetween = function timeBetween(date1, date2, timeIn) {
1118
- if (timeIn === 'days' || timeIn === 'day') {
1119
- if (date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear()) {
1120
- return 1;
1121
- }
1122
- }
1123
- var one;
1124
- switch (timeIn) {
1125
- case 'days':
1126
- case 'day':
1127
- one = 1000 * 60 * 60 * 24;
1128
- break;
1129
- case 'minutes':
1130
- case 'minute':
1131
- one = 1000 * 60;
1132
- break;
1133
- default:
1134
- return 0;
1135
- }
1136
- var date1Ms = date1.getTime();
1137
- var date2Ms = date2.getTime();
1138
- var diff = (date2Ms - date1Ms) / one;
1139
- return diff < 0 ? 0 : diff;
1140
- };
1141
- var eventStart = new Date(startTime);
1142
- var eventEnd = new Date(endTime);
1143
- var span = 0;
1144
- var windowStart = new Date(this.startDate);
1145
- var windowEnd = new Date(this.endDate);
1146
- windowStart.setHours(0, 0, 0, 0);
1147
- windowEnd.setHours(23, 59, 59);
1148
- if (this.viewType === _default.ViewType.Day) {
1149
- if (headers.length > 0) {
1150
- var day = new Date(headers[0].time);
1151
- if (day.getDate() > eventStart.getDate() && day.getDate() < eventEnd.getDate()) {
1152
- span = 1440 / this.config.minuteStep;
1153
- } else if (day.getDate() > eventStart.getDate() && day.getDate() === eventEnd.getDate()) {
1154
- span = Math.ceil(timeBetween(day, eventEnd, 'minutes') / this.config.minuteStep);
1155
- } else if (day.getDate() === eventStart.getDate() && day.getDate() < eventEnd.getDate()) {
1156
- day.setHours(23, 59, 59);
1157
- span = Math.ceil(timeBetween(eventStart, day, 'minutes') / this.config.minuteStep);
1158
- } else if (day.getDate() === eventStart.getDate() && day.getDate() === eventEnd.getDate() || eventEnd.getDate() === eventStart.getDate()) {
1159
- span = Math.ceil(timeBetween(eventStart, eventEnd, 'minutes') / this.config.minuteStep);
1160
- }
1161
- }
1162
- } else if (this.viewType === _default.ViewType.Week || this.viewType === _default.ViewType.Month || this.viewType === _default.ViewType.Quarter || this.viewType === _default.ViewType.Year) {
1163
- var startDate = windowStart < eventStart ? eventStart : windowStart;
1164
- var endDate = windowEnd > eventEnd ? eventEnd : windowEnd;
1165
- startDate.setHours(0, 0, 0, 0);
1166
- // Only extend to end-of-day if the event does not end exactly at midnight
1167
- // (midnight = start of the day, treated as exclusive by the header-item check)
1168
- if (endDate.getHours() !== 0 || endDate.getMinutes() !== 0 || endDate.getSeconds() !== 0) {
1169
- endDate.setHours(23, 59, 59, 0);
1170
- } else {
1171
- endDate.setDate(endDate.getDate() - 1);
1172
- endDate.setHours(23, 59, 59, 0);
1173
- }
1174
- span = Math.ceil(timeBetween(startDate, endDate, 'days'));
1175
- } else {
1176
- if (this.cellUnit === _default.CellUnit.Day) {
1177
- eventEnd.setHours(23, 59, 59);
1178
- eventStart.setHours(0, 0, 0, 0);
1179
- }
1180
- var timeIn = this.cellUnit === _default.CellUnit.Day ? 'days' : 'minutes';
1181
- var dividedBy = this.cellUnit === _default.CellUnit.Day ? 1 : this.config.minuteStep;
1182
- if (windowStart >= eventStart && eventEnd <= windowEnd) {
1183
- span = Math.ceil(timeBetween(windowStart, eventEnd, timeIn) / dividedBy);
1184
- } else if (windowStart > eventStart && eventEnd > windowEnd) {
1185
- span = Math.ceil(timeBetween(windowStart, windowEnd, timeIn) / dividedBy);
1186
- } else if (windowStart <= eventStart && eventEnd >= windowEnd) {
1187
- span = Math.ceil(timeBetween(eventStart, windowEnd, timeIn) / dividedBy);
1188
- } else {
1189
- span = Math.ceil(timeBetween(eventStart, eventEnd, timeIn) / dividedBy);
1190
- }
948
+ if (currentNode.children.length > 0) {
949
+ currentNode.data.hasChildren = true;
950
+ currentNode.data.expanded = this.config.defaultExpanded;
1191
951
  }
1192
- return span;
1193
- }
1194
- }, {
1195
- key: "_validateResource",
1196
- value: function _validateResource(resources) {
1197
- if (Object.prototype.toString.call(resources) !== '[object Array]') {
1198
- throw new Error('Resources should be Array object');
952
+ initRenderData.push(currentNode.data);
953
+ for (i = currentNode.children.length - 1; i >= 0; i -= 1) {
954
+ currentNode.children[i].data.indent = currentNode.data.indent + 1;
955
+ slotStack.push(currentNode.children[i]);
1199
956
  }
1200
- resources.forEach(function (item, index) {
1201
- if (item === undefined) {
1202
- console.error("Resource undefined: ".concat(index));
1203
- throw new Error("Resource undefined: ".concat(index));
1204
- }
1205
- if (item.id === undefined || item.name === undefined) {
1206
- console.error('Resource property missed', index, item);
1207
- throw new Error("Resource property undefined: ".concat(index));
1208
- }
1209
- });
1210
957
  }
1211
- }, {
1212
- key: "_validateEventGroups",
1213
- value: function _validateEventGroups(eventGroups) {
1214
- if (Object.prototype.toString.call(eventGroups) !== '[object Array]') {
1215
- throw new Error('Event groups should be Array object');
958
+ return initRenderData;
959
+ }
960
+ _getCellStep() {
961
+ const unit = {
962
+ [CellUnit.Hour]: 'minutes',
963
+ [CellUnit.Week]: 'weeks',
964
+ [CellUnit.Month]: 'months',
965
+ [CellUnit.Year]: 'years'
966
+ }[this.cellUnit] || 'days';
967
+ return {
968
+ amount: unit === 'minutes' ? this.config.minuteStep : 1,
969
+ unit
970
+ };
971
+ }
972
+
973
+ // Span = number of visible header cells the event overlaps, using the same overlap rule as
974
+ // _createRenderData. Headers only cover the visible window (and visible days), so the event is
975
+ // clamped consistently across views, and calendar-aware dayjs math keeps DST days at one cell.
976
+ _getSpan(startTime, endTime, headers) {
977
+ if (this.showAgenda) return 1;
978
+ const eventStart = normalizeEventStart(startTime);
979
+ const eventEnd = normalizeEventEnd(endTime);
980
+ const {
981
+ amount,
982
+ unit
983
+ } = this._getCellStep();
984
+ return headers.filter(header => {
985
+ const cellStart = this.localeDayjs(new Date(header.time));
986
+ return cellStart.isBefore(eventEnd) && cellStart.add(amount, unit).isAfter(eventStart);
987
+ }).length;
988
+ }
989
+ _validateResource(resources) {
990
+ if (Object.prototype.toString.call(resources) !== '[object Array]') {
991
+ throw new Error('Resources should be Array object');
992
+ }
993
+ resources.forEach((item, index) => {
994
+ if (item === undefined) {
995
+ console.error(`Resource undefined: ${index}`);
996
+ throw new Error(`Resource undefined: ${index}`);
1216
997
  }
1217
- eventGroups.forEach(function (item, index) {
1218
- if (item === undefined) {
1219
- console.error("Event group undefined: ".concat(index));
1220
- throw new Error("Event group undefined: ".concat(index));
1221
- }
1222
- if (item.id === undefined || item.name === undefined) {
1223
- console.error('Event group property missed', index, item);
1224
- throw new Error("Event group property undefined: ".concat(index));
1225
- }
1226
- });
1227
- }
1228
- }, {
1229
- key: "_validateEvents",
1230
- value: function _validateEvents(events) {
1231
- if (Object.prototype.toString.call(events) !== '[object Array]') {
1232
- throw new Error('Events should be Array object');
998
+ if (item.id === undefined || item.name === undefined) {
999
+ console.error('Resource property missed', index, item);
1000
+ throw new Error(`Resource property undefined: ${index}`);
1233
1001
  }
1234
- events.forEach(function (e, index) {
1235
- if (e === undefined) {
1236
- console.error("Event undefined: ".concat(index));
1237
- throw new Error("Event undefined: ".concat(index));
1238
- }
1239
- var hasResourceTarget = e.resourceId !== undefined || Array.isArray(e.resourceIds) && e.resourceIds.length > 0;
1240
- if (e.id === undefined || !hasResourceTarget || e.title === undefined || e.start === undefined || e.end === undefined) {
1241
- console.error('Event property missed (id, resourceId/resourceIds, title, start, end)', index, e);
1242
- throw new Error("Event property undefined (id/resourceId|resourceIds/title/start/end): ".concat(index));
1243
- }
1244
- });
1245
- }
1246
- }, {
1247
- key: "_validateMinuteStep",
1248
- value: function _validateMinuteStep(minuteStep) {
1249
- if (60 % minuteStep !== 0) {
1250
- console.error('Minute step is not set properly - 60 minutes must be divisible without remainder by this number');
1251
- throw new Error('Minute step is not set properly - 60 minutes must be divisible without remainder by this number');
1002
+ });
1003
+ }
1004
+ _validateEventGroups(eventGroups) {
1005
+ if (Object.prototype.toString.call(eventGroups) !== '[object Array]') {
1006
+ throw new Error('Event groups should be Array object');
1007
+ }
1008
+ eventGroups.forEach((item, index) => {
1009
+ if (item === undefined) {
1010
+ console.error(`Event group undefined: ${index}`);
1011
+ throw new Error(`Event group undefined: ${index}`);
1252
1012
  }
1013
+ if (item.id === undefined || item.name === undefined) {
1014
+ console.error('Event group property missed', index, item);
1015
+ throw new Error(`Event group property undefined: ${index}`);
1016
+ }
1017
+ });
1018
+ }
1019
+ _validateEvents(events) {
1020
+ if (Object.prototype.toString.call(events) !== '[object Array]') {
1021
+ throw new Error('Events should be Array object');
1022
+ }
1023
+ events.forEach((e, index) => {
1024
+ if (e === undefined) {
1025
+ console.error(`Event undefined: ${index}`);
1026
+ throw new Error(`Event undefined: ${index}`);
1027
+ }
1028
+ const hasResourceTarget = e.resourceId !== undefined || Array.isArray(e.resourceIds) && e.resourceIds.length > 0;
1029
+ if (e.id === undefined || !hasResourceTarget || e.title === undefined || e.start === undefined || e.end === undefined) {
1030
+ console.error('Event property missed (id, resourceId/resourceIds, title, start, end)', index, e);
1031
+ throw new Error(`Event property undefined (id/resourceId|resourceIds/title/start/end): ${index}`);
1032
+ }
1033
+ });
1034
+ }
1035
+ _validateMinuteStep(minuteStep) {
1036
+ if (60 % minuteStep !== 0) {
1037
+ console.error('Minute step is not set properly - 60 minutes must be divisible without remainder by this number');
1038
+ throw new Error('Minute step is not set properly - 60 minutes must be divisible without remainder by this number');
1253
1039
  }
1254
- }, {
1255
- key: "_compare",
1256
- value: function _compare(event1, event2) {
1257
- var start1 = this.localeDayjs(event1.start);
1258
- var start2 = this.localeDayjs(event2.start);
1259
- if (start1 !== start2) return start1 < start2 ? -1 : 1;
1260
- var end1 = this.localeDayjs(event1.end);
1261
- var end2 = this.localeDayjs(event2.end);
1262
- if (end1 !== end2) return end1 < end2 ? -1 : 1;
1263
- return event1.id < event2.id ? -1 : 1;
1264
- }
1265
- }, {
1266
- key: "_createRenderData",
1267
- value: function _createRenderData() {
1268
- var _this6 = this;
1269
- var initRenderData = this._createInitRenderData(this.isEventPerspective, this.eventGroups, this.resources, this.headers);
1270
- // this.events.sort(this._compare);
1271
- var cellMaxEventsCount = this.getCellMaxEvents();
1272
- var cellMaxEventsCountValue = 30;
1273
- this.events.forEach(function (item) {
1274
- var targetSlotIds = [];
1275
- if (_this6.isEventPerspective) {
1276
- targetSlotIds = [_this6._getEventSlotId(item)];
1277
- } else if (item.resourceIds && item.resourceIds.length > 0) {
1278
- // Multi-resource event
1279
- targetSlotIds = item.resourceIds;
1280
- } else if (item.resourceId) {
1281
- // Single resource event (backward compatibility)
1282
- targetSlotIds = [item.resourceId];
1283
- }
1284
- targetSlotIds.forEach(function (slotId) {
1285
- var resourceEventsList = initRenderData.filter(function (x) {
1286
- return x.slotId === slotId;
1287
- });
1288
- if (resourceEventsList.length > 0) {
1289
- var resourceEvents = resourceEventsList[0];
1290
- var span = _this6._getSpan(item.start, item.end, _this6.headers);
1291
- var eventStart = new Date(item.start);
1292
- var eventEnd = new Date(item.end);
1293
- var pos = -1;
1294
- resourceEvents.headerItems.forEach(function (header, index) {
1295
- var headerStart = new Date(header.start);
1296
- var headerEnd = new Date(header.end);
1297
- if (headerEnd > eventStart && headerStart < eventEnd) {
1298
- header.count += 1;
1299
- if (header.count > resourceEvents.rowMaxCount) {
1300
- resourceEvents.rowMaxCount = header.count;
1301
- var rowsCount = cellMaxEventsCount <= cellMaxEventsCountValue && resourceEvents.rowMaxCount > cellMaxEventsCount ? cellMaxEventsCount : resourceEvents.rowMaxCount;
1302
- var newRowHeight = rowsCount * _this6.config.eventItemLineHeight + (_this6.config.creatable && _this6.config.checkConflict === false ? 20 : 2);
1303
- if (newRowHeight > resourceEvents.rowHeight) resourceEvents.rowHeight = newRowHeight;
1304
- }
1305
- if (pos === -1) {
1306
- var tmp = 0;
1307
- while (header.events[tmp] !== undefined) tmp += 1;
1308
- pos = tmp;
1309
- }
1310
- var render = headerStart <= eventStart || index === 0;
1311
- if (render === false) {
1312
- var previousHeader = resourceEvents.headerItems[index - 1];
1313
- var previousHeaderStart = new Date(previousHeader.start);
1314
- var previousHeaderEnd = new Date(previousHeader.end);
1315
- if (previousHeaderEnd <= eventStart || previousHeaderStart >= eventEnd) render = true;
1316
- }
1317
- header.events[pos] = _this6._createHeaderEvent(render, span, item);
1040
+ }
1041
+ _compare(event1, event2) {
1042
+ const start1 = this.localeDayjs(event1.start);
1043
+ const start2 = this.localeDayjs(event2.start);
1044
+ if (start1 !== start2) return start1 < start2 ? -1 : 1;
1045
+ const end1 = this.localeDayjs(event1.end);
1046
+ const end2 = this.localeDayjs(event2.end);
1047
+ if (end1 !== end2) return end1 < end2 ? -1 : 1;
1048
+ return event1.id < event2.id ? -1 : 1;
1049
+ }
1050
+ _createRenderData() {
1051
+ const initRenderData = this._createInitRenderData(this.isEventPerspective, this.eventGroups, this.resources, this.headers);
1052
+ // this.events.sort(this._compare);
1053
+ const cellMaxEventsCount = this.getCellMaxEvents();
1054
+ const cellMaxEventsCountValue = 30;
1055
+ this.events.forEach(item => {
1056
+ let targetSlotIds = [];
1057
+ if (this.isEventPerspective) {
1058
+ targetSlotIds = [this._getEventSlotId(item)];
1059
+ } else if (item.resourceIds && item.resourceIds.length > 0) {
1060
+ // Multi-resource event
1061
+ targetSlotIds = item.resourceIds;
1062
+ } else if (item.resourceId) {
1063
+ // Single resource event (backward compatibility)
1064
+ targetSlotIds = [item.resourceId];
1065
+ }
1066
+ targetSlotIds.forEach(slotId => {
1067
+ const resourceEventsList = initRenderData.filter(x => x.slotId === slotId);
1068
+ if (resourceEventsList.length > 0) {
1069
+ const resourceEvents = resourceEventsList[0];
1070
+ const span = this._getSpan(item.start, item.end, this.headers);
1071
+ const eventStart = normalizeEventStart(item.start).toDate();
1072
+ const eventEnd = normalizeEventEnd(item.end).toDate();
1073
+ let pos = -1;
1074
+ resourceEvents.headerItems.forEach((header, index) => {
1075
+ const headerStart = new Date(header.start);
1076
+ const headerEnd = new Date(header.end);
1077
+ if (headerEnd > eventStart && headerStart < eventEnd) {
1078
+ header.count += 1;
1079
+ if (header.count > resourceEvents.rowMaxCount) {
1080
+ resourceEvents.rowMaxCount = header.count;
1081
+ const rowsCount = cellMaxEventsCount <= cellMaxEventsCountValue && resourceEvents.rowMaxCount > cellMaxEventsCount ? cellMaxEventsCount : resourceEvents.rowMaxCount;
1082
+ const newRowHeight = rowsCount * this.config.eventItemLineHeight + (this.config.creatable && this.config.checkConflict === false ? 20 : 2);
1083
+ if (newRowHeight > resourceEvents.rowHeight) resourceEvents.rowHeight = newRowHeight;
1318
1084
  }
1319
- });
1320
- }
1321
- });
1322
- });
1323
- if (cellMaxEventsCount <= cellMaxEventsCountValue || this.behaviors.getSummaryFunc !== undefined) {
1324
- initRenderData.forEach(function (resourceEvents) {
1325
- var hasSummary = false;
1326
- resourceEvents.headerItems.forEach(function (headerItem) {
1327
- if (cellMaxEventsCount <= cellMaxEventsCountValue) {
1328
- var renderItemsCount = 0;
1329
- var addMoreIndex = 0;
1330
- var index = 0;
1331
- while (index < cellMaxEventsCount - 1) {
1332
- if (headerItem.events[index] !== undefined) {
1333
- renderItemsCount += 1;
1334
- addMoreIndex = index + 1;
1335
- }
1336
- index += 1;
1085
+ if (pos === -1) {
1086
+ let tmp = 0;
1087
+ while (header.events[tmp] !== undefined) tmp += 1;
1088
+ pos = tmp;
1337
1089
  }
1090
+ let render = headerStart <= eventStart || index === 0;
1091
+ if (render === false) {
1092
+ const previousHeader = resourceEvents.headerItems[index - 1];
1093
+ const previousHeaderStart = new Date(previousHeader.start);
1094
+ const previousHeaderEnd = new Date(previousHeader.end);
1095
+ if (previousHeaderEnd <= eventStart || previousHeaderStart >= eventEnd) render = true;
1096
+ }
1097
+ header.events[pos] = this._createHeaderEvent(render, span, item);
1098
+ }
1099
+ });
1100
+ }
1101
+ });
1102
+ });
1103
+ if (cellMaxEventsCount <= cellMaxEventsCountValue || this.behaviors.getSummaryFunc !== undefined) {
1104
+ initRenderData.forEach(resourceEvents => {
1105
+ let hasSummary = false;
1106
+ resourceEvents.headerItems.forEach(headerItem => {
1107
+ if (cellMaxEventsCount <= cellMaxEventsCountValue) {
1108
+ let renderItemsCount = 0;
1109
+ let addMoreIndex = 0;
1110
+ let index = 0;
1111
+ while (index < cellMaxEventsCount - 1) {
1338
1112
  if (headerItem.events[index] !== undefined) {
1339
- if (renderItemsCount + 1 < headerItem.count) {
1340
- headerItem.addMore = headerItem.count - renderItemsCount;
1341
- headerItem.addMoreIndex = addMoreIndex;
1342
- }
1343
- } else if (renderItemsCount < headerItem.count) {
1113
+ renderItemsCount += 1;
1114
+ addMoreIndex = index + 1;
1115
+ }
1116
+ index += 1;
1117
+ }
1118
+ if (headerItem.events[index] !== undefined) {
1119
+ if (renderItemsCount + 1 < headerItem.count) {
1344
1120
  headerItem.addMore = headerItem.count - renderItemsCount;
1345
1121
  headerItem.addMoreIndex = addMoreIndex;
1346
1122
  }
1123
+ } else if (renderItemsCount < headerItem.count) {
1124
+ headerItem.addMore = headerItem.count - renderItemsCount;
1125
+ headerItem.addMoreIndex = addMoreIndex;
1347
1126
  }
1348
- if (_this6.behaviors.getSummaryFunc !== undefined) {
1349
- var events = [];
1350
- headerItem.events.forEach(function (e) {
1351
- if (e !== null && e !== void 0 && e.eventItem) events.push(e.eventItem);
1352
- });
1353
- headerItem.summary = _this6.behaviors.getSummaryFunc(_this6, events, resourceEvents.slotId, resourceEvents.slotName, headerItem.start, headerItem.end);
1354
- if (headerItem.summary && headerItem.summary.text !== undefined) hasSummary = true;
1355
- }
1356
- });
1357
- resourceEvents.hasSummary = hasSummary;
1358
- if (hasSummary) {
1359
- var rowsCount = cellMaxEventsCount <= cellMaxEventsCountValue && resourceEvents.rowMaxCount > cellMaxEventsCount ? cellMaxEventsCount : resourceEvents.rowMaxCount;
1360
- var newRowHeight = (rowsCount + 1) * _this6.config.eventItemLineHeight + (_this6.config.creatable && _this6.config.checkConflict === false ? 20 : 2);
1361
- if (newRowHeight > resourceEvents.rowHeight) resourceEvents.rowHeight = newRowHeight;
1127
+ }
1128
+ if (this.behaviors.getSummaryFunc !== undefined) {
1129
+ const events = [];
1130
+ headerItem.events.forEach(e => {
1131
+ if (e?.eventItem) events.push(e.eventItem);
1132
+ });
1133
+ headerItem.summary = this.behaviors.getSummaryFunc(this, events, resourceEvents.slotId, resourceEvents.slotName, headerItem.start, headerItem.end);
1134
+ if (headerItem.summary && headerItem.summary.text !== undefined) hasSummary = true;
1362
1135
  }
1363
1136
  });
1364
- }
1365
- this.renderData = initRenderData;
1366
- }
1367
- }, {
1368
- key: "_startResizing",
1369
- value: function _startResizing() {
1370
- this.resizing = true;
1371
- }
1372
- }, {
1373
- key: "_stopResizing",
1374
- value: function _stopResizing() {
1375
- this.resizing = false;
1376
- }
1377
- }, {
1378
- key: "_isResizing",
1379
- value: function _isResizing() {
1380
- return this.resizing;
1137
+ resourceEvents.hasSummary = hasSummary;
1138
+ if (hasSummary) {
1139
+ const rowsCount = cellMaxEventsCount <= cellMaxEventsCountValue && resourceEvents.rowMaxCount > cellMaxEventsCount ? cellMaxEventsCount : resourceEvents.rowMaxCount;
1140
+ const newRowHeight = (rowsCount + 1) * this.config.eventItemLineHeight + (this.config.creatable && this.config.checkConflict === false ? 20 : 2);
1141
+ if (newRowHeight > resourceEvents.rowHeight) resourceEvents.rowHeight = newRowHeight;
1142
+ }
1143
+ });
1381
1144
  }
1382
- }]);
1383
- }();
1145
+ this.renderData = initRenderData;
1146
+ }
1147
+ _startResizing() {
1148
+ this.resizing = true;
1149
+ }
1150
+ _stopResizing() {
1151
+ this.resizing = false;
1152
+ }
1153
+ _isResizing() {
1154
+ return this.resizing;
1155
+ }
1156
+ }