diff --git a/CHANGELOG.md b/CHANGELOG.md index 138db2a..6b5daaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 63ce095..ebc137c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/JBDateInput.tsx b/lib/JBDateInput.tsx index a7a310b..10f88e3 100644 --- a/lib/JBDateInput.tsx +++ b/lib/JBDateInput.tsx @@ -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)=>void, @@ -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); } } @@ -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]); diff --git a/package.json b/package.json index d1ab10e..97c480f 100644 --- a/package.json +++ b/package.json @@ -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": [ @@ -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" } }