|
1 | | -# ReactJS-Email |
| 1 | +# ReactJS - Email Component |
| 2 | + |
| 3 | +ReactJS based Email component, provides input field to add single / multiple emails with validation. The email value is automatically validated on blur event. You can change validation message using props. You can also disable email field using disable props. |
| 4 | + |
| 5 | +## Table of contents |
| 6 | + |
| 7 | +- [Browser Support](#browser-support) |
| 8 | +- [Demo](#demo) |
| 9 | +- [Getting started](#getting-started) |
| 10 | +- [Usage](#usage) |
| 11 | +- [Available Props](#available-props) |
| 12 | +- [Methods](#methods) |
| 13 | +- [Want to Contribute?](#want-to-contribute) |
| 14 | +- [Collection of Components](#collection-of-components) |
| 15 | +- [Changelog](#changelog) |
| 16 | +- [License](#license) |
| 17 | +- [Keywords](#Keywords) |
| 18 | + |
| 19 | +## Browser Support |
| 20 | + |
| 21 | +|  |  |  |  |  | |
| 22 | +| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | |
| 23 | +| 83.0 ✔ | 77.0 ✔ | 13.1.1 ✔ | 83.0 ✔ | 11.9 ✔ | |
| 24 | + |
| 25 | +## Demo |
| 26 | + |
| 27 | +[](https://github.com/weblineindia/ReactJS-Email/email.gif) |
| 28 | + |
| 29 | +## Getting started |
| 30 | + |
| 31 | +Install the npm package: |
| 32 | + |
| 33 | +```bash |
| 34 | +npm install react-weblineindia-email |
| 35 | +#OR |
| 36 | +yarn add react-weblineindia-email |
| 37 | +``` |
| 38 | + |
| 39 | +## Usage |
| 40 | + |
| 41 | +Use the `<react-weblineindia-email>` component: |
| 42 | + |
| 43 | +```js |
| 44 | +import React ,{ Component } from 'react'; |
| 45 | +import Email from 'react-weblineindia-email' |
| 46 | +class Test extends Component { |
| 47 | +constructor(props) { |
| 48 | + super(props); |
| 49 | + this.state = { |
| 50 | + emailValue:[{email:""}] |
| 51 | + }; |
| 52 | + } |
| 53 | + onMultipleEmail() { |
| 54 | + this.state.emailValue.push({ |
| 55 | + email: "", |
| 56 | + }); |
| 57 | + } |
| 58 | + onChange(event, index) { |
| 59 | + debugger; |
| 60 | + let value = this.state.emailValue; |
| 61 | + value[index].email = event.target.value; |
| 62 | + this.setState({ |
| 63 | + emailValue: value, |
| 64 | + }); |
| 65 | + } |
| 66 | + render() { |
| 67 | + return ( |
| 68 | + <div className="App"> |
| 69 | + {this.state.emailValue.map((item, i) => { |
| 70 | + return ( |
| 71 | + <div key={i}> |
| 72 | + <Email |
| 73 | + isShowPlus={this.state.emailValue.length - 1 === i} |
| 74 | + value={this.state.emailValue} |
| 75 | + index={i} |
| 76 | + onMultipleEmail={this.onMultipleEmail.bind(this)} |
| 77 | + onChange={this.onChange.bind(this)} |
| 78 | + /> |
| 79 | + </div> |
| 80 | + ); |
| 81 | + })} |
| 82 | + </div> |
| 83 | + ); |
| 84 | + } |
| 85 | +} |
| 86 | +export default Test; |
| 87 | + |
| 88 | +``` |
| 89 | + |
| 90 | +## Available Props |
| 91 | + |
| 92 | +| Prop | Type | default | Description | |
| 93 | +| ------------------- | ------------- | ----------------------- | --------------------------------------------- | |
| 94 | +| maxlength | Number | 50 | maxlength for email | |
| 95 | +| id | String | | email id | |
| 96 | +| emailFormateError | String | Email is not valid | email formate validation | |
| 97 | +| duplicateEmailError | String | Do not enter same email | duplicate email error | |
| 98 | +| onMultipleEmail | Function | | when click on plus icon on email | |
| 99 | +| name | String | email | email name. | |
| 100 | +| index | Number | 0 | email index. | |
| 101 | +| values | Array[Object] | [{email : ''}] | email default array | |
| 102 | +| isMultiple | Boolean | true | flag to implement multiple email | |
| 103 | +| isShowPlus | Boolean | false | flag to show plus icon for add multiple email | |
| 104 | +| placeholder | String | Email | email placeholder | |
| 105 | +| disabled | Boolean | false | disable input field | |
| 106 | +| tabindex | Number | 0 | email tabIndex | |
| 107 | + |
| 108 | +## Methods |
| 109 | + |
| 110 | +| Name | Description | |
| 111 | +| ----------- | --------------------------------------------------- | |
| 112 | +| focus | Gets triggered when the input field receives focus. | |
| 113 | +| blur | Gets triggered when the input field loses focus. | |
| 114 | +| inputChange | Gets triggered every time input got changed. | |
| 115 | + |
| 116 | +## Want to Contribute? |
| 117 | + |
| 118 | +- Created something awesome, made this code better, added some functionality, or whatever (this is the hardest part). |
| 119 | +- [Fork it](http://help.github.com/forking/). |
| 120 | +- Create new branch to contribute your changes. |
| 121 | +- Commit all your changes to your branch. |
| 122 | +- Submit a [pull request](http://help.github.com/pull-requests/). |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## Collection of Components |
| 127 | + |
| 128 | +We have built many other components and free resources for software development in various programming languages. Kindly click here to view our [Free Resources for Software Development](https://www.weblineindia.com/software-development-resources.html) |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## Changelog |
| 133 | + |
| 134 | +Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md). |
| 135 | + |
| 136 | +## License |
| 137 | + |
| 138 | +[MIT](LICENSE) |
| 139 | + |
| 140 | +[mit]: https://github.com/weblineindia/ReactJS-Email/blob/master/LICENSE |
| 141 | + |
| 142 | +## Keywords |
| 143 | + |
| 144 | +react-weblineindia-email, react-email, reactjs-email, email-component, email-validation, react-mail-validation |
0 commit comments