@super-calendar/native 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.
@@ -17,6 +17,7 @@ import {
17
17
  } from "date-fns";
18
18
  import {
19
19
  type ComponentRef,
20
+ type ComponentType,
20
21
  memo,
21
22
  type ReactElement,
22
23
  useCallback,
@@ -41,11 +42,13 @@ import type {
41
42
  EventDragHandler,
42
43
  EventDragStartHandler,
43
44
  EventKeyExtractor,
45
+ MonthDateInfo,
44
46
  RenderEvent,
45
47
  WeekStartsOn,
46
48
  } from "../types";
47
49
  import {
48
50
  type CalendarSelection,
51
+ type CreateGhostArgs,
49
52
  CalendarSelectionProvider,
50
53
  buildMultiWeekGrid,
51
54
  type DateRange,
@@ -53,8 +56,8 @@ import {
53
56
  filterHiddenDays,
54
57
  getWeekDays,
55
58
  weekdayFormatToken,
59
+ type CalendarLabels,
56
60
  } from "@super-calendar/core";
57
- import type { CalendarLabels } from "@super-calendar/core";
58
61
  import { createSlots, type SlotStyleProps } from "../utils/slots";
59
62
  import { useWebPagerKeys } from "../utils/useWebPagerKeys";
60
63
  import { DateRows, type DateRowsSource, type MonthViewSlot } from "./MonthView";
@@ -86,6 +89,8 @@ export type MonthPagerProps<T> = {
86
89
  hiddenDays?: number[];
87
90
  weekdayFormat?: WeekdayFormat;
88
91
  locale?: Locale;
92
+ now?: Date;
93
+ timeZone?: string;
89
94
  sortedMonthView?: boolean;
90
95
  moreLabel?: string;
91
96
  /** Translations for the screen-reader words and gutter text; omitted keys use English. */
@@ -106,6 +111,8 @@ export type MonthPagerProps<T> = {
106
111
  onPressMore?: (events: CalendarEvent<T>[], date: Date) => void;
107
112
  /** Drag across empty day cells to sweep out an all-day span for a new event. */
108
113
  onCreateEvent?: (start: Date, end: Date) => void;
114
+ /** Content for each row of the live creation preview; requires `onCreateEvent`. */
115
+ renderCreateGhost?: ComponentType<CreateGhostArgs>;
109
116
  /** Drag-to-select: reports the swept `[start, end]` days live. */
110
117
  onSelectDrag?: (start: Date, end: Date) => void;
111
118
  /** Days drawn as selected (a filled badge). */
@@ -137,8 +144,8 @@ export type MonthPagerProps<T> = {
137
144
  activeDate?: Date;
138
145
  /** Replace the weekday-label header above the month grid. Receives the week's days. */
139
146
  renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
140
- /** Replace the default date badge in each day cell. Receives the day. */
141
- renderCustomDateForMonth?: (date: Date) => React.ReactNode;
147
+ /** Replace the default date badge in each day cell. Receives the day and its state. */
148
+ renderCustomDateForMonth?: (date: Date, info: MonthDateInfo) => React.ReactNode;
142
149
  } & SlotStyleProps<MonthViewSlot>;
143
150
 
144
151
  /**
@@ -185,6 +192,8 @@ function DateRowsPagerInner<T>({
185
192
  hiddenDays,
186
193
  weekdayFormat = "short",
187
194
  locale,
195
+ now,
196
+ timeZone,
188
197
  sortedMonthView,
189
198
  moreLabel,
190
199
  labels,
@@ -201,6 +210,7 @@ function DateRowsPagerInner<T>({
201
210
  onLongPressEvent,
202
211
  onPressMore,
203
212
  onCreateEvent,
213
+ renderCreateGhost,
204
214
  onSelectDrag,
205
215
  selectedDates,
206
216
  selectedRange,
@@ -370,16 +380,37 @@ function DateRowsPagerInner<T>({
370
380
  // `fillCellOnSelection` and `onSelectDrag` ride along because they reach the
371
381
  // grids as renderItem props, not through the selection context below: toggling
372
382
  // a "pick dates" mode on must reach the pages already rendered.
383
+ // `now` and `timeZone` move the today highlight on the pages already rendered.
384
+ const nowTime = now?.getTime();
373
385
  const monthExtraData = useMemo(
374
386
  () => ({
375
387
  events,
376
388
  activeDate,
389
+ nowTime,
390
+ timeZone,
377
391
  fillCellOnSelection,
378
392
  dragSelect: onSelectDrag != null,
379
393
  chipHeight,
380
394
  chipGap,
395
+ renderCreateGhost,
396
+ onCreateEvent,
397
+ createGhostClassName: classNames?.createGhost,
398
+ createGhostStyle: styleOverrides?.createGhost,
381
399
  }),
382
- [events, activeDate, fillCellOnSelection, onSelectDrag, chipHeight, chipGap],
400
+ [
401
+ events,
402
+ activeDate,
403
+ nowTime,
404
+ timeZone,
405
+ fillCellOnSelection,
406
+ onSelectDrag,
407
+ chipHeight,
408
+ chipGap,
409
+ renderCreateGhost,
410
+ onCreateEvent,
411
+ classNames?.createGhost,
412
+ styleOverrides?.createGhost,
413
+ ],
383
414
  );
384
415
 
385
416
  // Selection reaches the grids through context, not `renderItem`, so a change
@@ -423,6 +454,8 @@ function DateRowsPagerInner<T>({
423
454
  weekStartsOn={weekStartsOn}
424
455
  hiddenDays={hiddenDays}
425
456
  locale={locale}
457
+ now={now}
458
+ timeZone={timeZone}
426
459
  sortedMonthView={sortedMonthView}
427
460
  moreLabel={moreLabel}
428
461
  labels={labels}
@@ -440,6 +473,7 @@ function DateRowsPagerInner<T>({
440
473
  onLongPressEvent={onLongPressEvent}
441
474
  onPressMore={onPressMore}
442
475
  onCreateEvent={onCreateEvent}
476
+ renderCreateGhost={renderCreateGhost}
443
477
  onSelectDrag={onSelectDrag}
444
478
  fillCellOnSelection={fillCellOnSelection}
445
479
  onDragEvent={onDragEvent}
@@ -462,6 +496,8 @@ function DateRowsPagerInner<T>({
462
496
  weekStartsOn,
463
497
  hiddenDays,
464
498
  locale,
499
+ now,
500
+ timeZone,
465
501
  sortedMonthView,
466
502
  moreLabel,
467
503
  labels,
@@ -480,6 +516,7 @@ function DateRowsPagerInner<T>({
480
516
  onLongPressEvent,
481
517
  onPressMore,
482
518
  onCreateEvent,
519
+ renderCreateGhost,
483
520
  onSelectDrag,
484
521
  fillCellOnSelection,
485
522
  onDragEvent,