@super-calendar/native 2.10.0 → 2.11.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/dist/index.d.mts +51 -13
- package/dist/index.d.ts +51 -13
- package/dist/index.js +908 -592
- package/dist/index.mjs +909 -593
- package/package.json +2 -2
- package/src/components/Agenda.tsx +5 -1
- package/src/components/AllDayLane.tsx +36 -53
- package/src/components/Calendar.tsx +39 -4
- package/src/components/MultiDayMovePreview.tsx +1 -3
- package/src/components/TimeGrid.tsx +1366 -878
- package/src/components/YearView.tsx +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Gesture-driven, virtualized month / week / day calendar and date picker for React Native (and web via react-native-web).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agenda",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@super-calendar/core": "2.
|
|
67
|
+
"@super-calendar/core": "2.11.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@legendapp/list": ">=3",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LegendList, type LegendListRenderItemProps } from "@legendapp/list/react-native";
|
|
2
2
|
import { format, isSameDay, type Locale, startOfDay } from "date-fns";
|
|
3
3
|
import { type ComponentType, type ReactElement, useCallback, useMemo } from "react";
|
|
4
|
-
import { StyleSheet, Text, type TextStyle, View } from "react-native";
|
|
4
|
+
import { StyleSheet, Text, type TextStyle, View, type ScrollViewProps } from "react-native";
|
|
5
5
|
import { useCalendarTheme } from "../theme";
|
|
6
6
|
import type { CalendarEvent, EventKeyExtractor, RenderEvent } from "../types";
|
|
7
7
|
import { createSlots, type SlotStyleProps } from "../utils/slots";
|
|
@@ -27,6 +27,8 @@ export type AgendaProps<T> = SlotStyleProps<AgendaSlot> & {
|
|
|
27
27
|
activeDate?: Date;
|
|
28
28
|
/** Drawn between rows of the agenda list. */
|
|
29
29
|
itemSeparatorComponent?: ComponentType<unknown> | null;
|
|
30
|
+
/** Pull-to-refresh control, mounted on the list's scroll view. */
|
|
31
|
+
refreshControl?: ScrollViewProps["refreshControl"];
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
type Row<T> =
|
|
@@ -48,6 +50,7 @@ export function Agenda<T>({
|
|
|
48
50
|
onPressDay,
|
|
49
51
|
activeDate,
|
|
50
52
|
itemSeparatorComponent,
|
|
53
|
+
refreshControl,
|
|
51
54
|
classNames,
|
|
52
55
|
styles: styleOverrides,
|
|
53
56
|
}: AgendaProps<T>): ReactElement {
|
|
@@ -145,6 +148,7 @@ export function Agenda<T>({
|
|
|
145
148
|
(itemSeparatorComponent ?? undefined) as ComponentType<{ leadingItem: Row<T> }> | undefined
|
|
146
149
|
}
|
|
147
150
|
recycleItems={false}
|
|
151
|
+
refreshControl={refreshControl}
|
|
148
152
|
/>
|
|
149
153
|
);
|
|
150
154
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { addDays, startOfDay } from "date-fns";
|
|
2
|
-
import {
|
|
2
|
+
import { type LayoutChangeEvent, StyleSheet, View } from "react-native";
|
|
3
3
|
import { useCalendarTheme } from "../theme";
|
|
4
4
|
import type { CalendarEvent, CalendarMode, EventKeyExtractor, RenderEvent } from "../types";
|
|
5
5
|
import { useSlots } from "../utils/slots";
|
|
@@ -7,36 +7,38 @@ import { isAllDayEvent, isBackgroundEvent } from "@super-calendar/core";
|
|
|
7
7
|
|
|
8
8
|
// The lane's slots are a subset of the TimeGrid slot union; typed locally so
|
|
9
9
|
// this file doesn't import the full TimeGrid type.
|
|
10
|
-
type AllDayLaneSlot = "allDayLane" | "
|
|
10
|
+
type AllDayLaneSlot = "allDayLane" | "allDayColumn" | "allDayEvent";
|
|
11
11
|
|
|
12
12
|
type AllDayLaneProps<T> = {
|
|
13
13
|
days: Date[];
|
|
14
14
|
events: CalendarEvent<T>[];
|
|
15
15
|
mode: CalendarMode;
|
|
16
|
-
hourColumnWidth: number;
|
|
17
16
|
dayWidth: number;
|
|
18
17
|
renderEvent: RenderEvent<T>;
|
|
19
18
|
keyExtractor: EventKeyExtractor<T>;
|
|
20
19
|
onPressEvent: (event: CalendarEvent<T>) => void;
|
|
21
20
|
onLongPressEvent?: (event: CalendarEvent<T>) => void;
|
|
21
|
+
/** Reports the lane's natural height, which the grid's all-day band follows. */
|
|
22
|
+
onLayout?: (event: LayoutChangeEvent) => void;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
* The all-day lane
|
|
26
|
-
* excluded from the timed columns (see `layoutDayEvents`) and shown
|
|
27
|
-
* stacked under their day(s).
|
|
28
|
-
*
|
|
26
|
+
* The all-day lane of one page, pinned above the scrolling hours. All-day
|
|
27
|
+
* events are excluded from the timed columns (see `layoutDayEvents`) and shown
|
|
28
|
+
* here, stacked under their day(s). Always rendered so every page reports a
|
|
29
|
+
* height, zero when the week has none, which the band above the grid follows
|
|
30
|
+
* live as you swipe; the "all-day" label lives in the hour column.
|
|
29
31
|
*/
|
|
30
32
|
export function AllDayLane<T>({
|
|
31
33
|
days,
|
|
32
34
|
events,
|
|
33
35
|
mode,
|
|
34
|
-
hourColumnWidth,
|
|
35
36
|
dayWidth,
|
|
36
37
|
renderEvent,
|
|
37
38
|
keyExtractor,
|
|
38
39
|
onPressEvent,
|
|
39
40
|
onLongPressEvent,
|
|
41
|
+
onLayout,
|
|
40
42
|
}: AllDayLaneProps<T>) {
|
|
41
43
|
const theme = useCalendarTheme();
|
|
42
44
|
const slot = useSlots<AllDayLaneSlot>();
|
|
@@ -50,50 +52,40 @@ export function AllDayLane<T>({
|
|
|
50
52
|
return allDay.filter((event) => event.start < next && event.end > start);
|
|
51
53
|
});
|
|
52
54
|
|
|
53
|
-
if (perDay.every((list) => list.length === 0)) return null;
|
|
54
|
-
|
|
55
55
|
return (
|
|
56
56
|
<View
|
|
57
57
|
{...slot("allDayLane", {
|
|
58
58
|
base: styles.lane,
|
|
59
|
-
themed:
|
|
59
|
+
themed: theme.containers.allDayLane,
|
|
60
60
|
})}
|
|
61
|
+
onLayout={onLayout}
|
|
61
62
|
>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<RenderEventComponent
|
|
87
|
-
event={event}
|
|
88
|
-
mode={mode}
|
|
89
|
-
isAllDay
|
|
90
|
-
onPress={() => onPressEvent(event)}
|
|
91
|
-
onLongPress={onLongPressEvent ? () => onLongPressEvent(event) : undefined}
|
|
92
|
-
/>
|
|
63
|
+
{perDay.every((list) => list.length === 0)
|
|
64
|
+
? null
|
|
65
|
+
: days.map((day, dayIndex) => (
|
|
66
|
+
<View
|
|
67
|
+
key={day.toISOString()}
|
|
68
|
+
{...slot("allDayColumn", {
|
|
69
|
+
base: [styles.column, { width: dayWidth }],
|
|
70
|
+
themed: theme.containers.allDayColumn,
|
|
71
|
+
})}
|
|
72
|
+
>
|
|
73
|
+
{perDay[dayIndex].map((event, index) => (
|
|
74
|
+
<View
|
|
75
|
+
key={keyExtractor(event, index)}
|
|
76
|
+
{...slot("allDayEvent", { base: styles.chip })}
|
|
77
|
+
>
|
|
78
|
+
<RenderEventComponent
|
|
79
|
+
event={event}
|
|
80
|
+
mode={mode}
|
|
81
|
+
isAllDay
|
|
82
|
+
onPress={() => onPressEvent(event)}
|
|
83
|
+
onLongPress={onLongPressEvent ? () => onLongPressEvent(event) : undefined}
|
|
84
|
+
/>
|
|
85
|
+
</View>
|
|
86
|
+
))}
|
|
93
87
|
</View>
|
|
94
88
|
))}
|
|
95
|
-
</View>
|
|
96
|
-
))}
|
|
97
89
|
</View>
|
|
98
90
|
);
|
|
99
91
|
}
|
|
@@ -101,15 +93,6 @@ export function AllDayLane<T>({
|
|
|
101
93
|
const styles = StyleSheet.create({
|
|
102
94
|
lane: {
|
|
103
95
|
flexDirection: "row",
|
|
104
|
-
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
105
|
-
},
|
|
106
|
-
gutter: {
|
|
107
|
-
justifyContent: "center",
|
|
108
|
-
},
|
|
109
|
-
label: {
|
|
110
|
-
fontSize: 10,
|
|
111
|
-
textAlign: "right",
|
|
112
|
-
paddingRight: 6,
|
|
113
96
|
},
|
|
114
97
|
column: {
|
|
115
98
|
paddingVertical: 2,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
startOfYear,
|
|
14
14
|
} from "date-fns";
|
|
15
15
|
import { type ReactElement, useCallback, useMemo } from "react";
|
|
16
|
-
import type { StyleProp, ViewStyle } from "react-native";
|
|
16
|
+
import type { ScrollViewProps, StyleProp, ViewStyle } from "react-native";
|
|
17
17
|
import { useSharedValue } from "react-native-reanimated";
|
|
18
18
|
import { CalendarThemeProvider, mergeTheme, type PartialCalendarTheme } from "../theme";
|
|
19
19
|
import type {
|
|
@@ -207,6 +207,18 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
207
207
|
* band stays non-interactive and hidden from assistive tech.
|
|
208
208
|
*/
|
|
209
209
|
renderBusinessHours?: (band: BusinessHoursBand) => React.ReactNode;
|
|
210
|
+
/**
|
|
211
|
+
* Week/day grid only: a component that draws a `display: "background"` event's
|
|
212
|
+
* band in place of the themed shade. Rendered as a real component, like
|
|
213
|
+
* `renderEvent`, so it may use hooks. It receives `event`, `mode`, a live
|
|
214
|
+
* `boxHeight`, `continuesBefore` / `continuesAfter` for a multi-day event, and
|
|
215
|
+
* `onPress` / `onLongPress`, which fire `onPressEvent` / `onLongPressEvent`.
|
|
216
|
+
* The band lets touches through to what you render and stops hiding itself
|
|
217
|
+
* from assistive tech, so a pressable there works; cell presses and
|
|
218
|
+
* drag-to-create are unreachable underneath it. Without this prop the band
|
|
219
|
+
* stays a shaded, non-interactive range. The resource timeline keeps the shade.
|
|
220
|
+
*/
|
|
221
|
+
renderBackgroundEvent?: RenderEvent<T>;
|
|
210
222
|
/** Stable key per event. Defaults to start-time + index. */
|
|
211
223
|
keyExtractor?: EventKeyExtractor<T>;
|
|
212
224
|
/** Partial theme merged over the defaults. */
|
|
@@ -234,11 +246,26 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
234
246
|
/** Sub-hour divider lines per hour on the week/day grid (e.g. 2 = half-hours). Default 1. */
|
|
235
247
|
timeslots?: number;
|
|
236
248
|
/**
|
|
237
|
-
* Show the all-day lane above the week/day grid. Default true
|
|
238
|
-
*
|
|
239
|
-
*
|
|
249
|
+
* Show the all-day lane above the week/day grid. Default true: the lane is
|
|
250
|
+
* sized to the week's all-day events, collapsing to nothing when there are
|
|
251
|
+
* none, and its height follows the week as you swipe. When false the lane is
|
|
252
|
+
* never rendered, so
|
|
253
|
+
* all-day events (see `ICalendarEvent.allDay` and whole-day spans) are not
|
|
254
|
+
* shown on the time grid.
|
|
240
255
|
*/
|
|
241
256
|
showAllDayEventCell?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Show the "all-day" text label in the week/day hour column. Default false: a
|
|
259
|
+
* week with no all-day events then shows no lane at all, rather than a label
|
|
260
|
+
* beside an empty row; with the label on, it slides away with the lane.
|
|
261
|
+
*/
|
|
262
|
+
showAllDayLabel?: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Pull-to-refresh for the modes that scroll vertically: pass a `RefreshControl`
|
|
265
|
+
* element and it wraps the schedule list, the week/day grid's scroll view or
|
|
266
|
+
* the year view. Month pages scroll sideways, so it has no effect there.
|
|
267
|
+
*/
|
|
268
|
+
refreshControl?: ScrollViewProps["refreshControl"];
|
|
242
269
|
/** Tint weekend columns (default true). Set false to treat weekends normally. */
|
|
243
270
|
highlightWeekends?: boolean;
|
|
244
271
|
/** Allow moving events by default (per-event `startEditable` overrides). Default true. */
|
|
@@ -456,6 +483,7 @@ export function Calendar<T>({
|
|
|
456
483
|
calendarCellStyle,
|
|
457
484
|
businessHours,
|
|
458
485
|
renderBusinessHours,
|
|
486
|
+
renderBackgroundEvent,
|
|
459
487
|
keyExtractor = defaultKeyExtractor as EventKeyExtractor<T>,
|
|
460
488
|
theme,
|
|
461
489
|
cellHeight: cellHeightProp,
|
|
@@ -468,6 +496,8 @@ export function Calendar<T>({
|
|
|
468
496
|
hideHours,
|
|
469
497
|
timeslots,
|
|
470
498
|
showAllDayEventCell,
|
|
499
|
+
showAllDayLabel,
|
|
500
|
+
refreshControl,
|
|
471
501
|
highlightWeekends,
|
|
472
502
|
eventStartEditable,
|
|
473
503
|
eventDurationEditable,
|
|
@@ -653,6 +683,7 @@ export function Calendar<T>({
|
|
|
653
683
|
<YearView
|
|
654
684
|
date={date}
|
|
655
685
|
events={displayEvents}
|
|
686
|
+
refreshControl={refreshControl}
|
|
656
687
|
weekStartsOn={weekStartsOn}
|
|
657
688
|
hiddenDays={hiddenDays}
|
|
658
689
|
locale={locale}
|
|
@@ -680,6 +711,7 @@ export function Calendar<T>({
|
|
|
680
711
|
onPressDay={onPressDay}
|
|
681
712
|
activeDate={activeDate}
|
|
682
713
|
itemSeparatorComponent={itemSeparatorComponent}
|
|
714
|
+
refreshControl={refreshControl}
|
|
683
715
|
classNames={classNames}
|
|
684
716
|
styles={styleOverrides}
|
|
685
717
|
/>
|
|
@@ -704,6 +736,8 @@ export function Calendar<T>({
|
|
|
704
736
|
hideHours={hideHours}
|
|
705
737
|
timeslots={timeslots}
|
|
706
738
|
showAllDayEventCell={showAllDayEventCell}
|
|
739
|
+
showAllDayLabel={showAllDayLabel}
|
|
740
|
+
refreshControl={refreshControl}
|
|
707
741
|
highlightWeekends={highlightWeekends}
|
|
708
742
|
eventStartEditable={eventStartEditable}
|
|
709
743
|
eventDurationEditable={eventDurationEditable}
|
|
@@ -711,6 +745,7 @@ export function Calendar<T>({
|
|
|
711
745
|
calendarCellStyle={calendarCellStyle}
|
|
712
746
|
businessHours={businessHours}
|
|
713
747
|
renderBusinessHours={renderBusinessHours}
|
|
748
|
+
renderBackgroundEvent={renderBackgroundEvent}
|
|
714
749
|
showWeekNumber={showWeekNumber}
|
|
715
750
|
weekNumberPrefix={weekNumberPrefix}
|
|
716
751
|
hourComponent={hourComponent}
|
|
@@ -28,7 +28,6 @@ type PreviewProps<T> = {
|
|
|
28
28
|
days: Date[];
|
|
29
29
|
cellHeight: SharedValue<number>;
|
|
30
30
|
dayWidth: number;
|
|
31
|
-
hourColumnWidth: number;
|
|
32
31
|
minHour: number;
|
|
33
32
|
mode: CalendarMode;
|
|
34
33
|
renderEvent: RenderEvent<T>;
|
|
@@ -62,7 +61,6 @@ function PreviewDay<T>({
|
|
|
62
61
|
move,
|
|
63
62
|
cellHeight,
|
|
64
63
|
dayWidth,
|
|
65
|
-
hourColumnWidth,
|
|
66
64
|
minHour,
|
|
67
65
|
mode,
|
|
68
66
|
renderEvent: RenderEventComponent,
|
|
@@ -149,7 +147,7 @@ function PreviewDay<T>({
|
|
|
149
147
|
position: "absolute",
|
|
150
148
|
overflow: "hidden",
|
|
151
149
|
padding: eventGap,
|
|
152
|
-
left:
|
|
150
|
+
left: index * dayWidth,
|
|
153
151
|
width: dayWidth,
|
|
154
152
|
zIndex: 100,
|
|
155
153
|
},
|