Skip to content

Commit d4bfc79

Browse files
committed
Merge branch 'master' of github.com:wix/react-native-calendars into release
2 parents bb3ec4e + eb335eb commit d4bfc79

File tree

10 files changed

+25
-21
lines changed

10 files changed

+25
-21
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
agents:
2-
queue: mbms
31
env:
42
LC_ALL: 'en_US'
53
steps:
@@ -34,4 +32,4 @@ steps:
3432
npm run build:ts
3533
if [[ $BUILDKITE_PULL_REQUEST == 'false' ]];then
3634
npm run release
37-
fi
35+
fi

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ module.exports = {
2929
'react/jsx-uses-vars': 2,
3030
'@typescript-eslint/no-use-before-define': 0,
3131
'@typescript-eslint/no-var-requires': 0,
32-
'@typescript-eslint/explicit-function-return-type': 0
32+
'@typescript-eslint/explicit-function-return-type': 0,
33+
'@typescript-eslint/ban-types': 0,
34+
'@typescript-eslint/ban-ts-comment': 1
3335
}
3436
};

example/src/mocks/theme.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Platform} from "react-native";
1+
import {Platform} from 'react-native';
22

33
export const themeColor = '#00AAAF';
44
export const lightThemeColor = '#f2f7f7';
@@ -16,18 +16,18 @@ export function getTheme() {
1616
monthTextColor: 'black',
1717
textMonthFontSize: 16,
1818
textMonthFontFamily: 'HelveticaNeue',
19-
textMonthFontWeight: 'bold' as 'bold',
19+
textMonthFontWeight: 'bold' as const,
2020
// day names
2121
textSectionTitleColor: 'black',
2222
textDayHeaderFontSize: 12,
2323
textDayHeaderFontFamily: 'HelveticaNeue',
24-
textDayHeaderFontWeight: 'normal' as 'normal',
24+
textDayHeaderFontWeight: 'normal' as const,
2525
// dates
2626
dayTextColor: themeColor,
2727
todayTextColor: '#af0078',
2828
textDayFontSize: 18,
2929
textDayFontFamily: 'HelveticaNeue',
30-
textDayFontWeight: '500' as '500',
30+
textDayFontWeight: '500' as const,
3131
textDayStyle: {marginTop: Platform.OS === 'android' ? 2 : 4},
3232
// selected date
3333
selectedDayBackgroundColor: themeColor,

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"@types/react": "^17.0.44",
5353
"@types/react-native": "^0.64.19",
5454
"@types/xdate": "^0.8.32",
55-
"@typescript-eslint/eslint-plugin": "^2.13.0",
56-
"@typescript-eslint/parser": "^2.13.0",
55+
"@typescript-eslint/eslint-plugin": "^4.0.0",
56+
"@typescript-eslint/parser": "^4.0.0",
5757
"@welldone-software/why-did-you-render": "^6.0.3",
5858
"babel-eslint": "^10.1.0",
5959
"babel-jest": "^26.6.3",
@@ -82,7 +82,7 @@
8282
"typescript": "^4.3.3"
8383
},
8484
"optionalDependencies": {
85-
"moment": "^2.24.0"
85+
"moment": "^2.29.4"
8686
},
8787
"jest": {
8888
"preset": "react-native",

src/calendar-list/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {xdateToData, parseDate, toMarkingFormat} from '../interface';
1010
import {page, sameDate, sameMonth} from '../dateutils';
1111
import constants from '../commons/constants';
1212
import {useDidUpdate} from '../hooks';
13+
import {ContextProp} from '../types';
1314
import styleConstructor from './style';
1415
import Calendar, {CalendarProps} from '../calendar';
1516
import CalendarListItem from './item';
@@ -51,7 +52,7 @@ export interface CalendarListImperativeMethods {
5152
* @example: https://github.com/wix/react-native-calendars/blob/master/example/src/screens/calendarsList.js
5253
* @gif: https://github.com/wix/react-native-calendars/blob/master/demo/assets/calendar-list.gif
5354
*/
54-
const CalendarList = (props: CalendarListProps, ref: any) => {
55+
const CalendarList = (props: CalendarListProps & ContextProp, ref: any) => {
5556
useImperativeHandle(ref, () => ({
5657
scrollToDay: (date: XDate | string, offset: number, animated: boolean) => {
5758
scrollToDay(date, offset, animated);

src/calendar-list/item.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import XDate from 'xdate';
2-
import React, {useRef, useMemo, useContext, useCallback} from 'react';
2+
import React, {useRef, useMemo, useCallback} from 'react';
33
import {Text} from 'react-native';
44
import {Theme} from '../types';
55
import {toMarkingFormat} from '../interface';
66
import {extractCalendarProps} from '../componentUpdater';
77
import styleConstructor from './style';
88
import Calendar, {CalendarProps} from '../calendar';
9-
import CalendarContext from '../expandableCalendar/Context';
109

1110
export type CalendarListItemProps = CalendarProps & {
1211
item: any;
@@ -32,7 +31,6 @@ const CalendarListItem = React.memo((props: CalendarListItemProps) => {
3231
onPressArrowRight,
3332
visible
3433
} = props;
35-
const context = useContext(CalendarContext);
3634

3735
const style = useRef(styleConstructor(theme));
3836

@@ -100,7 +98,6 @@ const CalendarListItem = React.memo((props: CalendarListItemProps) => {
10098
disableMonthChange
10199
onPressArrowLeft={horizontal ? _onPressArrowLeft : onPressArrowLeft}
102100
onPressArrowRight={horizontal ? _onPressArrowRight : onPressArrowRight}
103-
context={context} // ???
104101
/>
105102
);
106103
});

src/calendar/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import XDate from 'xdate';
3-
3+
import isEmpty from 'lodash/isEmpty';
44
import React, {useRef, useState, useEffect, useCallback, useMemo} from 'react';
55
import {View, ViewStyle, StyleProp} from 'react-native';
66
// @ts-expect-error
@@ -11,7 +11,7 @@ import {page, isGTE, isLTE, sameMonth} from '../dateutils';
1111
import {xdateToData, parseDate, toMarkingFormat} from '../interface';
1212
import {getState} from '../day-state-manager';
1313
import {extractHeaderProps, extractDayProps} from '../componentUpdater';
14-
import {DateData, Theme, MarkedDates} from '../types';
14+
import {DateData, Theme, MarkedDates, ContextProp} from '../types';
1515
import {useDidUpdate} from '../hooks';
1616
import styleConstructor from './style';
1717
import CalendarHeader, {CalendarHeaderProps} from './header';
@@ -70,7 +70,7 @@ export interface CalendarProps extends CalendarHeaderProps, DayProps {
7070
* @example: https://github.com/wix/react-native-calendars/blob/master/example/src/screens/calendars.js
7171
* @gif: https://github.com/wix/react-native-calendars/blob/master/demo/assets/calendar.gif
7272
*/
73-
const Calendar = (props: CalendarProps) => {
73+
const Calendar = (props: CalendarProps & ContextProp) => {
7474
const {
7575
initialDate,
7676
current,
@@ -198,14 +198,15 @@ const Calendar = (props: CalendarProps) => {
198198
}
199199

200200
const dateString = toMarkingFormat(day);
201+
const isControlled = isEmpty(props.context);
201202

202203
return (
203204
<View style={style.current.dayContainer} key={id}>
204205
<Day
205206
{...dayProps}
206207
testID={`${testID}.day_${dateString}`}
207208
date={dateString}
208-
state={getState(day, currentMonth, props)}
209+
state={getState(day, currentMonth, props, isControlled)}
209210
marking={markedDates?.[dateString]}
210211
onPress={_onDayPress}
211212
onLongPress={onLongPressDay}

src/expandableCalendar/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
583583
numberOfDays={numberOfDays}
584584
headerStyle={_headerStyle}
585585
timelineLeftInset={timelineLeftInset}
586+
context={useContext(Context)}
586587
/>
587588
);
588589
};

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import {ViewStyle, TextStyle} from 'react-native';
22
import {MarkingProps} from './calendar/day/marking';
3+
import {CalendarContextProps} from './expandableCalendar/Context';
34

5+
export type ContextProp = {
6+
context?: CalendarContextProps;
7+
}
48
export type MarkingTypes = 'dot' | 'multi-dot' | 'period' | 'multi-period' | 'custom';
59
export type MarkedDates = {
610
[key: string]: MarkingProps;

src/utils/__tests__/Playground.perf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {measurePerformance} from 'reassure';
3-
import {Calendar, CalendarList} from '../../index';
3+
import {Calendar, CalendarList, ExpandableCalendar} from '../../index';
44

55
const INITIAL_DATE = '2022-07-07';
66

0 commit comments

Comments
 (0)