@super-calendar/dom 2.8.2 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/index.d.mts +88 -11
- package/dist/index.d.ts +88 -11
- package/dist/index.js +394 -85
- package/dist/index.mjs +396 -87
- package/package.json +2 -2
- package/src/Calendar.tsx +49 -4
- package/src/MonthView.tsx +200 -50
- package/src/TimeGrid.tsx +257 -54
- package/src/YearView.tsx +218 -19
package/dist/index.js
CHANGED
|
@@ -241,12 +241,56 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
|
|
|
241
241
|
* highlighted and a dot under days that hold events. It's the view `Calendar`
|
|
242
242
|
* renders for `mode="year"`.
|
|
243
243
|
*/
|
|
244
|
-
function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, theme: themeOverrides, className, style, classNames, styles }) {
|
|
244
|
+
function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, theme: themeOverrides, className, style, classNames, styles }) {
|
|
245
245
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
246
246
|
const slot = createSlots({
|
|
247
247
|
classNames,
|
|
248
248
|
styles
|
|
249
249
|
});
|
|
250
|
+
const sweepEnabled = onSelectDrag != null || onCreateEvent != null;
|
|
251
|
+
const [creating, setCreating] = (0, react.useState)(null);
|
|
252
|
+
const creatingRef = (0, react.useRef)(creating);
|
|
253
|
+
creatingRef.current = creating;
|
|
254
|
+
const movedRef = (0, react.useRef)(false);
|
|
255
|
+
const suppressClickRef = (0, react.useRef)(false);
|
|
256
|
+
const beginPress = () => {
|
|
257
|
+
suppressClickRef.current = false;
|
|
258
|
+
movedRef.current = false;
|
|
259
|
+
};
|
|
260
|
+
const beginCreate = (day) => {
|
|
261
|
+
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
262
|
+
setCreating({
|
|
263
|
+
anchor: t,
|
|
264
|
+
hover: t
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
const extendCreate = (day) => {
|
|
268
|
+
const current = creatingRef.current;
|
|
269
|
+
if (!current) return;
|
|
270
|
+
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
271
|
+
if (t === current.hover) return;
|
|
272
|
+
movedRef.current = true;
|
|
273
|
+
setCreating((c) => c ? {
|
|
274
|
+
...c,
|
|
275
|
+
hover: t
|
|
276
|
+
} : c);
|
|
277
|
+
const [lo, hi] = current.anchor <= t ? [current.anchor, t] : [t, current.anchor];
|
|
278
|
+
onSelectDrag?.(new Date(lo), new Date(hi));
|
|
279
|
+
};
|
|
280
|
+
const isCreating = creating !== null;
|
|
281
|
+
(0, react.useEffect)(() => {
|
|
282
|
+
if (!isCreating) return;
|
|
283
|
+
const finish = () => {
|
|
284
|
+
const c = creatingRef.current;
|
|
285
|
+
setCreating(null);
|
|
286
|
+
if (!c || !movedRef.current) return;
|
|
287
|
+
suppressClickRef.current = true;
|
|
288
|
+
const range = (0, _super_calendar_core.monthCreateRange)(new Date(c.anchor), new Date(c.hover));
|
|
289
|
+
onCreateEvent?.(range.start, range.end);
|
|
290
|
+
};
|
|
291
|
+
window.addEventListener("pointerup", finish);
|
|
292
|
+
return () => window.removeEventListener("pointerup", finish);
|
|
293
|
+
}, [isCreating, onCreateEvent]);
|
|
250
294
|
const months = (0, react.useMemo)(() => (0, _super_calendar_core.getYearMonths)(date), [date]);
|
|
251
295
|
const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.filterHiddenDays)((0, _super_calendar_core.getWeekDays)(date, weekStartsOn), hiddenDays).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
|
|
252
296
|
date,
|
|
@@ -343,9 +387,21 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDa
|
|
|
343
387
|
"aria-hidden": true,
|
|
344
388
|
style: { aspectRatio: "1" }
|
|
345
389
|
}, day.toISOString());
|
|
346
|
-
const
|
|
390
|
+
const isToday = (0, _super_calendar_core.getIsToday)(day);
|
|
391
|
+
const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : isToday;
|
|
347
392
|
const hasEvents = eventDays.has((0, date_fns.startOfDay)(day).toISOString());
|
|
348
|
-
const
|
|
393
|
+
const state = (0, _super_calendar_core.daySelectionState)(day, {
|
|
394
|
+
selectedDates,
|
|
395
|
+
selectedRange
|
|
396
|
+
}, {
|
|
397
|
+
minDate,
|
|
398
|
+
maxDate,
|
|
399
|
+
isDateDisabled
|
|
400
|
+
});
|
|
401
|
+
const dayTime = (0, date_fns.startOfDay)(day).getTime();
|
|
402
|
+
const inCreate = creating != null && dayTime >= Math.min(creating.anchor, creating.hover) && dayTime <= Math.max(creating.anchor, creating.hover);
|
|
403
|
+
const label = `${(0, date_fns.format)(day, "EEEE, d LLLL yyyy", { locale })}${isToday ? ", today" : ""}${state.isSelected ? ", selected" : ""}${state.isDisabled ? ", unavailable" : ""}${hasEvents ? ", has events" : ""}`;
|
|
404
|
+
const badge = (0, _super_calendar_core.dayBadgeKind)(state, isHighlighted);
|
|
349
405
|
const daySlot = slot("day", {
|
|
350
406
|
base: {
|
|
351
407
|
position: "relative",
|
|
@@ -357,21 +413,40 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDa
|
|
|
357
413
|
border: "none",
|
|
358
414
|
background: "transparent",
|
|
359
415
|
font: "inherit",
|
|
360
|
-
cursor: onPressDay ? "pointer" : "default",
|
|
361
|
-
boxSizing: "border-box"
|
|
416
|
+
cursor: state.isDisabled ? "default" : onPressDay || sweepEnabled ? "pointer" : "default",
|
|
417
|
+
boxSizing: "border-box",
|
|
418
|
+
...sweepEnabled ? { touchAction: "pan-y" } : null
|
|
362
419
|
},
|
|
363
420
|
themed: {
|
|
364
421
|
fontSize: 11,
|
|
365
|
-
|
|
366
|
-
...isHighlighted ? {
|
|
367
|
-
background: theme.todayBackground,
|
|
368
|
-
color: theme.todayText
|
|
369
|
-
} : { color: theme.text }
|
|
422
|
+
color: state.isDisabled ? theme.textDisabled : theme.text
|
|
370
423
|
}
|
|
371
424
|
});
|
|
372
425
|
const states = dataState({
|
|
373
|
-
"data-today":
|
|
374
|
-
"data-events": hasEvents
|
|
426
|
+
"data-today": isToday,
|
|
427
|
+
"data-events": hasEvents,
|
|
428
|
+
"data-selected": state.isSelected,
|
|
429
|
+
"data-range": state.isInRange,
|
|
430
|
+
"data-disabled": state.isDisabled,
|
|
431
|
+
"data-creating": inCreate
|
|
432
|
+
});
|
|
433
|
+
const bandKind = (0, _super_calendar_core.rangeBandKind)(state, true);
|
|
434
|
+
const rounding = (0, _super_calendar_core.bandRounding)((0, _super_calendar_core.rangeBandKind)(state, false));
|
|
435
|
+
const band = bandKind === "none" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
436
|
+
"data-band": true,
|
|
437
|
+
"aria-hidden": true,
|
|
438
|
+
...slot("rangeBand", {
|
|
439
|
+
base: {
|
|
440
|
+
position: "absolute",
|
|
441
|
+
inset: 0,
|
|
442
|
+
zIndex: 0,
|
|
443
|
+
borderTopLeftRadius: rounding.start ? "50%" : 0,
|
|
444
|
+
borderBottomLeftRadius: rounding.start ? "50%" : 0,
|
|
445
|
+
borderTopRightRadius: rounding.end ? "50%" : 0,
|
|
446
|
+
borderBottomRightRadius: rounding.end ? "50%" : 0
|
|
447
|
+
},
|
|
448
|
+
themed: { background: theme.rangeBackground }
|
|
449
|
+
})
|
|
375
450
|
});
|
|
376
451
|
const dot = hasEvents ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
377
452
|
"aria-hidden": true,
|
|
@@ -381,27 +456,77 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDa
|
|
|
381
456
|
bottom: 1,
|
|
382
457
|
left: "50%",
|
|
383
458
|
marginLeft: -1.5,
|
|
459
|
+
zIndex: 2,
|
|
384
460
|
width: 3,
|
|
385
461
|
height: 3,
|
|
386
462
|
borderRadius: 2
|
|
387
463
|
},
|
|
388
|
-
themed: { background:
|
|
464
|
+
themed: { background: badge === "none" ? theme.todayBackground : theme.todayText }
|
|
389
465
|
})
|
|
390
466
|
}) : null;
|
|
391
|
-
|
|
467
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
468
|
+
band,
|
|
469
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
470
|
+
...slot("dayBadge", {
|
|
471
|
+
base: {
|
|
472
|
+
position: "relative",
|
|
473
|
+
zIndex: 1,
|
|
474
|
+
width: "100%",
|
|
475
|
+
height: "100%",
|
|
476
|
+
borderRadius: "50%",
|
|
477
|
+
display: "flex",
|
|
478
|
+
alignItems: "center",
|
|
479
|
+
justifyContent: "center"
|
|
480
|
+
},
|
|
481
|
+
themed: badge === "today" ? {
|
|
482
|
+
background: theme.todayBackground,
|
|
483
|
+
color: theme.todayText
|
|
484
|
+
} : badge === "selected" ? {
|
|
485
|
+
background: theme.selectedBackground,
|
|
486
|
+
color: theme.selectedText
|
|
487
|
+
} : {}
|
|
488
|
+
}),
|
|
489
|
+
children: day.getDate()
|
|
490
|
+
}),
|
|
491
|
+
dot
|
|
492
|
+
] });
|
|
493
|
+
const sweepHandlers = sweepEnabled ? {
|
|
494
|
+
onPointerDown: (e) => {
|
|
495
|
+
beginPress();
|
|
496
|
+
if (e.button === 0 && !state.isDisabled) beginCreate(day);
|
|
497
|
+
},
|
|
498
|
+
onPointerEnter: state.isDisabled ? void 0 : () => extendCreate(day)
|
|
499
|
+
} : null;
|
|
500
|
+
return onPressDay ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
392
501
|
type: "button",
|
|
393
502
|
role: "gridcell",
|
|
394
|
-
|
|
503
|
+
disabled: state.isDisabled,
|
|
395
504
|
"aria-label": label,
|
|
505
|
+
onClick: () => {
|
|
506
|
+
if (suppressClickRef.current) {
|
|
507
|
+
suppressClickRef.current = false;
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
onPressDay(day);
|
|
511
|
+
},
|
|
512
|
+
...sweepHandlers,
|
|
396
513
|
...states,
|
|
397
514
|
...daySlot,
|
|
398
|
-
children:
|
|
399
|
-
}, day.toISOString()) : /* @__PURE__ */ (0, react_jsx_runtime.
|
|
515
|
+
children: content
|
|
516
|
+
}, day.toISOString()) : sweepEnabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
400
517
|
role: "gridcell",
|
|
518
|
+
"aria-disabled": state.isDisabled || void 0,
|
|
401
519
|
"aria-label": label,
|
|
520
|
+
...sweepHandlers,
|
|
402
521
|
...states,
|
|
403
522
|
...daySlot,
|
|
404
|
-
children:
|
|
523
|
+
children: content
|
|
524
|
+
}, day.toISOString()) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
525
|
+
role: "gridcell",
|
|
526
|
+
"aria-label": label,
|
|
527
|
+
...states,
|
|
528
|
+
...daySlot,
|
|
529
|
+
children: content
|
|
405
530
|
}, day.toISOString());
|
|
406
531
|
})
|
|
407
532
|
}, week[0].toISOString()))
|
|
@@ -422,6 +547,7 @@ const DATE_ROW = 24;
|
|
|
422
547
|
const CHIP_HEIGHT = 18;
|
|
423
548
|
const CHIP_GAP = 2;
|
|
424
549
|
const CELL_PAD = 4;
|
|
550
|
+
const DRAGGED_CHIP_OPACITY = .4;
|
|
425
551
|
function dayCellDefault(day, theme, highlightWeekends) {
|
|
426
552
|
return {
|
|
427
553
|
base: {
|
|
@@ -448,21 +574,27 @@ function dayCellDefault(day, theme, highlightWeekends) {
|
|
|
448
574
|
* rounded strip (the default) or fill the whole cell (`fillCell`). Returns null
|
|
449
575
|
* for days with no band. Endpoints get the leading/trailing pill rounding. Its
|
|
450
576
|
* geometry is structural; only the fill colour is themed.
|
|
577
|
+
*
|
|
578
|
+
* In events mode the strip tracks the compact date badge instead of the picker's
|
|
579
|
+
* tall cell, so it reads as a band across the dates rather than a block over the
|
|
580
|
+
* event chips (and matches the native renderer's month grid).
|
|
451
581
|
*/
|
|
452
|
-
function rangeBandDefault(day, theme, fillCell) {
|
|
582
|
+
function rangeBandDefault(day, theme, fillCell, eventsMode) {
|
|
453
583
|
const kind = (0, _super_calendar_core.rangeBandKind)(day, fillCell);
|
|
454
584
|
if (kind === "none") return null;
|
|
455
585
|
const fill = kind === "fill";
|
|
456
|
-
const
|
|
457
|
-
const
|
|
586
|
+
const badgeSize = eventsMode ? DATE_ROW - 2 : theme.dayBadgeSize;
|
|
587
|
+
const bandHeight = eventsMode ? badgeSize : theme.rangeBandHeight;
|
|
588
|
+
const inset = fill ? 0 : eventsMode ? CELL_PAD : Math.max(0, (theme.cellHeight - bandHeight) / 2);
|
|
589
|
+
const radius = fill ? 0 : bandHeight / 2;
|
|
458
590
|
const rounding = (0, _super_calendar_core.bandRounding)(kind);
|
|
459
|
-
const cap = `calc(50% - ${
|
|
591
|
+
const cap = eventsMode ? 0 : `calc(50% - ${badgeSize / 2}px)`;
|
|
460
592
|
const base = {
|
|
461
593
|
position: "absolute",
|
|
462
594
|
left: rounding.start ? cap : 0,
|
|
463
595
|
right: rounding.end ? cap : 0,
|
|
464
596
|
top: inset,
|
|
465
|
-
bottom: inset,
|
|
597
|
+
...fill || !eventsMode ? { bottom: inset } : { height: bandHeight },
|
|
466
598
|
zIndex: 0
|
|
467
599
|
};
|
|
468
600
|
if (rounding.start) {
|
|
@@ -499,7 +631,7 @@ function badgeDefault(day, theme, hovered) {
|
|
|
499
631
|
}
|
|
500
632
|
};
|
|
501
633
|
}
|
|
502
|
-
function eventCellDefault(day, theme, height, highlightWeekends) {
|
|
634
|
+
function eventCellDefault(day, theme, height, highlightWeekends, isDragTarget) {
|
|
503
635
|
return {
|
|
504
636
|
base: {
|
|
505
637
|
position: "relative",
|
|
@@ -517,7 +649,7 @@ function eventCellDefault(day, theme, height, highlightWeekends) {
|
|
|
517
649
|
},
|
|
518
650
|
themed: {
|
|
519
651
|
borderTop: `1px solid ${theme.gridLine}`,
|
|
520
|
-
background: highlightWeekends && day.isWeekend && !day.isInRange ? theme.weekendBackground : "transparent",
|
|
652
|
+
background: isDragTarget ? theme.rangeBackground : highlightWeekends && day.isWeekend && !day.isInRange ? theme.weekendBackground : "transparent",
|
|
521
653
|
color: day.isDisabled ? theme.textDisabled : theme.text
|
|
522
654
|
}
|
|
523
655
|
};
|
|
@@ -617,7 +749,7 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
617
749
|
* <MonthView date={new Date()} events={events} onPressDay={(d) => setDate(d)} />
|
|
618
750
|
* ```
|
|
619
751
|
*/
|
|
620
|
-
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onCreateEvent, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
752
|
+
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onPressCell, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
621
753
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
622
754
|
const slot = createSlots({
|
|
623
755
|
classNames,
|
|
@@ -707,46 +839,87 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
707
839
|
const [hoveredKey, setHoveredKey] = (0, react.useState)(null);
|
|
708
840
|
const gridRef = (0, react.useRef)(null);
|
|
709
841
|
const focusKey = (0, date_fns.format)(focusedDate, "yyyy-MM-dd");
|
|
710
|
-
const [
|
|
711
|
-
const
|
|
712
|
-
|
|
842
|
+
const [drag, setDrag] = (0, react.useState)(null);
|
|
843
|
+
const dragRef = (0, react.useRef)(drag);
|
|
844
|
+
dragRef.current = drag;
|
|
713
845
|
const movedRef = (0, react.useRef)(false);
|
|
714
846
|
const suppressClickRef = (0, react.useRef)(false);
|
|
847
|
+
const consumeSuppressedClick = () => {
|
|
848
|
+
if (!suppressClickRef.current) return false;
|
|
849
|
+
suppressClickRef.current = false;
|
|
850
|
+
return true;
|
|
851
|
+
};
|
|
852
|
+
const canMove = (event) => onDragEvent != null && !event.disabled && event.draggable !== false && (event.startEditable ?? eventStartEditable);
|
|
853
|
+
const beginPress = () => {
|
|
854
|
+
suppressClickRef.current = false;
|
|
855
|
+
movedRef.current = false;
|
|
856
|
+
};
|
|
715
857
|
const beginCreate = (day) => {
|
|
716
|
-
if (!onCreateEvent) return;
|
|
858
|
+
if (!onCreateEvent && !onSelectDrag) return;
|
|
717
859
|
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
718
|
-
|
|
719
|
-
|
|
860
|
+
setDrag({
|
|
861
|
+
kind: "create",
|
|
720
862
|
anchor: t,
|
|
721
863
|
hover: t
|
|
722
864
|
});
|
|
723
865
|
};
|
|
724
|
-
const
|
|
725
|
-
if (!
|
|
866
|
+
const beginMove = (event, day) => {
|
|
867
|
+
if (!canMove(event)) return;
|
|
868
|
+
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
869
|
+
setDrag({
|
|
870
|
+
kind: "move",
|
|
871
|
+
event,
|
|
872
|
+
from: t,
|
|
873
|
+
to: t
|
|
874
|
+
});
|
|
875
|
+
onDragStart?.(event);
|
|
876
|
+
};
|
|
877
|
+
const extendDrag = (day) => {
|
|
878
|
+
const current = dragRef.current;
|
|
879
|
+
if (!current) return;
|
|
726
880
|
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
727
|
-
if (t
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
881
|
+
if (t === (current.kind === "create" ? current.hover : current.to)) return;
|
|
882
|
+
movedRef.current = true;
|
|
883
|
+
setDrag(current.kind === "create" ? {
|
|
884
|
+
...current,
|
|
885
|
+
hover: t
|
|
886
|
+
} : {
|
|
887
|
+
...current,
|
|
888
|
+
to: t
|
|
889
|
+
});
|
|
890
|
+
if (current.kind === "create") {
|
|
891
|
+
const [lo, hi] = current.anchor <= t ? [current.anchor, t] : [t, current.anchor];
|
|
892
|
+
onSelectDrag?.(new Date(lo), new Date(hi));
|
|
733
893
|
}
|
|
734
894
|
};
|
|
735
|
-
const
|
|
895
|
+
const isDragging = drag !== null;
|
|
896
|
+
const dragWired = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
|
|
736
897
|
(0, react.useEffect)(() => {
|
|
737
|
-
if (!
|
|
898
|
+
if (!isDragging) return;
|
|
738
899
|
const finish = () => {
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
if (!
|
|
900
|
+
const current = dragRef.current;
|
|
901
|
+
setDrag(null);
|
|
902
|
+
if (!current || !movedRef.current) return;
|
|
742
903
|
suppressClickRef.current = true;
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
904
|
+
if (current.kind === "create") {
|
|
905
|
+
const range = (0, _super_calendar_core.monthCreateRange)(new Date(current.anchor), new Date(current.hover));
|
|
906
|
+
onCreateEvent?.(range.start, range.end);
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
const next = (0, _super_calendar_core.monthDropBounds)(current.event, new Date(current.from), new Date(current.to));
|
|
910
|
+
if (!next) return;
|
|
911
|
+
if (eventOverlap === false && (0, _super_calendar_core.overlapsOtherEvents)(events ?? [], current.event, next.start, next.end)) return;
|
|
912
|
+
onDragEvent?.(current.event, next.start, next.end);
|
|
746
913
|
};
|
|
747
914
|
window.addEventListener("pointerup", finish);
|
|
748
915
|
return () => window.removeEventListener("pointerup", finish);
|
|
749
|
-
}, [
|
|
916
|
+
}, [
|
|
917
|
+
isDragging,
|
|
918
|
+
onCreateEvent,
|
|
919
|
+
onDragEvent,
|
|
920
|
+
eventOverlap,
|
|
921
|
+
events
|
|
922
|
+
]);
|
|
750
923
|
const onKeyDown = (e) => {
|
|
751
924
|
let next = null;
|
|
752
925
|
if (e.key === "ArrowLeft") next = (0, date_fns.addDays)(focusedDate, -1);
|
|
@@ -846,10 +1019,11 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
846
1019
|
"aria-hidden": true,
|
|
847
1020
|
style: { height: cellHeight }
|
|
848
1021
|
}, day.id);
|
|
849
|
-
const band = rangeBandDefault(day, theme, fillCellOnSelection);
|
|
1022
|
+
const band = rangeBandDefault(day, theme, fillCellOnSelection, eventsMode);
|
|
850
1023
|
const label = (0, date_fns.format)(day.date, "EEEE, d MMMM yyyy", locale ? { locale } : void 0);
|
|
851
1024
|
const dayTime = (0, date_fns.startOfDay)(day.date).getTime();
|
|
852
|
-
const inCreate =
|
|
1025
|
+
const inCreate = drag?.kind === "create" && dayTime >= Math.min(drag.anchor, drag.hover) && dayTime <= Math.max(drag.anchor, drag.hover);
|
|
1026
|
+
const isDropTarget = drag?.kind === "move" && dayTime === drag.to && drag.to !== drag.from;
|
|
853
1027
|
const dayData = dataState({
|
|
854
1028
|
"data-today": day.isToday,
|
|
855
1029
|
"data-selected": day.isSelected,
|
|
@@ -857,13 +1031,14 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
857
1031
|
"data-weekend": day.isWeekend,
|
|
858
1032
|
"data-outside": !day.isCurrentMonth,
|
|
859
1033
|
"data-disabled": day.isDisabled,
|
|
860
|
-
"data-creating": inCreate
|
|
1034
|
+
"data-creating": inCreate,
|
|
1035
|
+
"data-drop": isDropTarget
|
|
861
1036
|
});
|
|
862
1037
|
if (eventsMode) {
|
|
863
1038
|
const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day.date).toISOString()) ?? [];
|
|
864
1039
|
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= visibleLanes).map((s) => s.event);
|
|
865
1040
|
const dayLabel = (0, date_fns.format)(day.date, "d MMMM", locale ? { locale } : void 0);
|
|
866
|
-
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends));
|
|
1041
|
+
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget));
|
|
867
1042
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
868
1043
|
role: "gridcell",
|
|
869
1044
|
"data-day": day.id,
|
|
@@ -872,26 +1047,28 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
872
1047
|
"aria-disabled": day.isDisabled || void 0,
|
|
873
1048
|
"aria-label": label,
|
|
874
1049
|
...dayCellProps,
|
|
875
|
-
style:
|
|
1050
|
+
style: dragWired ? {
|
|
876
1051
|
...dayCellProps.style,
|
|
877
|
-
touchAction: "none"
|
|
1052
|
+
touchAction: "none",
|
|
1053
|
+
userSelect: "none"
|
|
878
1054
|
} : dayCellProps.style,
|
|
879
|
-
onPointerDown:
|
|
880
|
-
if (e.button
|
|
1055
|
+
onPointerDown: dragWired && !day.isDisabled ? (e) => {
|
|
1056
|
+
if (e.button !== 0) return;
|
|
1057
|
+
beginPress();
|
|
1058
|
+
beginCreate(day.date);
|
|
881
1059
|
} : void 0,
|
|
882
|
-
onPointerEnter:
|
|
1060
|
+
onPointerEnter: dragWired && !day.isDisabled ? () => extendDrag(day.date) : void 0,
|
|
883
1061
|
onClick: day.isDisabled ? void 0 : () => {
|
|
884
|
-
if (
|
|
885
|
-
suppressClickRef.current = false;
|
|
886
|
-
return;
|
|
887
|
-
}
|
|
1062
|
+
if (consumeSuppressedClick()) return;
|
|
888
1063
|
onPressDay?.(day.date);
|
|
1064
|
+
onPressCell?.((0, date_fns.startOfDay)(day.date));
|
|
889
1065
|
},
|
|
890
1066
|
onKeyDown: keyboardDayNavigation && !day.isDisabled ? (e) => {
|
|
891
1067
|
if (e.target !== e.currentTarget) return;
|
|
892
1068
|
if (e.key === "Enter" || e.key === " ") {
|
|
893
1069
|
e.preventDefault();
|
|
894
1070
|
onPressDay?.(day.date);
|
|
1071
|
+
onPressCell?.((0, date_fns.startOfDay)(day.date));
|
|
895
1072
|
}
|
|
896
1073
|
} : void 0,
|
|
897
1074
|
children: [
|
|
@@ -907,10 +1084,18 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
907
1084
|
}),
|
|
908
1085
|
barSegs.filter((b) => b.startCol === dayCol).map((b) => {
|
|
909
1086
|
const span = b.endCol - b.startCol + 1;
|
|
1087
|
+
const isDragged = drag?.kind === "move" && drag.event === b.seg.event;
|
|
910
1088
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
911
1089
|
type: "button",
|
|
1090
|
+
onPointerDown: canMove(b.seg.event) ? (e) => {
|
|
1091
|
+
if (e.button !== 0) return;
|
|
1092
|
+
e.stopPropagation();
|
|
1093
|
+
beginPress();
|
|
1094
|
+
beginMove(b.seg.event, day.date);
|
|
1095
|
+
} : void 0,
|
|
912
1096
|
onClick: (e) => {
|
|
913
1097
|
e.stopPropagation();
|
|
1098
|
+
if (consumeSuppressedClick()) return;
|
|
914
1099
|
onPressEvent?.(b.seg.event);
|
|
915
1100
|
},
|
|
916
1101
|
...barChipButton,
|
|
@@ -927,7 +1112,10 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
927
1112
|
width: `calc(${span * 100}% - 4px)`,
|
|
928
1113
|
top: 30 + b.seg.lane * 20,
|
|
929
1114
|
height: CHIP_HEIGHT,
|
|
930
|
-
pointerEvents:
|
|
1115
|
+
pointerEvents: isDragging ? "none" : "auto",
|
|
1116
|
+
opacity: isDragged ? DRAGGED_CHIP_OPACITY : void 0,
|
|
1117
|
+
cursor: canMove(b.seg.event) ? "grab" : void 0,
|
|
1118
|
+
touchAction: dragWired ? "none" : void 0,
|
|
931
1119
|
zIndex: 2
|
|
932
1120
|
},
|
|
933
1121
|
children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
|
|
@@ -1064,7 +1252,10 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1064
1252
|
"aria-label": label,
|
|
1065
1253
|
"aria-pressed": day.isSelected || day.isInRange,
|
|
1066
1254
|
...slot("day", dayCellDefault(day, theme, highlightWeekends)),
|
|
1067
|
-
onClick: day.isDisabled ? void 0 : () =>
|
|
1255
|
+
onClick: day.isDisabled ? void 0 : () => {
|
|
1256
|
+
onPressDay?.(day.date);
|
|
1257
|
+
onPressCell?.((0, date_fns.startOfDay)(day.date));
|
|
1258
|
+
},
|
|
1068
1259
|
onMouseEnter: day.isDisabled ? void 0 : () => setHoveredKey(day.id),
|
|
1069
1260
|
onMouseLeave: () => setHoveredKey((k) => k === day.id ? null : k),
|
|
1070
1261
|
children: [band ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1087,6 +1278,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1087
1278
|
//#endregion
|
|
1088
1279
|
//#region src/TimeGrid.tsx
|
|
1089
1280
|
const GUTTER_WIDTH$1 = 56;
|
|
1281
|
+
const HOURS_PER_DAY = 24;
|
|
1090
1282
|
const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
1091
1283
|
const EDGE_ZONE = 32;
|
|
1092
1284
|
const EDGE_DWELL_MS = 600;
|
|
@@ -1192,7 +1384,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1192
1384
|
});
|
|
1193
1385
|
const scrollRef = (0, react.useRef)(null);
|
|
1194
1386
|
const dfns = locale ? { locale } : void 0;
|
|
1195
|
-
const
|
|
1387
|
+
const snapMinutes = Math.max(1, dragStepMinutes);
|
|
1388
|
+
const snapHours = snapMinutes / 60;
|
|
1196
1389
|
const windowStart = Math.max(0, Math.min(minHour, 23));
|
|
1197
1390
|
const windowEnd = Math.max(windowStart + 1, Math.min(maxHour, 24));
|
|
1198
1391
|
const windowHours = windowEnd - windowStart;
|
|
@@ -1355,15 +1548,22 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1355
1548
|
const dHours = (e.clientY - dragOrigin.current.pointerY) / hourHeightRef.current;
|
|
1356
1549
|
const snap = (v) => Math.round(v / snapHours) * snapHours;
|
|
1357
1550
|
if (d.kind === "move") {
|
|
1358
|
-
const
|
|
1551
|
+
const raw = snap(dragOrigin.current.startHours + dHours);
|
|
1552
|
+
const startHours = d.continuesBefore ? raw : (0, _super_calendar_core.clampMoveStartMinutes)(raw * 60, windowStart, windowEnd, snapMinutes) / 60;
|
|
1359
1553
|
const o = dragOrigin.current;
|
|
1360
1554
|
const rawDayDelta = o.dayWidth > 0 ? Math.round((e.clientX - o.pointerX) / o.dayWidth) : 0;
|
|
1361
|
-
const
|
|
1555
|
+
const targetDay = clamp$1(o.dayIndex + rawDayDelta, 0, daysRef.current.length - 1);
|
|
1556
|
+
const dayDelta = targetDay - o.dayIndex;
|
|
1557
|
+
const spillHours = Math.min(Math.max(startHours + d.durationHours - HOURS_PER_DAY, 0), windowHours);
|
|
1558
|
+
const nextDay = daysRef.current[targetDay + 1];
|
|
1559
|
+
const spillDayIndex = spillHours > 0 && nextDay && (0, date_fns.differenceInCalendarDays)(nextDay, daysRef.current[targetDay]) === 1 && !d.continuesAfter ? targetDay + 1 : -1;
|
|
1362
1560
|
applyDrag({
|
|
1363
1561
|
...d,
|
|
1364
1562
|
startHours,
|
|
1365
1563
|
dayDelta,
|
|
1366
1564
|
dayOffsetPx: dayDelta * o.dayWidth,
|
|
1565
|
+
spillHours,
|
|
1566
|
+
spillDayIndex,
|
|
1367
1567
|
moved: true
|
|
1368
1568
|
});
|
|
1369
1569
|
const g = ghostRef.current;
|
|
@@ -1412,25 +1612,31 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1412
1612
|
held?.onPress();
|
|
1413
1613
|
return;
|
|
1414
1614
|
}
|
|
1415
|
-
const
|
|
1615
|
+
const origin = dragOrigin.current;
|
|
1616
|
+
const originIndex = origin?.dayIndex ?? 0;
|
|
1416
1617
|
let base = null;
|
|
1417
1618
|
if (d.kind === "move") if (pagedRef.current) {
|
|
1418
1619
|
const day = dayAt(e.clientX, e.clientY);
|
|
1419
1620
|
base = day ? (0, date_fns.startOfDay)(day) : null;
|
|
1420
1621
|
} else base = (0, date_fns.startOfDay)(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
|
|
1421
1622
|
else base = (0, date_fns.startOfDay)(daysRef.current[originIndex] ?? daysRef.current[0]);
|
|
1422
|
-
if (base && held) {
|
|
1423
|
-
const
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1623
|
+
if (base && held && origin) {
|
|
1624
|
+
const segmentStart = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
|
|
1625
|
+
const segmentEnd = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
|
|
1626
|
+
const startShift = d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
|
|
1627
|
+
const endShift = d.kind === "move" ? startShift : d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
|
|
1628
|
+
const start = new Date(held.event.start.getTime() + startShift);
|
|
1629
|
+
const end = new Date(held.event.end.getTime() + endShift);
|
|
1630
|
+
if (end > start) onDragEventRef.current?.(held.event, start, end);
|
|
1426
1631
|
}
|
|
1427
1632
|
finishDrag();
|
|
1428
1633
|
};
|
|
1429
1634
|
const cancelDrag = () => {
|
|
1430
1635
|
finishDrag();
|
|
1431
1636
|
};
|
|
1432
|
-
const beginDrag = (e,
|
|
1637
|
+
const beginDrag = (e, pe, key, kind, dayIndex, onPress) => {
|
|
1433
1638
|
if (!onDragEvent) return;
|
|
1639
|
+
const { event, startHours, durationHours, continuesBefore, continuesAfter } = pe;
|
|
1434
1640
|
e.stopPropagation();
|
|
1435
1641
|
try {
|
|
1436
1642
|
e.target.setPointerCapture?.(e.pointerId);
|
|
@@ -1439,13 +1645,16 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1439
1645
|
const column = kind === "move" ? boxEl.parentElement : null;
|
|
1440
1646
|
const dayWidth = column ? column.getBoundingClientRect().width : 0;
|
|
1441
1647
|
const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
|
|
1648
|
+
const originBase = (0, date_fns.startOfDay)(days[dayIndex] ?? days[0]);
|
|
1442
1649
|
dragOrigin.current = {
|
|
1443
1650
|
pointerX: e.clientX,
|
|
1444
1651
|
pointerY: e.clientY,
|
|
1445
1652
|
startHours,
|
|
1446
1653
|
durationHours,
|
|
1447
1654
|
dayIndex,
|
|
1448
|
-
dayWidth
|
|
1655
|
+
dayWidth,
|
|
1656
|
+
segmentStart: (0, date_fns.addMinutes)(originBase, Math.round(startHours * 60)),
|
|
1657
|
+
segmentEnd: (0, date_fns.addMinutes)(originBase, Math.round((startHours + durationHours) * 60))
|
|
1449
1658
|
};
|
|
1450
1659
|
draggedRef.current = {
|
|
1451
1660
|
event,
|
|
@@ -1468,8 +1677,12 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1468
1677
|
kind,
|
|
1469
1678
|
startHours,
|
|
1470
1679
|
durationHours,
|
|
1680
|
+
continuesBefore,
|
|
1681
|
+
continuesAfter,
|
|
1471
1682
|
dayDelta: 0,
|
|
1472
1683
|
dayOffsetPx: 0,
|
|
1684
|
+
spillHours: 0,
|
|
1685
|
+
spillDayIndex: -1,
|
|
1473
1686
|
moved: false
|
|
1474
1687
|
});
|
|
1475
1688
|
onDragStart?.(event);
|
|
@@ -1529,10 +1742,10 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1529
1742
|
const moved = Math.abs(endPx - o.startPx) > 4;
|
|
1530
1743
|
const h = hourHeightRef.current;
|
|
1531
1744
|
if (moved && onCreateEvent) {
|
|
1532
|
-
const range = (0, _super_calendar_core.cellRangeFromDrag)(day, o.startPx, endPx, h, windowStart,
|
|
1745
|
+
const range = (0, _super_calendar_core.cellRangeFromDrag)(day, o.startPx, endPx, h, windowStart, snapMinutes);
|
|
1533
1746
|
if (range) onCreateEvent(range.start, range.end);
|
|
1534
1747
|
} else if (onPressCell) {
|
|
1535
|
-
const at = (0, _super_calendar_core.cellRangeFromDrag)(day, o.startPx, o.startPx, h, windowStart,
|
|
1748
|
+
const at = (0, _super_calendar_core.cellRangeFromDrag)(day, o.startPx, o.startPx, h, windowStart, snapMinutes);
|
|
1536
1749
|
if (at) onPressCell(at.start);
|
|
1537
1750
|
}
|
|
1538
1751
|
createOrigin.current = null;
|
|
@@ -1543,6 +1756,34 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1543
1756
|
setCreateBox(null);
|
|
1544
1757
|
};
|
|
1545
1758
|
const positionedByDay = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.layoutDayEvents)(events, day)), [days, events]);
|
|
1759
|
+
const moveOrigin = dragOrigin.current;
|
|
1760
|
+
const heldEvent = draggedRef.current?.event;
|
|
1761
|
+
const movingEvent = heldEvent && (events.includes(heldEvent) ? heldEvent : events.find((event) => event.start.getTime() === heldEvent.start.getTime() && event.end.getTime() === heldEvent.end.getTime() && event.title === heldEvent.title) ?? heldEvent);
|
|
1762
|
+
const multiDayMove = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
|
|
1763
|
+
const target = days[moveOrigin.dayIndex + drag.dayDelta];
|
|
1764
|
+
const shift = (0, date_fns.addMinutes)((0, date_fns.startOfDay)(target), Math.round(drag.startHours * 60)).getTime() - moveOrigin.segmentStart.getTime();
|
|
1765
|
+
return {
|
|
1766
|
+
...movingEvent,
|
|
1767
|
+
start: new Date(movingEvent.start.getTime() + shift),
|
|
1768
|
+
end: new Date(movingEvent.end.getTime() + shift),
|
|
1769
|
+
allDay: false
|
|
1770
|
+
};
|
|
1771
|
+
})() : null;
|
|
1772
|
+
const spillPreviewFor = (dayIndex) => {
|
|
1773
|
+
if (paged || !drag || drag.kind !== "move" || drag.spillDayIndex !== dayIndex) return null;
|
|
1774
|
+
const dragged = draggedRef.current?.event;
|
|
1775
|
+
if (!dragged) return null;
|
|
1776
|
+
return {
|
|
1777
|
+
event: dragged,
|
|
1778
|
+
mode,
|
|
1779
|
+
isAllDay: false,
|
|
1780
|
+
boxHeight: Math.max(drag.spillHours * hourHeight, 14),
|
|
1781
|
+
continuesBefore: true,
|
|
1782
|
+
continuesAfter: false,
|
|
1783
|
+
ampm,
|
|
1784
|
+
onPress: () => {}
|
|
1785
|
+
};
|
|
1786
|
+
};
|
|
1546
1787
|
const navByDay = (0, react.useMemo)(() => positionedByDay.map((list, day) => list.map((pe, idx) => ({
|
|
1547
1788
|
key: `${day}:${idx}`,
|
|
1548
1789
|
start: pe.startHours,
|
|
@@ -1850,6 +2091,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1850
2091
|
const nowTop = (nowHours - windowStart) * hourHeight;
|
|
1851
2092
|
const bands = bandsByDay[dayIndex];
|
|
1852
2093
|
const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
|
|
2094
|
+
const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
|
|
2095
|
+
const moveSegment = multiDayMove ? (0, _super_calendar_core.layoutDayEvents)([multiDayMove], day)[0] : void 0;
|
|
1853
2096
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1854
2097
|
"data-date": day.toISOString(),
|
|
1855
2098
|
onPointerDown: cellEnabled ? (e) => beginCreate(e, dayIndex) : void 0,
|
|
@@ -1921,12 +2164,13 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1921
2164
|
}),
|
|
1922
2165
|
positioned.map((pe, idx) => {
|
|
1923
2166
|
const key = `${dayIndex}:${idx}`;
|
|
1924
|
-
const active = !paged && drag?.key === key ? drag : null;
|
|
2167
|
+
const active = !paged && drag?.key === key && (!multiDayMove || pe.event === movingEvent) ? drag : null;
|
|
2168
|
+
const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
|
|
1925
2169
|
const startHours = active ? active.startHours : pe.startHours;
|
|
1926
2170
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
1927
2171
|
if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
|
|
1928
2172
|
const top = (startHours - windowStart) * hourHeight;
|
|
1929
|
-
const boxHeight = Math.max(durationHours * hourHeight, 14);
|
|
2173
|
+
const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, 14);
|
|
1930
2174
|
const widthPct = 100 / pe.columns;
|
|
1931
2175
|
const onPress = () => onPressEvent?.(pe.event);
|
|
1932
2176
|
const args = {
|
|
@@ -1965,9 +2209,9 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1965
2209
|
}
|
|
1966
2210
|
if (keyboardEventNavigation) onEventKeyDown(key, e);
|
|
1967
2211
|
},
|
|
1968
|
-
onPointerDown: canMove ? (e) => beginDrag(e, pe
|
|
2212
|
+
onPointerDown: canMove ? (e) => beginDrag(e, pe, key, "move", dayIndex, onPress) : void 0,
|
|
1969
2213
|
onClick: canMove ? void 0 : onPress,
|
|
1970
|
-
...dataState({ "data-dragging": !!active }),
|
|
2214
|
+
...dataState({ "data-dragging": !!active && !hiddenForMove }),
|
|
1971
2215
|
...slot("event", { base: {
|
|
1972
2216
|
position: "absolute",
|
|
1973
2217
|
top,
|
|
@@ -1978,6 +2222,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1978
2222
|
touchAction: canMove ? "none" : "auto",
|
|
1979
2223
|
zIndex: active ? 3 : 1,
|
|
1980
2224
|
opacity: active ? .85 : 1,
|
|
2225
|
+
visibility: hiddenForMove ? "hidden" : void 0,
|
|
1981
2226
|
...active && active.dayOffsetPx !== 0 ? { transform: `translateX(${active.dayOffsetPx}px)` } : null
|
|
1982
2227
|
} }),
|
|
1983
2228
|
children: [
|
|
@@ -1989,7 +2234,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1989
2234
|
canResize && !pe.continuesBefore ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1990
2235
|
onPointerDown: (e) => {
|
|
1991
2236
|
e.stopPropagation();
|
|
1992
|
-
beginDrag(e, pe
|
|
2237
|
+
beginDrag(e, pe, key, "resize-start", dayIndex);
|
|
1993
2238
|
},
|
|
1994
2239
|
style: {
|
|
1995
2240
|
position: "absolute",
|
|
@@ -2001,10 +2246,10 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2001
2246
|
touchAction: "none"
|
|
2002
2247
|
}
|
|
2003
2248
|
}) : null,
|
|
2004
|
-
canResize ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2249
|
+
canResize && !pe.continuesAfter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2005
2250
|
onPointerDown: (e) => {
|
|
2006
2251
|
e.stopPropagation();
|
|
2007
|
-
beginDrag(e, pe
|
|
2252
|
+
beginDrag(e, pe, key, "resize", dayIndex);
|
|
2008
2253
|
},
|
|
2009
2254
|
style: {
|
|
2010
2255
|
position: "absolute",
|
|
@@ -2019,6 +2264,56 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2019
2264
|
]
|
|
2020
2265
|
}, idx);
|
|
2021
2266
|
}),
|
|
2267
|
+
moveSegment ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2268
|
+
"aria-hidden": true,
|
|
2269
|
+
...dataState({ "data-dragging": true }),
|
|
2270
|
+
...slot("event", { base: {
|
|
2271
|
+
position: "absolute",
|
|
2272
|
+
top: (moveSegment.startHours - windowStart) * hourHeight,
|
|
2273
|
+
left: 1,
|
|
2274
|
+
right: 1,
|
|
2275
|
+
height: Math.max(moveSegment.durationHours * hourHeight, 14),
|
|
2276
|
+
pointerEvents: "none",
|
|
2277
|
+
zIndex: 3,
|
|
2278
|
+
opacity: .85
|
|
2279
|
+
} }),
|
|
2280
|
+
children: (() => {
|
|
2281
|
+
const args = {
|
|
2282
|
+
event: moveSegment.event,
|
|
2283
|
+
mode,
|
|
2284
|
+
isAllDay: false,
|
|
2285
|
+
boxHeight: Math.max(moveSegment.durationHours * hourHeight, 14),
|
|
2286
|
+
continuesBefore: moveSegment.continuesBefore,
|
|
2287
|
+
continuesAfter: moveSegment.continuesAfter,
|
|
2288
|
+
ampm,
|
|
2289
|
+
onPress: () => {}
|
|
2290
|
+
};
|
|
2291
|
+
return Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultDomEvent, {
|
|
2292
|
+
...args,
|
|
2293
|
+
theme,
|
|
2294
|
+
boxProps: slot("eventBox")
|
|
2295
|
+
});
|
|
2296
|
+
})()
|
|
2297
|
+
}) : null,
|
|
2298
|
+
spill ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2299
|
+
"aria-hidden": true,
|
|
2300
|
+
...dataState({ "data-dragging": true }),
|
|
2301
|
+
...slot("event", { base: {
|
|
2302
|
+
position: "absolute",
|
|
2303
|
+
top: -windowStart * hourHeight,
|
|
2304
|
+
left: 1,
|
|
2305
|
+
right: 1,
|
|
2306
|
+
height: spill.boxHeight,
|
|
2307
|
+
pointerEvents: "none",
|
|
2308
|
+
zIndex: 3,
|
|
2309
|
+
opacity: .85
|
|
2310
|
+
} }),
|
|
2311
|
+
children: Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...spill }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultDomEvent, {
|
|
2312
|
+
...spill,
|
|
2313
|
+
theme,
|
|
2314
|
+
boxProps: slot("eventBox")
|
|
2315
|
+
})
|
|
2316
|
+
}) : null,
|
|
2022
2317
|
showNow ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2023
2318
|
...slot("nowIndicator", { base: {
|
|
2024
2319
|
position: "absolute",
|
|
@@ -2129,7 +2424,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
2129
2424
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
2130
2425
|
* ```
|
|
2131
2426
|
*/
|
|
2132
|
-
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2427
|
+
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2133
2428
|
const displayEvents = (0, react.useMemo)(() => {
|
|
2134
2429
|
let out = events ?? EMPTY_EVENTS;
|
|
2135
2430
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -2172,8 +2467,15 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2172
2467
|
} : style,
|
|
2173
2468
|
classNames,
|
|
2174
2469
|
styles,
|
|
2470
|
+
selectedRange,
|
|
2471
|
+
selectedDates,
|
|
2472
|
+
minDate,
|
|
2473
|
+
maxDate,
|
|
2474
|
+
isDateDisabled,
|
|
2175
2475
|
onPressDay,
|
|
2176
|
-
onPressMonth
|
|
2476
|
+
onPressMonth,
|
|
2477
|
+
onSelectDrag,
|
|
2478
|
+
onCreateEvent
|
|
2177
2479
|
});
|
|
2178
2480
|
else if (mode === "schedule") view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Agenda, {
|
|
2179
2481
|
events: displayEvents,
|
|
@@ -2207,6 +2509,7 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2207
2509
|
maxVisibleEventCount,
|
|
2208
2510
|
moreLabel,
|
|
2209
2511
|
showAdjacentMonths,
|
|
2512
|
+
showTitle,
|
|
2210
2513
|
fillCellOnSelection,
|
|
2211
2514
|
selectedRange,
|
|
2212
2515
|
selectedDates,
|
|
@@ -2215,7 +2518,13 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2215
2518
|
isDateDisabled,
|
|
2216
2519
|
keyboardDayNavigation,
|
|
2217
2520
|
onPressDay,
|
|
2521
|
+
onPressCell,
|
|
2218
2522
|
onCreateEvent,
|
|
2523
|
+
onSelectDrag,
|
|
2524
|
+
onDragEvent,
|
|
2525
|
+
onDragStart,
|
|
2526
|
+
eventStartEditable,
|
|
2527
|
+
eventOverlap,
|
|
2219
2528
|
onPressEvent,
|
|
2220
2529
|
onPressMore,
|
|
2221
2530
|
renderEvent: renderMonthEvent,
|