Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weekStartsOn propagation #523

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
383f63b
refactor: remove empty instruction
gbili Oct 7, 2021
5fa02ec
feat: allow custom weekStartsOn for DefinedRange
gbili Oct 7, 2021
8636bbb
build: new version
gbili Oct 7, 2021
9671f9d
feat: migrate to tsc, no errors
gbili Oct 11, 2021
e0175a1
fix: remove scss warning
gbili Oct 11, 2021
683d20c
feat: tests passing 2 snapshots obsolete
gbili Oct 13, 2021
bac6dc3
docs: fix markdown
gbili Oct 13, 2021
08613c0
feat: all tests and snapshots passing
gbili Oct 13, 2021
b378c84
refactor: remove unused comment
gbili Oct 13, 2021
65022cd
refactor: rename MaybeMaybe to something more explicit
gbili Oct 13, 2021
0f05fb3
refactor: rename Range to express it may be empty
gbili Oct 13, 2021
bc24b3e
refactor: remove unused declarations
gbili Oct 13, 2021
ae2317d
feat: allow weekStartsOn to change
gbili Oct 13, 2021
8238ce1
fix: few lint errors
gbili Oct 13, 2021
6873f51
docs: point proper package
gbili Oct 13, 2021
c966323
v1.5.1
gbili Oct 13, 2021
062675e
docs: fix import package name
gbili Oct 13, 2021
2dce8b8
v1.5.2
gbili Oct 13, 2021
1ac330a
fix: point to own user
gbili Oct 13, 2021
e36177b
v1.5.3
gbili Oct 13, 2021
11df1c9
feat: update styleguide
gbili Oct 13, 2021
9ad108e
v1.5.4
gbili Oct 13, 2021
a3721b1
v1.5.5
gbili Oct 13, 2021
a2672d8
fix: add proper tsconfig for declaration files output
gbili Oct 13, 2021
08d8a4f
v1.5.6
gbili Oct 13, 2021
c57f276
fix: HACK defaultProps types allow optional to prevent ts complaining…
gbili Oct 13, 2021
f8162b6
v1.5.7
gbili Oct 13, 2021
f003a2b
fix: no classes were being passed to components
gbili Oct 14, 2021
5748609
v1.5.8
gbili Oct 14, 2021
10d04b8
refactor: pretty
gbili Oct 15, 2021
fd779e0
refactor: simplify
gbili Oct 15, 2021
50166a0
refactor: make clearer what the function is
gbili Oct 17, 2021
2bb8c89
refactor:make functional components
gbili Oct 17, 2021
7db2431
refactor: make it React.FC, disappeared props are default ones
gbili Oct 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .babelrc
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
{
"presets": [
["@babel/preset-env"],
["@babel/preset-react"]
],
"plugins": [
["@babel/plugin-proposal-class-properties"],
["@babel/plugin-proposal-export-default-from"],
"date-fns"
]
}

