Skip to content

Commit

Permalink
v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasJang committed Mar 1, 2019
1 parent da17995 commit 5ad4231
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 17 deletions.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -24,7 +24,7 @@ npm install react-multi-email -S

```typescript jsx
import * as React from 'react';
import { ReactMultiEmail } from 'react-multi-email';
import { ReactMultiEmail, isEmail } from 'react-multi-email';
import 'react-multi-email/style.css';

interface IProps {}
Expand All @@ -48,6 +48,9 @@ class Basic extends React.Component<IProps, IState> {
onChange={(_emails: string[]) => {
this.setState({ emails: _emails });
}}
validateEmail={email => {
return isEmail(email); // return boolean
}}
getLabel={(
email: string,
index: number,
Expand Down
5 changes: 4 additions & 1 deletion dist/README.md
Expand Up @@ -24,7 +24,7 @@ npm install react-multi-email -S

```typescript jsx
import * as React from 'react';
import { ReactMultiEmail } from 'react-multi-email';
import { ReactMultiEmail, isEmail } from 'react-multi-email';
import 'react-multi-email/style.css';

interface IProps {}
Expand All @@ -48,6 +48,9 @@ class Basic extends React.Component<IProps, IState> {
onChange={(_emails: string[]) => {
this.setState({ emails: _emails });
}}
validateEmail={email => {
return isEmail(email); // return boolean
}}
getLabel={(
email: string,
index: number,
Expand Down
1 change: 1 addition & 0 deletions dist/commonjs/ReactMultiEmail.d.ts
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
export interface IReactMultiEmailProps {
emails?: string[];
onChange?: (emails: string[]) => void;
validateEmail?: (email: string) => boolean;
style?: object;
getLabel: (email: string, index: number, removeEmail: (index: number) => void) => void;
className?: string;
Expand Down
6 changes: 4 additions & 2 deletions dist/commonjs/ReactMultiEmail.js
Expand Up @@ -22,9 +22,11 @@ var ReactMultiEmail = /** @class */ (function (_super) {
inputValue: '',
};
_this.findEmailAddress = function (value, isEnter) {
var validateEmail = _this.props.validateEmail;
var validEmails = [];
var inputValue = '';
var re = /[ ,;]/g;
var isEmail = validateEmail || isEmail_1.default;
var addEmails = function (email) {
var emails = _this.state.emails;
for (var i = 0, l = emails.length; i < l; i++) {
Expand All @@ -41,7 +43,7 @@ var ReactMultiEmail = /** @class */ (function (_super) {
return n !== '' && n !== undefined && n !== null;
});
do {
if (isEmail_1.default('' + arr[0])) {
if (isEmail('' + arr[0])) {
addEmails('' + arr.shift());
}
else {
Expand All @@ -57,7 +59,7 @@ var ReactMultiEmail = /** @class */ (function (_super) {
}
else {
if (isEnter) {
if (isEmail_1.default(value)) {
if (isEmail(value)) {
addEmails(value);
}
else {
Expand Down
1 change: 1 addition & 0 deletions dist/es6/ReactMultiEmail.d.ts
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
export interface IReactMultiEmailProps {
emails?: string[];
onChange?: (emails: string[]) => void;
validateEmail?: (email: string) => boolean;
style?: object;
getLabel: (email: string, index: number, removeEmail: (index: number) => void) => void;
className?: string;
Expand Down
4 changes: 3 additions & 1 deletion dist/es6/ReactMultiEmail.js
@@ -1,5 +1,5 @@
import * as React from 'react';
import isEmail from './isEmail';
import isEmailFn from './isEmail';
class ReactMultiEmail extends React.Component {
constructor(props) {
super(props);
Expand All @@ -9,9 +9,11 @@ class ReactMultiEmail extends React.Component {
inputValue: '',
};
this.findEmailAddress = (value, isEnter) => {
const { validateEmail } = this.props;
let validEmails = [];
let inputValue = '';
const re = /[ ,;]/g;
const isEmail = validateEmail || isEmailFn;
const addEmails = (email) => {
const emails = this.state.emails;
for (let i = 0, l = emails.length; i < l; i++) {
Expand Down
2 changes: 1 addition & 1 deletion dist/package.json
@@ -1,6 +1,6 @@
{
"name": "react-multi-email",
"version": "0.4.4",
"version": "0.5.0",
"description": "React multi email input",
"jsnext:main": "es6/index.js",
"main": "commonjs/index.js",
Expand Down
4 changes: 2 additions & 2 deletions docs/asset-manifest.json
@@ -1,7 +1,7 @@
{
"main.css": "static/css/main.ab19594c.css",
"main.css.map": "static/css/main.ab19594c.css.map",
"main.js": "static/js/main.2bc07060.js",
"main.js.map": "static/js/main.2bc07060.js.map",
"main.js": "static/js/main.f9c460be.js",
"main.js.map": "static/js/main.f9c460be.js.map",
"static/media/axui-logo.png": "static/media/axui-logo.bdc57a37.png"
}
2 changes: 1 addition & 1 deletion docs/index.html
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>AXUI : react-multi-email</title><link href="/static/css/main.ab19594c.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="/static/js/main.2bc07060.js"></script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>AXUI : react-multi-email</title><link href="/static/css/main.ab19594c.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="/static/js/main.f9c460be.js"></script></body></html>
2 changes: 1 addition & 1 deletion docs/service-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/static/js/main.2bc07060.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/static/js/main.f9c460be.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "react-multi-email",
"version": "0.4.4",
"version": "0.5.0",
"peerDependencies": {
"react": "^16.4.0",
"react-dom": "^16.4.0"
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
@@ -1,6 +1,6 @@
{
"name": "react-multi-email",
"version": "0.4.4",
"version": "0.5.0",
"description": "React multi email input",
"jsnext:main": "es6/index.js",
"main": "commonjs/index.js",
Expand Down
5 changes: 4 additions & 1 deletion src/react-multi-email/ReactMultiEmail.tsx
@@ -1,9 +1,10 @@
import * as React from 'react';
import isEmail from './isEmail';
import isEmailFn from './isEmail';

export interface IReactMultiEmailProps {
emails?: string[];
onChange?: (emails: string[]) => void;
validateEmail?: (email: string) => boolean;
style?: object;
getLabel: (
email: string,
Expand Down Expand Up @@ -55,9 +56,11 @@ class ReactMultiEmail extends React.Component<
}

findEmailAddress = (value: string, isEnter?: boolean) => {
const { validateEmail } = this.props;
let validEmails: string[] = [];
let inputValue: string = '';
const re = /[ ,;]/g;
const isEmail = validateEmail || isEmailFn;

const addEmails = (email: string) => {
const emails: string[] = this.state.emails;
Expand Down
5 changes: 4 additions & 1 deletion src/samples/CustomizeStyle.tsx
@@ -1,5 +1,5 @@
import * as React from 'react';
import { ReactMultiEmail } from 'react-multi-email';
import { ReactMultiEmail, isEmail } from 'react-multi-email';

interface IProps {}
interface IState {
Expand Down Expand Up @@ -27,6 +27,9 @@ class CustomizeStyle extends React.Component<IProps, IState> {
onChange={(_emails: string[]) => {
this.setState({ emails: _emails });
}}
validateEmail={email => {
return isEmail(email);
}}
getLabel={(
email: string,
index: number,
Expand Down

0 comments on commit 5ad4231

Please sign in to comment.