react-multi-email
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -98,6 +98,6 @@ "use strict"; | ||
var _this = this; | ||
var id = props.id, style = props.style, propsEmails = props.emails, _a = props.className, className = _a === void 0 ? '' : _a, noClass = props.noClass, placeholder = props.placeholder, autoFocus = props.autoFocus, _b = props.allowDisplayName, allowDisplayName = _b === void 0 ? false : _b, _c = props.stripDisplayName, stripDisplayName = _c === void 0 ? false : _c, _d = props.allowDuplicate, allowDuplicate = _d === void 0 ? false : _d, _e = props.delimiter, delimiter = _e === void 0 ? "[".concat(allowDisplayName ? '' : ' ', ",;]") : _e, _f = props.initialInputValue, initialInputValue = _f === void 0 ? '' : _f, inputClassName = props.inputClassName, autoComplete = props.autoComplete, getLabel = props.getLabel, 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, _g = props.disableOnBlurValidation, disableOnBlurValidation = _g === void 0 ? false : _g; | ||
var id = props.id, style = props.style, _a = props.className, className = _a === void 0 ? '' : _a, noClass = props.noClass, placeholder = props.placeholder, autoFocus = props.autoFocus, _b = props.allowDisplayName, allowDisplayName = _b === void 0 ? false : _b, _c = props.stripDisplayName, stripDisplayName = _c === void 0 ? false : _c, _d = props.allowDuplicate, allowDuplicate = _d === void 0 ? false : _d, _e = props.delimiter, delimiter = _e === void 0 ? "[".concat(allowDisplayName ? '' : ' ', ",;]") : _e, _f = props.initialInputValue, initialInputValue = _f === void 0 ? '' : _f, inputClassName = props.inputClassName, autoComplete = props.autoComplete, getLabel = props.getLabel, 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, _g = props.disableOnBlurValidation, disableOnBlurValidation = _g === void 0 ? false : _g; | ||
var emailInputRef = React.useRef(null); | ||
var _h = __read(React.useState(false), 2), focused = _h[0], setFocused = _h[1]; | ||
var _j = __read(React.useState(function () { return initialEmailAddress(propsEmails); }), 2), emails = _j[0], setEmails = _j[1]; | ||
var _j = __read(React.useState([]), 2), emails = _j[0], setEmails = _j[1]; | ||
var _k = __read(React.useState(initialInputValue), 2), inputValue = _k[0], setInputValue = _k[1]; | ||
@@ -239,3 +239,14 @@ var _l = __read(React.useState(false), 2), spinning = _l[0], setSpinning = _l[1]; | ||
}); | ||
}); }, [allowDisplayName, delimiter, emails, enable, onChange, onChangeInput, onDisabled, stripDisplayName, validateEmail]); | ||
}); }, [ | ||
allowDisplayName, | ||
allowDuplicate, | ||
delimiter, | ||
emails, | ||
enable, | ||
onChange, | ||
onChangeInput, | ||
onDisabled, | ||
stripDisplayName, | ||
validateEmail, | ||
]); | ||
var onChangeInputValue = React.useCallback(function (value) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -319,2 +330,5 @@ return __generator(this, function (_a) { | ||
}, [onFocus]); | ||
React.useEffect(function () { | ||
setEmails(initialEmailAddress(props.emails)); | ||
}, [props.emails]); | ||
return (React.createElement("div", { className: "".concat(className, " ").concat(noClass ? '' : 'react-multi-email', " ").concat(focused ? 'focused' : '', " ").concat(inputValue === '' && emails.length === 0 ? 'empty' : ''), style: style, onClick: function () { var _a; return (_a = emailInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } }, | ||
@@ -321,0 +335,0 @@ spinning && (spinner === null || spinner === void 0 ? void 0 : spinner()), |
@@ -45,6 +45,6 @@ "use strict"; | ||
function ReactMultiEmail(props) { | ||
const { id, style, emails: propsEmails, className = '', noClass, placeholder, autoFocus, allowDisplayName = false, stripDisplayName = false, allowDuplicate = false, delimiter = `[${allowDisplayName ? '' : ' '},;]`, initialInputValue = '', inputClassName, autoComplete, getLabel, enable, onDisabled, validateEmail, onChange, onChangeInput, onFocus, onBlur, onKeyDown, onKeyUp, spinner, disableOnBlurValidation = false, } = props; | ||
const { id, style, className = '', noClass, placeholder, autoFocus, allowDisplayName = false, stripDisplayName = false, allowDuplicate = false, delimiter = `[${allowDisplayName ? '' : ' '},;]`, initialInputValue = '', inputClassName, autoComplete, getLabel, enable, onDisabled, validateEmail, onChange, onChangeInput, onFocus, onBlur, onKeyDown, onKeyUp, spinner, disableOnBlurValidation = false, } = props; | ||
const emailInputRef = React.useRef(null); | ||
const [focused, setFocused] = React.useState(false); | ||
const [emails, setEmails] = React.useState(() => initialEmailAddress(propsEmails)); | ||
const [emails, setEmails] = React.useState([]); | ||
const [inputValue, setInputValue] = React.useState(initialInputValue); | ||
@@ -175,3 +175,14 @@ const [spinning, setSpinning] = React.useState(false); | ||
} | ||
}), [allowDisplayName, delimiter, emails, enable, onChange, onChangeInput, onDisabled, stripDisplayName, validateEmail]); | ||
}), [ | ||
allowDisplayName, | ||
allowDuplicate, | ||
delimiter, | ||
emails, | ||
enable, | ||
onChange, | ||
onChangeInput, | ||
onDisabled, | ||
stripDisplayName, | ||
validateEmail, | ||
]); | ||
const onChangeInputValue = React.useCallback((value) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -224,2 +235,5 @@ yield findEmailAddress(value); | ||
}, [onFocus]); | ||
React.useEffect(() => { | ||
setEmails(initialEmailAddress(props.emails)); | ||
}, [props.emails]); | ||
return (React.createElement("div", { className: `${className} ${noClass ? '' : 'react-multi-email'} ${focused ? 'focused' : ''} ${inputValue === '' && emails.length === 0 ? 'empty' : ''}`, style: style, onClick: () => { var _a; return (_a = emailInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } }, | ||
@@ -226,0 +240,0 @@ spinning && (spinner === null || spinner === void 0 ? void 0 : spinner()), |
{ | ||
"name": "react-multi-email", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"jsnext:main": "dist/es6/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/es6/index.js", |
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
127795
1046