react-native-dot-calendar 0.0.0-stage → 0.1.1
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/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +113 -2
- package/docs/calendar.png +0 -0
- package/lib/module/MonthCalendar.js +334 -0
- package/lib/module/MonthCalendar.js.map +1 -0
- package/lib/module/dates.js +99 -0
- package/lib/module/dates.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/theme.js +20 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/typescript/MonthCalendar.d.ts +50 -0
- package/lib/typescript/MonthCalendar.d.ts.map +1 -0
- package/lib/typescript/dates.d.ts +35 -0
- package/lib/typescript/dates.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/theme.d.ts +25 -0
- package/lib/typescript/theme.d.ts.map +1 -0
- package/package.json +91 -4
- package/src/MonthCalendar.tsx +401 -0
- package/src/dates.ts +102 -0
- package/src/index.ts +14 -0
- package/src/theme.ts +41 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
- Add a sample image to the README. No code changes.
|
|
6
|
+
|
|
7
|
+
## 0.1.0
|
|
8
|
+
|
|
9
|
+
- `MonthCalendar`: month grid with event dots, day selection, month navigation, `minDate` / `maxDate`, a configurable first day of the week, custom month and weekday names, and theming.
|
|
10
|
+
- Date helpers: `startOfMonth`, `endOfMonth`, `addMonths`, `buildMonthGrid`, `toDateString`, `todayString`, `isValidDate`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jay Singh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-native-dot-calendar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A light month calendar for React Native: event dots under each day, day selection, month navigation and theming.
|
|
4
|
+
|
|
5
|
+
<img src="https://unpkg.com/react-native-dot-calendar/docs/calendar.png" alt="Month calendar showing December 2026 with coloured event dots, today outlined and the 17th selected" width="390" />
|
|
6
|
+
|
|
7
|
+
- Pure JavaScript. No native code, so there is nothing to link and it works with Expo.
|
|
8
|
+
- No date library. Dates go in and out as `YYYY-MM-DD` strings.
|
|
9
|
+
- Lays out with flexbox, so it fits any width, rotation or split screen.
|
|
10
|
+
- Accessible: every day and arrow is a labelled button.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install react-native-dot-calendar
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Needs `react` 18 or later and `react-native` 0.73 or later.
|
|
19
|
+
|
|
20
|
+
## Use
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import React, { useState } from 'react';
|
|
24
|
+
import { MonthCalendar } from 'react-native-dot-calendar';
|
|
25
|
+
|
|
26
|
+
const markedDates = {
|
|
27
|
+
'2026-12-10': { dots: [{ color: '#22C55E' }] },
|
|
28
|
+
'2026-12-25': { dots: [{ color: '#EF4444', key: 'holiday' }, { color: '#3B82F6', key: 'leave' }] },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const Schedule = () => {
|
|
32
|
+
const [selectedDate, setSelectedDate] = useState<string | null>(null);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<MonthCalendar
|
|
36
|
+
selectedDate={selectedDate}
|
|
37
|
+
markedDates={markedDates}
|
|
38
|
+
onDayPress={setSelectedDate}
|
|
39
|
+
onMonthChange={(month) => console.log('Now showing', month)}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Controlling the month
|
|
46
|
+
|
|
47
|
+
Leave `month` out and the calendar keeps track of the month itself, starting at `initialMonth` or the current month.
|
|
48
|
+
|
|
49
|
+
Pass `month` to control it, for example to load events before the month changes:
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
const [month, setMonth] = useState('2026-12');
|
|
53
|
+
|
|
54
|
+
<MonthCalendar month={month} onMonthChange={setMonth} />;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Props
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Default | What it does |
|
|
60
|
+
| --- | --- | --- | --- |
|
|
61
|
+
| `month` | `string` | | Month on screen, as `YYYY-MM` or any `YYYY-MM-DD` in it. Makes the calendar controlled. |
|
|
62
|
+
| `initialMonth` | `string` | current month | Month shown first when `month` is not set. |
|
|
63
|
+
| `selectedDate` | `string \| null` | | Highlighted day. |
|
|
64
|
+
| `markedDates` | `Record<string, { dots?: { color: string; key?: string }[] }>` | | Dots by day. |
|
|
65
|
+
| `onDayPress` | `(date: string) => void` | | Called with the pressed day. Days of the neighbouring months report too. |
|
|
66
|
+
| `onMonthChange` | `(month: string) => void` | | Called with the first day of the new month, `YYYY-MM-01`. |
|
|
67
|
+
| `firstDayOfWeek` | `0`–`6` | `0` | `0` is Sunday, `1` is Monday. |
|
|
68
|
+
| `minDate` / `maxDate` | `string` | | Days outside the range cannot be pressed, and months outside it cannot be reached. |
|
|
69
|
+
| `maxDots` | `number` | `3` | Most dots drawn under one day. |
|
|
70
|
+
| `showAdjacentDays` | `boolean` | `true` | Show days of the neighbouring months in the first and last weeks. |
|
|
71
|
+
| `monthNames` | `string[]` | English | Twelve names, January first. |
|
|
72
|
+
| `weekdayNames` | `string[]` | `S M T W T F S` | Seven labels, Sunday first whatever `firstDayOfWeek` is. |
|
|
73
|
+
| `previousMonthLabel` / `nextMonthLabel` | `string` | English | Screen reader labels of the arrows. |
|
|
74
|
+
| `theme` | `Partial<CalendarTheme>` | | Colours, corner radius and fonts. See below. |
|
|
75
|
+
| `style` | `ViewStyle` | | Style of the outer view: margins, shadow, border. |
|
|
76
|
+
| `testID` | `string` | `month-calendar` | Prefix of the test IDs: `-title`, `-previous`, `-next`, `-day-YYYY-MM-DD`. |
|
|
77
|
+
|
|
78
|
+
## Theme
|
|
79
|
+
|
|
80
|
+
Pass only what you want to change. `defaultTheme` is exported with the rest.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<MonthCalendar
|
|
84
|
+
theme={{
|
|
85
|
+
selectedDayBackgroundColor: '#0F766E',
|
|
86
|
+
todayTextColor: '#0F766E',
|
|
87
|
+
todayBackgroundColor: 'rgba(15, 118, 110, 0.1)',
|
|
88
|
+
arrowColor: '#0F766E',
|
|
89
|
+
dayFontFamily: 'Inter-Regular',
|
|
90
|
+
headerFontFamily: 'Inter-Bold',
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Keys: `backgroundColor`, `borderRadius`, `headerTextColor`, `headerBorderColor`, `arrowColor`, `arrowBackgroundColor`, `weekdayTextColor`, `dayTextColor`, `adjacentDayTextColor`, `disabledDayTextColor`, `todayTextColor`, `todayBackgroundColor`, `selectedDayTextColor`, `selectedDayBackgroundColor`, `selectedDotColor`, `headerFontFamily`, `weekdayFontFamily`, `dayFontFamily`.
|
|
96
|
+
|
|
97
|
+
## Date helpers
|
|
98
|
+
|
|
99
|
+
The helpers the calendar uses are exported, which is handy for loading a month of events:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { startOfMonth, endOfMonth, addMonths, buildMonthGrid, toDateString, todayString, isValidDate } from 'react-native-dot-calendar';
|
|
103
|
+
|
|
104
|
+
startOfMonth('2026-12-04'); // '2026-12-01'
|
|
105
|
+
endOfMonth('2026-12-04'); // '2026-12-31'
|
|
106
|
+
addMonths('2026-12-04', 1); // '2027-01-01'
|
|
107
|
+
buildMonthGrid('2026-12', 1); // weeks of { date, day, inMonth }, Monday first
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
All dates are in the device's time zone.
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT
|
|
Binary file
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { memo, useMemo, useState } from 'react';
|
|
4
|
+
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
|
+
import { addMonths, buildMonthGrid, endOfMonth, isValidDate, parseDate, startOfMonth, todayString } from "./dates.js";
|
|
6
|
+
import { defaultTheme } from "./theme.js";
|
|
7
|
+
|
|
8
|
+
/** Markings by day, keyed `YYYY-MM-DD`. */
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const DEFAULT_MONTH_NAMES = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
11
|
+
const DEFAULT_WEEKDAY_NAMES = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
|
|
12
|
+
const WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
13
|
+
const DEFAULT_MAX_DOTS = 3;
|
|
14
|
+
const ARROW_HIT_SLOP = 8;
|
|
15
|
+
const NO_DOTS = [];
|
|
16
|
+
const Arrow = ({
|
|
17
|
+
direction,
|
|
18
|
+
label,
|
|
19
|
+
disabled,
|
|
20
|
+
theme,
|
|
21
|
+
onPress,
|
|
22
|
+
testID
|
|
23
|
+
}) => /*#__PURE__*/_jsx(Pressable, {
|
|
24
|
+
accessibilityRole: "button",
|
|
25
|
+
accessibilityLabel: label,
|
|
26
|
+
accessibilityState: {
|
|
27
|
+
disabled
|
|
28
|
+
},
|
|
29
|
+
disabled: disabled,
|
|
30
|
+
hitSlop: ARROW_HIT_SLOP,
|
|
31
|
+
onPress: onPress,
|
|
32
|
+
style: [styles.arrow, {
|
|
33
|
+
backgroundColor: theme.arrowBackgroundColor
|
|
34
|
+
}, disabled && styles.arrowDisabled],
|
|
35
|
+
testID: testID,
|
|
36
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
37
|
+
style: [styles.chevron, direction === 'previous' ? styles.chevronPrevious : styles.chevronNext, {
|
|
38
|
+
borderColor: theme.arrowColor
|
|
39
|
+
}]
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
const dayTextColor = ({
|
|
43
|
+
day,
|
|
44
|
+
isToday,
|
|
45
|
+
isSelected,
|
|
46
|
+
isDisabled,
|
|
47
|
+
theme
|
|
48
|
+
}) => {
|
|
49
|
+
if (isSelected) {
|
|
50
|
+
return theme.selectedDayTextColor;
|
|
51
|
+
}
|
|
52
|
+
if (isDisabled) {
|
|
53
|
+
return theme.disabledDayTextColor;
|
|
54
|
+
}
|
|
55
|
+
if (isToday) {
|
|
56
|
+
return theme.todayTextColor;
|
|
57
|
+
}
|
|
58
|
+
return day.inMonth ? theme.dayTextColor : theme.adjacentDayTextColor;
|
|
59
|
+
};
|
|
60
|
+
const dayBackgroundColor = ({
|
|
61
|
+
isToday,
|
|
62
|
+
isSelected,
|
|
63
|
+
theme
|
|
64
|
+
}) => {
|
|
65
|
+
if (isSelected) {
|
|
66
|
+
return theme.selectedDayBackgroundColor;
|
|
67
|
+
}
|
|
68
|
+
return isToday ? theme.todayBackgroundColor : 'transparent';
|
|
69
|
+
};
|
|
70
|
+
const DayCell = /*#__PURE__*/memo(props => {
|
|
71
|
+
const {
|
|
72
|
+
day,
|
|
73
|
+
label,
|
|
74
|
+
isToday,
|
|
75
|
+
isSelected,
|
|
76
|
+
isDisabled,
|
|
77
|
+
dots,
|
|
78
|
+
theme,
|
|
79
|
+
onPress,
|
|
80
|
+
testID
|
|
81
|
+
} = props;
|
|
82
|
+
const emphasised = isSelected || isToday;
|
|
83
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
84
|
+
accessibilityRole: "button",
|
|
85
|
+
accessibilityLabel: label,
|
|
86
|
+
accessibilityState: {
|
|
87
|
+
selected: isSelected,
|
|
88
|
+
disabled: isDisabled
|
|
89
|
+
},
|
|
90
|
+
disabled: isDisabled || !onPress,
|
|
91
|
+
onPress: () => onPress?.(day.date),
|
|
92
|
+
style: styles.cell,
|
|
93
|
+
testID: testID,
|
|
94
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
95
|
+
style: [styles.dayCircle, {
|
|
96
|
+
backgroundColor: dayBackgroundColor(props)
|
|
97
|
+
}],
|
|
98
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
99
|
+
style: [styles.dayText, emphasised && styles.dayTextEmphasised, {
|
|
100
|
+
color: dayTextColor(props),
|
|
101
|
+
fontFamily: theme.dayFontFamily
|
|
102
|
+
}],
|
|
103
|
+
children: day.day
|
|
104
|
+
}), dots.length > 0 && /*#__PURE__*/_jsx(View, {
|
|
105
|
+
style: styles.dots,
|
|
106
|
+
children: dots.map((dot, index) => /*#__PURE__*/_jsx(View, {
|
|
107
|
+
style: [styles.dot, {
|
|
108
|
+
backgroundColor: isSelected ? theme.selectedDotColor : dot.color
|
|
109
|
+
}]
|
|
110
|
+
}, dot.key ?? index))
|
|
111
|
+
})]
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
DayCell.displayName = 'DayCell';
|
|
116
|
+
const resolveMonth = (month, fallback) => month !== undefined && isValidDate(month) ? startOfMonth(month) : fallback;
|
|
117
|
+
export const MonthCalendar = ({
|
|
118
|
+
month,
|
|
119
|
+
initialMonth,
|
|
120
|
+
selectedDate,
|
|
121
|
+
markedDates,
|
|
122
|
+
onDayPress,
|
|
123
|
+
onMonthChange,
|
|
124
|
+
firstDayOfWeek = 0,
|
|
125
|
+
minDate,
|
|
126
|
+
maxDate,
|
|
127
|
+
maxDots = DEFAULT_MAX_DOTS,
|
|
128
|
+
showAdjacentDays = true,
|
|
129
|
+
monthNames = DEFAULT_MONTH_NAMES,
|
|
130
|
+
weekdayNames = DEFAULT_WEEKDAY_NAMES,
|
|
131
|
+
previousMonthLabel = 'Previous month',
|
|
132
|
+
nextMonthLabel = 'Next month',
|
|
133
|
+
theme: themeOverrides,
|
|
134
|
+
style,
|
|
135
|
+
testID = 'month-calendar'
|
|
136
|
+
}) => {
|
|
137
|
+
const today = todayString();
|
|
138
|
+
const [ownMonth, setOwnMonth] = useState(() => resolveMonth(initialMonth, startOfMonth(today)));
|
|
139
|
+
const visibleMonth = resolveMonth(month, ownMonth);
|
|
140
|
+
const theme = useMemo(() => ({
|
|
141
|
+
...defaultTheme,
|
|
142
|
+
...themeOverrides
|
|
143
|
+
}), [themeOverrides]);
|
|
144
|
+
const weeks = useMemo(() => buildMonthGrid(visibleMonth, firstDayOfWeek), [visibleMonth, firstDayOfWeek]);
|
|
145
|
+
|
|
146
|
+
// Zero-padded YYYY-MM-DD strings sort the same way the dates do.
|
|
147
|
+
const lowerBound = isValidDate(minDate) ? minDate : undefined;
|
|
148
|
+
const upperBound = isValidDate(maxDate) ? maxDate : undefined;
|
|
149
|
+
const isOutOfRange = date => lowerBound !== undefined && date < lowerBound || upperBound !== undefined && date > upperBound;
|
|
150
|
+
const goToMonth = offset => {
|
|
151
|
+
const next = addMonths(visibleMonth, offset);
|
|
152
|
+
if (month === undefined) {
|
|
153
|
+
setOwnMonth(next);
|
|
154
|
+
}
|
|
155
|
+
onMonthChange?.(next);
|
|
156
|
+
};
|
|
157
|
+
const dayLabel = date => {
|
|
158
|
+
const parts = parseDate(date);
|
|
159
|
+
return parts ? `${monthNames[parts.month]} ${parts.day}, ${parts.year}` : date;
|
|
160
|
+
};
|
|
161
|
+
const visible = parseDate(visibleMonth);
|
|
162
|
+
const title = visible ? `${monthNames[visible.month]} ${visible.year}` : '';
|
|
163
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
164
|
+
style: [styles.container, {
|
|
165
|
+
backgroundColor: theme.backgroundColor,
|
|
166
|
+
borderRadius: theme.borderRadius
|
|
167
|
+
}, style],
|
|
168
|
+
testID: testID,
|
|
169
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
170
|
+
style: [styles.header, {
|
|
171
|
+
borderBottomColor: theme.headerBorderColor
|
|
172
|
+
}],
|
|
173
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
174
|
+
accessibilityRole: "header",
|
|
175
|
+
style: [styles.title, {
|
|
176
|
+
color: theme.headerTextColor,
|
|
177
|
+
fontFamily: theme.headerFontFamily
|
|
178
|
+
}],
|
|
179
|
+
testID: `${testID}-title`,
|
|
180
|
+
children: title
|
|
181
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
182
|
+
style: styles.arrows,
|
|
183
|
+
children: [/*#__PURE__*/_jsx(Arrow, {
|
|
184
|
+
direction: "previous",
|
|
185
|
+
label: previousMonthLabel,
|
|
186
|
+
disabled: isOutOfRange(endOfMonth(addMonths(visibleMonth, -1))),
|
|
187
|
+
theme: theme,
|
|
188
|
+
onPress: () => goToMonth(-1),
|
|
189
|
+
testID: `${testID}-previous`
|
|
190
|
+
}), /*#__PURE__*/_jsx(Arrow, {
|
|
191
|
+
direction: "next",
|
|
192
|
+
label: nextMonthLabel,
|
|
193
|
+
disabled: isOutOfRange(addMonths(visibleMonth, 1)),
|
|
194
|
+
theme: theme,
|
|
195
|
+
onPress: () => goToMonth(1),
|
|
196
|
+
testID: `${testID}-next`
|
|
197
|
+
})]
|
|
198
|
+
})]
|
|
199
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
200
|
+
style: styles.weekdays,
|
|
201
|
+
accessibilityElementsHidden: true,
|
|
202
|
+
importantForAccessibility: "no-hide-descendants",
|
|
203
|
+
children: WEEKDAYS.map(offset => {
|
|
204
|
+
const weekday = (firstDayOfWeek + offset) % WEEKDAYS.length;
|
|
205
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
206
|
+
style: [styles.weekday, {
|
|
207
|
+
color: theme.weekdayTextColor,
|
|
208
|
+
fontFamily: theme.weekdayFontFamily
|
|
209
|
+
}],
|
|
210
|
+
children: weekdayNames[weekday]
|
|
211
|
+
}, weekday);
|
|
212
|
+
})
|
|
213
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
214
|
+
style: styles.grid,
|
|
215
|
+
children: weeks.map(week => /*#__PURE__*/_jsx(View, {
|
|
216
|
+
style: styles.week,
|
|
217
|
+
children: week.map(day => day.inMonth || showAdjacentDays ? /*#__PURE__*/_jsx(DayCell, {
|
|
218
|
+
day: day,
|
|
219
|
+
label: dayLabel(day.date),
|
|
220
|
+
isToday: day.date === today,
|
|
221
|
+
isSelected: day.date === selectedDate,
|
|
222
|
+
isDisabled: isOutOfRange(day.date),
|
|
223
|
+
dots: markedDates?.[day.date]?.dots?.slice(0, maxDots) ?? NO_DOTS,
|
|
224
|
+
theme: theme,
|
|
225
|
+
onPress: onDayPress,
|
|
226
|
+
testID: `${testID}-day-${day.date}`
|
|
227
|
+
}, day.date) : /*#__PURE__*/_jsx(View, {
|
|
228
|
+
style: styles.cell
|
|
229
|
+
}, day.date))
|
|
230
|
+
}, week[0].date))
|
|
231
|
+
})]
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
const styles = StyleSheet.create({
|
|
235
|
+
container: {
|
|
236
|
+
overflow: 'hidden'
|
|
237
|
+
},
|
|
238
|
+
header: {
|
|
239
|
+
flexDirection: 'row',
|
|
240
|
+
justifyContent: 'space-between',
|
|
241
|
+
alignItems: 'center',
|
|
242
|
+
paddingHorizontal: 16,
|
|
243
|
+
paddingVertical: 14,
|
|
244
|
+
borderBottomWidth: 1
|
|
245
|
+
},
|
|
246
|
+
title: {
|
|
247
|
+
fontSize: 16,
|
|
248
|
+
fontWeight: '700'
|
|
249
|
+
},
|
|
250
|
+
arrows: {
|
|
251
|
+
flexDirection: 'row',
|
|
252
|
+
alignItems: 'center',
|
|
253
|
+
gap: 12
|
|
254
|
+
},
|
|
255
|
+
arrow: {
|
|
256
|
+
width: 32,
|
|
257
|
+
height: 32,
|
|
258
|
+
borderRadius: 16,
|
|
259
|
+
alignItems: 'center',
|
|
260
|
+
justifyContent: 'center'
|
|
261
|
+
},
|
|
262
|
+
arrowDisabled: {
|
|
263
|
+
opacity: 0.4
|
|
264
|
+
},
|
|
265
|
+
chevron: {
|
|
266
|
+
width: 8,
|
|
267
|
+
height: 8,
|
|
268
|
+
borderTopWidth: 2,
|
|
269
|
+
borderLeftWidth: 2
|
|
270
|
+
},
|
|
271
|
+
chevronPrevious: {
|
|
272
|
+
marginLeft: 3,
|
|
273
|
+
transform: [{
|
|
274
|
+
rotate: '-45deg'
|
|
275
|
+
}]
|
|
276
|
+
},
|
|
277
|
+
chevronNext: {
|
|
278
|
+
marginRight: 3,
|
|
279
|
+
transform: [{
|
|
280
|
+
rotate: '135deg'
|
|
281
|
+
}]
|
|
282
|
+
},
|
|
283
|
+
weekdays: {
|
|
284
|
+
flexDirection: 'row',
|
|
285
|
+
paddingHorizontal: 8,
|
|
286
|
+
paddingTop: 12,
|
|
287
|
+
paddingBottom: 8
|
|
288
|
+
},
|
|
289
|
+
weekday: {
|
|
290
|
+
flex: 1,
|
|
291
|
+
textAlign: 'center',
|
|
292
|
+
fontSize: 12,
|
|
293
|
+
fontWeight: '500'
|
|
294
|
+
},
|
|
295
|
+
grid: {
|
|
296
|
+
paddingHorizontal: 8,
|
|
297
|
+
paddingBottom: 12
|
|
298
|
+
},
|
|
299
|
+
week: {
|
|
300
|
+
flexDirection: 'row'
|
|
301
|
+
},
|
|
302
|
+
cell: {
|
|
303
|
+
flex: 1,
|
|
304
|
+
height: 48,
|
|
305
|
+
alignItems: 'center',
|
|
306
|
+
justifyContent: 'center',
|
|
307
|
+
marginBottom: 4
|
|
308
|
+
},
|
|
309
|
+
dayCircle: {
|
|
310
|
+
width: 36,
|
|
311
|
+
height: 36,
|
|
312
|
+
borderRadius: 18,
|
|
313
|
+
alignItems: 'center',
|
|
314
|
+
justifyContent: 'center'
|
|
315
|
+
},
|
|
316
|
+
dayText: {
|
|
317
|
+
fontSize: 15,
|
|
318
|
+
fontWeight: '400'
|
|
319
|
+
},
|
|
320
|
+
dayTextEmphasised: {
|
|
321
|
+
fontWeight: '600'
|
|
322
|
+
},
|
|
323
|
+
dots: {
|
|
324
|
+
flexDirection: 'row',
|
|
325
|
+
gap: 3,
|
|
326
|
+
marginTop: 1
|
|
327
|
+
},
|
|
328
|
+
dot: {
|
|
329
|
+
width: 6,
|
|
330
|
+
height: 6,
|
|
331
|
+
borderRadius: 3
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
//# sourceMappingURL=MonthCalendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","memo","useMemo","useState","Pressable","StyleSheet","Text","View","addMonths","buildMonthGrid","endOfMonth","isValidDate","parseDate","startOfMonth","todayString","defaultTheme","jsx","_jsx","jsxs","_jsxs","DEFAULT_MONTH_NAMES","DEFAULT_WEEKDAY_NAMES","WEEKDAYS","DEFAULT_MAX_DOTS","ARROW_HIT_SLOP","NO_DOTS","Arrow","direction","label","disabled","theme","onPress","testID","accessibilityRole","accessibilityLabel","accessibilityState","hitSlop","style","styles","arrow","backgroundColor","arrowBackgroundColor","arrowDisabled","children","chevron","chevronPrevious","chevronNext","borderColor","arrowColor","dayTextColor","day","isToday","isSelected","isDisabled","selectedDayTextColor","disabledDayTextColor","todayTextColor","inMonth","adjacentDayTextColor","dayBackgroundColor","selectedDayBackgroundColor","todayBackgroundColor","DayCell","props","dots","emphasised","selected","date","cell","dayCircle","dayText","dayTextEmphasised","color","fontFamily","dayFontFamily","length","map","dot","index","selectedDotColor","key","displayName","resolveMonth","month","fallback","undefined","MonthCalendar","initialMonth","selectedDate","markedDates","onDayPress","onMonthChange","firstDayOfWeek","minDate","maxDate","maxDots","showAdjacentDays","monthNames","weekdayNames","previousMonthLabel","nextMonthLabel","themeOverrides","today","ownMonth","setOwnMonth","visibleMonth","weeks","lowerBound","upperBound","isOutOfRange","goToMonth","offset","next","dayLabel","parts","year","visible","title","container","borderRadius","header","borderBottomColor","headerBorderColor","headerTextColor","headerFontFamily","arrows","weekdays","accessibilityElementsHidden","importantForAccessibility","weekday","weekdayTextColor","weekdayFontFamily","grid","week","slice","create","overflow","flexDirection","justifyContent","alignItems","paddingHorizontal","paddingVertical","borderBottomWidth","fontSize","fontWeight","gap","width","height","opacity","borderTopWidth","borderLeftWidth","marginLeft","transform","rotate","marginRight","paddingTop","paddingBottom","flex","textAlign","marginBottom","marginTop"],"sourceRoot":"../../src","sources":["MonthCalendar.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,IAAI,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACtD,SAASC,SAAS,EAAEC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAEhE,SAAS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,iBAAiB,EAAE,CAAC;IACpBe,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE;EACjB,CAAC;EACD3B,OAAO,EAAE;IACP4B,IAAI,EAAE,CAAC;IACPC,SAAS,EAAE,QAAQ;IACnBf,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDZ,IAAI,EAAE;IACJQ,iBAAiB,EAAE,CAAC;IACpBgB,aAAa,EAAE;EACjB,CAAC;EACDvB,IAAI,EAAE;IACJI,aAAa,EAAE;EACjB,CAAC;EACDrE,IAAI,EAAE;IACJyF,IAAI,EAAE,CAAC;IACPV,MAAM,EAAE,EAAE;IACVR,UAAU,EAAE,QAAQ;IACpBD,cAAc,EAAE,QAAQ;IACxBqB,YAAY,EAAE;EAChB,CAAC;EACD1F,SAAS,EAAE;IACT6E,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACV5B,YAAY,EAAE,EAAE;IAChBoB,UAAU,EAAE,QAAQ;IACpBD,cAAc,EAAE;EAClB,CAAC;EACDpE,OAAO,EAAE;IACPyE,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDzE,iBAAiB,EAAE;IACjByE,UAAU,EAAE;EACd,CAAC;EACDhF,IAAI,EAAE;IACJyE,aAAa,EAAE,KAAK;IACpBQ,GAAG,EAAE,CAAC;IACNe,SAAS,EAAE;EACb,CAAC;EACDnF,GAAG,EAAE;IACHqE,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACT5B,YAAY,EAAE;EAChB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const DAYS_IN_WEEK = 7;
|
|
4
|
+
const DATE_PATTERN = /^(\d{4})-(\d{2})(?:-(\d{2}))?$/;
|
|
5
|
+
const pad = (value, length) => String(value).padStart(length, '0');
|
|
6
|
+
|
|
7
|
+
// Built with setFullYear because `new Date(year, ...)` reads years 0-99 as 1900-1999.
|
|
8
|
+
const localDate = (year, month, day) => {
|
|
9
|
+
const date = new Date(2000, 0, 1);
|
|
10
|
+
date.setFullYear(year, month, day);
|
|
11
|
+
return date;
|
|
12
|
+
};
|
|
13
|
+
const daysInMonth = (year, month) => localDate(year, month + 1, 0).getDate();
|
|
14
|
+
|
|
15
|
+
/** Formats a `Date` as `YYYY-MM-DD` in the device's time zone. */
|
|
16
|
+
export const toDateString = date => `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1, 2)}-${pad(date.getDate(), 2)}`;
|
|
17
|
+
|
|
18
|
+
/** Today as `YYYY-MM-DD` in the device's time zone. */
|
|
19
|
+
export const todayString = () => toDateString(new Date());
|
|
20
|
+
|
|
21
|
+
/** Reads `YYYY-MM-DD` or `YYYY-MM` (day defaults to 1). Returns null when it is not a real date. */
|
|
22
|
+
export const parseDate = value => {
|
|
23
|
+
const match = DATE_PATTERN.exec(value ?? '');
|
|
24
|
+
if (!match) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const year = Number(match[1]);
|
|
28
|
+
const month = Number(match[2]) - 1;
|
|
29
|
+
const day = match[3] === undefined ? 1 : Number(match[3]);
|
|
30
|
+
if (month < 0 || month > 11 || day < 1 || day > daysInMonth(year, month)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
year,
|
|
35
|
+
month,
|
|
36
|
+
day
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export const isValidDate = value => parseDate(value) !== null;
|
|
40
|
+
const requireDate = value => {
|
|
41
|
+
const parts = parseDate(value);
|
|
42
|
+
if (!parts) {
|
|
43
|
+
throw new RangeError(`Expected a date as YYYY-MM-DD or YYYY-MM, got "${value}"`);
|
|
44
|
+
}
|
|
45
|
+
return parts;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** First day of the month that holds `value`, as `YYYY-MM-01`. */
|
|
49
|
+
export const startOfMonth = value => {
|
|
50
|
+
const {
|
|
51
|
+
year,
|
|
52
|
+
month
|
|
53
|
+
} = requireDate(value);
|
|
54
|
+
return toDateString(localDate(year, month, 1));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Last day of the month that holds `value`. */
|
|
58
|
+
export const endOfMonth = value => {
|
|
59
|
+
const {
|
|
60
|
+
year,
|
|
61
|
+
month
|
|
62
|
+
} = requireDate(value);
|
|
63
|
+
return toDateString(localDate(year, month + 1, 0));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** First day of the month `count` months away from the month that holds `value`. */
|
|
67
|
+
export const addMonths = (value, count) => {
|
|
68
|
+
const {
|
|
69
|
+
year,
|
|
70
|
+
month
|
|
71
|
+
} = requireDate(value);
|
|
72
|
+
return toDateString(localDate(year, month + count, 1));
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The weeks to draw for a month. Every week has seven days, so the first and
|
|
77
|
+
* last weeks are filled with days from the neighbouring months.
|
|
78
|
+
*/
|
|
79
|
+
export const buildMonthGrid = (value, firstDayOfWeek = 0) => {
|
|
80
|
+
const {
|
|
81
|
+
year,
|
|
82
|
+
month
|
|
83
|
+
} = requireDate(value);
|
|
84
|
+
const leading = (localDate(year, month, 1).getDay() - firstDayOfWeek + DAYS_IN_WEEK) % DAYS_IN_WEEK;
|
|
85
|
+
const weekCount = Math.ceil((leading + daysInMonth(year, month)) / DAYS_IN_WEEK);
|
|
86
|
+
return Array.from({
|
|
87
|
+
length: weekCount
|
|
88
|
+
}, (_week, weekIndex) => Array.from({
|
|
89
|
+
length: DAYS_IN_WEEK
|
|
90
|
+
}, (_day, dayIndex) => {
|
|
91
|
+
const date = localDate(year, month, weekIndex * DAYS_IN_WEEK + dayIndex + 1 - leading);
|
|
92
|
+
return {
|
|
93
|
+
date: toDateString(date),
|
|
94
|
+
day: date.getDate(),
|
|
95
|
+
inMonth: date.getMonth() === month
|
|
96
|
+
};
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DAYS_IN_WEEK","DATE_PATTERN","pad","value","length","String","padStart","localDate","year","month","day","date","Date","setFullYear","daysInMonth","getDate","toDateString","getFullYear","getMonth","todayString","parseDate","match","exec","Number","undefined","isValidDate","requireDate","parts","RangeError","startOfMonth","endOfMonth","addMonths","count","buildMonthGrid","firstDayOfWeek","leading","getDay","weekCount","Math","ceil","Array","from","_week","weekIndex","_day","dayIndex","inMonth"],"sourceRoot":"../../src","sources":["dates.ts"],"mappings":";;AAkBA,MAAMA,YAAY,GAAG,CAAC;AACtB,MAAMC,YAAY,GAAG,gCAAgC;AAErD,MAAMC,GAAG,GAAGA,CAACC,KAAa,EAAEC,MAAc,KAAKC,MAAM,CAACF,KAAK,CAAC,CAACG,QAAQ,CAACF,MAAM,EAAE,GAAG,CAAC;;AAElF;AACA,MAAMG,SAAS,GAAGA,CAACC,IAAY,EAAEC,KAAa,EAAEC,GAAW,KAAK;EAC9D,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;EACjCD,IAAI,CAACE,WAAW,CAACL,IAAI,EAAEC,KAAK,EAAEC,GAAG,CAAC;EAClC,OAAOC,IAAI;AACb,CAAC;AAED,MAAMG,WAAW,GAAGA,CAACN,IAAY,EAAEC,KAAa,KAAKF,SAAS,CAACC,IAAI,EAAEC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAACM,OAAO,CAAC,CAAC;;AAE5F;AACA,OAAO,MAAMC,YAAY,GAAIL,IAAU,IACrC,GAAGT,GAAG,CAACS,IAAI,CAACM,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,IAAIf,GAAG,CAACS,IAAI,CAACO,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAIhB,GAAG,CAACS,IAAI,CAACI,OAAO,CAAC,CAAC,EAAE,CAAC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Aa,CAAC,EAAE,CAAC4C,IAAI,EAAEC,QAAQ,KAAK;IACvD,MAAMlC,IAAI,GAAGJ,SAAS,CAACC,IAAI,EAAEC,KAAK,EAAEkC,SAAS,GAAG3C,YAAY,GAAG6C,QAAQ,GAAG,CAAC,GAAGV,OAAO,CAAC;IACtF,OAAO;MACLxB,IAAI,EAAEK,YAAY,CAACL,IAAI,CAAC;MACxBD,GAAG,EAAEC,IAAI,CAACI,OAAO,CAAC,CAAC;MACnB+B,OAAO,EAAEnC,IAAI,CAACO,QAAQ,CAAC,CAAC,KAAKT;IAC/B,CAAC;EACH,CAAC,CACH,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { MonthCalendar } from "./MonthCalendar.js";
|
|
4
|
+
export { defaultTheme } from "./theme.js";
|
|
5
|
+
export { addMonths, buildMonthGrid, endOfMonth, isValidDate, startOfMonth, toDateString, todayString } from "./dates.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MonthCalendar","defaultTheme","addMonths","buildMonthGrid","endOfMonth","isValidDate","startOfMonth","toDateString","todayString"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,oBAAiB;AAE/C,SAASC,YAAY,QAAQ,YAAS;AAEtC,SACEC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,WAAW,QACN,YAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const defaultTheme = {
|
|
4
|
+
backgroundColor: '#FFFFFF',
|
|
5
|
+
borderRadius: 12,
|
|
6
|
+
headerTextColor: '#1A1C1E',
|
|
7
|
+
headerBorderColor: '#F0F2F5',
|
|
8
|
+
arrowColor: '#3B82F6',
|
|
9
|
+
arrowBackgroundColor: '#F5F7F9',
|
|
10
|
+
weekdayTextColor: '#6B7280',
|
|
11
|
+
dayTextColor: '#1A1C1E',
|
|
12
|
+
adjacentDayTextColor: '#D1D5DB',
|
|
13
|
+
disabledDayTextColor: '#D1D5DB',
|
|
14
|
+
todayTextColor: '#3B82F6',
|
|
15
|
+
todayBackgroundColor: 'rgba(59, 130, 246, 0.1)',
|
|
16
|
+
selectedDayTextColor: '#FFFFFF',
|
|
17
|
+
selectedDayBackgroundColor: '#3B82F6',
|
|
18
|
+
selectedDotColor: '#FFFFFF'
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultTheme","backgroundColor","borderRadius","headerTextColor","headerBorderColor","arrowColor","arrowBackgroundColor","weekdayTextColor","dayTextColor","adjacentDayTextColor","disabledDayTextColor","todayTextColor","todayBackgroundColor","selectedDayTextColor","selectedDayBackgroundColor","selectedDotColor"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;AAwBA,OAAO,MAAMA,YAA2B,GAAG;EACzCC,eAAe,EAAE,SAAS;EAC1BC,YAAY,EAAE,EAAE;EAChBC,eAAe,EAAE,SAAS;EAC1BC,iBAAiB,EAAE,SAAS;EAC5BC,UAAU,EAAE,SAAS;EACrBC,oBAAoB,EAAE,SAAS;EAC/BC,gBAAgB,EAAE,SAAS;EAC3BC,YAAY,EAAE,SAAS;EACvBC,oBAAoB,EAAE,SAAS;EAC/BC,oBAAoB,EAAE,SAAS;EAC/BC,cAAc,EAAE,SAAS;EACzBC,oBAAoB,EAAE,yBAAyB;EAC/CC,oBAAoB,EAAE,SAAS;EAC/BC,0BAA0B,EAAE,SAAS;EACrCC,gBAAgB,EAAE;AACpB,CAAC","ignoreList":[]}
|