Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 6f86cca

Browse files
authored
Merge pull request #631 from hypeserver/date-fns-support
upgrade for datefns 3
2 parents 222d80c + e7d8fc7 commit 6f86cca

File tree

10 files changed

+4196
-4272
lines changed

10 files changed

+4196
-4272
lines changed

.babelrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
["@babel/preset-react"]
55
],
66
"plugins": [
7-
["@babel/plugin-proposal-class-properties"],
8-
["@babel/plugin-proposal-export-default-from"],
9-
"date-fns"
7+
["@babel/plugin-transform-class-properties"],
8+
["@babel/plugin-proposal-export-default-from"]
109
]
1110
}
1211

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jobs:
55
name: Test
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v2
9-
- uses: borales/actions-yarn@v2.0.0
8+
- uses: actions/checkout@v3
9+
- uses: borales/actions-yarn@v4
1010
with:
1111
cmd: install
12-
- uses: borales/actions-yarn@v2.0.0
12+
- uses: borales/actions-yarn@v4
1313
with:
1414
cmd: test

.vscode/settings.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
22
"eslint.enable": true,
3-
"editor.tabSize": 2,
4-
"editor.codeActionsOnSave": {
5-
"source.fixAll.eslint": true
6-
}
3+
"editor.tabSize": 2
74
}
File renamed without changes.

demo/components/SectionsRenderer.js renamed to demo/components/SectionsRenderer.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import Styled from 'rsg-components/Styled';
4-
import Heading from 'rsg-components/Heading';
54
// Import default implementation from react-styleguidist using the full path
65
import DefaultSectionsRenderer from 'react-styleguidist/lib/client/rsg-components/Sections/SectionsRenderer';
76

@@ -15,7 +14,7 @@ const styles = ({ fontFamily, space }) => ({
1514
},
1615
});
1716

