@super-calendar/solid 2.17.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -9
- package/dist/client/index.d.ts +56 -14
- package/dist/client/index.js +683 -406
- package/dist/server/index.d.ts +56 -14
- package/dist/server/index.js +1418 -1238
- package/package.json +7 -7
- package/src/Agenda.tsx +19 -2
- package/src/Calendar.tsx +108 -30
- package/src/MonthList.tsx +1 -1
- package/src/MonthView.tsx +220 -29
- package/src/TimeGrid.tsx +350 -155
- package/src/YearView.tsx +17 -1
package/src/MonthView.tsx
CHANGED
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
bandRounding,
|
|
4
4
|
buildMonthGrid,
|
|
5
5
|
buildMultiWeekGrid,
|
|
6
|
+
nowInTimeZone,
|
|
6
7
|
type CalendarEvent,
|
|
8
|
+
type CreateGhostArgs,
|
|
7
9
|
type CalendarLabels,
|
|
8
10
|
compareDayEvents,
|
|
9
11
|
type DateRange,
|
|
@@ -14,10 +16,14 @@ import {
|
|
|
14
16
|
groupEventsByDay,
|
|
15
17
|
isAllDayEvent,
|
|
16
18
|
isBackgroundEvent,
|
|
19
|
+
keepMonthDraftVisible,
|
|
17
20
|
layoutMonthWeek,
|
|
18
21
|
monthCreateRange,
|
|
19
22
|
monthDropBounds,
|
|
23
|
+
monthExtraLaneColumns,
|
|
20
24
|
type MonthGridWeekday,
|
|
25
|
+
monthVisibleBars,
|
|
26
|
+
withDraftEventDays,
|
|
21
27
|
type MultiWeekGridDay,
|
|
22
28
|
overlapsOtherEvents,
|
|
23
29
|
rangeBandKind,
|
|
@@ -63,12 +69,16 @@ export type MonthViewSlot =
|
|
|
63
69
|
| "dayBadge"
|
|
64
70
|
| "rangeBand"
|
|
65
71
|
| "events"
|
|
72
|
+
| "createGhost"
|
|
66
73
|
| "chipButton"
|
|
67
74
|
| "chip"
|
|
68
75
|
| "more"
|
|
69
76
|
| "morePopover";
|
|
70
77
|
|
|
71
78
|
// Stable empty layout for rows with no events (avoids a fresh object per render).
|
|
79
|
+
// Whether a pointer press began on an event chip inside a day cell.
|
|
80
|
+
const pressedEvent = (event: Event) =>
|
|
81
|
+
event.target instanceof Element && event.target.closest('[data-slot="chipButton"]') !== null;
|
|
72
82
|
const EMPTY_LAYOUT = {
|
|
73
83
|
segments: [],
|
|
74
84
|
laneCount: 0,
|
|
@@ -81,6 +91,10 @@ const CHIP_GAP = 2;
|
|
|
81
91
|
const CELL_PAD = 4;
|
|
82
92
|
// Opacity of an event chip while it is being dragged to another day.
|
|
83
93
|
const DRAGGED_CHIP_OPACITY = 0.4;
|
|
94
|
+
// How far a press travels before it becomes a drag. Until then the chips stay
|
|
95
|
+
// hit-testable, so a click still reaches the chip it pressed.
|
|
96
|
+
const DRAG_SLOP_PX = 4;
|
|
97
|
+
const TOUCH_DRAG_SLOP_PX = 8;
|
|
84
98
|
|
|
85
99
|
/** Props passed to a custom month event chip renderer. */
|
|
86
100
|
export interface SolidMonthEventArgs<T = unknown> {
|
|
@@ -115,6 +129,10 @@ type MonthDrag<T> = (
|
|
|
115
129
|
) & {
|
|
116
130
|
// The rows the drag began in, so a drag never commits into a different window.
|
|
117
131
|
windowKey: string;
|
|
132
|
+
// Set once the pointer travels past the drag slop (or a touch hold fires).
|
|
133
|
+
// Chips stop taking pointer input only then, so a plain click is not
|
|
134
|
+
// retargeted to the day cell beneath.
|
|
135
|
+
armed: boolean;
|
|
118
136
|
};
|
|
119
137
|
|
|
120
138
|
// A day as the shared rows render it. Month days carry `isCurrentMonth`;
|
|
@@ -188,6 +206,13 @@ export interface MonthViewProps<T = unknown>
|
|
|
188
206
|
showWeekdays?: boolean;
|
|
189
207
|
/** date-fns locale for the title and weekday labels. */
|
|
190
208
|
locale?: Locale;
|
|
209
|
+
/**
|
|
210
|
+
* The instant whose calendar day is highlighted as today. Defaults to the
|
|
211
|
+
* device clock, and is read in `timeZone` when one is set.
|
|
212
|
+
*/
|
|
213
|
+
now?: Date;
|
|
214
|
+
/** Highlight today as it is in this IANA time zone (default: the device's). */
|
|
215
|
+
timeZone?: string;
|
|
191
216
|
/** Theme overrides; falls back to the default light theme. */
|
|
192
217
|
theme?: Partial<SolidCalendarTheme>;
|
|
193
218
|
/** Fired when a selectable day is clicked. */
|
|
@@ -205,6 +230,12 @@ export interface MonthViewProps<T = unknown>
|
|
|
205
230
|
* carry `data-creating` for styling.
|
|
206
231
|
*/
|
|
207
232
|
onCreateEvent?: (start: Date, end: Date) => void;
|
|
233
|
+
/**
|
|
234
|
+
* Custom content for a drag-to-create preview, once per covered week row.
|
|
235
|
+
* Receives the full all-day range with an exclusive end. Requires onCreateEvent.
|
|
236
|
+
* Content is clipped, noninteractive, and hidden from assistive technology.
|
|
237
|
+
*/
|
|
238
|
+
renderCreateGhost?: Component<CreateGhostArgs>;
|
|
208
239
|
/**
|
|
209
240
|
* Reports the day span of a create sweep **as it happens**, as the ordered
|
|
210
241
|
* inclusive `[start, end]` days (both at midnight), so a selection highlight can
|
|
@@ -612,7 +643,12 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
612
643
|
// Calendar layout (date in the corner + event chips) is on whenever `events`
|
|
613
644
|
// is provided; otherwise the compact picker badge layout is used. Multi-week
|
|
614
645
|
// rows always use the calendar layout.
|
|
615
|
-
const
|
|
646
|
+
const createContentEnabled = createMemo(
|
|
647
|
+
() => props.onCreateEvent != null && props.renderCreateGhost != null,
|
|
648
|
+
);
|
|
649
|
+
const eventsMode = createMemo(
|
|
650
|
+
() => props.events !== undefined || multiWeek() || createContentEnabled(),
|
|
651
|
+
);
|
|
616
652
|
// The day cells form a roving tab stop (arrow keys + Enter) in the picker
|
|
617
653
|
// always, and in events mode only when the consumer opts in. Otherwise events
|
|
618
654
|
// mode tabs through the event chips alone.
|
|
@@ -704,6 +740,8 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
704
740
|
maxDate: props.maxDate,
|
|
705
741
|
isDateDisabled: props.isDateDisabled,
|
|
706
742
|
locale: props.locale,
|
|
743
|
+
// Read here, not memoized apart, so each rebuild sees the current day.
|
|
744
|
+
today: nowInTimeZone(props.now, props.timeZone),
|
|
707
745
|
};
|
|
708
746
|
const weeks = numberOfWeeks();
|
|
709
747
|
if (weeks === undefined) {
|
|
@@ -852,6 +890,47 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
852
890
|
// all-day span, or press an event chip and drop it on another day. Both are
|
|
853
891
|
// released on a window pointerup, so letting go anywhere still commits.
|
|
854
892
|
const [drag, setDrag] = createSignal<MonthDrag<T> | null>(null);
|
|
893
|
+
const createRange = createMemo(
|
|
894
|
+
() => {
|
|
895
|
+
const current = drag();
|
|
896
|
+
return createContentEnabled() && current?.kind === "create"
|
|
897
|
+
? monthCreateRange(new Date(current.anchor), new Date(current.hover))
|
|
898
|
+
: null;
|
|
899
|
+
},
|
|
900
|
+
{ equals: (a, b) => a === b || (!!a && !!b && +a.start === +b.start && +a.end === +b.end) },
|
|
901
|
+
);
|
|
902
|
+
// Lanes a week row shows: all of them, or one fewer than the cap plus "+more".
|
|
903
|
+
const visibleLanesFor = (laneCount: number) =>
|
|
904
|
+
laneCount > props.maxVisibleEventCount
|
|
905
|
+
? Math.max(props.maxVisibleEventCount - 1, 1)
|
|
906
|
+
: laneCount;
|
|
907
|
+
// While a create sweep draws its content, lay the rows it covers out with the
|
|
908
|
+
// draft as an all-day event, so it takes the lane the created event will land on
|
|
909
|
+
// and the other bars move aside the same way.
|
|
910
|
+
const draftEvent = createMemo(() => {
|
|
911
|
+
const range = createRange();
|
|
912
|
+
return range
|
|
913
|
+
? ({ title: "", start: range.start, end: range.end, allDay: true } as CalendarEvent<T>)
|
|
914
|
+
: null;
|
|
915
|
+
});
|
|
916
|
+
const rowLayouts = createMemo(() => {
|
|
917
|
+
const draft = draftEvent();
|
|
918
|
+
const base = weekLayouts();
|
|
919
|
+
if (!draft) return base;
|
|
920
|
+
const days = withDraftEventDays(eventsByDay(), draft);
|
|
921
|
+
return _grid().weeks.map((week, index) => {
|
|
922
|
+
const row = base[index] ?? EMPTY_LAYOUT;
|
|
923
|
+
if (!week.days.some((d) => d.date >= draft.start && d.date < draft.end)) return row;
|
|
924
|
+
const placed = layoutMonthWeek(
|
|
925
|
+
week.days.map((d) => d.date),
|
|
926
|
+
collectRowEvents(week, days),
|
|
927
|
+
);
|
|
928
|
+
return keepMonthDraftVisible(placed, row, draft, {
|
|
929
|
+
visibleLanes: visibleLanesFor,
|
|
930
|
+
extraLaneFits: (visibleLanes) => visibleLanes < props.maxVisibleEventCount,
|
|
931
|
+
});
|
|
932
|
+
});
|
|
933
|
+
});
|
|
855
934
|
const dragRef: ElementRef<MonthDrag<T> | null> = { current: null };
|
|
856
935
|
const applyDrag = (value: MonthDrag<T> | null) => {
|
|
857
936
|
dragRef.current = value;
|
|
@@ -868,8 +947,9 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
868
947
|
const suppressClickRef = {
|
|
869
948
|
current: false,
|
|
870
949
|
};
|
|
871
|
-
|
|
872
|
-
|
|
950
|
+
// Keyboard and assistive-technology clicks have detail 0 and never trail a drag.
|
|
951
|
+
const consumeSuppressedClick = (detail: number) => {
|
|
952
|
+
if (detail === 0 || !suppressClickRef.current) return false;
|
|
873
953
|
suppressClickRef.current = false;
|
|
874
954
|
return true;
|
|
875
955
|
};
|
|
@@ -880,15 +960,22 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
880
960
|
!event.disabled &&
|
|
881
961
|
event.draggable !== false &&
|
|
882
962
|
(event.startEditable ?? props.eventStartEditable);
|
|
963
|
+
// Where the current press began and how far it may travel before it drags.
|
|
964
|
+
let pressOrigin = { x: 0, y: 0, slop: DRAG_SLOP_PX };
|
|
883
965
|
// A fresh press starts a new interaction, so any guard left over from the
|
|
884
966
|
// previous one is stale.
|
|
885
967
|
const beginPress = (e: PointerEvent) => {
|
|
886
968
|
if (dragRef.current || e.isPrimary === false) return false;
|
|
887
969
|
suppressClickRef.current = false;
|
|
888
970
|
movedRef.current = false;
|
|
971
|
+
pressOrigin = {
|
|
972
|
+
x: e.clientX,
|
|
973
|
+
y: e.clientY,
|
|
974
|
+
slop: e.pointerType === "touch" ? TOUCH_DRAG_SLOP_PX : DRAG_SLOP_PX,
|
|
975
|
+
};
|
|
889
976
|
return true;
|
|
890
977
|
};
|
|
891
|
-
const beginCreate = (day: Date, pointerId: number) => {
|
|
978
|
+
const beginCreate = (day: Date, pointerId: number, armed: boolean) => {
|
|
892
979
|
if (!props.onCreateEvent && !props.onSelectDrag) return;
|
|
893
980
|
const t = startOfDay(day).getTime();
|
|
894
981
|
applyDrag({
|
|
@@ -897,9 +984,10 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
897
984
|
anchor: t,
|
|
898
985
|
hover: t,
|
|
899
986
|
windowKey: windowKey(),
|
|
987
|
+
armed,
|
|
900
988
|
});
|
|
901
989
|
};
|
|
902
|
-
const beginMove = (event: CalendarEvent<T>, day: Date, pointerId: number) => {
|
|
990
|
+
const beginMove = (event: CalendarEvent<T>, day: Date, pointerId: number, armed: boolean) => {
|
|
903
991
|
if (!canMove(event)) return;
|
|
904
992
|
const t = startOfDay(day).getTime();
|
|
905
993
|
applyDrag({
|
|
@@ -909,6 +997,7 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
909
997
|
from: t,
|
|
910
998
|
to: t,
|
|
911
999
|
windowKey: windowKey(),
|
|
1000
|
+
armed,
|
|
912
1001
|
});
|
|
913
1002
|
props.onDragStart?.(event);
|
|
914
1003
|
};
|
|
@@ -923,10 +1012,12 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
923
1012
|
? {
|
|
924
1013
|
...current,
|
|
925
1014
|
hover: t,
|
|
1015
|
+
armed: true,
|
|
926
1016
|
}
|
|
927
1017
|
: {
|
|
928
1018
|
...current,
|
|
929
1019
|
to: t,
|
|
1020
|
+
armed: true,
|
|
930
1021
|
},
|
|
931
1022
|
);
|
|
932
1023
|
// A sweep reports its span live, so a selection can track the drag; a move
|
|
@@ -952,12 +1043,16 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
952
1043
|
moving?: CalendarEvent<T>,
|
|
953
1044
|
) => {
|
|
954
1045
|
if (event.button !== 0 || heldTouch || !beginPress(event)) return;
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1046
|
+
// A press on an event that can't move starts a fresh interaction but no
|
|
1047
|
+
// sweep: a sweep starts from a day, and its preview would move the row
|
|
1048
|
+
// under the click.
|
|
1049
|
+
if (!moving && pressedEvent(event)) return;
|
|
1050
|
+
const start = (armed: boolean) => {
|
|
1051
|
+
if (moving) beginMove(moving, day, event.pointerId, armed);
|
|
1052
|
+
else beginCreate(day, event.pointerId, armed);
|
|
958
1053
|
};
|
|
959
1054
|
if (!multiWeek() || !event.pointerType || event.pointerType === "mouse") {
|
|
960
|
-
start();
|
|
1055
|
+
start(false);
|
|
961
1056
|
return;
|
|
962
1057
|
}
|
|
963
1058
|
heldOrigin = { day, event: moving };
|
|
@@ -969,7 +1064,8 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
969
1064
|
clientX: event.clientX,
|
|
970
1065
|
clientY: event.clientY,
|
|
971
1066
|
},
|
|
972
|
-
|
|
1067
|
+
// The hold itself is the deliberate gesture, so a held drag starts armed.
|
|
1068
|
+
() => start(true),
|
|
973
1069
|
(x, y) => {
|
|
974
1070
|
const element = gridRef.current?.ownerDocument
|
|
975
1071
|
.elementFromPoint(x, y)
|
|
@@ -1029,6 +1125,7 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1029
1125
|
},
|
|
1030
1126
|
);
|
|
1031
1127
|
const isDragging = createMemo(() => drag() !== null);
|
|
1128
|
+
const dragArmed = createMemo(() => drag()?.armed === true);
|
|
1032
1129
|
// Whether any month drag is wired up at all, so the cells only take over touch
|
|
1033
1130
|
// scrolling and pointer tracking when one of the handlers can actually fire.
|
|
1034
1131
|
const dragWired = createMemo(
|
|
@@ -1043,7 +1140,13 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1043
1140
|
const current = dragRef.current;
|
|
1044
1141
|
if (!current || current.pointerId !== e.pointerId) return;
|
|
1045
1142
|
applyDrag(null);
|
|
1046
|
-
if (!movedRef.current)
|
|
1143
|
+
if (!movedRef.current) {
|
|
1144
|
+
// An armed move that returns to its day is released over the day cell,
|
|
1145
|
+
// because the chip ignored pointer input mid drag. The click that
|
|
1146
|
+
// follows belongs to the abandoned drag, not to the day.
|
|
1147
|
+
if (current.kind === "move" && current.armed) suppressClickRef.current = true;
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1047
1150
|
suppressClickRef.current = true;
|
|
1048
1151
|
// Multi-week rows drop a drag whose window was replaced before release.
|
|
1049
1152
|
if (multiWeek() && current.windowKey !== windowKey()) return;
|
|
@@ -1064,17 +1167,36 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1064
1167
|
}
|
|
1065
1168
|
props.onDragEvent?.(current.event, next.start, next.end);
|
|
1066
1169
|
};
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1170
|
+
const clear = () => {
|
|
1171
|
+
heldTouch?.();
|
|
1069
1172
|
applyDrag(null);
|
|
1070
1173
|
movedRef.current = false;
|
|
1071
1174
|
suppressClickRef.current = true;
|
|
1072
1175
|
};
|
|
1176
|
+
const cancel = (event: PointerEvent) => {
|
|
1177
|
+
if (dragRef.current?.pointerId === event.pointerId) clear();
|
|
1178
|
+
};
|
|
1179
|
+
const arm = (event: PointerEvent) => {
|
|
1180
|
+
const current = dragRef.current;
|
|
1181
|
+
if (!current || current.armed || current.pointerId !== event.pointerId) return;
|
|
1182
|
+
const distance = Math.hypot(event.clientX - pressOrigin.x, event.clientY - pressOrigin.y);
|
|
1183
|
+
if (distance <= pressOrigin.slop) return;
|
|
1184
|
+
applyDrag({ ...current, armed: true });
|
|
1185
|
+
};
|
|
1186
|
+
const keyDown = (event: KeyboardEvent) => {
|
|
1187
|
+
if (event.key !== "Escape") return;
|
|
1188
|
+
event.preventDefault();
|
|
1189
|
+
clear();
|
|
1190
|
+
};
|
|
1191
|
+
window.addEventListener("pointermove", arm);
|
|
1073
1192
|
window.addEventListener("pointerup", finish);
|
|
1074
1193
|
window.addEventListener("pointercancel", cancel);
|
|
1194
|
+
window.addEventListener("keydown", keyDown);
|
|
1075
1195
|
return () => {
|
|
1196
|
+
window.removeEventListener("pointermove", arm);
|
|
1076
1197
|
window.removeEventListener("pointerup", finish);
|
|
1077
1198
|
window.removeEventListener("pointercancel", cancel);
|
|
1199
|
+
window.removeEventListener("keydown", keyDown);
|
|
1078
1200
|
};
|
|
1079
1201
|
}),
|
|
1080
1202
|
);
|
|
@@ -1221,18 +1343,20 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1221
1343
|
// inside its start-column cell (valid grid content that reads with that day)
|
|
1222
1344
|
// and overflows right across the days it spans. The cells reserve the lane
|
|
1223
1345
|
// rows so "+more" sits below the bars.
|
|
1224
|
-
const rowLayout = createMemo(() =>
|
|
1346
|
+
const rowLayout = createMemo(() => rowLayouts()[weekIndex] ?? EMPTY_LAYOUT);
|
|
1225
1347
|
// When lanes overflow, keep the last row for "+more" but always show at
|
|
1226
1348
|
// least one bar, so a day never collapses to only the overflow row.
|
|
1227
|
-
const
|
|
1228
|
-
() => rowLayout().laneCount > props.maxVisibleEventCount,
|
|
1229
|
-
);
|
|
1230
|
-
const visibleLanes = createMemo(() =>
|
|
1231
|
-
overflowing() ? Math.max(props.maxVisibleEventCount - 1, 1) : rowLayout().laneCount,
|
|
1232
|
-
);
|
|
1349
|
+
const visibleLanes = createMemo(() => visibleLanesFor(rowLayout().laneCount));
|
|
1233
1350
|
// With adjacent months hidden, clamp bars to the current-month columns so
|
|
1234
1351
|
// none draw over the blank leading/trailing cells.
|
|
1235
1352
|
const cols = createMemo(() => week().days.length);
|
|
1353
|
+
// A day whose only hidden event sits on the "+more" row's lane draws that
|
|
1354
|
+
// event there instead of "+1 more".
|
|
1355
|
+
const extraLane = createMemo(() =>
|
|
1356
|
+
visibleLanes() < props.maxVisibleEventCount
|
|
1357
|
+
? monthExtraLaneColumns(rowLayout(), visibleLanes(), cols())
|
|
1358
|
+
: week().days.map(() => false),
|
|
1359
|
+
);
|
|
1236
1360
|
const columns = createMemo(() => {
|
|
1237
1361
|
let first = 0;
|
|
1238
1362
|
let last = cols() - 1;
|
|
@@ -1249,12 +1373,33 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1249
1373
|
last,
|
|
1250
1374
|
};
|
|
1251
1375
|
});
|
|
1376
|
+
// The draft's own lane and columns, clamped like the bars.
|
|
1377
|
+
const draftSpan = createMemo(() => {
|
|
1378
|
+
const draft = draftEvent();
|
|
1379
|
+
const segment = draft
|
|
1380
|
+
? rowLayout().segments.find((s) => s.event === draft)
|
|
1381
|
+
: undefined;
|
|
1382
|
+
if (!segment) return null;
|
|
1383
|
+
const start = Math.max(segment.startCol, columns().first);
|
|
1384
|
+
const end = Math.min(segment.endCol, columns().last);
|
|
1385
|
+
return start <= end ? { start, end, lane: segment.lane } : null;
|
|
1386
|
+
});
|
|
1387
|
+
const draftTop = createMemo(
|
|
1388
|
+
() =>
|
|
1389
|
+
CELL_PAD +
|
|
1390
|
+
DATE_ROW +
|
|
1391
|
+
props.chipGap +
|
|
1392
|
+
(draftSpan()?.lane ?? 0) * (props.chipHeight + props.chipGap),
|
|
1393
|
+
);
|
|
1394
|
+
const draftHeight = createMemo(() =>
|
|
1395
|
+
Math.min(props.chipHeight, Math.max(0, eventRowHeight() - draftTop())),
|
|
1396
|
+
);
|
|
1252
1397
|
return (
|
|
1253
1398
|
<>
|
|
1254
1399
|
{(() => {
|
|
1255
1400
|
const barSegs = createMemo(() =>
|
|
1256
|
-
rowLayout()
|
|
1257
|
-
.
|
|
1401
|
+
monthVisibleBars(rowLayout(), visibleLanes(), extraLane())
|
|
1402
|
+
.filter((s) => s.event !== draftEvent())
|
|
1258
1403
|
.map((s) => {
|
|
1259
1404
|
const startCol = Math.max(s.startCol, columns().first);
|
|
1260
1405
|
const endCol = Math.min(s.endCol, columns().last);
|
|
@@ -1285,6 +1430,11 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1285
1430
|
{
|
|
1286
1431
|
<For each={week().days} keyed={false}>
|
|
1287
1432
|
{(day, dayCol) => {
|
|
1433
|
+
// Lanes this day shows: the row's, plus the "+more" row's when it
|
|
1434
|
+
// holds the day's only hidden event.
|
|
1435
|
+
const dayLanes = createMemo(
|
|
1436
|
+
() => visibleLanes() + (extraLane()[dayCol] ? 1 : 0),
|
|
1437
|
+
);
|
|
1288
1438
|
const hidden = createMemo(
|
|
1289
1439
|
() => !showAdjacentMonths() && isOutsidePeriod(day()),
|
|
1290
1440
|
);
|
|
@@ -1381,7 +1531,8 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1381
1531
|
(s) =>
|
|
1382
1532
|
s.startCol <= dayCol &&
|
|
1383
1533
|
s.endCol >= dayCol &&
|
|
1384
|
-
s.lane >=
|
|
1534
|
+
s.lane >= dayLanes() &&
|
|
1535
|
+
s.event !== draftEvent(),
|
|
1385
1536
|
)
|
|
1386
1537
|
.map((s) => s.event),
|
|
1387
1538
|
);
|
|
@@ -1494,8 +1645,8 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1494
1645
|
onClick={
|
|
1495
1646
|
day().isDisabled
|
|
1496
1647
|
? undefined
|
|
1497
|
-
: () => {
|
|
1498
|
-
if (consumeSuppressedClick()) return;
|
|
1648
|
+
: (e) => {
|
|
1649
|
+
if (consumeSuppressedClick(e.detail)) return;
|
|
1499
1650
|
props.onPressDay?.(day().date);
|
|
1500
1651
|
props.onPressCell?.(startOfDay(day().date));
|
|
1501
1652
|
}
|
|
@@ -1540,6 +1691,45 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1540
1691
|
start day's gridcell and reads with that day. Made
|
|
1541
1692
|
non-interactive mid drag so a sweep (or a move) reaches the
|
|
1542
1693
|
cells beneath. */}
|
|
1694
|
+
<Show
|
|
1695
|
+
when={
|
|
1696
|
+
props.renderCreateGhost &&
|
|
1697
|
+
createRange() &&
|
|
1698
|
+
draftSpan()?.start === dayCol &&
|
|
1699
|
+
draftHeight() > 0
|
|
1700
|
+
}
|
|
1701
|
+
>
|
|
1702
|
+
<div
|
|
1703
|
+
{...slot("createGhost", {
|
|
1704
|
+
base: {
|
|
1705
|
+
position: "absolute",
|
|
1706
|
+
left: 2,
|
|
1707
|
+
width: `calc(${(draftSpan()!.end - dayCol + 1) * 100}% - 4px)`,
|
|
1708
|
+
top: draftTop(),
|
|
1709
|
+
height: draftHeight(),
|
|
1710
|
+
boxSizing: "border-box",
|
|
1711
|
+
pointerEvents: "none",
|
|
1712
|
+
overflow: "hidden",
|
|
1713
|
+
zIndex: 3,
|
|
1714
|
+
},
|
|
1715
|
+
themed: {
|
|
1716
|
+
background: theme().rangeBackground,
|
|
1717
|
+
border: `1px solid ${theme().selectedBackground}`,
|
|
1718
|
+
borderRadius: 4,
|
|
1719
|
+
fontSize: 12,
|
|
1720
|
+
color: theme().text,
|
|
1721
|
+
},
|
|
1722
|
+
})}
|
|
1723
|
+
inert
|
|
1724
|
+
aria-hidden="true"
|
|
1725
|
+
>
|
|
1726
|
+
<Dynamic
|
|
1727
|
+
component={props.renderCreateGhost!}
|
|
1728
|
+
start={createRange()!.start}
|
|
1729
|
+
end={createRange()!.end}
|
|
1730
|
+
/>
|
|
1731
|
+
</div>
|
|
1732
|
+
</Show>
|
|
1543
1733
|
{
|
|
1544
1734
|
<For
|
|
1545
1735
|
each={barSegs().filter((b) => b.startCol === dayCol)}
|
|
@@ -1552,7 +1742,8 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1552
1742
|
const isDragged = createMemo(() => {
|
|
1553
1743
|
const currentDrag = drag();
|
|
1554
1744
|
return (
|
|
1555
|
-
currentDrag?.
|
|
1745
|
+
currentDrag?.armed === true &&
|
|
1746
|
+
currentDrag.kind === "move" &&
|
|
1556
1747
|
currentDrag.event === b().seg.event
|
|
1557
1748
|
);
|
|
1558
1749
|
});
|
|
@@ -1571,7 +1762,7 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1571
1762
|
}
|
|
1572
1763
|
onClick={(e) => {
|
|
1573
1764
|
e.stopPropagation();
|
|
1574
|
-
if (consumeSuppressedClick()) return;
|
|
1765
|
+
if (consumeSuppressedClick(e.detail)) return;
|
|
1575
1766
|
props.onPressEvent?.(b().seg.event);
|
|
1576
1767
|
}}
|
|
1577
1768
|
{...barChipButton()}
|
|
@@ -1602,7 +1793,7 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1602
1793
|
b().seg.lane *
|
|
1603
1794
|
(props.chipHeight + props.chipGap),
|
|
1604
1795
|
height: props.chipHeight,
|
|
1605
|
-
pointerEvents:
|
|
1796
|
+
pointerEvents: dragArmed() ? "none" : "auto",
|
|
1606
1797
|
// Fade the bar being carried, so the tinted drop
|
|
1607
1798
|
// target reads as where it is going.
|
|
1608
1799
|
opacity: isDragged()
|
|
@@ -1668,7 +1859,7 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
|
|
|
1668
1859
|
space and "+more" sits below them. */}
|
|
1669
1860
|
{Array.from(
|
|
1670
1861
|
{
|
|
1671
|
-
length:
|
|
1862
|
+
length: dayLanes(),
|
|
1672
1863
|
},
|
|
1673
1864
|
() => (
|
|
1674
1865
|
<div
|