-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DateRangePicker] Introduce new component 🎉 (#1602)
* Make value for picker be a generic type * Spread new props from passing to the dom element * Split makePickerWith state hoc * Better type inference for new makePickerWithWrapper * Refactor and opimize shared prop types inference for pickers * Rename eome type names and files * Integrate validation back to usePickerState * Remove DateRangePicker code * Remove DateRangePickerUsage from index module * Fix small linter and ts errors * Fix build erros * Run prettier manually * Display calendars for date range * [WiP] Work on displaying 2 calendars one by one * WATER ON MY MAC * Proper display days with margins with range highlights * Fix unexpected month switchings * Implement range preview * Optimize rerenders of Day and DateRangeDay, closes #1306 * Fix crash and missing rerender * Optimize rerendering performace of <Day /> * Use popper for date range wrapper * Proper displaying values in DateRangePIckerInput * Implement ClickAwayListner for popper wrapper * Fix slide animation in date range picker * Reorganize test folders * Reorganize integration test folder * Add focus managment logic * Implement autoscrolling for switching between range start/end * Improve date range picker with disabling min/max dates * Update date-io adapter version to 2.5.0 * Do not display range preview on highlighted days * Better focus and blur handling for popper * Fix range preview border style * Fix type erros * Fix fantom borders appearing * Better styling for popper and possibility to replace transition * Fix missing mui globals * Fix werid memoization issue in Safari * Implement mobile version of DateRangePicker * Better displaying in mobile mode * Make possible to switch view by clicking on month and year header * Properly spread props to mobile keyboard input view * Fix ts erros and enable api generation * Fix example ts-checks * Fix ts error in ServerRerquest.example.jsx * Fix error if mouning in open state * Add props test for DateRangePickers * Export responsive date range picker by default * Add missing displayName to the ToolbarButton * Small enhancmenets * Fix inclusivity of range for non-datefns livs * Fix ts error * Remove fake data from range example * Use tsx in date range picker examples * Add `startText` and `endText` props * Update material-ui and fix createSvgIcon import, closes #1619 * Use new TextField `focused` prop for highlighting * Close picker after range selected * Update jss version * Add more date-range-manager tests * More examples and possibility to change wrapper mode for static wrapper * Fix ts wrapper props inferring * Update lib/src/views/Calendar/CalendarView.tsx Co-Authored-By: Olivier Tassinari <olivier.tassinari@gmail.com> * Update docs/pages/demo/daterangepicker/CalendarsDateRangePicker.example.tsx Co-Authored-By: Olivier Tassinari <olivier.tassinari@gmail.com> * Update createSvgIcon imports * Fix ts inferrence for static wrapper props * Add missing props spreading * Fix more build errors * Update lib/src/__tests__/setup.js Co-Authored-By: Olivier Tassinari <olivier.tassinari@gmail.com> * Address review * forwardRef for DateRangePicker Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
- Loading branch information
1 parent
c38b5ed
commit 7bed283
Showing
96 changed files
with
3,968 additions
and
800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
docs/pages/demo/daterangepicker/BasicDateRangePicker.example.jsx
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
docs/pages/demo/daterangepicker/BasicDateRangePicker.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as React from 'react'; | ||
import { DateRangePicker, DateRange } from '@material-ui/pickers'; | ||
|
||
function BasicDateRangePicker() { | ||
const [selectedDate, handleDateChange] = React.useState<DateRange>([null, null]); | ||
|
||
return ( | ||
<DateRangePicker | ||
startText="Check-in" | ||
endText="Check-out" | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
); | ||
} | ||
|
||
export default BasicDateRangePicker; |
33 changes: 33 additions & 0 deletions
33
docs/pages/demo/daterangepicker/CalendarsDateRangePicker.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as React from 'react'; | ||
import Grid from '@material-ui/core/Grid'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import { DateRangePicker, DateRange } from '@material-ui/pickers'; | ||
|
||
function CalendarsDateRangePicker() { | ||
const [selectedDate, handleDateChange] = React.useState<DateRange>([null, null]); | ||
|
||
return ( | ||
<Grid container direction="column" alignItems="center"> | ||
<Typography gutterBottom> 1 calendar </Typography> | ||
<DateRangePicker | ||
calendars={1} | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
<Typography gutterBottom> 2 calendars</Typography> | ||
<DateRangePicker | ||
calendars={2} | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
<Typography gutterBottom> 3 calendars</Typography> | ||
<DateRangePicker | ||
calendars={3} | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default CalendarsDateRangePicker; |
27 changes: 27 additions & 0 deletions
27
docs/pages/demo/daterangepicker/MinMaxDateRangePicker.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as React from 'react'; | ||
import addWeeks from 'date-fns/addWeeks'; | ||
import { Dayjs } from 'dayjs'; | ||
import { Moment } from 'moment'; | ||
import { DateTime } from 'luxon'; | ||
import { makeJSDateObject } from '../../../utils/helpers'; | ||
import { DateRangePicker, DateRange } from '@material-ui/pickers'; | ||
|
||
function getWeeksAfter(date: Moment | DateTime | Dayjs | Date, amount: number) { | ||
// TODO: replace with implementation for your date library | ||
return date ? addWeeks(makeJSDateObject(date), amount) : undefined; | ||
} | ||
|
||
function MinMaxDateRangePicker() { | ||
const [selectedRange, handleDateChange] = React.useState<DateRange>([null, null]); | ||
|
||
return ( | ||
<DateRangePicker | ||
disablePast | ||
value={selectedRange} | ||
maxDate={getWeeksAfter(selectedRange[0], 4)} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
); | ||
} | ||
|
||
export default MinMaxDateRangePicker; |
24 changes: 24 additions & 0 deletions
24
docs/pages/demo/daterangepicker/ResponsiveDateRangePicker.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { MobileDateRangePicker, DesktopDateRangePicker, DateRange } from '@material-ui/pickers'; | ||
|
||
function ResponsiveDateRangePicker() { | ||
const [selectedDate, handleDateChange] = React.useState<DateRange>([null, null]); | ||
|
||
return ( | ||
<> | ||
<MobileDateRangePicker | ||
startText="Mobile start" | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
|
||
<DesktopDateRangePicker | ||
startText="Desktop start" | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
export default ResponsiveDateRangePicker; |
24 changes: 24 additions & 0 deletions
24
docs/pages/demo/daterangepicker/StaticDateRangePicker.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { StaticDateRangePicker, DateRange } from '@material-ui/pickers'; | ||
|
||
function StaticDateRangePickerExample() { | ||
const [selectedDate, handleDateChange] = React.useState<DateRange>([null, null]); | ||
|
||
return ( | ||
<> | ||
<StaticDateRangePicker | ||
displayStaticWrapperAs="desktop" | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
|
||
<StaticDateRangePicker | ||
displayStaticWrapperAs="mobile" | ||
value={selectedDate} | ||
onChange={date => handleDateChange(date)} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
export default StaticDateRangePickerExample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
7bed283
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: