react-multi-email
Advanced tools
Comparing version 1.0.22 to 1.0.23
@@ -61,2 +61,9 @@ "use strict"; | ||
}; | ||
var __asyncValues = (this && this.__asyncValues) || function (o) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var m = o[Symbol.asyncIterator], i; | ||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); | ||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } | ||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
@@ -97,10 +104,4 @@ var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
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]; | ||
var _k = __read(React.useState(''), 2), inputValue = _k[0], setInputValue = _k[1]; | ||
var _l = __read(React.useState(false), 2), spinning = _l[0], setSpinning = _l[1]; | ||
var initialEmailAddress = function (emails) { | ||
if (typeof emails === 'undefined') | ||
return []; | ||
var validEmails = emails.filter(function (email) { return validateEmail ? validateEmail(email) : (0, isEmail_1.isEmail)(email); }); | ||
return validEmails; | ||
}; | ||
var findEmailAddress = React.useCallback(function (value, isEnter) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -212,3 +213,2 @@ var validEmails, inputValue, re, isEmail, addEmails, setArr, arr, validateResult, validateResultWithDisplayName, email, validateResult, validateResultWithDisplayName, email; | ||
addEmails(value); | ||
setSpinning(false); | ||
} | ||
@@ -218,2 +218,3 @@ else { | ||
} | ||
setSpinning(false); | ||
_c.label = 9; | ||
@@ -327,4 +328,72 @@ case 9: return [3 /*break*/, 11]; | ||
React.useEffect(function () { | ||
setEmails(initialEmailAddress(props.emails)); | ||
}, [props.emails]); | ||
setInputValue(initialInputValue); | ||
}, [initialInputValue]); | ||
React.useEffect(function () { | ||
var _a; | ||
if (validateEmail) { | ||
(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var validEmails, _a, _b, _c, email, e_1_1; | ||
var _d, e_1, _e, _f; | ||
var _g; | ||
return __generator(this, function (_h) { | ||
switch (_h.label) { | ||
case 0: | ||
setSpinning(true); | ||
validEmails = []; | ||
_h.label = 1; | ||
case 1: | ||
_h.trys.push([1, 9, 10, 15]); | ||
_a = true, _b = __asyncValues((_g = props.emails) !== null && _g !== void 0 ? _g : []); | ||
_h.label = 2; | ||
case 2: return [4 /*yield*/, _b.next()]; | ||
case 3: | ||
if (!(_c = _h.sent(), _d = _c.done, !_d)) return [3 /*break*/, 8]; | ||
_f = _c.value; | ||
_a = false; | ||
_h.label = 4; | ||
case 4: | ||
_h.trys.push([4, , 6, 7]); | ||
email = _f; | ||
return [4 /*yield*/, validateEmail(email)]; | ||
case 5: | ||
if (_h.sent()) { | ||
validEmails.push(email); | ||
} | ||
return [3 /*break*/, 7]; | ||
case 6: | ||
_a = true; | ||
return [7 /*endfinally*/]; | ||
case 7: return [3 /*break*/, 2]; | ||
case 8: return [3 /*break*/, 15]; | ||
case 9: | ||
e_1_1 = _h.sent(); | ||
e_1 = { error: e_1_1 }; | ||
return [3 /*break*/, 15]; | ||
case 10: | ||
_h.trys.push([10, , 13, 14]); | ||
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 12]; | ||
return [4 /*yield*/, _e.call(_b)]; | ||
case 11: | ||
_h.sent(); | ||
_h.label = 12; | ||
case 12: return [3 /*break*/, 14]; | ||
case 13: | ||
if (e_1) throw e_1.error; | ||
return [7 /*endfinally*/]; | ||
case 14: return [7 /*endfinally*/]; | ||
case 15: | ||
setEmails(validEmails); | ||
setSpinning(false); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); })(); | ||
} | ||
else { | ||
var validEmails = (_a = props.emails) === null || _a === void 0 ? void 0 : _a.filter(function (email) { | ||
return (0, isEmail_1.isEmail)(email); | ||
}); | ||
setEmails(validEmails !== null && validEmails !== void 0 ? validEmails : []); | ||
} | ||
}, [props.emails, validateEmail]); | ||
return (React.createElement("div", { className: "".concat(className, " ").concat(noClass ? '' : 'react-multi-email', " ").concat(focused ? 'focused' : '', " ").concat(inputValue === '' && emails.length === 0 ? 'empty' : 'fill'), style: style, onClick: function () { var _a; return (_a = emailInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } }, | ||
@@ -331,0 +400,0 @@ spinning && (spinner === null || spinner === void 0 ? void 0 : spinner()), |
@@ -34,2 +34,9 @@ "use strict"; | ||
}; | ||
var __asyncValues = (this && this.__asyncValues) || function (o) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var m = o[Symbol.asyncIterator], i; | ||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); | ||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } | ||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -44,10 +51,4 @@ exports.ReactMultiEmail = void 0; | ||
const [emails, setEmails] = React.useState([]); | ||
const [inputValue, setInputValue] = React.useState(initialInputValue); | ||
const [inputValue, setInputValue] = React.useState(''); | ||
const [spinning, setSpinning] = React.useState(false); | ||
const initialEmailAddress = (emails) => { | ||
if (typeof emails === 'undefined') | ||
return []; | ||
const validEmails = emails.filter(email => validateEmail ? validateEmail(email) : (0, isEmail_1.isEmail)(email)); | ||
return validEmails; | ||
}; | ||
const findEmailAddress = React.useCallback((value, isEnter) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -151,3 +152,2 @@ var _a, _b; | ||
addEmails(value); | ||
setSpinning(false); | ||
} | ||
@@ -157,2 +157,3 @@ else { | ||
} | ||
setSpinning(false); | ||
} | ||
@@ -233,4 +234,45 @@ } | ||
React.useEffect(() => { | ||
setEmails(initialEmailAddress(props.emails)); | ||
}, [props.emails]); | ||
setInputValue(initialInputValue); | ||
}, [initialInputValue]); | ||
React.useEffect(() => { | ||
var _a; | ||
if (validateEmail) { | ||
(() => __awaiter(this, void 0, void 0, function* () { | ||
var _b, e_1, _c, _d; | ||
var _e; | ||
setSpinning(true); | ||
const validEmails = []; | ||
try { | ||
for (var _f = true, _g = __asyncValues((_e = props.emails) !== null && _e !== void 0 ? _e : []), _h; _h = yield _g.next(), _b = _h.done, !_b;) { | ||
_d = _h.value; | ||
_f = false; | ||
try { | ||
const email = _d; | ||
if (yield validateEmail(email)) { | ||
validEmails.push(email); | ||
} | ||
} | ||
finally { | ||
_f = true; | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (!_f && !_b && (_c = _g.return)) yield _c.call(_g); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
setEmails(validEmails); | ||
setSpinning(false); | ||
}))(); | ||
} | ||
else { | ||
const validEmails = (_a = props.emails) === null || _a === void 0 ? void 0 : _a.filter(email => { | ||
return (0, isEmail_1.isEmail)(email); | ||
}); | ||
setEmails(validEmails !== null && validEmails !== void 0 ? validEmails : []); | ||
} | ||
}, [props.emails, validateEmail]); | ||
return (React.createElement("div", { className: `${className} ${noClass ? '' : 'react-multi-email'} ${focused ? 'focused' : ''} ${inputValue === '' && emails.length === 0 ? 'empty' : 'fill'}`, style: style, onClick: () => { var _a; return (_a = emailInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } }, | ||
@@ -237,0 +279,0 @@ spinning && (spinner === null || spinner === void 0 ? void 0 : spinner()), |
{ | ||
"name": "react-multi-email", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"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
133239
1146