18-
export function SectionsRenderer({ classes, children }) {
17+
function SectionsRenderer({ children }) {
1918
return (
2019
<div>
2120
<DefaultSectionsRenderer>{children}</DefaultSectionsRenderer>
File renamed without changes.

package.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-date-range",
3-
"version": "1.4.0",
3+
"version": "2.0.0-alpha.4",
44
"description": "A React component for choosing dates and date ranges.",
55
"main": "dist/index.js",
66
"scripts": {
@@ -44,22 +44,21 @@
4444
"shallow-equal": "^1.2.1"
4545
},
4646
"peerDependencies": {
47-
"date-fns": "2.0.0-alpha.7 || >=2.0.0",
47+
"date-fns": "3.0.6 || >=3.0.0",
4848
"react": "^0.14 || ^15.0.0-rc || >=15.0"
4949
},
5050
"devDependencies": {
51-
"@babel/cli": "^7.7.7",
51+
"@babel/cli": "^7.23.4",
5252
"@babel/core": "^7.4.4",
53-
"@babel/plugin-proposal-class-properties": "^7.5.5",
5453
"@babel/plugin-proposal-export-default-from": "^7.7.4",
54+
"@babel/plugin-transform-class-properties": "^7.23.3",
5555
"@babel/preset-env": "^7.4.4",
5656
"@babel/preset-react": "^7.7.4",
5757
"autoprefixer": "^9.7.3",
5858
"babel-eslint": "^10.0.3",
59-
"babel-loader": "^8.0.6",
60-
"babel-plugin-date-fns": "^2.0.0",
61-
"css-loader": "^3.2.0",
62-
"date-fns": "^2.8.1",
59+
"babel-loader": "^9.1.3",
60+
"css-loader": "^3.6.0",
61+
"date-fns": "^3.0.6",
6362
"enzyme": "^3.11.0",
6463
"enzyme-adapter-react-16": "^1.15.2",
6564
"enzyme-to-json": "^3.4.3",
@@ -79,9 +78,9 @@
7978
"prettier": "^1.19.1",
8079
"react": "^16.12.0",
8180
"react-dom": "^16.12.0",
82-
"react-styleguidist": "^10.4.0",
83-
"style-loader": "^1.0.0",
81+
"react-styleguidist": "^12.0.1",
82+
"style-loader": "^1.3.0",
8483
"url-loader": "^3.0.0",
85-
"webpack": "^4.41.5"
84+
"webpack": "^5.89.0"
8685
}
8786
}

src/components/Calendar/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
min,
2828
max,
2929
} from 'date-fns';
30-
import defaultLocale from 'date-fns/locale/en-US';
30+
import { enUS as defaultLocale } from 'date-fns/locale/en-US';
3131
import coreStyles from '../../styles';
3232
import { ariaLabelsShape } from '../../accessibility';
3333

@@ -99,9 +99,9 @@ class Calendar extends PureComponent {
9999
updateShownDate = (props = this.props) => {
100100
const newProps = props.scroll.enabled
101101
? {
102-
...props,
103-
months: this.list.getVisibleRange().length,
104-
}
102+
...props,
103+
months: this.list.getVisibleRange().length,
104+
}
105105
: props;
106106
const newFocus = calcFocusDate(this.state.focusedDate, newProps);
107107
this.focusToDate(newFocus, newProps);
@@ -493,7 +493,7 @@ class Calendar extends PureComponent {
493493
isVertical ? this.styles.monthsVertical : this.styles.monthsHorizontal
494494
)}>
495495
{new Array(this.props.months).fill(null).map((_, i) => {
496-
let monthStep = addMonths(this.state.focusedDate, i);;
496+
let monthStep = addMonths(this.state.focusedDate, i);
497497
if (this.props.calendarFocus === 'backwards') {
498498
monthStep = subMonths(this.state.focusedDate, this.props.months - 1 - i);
499499
}
@@ -530,7 +530,7 @@ Calendar.defaultProps = {
530530
showMonthArrow: true,
531531
showMonthAndYearPickers: true,
532532
disabledDates: [],
533-
disabledDay: () => {},
533+
disabledDay: () => { },
534534
classNames: {},
535535
locale: defaultLocale,
536536
ranges: [],

styleguide.config.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,18 @@ module.exports = {
66
//ignore: ['**/*.test.js', '**/DateInput/*', '**/DayCell/*', '**/Month/*', '**/InputRangeField/*'],
77
title: 'react-date-range',
88
showSidebar: false,
9+
require: [
10+
path.join(__dirname, 'dist/styles.css'),
11+
path.join(__dirname, 'dist/theme/default.css'),
12+
path.join(__dirname, 'demo/styles.css')
13+
],
914
template: {
1015
head: {
1116
links: [
1217
{
1318
rel: 'stylesheet',
1419
href: 'https://fonts.googleapis.com/css?family=Open+Sans:300,400',
1520
},
16-
{
17-
rel: 'stylesheet',
18-
href: './dist/styles.css',
19-
},
20-
{
21-
rel: 'stylesheet',
22-
href: './dist/theme/default.css',
23-
},
24-
{
25-
rel: 'stylesheet',
26-
href: './demo/styles.css',
27-
},
2821
],
2922
},
3023
},
@@ -75,20 +68,22 @@ module.exports = {
7568
'react-date-range': path.resolve(__dirname, moduleSource),
7669
},
7770
webpackConfig: {
71+
mode: isDEV ? 'development' : 'production',
72+
devtool: isDEV ? 'eval' : 'source-map',
7873
module: {
7974
rules: [
8075
{
81-
test: /\.jsx?$/,
76+
test: /\.(?:jsx|mjs|cjs|js)$/,
8277
exclude: /node_modules/,
83-
loader: 'babel-loader',
78+
use: 'babel-loader',
8479
},
8580
{
8681
test: /\.css$/,
87-
loader: 'style-loader!css-loader?modules',
82+
use: ["style-loader", "css-loader"],
8883
},
8984
{
9085
test: /\.svg$/,
91-
loader: 'url-loader',
86+
use: 'url-loader',
9287
},
9388
],
9489
},

0 commit comments

Comments
 (0)