@event-calendar/core 5.0.3 → 5.0.5
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 +5 -7
- package/dist/index.js +84 -28
- package/package.json +1 -1
- package/src/lib/components/BaseDay.svelte +1 -1
- package/src/lib/view.js +4 -0
- package/src/plugins/day-grid/View.svelte +14 -3
- package/src/plugins/interaction/Action.svelte +13 -7
- package/src/plugins/resource-timeline/Day.svelte +8 -4
- package/src/plugins/resource-timeline/View.svelte +24 -5
- package/src/plugins/time-grid/Day.svelte +7 -3
- package/src/plugins/time-grid/View.svelte +22 -3
- package/src/storage/state.js +1 -0
- package/src/storage/stores.js +6 -20
- package/src/styles/index.css +1 -1
- package/src/styles/sidebar.css +2 -4
- package/src/styles/slots.css +1 -1
package/README.md
CHANGED
|
@@ -245,8 +245,8 @@ This bundle contains a version of the calendar that includes all plugins and is
|
|
|
245
245
|
|
|
246
246
|
The first step is to include the following lines of code in the `<head>` section of your page:
|
|
247
247
|
```html
|
|
248
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.0.
|
|
249
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.0.
|
|
248
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.0.4/dist/event-calendar.min.css">
|
|
249
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@5.0.4/dist/event-calendar.min.js"></script>
|
|
250
250
|
```
|
|
251
251
|
|
|
252
252
|
<details>
|
package/dist/index.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* EventCalendar v5.0.
|
|
2
|
+
* EventCalendar v5.0.5
|
|
3
3
|
* https://github.com/vkurko/calendar
|
|
4
4
|
*/
|
|
5
5
|
.ec {
|
|
@@ -276,14 +276,12 @@
|
|
|
276
276
|
inset-inline-start: 0;
|
|
277
277
|
z-index: 1;
|
|
278
278
|
background-color: var(--ec-bg-color);
|
|
279
|
-
border-
|
|
280
|
-
border-width: 1px;
|
|
281
|
-
border-inline-end-style: solid;
|
|
279
|
+
border-inline-end: 1px solid var(--ec-border-color);
|
|
282
280
|
text-align: end;
|
|
283
281
|
overflow: clip;
|
|
284
282
|
|
|
285
283
|
.ec-header & {
|
|
286
|
-
border-block-end
|
|
284
|
+
border-block-end: 1px solid var(--ec-border-color);
|
|
287
285
|
padding-block: .375rem;
|
|
288
286
|
}
|
|
289
287
|
|
|
@@ -344,7 +342,7 @@
|
|
|
344
342
|
.ec-time-grid & {
|
|
345
343
|
block-size: calc(var(--ec-slot-height) * var(--ec-slot-label-periodicity));
|
|
346
344
|
position: relative;
|
|
347
|
-
inset-block-start: -.
|
|
345
|
+
inset-block-start: -.5lh;
|
|
348
346
|
}
|
|
349
347
|
|
|
350
348
|
.ec-timeline & {
|
|
@@ -653,7 +651,7 @@
|
|
|
653
651
|
|
|
654
652
|
.ec-timeline & {
|
|
655
653
|
grid-template-columns: max-content repeat(var(--ec-grid-cols), min-content);
|
|
656
|
-
grid-template-rows: max-content
|
|
654
|
+
grid-template-rows: max-content var(--ec-grid-rows);
|
|
657
655
|
flex-grow: 1;
|
|
658
656
|
}
|
|
659
657
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* EventCalendar v5.0.
|
|
2
|
+
* EventCalendar v5.0.5
|
|
3
3
|
* https://github.com/vkurko/calendar
|
|
4
4
|
*/
|
|
5
5
|
import { tick, getContext, untrack, setContext, onMount, mount, unmount } from "svelte";
|
|
@@ -340,6 +340,9 @@ function toViewWithLocalDates(view2) {
|
|
|
340
340
|
function listView(view2) {
|
|
341
341
|
return view2.startsWith("list");
|
|
342
342
|
}
|
|
343
|
+
function timelineView(view2) {
|
|
344
|
+
return view2.includes("Timeline");
|
|
345
|
+
}
|
|
343
346
|
let eventId = 1;
|
|
344
347
|
function createEvents(input) {
|
|
345
348
|
return input.map((event) => {
|
|
@@ -885,21 +888,9 @@ function dayGrid(state) {
|
|
|
885
888
|
}
|
|
886
889
|
function activeRange(state) {
|
|
887
890
|
return derived(
|
|
888
|
-
[state._currentRange, state.
|
|
889
|
-
([$_currentRange, $
|
|
890
|
-
|
|
891
|
-
let end = cloneDate($_currentRange.end);
|
|
892
|
-
if ($_dayGrid) {
|
|
893
|
-
prevClosestDay(start, $firstDay);
|
|
894
|
-
nextClosestDay(end, $firstDay);
|
|
895
|
-
} else if ($slotMaxTime.days || $slotMaxTime.seconds > DAY_IN_SECONDS) {
|
|
896
|
-
addDuration(subtractDay(end), $slotMaxTime);
|
|
897
|
-
let start2 = subtractDay(cloneDate(end));
|
|
898
|
-
if (start2 < start) {
|
|
899
|
-
start = start2;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
return { start, end };
|
|
891
|
+
[state._currentRange, state._activeRangeExt],
|
|
892
|
+
([$_currentRange, $_activeRangeExt]) => {
|
|
893
|
+
return $_activeRangeExt({ start: cloneDate($_currentRange.start), end: cloneDate($_currentRange.end) });
|
|
903
894
|
}
|
|
904
895
|
);
|
|
905
896
|
}
|
|
@@ -1065,9 +1056,10 @@ function now() {
|
|
|
1065
1056
|
});
|
|
1066
1057
|
}
|
|
1067
1058
|
function today(state) {
|
|
1068
|
-
let $today = createDate();
|
|
1059
|
+
let $today = setMidnight(createDate());
|
|
1069
1060
|
let today2 = writable($today);
|
|
1070
|
-
|
|
1061
|
+
state._now.subscribe(($_now) => {
|
|
1062
|
+
let newToday = setMidnight(cloneDate($_now));
|
|
1071
1063
|
if (!datesEqual($today, newToday)) {
|
|
1072
1064
|
$today = newToday;
|
|
1073
1065
|
today2.set(newToday);
|
|
@@ -1090,6 +1082,7 @@ class State {
|
|
|
1090
1082
|
this._auxiliary = writable([]);
|
|
1091
1083
|
this._dayGrid = dayGrid(this);
|
|
1092
1084
|
this._currentRange = currentRange(this);
|
|
1085
|
+
this._activeRangeExt = writable(identity);
|
|
1093
1086
|
this._activeRange = activeRange(this);
|
|
1094
1087
|
this._fetchedRange = writable({ start: void 0, end: void 0 });
|
|
1095
1088
|
this._events = events(this);
|
|
@@ -1742,7 +1735,7 @@ function BaseDay($$anchor, $$props) {
|
|
|
1742
1735
|
const $_interaction = () => $.store_get(_interaction, "$_interaction", $$stores);
|
|
1743
1736
|
const [$$stores, $$cleanup] = $.setup_stores();
|
|
1744
1737
|
let el = $.prop($$props, "el", 15), allDay = $.prop($$props, "allDay", 3, false), resource = $.prop($$props, "resource", 3, void 0), dateFromPoint = $.prop($$props, "dateFromPoint", 3, () => $$props.date), classes = $.prop($$props, "classes", 3, identity), disabled = $.prop($$props, "disabled", 3, false), highlight = $.prop($$props, "highlight", 3, false), role = $.prop($$props, "role", 3, "cell"), noIeb = $.prop($$props, "noIeb", 3, false), noBeb = $.prop($$props, "noBeb", 3, false);
|
|
1745
|
-
let { _interaction, _today,
|
|
1738
|
+
let { _interaction, _today, theme } = getContext("state");
|
|
1746
1739
|
let isToday = $.derived(() => datesEqual($$props.date, $_today()));
|
|
1747
1740
|
let classNames = $.derived(() => classes()([
|
|
1748
1741
|
$theme().day,
|
|
@@ -2482,6 +2475,7 @@ function View$3($$anchor, $$props) {
|
|
|
2482
2475
|
const $highlightedDates = () => $.store_get(highlightedDates, "$highlightedDates", $$stores);
|
|
2483
2476
|
const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
|
|
2484
2477
|
const $_iEvents = () => $.store_get(_iEvents, "$_iEvents", $$stores);
|
|
2478
|
+
const $firstDay = () => $.store_get(firstDay, "$firstDay", $$stores);
|
|
2485
2479
|
const $_hiddenChunks = () => $.store_get(_hiddenChunks, "$_hiddenChunks", $$stores);
|
|
2486
2480
|
const $_mainEl = () => $.store_get(_mainEl, "$_mainEl", $$stores);
|
|
2487
2481
|
const $theme = () => $.store_get(theme, "$theme", $$stores);
|
|
@@ -2491,6 +2485,7 @@ function View$3($$anchor, $$props) {
|
|
|
2491
2485
|
const $_popupDay = () => $.store_get(_popupDay, "$_popupDay", $$stores);
|
|
2492
2486
|
const [$$stores, $$cleanup] = $.setup_stores();
|
|
2493
2487
|
let {
|
|
2488
|
+
_activeRangeExt,
|
|
2494
2489
|
_mainEl,
|
|
2495
2490
|
_colsCount,
|
|
2496
2491
|
_filteredEvents,
|
|
@@ -2501,6 +2496,7 @@ function View$3($$anchor, $$props) {
|
|
|
2501
2496
|
_popupDay,
|
|
2502
2497
|
_viewDates,
|
|
2503
2498
|
dayMaxEvents,
|
|
2499
|
+
firstDay,
|
|
2504
2500
|
highlightedDates,
|
|
2505
2501
|
theme,
|
|
2506
2502
|
validRange
|
|
@@ -2509,6 +2505,15 @@ function View$3($$anchor, $$props) {
|
|
|
2509
2505
|
let grid = $.derived(() => createGrid$3($_viewDates(), $_colsCount(), $validRange(), $highlightedDates()));
|
|
2510
2506
|
let $$d = $.derived(() => createEventChunks$2($_filteredEvents(), $.get(grid))), chunks = $.derived(() => $.get($$d).chunks), bgChunks = $.derived(() => $.get($$d).bgChunks);
|
|
2511
2507
|
let iChunks = $.derived(() => createIEventChunks$2($_iEvents(), $.get(grid)));
|
|
2508
|
+
$.user_pre_effect(() => {
|
|
2509
|
+
$.store_set(_activeRangeExt, ({ start, end }) => ({
|
|
2510
|
+
start: prevClosestDay(start, $firstDay()),
|
|
2511
|
+
end: nextClosestDay(end, $firstDay())
|
|
2512
|
+
}));
|
|
2513
|
+
return () => {
|
|
2514
|
+
$.store_set(_activeRangeExt, identity);
|
|
2515
|
+
};
|
|
2516
|
+
});
|
|
2512
2517
|
let refs = [];
|
|
2513
2518
|
function reposition() {
|
|
2514
2519
|
$.store_set(_hiddenChunks, {});
|
|
@@ -3103,7 +3108,7 @@ function Action($$anchor, $$props) {
|
|
|
3103
3108
|
return findPayload(dayEl.previousElementSibling);
|
|
3104
3109
|
}
|
|
3105
3110
|
} else {
|
|
3106
|
-
if (selecting() && payload.resource && !$_iEvents()[0].resourceIds.includes(payload.resource.id)) {
|
|
3111
|
+
if ((selecting() || resizing()) && payload.resource && !$_iEvents()[0].resourceIds.includes(payload.resource.id) && !timelineView($view())) {
|
|
3107
3112
|
if (toX > fromX) {
|
|
3108
3113
|
return findPayload(dayEl.previousElementSibling);
|
|
3109
3114
|
} else {
|
|
@@ -3118,11 +3123,14 @@ function Action($$anchor, $$props) {
|
|
|
3118
3123
|
function calcViewport() {
|
|
3119
3124
|
let mainRect = rect($_mainEl());
|
|
3120
3125
|
let gridRect = rect(gridEl);
|
|
3126
|
+
let scaleX = mainRect.width / $_mainEl().offsetWidth;
|
|
3127
|
+
let scaleY = mainRect.height / $_mainEl().offsetHeight;
|
|
3128
|
+
let rtl = isRtl();
|
|
3121
3129
|
viewport = {
|
|
3122
|
-
left: max(0, gridRect.left + $_mainEl().scrollLeft),
|
|
3123
|
-
right: min(document.documentElement.clientWidth, mainRect.left + $_mainEl().clientWidth) - 2,
|
|
3124
|
-
top: max(0, gridRect.top + (!allDaySlot ? $_mainEl().scrollTop : 0)),
|
|
3125
|
-
bottom: min(document.documentElement.clientHeight, !allDaySlot ? mainRect.top + $_mainEl().clientHeight : gridRect.bottom) - 2
|
|
3130
|
+
left: max(0, rtl ? mainRect.right - $_mainEl().clientWidth * scaleX : gridRect.left + $_mainEl().scrollLeft * scaleX),
|
|
3131
|
+
right: min(document.documentElement.clientWidth, rtl ? gridRect.right + $_mainEl().scrollLeft * scaleX : mainRect.left + $_mainEl().clientWidth * scaleX) - 2,
|
|
3132
|
+
top: max(0, gridRect.top + (!allDaySlot ? $_mainEl().scrollTop : 0) * scaleY),
|
|
3133
|
+
bottom: min(document.documentElement.clientHeight, !allDaySlot ? mainRect.top + $_mainEl().clientHeight * scaleY : gridRect.bottom) - 2
|
|
3126
3134
|
};
|
|
3127
3135
|
}
|
|
3128
3136
|
function createIEvent(jsEvent, callback) {
|
|
@@ -4105,7 +4113,13 @@ function Day$1($$anchor, $$props) {
|
|
|
4105
4113
|
let date = $.derived(() => $$props.day.dayStart), start = $.derived(() => $$props.day.start), resource = $.derived(() => $$props.day.resource), disabled = $.derived(() => $$props.day.disabled), highlight = $.derived(() => $$props.day.highlight);
|
|
4106
4114
|
let el = $.state(void 0);
|
|
4107
4115
|
function dateFromPoint(x, y) {
|
|
4108
|
-
|
|
4116
|
+
if (allDay()) {
|
|
4117
|
+
return $.get(date);
|
|
4118
|
+
} else {
|
|
4119
|
+
let dayRect = rect($.get(el));
|
|
4120
|
+
let scaleY = dayRect.height / $.get(el).offsetHeight;
|
|
4121
|
+
return addDuration(cloneDate($.get(start)), $slotDuration(), floor((y - dayRect.top) / ($slotHeight() * scaleY)));
|
|
4122
|
+
}
|
|
4109
4123
|
}
|
|
4110
4124
|
BaseDay($$anchor, {
|
|
4111
4125
|
get date() {
|
|
@@ -4294,6 +4308,7 @@ function View$1($$anchor, $$props) {
|
|
|
4294
4308
|
const $highlightedDates = () => $.store_get(highlightedDates, "$highlightedDates", $$stores);
|
|
4295
4309
|
const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
|
|
4296
4310
|
const $_iEvents = () => $.store_get(_iEvents, "$_iEvents", $$stores);
|
|
4311
|
+
const $slotMaxTime = () => $.store_get(slotMaxTime, "$slotMaxTime", $$stores);
|
|
4297
4312
|
const $scrollTime = () => $.store_get(scrollTime, "$scrollTime", $$stores);
|
|
4298
4313
|
const $_mainEl = () => $.store_get(_mainEl, "$_mainEl", $$stores);
|
|
4299
4314
|
const $slotDuration = () => $.store_get(slotDuration, "$slotDuration", $$stores);
|
|
@@ -4307,6 +4322,7 @@ function View$1($$anchor, $$props) {
|
|
|
4307
4322
|
const $showNowIndicator = () => $.store_get(showNowIndicator, "$showNowIndicator", $$stores);
|
|
4308
4323
|
const [$$stores, $$cleanup] = $.setup_stores();
|
|
4309
4324
|
let {
|
|
4325
|
+
_activeRangeExt,
|
|
4310
4326
|
_mainEl,
|
|
4311
4327
|
_filteredEvents,
|
|
4312
4328
|
_iEvents,
|
|
@@ -4323,6 +4339,7 @@ function View$1($$anchor, $$props) {
|
|
|
4323
4339
|
scrollTime,
|
|
4324
4340
|
slotHeight,
|
|
4325
4341
|
slotDuration,
|
|
4342
|
+
slotMaxTime,
|
|
4326
4343
|
theme,
|
|
4327
4344
|
validRange
|
|
4328
4345
|
} = getContext("state");
|
|
@@ -4331,6 +4348,21 @@ function View$1($$anchor, $$props) {
|
|
|
4331
4348
|
let grid = $.derived(() => $$props.createGridFn?.() ?? createGrid$1($_viewDates(), $_slotTimeLimits(), $validRange(), $highlightedDates()));
|
|
4332
4349
|
let $$d = $.derived(() => createEventChunks$1($_filteredEvents(), $.get(grid))), chunks = $.derived(() => $.get($$d).chunks), bgChunks = $.derived(() => $.get($$d).bgChunks), allDayChunks = $.derived(() => $.get($$d).allDayChunks), allDayBgChunks = $.derived(() => $.get($$d).allDayBgChunks);
|
|
4333
4350
|
let $$d_1 = $.derived(() => createIEventChunks$1($_iEvents(), $.get(grid))), iChunks = $.derived(() => $.get($$d_1).iChunks), allDayIChunks = $.derived(() => $.get($$d_1).allDayIChunks);
|
|
4351
|
+
$.user_pre_effect(() => {
|
|
4352
|
+
$.store_set(_activeRangeExt, ({ start, end }) => {
|
|
4353
|
+
if ($slotMaxTime().days || $slotMaxTime().seconds > DAY_IN_SECONDS) {
|
|
4354
|
+
addDuration(subtractDay(end), $slotMaxTime());
|
|
4355
|
+
let start2 = subtractDay(cloneDate(end));
|
|
4356
|
+
if (start2 < start) {
|
|
4357
|
+
start = start2;
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
return { start, end };
|
|
4361
|
+
});
|
|
4362
|
+
return () => {
|
|
4363
|
+
$.store_set(_activeRangeExt, identity);
|
|
4364
|
+
};
|
|
4365
|
+
});
|
|
4334
4366
|
$.user_effect(() => {
|
|
4335
4367
|
$_viewDates();
|
|
4336
4368
|
$scrollTime();
|
|
@@ -5015,7 +5047,13 @@ function Day($$anchor, $$props) {
|
|
|
5015
5047
|
let date = $.derived(() => $$props.day.dayStart), start = $.derived(() => $$props.day.start), resource = $.derived(() => $$props.day.resource), disabled = $.derived(() => $$props.day.disabled), highlight = $.derived(() => $$props.day.highlight);
|
|
5016
5048
|
let el = $.state(void 0);
|
|
5017
5049
|
function dateFromPoint(x, y) {
|
|
5018
|
-
|
|
5050
|
+
if ($_monthView()) {
|
|
5051
|
+
return $.get(date);
|
|
5052
|
+
} else {
|
|
5053
|
+
let dayRect = rect($.get(el));
|
|
5054
|
+
let scaleX = dayRect.width / $.get(el).offsetWidth;
|
|
5055
|
+
return addDuration(cloneDate($.get(start)), $slotDuration(), floor((isRtl() ? dayRect.right - x : x - dayRect.left) / ($slotWidth() * scaleX)));
|
|
5056
|
+
}
|
|
5019
5057
|
}
|
|
5020
5058
|
BaseDay($$anchor, {
|
|
5021
5059
|
get allDay() {
|
|
@@ -5294,6 +5332,7 @@ function View($$anchor, $$props) {
|
|
|
5294
5332
|
const $highlightedDates = () => $.store_get(highlightedDates, "$highlightedDates", $$stores);
|
|
5295
5333
|
const $_filteredEvents = () => $.store_get(_filteredEvents, "$_filteredEvents", $$stores);
|
|
5296
5334
|
const $_iEvents = () => $.store_get(_iEvents, "$_iEvents", $$stores);
|
|
5335
|
+
const $slotMaxTime = () => $.store_get(slotMaxTime, "$slotMaxTime", $$stores);
|
|
5297
5336
|
const $scrollTime = () => $.store_get(scrollTime, "$scrollTime", $$stores);
|
|
5298
5337
|
const $_monthView = () => $.store_get(_monthView, "$_monthView", $$stores);
|
|
5299
5338
|
const $_today = () => $.store_get(_today, "$_today", $$stores);
|
|
@@ -5310,6 +5349,7 @@ function View($$anchor, $$props) {
|
|
|
5310
5349
|
const $nowIndicator = () => $.store_get(nowIndicator, "$nowIndicator", $$stores);
|
|
5311
5350
|
const [$$stores, $$cleanup] = $.setup_stores();
|
|
5312
5351
|
let {
|
|
5352
|
+
_activeRangeExt,
|
|
5313
5353
|
_daySlots,
|
|
5314
5354
|
_dayTimeLimits,
|
|
5315
5355
|
_filteredEvents,
|
|
@@ -5328,6 +5368,7 @@ function View($$anchor, $$props) {
|
|
|
5328
5368
|
scrollTime,
|
|
5329
5369
|
slotDuration,
|
|
5330
5370
|
slotHeight,
|
|
5371
|
+
slotMaxTime,
|
|
5331
5372
|
slotWidth,
|
|
5332
5373
|
theme,
|
|
5333
5374
|
validRange
|
|
@@ -5336,6 +5377,21 @@ function View($$anchor, $$props) {
|
|
|
5336
5377
|
let grid = $.derived(() => createGrid($_viewDates(), $_viewResources(), $_dayTimeLimits(), $validRange(), $highlightedDates()));
|
|
5337
5378
|
let $$d = $.derived(() => createEventChunks($_filteredEvents(), $.get(grid))), chunks = $.derived(() => $.get($$d).chunks), bgChunks = $.derived(() => $.get($$d).bgChunks);
|
|
5338
5379
|
let iChunks = $.derived(() => createIEventChunks($_iEvents(), $.get(grid)));
|
|
5380
|
+
$.user_pre_effect(() => {
|
|
5381
|
+
$.store_set(_activeRangeExt, ({ start, end }) => {
|
|
5382
|
+
if ($slotMaxTime().days || $slotMaxTime().seconds > DAY_IN_SECONDS) {
|
|
5383
|
+
addDuration(subtractDay(end), $slotMaxTime());
|
|
5384
|
+
let start2 = subtractDay(cloneDate(end));
|
|
5385
|
+
if (start2 < start) {
|
|
5386
|
+
start = start2;
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5389
|
+
return { start, end };
|
|
5390
|
+
});
|
|
5391
|
+
return () => {
|
|
5392
|
+
$.store_set(_activeRangeExt, identity);
|
|
5393
|
+
};
|
|
5394
|
+
});
|
|
5339
5395
|
$.user_effect(() => {
|
|
5340
5396
|
$_viewDates();
|
|
5341
5397
|
$scrollTime();
|
|
@@ -5356,7 +5412,7 @@ function View($$anchor, $$props) {
|
|
|
5356
5412
|
scrollLeft += toSeconds(slotTimeLimits2.max) - toSeconds(slotTimeLimits2.min);
|
|
5357
5413
|
}
|
|
5358
5414
|
}
|
|
5359
|
-
$.store_mutate(_mainEl, $.untrack($_mainEl).scrollLeft = scrollLeft / toSeconds($slotDuration()) * $slotWidth() * (
|
|
5415
|
+
$.store_mutate(_mainEl, $.untrack($_mainEl).scrollLeft = scrollLeft / toSeconds($slotDuration()) * $slotWidth() * (isRtl() ? -1 : 1), $.untrack($_mainEl));
|
|
5360
5416
|
}
|
|
5361
5417
|
let refs = [];
|
|
5362
5418
|
function reposition() {
|
|
@@ -5550,7 +5606,7 @@ function View($$anchor, $$props) {
|
|
|
5550
5606
|
$.set_class(section, 1, $theme().main);
|
|
5551
5607
|
styles = $.set_style(section, "", styles, {
|
|
5552
5608
|
"--ec-grid-cols": $.get(grid)[0].length,
|
|
5553
|
-
"--ec-grid-rows": $.get(grid).length,
|
|
5609
|
+
"--ec-grid-rows": `${$.get(grid).length > 1 ? `repeat(${$.get(grid).length - 1}, auto)` : ""} minmax(auto, 1fr)`,
|
|
5554
5610
|
"--ec-col-width": $columnWidth() ?? "minmax(4em, 1fr)",
|
|
5555
5611
|
"--ec-slot-label-periodicity": $_slotLabelPeriodicity(),
|
|
5556
5612
|
"--ec-slot-height": `${$slotHeight() ?? ""}px`,
|
package/package.json
CHANGED
package/src/lib/view.js
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext} from 'svelte';
|
|
3
|
-
import {contentFrom, resizeObserver, runReposition} from '#lib';
|
|
3
|
+
import {contentFrom, identity, nextClosestDay, prevClosestDay, resizeObserver, runReposition} from '#lib';
|
|
4
4
|
import Day from './Day.svelte';
|
|
5
5
|
import Event from './Event.svelte';
|
|
6
6
|
import Popup from './Popup.svelte';
|
|
7
7
|
import {createEventChunks, createIEventChunks, createGrid} from './lib.js';
|
|
8
8
|
|
|
9
|
-
let {_mainEl, _colsCount, _filteredEvents, _hiddenChunks, _iEvents, _intlDayHeader,
|
|
10
|
-
_viewDates, dayMaxEvents, highlightedDates, theme,
|
|
9
|
+
let {_activeRangeExt, _mainEl, _colsCount, _filteredEvents, _hiddenChunks, _iEvents, _intlDayHeader,
|
|
10
|
+
_intlDayHeaderAL, _popupDay, _viewDates, dayMaxEvents, firstDay, highlightedDates, theme,
|
|
11
|
+
validRange} = getContext('state');
|
|
11
12
|
|
|
12
13
|
let gridEl = $state();
|
|
13
14
|
let grid = $derived(createGrid($_viewDates, $_colsCount, $validRange, $highlightedDates));
|
|
14
15
|
let {chunks, bgChunks} = $derived(createEventChunks($_filteredEvents, grid));
|
|
15
16
|
let iChunks = $derived(createIEventChunks($_iEvents, grid));
|
|
16
17
|
|
|
18
|
+
$effect.pre(() => {
|
|
19
|
+
$_activeRangeExt = ({start, end}) => ({
|
|
20
|
+
start: prevClosestDay(start, $firstDay),
|
|
21
|
+
end: nextClosestDay(end, $firstDay)
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
$_activeRangeExt = identity;
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
17
28
|
// Events reposition
|
|
18
29
|
let refs = [];
|
|
19
30
|
function reposition() {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import {getContext, onMount} from 'svelte';
|
|
3
3
|
import {
|
|
4
4
|
addDay, addDuration, ancestor, assign, cloneDate, cloneEvent, copyTime, createDuration, getElementWithPayload,
|
|
5
|
-
getPayload, isFunction, listen, listView, max, min, noop, rect, runAll, subtractDay, subtractDuration,
|
|
6
|
-
toEventWithLocalDates, toISOString, toLocalDate, toViewWithLocalDates
|
|
5
|
+
getPayload, isFunction, isRtl, listen, listView, max, min, noop, rect, runAll, subtractDay, subtractDuration,
|
|
6
|
+
timelineView, toEventWithLocalDates, toISOString, toLocalDate, toViewWithLocalDates
|
|
7
7
|
} from '#lib';
|
|
8
8
|
import {animate, limit, eventDraggable} from './lib';
|
|
9
9
|
|
|
@@ -417,7 +417,10 @@
|
|
|
417
417
|
return findPayload(dayEl.previousElementSibling);
|
|
418
418
|
}
|
|
419
419
|
} else {
|
|
420
|
-
if (
|
|
420
|
+
if (
|
|
421
|
+
(selecting() || resizing()) &&
|
|
422
|
+
payload.resource && !$_iEvents[0].resourceIds.includes(payload.resource.id) && !timelineView($view)
|
|
423
|
+
) {
|
|
421
424
|
if (toX > fromX) {
|
|
422
425
|
return findPayload(dayEl.previousElementSibling);
|
|
423
426
|
} else {
|
|
@@ -433,11 +436,14 @@
|
|
|
433
436
|
function calcViewport() {
|
|
434
437
|
let mainRect = rect($_mainEl);
|
|
435
438
|
let gridRect = rect(gridEl);
|
|
439
|
+
let scaleX = mainRect.width / $_mainEl.offsetWidth;
|
|
440
|
+
let scaleY = mainRect.height / $_mainEl.offsetHeight;
|
|
441
|
+
let rtl = isRtl();
|
|
436
442
|
viewport = {
|
|
437
|
-
left: max(0, gridRect.left + $_mainEl.scrollLeft),
|
|
438
|
-
right: min(document.documentElement.clientWidth, mainRect.left + $_mainEl.clientWidth) - 2,
|
|
439
|
-
top: max(0, gridRect.top + (!allDaySlot ? $_mainEl.scrollTop : 0)),
|
|
440
|
-
bottom: min(document.documentElement.clientHeight, !allDaySlot ? mainRect.top + $_mainEl.clientHeight : gridRect.bottom) - 2
|
|
443
|
+
left: max(0, rtl ? mainRect.right - $_mainEl.clientWidth * scaleX : gridRect.left + $_mainEl.scrollLeft * scaleX),
|
|
444
|
+
right: min(document.documentElement.clientWidth, rtl ? gridRect.right + $_mainEl.scrollLeft * scaleX : mainRect.left + $_mainEl.clientWidth * scaleX) - 2,
|
|
445
|
+
top: max(0, gridRect.top + (!allDaySlot ? $_mainEl.scrollTop : 0) * scaleY),
|
|
446
|
+
bottom: min(document.documentElement.clientHeight, !allDaySlot ? mainRect.top + $_mainEl.clientHeight * scaleY : gridRect.bottom) - 2
|
|
441
447
|
};
|
|
442
448
|
}
|
|
443
449
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext} from 'svelte';
|
|
3
|
-
import {addDuration, cloneDate, floor, rect} from '#lib';
|
|
3
|
+
import {addDuration, cloneDate, floor, isRtl, rect} from '#lib';
|
|
4
4
|
import {BaseDay} from '#components';
|
|
5
5
|
|
|
6
6
|
let {day, noIeb, noBeb} = $props();
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
let el = $state();
|
|
13
13
|
|
|
14
14
|
function dateFromPoint(x, y) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if ($_monthView) {
|
|
16
|
+
return date;
|
|
17
|
+
} else {
|
|
18
|
+
let dayRect = rect(el);
|
|
19
|
+
let scaleX = dayRect.width / el.offsetWidth;
|
|
20
|
+
return addDuration(cloneDate(start), $slotDuration, floor((isRtl() ? dayRect.right - x : x - dayRect.left) / ($slotWidth * scaleX)));
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
</script>
|
|
20
24
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext, tick} from 'svelte';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
max, resizeObserver, runReposition, contentFrom, toSeconds, datesEqual, min, isRtl, DAY_IN_SECONDS, addDuration,
|
|
5
|
+
subtractDay, cloneDate, identity
|
|
6
|
+
} from "#lib";
|
|
4
7
|
import {createGrid, createEventChunks, createIEventChunks, getSlotTimeLimits} from './lib.js';
|
|
5
8
|
import {ColHead, DayHeader} from '#components';
|
|
6
9
|
import Day from './Day.svelte';
|
|
@@ -9,9 +12,9 @@
|
|
|
9
12
|
import Expander from './Expander.svelte';
|
|
10
13
|
import NowIndicator from './NowIndicator.svelte';
|
|
11
14
|
|
|
12
|
-
let {_daySlots, _dayTimeLimits, _filteredEvents, _iEvents, _mainEl, _monthView, _nestedResources, _sidebarWidth,
|
|
15
|
+
let {_activeRangeExt, _daySlots, _dayTimeLimits, _filteredEvents, _iEvents, _mainEl, _monthView, _nestedResources, _sidebarWidth,
|
|
13
16
|
_slotLabelPeriodicity, _today, _viewResources, _viewDates, columnWidth, highlightedDates, nowIndicator, scrollTime,
|
|
14
|
-
slotDuration, slotHeight, slotWidth, theme, validRange} = getContext('state');
|
|
17
|
+
slotDuration, slotHeight, slotMaxTime, slotWidth, theme, validRange} = getContext('state');
|
|
15
18
|
|
|
16
19
|
let headerHeight = $state(0);
|
|
17
20
|
|
|
@@ -19,6 +22,22 @@
|
|
|
19
22
|
let {chunks, bgChunks} = $derived(createEventChunks($_filteredEvents, grid));
|
|
20
23
|
let iChunks = $derived(createIEventChunks($_iEvents, grid));
|
|
21
24
|
|
|
25
|
+
$effect.pre(() => {
|
|
26
|
+
$_activeRangeExt = ({start, end}) => {
|
|
27
|
+
if ($slotMaxTime.days || $slotMaxTime.seconds > DAY_IN_SECONDS) {
|
|
28
|
+
addDuration(subtractDay(end), $slotMaxTime);
|
|
29
|
+
let start2 = subtractDay(cloneDate(end));
|
|
30
|
+
if (start2 < start) {
|
|
31
|
+
start = start2;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {start, end};
|
|
35
|
+
};
|
|
36
|
+
return () => {
|
|
37
|
+
$_activeRangeExt = identity;
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
22
41
|
// Handle scrollTime
|
|
23
42
|
$effect(() => {
|
|
24
43
|
$_viewDates;
|
|
@@ -43,7 +62,7 @@
|
|
|
43
62
|
scrollLeft += toSeconds(slotTimeLimits.max) - toSeconds(slotTimeLimits.min);
|
|
44
63
|
}
|
|
45
64
|
}
|
|
46
|
-
$_mainEl.scrollLeft = scrollLeft / toSeconds($slotDuration) * $slotWidth * (
|
|
65
|
+
$_mainEl.scrollLeft = scrollLeft / toSeconds($slotDuration) * $slotWidth * (isRtl() ? -1 : 1);
|
|
47
66
|
}
|
|
48
67
|
|
|
49
68
|
// Events reposition
|
|
@@ -58,7 +77,7 @@
|
|
|
58
77
|
bind:this={$_mainEl}
|
|
59
78
|
class="{$theme.main}"
|
|
60
79
|
style:--ec-grid-cols="{grid[0].length}"
|
|
61
|
-
style:--ec-grid-rows="{grid.length}"
|
|
80
|
+
style:--ec-grid-rows="{grid.length > 1 ? `repeat(${grid.length - 1}, auto)` : ''} minmax(auto, 1fr)"
|
|
62
81
|
style:--ec-col-width="{$columnWidth ?? 'minmax(4em, 1fr)'}"
|
|
63
82
|
style:--ec-slot-label-periodicity="{$_slotLabelPeriodicity}"
|
|
64
83
|
style:--ec-slot-height="{$slotHeight}px"
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
let el = $state();
|
|
13
13
|
|
|
14
14
|
function dateFromPoint(x, y) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (allDay) {
|
|
16
|
+
return date;
|
|
17
|
+
} else {
|
|
18
|
+
let dayRect = rect(el);
|
|
19
|
+
let scaleY = dayRect.height / el.offsetHeight;
|
|
20
|
+
return addDuration(cloneDate(start), $slotDuration, floor((y - dayRect.top) / ($slotHeight * scaleY)));
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
</script>
|
|
20
24
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import {getContext, tick} from 'svelte';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
addDuration, cloneDate, contentFrom, DAY_IN_SECONDS, identity, resizeObserver, runReposition, subtractDay,
|
|
5
|
+
toSeconds
|
|
6
|
+
} from '#lib';
|
|
4
7
|
import {createAllDayContent, createGrid, createEventChunks, createIEventChunks} from './lib.js';
|
|
5
8
|
import {ColHead, DayHeader} from '#components';
|
|
6
9
|
import Day from './Day.svelte';
|
|
@@ -10,9 +13,9 @@
|
|
|
10
13
|
|
|
11
14
|
let {header, nowIndicator, createGridFn} = $props();
|
|
12
15
|
|
|
13
|
-
let {_mainEl, _filteredEvents, _iEvents, _sidebarWidth, _slotLabelPeriodicity, _slotTimeLimits, _slots,
|
|
16
|
+
let {_activeRangeExt, _mainEl, _filteredEvents, _iEvents, _sidebarWidth, _slotLabelPeriodicity, _slotTimeLimits, _slots,
|
|
14
17
|
_viewDates, allDayContent, allDaySlot, columnWidth, highlightedDates, nowIndicator: showNowIndicator,
|
|
15
|
-
scrollTime, slotHeight, slotDuration, theme, validRange} = getContext('state');
|
|
18
|
+
scrollTime, slotHeight, slotDuration, slotMaxTime, theme, validRange} = getContext('state');
|
|
16
19
|
|
|
17
20
|
let headerHeight = $state(0);
|
|
18
21
|
let allDayText = $derived(createAllDayContent($allDayContent));
|
|
@@ -21,6 +24,22 @@
|
|
|
21
24
|
let {chunks, bgChunks, allDayChunks, allDayBgChunks} = $derived(createEventChunks($_filteredEvents, grid));
|
|
22
25
|
let {iChunks, allDayIChunks} = $derived(createIEventChunks($_iEvents, grid));
|
|
23
26
|
|
|
27
|
+
$effect.pre(() => {
|
|
28
|
+
$_activeRangeExt = ({start, end}) => {
|
|
29
|
+
if ($slotMaxTime.days || $slotMaxTime.seconds > DAY_IN_SECONDS) {
|
|
30
|
+
addDuration(subtractDay(end), $slotMaxTime);
|
|
31
|
+
let start2 = subtractDay(cloneDate(end));
|
|
32
|
+
if (start2 < start) {
|
|
33
|
+
start = start2;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return {start, end};
|
|
37
|
+
};
|
|
38
|
+
return () => {
|
|
39
|
+
$_activeRangeExt = identity;
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
24
43
|
// Handle scrollTime
|
|
25
44
|
$effect(() => {
|
|
26
45
|
$_viewDates;
|
package/src/storage/state.js
CHANGED
|
@@ -27,6 +27,7 @@ export default class {
|
|
|
27
27
|
this._auxiliary = writable([]); // auxiliary components
|
|
28
28
|
this._dayGrid = dayGrid(this);
|
|
29
29
|
this._currentRange = currentRange(this);
|
|
30
|
+
this._activeRangeExt = writable(identity);
|
|
30
31
|
this._activeRange = activeRange(this);
|
|
31
32
|
this._fetchedRange = writable({start: undefined, end: undefined});
|
|
32
33
|
this._events = events(this);
|
package/src/storage/stores.js
CHANGED
|
@@ -11,24 +11,9 @@ export function dayGrid(state) {
|
|
|
11
11
|
|
|
12
12
|
export function activeRange(state) {
|
|
13
13
|
return derived(
|
|
14
|
-
[state._currentRange, state.
|
|
15
|
-
([$_currentRange, $
|
|
16
|
-
|
|
17
|
-
let end = cloneDate($_currentRange.end);
|
|
18
|
-
|
|
19
|
-
if ($_dayGrid) {
|
|
20
|
-
// First day of week
|
|
21
|
-
prevClosestDay(start, $firstDay);
|
|
22
|
-
nextClosestDay(end, $firstDay);
|
|
23
|
-
} else if ($slotMaxTime.days || $slotMaxTime.seconds > DAY_IN_SECONDS) {
|
|
24
|
-
addDuration(subtractDay(end), $slotMaxTime);
|
|
25
|
-
let start2 = subtractDay(cloneDate(end));
|
|
26
|
-
if (start2 < start) {
|
|
27
|
-
start = start2;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return {start, end};
|
|
14
|
+
[state._currentRange, state._activeRangeExt],
|
|
15
|
+
([$_currentRange, $_activeRangeExt]) => {
|
|
16
|
+
return $_activeRangeExt({start: cloneDate($_currentRange.start), end: cloneDate($_currentRange.end)});
|
|
32
17
|
}
|
|
33
18
|
);
|
|
34
19
|
}
|
|
@@ -235,9 +220,10 @@ export function now() {
|
|
|
235
220
|
}
|
|
236
221
|
|
|
237
222
|
export function today(state) {
|
|
238
|
-
let $today = createDate();
|
|
223
|
+
let $today = setMidnight(createDate());
|
|
239
224
|
let today = writable($today);
|
|
240
|
-
|
|
225
|
+
state._now.subscribe($_now => {
|
|
226
|
+
let newToday = setMidnight(cloneDate($_now));
|
|
241
227
|
if (!datesEqual($today, newToday)) {
|
|
242
228
|
$today = newToday;
|
|
243
229
|
today.set(newToday);
|
package/src/styles/index.css
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
.ec-timeline & {
|
|
39
39
|
grid-template-columns: max-content repeat(var(--ec-grid-cols), min-content);
|
|
40
|
-
grid-template-rows: max-content
|
|
40
|
+
grid-template-rows: max-content var(--ec-grid-rows);
|
|
41
41
|
flex-grow: 1;
|
|
42
42
|
}
|
|
43
43
|
|
package/src/styles/sidebar.css
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
inset-inline-start: 0;
|
|
4
4
|
z-index: 1;
|
|
5
5
|
background-color: var(--ec-bg-color);
|
|
6
|
-
border-
|
|
7
|
-
border-width: 1px;
|
|
8
|
-
border-inline-end-style: solid;
|
|
6
|
+
border-inline-end: 1px solid var(--ec-border-color);
|
|
9
7
|
text-align: end;
|
|
10
8
|
overflow: clip;
|
|
11
9
|
|
|
12
10
|
.ec-header & {
|
|
13
|
-
border-block-end
|
|
11
|
+
border-block-end: 1px solid var(--ec-border-color);
|
|
14
12
|
padding-block: .375rem;
|
|
15
13
|
}
|
|
16
14
|
|