-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DatePicker): add disableDates (#3788)
closes #3787 --------- Co-authored-by: alyonurchick1 <[email protected]>
- Loading branch information
1 parent
9e52d2f
commit 5acafb7
Showing
14 changed files
with
122 additions
and
43 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
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
39 changes: 39 additions & 0 deletions
39
...Picker/__stand__/examples/DatePickerExampleDisableDates/DatePickerExampleDisableDates.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,39 @@ | ||
import { Example } from '@consta/stand'; | ||
import React, { useState } from 'react'; | ||
|
||
import { DatePicker } from '../../../DatePicker'; | ||
|
||
const getDisableDates = (): Array<Date | [Date, Date]> => { | ||
const date = new Date(); | ||
const year = date.getFullYear(); | ||
const month = date.getMonth(); | ||
const day = date.getDate(); | ||
return [ | ||
// интервал времени текущей даты с 12:34:20 - 16:10:41 | ||
[ | ||
new Date(year, month, day, 12, 34, 20), | ||
new Date(year, month, day, 16, 10, 41), | ||
], | ||
// слелдующий день | ||
new Date(year, month, day + 1), | ||
// отключаем с 1го по 12ое включительно | ||
[new Date(year, month, 1), new Date(year, month, 13)], | ||
]; | ||
}; | ||
|
||
const disableDates = getDisableDates(); | ||
|
||
export const DatePickerExampleDisableDates = () => { | ||
const [value, setValue] = useState<Date | null>(); | ||
|
||
return ( | ||
<Example col={1}> | ||
<DatePicker | ||
type="date-time" | ||
value={value} | ||
disableDates={disableDates} | ||
onChange={setValue} | ||
/> | ||
</Example> | ||
); | ||
}; |
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