"presets": ["@babel/preset-env", "@babel/preset-react"]
}
30 changes: 0 additions & 30 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)
Copyright (c) 2015-2020 Adphorus
Copyright (c) 2020- Hypeserver
Copyright (c) 2021- Guillermo Pages

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
# react-date-range
[![npm](https://img.shields.io/npm/v/react-date-range)](https://www.npmjs.com/package/react-date-range)
[![npm](https://img.shields.io/npm/l/react-date-range)]()
[![npm](https://img.shields.io/npm/dw/react-date-range)](https://www.npmjs.com/package/react-date-range)
[![sponsors](https://img.shields.io/github/sponsors/hypeserver)](https://github.com/sponsors/hypeserver)

[![npm](https://img.shields.io/npm/v/react-date-range-ts)](https://www.npmjs.com/package/react-date-range-ts)
[![npm](https://img.shields.io/npm/dw/react-date-range-ts)](https://www.npmjs.com/package/react-date-range-ts)
[![sponsors](https://img.shields.io/github/sponsors/hypeserver)](https://github.com/sponsors/hypeserver-ts)

A date library agnostic React component for choosing dates and date ranges. Uses [date-fns](http://date-fns.org/) for date operations.

### Why should you use `react-date-range`?
## Why should you use `react-date-range-ts`

- Stateless date operations
- Highly configurable
- Multiple range selection
- Based on native js dates
- Drag n Drop selection
- Keyboard friendly
- Fully Typed with Typescript

**Live Demo :** [http://hypeserver.github.io/react-date-range](http://hypeserver.github.io/react-date-range)

![](https://raw.githubusercontent.com/hypeserver/react-date-range/master/demo/ss.png)
**Live Demo :** [http://gbili.github.io/react-date-range-ts](http://gbili.github.io/react-date-range-ts)

![demo-calendar-screenshot](https://raw.githubusercontent.com/gbili/react-date-range-ts/master/demo/ss.png)

## Getting Started

### Installation

```sh
npm install --save react-date-range-ts
```
npm install --save react-date-range
```

This plugin expects `react` and `date-fns` as peerDependencies, It means that you need to install them in your project folder.

```
```sh
npm install --save react date-fns
```

Expand All @@ -38,13 +39,14 @@ npm install --save react date-fns
You need to import skeleton and theme styles first.

```javascript
import 'react-date-range/dist/styles.css'; // main style file
import 'react-date-range/dist/theme/default.css'; // theme css file
import 'react-date-range-ts/dist/styles.css'; // main style file
import 'react-date-range-ts/dist/theme/default.css'; // theme css file
```

### `DatePicker`

```javascript
import { Calendar } from 'react-date-range';
import { Calendar } from 'react-date-range-ts';

class MyComponent extends Component {
handleSelect(date){
Expand All @@ -63,8 +65,9 @@ class MyComponent extends Component {
```

### `DateRangePicker / DateRange`

```javascript
import { DateRangePicker } from 'react-date-range';
import { DateRangePicker } from 'react-date-range-ts';

class MyComponent extends Component {
handleSelect(ranges){
Expand Down Expand Up @@ -146,6 +149,7 @@ ariaLabels | Object | {} | inserts ar
dayContentRenderer | Function | null | Function to customize the rendering of Calendar Day. given a date is supposed to return what to render.

*shape of range:

```js
{
startDate: PropTypes.object,
Expand All @@ -159,6 +163,7 @@ dayContentRenderer | Function | null | Function t
```

**shape of ariaLabels:

```js
{
// The key of dateInput should be same as key in range.
Expand All @@ -174,6 +179,7 @@ dayContentRenderer | Function | null | Function t
nextButton: PropTypes.string,
}
```

#### Infinite Scrolled Mode

To enable infinite scroll set `scroll={{enabled: true}}` basically. Infinite scroll feature is affected by `direction`(rendering direction for months) and `months`(for rendered months count) props directly.
Expand All @@ -191,8 +197,8 @@ If you prefer, you can overwrite calendar sizes with `calendarWidth`/`calendarHe
}),
```


### Release workflow

- Merge everything that needs to be in the release to master
- Open a new release PR than:
- bumps version to appropriate one <new_version>
Expand Down
12 changes: 6 additions & 6 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
**react-date-range** can be installed with **npm**, by the following command:
**react-date-range-ts** can be installed with **npm**, by the following command:

```bash static
npm install react-date-range
```bash static
npm install react-date-range-ts
```

First, styles and theme file must be imported:

```js static
import 'react-date-range/dist/styles.css'; // main css file
import 'react-date-range/dist/theme/default.css'; // theme css file
```js static
import 'react-date-range-ts/dist/styles.css'; // main css file
import 'react-date-range-ts/dist/theme/default.css'; // theme css file
```

Then, import one of the 4 standalone components: [DateRange](#daterange), [DateRangePicker](#daterangepicker), [Calendar](#calendar), [DefinedRange](#definedrange)
2 changes: 1 addition & 1 deletion demo/components/StyleGuide.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function StyleGuideRenderer({ classes, title, homepageUrl, children }) {
</a>
</Logo>
<nav className={classes.nav}>
<a className={classes.headerLink} href="https://github.com/hypeserver/react-date-range">
<a className={classes.headerLink} href="https://github.com/gbili/react-date-range-ts">
GitHub
</a>
</nav>
Expand Down
105 changes: 105 additions & 0 deletions demo/components/StyleGuide.tsx.back
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import React from 'react';
import Logo from 'rsg-components/Logo';
import Markdown from 'rsg-components/Markdown';
import Styled from 'rsg-components/Styled';

const xsmall = '@media (max-width: 600px)';
type StylesProps = { font: string; base: string; light: string; link: string; baseBackground: string; mq: { small: string; } };
const styles = ({ font, base, light, link, baseBackground, mq }: StylesProps) => ({
root: {
color: base,
backgroundColor: baseBackground,
},
header: {
color: '#fff',
backgroundColor: link,
},
bar: {
display: 'flex',
alignItems: 'center',
[xsmall]: {
flexDirection: 'column',
alignItems: 'center',
},
},
nav: {
marginLeft: 'auto',
marginRight: '-0.5em',
[xsmall]: {
margin: [[10, 0, 0]],
},
},
headerLink: {
'&, &:link, &:visited': {
marginLeft: '0.5em',
marginRight: '0.5em',
fontFamily: font,
color: '#efefef',
},
'&:hover, &:active': {
color: '#fff',
cursor: 'pointer',
},
},
content: {
maxWidth: 1000,
padding: [[15, 30]],
margin: [[0, 'auto']],
[mq.small]: {
padding: 15,
},
display: 'block',
},
components: {
overflow: 'auto', // To prevent the pane from growing out of the screen
},
footer: {
display: 'block',
color: light,
fontFamily: font,
fontSize: 12,
},
});

type ClassesProp = {
root: string;
header: string;
content: string;
bar: string;
headerLink: string;
nav: string;
footer: string;
}

type StyleGuideRendererProps = { classes: ClassesProp; title: JSX.Element | string | number; homepageUrl: string; children: JSX.Element; };

export function StyleGuideRenderer({ classes, title, homepageUrl, children }: StyleGuideRendererProps) {
return (
<div className={classes.root}>
<header className={classes.header}>
<div className={classes.content}>
<div className={classes.bar}>
<Logo>
<a className={classes.headerLink} href="#">
{title}
</a>
</Logo>
<nav className={classes.nav}>
<a className={classes.headerLink} href="https://github.com/gbili/react-date-range-ts">
GitHub
</a>
</nav>
</div>
</div>
</header>
<main className={classes.content}>
{children}
<footer className={classes.footer}>
<Markdown text={`Created with [React Styleguidist](${homepageUrl}) ❤️`} />
</footer>
</main>
</div>
);
}

export default Styled(styles)(StyleGuideRenderer);
7 changes: 0 additions & 7 deletions jest.config.js

This file was deleted.

17 changes: 17 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const config = {
verbose: true,
testURL: 'http://localhost/',
setupFiles: ['<rootDir>/setupTests.ts'],
maxWorkers: 100,
roots: ['<rootDir>/src'],
testMatch: [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
testEnvironment: "jsdom",
transform: { "^.+\\.(ts|tsx)$": "ts-jest" },
moduleFileExtensions: ['ts', 'tsx', 'js'], //...defaults.moduleFileExtensions,
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/demo/dist/'],
snapshotSerializers: ['enzyme-to-json/serializer'],
};
export default config;
Loading