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

Commit

Permalink
add date to accaptable type form min & max
Browse files Browse the repository at this point in the history
  • Loading branch information
javadbat committed Dec 2, 2023
1 parent 2f43b79 commit 8437831
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#changelog
## [2.4.0] - 2023-11-12
### new features
- add Date to valid type for min & max date restriction input
## [2.3.0] - 2023-11-12
### new features
- add placeholder support when input is empty
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ we have 3 value type:

## min and max date limit

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

```jsx
<JBDateInput label="تاریخ شروع " value="2020-08-10T08:51:23.176Z" min="2020-08-05T08:51:23.176Z" max="2020-08-15T08:51:23.176Z">
Expand Down
12 changes: 6 additions & 6 deletions lib/JBDateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export type JBDateInputProps = {
label?: string,
style?:string,
name?:string,
min?: string | null | undefined,
max?: string | null | undefined,
min?: string | null | undefined | Date,
max?: string | null | undefined | Date,
format?: string,
className?:string,
onKeyup?: (e:JBDateInputEventType<KeyboardEvent>)=>void,
Expand Down Expand Up @@ -100,10 +100,10 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
if (props.max) {
if (props.format && props.format !== element.current?.valueFormat) {
onFormatChangeCallBackQueueRef.current.push(() => {
if(props.max){element.current?.setAttribute('max', props.max);}
if(props.max){element.current?.setMaxDate(props.max);}
});
} else {
element.current?.setAttribute('max', props.max);
element.current?.setMaxDate(props.max);
}
}

Expand All @@ -112,10 +112,10 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
if (props.min) {
if (props.format && props.format !== element.current?.valueFormat) {
onFormatChangeCallBackQueueRef.current.push(() => {
props.min && element.current?.setAttribute('min', props.min);
props.min && element.current?.setMinDate(props.min);
});
} else {
element.current?.setAttribute('min', props.min);
element.current?.setMinDate(props.min);
}
}
}, [props.min]);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"react component",
"react"
],
"version": "2.3.1",
"version": "2.4.0",
"bugs": "https://github.com/javadbat/jb-date-input-react/issues",
"license": "MIT",
"files": [
Expand All @@ -36,6 +36,6 @@
"url": "https://github.com/javadbat/jb-date-input-react"
},
"dependencies": {
"jb-date-input": ">=3.10.0"
"jb-date-input": ">=3.11.0"
}
}

0 comments on commit 8437831

Please sign in to comment.