@super-calendar/native 2.0.0 → 2.1.3
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 +75 -0
- package/dist/{DefaultMonthEvent-86XCNCge.d.ts → DefaultMonthEvent-D2s0x2Bn.d.mts} +79 -6
- package/dist/{DefaultMonthEvent-CpRoOloh.d.mts → DefaultMonthEvent-DaTEIcRs.d.ts} +79 -6
- package/dist/{MonthList-CyrEJ_U6.mjs → MonthList-DXvjxiyu.mjs} +59 -0
- package/dist/{MonthList-BCfN-UGz.js → MonthList-oXiArmbu.js} +59 -0
- package/dist/index.d.mts +55 -6
- package/dist/index.d.ts +55 -6
- package/dist/index.js +57 -8
- package/dist/index.mjs +57 -8
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +5 -5
- package/src/components/Agenda.tsx +3 -2
- package/src/components/Calendar.tsx +29 -2
- package/src/components/DefaultEvent.tsx +2 -1
- package/src/components/DefaultMonthEvent.tsx +2 -1
- package/src/components/MonthList.tsx +21 -2
- package/src/components/MonthPager.tsx +21 -2
- package/src/components/MonthView.tsx +19 -2
- package/src/components/TimeGrid.tsx +42 -10
- package/src/index.tsx +22 -0
- package/src/picker.tsx +17 -4
- package/src/theme.ts +16 -3
- package/src/types.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @super-calendar/native
|
|
2
|
+
|
|
3
|
+
[](https://jsr.io/@super-calendar/native) [](https://jsr.io/@super-calendar/native)
|
|
4
|
+
|
|
5
|
+
The React Native renderer for [super-calendar](https://github.com/afonsojramos/react-native-super-calendar): a gesture-driven, virtualized **month / week / day** calendar and date picker. Runs on iOS, Android, and web (web via [react-native-web](https://necolas.github.io/react-native-web/)).
|
|
6
|
+
|
|
7
|
+
- 📆 Month grid plus day / 3-day / week / custom-N time grids and an agenda
|
|
8
|
+
- 🤏 Pinch-to-zoom week/day grid (UI thread, no re-renders)
|
|
9
|
+
- ♾️ Virtualized, snap-paging views via [`@legendapp/list`](https://legendapp.com/open-source/list/)
|
|
10
|
+
- 🧩 Bring-your-own event type (`CalendarEvent<T>`) and a `renderEvent` escape hatch
|
|
11
|
+
- 🪝 Headless `useMonthGrid` and `useDateRange` for fully custom UIs
|
|
12
|
+
- 🎨 Themeable, with a `darkTheme` preset
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
# Deno
|
|
18
|
+
deno add jsr:@super-calendar/native
|
|
19
|
+
|
|
20
|
+
# npm / pnpm / yarn / bun
|
|
21
|
+
npx jsr add @super-calendar/native
|
|
22
|
+
pnpm dlx jsr add @super-calendar/native
|
|
23
|
+
bunx jsr add @super-calendar/native
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Peer dependencies: `@legendapp/list` (>=3), `date-fns` (>=3), `react` (>=19), `react-native` (>=0.85), `react-native-gesture-handler` (>=2), `react-native-reanimated` (>=4), and `react-native-worklets` (>=0.8).
|
|
27
|
+
|
|
28
|
+
For a picker-only bundle that does not require Reanimated, import from the `@super-calendar/native/picker` subpath.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { useState } from "react";
|
|
34
|
+
import { Calendar, type CalendarEvent } from "@super-calendar/native";
|
|
35
|
+
|
|
36
|
+
type MyEvent = { id: string; color: string };
|
|
37
|
+
|
|
38
|
+
const events: CalendarEvent<MyEvent>[] = [
|
|
39
|
+
{
|
|
40
|
+
id: "1",
|
|
41
|
+
color: "#1F6FEB",
|
|
42
|
+
title: "Lecture",
|
|
43
|
+
start: new Date(2026, 5, 19, 10, 0),
|
|
44
|
+
end: new Date(2026, 5, 19, 11, 30),
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
export function MyCalendar() {
|
|
49
|
+
const [mode, setMode] = useState<"month" | "week" | "day">("week");
|
|
50
|
+
const [date, setDate] = useState(new Date());
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Calendar
|
|
54
|
+
mode={mode}
|
|
55
|
+
date={date}
|
|
56
|
+
events={events}
|
|
57
|
+
weekStartsOn={1}
|
|
58
|
+
onChangeDate={setDate}
|
|
59
|
+
onPressEvent={(event) => console.log(event.id)}
|
|
60
|
+
onPressDay={(day) => {
|
|
61
|
+
setDate(day);
|
|
62
|
+
setMode("day");
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Documentation
|
|
70
|
+
|
|
71
|
+
See the [full documentation](https://super-calendar.afonsojramos.me) and the [quickstart](https://super-calendar.afonsojramos.me/quickstart), including theming, recurring events, time zones, and the headless picker.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
|
-
import {
|
|
2
|
+
import { ComponentType, ReactElement } from "react";
|
|
3
3
|
import { SharedValue } from "react-native-reanimated";
|
|
4
4
|
import { BusinessHours, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn } from "@super-calendar/core";
|
|
5
|
-
import {
|
|
5
|
+
import { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
6
6
|
|
|
7
7
|
//#region src/theme.d.ts
|
|
8
8
|
/**
|
|
@@ -13,6 +13,7 @@ import { ComponentType } from "react";
|
|
|
13
13
|
interface CalendarTheme {
|
|
14
14
|
/** The shared colour palette (sourced from `@super-calendar/core`). */
|
|
15
15
|
colors: CalendarColors;
|
|
16
|
+
/** Text styles for the calendar's labels and the built-in event box. */
|
|
16
17
|
text: {
|
|
17
18
|
/** Large day number in the week/day header. */dayNumber: TextStyle; /** Short weekday label ("Mon") in headers. */
|
|
18
19
|
weekday: TextStyle; /** Date number inside a month cell. */
|
|
@@ -29,6 +30,7 @@ interface CalendarTheme {
|
|
|
29
30
|
*/
|
|
30
31
|
rangeBandHeight: number;
|
|
31
32
|
}
|
|
33
|
+
/** The default light theme. Every key the calendar reads falls back to this. */
|
|
32
34
|
declare const defaultTheme: CalendarTheme;
|
|
33
35
|
/**
|
|
34
36
|
* A ready-made dark palette. Pass it straight to `<Calendar theme={darkTheme} />`,
|
|
@@ -38,16 +40,32 @@ declare const defaultTheme: CalendarTheme;
|
|
|
38
40
|
declare const darkTheme: CalendarTheme;
|
|
39
41
|
/** Deep-merge a partial theme over {@link defaultTheme}. */
|
|
40
42
|
declare function mergeTheme(theme?: PartialCalendarTheme): CalendarTheme;
|
|
43
|
+
/**
|
|
44
|
+
* A theme with every key optional. Pass this to `<Calendar theme={...} />` to
|
|
45
|
+
* override only the colours, text styles, or metrics you care about; the rest
|
|
46
|
+
* come from {@link defaultTheme}.
|
|
47
|
+
*/
|
|
41
48
|
type PartialCalendarTheme = {
|
|
42
49
|
colors?: Partial<CalendarTheme["colors"]>;
|
|
43
50
|
text?: Partial<CalendarTheme["text"]>;
|
|
44
51
|
todayBadgeRadius?: number;
|
|
45
52
|
rangeBandHeight?: number;
|
|
46
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Context provider that supplies the active {@link CalendarTheme} to descendants.
|
|
56
|
+
* `<Calendar>` wraps its subtree in this; use it directly only to theme custom
|
|
57
|
+
* components rendered outside a `<Calendar>`.
|
|
58
|
+
*/
|
|
47
59
|
declare const CalendarThemeProvider: import("react").Provider<CalendarTheme>;
|
|
60
|
+
/** Read the active {@link CalendarTheme} from context. Useful inside custom renderers. */
|
|
48
61
|
declare const useCalendarTheme: () => CalendarTheme;
|
|
49
62
|
//#endregion
|
|
50
63
|
//#region src/types.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* Props passed to a {@link RenderEvent} component for one event. Carries the
|
|
66
|
+
* event, the current mode, press handlers, and built-in renderer hints such as
|
|
67
|
+
* `boxHeight`, `continuesBefore`/`continuesAfter`, and `isAllDay`.
|
|
68
|
+
*/
|
|
51
69
|
type RenderEventArgs<T = unknown> = {
|
|
52
70
|
event: CalendarEvent<T>;
|
|
53
71
|
mode: CalendarMode;
|
|
@@ -82,6 +100,7 @@ type RenderEventArgs<T = unknown> = {
|
|
|
82
100
|
type RenderEvent<T = unknown> = ComponentType<RenderEventArgs<T>>;
|
|
83
101
|
//#endregion
|
|
84
102
|
//#region src/components/MonthView.d.ts
|
|
103
|
+
/** Props for {@link MonthView}, the single-month grid. */
|
|
85
104
|
type MonthViewProps<T> = {
|
|
86
105
|
date: Date;
|
|
87
106
|
events: CalendarEvent$1<T>[];
|
|
@@ -161,10 +180,27 @@ declare function MonthViewInner<T>({
|
|
|
161
180
|
renderCustomDateForMonth,
|
|
162
181
|
onDayPointerDown,
|
|
163
182
|
onDayPointerEnter
|
|
164
|
-
}: MonthViewProps<T>):
|
|
183
|
+
}: MonthViewProps<T>): ReactElement;
|
|
184
|
+
/**
|
|
185
|
+
* A single month rendered as a 7-column grid of day cells, each showing its
|
|
186
|
+
* event chips with a "+N more" overflow. Render it on its own for a static
|
|
187
|
+
* month, or let `MonthList`/`Calendar` page through months for you.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```tsx
|
|
191
|
+
* import { MonthView, type CalendarEvent } from "react-native-super-calendar";
|
|
192
|
+
*
|
|
193
|
+
* <MonthView
|
|
194
|
+
* date={new Date()}
|
|
195
|
+
* events={events}
|
|
196
|
+
* onPressDay={(day) => console.log(day)}
|
|
197
|
+
* />
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
165
200
|
declare const MonthView: typeof MonthViewInner;
|
|
166
201
|
//#endregion
|
|
167
202
|
//#region src/components/MonthPager.d.ts
|
|
203
|
+
/** Props for {@link MonthPager}, the horizontally swipeable month carousel. */
|
|
168
204
|
type MonthPagerProps<T> = {
|
|
169
205
|
date: Date;
|
|
170
206
|
events: CalendarEvent$1<T>[];
|
|
@@ -218,10 +254,29 @@ declare function MonthPagerInner<T>({
|
|
|
218
254
|
activeDate,
|
|
219
255
|
renderHeaderForMonthView,
|
|
220
256
|
renderCustomDateForMonth
|
|
221
|
-
}: MonthPagerProps<T>):
|
|
257
|
+
}: MonthPagerProps<T>): ReactElement;
|
|
258
|
+
/**
|
|
259
|
+
* A horizontally swipeable month carousel. Swipe left/right to page between
|
|
260
|
+
* months; the committed month is reported through `onChangeDate`. It is the
|
|
261
|
+
* Reanimated-driven month view that `Calendar` uses in month mode.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```tsx
|
|
265
|
+
* import { MonthPager } from "react-native-super-calendar";
|
|
266
|
+
*
|
|
267
|
+
* <MonthPager
|
|
268
|
+
* date={date}
|
|
269
|
+
* events={events}
|
|
270
|
+
* weekStartsOn={0}
|
|
271
|
+
* onChangeDate={setDate}
|
|
272
|
+
* onPressEvent={(e) => console.log(e.title)}
|
|
273
|
+
* />
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
222
276
|
declare const MonthPager: typeof MonthPagerInner;
|
|
223
277
|
//#endregion
|
|
224
278
|
//#region src/components/MonthList.d.ts
|
|
279
|
+
/** Props for {@link MonthList}, the vertically scrolling list of months. */
|
|
225
280
|
type MonthListProps<T> = {
|
|
226
281
|
/** The month scrolled to on mount. */date: Date; /** Events to render in the grids. Omit for an events-free date picker. */
|
|
227
282
|
events?: CalendarEvent$1<T>[];
|
|
@@ -299,7 +354,25 @@ declare function MonthListInner<T>({
|
|
|
299
354
|
onSelectDrag,
|
|
300
355
|
onChangeVisibleMonth,
|
|
301
356
|
renderMonthHeader
|
|
302
|
-
}: MonthListProps<T>):
|
|
357
|
+
}: MonthListProps<T>): ReactElement;
|
|
358
|
+
/**
|
|
359
|
+
* A vertically scrolling, virtualized list of month grids. It doubles as the
|
|
360
|
+
* date picker: pass `selectedRange`/`selectedDates` and selection handlers to
|
|
361
|
+
* turn it into a single-date or range picker. Free of Reanimated, so the
|
|
362
|
+
* `/picker` entry point can ship it without the timetable views.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```tsx
|
|
366
|
+
* import { MonthList } from "react-native-super-calendar/picker";
|
|
367
|
+
*
|
|
368
|
+
* <MonthList
|
|
369
|
+
* date={new Date()}
|
|
370
|
+
* weekStartsOn={0}
|
|
371
|
+
* selectedRange={range}
|
|
372
|
+
* onPressDay={handlePressDay}
|
|
373
|
+
* />
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
303
376
|
declare const MonthList: typeof MonthListInner;
|
|
304
377
|
//#endregion
|
|
305
378
|
//#region src/components/DefaultMonthEvent.d.ts
|
|
@@ -321,6 +394,6 @@ declare function DefaultMonthEvent<T>({
|
|
|
321
394
|
cellStyle,
|
|
322
395
|
onPress,
|
|
323
396
|
onLongPress
|
|
324
|
-
}: RenderEventArgs<T>):
|
|
397
|
+
}: RenderEventArgs<T>): ReactElement;
|
|
325
398
|
//#endregion
|
|
326
399
|
export { defaultTheme as C, darkTheme as S, useCalendarTheme as T, TimeGridMode as _, MonthPagerProps as a, CalendarThemeProvider as b, BusinessHours as c, EventKeyExtractor as d, ICalendarEvent as f, RenderEventArgs as g, RenderEvent as h, MonthPager as i, CalendarEvent$1 as l, RecurrenceRule as m, MonthList as n, MonthView as o, RecurrenceFrequency as p, MonthListProps as r, MonthViewProps as s, DefaultMonthEvent as t, CalendarMode$1 as u, WeekStartsOn as v, mergeTheme as w, PartialCalendarTheme as x, CalendarTheme as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
|
-
import { ComponentType } from "react";
|
|
2
|
+
import { ComponentType, ReactElement } from "react";
|
|
3
|
+
import { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
4
|
import { SharedValue } from "react-native-reanimated";
|
|
4
5
|
import { BusinessHours, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn } from "@super-calendar/core";
|
|
5
|
-
import { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
6
6
|
|
|
7
7
|
//#region src/theme.d.ts
|
|
8
8
|
/**
|
|
@@ -13,6 +13,7 @@ import { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
|
13
13
|
interface CalendarTheme {
|
|
14
14
|
/** The shared colour palette (sourced from `@super-calendar/core`). */
|
|
15
15
|
colors: CalendarColors;
|
|
16
|
+
/** Text styles for the calendar's labels and the built-in event box. */
|
|
16
17
|
text: {
|
|
17
18
|
/** Large day number in the week/day header. */dayNumber: TextStyle; /** Short weekday label ("Mon") in headers. */
|
|
18
19
|
weekday: TextStyle; /** Date number inside a month cell. */
|
|
@@ -29,6 +30,7 @@ interface CalendarTheme {
|
|
|
29
30
|
*/
|
|
30
31
|
rangeBandHeight: number;
|
|
31
32
|
}
|
|
33
|
+
/** The default light theme. Every key the calendar reads falls back to this. */
|
|
32
34
|
declare const defaultTheme: CalendarTheme;
|
|
33
35
|
/**
|
|
34
36
|
* A ready-made dark palette. Pass it straight to `<Calendar theme={darkTheme} />`,
|
|
@@ -38,16 +40,32 @@ declare const defaultTheme: CalendarTheme;
|
|
|
38
40
|
declare const darkTheme: CalendarTheme;
|
|
39
41
|
/** Deep-merge a partial theme over {@link defaultTheme}. */
|
|
40
42
|
declare function mergeTheme(theme?: PartialCalendarTheme): CalendarTheme;
|
|
43
|
+
/**
|
|
44
|
+
* A theme with every key optional. Pass this to `<Calendar theme={...} />` to
|
|
45
|
+
* override only the colours, text styles, or metrics you care about; the rest
|
|
46
|
+
* come from {@link defaultTheme}.
|
|
47
|
+
*/
|
|
41
48
|
type PartialCalendarTheme = {
|
|
42
49
|
colors?: Partial<CalendarTheme["colors"]>;
|
|
43
50
|
text?: Partial<CalendarTheme["text"]>;
|
|
44
51
|
todayBadgeRadius?: number;
|
|
45
52
|
rangeBandHeight?: number;
|
|
46
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Context provider that supplies the active {@link CalendarTheme} to descendants.
|
|
56
|
+
* `<Calendar>` wraps its subtree in this; use it directly only to theme custom
|
|
57
|
+
* components rendered outside a `<Calendar>`.
|
|
58
|
+
*/
|
|
47
59
|
declare const CalendarThemeProvider: import("react").Provider<CalendarTheme>;
|
|
60
|
+
/** Read the active {@link CalendarTheme} from context. Useful inside custom renderers. */
|
|
48
61
|
declare const useCalendarTheme: () => CalendarTheme;
|
|
49
62
|
//#endregion
|
|
50
63
|
//#region src/types.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* Props passed to a {@link RenderEvent} component for one event. Carries the
|
|
66
|
+
* event, the current mode, press handlers, and built-in renderer hints such as
|
|
67
|
+
* `boxHeight`, `continuesBefore`/`continuesAfter`, and `isAllDay`.
|
|
68
|
+
*/
|
|
51
69
|
type RenderEventArgs<T = unknown> = {
|
|
52
70
|
event: CalendarEvent<T>;
|
|
53
71
|
mode: CalendarMode;
|
|
@@ -82,6 +100,7 @@ type RenderEventArgs<T = unknown> = {
|
|
|
82
100
|
type RenderEvent<T = unknown> = ComponentType<RenderEventArgs<T>>;
|
|
83
101
|
//#endregion
|
|
84
102
|
//#region src/components/MonthView.d.ts
|
|
103
|
+
/** Props for {@link MonthView}, the single-month grid. */
|
|
85
104
|
type MonthViewProps<T> = {
|
|
86
105
|
date: Date;
|
|
87
106
|
events: CalendarEvent$1<T>[];
|
|
@@ -161,10 +180,27 @@ declare function MonthViewInner<T>({
|
|
|
161
180
|
renderCustomDateForMonth,
|
|
162
181
|
onDayPointerDown,
|
|
163
182
|
onDayPointerEnter
|
|
164
|
-
}: MonthViewProps<T>):
|
|
183
|
+
}: MonthViewProps<T>): ReactElement;
|
|
184
|
+
/**
|
|
185
|
+
* A single month rendered as a 7-column grid of day cells, each showing its
|
|
186
|
+
* event chips with a "+N more" overflow. Render it on its own for a static
|
|
187
|
+
* month, or let `MonthList`/`Calendar` page through months for you.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```tsx
|
|
191
|
+
* import { MonthView, type CalendarEvent } from "react-native-super-calendar";
|
|
192
|
+
*
|
|
193
|
+
* <MonthView
|
|
194
|
+
* date={new Date()}
|
|
195
|
+
* events={events}
|
|
196
|
+
* onPressDay={(day) => console.log(day)}
|
|
197
|
+
* />
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
165
200
|
declare const MonthView: typeof MonthViewInner;
|
|
166
201
|
//#endregion
|
|
167
202
|
//#region src/components/MonthPager.d.ts
|
|
203
|
+
/** Props for {@link MonthPager}, the horizontally swipeable month carousel. */
|
|
168
204
|
type MonthPagerProps<T> = {
|
|
169
205
|
date: Date;
|
|
170
206
|
events: CalendarEvent$1<T>[];
|
|
@@ -218,10 +254,29 @@ declare function MonthPagerInner<T>({
|
|
|
218
254
|
activeDate,
|
|
219
255
|
renderHeaderForMonthView,
|
|
220
256
|
renderCustomDateForMonth
|
|
221
|
-
}: MonthPagerProps<T>):
|
|
257
|
+
}: MonthPagerProps<T>): ReactElement;
|
|
258
|
+
/**
|
|
259
|
+
* A horizontally swipeable month carousel. Swipe left/right to page between
|
|
260
|
+
* months; the committed month is reported through `onChangeDate`. It is the
|
|
261
|
+
* Reanimated-driven month view that `Calendar` uses in month mode.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```tsx
|
|
265
|
+
* import { MonthPager } from "react-native-super-calendar";
|
|
266
|
+
*
|
|
267
|
+
* <MonthPager
|
|
268
|
+
* date={date}
|
|
269
|
+
* events={events}
|
|
270
|
+
* weekStartsOn={0}
|
|
271
|
+
* onChangeDate={setDate}
|
|
272
|
+
* onPressEvent={(e) => console.log(e.title)}
|
|
273
|
+
* />
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
222
276
|
declare const MonthPager: typeof MonthPagerInner;
|
|
223
277
|
//#endregion
|
|
224
278
|
//#region src/components/MonthList.d.ts
|
|
279
|
+
/** Props for {@link MonthList}, the vertically scrolling list of months. */
|
|
225
280
|
type MonthListProps<T> = {
|
|
226
281
|
/** The month scrolled to on mount. */date: Date; /** Events to render in the grids. Omit for an events-free date picker. */
|
|
227
282
|
events?: CalendarEvent$1<T>[];
|
|
@@ -299,7 +354,25 @@ declare function MonthListInner<T>({
|
|
|
299
354
|
onSelectDrag,
|
|
300
355
|
onChangeVisibleMonth,
|
|
301
356
|
renderMonthHeader
|
|
302
|
-
}: MonthListProps<T>):
|
|
357
|
+
}: MonthListProps<T>): ReactElement;
|
|
358
|
+
/**
|
|
359
|
+
* A vertically scrolling, virtualized list of month grids. It doubles as the
|
|
360
|
+
* date picker: pass `selectedRange`/`selectedDates` and selection handlers to
|
|
361
|
+
* turn it into a single-date or range picker. Free of Reanimated, so the
|
|
362
|
+
* `/picker` entry point can ship it without the timetable views.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```tsx
|
|
366
|
+
* import { MonthList } from "react-native-super-calendar/picker";
|
|
367
|
+
*
|
|
368
|
+
* <MonthList
|
|
369
|
+
* date={new Date()}
|
|
370
|
+
* weekStartsOn={0}
|
|
371
|
+
* selectedRange={range}
|
|
372
|
+
* onPressDay={handlePressDay}
|
|
373
|
+
* />
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
303
376
|
declare const MonthList: typeof MonthListInner;
|
|
304
377
|
//#endregion
|
|
305
378
|
//#region src/components/DefaultMonthEvent.d.ts
|
|
@@ -321,6 +394,6 @@ declare function DefaultMonthEvent<T>({
|
|
|
321
394
|
cellStyle,
|
|
322
395
|
onPress,
|
|
323
396
|
onLongPress
|
|
324
|
-
}: RenderEventArgs<T>):
|
|
397
|
+
}: RenderEventArgs<T>): ReactElement;
|
|
325
398
|
//#endregion
|
|
326
399
|
export { defaultTheme as C, darkTheme as S, useCalendarTheme as T, TimeGridMode as _, MonthPagerProps as a, CalendarThemeProvider as b, BusinessHours as c, EventKeyExtractor as d, ICalendarEvent as f, RenderEventArgs as g, RenderEvent as h, MonthPager as i, CalendarEvent$1 as l, RecurrenceRule as m, MonthList as n, MonthView as o, RecurrenceFrequency as p, MonthListProps as r, MonthViewProps as s, DefaultMonthEvent as t, CalendarMode$1 as u, WeekStartsOn as v, mergeTheme as w, PartialCalendarTheme as x, CalendarTheme as y };
|
|
@@ -6,6 +6,7 @@ import { Platform, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
8
8
|
//#region src/theme.ts
|
|
9
|
+
/** The default light theme. Every key the calendar reads falls back to this. */
|
|
9
10
|
const defaultTheme = {
|
|
10
11
|
colors: lightColors,
|
|
11
12
|
text: {
|
|
@@ -63,7 +64,13 @@ function mergeTheme(theme) {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
const CalendarThemeContext = createContext(defaultTheme);
|
|
67
|
+
/**
|
|
68
|
+
* Context provider that supplies the active {@link CalendarTheme} to descendants.
|
|
69
|
+
* `<Calendar>` wraps its subtree in this; use it directly only to theme custom
|
|
70
|
+
* components rendered outside a `<Calendar>`.
|
|
71
|
+
*/
|
|
66
72
|
const CalendarThemeProvider = CalendarThemeContext.Provider;
|
|
73
|
+
/** Read the active {@link CalendarTheme} from context. Useful inside custom renderers. */
|
|
67
74
|
const useCalendarTheme = () => useContext(CalendarThemeContext);
|
|
68
75
|
//#endregion
|
|
69
76
|
//#region src/utils/useWebPagerKeys.ts
|
|
@@ -337,6 +344,22 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
|
|
|
337
344
|
]
|
|
338
345
|
});
|
|
339
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* A single month rendered as a 7-column grid of day cells, each showing its
|
|
349
|
+
* event chips with a "+N more" overflow. Render it on its own for a static
|
|
350
|
+
* month, or let `MonthList`/`Calendar` page through months for you.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```tsx
|
|
354
|
+
* import { MonthView, type CalendarEvent } from "react-native-super-calendar";
|
|
355
|
+
*
|
|
356
|
+
* <MonthView
|
|
357
|
+
* date={new Date()}
|
|
358
|
+
* events={events}
|
|
359
|
+
* onPressDay={(day) => console.log(day)}
|
|
360
|
+
* />
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
340
363
|
const MonthView = memo(MonthViewInner);
|
|
341
364
|
const styles$3 = StyleSheet.create({
|
|
342
365
|
root: { flex: 1 },
|
|
@@ -562,6 +585,24 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, loc
|
|
|
562
585
|
]
|
|
563
586
|
});
|
|
564
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* A horizontally swipeable month carousel. Swipe left/right to page between
|
|
590
|
+
* months; the committed month is reported through `onChangeDate`. It is the
|
|
591
|
+
* Reanimated-driven month view that `Calendar` uses in month mode.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ```tsx
|
|
595
|
+
* import { MonthPager } from "react-native-super-calendar";
|
|
596
|
+
*
|
|
597
|
+
* <MonthPager
|
|
598
|
+
* date={date}
|
|
599
|
+
* events={events}
|
|
600
|
+
* weekStartsOn={0}
|
|
601
|
+
* onChangeDate={setDate}
|
|
602
|
+
* onPressEvent={(e) => console.log(e.title)}
|
|
603
|
+
* />
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
565
606
|
const MonthPager = memo(MonthPagerInner);
|
|
566
607
|
const MonthWeekdayHeader = ({ weekDays, locale }) => {
|
|
567
608
|
const theme = useCalendarTheme();
|
|
@@ -1003,6 +1044,24 @@ function MonthBlock({ height, inert, children }) {
|
|
|
1003
1044
|
children
|
|
1004
1045
|
});
|
|
1005
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* A vertically scrolling, virtualized list of month grids. It doubles as the
|
|
1049
|
+
* date picker: pass `selectedRange`/`selectedDates` and selection handlers to
|
|
1050
|
+
* turn it into a single-date or range picker. Free of Reanimated, so the
|
|
1051
|
+
* `/picker` entry point can ship it without the timetable views.
|
|
1052
|
+
*
|
|
1053
|
+
* @example
|
|
1054
|
+
* ```tsx
|
|
1055
|
+
* import { MonthList } from "react-native-super-calendar/picker";
|
|
1056
|
+
*
|
|
1057
|
+
* <MonthList
|
|
1058
|
+
* date={new Date()}
|
|
1059
|
+
* weekStartsOn={0}
|
|
1060
|
+
* selectedRange={range}
|
|
1061
|
+
* onPressDay={handlePressDay}
|
|
1062
|
+
* />
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1006
1065
|
const MonthList = memo(MonthListInner);
|
|
1007
1066
|
const styles = StyleSheet.create({
|
|
1008
1067
|
container: { flex: 1 },
|
|
@@ -6,6 +6,7 @@ let react_native = require("react-native");
|
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
let react_native_gesture_handler = require("react-native-gesture-handler");
|
|
8
8
|
//#region src/theme.ts
|
|
9
|
+
/** The default light theme. Every key the calendar reads falls back to this. */
|
|
9
10
|
const defaultTheme = {
|
|
10
11
|
colors: _super_calendar_core.lightColors,
|
|
11
12
|
text: {
|
|
@@ -63,7 +64,13 @@ function mergeTheme(theme) {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
const CalendarThemeContext = (0, react.createContext)(defaultTheme);
|
|
67
|
+
/**
|
|
68
|
+
* Context provider that supplies the active {@link CalendarTheme} to descendants.
|
|
69
|
+
* `<Calendar>` wraps its subtree in this; use it directly only to theme custom
|
|
70
|
+
* components rendered outside a `<Calendar>`.
|
|
71
|
+
*/
|
|
66
72
|
const CalendarThemeProvider = CalendarThemeContext.Provider;
|
|
73
|
+
/** Read the active {@link CalendarTheme} from context. Useful inside custom renderers. */
|
|
67
74
|
const useCalendarTheme = () => (0, react.useContext)(CalendarThemeContext);
|
|
68
75
|
//#endregion
|
|
69
76
|
//#region src/utils/useWebPagerKeys.ts
|
|
@@ -337,6 +344,22 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
|
|
|
337
344
|
]
|
|
338
345
|
});
|
|
339
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* A single month rendered as a 7-column grid of day cells, each showing its
|
|
349
|
+
* event chips with a "+N more" overflow. Render it on its own for a static
|
|
350
|
+
* month, or let `MonthList`/`Calendar` page through months for you.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```tsx
|
|
354
|
+
* import { MonthView, type CalendarEvent } from "react-native-super-calendar";
|
|
355
|
+
*
|
|
356
|
+
* <MonthView
|
|
357
|
+
* date={new Date()}
|
|
358
|
+
* events={events}
|
|
359
|
+
* onPressDay={(day) => console.log(day)}
|
|
360
|
+
* />
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
340
363
|
const MonthView = (0, react.memo)(MonthViewInner);
|
|
341
364
|
const styles$3 = react_native.StyleSheet.create({
|
|
342
365
|
root: { flex: 1 },
|
|
@@ -562,6 +585,24 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, loc
|
|
|
562
585
|
]
|
|
563
586
|
});
|
|
564
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* A horizontally swipeable month carousel. Swipe left/right to page between
|
|
590
|
+
* months; the committed month is reported through `onChangeDate`. It is the
|
|
591
|
+
* Reanimated-driven month view that `Calendar` uses in month mode.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ```tsx
|
|
595
|
+
* import { MonthPager } from "react-native-super-calendar";
|
|
596
|
+
*
|
|
597
|
+
* <MonthPager
|
|
598
|
+
* date={date}
|
|
599
|
+
* events={events}
|
|
600
|
+
* weekStartsOn={0}
|
|
601
|
+
* onChangeDate={setDate}
|
|
602
|
+
* onPressEvent={(e) => console.log(e.title)}
|
|
603
|
+
* />
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
565
606
|
const MonthPager = (0, react.memo)(MonthPagerInner);
|
|
566
607
|
const MonthWeekdayHeader = ({ weekDays, locale }) => {
|
|
567
608
|
const theme = useCalendarTheme();
|
|
@@ -1003,6 +1044,24 @@ function MonthBlock({ height, inert, children }) {
|
|
|
1003
1044
|
children
|
|
1004
1045
|
});
|
|
1005
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* A vertically scrolling, virtualized list of month grids. It doubles as the
|
|
1049
|
+
* date picker: pass `selectedRange`/`selectedDates` and selection handlers to
|
|
1050
|
+
* turn it into a single-date or range picker. Free of Reanimated, so the
|
|
1051
|
+
* `/picker` entry point can ship it without the timetable views.
|
|
1052
|
+
*
|
|
1053
|
+
* @example
|
|
1054
|
+
* ```tsx
|
|
1055
|
+
* import { MonthList } from "react-native-super-calendar/picker";
|
|
1056
|
+
*
|
|
1057
|
+
* <MonthList
|
|
1058
|
+
* date={new Date()}
|
|
1059
|
+
* weekStartsOn={0}
|
|
1060
|
+
* selectedRange={range}
|
|
1061
|
+
* onPressDay={handlePressDay}
|
|
1062
|
+
* />
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1006
1065
|
const MonthList = (0, react.memo)(MonthListInner);
|
|
1007
1066
|
const styles = react_native.StyleSheet.create({
|
|
1008
1067
|
container: { flex: 1 },
|