react-multi-email
Advanced tools
Comparing version
@@ -18,3 +18,3 @@ import * as React from 'react'; | ||
enableSpinner?: boolean; | ||
style?: object; | ||
style?: React.CSSProperties; | ||
getLabel: (email: string, index: number, removeEmail: (index: number, isDisabled?: boolean) => void) => React.ReactNode; | ||
@@ -25,4 +25,5 @@ className?: string; | ||
spinner?: () => React.ReactNode; | ||
delimiter?: string; | ||
} | ||
export declare function ReactMultiEmail(props: IReactMultiEmailProps): JSX.Element; | ||
//# sourceMappingURL=ReactMultiEmail.d.ts.map |
@@ -92,8 +92,8 @@ "use strict"; | ||
var _this = this; | ||
var id = props.id, style = props.style, getLabel = props.getLabel, _a = props.className, className = _a === void 0 ? '' : _a, noClass = props.noClass, placeholder = props.placeholder, autoFocus = props.autoFocus, enable = props.enable, onDisabled = props.onDisabled, validateEmail = props.validateEmail, onChange = props.onChange, onChangeInput = props.onChangeInput, onFocus = props.onFocus, onBlur = props.onBlur, onKeyDown = props.onKeyDown, onKeyUp = props.onKeyUp, spinner = props.spinner; | ||
var id = props.id, style = props.style, getLabel = props.getLabel, _a = props.className, className = _a === void 0 ? '' : _a, noClass = props.noClass, placeholder = props.placeholder, autoFocus = props.autoFocus, enable = props.enable, onDisabled = props.onDisabled, validateEmail = props.validateEmail, onChange = props.onChange, onChangeInput = props.onChangeInput, onFocus = props.onFocus, onBlur = props.onBlur, onKeyDown = props.onKeyDown, onKeyUp = props.onKeyUp, spinner = props.spinner, _b = props.delimiter, delimiter = _b === void 0 ? '[ ,;]' : _b; | ||
var emailInputRef = React.useRef(null); | ||
var _b = __read(React.useState(false), 2), focused = _b[0], setFocused = _b[1]; | ||
var _c = __read(React.useState([]), 2), emails = _c[0], setEmails = _c[1]; | ||
var _d = __read(React.useState(''), 2), inputValue = _d[0], setInputValue = _d[1]; | ||
var _e = __read(React.useState(false), 2), spinning = _e[0], setSpinning = _e[1]; | ||
var _c = __read(React.useState(false), 2), focused = _c[0], setFocused = _c[1]; | ||
var _d = __read(React.useState([]), 2), emails = _d[0], setEmails = _d[1]; | ||
var _e = __read(React.useState(''), 2), inputValue = _e[0], setInputValue = _e[1]; | ||
var _f = __read(React.useState(false), 2), spinning = _f[0], setSpinning = _f[1]; | ||
var findEmailAddress = React.useCallback(function (value, isEnter) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -106,3 +106,3 @@ var validEmails, inputValue, re, isEmail, addEmails, splitData, setArr, arr, validateResult, validateResult; | ||
inputValue = ''; | ||
re = /[ ,;]/g; | ||
re = new RegExp(delimiter, 'g'); | ||
isEmail = validateEmail || isEmail_1.isEmail; | ||
@@ -207,3 +207,3 @@ addEmails = function (email) { | ||
}); | ||
}); }, [emails, enable, onChange, onChangeInput, onDisabled, validateEmail]); | ||
}); }, [delimiter, emails, enable, onChange, onChangeInput, onDisabled, validateEmail]); | ||
var onChangeInputValue = React.useCallback(function (value) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -262,3 +262,3 @@ return __generator(this, function (_a) { | ||
}); | ||
}); }, [findEmailAddress]); | ||
}); }, [findEmailAddress, onKeyUp]); | ||
var handleOnChange = React.useCallback(function (e) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
@@ -265,0 +265,0 @@ switch (_a.label) { |
@@ -18,3 +18,3 @@ import * as React from 'react'; | ||
enableSpinner?: boolean; | ||
style?: object; | ||
style?: React.CSSProperties; | ||
getLabel: (email: string, index: number, removeEmail: (index: number, isDisabled?: boolean) => void) => React.ReactNode; | ||
@@ -25,4 +25,5 @@ className?: string; | ||
spinner?: () => React.ReactNode; | ||
delimiter?: string; | ||
} | ||
export declare function ReactMultiEmail(props: IReactMultiEmailProps): JSX.Element; | ||
//# sourceMappingURL=ReactMultiEmail.d.ts.map |
@@ -39,3 +39,3 @@ "use strict"; | ||
function ReactMultiEmail(props) { | ||
const { id, style, getLabel, className = '', noClass, placeholder, autoFocus, enable, onDisabled, validateEmail, onChange, onChangeInput, onFocus, onBlur, onKeyDown, onKeyUp, spinner, } = props; | ||
const { id, style, getLabel, className = '', noClass, placeholder, autoFocus, enable, onDisabled, validateEmail, onChange, onChangeInput, onFocus, onBlur, onKeyDown, onKeyUp, spinner, delimiter = '[ ,;]', } = props; | ||
const emailInputRef = React.useRef(null); | ||
@@ -49,3 +49,3 @@ const [focused, setFocused] = React.useState(false); | ||
let inputValue = ''; | ||
const re = /[ ,;]/g; | ||
const re = new RegExp(delimiter, 'g'); | ||
const isEmail = validateEmail || isEmail_1.isEmail; | ||
@@ -141,3 +141,3 @@ const addEmails = (email) => { | ||
} | ||
}), [emails, enable, onChange, onChangeInput, onDisabled, validateEmail]); | ||
}), [delimiter, emails, enable, onChange, onChangeInput, onDisabled, validateEmail]); | ||
const onChangeInputValue = React.useCallback((value) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -178,3 +178,3 @@ onChangeInput === null || onChangeInput === void 0 ? void 0 : onChangeInput(value); | ||
} | ||
}), [findEmailAddress]); | ||
}), [findEmailAddress, onKeyUp]); | ||
const handleOnChange = React.useCallback((e) => __awaiter(this, void 0, void 0, function* () { return yield onChangeInputValue(e.currentTarget.value); }), [onChangeInputValue]); | ||
@@ -181,0 +181,0 @@ const handleOnBlur = React.useCallback((e) => __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "react-multi-email", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"jsnext:main": "dist/es6/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/es6/index.js", |
136
README.md
@@ -70,2 +70,138 @@ [](https://badge.fury.io/js/react-multi-email) | ||
## Props | ||
<table> | ||
<tr> | ||
<th>Property</th> | ||
<th>Type</th> | ||
<th>Default</th> | ||
<th>Description</th> | ||
</tr> | ||
<tr> | ||
<td>id</td> | ||
<td>string</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>emails</td> | ||
<td>string[]</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>onChange</td> | ||
<td>(emails: string[]) => void;</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>enable</td> | ||
<td>({ emailCnt }: { emailCnt: number }) => boolean;</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>onDisabled</td> | ||
<td>() => void;</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>onChangeInput</td> | ||
<td>(value: string) => void;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>onFocus</td> | ||
<td>() => void;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>onBlur</td> | ||
<td>() => void;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>onKeyDown</td> | ||
<td>(evt: React.KeyboardEvent<HTMLInputElement>) => void;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>onKeyUp</td> | ||
<td>(evt: React.KeyboardEvent<HTMLInputElement>) => void;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>noClass</td> | ||
<td>boolean</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>validateEmail</td> | ||
<td>(email: string) => boolean | Promise<boolean>;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>enableSpinner</td> | ||
<td>boolean</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td>style</td> | ||
<td>React.CSSProperties</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td> | ||
getLabel</td> | ||
<td> | ||
( | ||
email: string, | ||
index: number, | ||
removeEmail: (index: number, isDisabled?: boolean) => void, | ||
) => React.ReactNode; | ||
</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td> | ||
className</td> | ||
<td>string</td> | ||
<td>''</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
placeholder</td> | ||
<td>string | React.ReactNode;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td> | ||
autoFocus</td> | ||
<td>boolean;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td> | ||
spinner</td> | ||
<td>() => React.ReactNode;</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td> | ||
delimiter</td> | ||
<td>string;</td> | ||
<td>'[ ,;]'</td> | ||
</tr> | ||
</table> | ||
## License | ||
@@ -72,0 +208,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
119902
2.06%921
0.22%211
181.33%