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

Commit bde3af2

Browse files
committed
add date value
1 parent f23d5aa commit bde3af2

File tree

3 files changed

+36
-25
lines changed

3 files changed

+36
-25
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.2.0] - 2023-10-20
3+
### new features
4+
- add support for `Date` type value
25
## [2.1.1] - 2023-10-17
36
### fixed
47
- fix value PropType to accept `null` value type

lib/JBDateInput.tsx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useRef, useState, useImperativeHandle, useCallback, DOMAttributes } from 'react';
2-
import PropTypes from 'prop-types';
2+
// import PropTypes from 'prop-types';
33
// import {type} from 'jb-date-input';
44
import 'jb-date-input';
55
// eslint-disable-next-line no-duplicate-imports
@@ -33,6 +33,7 @@ export type JBDateInputEventType<T> = T & {
3333
}
3434
export type JBDateInputProps = {
3535
label?: string,
36+
style?:string,
3637
name?:string,
3738
min?: string,
3839
max?: string,
@@ -44,7 +45,7 @@ export type JBDateInputProps = {
4445
valueType?: 'GREGORIAN'|'JALALI'|'TIME_STAMP',
4546
inputType?: 'GREGORIAN'|'JALALI',
4647
direction?: 'ltr'|'rtl',
47-
value: string | null | undefined,
48+
value: string | Date | null | undefined,
4849
validationList?: JBDateInputValidationItem[],
4950
required?: boolean,
5051
calendarDefaultDateView?:{ year:number, month: number, dateType:JBDateInputInputTypes},
@@ -124,6 +125,13 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
124125
element.current.value = props.value;
125126
}
126127
}, [props.value]);
128+
useEffect(() => {
129+
if (element.current) {
130+
if(typeof props.style == "string"){
131+
element.current.setAttribute("style",props.style);
132+
}
133+
}
134+
}, [props.style]);
127135
useEffect(() => {
128136
if (element.current && Array.isArray(props.validationList)) {
129137
element.current.validationList = props.validationList;
@@ -160,24 +168,24 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
160168
);
161169
});
162170
JBDateInput.displayName = "JBDateInput";
163-
JBDateInput.propTypes = {
164-
label: PropTypes.string,
165-
name:PropTypes.string,
166-
className:PropTypes.string,
167-
min: PropTypes.string,
168-
max: PropTypes.string,
169-
format: PropTypes.string,
170-
onKeyup: PropTypes.func,
171-
onChange: PropTypes.func,
172-
onSelect: PropTypes.func,
173-
valueType: PropTypes.oneOf(['GREGORIAN', 'JALALI', 'TIME_STAMP']),
174-
inputType: PropTypes.oneOf(['GREGORIAN', 'JALALI']),
175-
direction: PropTypes.oneOf(['ltr', 'rtl']),
176-
value: PropTypes.string,
177-
validationList: PropTypes.array,
178-
required: PropTypes.bool,
179-
calendarDefaultDateView: PropTypes.shape({ year: PropTypes.number.isRequired, month: PropTypes.number.isRequired, dateType: PropTypes.oneOf<JBDateInputInputTypes>([JBDateInputInputTypes.gregorian, JBDateInputInputTypes.jalali]).isRequired }),
180-
// calendarDefaultDateView: PropTypes.object,
181-
usePersianNumber: PropTypes.bool,
182-
// children:PropTypes.element
183-
};
171+
// JBDateInput.propTypes = {
172+
// label: PropTypes.string,
173+
// name:PropTypes.string,
174+
// className:PropTypes.string,
175+
// min: PropTypes.string,
176+
// max: PropTypes.string,
177+
// format: PropTypes.string,
178+
// onKeyup: PropTypes.func,
179+
// onChange: PropTypes.func,
180+
// onSelect: PropTypes.func,
181+
// valueType: PropTypes.oneOf(['GREGORIAN', 'JALALI', 'TIME_STAMP']),
182+
// inputType: PropTypes.oneOf(['GREGORIAN', 'JALALI']),
183+
// direction: PropTypes.oneOf(['ltr', 'rtl']),
184+
// value: PropTypes.string,
185+
// validationList: PropTypes.array,
186+
// required: PropTypes.bool,
187+
// calendarDefaultDateView: PropTypes.shape({ year: PropTypes.number.isRequired, month: PropTypes.number.isRequired, dateType: PropTypes.oneOf<JBDateInputInputTypes>([JBDateInputInputTypes.gregorian, JBDateInputInputTypes.jalali]).isRequired }),
188+
// // calendarDefaultDateView: PropTypes.object,
189+
// usePersianNumber: PropTypes.bool,
190+
// // children:PropTypes.element
191+
// };

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.1.1",
21+
"version": "2.2.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.7.13"
39+
"jb-date-input": ">=3.9.0"
4040
}
4141
}

0 commit comments

Comments
 (0)