Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 8437831

Browse files
committed
add date to accaptable type form min & max
1 parent 2f43b79 commit 8437831

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#changelog
2+
## [2.4.0] - 2023-11-12
3+
### new features
4+
- add Date to valid type for min & max date restriction input
25
## [2.3.0] - 2023-11-12
36
### new features
47
- add placeholder support when input is empty

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ we have 3 value type:
7979

8080
## min and max date limit
8181

82-
you can set minimum date and maximum date range for your app
82+
you can set minimum date and maximum date range for your app in string or Date type
8383

8484
```jsx
8585
<JBDateInput label="تاریخ شروع " value="2020-08-10T08:51:23.176Z" min="2020-08-05T08:51:23.176Z" max="2020-08-15T08:51:23.176Z">

lib/JBDateInput.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export type JBDateInputProps = {
3333
label?: string,
3434
style?:string,
3535
name?:string,
36-
min?: string | null | undefined,
37-
max?: string | null | undefined,
36+
min?: string | null | undefined | Date,
37+
max?: string | null | undefined | Date,
3838
format?: string,
3939
className?:string,
4040
onKeyup?: (e:JBDateInputEventType<KeyboardEvent>)=>void,
@@ -100,10 +100,10 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
100100
if (props.max) {
101101
if (props.format && props.format !== element.current?.valueFormat) {
102102
onFormatChangeCallBackQueueRef.current.push(() => {
103-
if(props.max){element.current?.setAttribute('max', props.max);}
103+
if(props.max){element.current?.setMaxDate(props.max);}
104104
});
105105
} else {
106-
element.current?.setAttribute('max', props.max);
106+
element.current?.setMaxDate(props.max);
107107
}
108108
}
109109

@@ -112,10 +112,10 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
112112
if (props.min) {
113113
if (props.format && props.format !== element.current?.valueFormat) {
114114
onFormatChangeCallBackQueueRef.current.push(() => {
115-
props.min && element.current?.setAttribute('min', props.min);
115+
props.min && element.current?.setMinDate(props.min);
116116
});
117117
} else {
118-
element.current?.setAttribute('min', props.min);
118+
element.current?.setMinDate(props.min);
119119
}
120120
}
121121
}, [props.min]);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"react component",
1919
"react"
2020
],
21-
"version": "2.3.1",
21+
"version": "2.4.0",
2222
"bugs": "https://github.com/javadbat/jb-date-input-react/issues",
2323
"license": "MIT",
2424
"files": [
@@ -36,6 +36,6 @@
3636
"url": "https://github.com/javadbat/jb-date-input-react"
3737
},
3838
"dependencies": {
39-
"jb-date-input": ">=3.10.0"
39+
"jb-date-input": ">=3.11.0"
4040
}
4141
}

0 commit comments

Comments
 (0)