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

Commit c12f5bd

Browse files
committed
add placeholder
1 parent 90ae271 commit c12f5bd

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-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.3.0] - 2023-11-12
3+
### new features
4+
- add placeholder support when input is empty
25
## [2.2.0] - 2023-10-20
36
### new features
47
- add support for `Date` type value

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ you can set minimum date and maximum date range for your app
8585
<JBDateInput label="تاریخ شروع " value="2020-08-10T08:51:23.176Z" min="2020-08-05T08:51:23.176Z" max="2020-08-15T08:51:23.176Z">
8686
</JBDateInput>
8787
```
88+
## placeholder
89+
90+
you can set placeholder to show it to user when input is empty. to doing so just set `placeholder` attribute in JSX DOM:
91+
92+
```jsx
93+
<JBDateInput placeholder="Enter Date Here">
94+
</JBDateInput>
95+
```
8896
## custom validation
8997

9098
beside of min and max you can also set your own custom validation like any other jb react components family to achive this you must create a array of validations and pass it to validationList props.

lib/JBDateInput.tsx

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import React, { useEffect, useRef, useState, useImperativeHandle, useCallback, DOMAttributes } from 'react';
2-
// import PropTypes from 'prop-types';
3-
// import {type} from 'jb-date-input';
42
import 'jb-date-input';
53
// eslint-disable-next-line no-duplicate-imports
64
import { JBDateInputWebComponent, JBDateInputInputTypes, JBDateInputValidationItem, JBDDateInputInboxElementWebComponent,JBDateInputValueObject } from 'jb-date-input';
@@ -50,6 +48,7 @@ export type JBDateInputProps = {
5048
required?: boolean,
5149
calendarDefaultDateView?:{ year:number, month: number, dateType:JBDateInputInputTypes},
5250
usePersianNumber?: boolean,
51+
placeholder:string | null | undefined,
5352
children?:any,
5453
}
5554

@@ -125,6 +124,11 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
125124
element.current.value = props.value;
126125
}
127126
}, [props.value]);
127+
useEffect(() => {
128+
if (element.current && props.placeholder !== undefined) {
129+
element.current.placeholder = props.placeholder;
130+
}
131+
}, [props.placeholder]);
128132
useEffect(() => {
129133
if (element.current) {
130134
if(typeof props.style == "string"){
@@ -168,24 +172,3 @@ export const JBDateInput = React.forwardRef((props: JBDateInputProps, ref) => {
168172
);
169173
});
170174
JBDateInput.displayName = "JBDateInput";
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.2.0",
21+
"version": "2.3.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.9.0"
39+
"jb-date-input": ">=3.10.0"
4040
}
4141
}

0 commit comments

Comments
 (0)