@super-calendar/solid 2.18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/solid",
3
- "version": "2.18.0",
3
+ "version": "2.19.0",
4
4
  "description": "Solid 2 calendar and date picker with virtualized views, keyboard navigation, and pointer gestures.",
5
5
  "keywords": [
6
6
  "calendar",
@@ -42,18 +42,18 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@super-calendar/core": "^2.18.0",
45
+ "@super-calendar/core": "^2.19.0",
46
46
  "csstype": "^3.1.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@solidjs/babel-plugin": "2.0.0-rc.20",
50
- "@solidjs/web": "2.0.0-rc.20",
51
- "solid-js": "2.0.0-rc.20"
49
+ "@solidjs/babel-plugin": "2.0.0",
50
+ "@solidjs/web": "2.0.0",
51
+ "solid-js": "2.0.0"
52
52
  },
53
53
  "peerDependencies": {
54
- "@solidjs/web": "2.0.0-rc.20",
54
+ "@solidjs/web": "^2.0.0",
55
55
  "date-fns": ">=3",
56
- "solid-js": "2.0.0-rc.20"
56
+ "solid-js": "^2.0.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "node scripts/build.mjs",
package/src/Agenda.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Dynamic, type JSX } from "@solidjs/web";
2
- import type { CalendarEvent, EventAccessibilityLabeler } from "@super-calendar/core/vanilla";
3
2
  import {
3
+ type CalendarEvent,
4
+ type EventAccessibilityLabeler,
4
5
  eventTimeLabel,
5
6
  getIsToday,
6
7
  nowInTimeZone,
package/src/Calendar.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type JSX } from "@solidjs/web";
2
- import type { CalendarHandle, CalendarLabels } from "@super-calendar/core/vanilla";
3
2
  import {
3
+ type CalendarHandle,
4
+ type CalendarLabels,
4
5
  buildMultiWeekGrid,
5
6
  type BusinessHours,
6
7
  type BusinessHoursBand,
package/src/MonthList.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type JSX } from "@solidjs/web";
2
- import type { CalendarLabels } from "@super-calendar/core/vanilla";
3
2
  import {
3
+ type CalendarLabels,
4
4
  buildMonthGrid,
5
5
  type CalendarEvent,
6
6
  compareDayEvents,
package/src/MonthView.tsx CHANGED
@@ -16,10 +16,14 @@ import {
16
16
  groupEventsByDay,
17
17
  isAllDayEvent,
18
18
  isBackgroundEvent,
19
+ keepMonthDraftVisible,
19
20
  layoutMonthWeek,
20
21
  monthCreateRange,
21
22
  monthDropBounds,
23
+ monthExtraLaneColumns,
22
24
  type MonthGridWeekday,
25
+ monthVisibleBars,
26
+ withDraftEventDays,
23
27
  type MultiWeekGridDay,
24
28
  overlapsOtherEvents,
25
29
  rangeBandKind,
@@ -72,6 +76,9 @@ export type MonthViewSlot =
72
76
  | "morePopover";
73
77
 
74
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;
75
82
  const EMPTY_LAYOUT = {
76
83
  segments: [],
77
84
  laneCount: 0,
@@ -892,6 +899,38 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
892
899
  },
893
900
  { equals: (a, b) => a === b || (!!a && !!b && +a.start === +b.start && +a.end === +b.end) },
894
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
+ });
895
934
  const dragRef: ElementRef<MonthDrag<T> | null> = { current: null };
896
935
  const applyDrag = (value: MonthDrag<T> | null) => {
897
936
  dragRef.current = value;
@@ -1004,6 +1043,10 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1004
1043
  moving?: CalendarEvent<T>,
1005
1044
  ) => {
1006
1045
  if (event.button !== 0 || heldTouch || !beginPress(event)) return;
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;
1007
1050
  const start = (armed: boolean) => {
1008
1051
  if (moving) beginMove(moving, day, event.pointerId, armed);
1009
1052
  else beginCreate(day, event.pointerId, armed);
@@ -1300,18 +1343,20 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1300
1343
  // inside its start-column cell (valid grid content that reads with that day)
1301
1344
  // and overflows right across the days it spans. The cells reserve the lane
1302
1345
  // rows so "+more" sits below the bars.
1303
- const rowLayout = createMemo(() => weekLayouts()[weekIndex] ?? EMPTY_LAYOUT);
1346
+ const rowLayout = createMemo(() => rowLayouts()[weekIndex] ?? EMPTY_LAYOUT);
1304
1347
  // When lanes overflow, keep the last row for "+more" but always show at
1305
1348
  // least one bar, so a day never collapses to only the overflow row.
1306
- const overflowing = createMemo(
1307
- () => rowLayout().laneCount > props.maxVisibleEventCount,
1308
- );
1309
- const visibleLanes = createMemo(() =>
1310
- overflowing() ? Math.max(props.maxVisibleEventCount - 1, 1) : rowLayout().laneCount,
1311
- );
1349
+ const visibleLanes = createMemo(() => visibleLanesFor(rowLayout().laneCount));
1312
1350
  // With adjacent months hidden, clamp bars to the current-month columns so
1313
1351
  // none draw over the blank leading/trailing cells.
1314
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
+ );
1315
1360
  const columns = createMemo(() => {
1316
1361
  let first = 0;
1317
1362
  let last = cols() - 1;
@@ -1328,25 +1373,23 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1328
1373
  last,
1329
1374
  };
1330
1375
  });
