File tree Expand file tree Collapse file tree 5 files changed +35
-2
lines changed
src/Components/Inputs/DatePicker Expand file tree Collapse file tree 5 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @programmer_network/yail" ,
3
- "version" : " 1.0.197 " ,
3
+ "version" : " 1.0.198 " ,
4
4
"description" : " Programmer Network's official UI library for React" ,
5
5
"author" : " Aleksandar Grbic - (https://programmer.network)" ,
6
6
"publishConfig" : {
Original file line number Diff line number Diff line change @@ -32,3 +32,26 @@ export const Default = () => {
32
32
/>
33
33
) ;
34
34
} ;
35
+
36
+ export const WithMinAndMaxDate = ( ) => {
37
+ const [ date , setDate ] = useState ( new Date ( ) ) ;
38
+
39
+ return (
40
+ < DatePicker
41
+ name = 'datetime'
42
+ minDate = { new Date ( ) }
43
+ maxDate = { new Date ( new Date ( ) . setDate ( new Date ( ) . getDate ( ) + 7 ) ) }
44
+ selected = { date }
45
+ timeIntervals = { 60 }
46
+ showTimeSelect
47
+ timeCaption = 'Time'
48
+ onChange = { input => {
49
+ if ( ! input . datetime ) {
50
+ return ;
51
+ }
52
+
53
+ setDate ( input . datetime ) ;
54
+ } }
55
+ />
56
+ ) ;
57
+ } ;
Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ const DatePicker: FC<IDatePickerProps> = props => {
15
15
timeFormat = "HH:mm" ,
16
16
timeCaption = "time" ,
17
17
timeIntervals = 15 ,
18
- dateFormat = "MMMM d, yyyy h:mm aa"
18
+ dateFormat = "MMMM d, yyyy h:mm aa" ,
19
+ minDate,
20
+ maxDate
19
21
} = props ;
20
22
21
23
const handleChange = ( date : Date | null ) => {
@@ -42,6 +44,8 @@ const DatePicker: FC<IDatePickerProps> = props => {
42
44
timeCaption = { timeCaption }
43
45
dateFormat = { dateFormat }
44
46
showPopperArrow = { false }
47
+ minDate = { minDate }
48
+ maxDate = { maxDate }
45
49
/>
46
50
</ div >
47
51
) ;
Original file line number Diff line number Diff line change @@ -92,3 +92,7 @@ li.react-datepicker__time-list-item {
92
92
.react-datepicker__input-container input {
93
93
@apply yl-w-full yl-appearance-none yl-rounded-md yl-border-2 yl-border-primary-text-color yl-bg-transparent yl-p-2 yl-text-primary-text-color hover:yl-cursor-pointer hover:yl-border-primary focus:yl-border-primary focus:yl-outline-none focus:yl-ring-transparent !important ;
94
94
}
95
+
96
+ .react-datepicker__day--disabled {
97
+ @apply yl-cursor-not-allowed yl-text-primary-text-color/40 !important ;
98
+ }
Original file line number Diff line number Diff line change @@ -8,4 +8,6 @@ export interface IDatePickerProps extends InputHeaderProps {
8
8
timeCaption ?: string ;
9
9
dateFormat ?: string ;
10
10
showTimeSelect ?: boolean ;
11
+ minDate ?: Date ;
12
+ maxDate ?: Date ;
11
13
}
You can’t perform that action at this time.
0 commit comments