@event-calendar/core 5.1.3 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.css +7 -4
- package/dist/index.js +130 -90
- package/package.json +1 -1
- package/src/Calendar.svelte +8 -2
- package/src/lib/date.js +4 -2
- package/src/lib/utils.js +12 -4
- package/src/plugins/day-grid/Popup.svelte +1 -2
- package/src/plugins/resource-timeline/View.svelte +23 -14
- package/src/plugins/resource-timeline/derived.js +5 -3
- package/src/plugins/resource-timeline/lib.js +25 -11
- package/src/plugins/resource-timeline/state.svelte.js +1 -1
- package/src/storage/effects.js +1 -1
- package/src/styles/popup.css +6 -3
package/README.md
CHANGED
|
@@ -246,8 +246,8 @@ This bundle contains a version of the calendar that includes all plugins and is
|
|
|
246
246
|
|
|
247
247
|
The first step is to include the following lines of code in the `<head>` section of your page:
|
|
248
248
|
```html
|
|
249
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.
|
|
250
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.
|
|
249
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.4/dist/event-calendar.min.css">
|
|
250
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.1.4/dist/event-calendar.min.js"></script>
|
|
251
251
|
```
|
|
252
252
|
|
|
253
253
|
<details>
|
package/dist/index.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* EventCalendar v5.1.
|
|
2
|
+
* EventCalendar v5.1.4
|
|
3
3
|
* https://github.com/vkurko/calendar
|
|
4
4
|
*/
|
|
5
5
|
.ec {
|
|
@@ -596,10 +596,11 @@
|
|
|
596
596
|
position: relative;
|
|
597
597
|
display: flex;
|
|
598
598
|
flex-direction: column;
|
|
599
|
+
box-sizing: border-box;
|
|
599
600
|
block-size: max-content;
|
|
600
|
-
inline-size:
|
|
601
|
-
min-block-size:
|
|
602
|
-
min-inline-size:
|
|
601
|
+
inline-size: 125%;
|
|
602
|
+
min-block-size: 8em;
|
|
603
|
+
min-inline-size: 12em;
|
|
603
604
|
padding: .375rem .75rem .75rem;
|
|
604
605
|
background-color: var(--ec-popup-bg-color);
|
|
605
606
|
border: 1px solid var(--ec-border-color);
|
|
@@ -620,6 +621,8 @@
|
|
|
620
621
|
.ec-events {
|
|
621
622
|
--ec-event-col-gap: 0;
|
|
622
623
|
display: block;
|
|
624
|
+
overflow-y: auto;
|
|
625
|
+
pointer-events: auto;
|
|
623
626
|
}
|
|
624
627
|
}
|
|
625
628
|
.ec {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* EventCalendar v5.1.
|
|
2
|
+
* EventCalendar v5.1.4
|
|
3
3
|
* https://github.com/vkurko/calendar
|
|
4
4
|
*/
|
|
5
5
|
import { untrack, getAbortSignal, tick, getContext, setContext, onMount, mount, unmount } from "svelte";
|
|
@@ -63,10 +63,70 @@ function intersectionObserver(callback, options) {
|
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
+
function assign(...args) {
|
|
67
|
+
return Object.assign(...args);
|
|
68
|
+
}
|
|
69
|
+
function keys(object) {
|
|
70
|
+
return Object.keys(object);
|
|
71
|
+
}
|
|
72
|
+
function entries(object) {
|
|
73
|
+
return Object.entries(object);
|
|
74
|
+
}
|
|
75
|
+
function floor(value) {
|
|
76
|
+
return Math.floor(value);
|
|
77
|
+
}
|
|
78
|
+
function ceil(value) {
|
|
79
|
+
return Math.ceil(value);
|
|
80
|
+
}
|
|
81
|
+
function min(...args) {
|
|
82
|
+
return Math.min(...args);
|
|
83
|
+
}
|
|
84
|
+
function max(...args) {
|
|
85
|
+
return Math.max(...args);
|
|
86
|
+
}
|
|
87
|
+
function symbol() {
|
|
88
|
+
return /* @__PURE__ */ Symbol("ec");
|
|
89
|
+
}
|
|
90
|
+
function isArray(value) {
|
|
91
|
+
return Array.isArray(value);
|
|
92
|
+
}
|
|
93
|
+
function isFunction(value) {
|
|
94
|
+
return typeof value === "function";
|
|
95
|
+
}
|
|
96
|
+
function isPlainObject(value) {
|
|
97
|
+
if (typeof value !== "object" || value === null) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const prototype = Object.getPrototypeOf(value);
|
|
101
|
+
return prototype === null || prototype === Object.prototype;
|
|
102
|
+
}
|
|
103
|
+
function isDate(value) {
|
|
104
|
+
return value instanceof Date;
|
|
105
|
+
}
|
|
106
|
+
function run(fn) {
|
|
107
|
+
return fn();
|
|
108
|
+
}
|
|
109
|
+
function runAll(fns) {
|
|
110
|
+
fns.forEach(run);
|
|
111
|
+
}
|
|
112
|
+
function noop() {
|
|
113
|
+
}
|
|
114
|
+
const identity = (x) => x;
|
|
115
|
+
function stopPropagation(fn, _this = void 0) {
|
|
116
|
+
return function(event) {
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
if (fn) {
|
|
119
|
+
fn.call(_this, event);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function isRtl() {
|
|
124
|
+
return window.getComputedStyle(document.documentElement).direction === "rtl";
|
|
125
|
+
}
|
|
66
126
|
const DAY_IN_SECONDS = 86400;
|
|
67
127
|
function createDate(input = void 0) {
|
|
68
128
|
if (input !== void 0) {
|
|
69
|
-
return input
|
|
129
|
+
return isDate(input) ? _fromLocalDate(input) : _fromISOString(input);
|
|
70
130
|
}
|
|
71
131
|
return _fromLocalDate(/* @__PURE__ */ new Date());
|
|
72
132
|
}
|
|
@@ -79,7 +139,7 @@ function createDuration(input) {
|
|
|
79
139
|
seconds += parseInt(part, 10) * Math.pow(60, exp--);
|
|
80
140
|
}
|
|
81
141
|
input = { seconds };
|
|
82
|
-
} else if (input
|
|
142
|
+
} else if (isDate(input)) {
|
|
83
143
|
input = { hours: input.getUTCHours(), minutes: input.getUTCMinutes(), seconds: input.getUTCSeconds() };
|
|
84
144
|
}
|
|
85
145
|
let weeks = input.weeks || input.week || 0;
|
|
@@ -203,56 +263,6 @@ function _fromISOString(str) {
|
|
|
203
263
|
Number(parts[5] || 0)
|
|
204
264
|
));
|
|
205
265
|
}
|
|
206
|
-
function assign(...args) {
|
|
207
|
-
return Object.assign(...args);
|
|
208
|
-
}
|
|
209
|
-
function keys(object) {
|
|
210
|
-
return Object.keys(object);
|
|
211
|
-
}
|
|
212
|
-
function entries(object) {
|
|
213
|
-
return Object.entries(object);
|
|
214
|
-
}
|
|
215
|
-
function floor(value) {
|
|
216
|
-
return Math.floor(value);
|
|
217
|
-
}
|
|
218
|
-
function ceil(value) {
|
|
219
|
-
return Math.ceil(value);
|
|
220
|
-
}
|
|
221
|
-
function min(...args) {
|
|
222
|
-
return Math.min(...args);
|
|
223
|
-
}
|
|
224
|
-
function max(...args) {
|
|
225
|
-
return Math.max(...args);
|
|
226
|
-
}
|
|
227
|
-
function symbol() {
|
|
228
|
-
return /* @__PURE__ */ Symbol("ec");
|
|
229
|
-
}
|
|
230
|
-
function isArray(value) {
|
|
231
|
-
return Array.isArray(value);
|
|
232
|
-
}
|
|
233
|
-
function isFunction(value) {
|
|
234
|
-
return typeof value === "function";
|
|
235
|
-
}
|
|
236
|
-
function run(fn) {
|
|
237
|
-
return fn();
|
|
238
|
-
}
|
|
239
|
-
function runAll(fns) {
|
|
240
|
-
fns.forEach(run);
|
|
241
|
-
}
|
|
242
|
-
function noop() {
|
|
243
|
-
}
|
|
244
|
-
const identity = (x) => x;
|
|
245
|
-
function stopPropagation(fn, _this = void 0) {
|
|
246
|
-
return function(event) {
|
|
247
|
-
event.stopPropagation();
|
|
248
|
-
if (fn) {
|
|
249
|
-
fn.call(_this, event);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function isRtl() {
|
|
254
|
-
return window.getComputedStyle(document.documentElement).direction === "rtl";
|
|
255
|
-
}
|
|
256
266
|
let payloadProp = symbol();
|
|
257
267
|
function setPayload(obj, payload) {
|
|
258
268
|
obj[payloadProp] = payload;
|
|
@@ -1065,7 +1075,7 @@ function runEventAllUpdated(mainState) {
|
|
|
1065
1075
|
}
|
|
1066
1076
|
function runViewDidMount(mainState) {
|
|
1067
1077
|
return () => {
|
|
1068
|
-
let {
|
|
1078
|
+
let { options: { view: view2, viewDidMount } } = mainState;
|
|
1069
1079
|
untrack(() => {
|
|
1070
1080
|
if (isFunction(viewDidMount)) {
|
|
1071
1081
|
tick().then(() => viewDidMount({
|
|
@@ -1676,12 +1686,18 @@ function Calendar($$anchor, $$props) {
|
|
|
1676
1686
|
assign(prevOptions, options());
|
|
1677
1687
|
});
|
|
1678
1688
|
function setOption(name, value) {
|
|
1689
|
+
if (isPlainObject(value)) {
|
|
1690
|
+
value = { ...value };
|
|
1691
|
+
}
|
|
1692
|
+
if (isArray(value)) {
|
|
1693
|
+
value = [...value];
|
|
1694
|
+
}
|
|
1679
1695
|
mainState.setOption(name, value, false);
|
|
1680
1696
|
return this;
|
|
1681
1697
|
}
|
|
1682
1698
|
function getOption(name) {
|
|
1683
1699
|
let value = mainState.options[name];
|
|
1684
|
-
return value
|
|
1700
|
+
return isDate(value) ? toLocalDate(value) : value;
|
|
1685
1701
|
}
|
|
1686
1702
|
function refetchEvents() {
|
|
1687
1703
|
mainState.fetchedRange = { start: void 0, end: void 0 };
|
|
@@ -2506,8 +2522,7 @@ function Popup($$anchor, $$props) {
|
|
|
2506
2522
|
let top;
|
|
2507
2523
|
if (popupRect.height >= gridRect.height) {
|
|
2508
2524
|
top = gridRect.top - dayRect.top;
|
|
2509
|
-
|
|
2510
|
-
$.set(style, $.get(style) + `inset-block-end:${bottom}px;`);
|
|
2525
|
+
$.set(style, $.get(style) + `block-size:${gridRect.height}px;`);
|
|
2511
2526
|
} else {
|
|
2512
2527
|
top = (dayRect.height - popupRect.height) / 2;
|
|
2513
2528
|
if (dayRect.top + top < gridRect.top) {
|
|
@@ -4988,7 +5003,7 @@ function initViewComponent$2(mainState) {
|
|
|
4988
5003
|
setExtensions(mainState);
|
|
4989
5004
|
return View_1;
|
|
4990
5005
|
}
|
|
4991
|
-
function createChunks(event, days) {
|
|
5006
|
+
function createChunks(event, days, monthView2) {
|
|
4992
5007
|
let dates = [];
|
|
4993
5008
|
let firstStart;
|
|
4994
5009
|
let lastEnd;
|
|
@@ -4996,17 +5011,31 @@ function createChunks(event, days) {
|
|
|
4996
5011
|
let gridRow;
|
|
4997
5012
|
let left;
|
|
4998
5013
|
let width = 0;
|
|
4999
|
-
for (let { gridColumn: column, gridRow: row, resource, dayStart, start, end, disabled } of days) {
|
|
5000
|
-
if (!disabled
|
|
5001
|
-
if (
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5014
|
+
for (let { gridColumn: column, gridRow: row, resource, dayStart, dayEnd, start, end, disabled } of days) {
|
|
5015
|
+
if (!disabled) {
|
|
5016
|
+
if (monthView2) {
|
|
5017
|
+
if (eventIntersects(event, dayStart, dayEnd, resource)) {
|
|
5018
|
+
if (!dates.length) {
|
|
5019
|
+
firstStart = dayStart;
|
|
5020
|
+
gridColumn = column;
|
|
5021
|
+
gridRow = row;
|
|
5022
|
+
}
|
|
5023
|
+
dates.push(dayStart);
|
|
5024
|
+
lastEnd = end;
|
|
5025
|
+
}
|
|
5026
|
+
} else {
|
|
5027
|
+
if (eventIntersects(event, start, end, resource)) {
|
|
5028
|
+
if (!dates.length) {
|
|
5029
|
+
firstStart = start;
|
|
5030
|
+
gridColumn = column;
|
|
5031
|
+
gridRow = row;
|
|
5032
|
+
left = max(event.start - start, 0) / 1e3;
|
|
5033
|
+
}
|
|
5034
|
+
dates.push(dayStart);
|
|
5035
|
+
lastEnd = end;
|
|
5036
|
+
width += (min(end, event.end) - max(start, event.start)) / 1e3;
|
|
5037
|
+
}
|
|
5006
5038
|
}
|
|
5007
|
-
dates.push(dayStart);
|
|
5008
|
-
lastEnd = end;
|
|
5009
|
-
width += (min(end, event.end) - max(start, event.start)) / 1e3;
|
|
5010
5039
|
}
|
|
5011
5040
|
}
|
|
5012
5041
|
if (dates.length) {
|
|
@@ -5088,16 +5117,18 @@ function grid(mainState, viewState) {
|
|
|
5088
5117
|
function eventChunks(mainState, viewState) {
|
|
5089
5118
|
return () => {
|
|
5090
5119
|
let { filteredEvents: filteredEvents2 } = mainState;
|
|
5091
|
-
let { grid: grid2 } = viewState;
|
|
5120
|
+
let { grid: grid2, monthView: monthView2 } = viewState;
|
|
5092
5121
|
let chunks = [];
|
|
5093
5122
|
let bgChunks = [];
|
|
5094
5123
|
untrack(() => {
|
|
5095
5124
|
for (let event of filteredEvents2) {
|
|
5096
5125
|
for (let days of grid2) {
|
|
5097
5126
|
if (bgEvent(event.display)) {
|
|
5098
|
-
|
|
5127
|
+
if (!monthView2 || event.allDay) {
|
|
5128
|
+
bgChunks = bgChunks.concat(createChunks(event, days, monthView2));
|
|
5129
|
+
}
|
|
5099
5130
|
} else {
|
|
5100
|
-
chunks = chunks.concat(createChunks(event, days));
|
|
5131
|
+
chunks = chunks.concat(createChunks(event, days, monthView2));
|
|
5101
5132
|
}
|
|
5102
5133
|
}
|
|
5103
5134
|
}
|
|
@@ -5198,6 +5229,13 @@ class ViewState5 extends RRState(TRRState()) {
|
|
|
5198
5229
|
set grid(value) {
|
|
5199
5230
|
$.set(this.#grid, value);
|
|
5200
5231
|
}
|
|
5232
|
+
#monthView;
|
|
5233
|
+
get monthView() {
|
|
5234
|
+
return $.get(this.#monthView);
|
|
5235
|
+
}
|
|
5236
|
+
set monthView(value) {
|
|
5237
|
+
$.set(this.#monthView, value);
|
|
5238
|
+
}
|
|
5201
5239
|
#chunks;
|
|
5202
5240
|
get chunks() {
|
|
5203
5241
|
return $.get(this.#chunks);
|
|
@@ -5219,13 +5257,6 @@ class ViewState5 extends RRState(TRRState()) {
|
|
|
5219
5257
|
set iChunks(value) {
|
|
5220
5258
|
$.set(this.#iChunks, value);
|
|
5221
5259
|
}
|
|
5222
|
-
#monthView;
|
|
5223
|
-
get monthView() {
|
|
5224
|
-
return $.get(this.#monthView);
|
|
5225
|
-
}
|
|
5226
|
-
set monthView(value) {
|
|
5227
|
-
$.set(this.#monthView, value);
|
|
5228
|
-
}
|
|
5229
5260
|
#nestedResources;
|
|
5230
5261
|
get nestedResources() {
|
|
5231
5262
|
return $.get(this.#nestedResources);
|
|
@@ -5241,11 +5272,11 @@ class ViewState5 extends RRState(TRRState()) {
|
|
|
5241
5272
|
);
|
|
5242
5273
|
this.#daySlots = $.derived(daySlots(mainState, this));
|
|
5243
5274
|
this.#grid = $.derived(grid(mainState, this));
|
|
5275
|
+
this.#monthView = $.derived(monthView(mainState));
|
|
5244
5276
|
let $$d = $.derived(eventChunks(mainState, this)), chunks = $.derived(() => $.get($$d).chunks), bgChunks = $.derived(() => $.get($$d).bgChunks);
|
|
5245
5277
|
this.#chunks = $.derived(() => $.get(chunks));
|
|
5246
5278
|
this.#bgChunks = $.derived(() => $.get(bgChunks));
|
|
5247
5279
|
this.#iChunks = $.derived(iEventChunks(mainState, this));
|
|
5248
|
-
this.#monthView = $.derived(monthView(mainState));
|
|
5249
5280
|
this.#nestedResources = $.derived(nestedResources(mainState));
|
|
5250
5281
|
}
|
|
5251
5282
|
}
|
|
@@ -5487,21 +5518,30 @@ function View($$anchor, $$props) {
|
|
|
5487
5518
|
tick().then(scrollToTime);
|
|
5488
5519
|
});
|
|
5489
5520
|
function scrollToTime() {
|
|
5490
|
-
if ($.get(monthView2)) {
|
|
5491
|
-
return;
|
|
5492
|
-
}
|
|
5493
5521
|
let scrollLeft = 0;
|
|
5494
5522
|
let todayOutOfView = $.get(today) < $.get(viewDates2)[0] || $.get(today) > $.get(viewDates2).at(-1);
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5523
|
+
if ($.get(monthView2)) {
|
|
5524
|
+
if (!todayOutOfView) {
|
|
5525
|
+
let days = $.get(grid2)[0];
|
|
5526
|
+
for (let day of days) {
|
|
5527
|
+
if (datesEqual(day.dayStart, $.get(today))) {
|
|
5528
|
+
$.get(mainEl).scrollLeft = ($.get(mainEl).scrollWidth - $.get(sidebarWidth)) / days.length * (day.gridColumn - 1) * (isRtl() ? -1 : 1);
|
|
5529
|
+
break;
|
|
5530
|
+
}
|
|
5531
|
+
}
|
|
5532
|
+
}
|
|
5533
|
+
} else {
|
|
5534
|
+
for (let date of $.get(viewDates2)) {
|
|
5535
|
+
let slotTimeLimits2 = getSlotTimeLimits($.get(dayTimeLimits2), date);
|
|
5536
|
+
if (todayOutOfView || datesEqual(date, $.get(today))) {
|
|
5537
|
+
scrollLeft += max(min(toSeconds($.get(scrollTime)), toSeconds(slotTimeLimits2.max)) - toSeconds(slotTimeLimits2.min), 0);
|
|
5538
|
+
break;
|
|
5539
|
+
} else {
|
|
5540
|
+
scrollLeft += toSeconds(slotTimeLimits2.max) - toSeconds(slotTimeLimits2.min);
|
|
5541
|
+
}
|
|
5502
5542
|
}
|
|
5543
|
+
$.get(mainEl).scrollLeft = scrollLeft / toSeconds($.get(slotDuration)) * $.get(slotWidth) * (isRtl() ? -1 : 1);
|
|
5503
5544
|
}
|
|
5504
|
-
$.get(mainEl).scrollLeft = scrollLeft / toSeconds($.get(slotDuration)) * $.get(slotWidth) * (isRtl() ? -1 : 1);
|
|
5505
5545
|
}
|
|
5506
5546
|
let refs = [];
|
|
5507
5547
|
function reposition() {
|
package/package.json
CHANGED
package/src/Calendar.svelte
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import './styles/index.css';
|
|
3
3
|
import {setContext, untrack} from 'svelte';
|
|
4
4
|
import {
|
|
5
|
-
assign, cloneDate, createEvents, getElementWithPayload, getPayload, nextDate,
|
|
5
|
+
assign, cloneDate, createEvents, getElementWithPayload, getPayload, isArray, isDate, isPlainObject, nextDate,
|
|
6
6
|
prevDate, toEventWithLocalDates, toLocalDate, toViewWithLocalDates
|
|
7
7
|
} from '#lib';
|
|
8
8
|
import MainState from './storage/state.svelte.js';
|
|
@@ -33,13 +33,19 @@
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
export function setOption(name, value) {
|
|
36
|
+
if (isPlainObject(value)) {
|
|
37
|
+
value = {...value};
|
|
38
|
+
}
|
|
39
|
+
if (isArray(value)) {
|
|
40
|
+
value = [...value];
|
|
41
|
+
}
|
|
36
42
|
mainState.setOption(name, value, false);
|
|
37
43
|
return this;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
export function getOption(name) {
|
|
41
47
|
let value = mainState.options[name];
|
|
42
|
-
return value
|
|
48
|
+
return isDate(value) ? toLocalDate(value) : value;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
export function refetchEvents() {
|
package/src/lib/date.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import {isDate} from './utils.js';
|
|
2
|
+
|
|
1
3
|
export const DAY_IN_SECONDS = 86400;
|
|
2
4
|
|
|
3
5
|
export function createDate(input = undefined) {
|
|
4
6
|
if (input !== undefined) {
|
|
5
|
-
return input
|
|
7
|
+
return isDate(input) ? _fromLocalDate(input) : _fromISOString(input);
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
return _fromLocalDate(new Date());
|
|
@@ -18,7 +20,7 @@ export function createDuration(input) {
|
|
|
18
20
|
seconds += parseInt(part, 10) * Math.pow(60, exp--);
|
|
19
21
|
}
|
|
20
22
|
input = {seconds};
|
|
21
|
-
} else if (input
|
|
23
|
+
} else if (isDate(input)) {
|
|
22
24
|
input = {hours: input.getUTCHours(), minutes: input.getUTCMinutes(), seconds: input.getUTCSeconds()};
|
|
23
25
|
}
|
|
24
26
|
|
package/src/lib/utils.js
CHANGED
|
@@ -10,10 +10,6 @@ export function entries(object) {
|
|
|
10
10
|
return Object.entries(object);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function hasOwn(object, property) {
|
|
14
|
-
return Object.hasOwn(object, property);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
13
|
export function floor(value) {
|
|
18
14
|
return Math.floor(value);
|
|
19
15
|
}
|
|
@@ -42,6 +38,18 @@ export function isFunction(value) {
|
|
|
42
38
|
return typeof value === 'function';
|
|
43
39
|
}
|
|
44
40
|
|
|
41
|
+
export function isPlainObject(value) {
|
|
42
|
+
if (typeof value !== 'object' || value === null) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const prototype = Object.getPrototypeOf(value);
|
|
46
|
+
return prototype === null || prototype === Object.prototype;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function isDate(value) {
|
|
50
|
+
return value instanceof Date;
|
|
51
|
+
}
|
|
52
|
+
|
|
45
53
|
export function run(fn) {
|
|
46
54
|
return fn();
|
|
47
55
|
}
|
|
@@ -62,8 +62,7 @@
|
|
|
62
62
|
let top;
|
|
63
63
|
if (popupRect.height >= gridRect.height) {
|
|
64
64
|
top = gridRect.top - dayRect.top;
|
|
65
|
-
|
|
66
|
-
style += `inset-block-end:${bottom}px;`;
|
|
65
|
+
style += `block-size:${gridRect.height}px;`;
|
|
67
66
|
} else {
|
|
68
67
|
top = (dayRect.height - popupRect.height) / 2;
|
|
69
68
|
if (dayRect.top + top < gridRect.top) {
|
|
@@ -27,24 +27,33 @@
|
|
|
27
27
|
tick().then(scrollToTime);
|
|
28
28
|
});
|
|
29
29
|
function scrollToTime() {
|
|
30
|
-
if (monthView) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
30
|
let scrollLeft = 0;
|
|
34
31
|
let todayOutOfView = today < viewDates[0] || today > viewDates.at(-1);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
if (monthView) {
|
|
33
|
+
if (!todayOutOfView) {
|
|
34
|
+
let days = grid[0];
|
|
35
|
+
for (let day of days) {
|
|
36
|
+
if (datesEqual(day.dayStart, today)) {
|
|
37
|
+
mainEl.scrollLeft = (mainEl.scrollWidth - sidebarWidth) / days.length * (day.gridColumn - 1) * (isRtl() ? -1 : 1);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
for (let date of viewDates) {
|
|
44
|
+
let slotTimeLimits = getSlotTimeLimits(dayTimeLimits, date);
|
|
45
|
+
if (todayOutOfView || datesEqual(date, today)) {
|
|
46
|
+
scrollLeft += max(
|
|
47
|
+
min(toSeconds(scrollTime), toSeconds(slotTimeLimits.max)) - toSeconds(slotTimeLimits.min),
|
|
48
|
+
0
|
|
49
|
+
);
|
|
50
|
+
break;
|
|
51
|
+
} else {
|
|
52
|
+
scrollLeft += toSeconds(slotTimeLimits.max) - toSeconds(slotTimeLimits.min);
|
|
53
|
+
}
|
|
45
54
|
}
|
|
55
|
+
mainEl.scrollLeft = scrollLeft / toSeconds(slotDuration) * slotWidth * (isRtl() ? -1 : 1);
|
|
46
56
|
}
|
|
47
|
-
mainEl.scrollLeft = scrollLeft / toSeconds(slotDuration) * slotWidth * (isRtl() ? -1 : 1);
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
// Events reposition
|
|
@@ -46,7 +46,7 @@ export function eventChunks(mainState, viewState) {
|
|
|
46
46
|
return () => {
|
|
47
47
|
// Dependencies
|
|
48
48
|
let {filteredEvents} = mainState;
|
|
49
|
-
let {grid} = viewState;
|
|
49
|
+
let {grid, monthView} = viewState;
|
|
50
50
|
|
|
51
51
|
let chunks = [];
|
|
52
52
|
let bgChunks = [];
|
|
@@ -55,9 +55,11 @@ export function eventChunks(mainState, viewState) {
|
|
|
55
55
|
for (let event of filteredEvents) {
|
|
56
56
|
for (let days of grid) {
|
|
57
57
|
if (bgEvent(event.display)) {
|
|
58
|
-
|
|
58
|
+
if (!monthView || event.allDay) {
|
|
59
|
+
bgChunks = bgChunks.concat(createChunks(event, days, monthView));
|
|
60
|
+
}
|
|
59
61
|
} else {
|
|
60
|
-
chunks = chunks.concat(createChunks(event, days));
|
|
62
|
+
chunks = chunks.concat(createChunks(event, days, monthView));
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {assign, createDuration, createEventChunk, eventIntersects, max, min} from '#lib';
|
|
2
2
|
|
|
3
|
-
export function createChunks(event, days) {
|
|
3
|
+
export function createChunks(event, days, monthView) {
|
|
4
4
|
let dates = [];
|
|
5
5
|
let firstStart;
|
|
6
6
|
let lastEnd;
|
|
@@ -8,17 +8,31 @@ export function createChunks(event, days) {
|
|
|
8
8
|
let gridRow;
|
|
9
9
|
let left;
|
|
10
10
|
let width = 0;
|
|
11
|
-
for (let {gridColumn: column, gridRow: row, resource, dayStart, start, end, disabled} of days) {
|
|
12
|
-
if (!disabled
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
for (let {gridColumn: column, gridRow: row, resource, dayStart, dayEnd, start, end, disabled} of days) {
|
|
12
|
+
if (!disabled) {
|
|
13
|
+
if (monthView) {
|
|
14
|
+
if (eventIntersects(event, dayStart, dayEnd, resource)) {
|
|
15
|
+
if (!dates.length) {
|
|
16
|
+
firstStart = dayStart;
|
|
17
|
+
gridColumn = column;
|
|
18
|
+
gridRow = row;
|
|
19
|
+
}
|
|
20
|
+
dates.push(dayStart);
|
|
21
|
+
lastEnd = end;
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
if (eventIntersects(event, start, end, resource)) {
|
|
25
|
+
if (!dates.length) {
|
|
26
|
+
firstStart = start;
|
|
27
|
+
gridColumn = column;
|
|
28
|
+
gridRow = row;
|
|
29
|
+
left = max(event.start - start, 0) / 1000;
|
|
30
|
+
}
|
|
31
|
+
dates.push(dayStart);
|
|
32
|
+
lastEnd = end;
|
|
33
|
+
width += (min(end, event.end) - max(start, event.start)) / 1000;
|
|
34
|
+
}
|
|
18
35
|
}
|
|
19
|
-
dates.push(dayStart);
|
|
20
|
-
lastEnd = end;
|
|
21
|
-
width += (min(end, event.end) - max(start, event.start)) / 1000;
|
|
22
36
|
}
|
|
23
37
|
}
|
|
24
38
|
if (dates.length) {
|
|
@@ -8,11 +8,11 @@ export default class ViewState extends RRState(TRRState()) {
|
|
|
8
8
|
this.dayTimeLimits = $derived.by(dayTimeLimits(mainState)); // flexible time limits per day
|
|
9
9
|
this.daySlots = $derived.by(daySlots(mainState, this));
|
|
10
10
|
this.grid = $derived.by(grid(mainState, this));
|
|
11
|
+
this.monthView = $derived.by(monthView(mainState));
|
|
11
12
|
let {chunks, bgChunks} = $derived.by(eventChunks(mainState, this));
|
|
12
13
|
this.chunks = $derived(chunks);
|
|
13
14
|
this.bgChunks = $derived(bgChunks);
|
|
14
15
|
this.iChunks = $derived.by(iEventChunks(mainState, this));
|
|
15
|
-
this.monthView = $derived.by(monthView(mainState));
|
|
16
16
|
this.nestedResources = $derived.by(nestedResources(mainState));
|
|
17
17
|
}
|
|
18
18
|
}
|
package/src/storage/effects.js
CHANGED
|
@@ -143,7 +143,7 @@ export function runEventAllUpdated(mainState) {
|
|
|
143
143
|
export function runViewDidMount(mainState) {
|
|
144
144
|
return () => {
|
|
145
145
|
// Dependencies
|
|
146
|
-
let {
|
|
146
|
+
let {options: {view, viewDidMount}} = mainState;
|
|
147
147
|
|
|
148
148
|
untrack(() => {
|
|
149
149
|
if (isFunction(viewDidMount)) {
|
package/src/styles/popup.css
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
position: relative;
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
|
+
box-sizing: border-box;
|
|
5
6
|
block-size: max-content;
|
|
6
|
-
inline-size:
|
|
7
|
-
min-block-size:
|
|
8
|
-
min-inline-size:
|
|
7
|
+
inline-size: 125%;
|
|
8
|
+
min-block-size: 8em;
|
|
9
|
+
min-inline-size: 12em;
|
|
9
10
|
padding: .375rem .75rem .75rem;
|
|
10
11
|
background-color: var(--ec-popup-bg-color);
|
|
11
12
|
border: 1px solid var(--ec-border-color);
|
|
@@ -26,5 +27,7 @@
|
|
|
26
27
|
.ec-events {
|
|
27
28
|
--ec-event-col-gap: 0;
|
|
28
29
|
display: block;
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
pointer-events: auto;
|
|
29
32
|
}
|
|
30
33
|
}
|