diff --git a/.eslintrc.js b/.eslintrc.js index 846d63f500..120c656787 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,7 +10,7 @@ module.exports = { describe: true }, extends: ['eslint:recommended'], - parser: 'babel-eslint', + parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true, @@ -18,7 +18,7 @@ module.exports = { }, sourceType: 'module' }, - plugins: ['react', 'react-native', 'jest'], + plugins: ['react', 'react-native', 'jest', '@typescript-eslint'], rules: { 'react-native/no-inline-styles': 1, 'linebreak-style': ['error', 'unix'], diff --git a/CHANGELOG.md b/CHANGELOG.md index 94b8e441d1..48cd272ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -702,3 +702,20 @@ - TS - Fix build process (PR #1545). - ExpandableCalendar - fix arrow press callbacks (PR #1489). - README & ISSUE_TEMPLATE - edit. + + +## [1.1265.0] - 2021-8-23 + +## Changed +- Change import to require - solved "Cannot assign to read only property 'exports' of object '#'" (PR #1553). +- TS migration for all components. +- Upgrading to react-native 0.64.2. + +## Added +- AgendaList - support offset scroll to section (PR #1526). +- AgendaList - allow passing 'onScrollToIndexFailed' (PR #1594). +- Day - support 'inactive' state and add 'disableAllTouchEventsForInactiveDays' prop (PR #1596). + +## Fixed +- ExpandableCalendar - 'onDayPress' not called (PR #1584). +- Fixed issue with 'dateutils' export (PR #1548). diff --git a/_editorconfig b/_editorconfig new file mode 100644 index 0000000000..7c286132fe --- /dev/null +++ b/_editorconfig @@ -0,0 +1,3 @@ +# Windows files +[*.bat] +end_of_line = crlf diff --git a/android/app/build.gradle b/android/app/build.gradle index 38b2caa588..dabbb7af8b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -16,9 +16,12 @@ def jscFlavor = 'org.webkit:android-jsc:+' def enableHermes = project.ext.react.get("enableHermes", false) android { + ndkVersion rootProject.ext.ndkVersion + compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -65,11 +68,12 @@ android { variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html + // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = - versionCodes.get(abi) * 1048576 + defaultConfig.versionCode + defaultConfig.versionCode * 1000 + versionCodes.get(abi) } } } diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index fa26aa56e1..b2f3ad9fce 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -4,5 +4,10 @@ - + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 9f42d5c461..a5510c469a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -21,7 +21,5 @@ - - diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 62fe59fa48..9fab0be743 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ - diff --git a/android/build.gradle b/android/build.gradle index f7c9df5bcb..86a1d881dc 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,10 +2,11 @@ buildscript { ext { - buildToolsVersion = "29.0.2" - minSdkVersion = 19 + buildToolsVersion = "29.0.3" + minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 + ndkVersion = "20.1.5948944" supportLibVersion = "29.0.0" RNNKotlinVersion = "1.3.72" } @@ -16,7 +17,7 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:3.5.3") + classpath("com.android.tools.build:gradle:4.1.0") classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/android/gradle.properties b/android/gradle.properties index 8b3ac93251..afe59c01dc 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -20,3 +20,6 @@ android.useDeprecatedNdk=true android.useAndroidX=true android.enableJetifier=true + +# Version of flipper SDK to use with React Native +FLIPPER_VERSION=0.75.1 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 7c18f286d6..f014ae30aa 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Wed Mar 27 10:33:44 IST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew index 77c906c272..305a24954a 100755 --- a/android/gradlew +++ b/android/gradlew @@ -83,6 +83,7 @@ cd "$SAVED" >&- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -130,6 +131,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/android/gradlew.bat b/android/gradlew.bat index 4cea078860..b9dd3fc046 100644 --- a/android/gradlew.bat +++ b/android/gradlew.bat @@ -43,7 +43,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -57,7 +57,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -67,21 +67,9 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants -if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* goto execute :4NT_args @@ -93,8 +81,9 @@ set CMD_LINE_ARGS=%$ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/example/.gitattributes b/example/.gitattributes index d42ff18354..45a3dcb2a2 100644 --- a/example/.gitattributes +++ b/example/.gitattributes @@ -1 +1,3 @@ -*.pbxproj -text +# Windows files should use crlf line endings +# https://help.github.com/articles/dealing-with-line-endings/ +*.bat text eol=crlf diff --git a/example/metro.config.js b/example/metro.config.js index dd4674dc0f..a9718e189f 100644 --- a/example/metro.config.js +++ b/example/metro.config.js @@ -10,7 +10,7 @@ module.exports = { getTransformOptions: async () => ({ transform: { experimentalImportSupport: false, - inlineRequires: false + inlineRequires: true } }) } diff --git a/example/src/screens/agenda.js b/example/src/screens/agenda.tsx similarity index 97% rename from example/src/screens/agenda.js rename to example/src/screens/agenda.tsx index 39841f3214..1e798b0355 100644 --- a/example/src/screens/agenda.js +++ b/example/src/screens/agenda.tsx @@ -1,17 +1,15 @@ import React, {Component} from 'react'; import {Alert, StyleSheet, Text, View, TouchableOpacity} from 'react-native'; +// @ts-expect-error import {Agenda} from 'react-native-calendars'; + const testIDs = require('../testIDs'); export default class AgendaScreen extends Component { - constructor(props) { - super(props); - - this.state = { - items: {} - }; - } + state = { + items: {} + }; render() { return ( diff --git a/example/src/screens/calendars.js b/example/src/screens/calendars.tsx similarity index 94% rename from example/src/screens/calendars.js rename to example/src/screens/calendars.tsx index c175382da8..59722dd9d6 100644 --- a/example/src/screens/calendars.js +++ b/example/src/screens/calendars.tsx @@ -1,7 +1,6 @@ -import _ from 'lodash'; -import XDate from 'xdate'; import React, {useState, Fragment} from 'react'; import {StyleSheet, View, ScrollView, Text, TouchableOpacity, Switch} from 'react-native'; +// @ts-expect-error import {Calendar} from 'react-native-calendars'; const testIDs = require('../testIDs'); @@ -19,19 +18,6 @@ const CalendarsScreen = () => { setSelected(day.dateString); }; - const getDisabledDates = (startDate, endDate, daysToDisable) => { - const disabledDates = {}; - const start = XDate(startDate); - const end = XDate(endDate); - - for (let m = XDate(start); m.diffDays(end) <= 0; m.addDays(1)) { - if (_.includes(daysToDisable, m.weekday())) { - disabledDates[m.toString('YYYY-MM-DD')] = {disabled: true}; - } - } - return disabledDates; - }; - const renderCalendarWithSelectableDate = () => { return ( @@ -185,7 +171,6 @@ const CalendarsScreen = () => { { borderBottomRightRadius: 5 } }, - ...getDisabledDates('2012-05-01', '2012-05-30', [0, 6]) + '2012-05-30': {disabled: true, disableTouchEvent: true} + }} + disabledDaysIndexes={[0, 6]} + theme={{ + textSectionTitleDisabledColor: 'grey', + textSectionTitleColor: '#00BBF2' }} /> @@ -257,7 +247,6 @@ const CalendarsScreen = () => { Custom calendar with custom marking type { ); }; + const renderCalendarWithInactiveDays = () => { + return ( + + Calendar with inactive days + + + ); + }; + const renderMarkedDatesExamples = () => { return ( @@ -414,6 +424,7 @@ const CalendarsScreen = () => { {renderCalendarWithMinAndMaxDates()} {renderCalendarWithCustomDay()} {renderCalendarWithCustomHeader()} + {renderCalendarWithInactiveDays()} ); }; @@ -432,14 +443,8 @@ const CalendarsScreen = () => { ); }; - const initialNumToRender = 100; // Workaround for Detox 18 migration bug - return ( - + {renderSwitch()} {showMarkedDatesExamples && renderMarkedDatesExamples()} {!showMarkedDatesExamples && renderExamples()} diff --git a/example/src/screens/calendarsList.js b/example/src/screens/calendarsList.tsx similarity index 98% rename from example/src/screens/calendarsList.js rename to example/src/screens/calendarsList.tsx index 747ba5b85d..8bc4652917 100644 --- a/example/src/screens/calendarsList.js +++ b/example/src/screens/calendarsList.tsx @@ -1,7 +1,9 @@ import React, {useState} from 'react'; import {StyleSheet, Text, View} from 'react-native'; +// @ts-expect-error import {CalendarList} from 'react-native-calendars'; + const testIDs = require('../testIDs'); const RANGE = 24; const initialDate = '2020-06-10'; diff --git a/example/src/screens/expandableCalendar.js b/example/src/screens/expandableCalendar.tsx similarity index 96% rename from example/src/screens/expandableCalendar.js rename to example/src/screens/expandableCalendar.tsx index 485f334f32..c2e95b2fa3 100644 --- a/example/src/screens/expandableCalendar.js +++ b/example/src/screens/expandableCalendar.tsx @@ -1,8 +1,10 @@ import _ from 'lodash'; import React, {Component, useCallback} from 'react'; import {Platform, StyleSheet, Alert, View, Text, TouchableOpacity, Button} from 'react-native'; +// @ts-expect-error import {ExpandableCalendar, AgendaList, CalendarProvider, WeekCalendar} from 'react-native-calendars'; + const testIDs = require('../testIDs'); const today = new Date().toISOString().split('T')[0]; @@ -128,7 +130,11 @@ function getTheme() { const leftArrowIcon = require('../img/previous.png'); const rightArrowIcon = require('../img/next.png'); -export default class ExpandableCalendarScreen extends Component { +interface Props { + weekView?: boolean +} + +export default class ExpandableCalendarScreen extends Component { marked = getMarkedDates(ITEMS); theme = getTheme(); todayBtnTheme = { @@ -144,7 +150,7 @@ export default class ExpandableCalendarScreen extends Component { // console.warn('ExpandableCalendarScreen onMonthChange: ', month, updateSource); }; - renderItem = ({item}) => { + renderItem = ({item}: any) => { return ; }; @@ -191,7 +197,11 @@ export default class ExpandableCalendarScreen extends Component { } } -const AgendaItem = React.memo(function AgendaItem(props) { +interface ItemProps { + item: any +} + +const AgendaItem = React.memo(function AgendaItem(props: ItemProps) { // console.warn('item rendered', Date.now()); const {item} = props; diff --git a/example/src/screens/horizontalCalendarList.js b/example/src/screens/horizontalCalendarList.tsx similarity index 97% rename from example/src/screens/horizontalCalendarList.js rename to example/src/screens/horizontalCalendarList.tsx index a8e5be821f..6a7e2f1d1d 100644 --- a/example/src/screens/horizontalCalendarList.js +++ b/example/src/screens/horizontalCalendarList.tsx @@ -1,6 +1,8 @@ import React, {useState} from 'react'; +// @ts-expect-error import {CalendarList} from 'react-native-calendars'; + const testIDs = require('../testIDs'); const initialDate = '2020-05-16'; diff --git a/example/src/screens/menu.js b/example/src/screens/menu.js index a5fc1fe7b0..9069c70406 100644 --- a/example/src/screens/menu.js +++ b/example/src/screens/menu.js @@ -65,7 +65,7 @@ export default class MenuScreen extends Component { options: { topBar: { title: { - text: screen + text: props?.weekView ? 'WeekCalendar' : screen }, backButton: { accessibilityLabel: 'back', diff --git a/example/src/screens/timelineCalendar.js b/example/src/screens/timelineCalendar.js deleted file mode 100644 index 3217edca66..0000000000 --- a/example/src/screens/timelineCalendar.js +++ /dev/null @@ -1,254 +0,0 @@ -import _ from 'lodash'; -import XDate from 'xdate'; -import React, {Component} from 'react'; -import {Platform, StyleSheet, View, Text, TouchableOpacity, Button} from 'react-native'; -import {ExpandableCalendar, Timeline, CalendarProvider} from 'react-native-calendars'; -import {sameDate} from '../../../src/dateutils'; - -const EVENTS = [ - { - start: '2017-09-06 22:30:00', - end: '2017-09-06 23:30:00', - title: 'Dr. Mariana Joseph', - summary: '3412 Piedmont Rd NE, GA 3032', - color: '#e6add8' - }, - { - start: '2017-09-07 00:30:00', - end: '2017-09-07 01:30:00', - title: 'Visit Grand Mother', - summary: 'Visit Grand Mother and bring some fruits.', - color: '#ade6d8' - }, - { - start: '2017-09-07 02:30:00', - end: '2017-09-07 03:20:00', - title: 'Meeting with Prof. Behjet Zuhaira', - summary: 'Meeting with Prof. Behjet at 130 in her office.', - color: '#e6add8' - }, - { - start: '2017-09-07 04:10:00', - end: '2017-09-07 04:40:00', - title: 'Tea Time with Dr. Hasan', - summary: 'Tea Time with Dr. Hasan, Talk about Project' - }, - { - start: '2017-09-07 01:05:00', - end: '2017-09-07 01:35:00', - title: 'Dr. Mariana Joseph', - summary: '3412 Piedmont Rd NE, GA 3032' - }, - { - start: '2017-09-07 14:30:00', - end: '2017-09-07 16:30:00', - title: 'Meeting Some Friends in ARMED', - summary: 'Arsalan, Hasnaat, Talha, Waleed, Bilal', - color: '#d8ade6' - }, - { - start: '2017-09-08 01:40:00', - end: '2017-09-08 02:25:00', - title: 'Meet Sir Khurram Iqbal', - summary: 'Computer Science Dept. Comsats Islamabad', - color: '#e6bcad' - }, - { - start: '2017-09-08 04:10:00', - end: '2017-09-08 04:40:00', - title: 'Tea Time with Colleagues', - summary: 'WeRplay' - }, - { - start: '2017-09-08 00:45:00', - end: '2017-09-08 01:45:00', - title: 'Lets Play Apex Legends', - summary: 'with Boys at Work' - }, - { - start: '2017-09-08 11:30:00', - end: '2017-09-08 12:30:00', - title: 'Dr. Mariana Joseph', - summary: '3412 Piedmont Rd NE, GA 3032' - }, - { - start: '2017-09-10 12:10:00', - end: '2017-09-10 13:45:00', - title: 'Merge Request to React Native Calendards', - summary: 'Merge Timeline Calendar to React Native Calendars' - } -]; - -export default class TimelineCalendarScreen extends Component { - state = { - currentDate: '2017-09-07' - }; - - onDateChanged = date => { - // console.warn('ExpandableCalendarScreen onDateChanged: ', date, updateSource); - // fetch and set data for date + week ahead - this.setState({currentDate: date}); - }; - - onMonthChange = (/* month, updateSource */) => { - // console.warn('ExpandableCalendarScreen onMonthChange: ', month, updateSource); - }; - - renderEmptyItem() { - return ( - - No Events Planned - - ); - } - - renderItem = ({item}) => { - if (_.isEmpty(item)) { - return this.renderEmptyItem(); - } - - return ( - - - {item.hour} - {item.duration} - - {item.title} - -