1331
- const draftColumns = createMemo(() => {
1332
- const range = createRange();
1333
- return range
1334
- ? week().days.flatMap((day, index) =>
1335
- (!showAdjacentMonths() && isOutsidePeriod(day)) ||
1336
- day.date < range.start ||
1337
- day.date >= range.end
1338
- ? []
1339
- : [index],
1340
- )
1341
- : [];
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;
1342
1386
  });
1343
1387
  const draftTop = createMemo(
1344
1388
  () =>
1345
1389
  CELL_PAD +
1346
1390
  DATE_ROW +
1347
1391
  props.chipGap +
1348
- Math.min(visibleLanes(), Math.max(0, props.maxVisibleEventCount - 1)) *
1349
- (props.chipHeight + props.chipGap),
1392
+ (draftSpan()?.lane ?? 0) * (props.chipHeight + props.chipGap),
1350
1393
  );
1351
1394
  const draftHeight = createMemo(() =>
1352
1395
  Math.min(props.chipHeight, Math.max(0, eventRowHeight() - draftTop())),
@@ -1355,8 +1398,8 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1355
1398
  <>
1356
1399
  {(() => {
1357
1400
  const barSegs = createMemo(() =>
1358
- rowLayout()
1359
- .segments.filter((s) => s.lane < visibleLanes())
1401
+ monthVisibleBars(rowLayout(), visibleLanes(), extraLane())
1402
+ .filter((s) => s.event !== draftEvent())
1360
1403
  .map((s) => {
1361
1404
  const startCol = Math.max(s.startCol, columns().first);
1362
1405
  const endCol = Math.min(s.endCol, columns().last);
@@ -1387,6 +1430,11 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1387
1430
  {
1388
1431
  <For each={week().days} keyed={false}>
1389
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
+ );
1390
1438
  const hidden = createMemo(
1391
1439
  () => !showAdjacentMonths() && isOutsidePeriod(day()),
1392
1440
  );
@@ -1483,7 +1531,8 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1483
1531
  (s) =>
1484
1532
  s.startCol <= dayCol &&
1485
1533
  s.endCol >= dayCol &&
1486
- s.lane >= visibleLanes(),
1534
+ s.lane >= dayLanes() &&
1535
+ s.event !== draftEvent(),
1487
1536
  )
1488
1537
  .map((s) => s.event),
1489
1538
  );
@@ -1646,7 +1695,7 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1646
1695
  when={
1647
1696
  props.renderCreateGhost &&
1648
1697
  createRange() &&
1649
- draftColumns()[0] === dayCol &&
1698
+ draftSpan()?.start === dayCol &&
1650
1699
  draftHeight() > 0
1651
1700
  }
1652
1701
  >
@@ -1655,7 +1704,7 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1655
1704
  base: {
1656
1705
  position: "absolute",
1657
1706
  left: 2,
1658
- width: `calc(${(draftColumns().at(-1)! - dayCol + 1) * 100}% - 4px)`,
1707
+ width: `calc(${(draftSpan()!.end - dayCol + 1) * 100}% - 4px)`,
1659
1708
  top: draftTop(),
1660
1709
  height: draftHeight(),
1661
1710
  boxSizing: "border-box",
@@ -1810,7 +1859,7 @@ export function DateRows<T = unknown>(incoming: DateRowsProps<T>): JSX.Element {
1810
1859
  space and "+more" sits below them. */}
1811
1860
  {Array.from(
1812
1861
  {
1813
- length: visibleLanes(),
1862
+ length: dayLanes(),
1814
1863
  },
1815
1864
  () => (
1816
1865
  <div