New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wadehrarshpreet/nbform

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wadehrarshpreet/nbform - npm Package Compare versions

Comparing version 0.0.1-alpha.9 to 0.0.1-alpha.10

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [0.0.1-alpha.10](https://github.com/wadehrarshpreet/nbform/compare/v0.0.1-alpha.9...v0.0.1-alpha.10) (2019-12-27)
### Features
* customValidation support async function ([efb0f4e](https://github.com/wadehrarshpreet/nbform/commit/efb0f4e6a27a06bf883b639862f00649a05a5ec3))
### [0.0.1-alpha.9](https://github.com/wadehrarshpreet/nbform/compare/v0.0.1-alpha.8...v0.0.1-alpha.9) (2019-12-26)

@@ -7,0 +14,0 @@

625

dist/cjs/NbForm/validation.js

@@ -8,4 +8,8 @@ "use strict";

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _lodash = _interopRequireDefault(require("lodash.get"));

@@ -15,4 +19,3 @@

var _NbFormUtil = require("./NbFormUtil");
/* eslint-disable no-await-in-loop */
function validateEmail(email) {

@@ -32,314 +35,432 @@ // eslint-disable-next-line

var checkValidation = function (_ref, value, validationRule, data) {
var type = _ref.type,
id = _ref.id,
_ref$subType = _ref.subType,
inputType = _ref$subType === void 0 ? '' : _ref$subType;
var checkValidation =
/*#__PURE__*/
function () {
var _ref2 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(_ref, value, validationRule, data) {
var type, id, _ref$subType, inputType, isError, error, formData, extraProps, _validationRule, minlength, required, min, max, _validationRule$dataT, dataType, validateValue, customValidation, result, customError, _result$, customType, res, _res, _customError, _customType, isLengthError, processValue, inValidInput, _isLengthError, _isLengthError2;
if (validationRule === void 0) {
validationRule = {};
}
return _regenerator["default"].wrap(function (_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
type = _ref.type, id = _ref.id, _ref$subType = _ref.subType, inputType = _ref$subType === void 0 ? '' : _ref$subType;
var isError = false;
var error = [];
var formData = (0, _lodash["default"])(data, 'formData') || {};
var extraProps = (0, _lodash["default"])(data, 'extraProps') || {};
if (validationRule === void 0) {
validationRule = {};
}
if (validationRule) {
var _validationRule = validationRule,
minlength = _validationRule.minlength,
required = _validationRule.required,
min = _validationRule.min,
max = _validationRule.max,
_validationRule$dataT = _validationRule.dataType,
dataType = _validationRule$dataT === void 0 ? '' : _validationRule$dataT,
validateValue = _validationRule.value,
customValidation = _validationRule.customValidation;
isError = false;
error = [];
formData = (0, _lodash["default"])(data, 'formData') || {};
extraProps = (0, _lodash["default"])(data, 'extraProps') || {};
if (typeof customValidation === 'function') {
var customFormData = {};
Object.keys(customFormData).forEach(function (key) {
customFormData[key] = (0, _NbFormUtil.reshapeObject)(formData[key], {
value: true,
isError: true
});
});
var result = customValidation(value, customFormData, extraProps);
if (!validationRule) {
_context.next = 37;
break;
}
if (typeof result === 'boolean' && result) {
isError = result;
error.push('default');
} else if ((0, _typeof2["default"])(result) === 'object' && Array.isArray(result)) {
var customError = result[0],
_result$ = result[1],
customType = _result$ === void 0 ? 'default' : _result$;
_validationRule = validationRule, minlength = _validationRule.minlength, required = _validationRule.required, min = _validationRule.min, max = _validationRule.max, _validationRule$dataT = _validationRule.dataType, dataType = _validationRule$dataT === void 0 ? '' : _validationRule$dataT, validateValue = _validationRule.value, customValidation = _validationRule.customValidation;
if (customError) {
isError = customError;
error.push(customType);
}
} else if ((0, _typeof2["default"])(result) === 'object' && typeof result.isError === 'boolean') {
var _customError = result.isError,
_customType = result.type;
if (!(typeof customValidation === 'function')) {
_context.next = 30;
break;
}
if (_customError) {
isError = _customError;
error.push(_customType);
}
} else {
console.warn('Skipping NbForm-CustomValidation Invalid Return Data check Docs.');
}
}
result = customValidation(value, (0, _NbFormState.getKeyValue)(formData), extraProps);
if (typeof validateValue !== 'undefined' && validateValue !== value) {
isError = true;
error.push('value');
}
if (!(typeof result === 'boolean' && result)) {
_context.next = 15;
break;
}
if (value === undefined || value === null || typeof value === 'string' && value.length === 0) {
if (required) {
isError = true;
}
isError = result;
error.push('default');
_context.next = 30;
break;
error.push('required');
}
case 15:
if (!((0, _typeof2["default"])(result) === 'object' && Array.isArray(result))) {
_context.next = 20;
break;
}
if (minlength !== undefined) {
var isLengthError = value.toString().trim().length < minlength;
customError = result[0], _result$ = result[1], customType = _result$ === void 0 ? 'default' : _result$;
if (isLengthError) {
isError = true;
error.push('minlength');
}
}
if (customError) {
isError = customError;
error.push(customType);
}
var processValue = value;
_context.next = 30;
break;
if (type === 'location-autocomplete' && required) {
if (!value.selectedAddress) {
isError = true;
}
}
case 20:
if (!(result !== null && (0, _typeof2["default"])(result) === 'object')) {
_context.next = 29;
break;
}
if (type === 'input' && (inputType === 'email' || dataType === 'email')) {
if (!validateEmail(value)) {
isError = true;
error.push('type', 'dataType');
}
} // only for number or data type int/float for now
res = result;
if (!(typeof result.then === 'function')) {
_context.next = 26;
break;
}
if (type === 'input' && inputType === 'number' || ['int', 'float'].indexOf(dataType) !== -1) {
var inValidInput = false; // check valid number input
// eslint-disable-next-line
_context.next = 25;
return result;
if (isNaN(parseFloat(value))) {
isError = true;
error.push('type', 'dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
case 25:
res = _context.sent;
case 26:
if (typeof res.isError === 'boolean') {
_res = res, _customError = _res.isError, _customType = _res.type;
if (!inValidInput && dataType === 'int' && parseInt(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (_customError) {
isError = _customError;
error.push(_customType);
}
}
_context.next = 30;
break;
if (!inValidInput && dataType === 'float' && parseFloat(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // if input is valid further checks
case 29:
console.warn('Skipping NbForm-CustomValidation Invalid Return Data check Docs.');
case 30:
if (typeof validateValue !== 'undefined' && validateValue !== value) {
isError = true;
error.push('value');
}
if (!inValidInput) {
// remove zero and characters from inputs
if (!dataType || dataType === 'float') processValue = parseFloat(value);else processValue = parseInt(value); // min length check for process value
if (value === undefined || value === null || typeof value === 'string' && value.length === 0) {
if (required) {
isError = true;
}
if (minlength !== undefined) {
var _isLengthError = processValue.toString().length < minlength;
error.push('required');
}
if (_isLengthError) {
isError = true;
error.push('minlength');
}
}
if (minlength !== undefined) {
isLengthError = value.toString().trim().length < minlength;
if (type === 'tel' && (0, _lodash["default"])(formData, [id + "_dialCode", 'value']) === '91') {
// force minlength = 10
var _isLengthError2 = processValue.toString().length < 10;
if (isLengthError) {
isError = true;
error.push('minlength');
}
}
if (_isLengthError2) {
isError = true;
error.push('minlength');
}
} // minimum value check
// eslint-disable-next-line
processValue = value;
if (type === 'location-autocomplete' && required) {
if (!value.selectedAddress) {
isError = true;
}
}
if (!isNaN(min)) {
if (value < min) {
isError = true;
error.push('min');
}
} // maximum value check
// eslint-disable-next-line
if (type === 'input' && (inputType === 'email' || dataType === 'email')) {
if (!validateEmail(value)) {
isError = true;
error.push('type', 'dataType');
}
} // only for number or data type int/float for now
if (!isNaN(max)) {
if (value > max) {
isError = true;
error.push('max');
}
if (type === 'input' && inputType === 'number' || ['int', 'float'].indexOf(dataType) !== -1) {
inValidInput = false; // check valid number input
// eslint-disable-next-line
if (isNaN(parseFloat(value))) {
isError = true;
error.push('type', 'dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (!inValidInput && dataType === 'int' && parseInt(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (!inValidInput && dataType === 'float' && parseFloat(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // if input is valid further checks
if (!inValidInput) {
// remove zero and characters from inputs
if (!dataType || dataType === 'float') processValue = parseFloat(value);else processValue = parseInt(value); // min length check for process value
if (minlength !== undefined) {
_isLengthError = processValue.toString().length < minlength;
if (_isLengthError) {
isError = true;
error.push('minlength');
}
}
if (type === 'tel' && (0, _lodash["default"])(formData, [id + "_dialCode", 'value']) === '91') {
// force minlength = 10
_isLengthError2 = processValue.toString().length < 10;
if (_isLengthError2) {
isError = true;
error.push('minlength');
}
} // minimum value check
// eslint-disable-next-line
if (!isNaN(min)) {
if (value < min) {
isError = true;
error.push('min');
}
} // maximum value check
// eslint-disable-next-line
if (!isNaN(max)) {
if (value > max) {
isError = true;
error.push('max');
}
}
}
}
case 37:
return _context.abrupt("return", {
error: error,
status: isError
});
case 38:
case "end":
return _context.stop();
}
}
}
}
}, _callee);
}));
return {
error: error,
status: isError
return function () {
return _ref2.apply(this, arguments);
};
}; // Check Each Input Validation & Prepare updateFormData object
}(); // Check Each Input Validation & Prepare updateFormData object
var prepareArguments = function (userInputs, formData, currentFormArguments, otherOptions) {
if (currentFormArguments === void 0) {
currentFormArguments = [[], [], [], []];
}
var prepareArguments =
/*#__PURE__*/
function () {
var _ref3 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2(userInputs, formData, currentFormArguments, otherOptions) {
var updateFormDataArguments, anyError, _otherOptions, _otherOptions$isGroup, isGroupInput, _otherOptions$groupVa, groupValidation, _otherOptions$extraPr, extraProps, inputFieldFilled, index, userInput, _userInput$id, id, validation, _userInput$errorMsg, errorMsg, type, groupId, gErrorLog, _ref4, value, _ref5, isError, errorType, eType, groupErrorLog;
if (otherOptions === void 0) {
otherOptions = {};
}
return _regenerator["default"].wrap(function (_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (currentFormArguments === void 0) {
currentFormArguments = [[], [], [], []];
}
var updateFormDataArguments = [].concat(currentFormArguments);
var anyError = false;
var _otherOptions = otherOptions,
_otherOptions$isGroup = _otherOptions.isGroupInput,
isGroupInput = _otherOptions$isGroup === void 0 ? false : _otherOptions$isGroup,
_otherOptions$groupVa = _otherOptions.groupValidation,
groupValidation = _otherOptions$groupVa === void 0 ? {} : _otherOptions$groupVa,
_otherOptions$extraPr = _otherOptions.extraProps,
extraProps = _otherOptions$extraPr === void 0 ? {} : _otherOptions$extraPr;
var inputFieldFilled = 0;
userInputs.forEach(function (userInput, index) {
var _userInput$id = userInput.id,
id = _userInput$id === void 0 ? '' : _userInput$id,
validation = userInput.validation,
_userInput$errorMsg = userInput.errorMsg,
errorMsg = _userInput$errorMsg === void 0 ? {} : _userInput$errorMsg,
type = userInput.type;
if (otherOptions === void 0) {
otherOptions = {};
}
if (type === 'inputGroup') {
if ((0, _typeof2["default"])(userInput.input) === 'object' && Array.isArray(userInput.input)) {
// let groupError = false;
var gErrorLog = {};
updateFormDataArguments = [].concat(currentFormArguments);
anyError = false;
_otherOptions = otherOptions, _otherOptions$isGroup = _otherOptions.isGroupInput, isGroupInput = _otherOptions$isGroup === void 0 ? false : _otherOptions$isGroup, _otherOptions$groupVa = _otherOptions.groupValidation, groupValidation = _otherOptions$groupVa === void 0 ? {} : _otherOptions$groupVa, _otherOptions$extraPr = _otherOptions.extraProps, extraProps = _otherOptions$extraPr === void 0 ? {} : _otherOptions$extraPr;
inputFieldFilled = 0;
index = 0;
var _prepareArguments = prepareArguments(userInput.input, formData, updateFormDataArguments, {
isGroupInput: true,
groupValidation: validation,
extraProps: extraProps
});
case 7:
if (!(index < userInputs.length)) {
_context2.next = 37;
break;
}
updateFormDataArguments = _prepareArguments[0];
anyError = _prepareArguments[1];
gErrorLog = _prepareArguments[2].groupErrorLog;
userInput = userInputs[index];
_userInput$id = userInput.id, id = _userInput$id === void 0 ? '' : _userInput$id, validation = userInput.validation, _userInput$errorMsg = userInput.errorMsg, errorMsg = _userInput$errorMsg === void 0 ? {} : _userInput$errorMsg, type = userInput.type;
if (gErrorLog && gErrorLog.type.indexOf('required') === -1) {
inputFieldFilled += 1;
}
if (!(type === 'inputGroup')) {
_context2.next = 23;
break;
}
if (gErrorLog.isError) {
updateFormDataArguments[0].push(id || "group-" + index);
updateFormDataArguments[1].push('');
updateFormDataArguments[2].push(gErrorLog.isError);
updateFormDataArguments[3].push(gErrorLog.isError ? errorMsg[(0, _lodash["default"])(gErrorLog, 'type.0')] || errorMsg["default"] : '');
}
}
groupId = id || "group-" + index;
return;
}
if (!((0, _typeof2["default"])(userInput.input) === 'object' && Array.isArray(userInput.input))) {
_context2.next = 22;
break;
}
var value = (0, _lodash["default"])(formData, [id, 'value']) || '';
// let groupError = false;
gErrorLog = {};
_context2.next = 16;
return prepareArguments(userInput.input, formData, updateFormDataArguments, {
isGroupInput: true,
groupValidation: validation,
extraProps: extraProps
});
var _checkValidation = checkValidation(userInput, value, validation, {
formData: formData,
extraProps: extraProps
}),
isError = _checkValidation.status,
errorType = _checkValidation.error;
case 16:
_ref4 = _context2.sent;
updateFormDataArguments = _ref4[0];
anyError = _ref4[1];
gErrorLog = _ref4[2].groupErrorLog;
if (isError === true) {
anyError = true;
}
if (gErrorLog && gErrorLog.type.indexOf('required') === -1) {
inputFieldFilled += 1;
}
var eType = errorType || [];
if (gErrorLog.isError) {
updateFormDataArguments[0].push(groupId);
updateFormDataArguments[1].push('');
updateFormDataArguments[2].push(gErrorLog.isError);
updateFormDataArguments[3].push(gErrorLog.isError ? errorMsg[(0, _lodash["default"])(gErrorLog, 'type.0')] || errorMsg["default"] : '');
}
if (errorType.indexOf('required') === -1) {
inputFieldFilled += 1;
}
case 22:
return _context2.abrupt("return");
if (Array.isArray(errorType) && errorType.length > 0) {
eType = errorType[0];
}
case 23:
value = (0, _lodash["default"])(formData, [id, 'value']) || '';
_context2.next = 26;
return checkValidation(userInput, value, validation, {
formData: formData,
extraProps: extraProps
});
if (isError) {
updateFormDataArguments[0].push(id);
updateFormDataArguments[1].push(value);
updateFormDataArguments[2].push(isError);
updateFormDataArguments[3].push(isError ? errorMsg[eType] || errorMsg["default"] : '');
}
});
var groupErrorLog = {
isError: false,
type: []
case 26:
_ref5 = _context2.sent;
isError = _ref5.status;
errorType = _ref5.error;
if (isError === true) {
anyError = true;
}
eType = errorType || [];
if (errorType.indexOf('required') === -1) {
inputFieldFilled += 1;
}
if (Array.isArray(errorType) && errorType.length > 0) {
eType = errorType[0];
}
if (isError) {
updateFormDataArguments[0].push(id);
updateFormDataArguments[1].push(value);
updateFormDataArguments[2].push(isError);
updateFormDataArguments[3].push(isError ? errorMsg[eType] || errorMsg["default"] : '');
}
case 34:
index++;
_context2.next = 7;
break;
case 37:
groupErrorLog = {
isError: false,
type: []
};
if (isGroupInput) {
// GROUP Validation support ['required', 'requiredAll'];
if (groupValidation && groupValidation.required === true) {
groupErrorLog = {
isError: inputFieldFilled <= 0,
type: inputFieldFilled <= 0 ? ['required'] : []
};
}
if (groupValidation.requiredAll === true) {
groupErrorLog = {
isError: inputFieldFilled === userInputs.length,
type: inputFieldFilled !== userInputs.length ? ['requiredAll'] : []
};
}
} // eslint-disable-next-line consistent-return
return _context2.abrupt("return", [updateFormDataArguments, anyError, {
groupErrorLog: groupErrorLog
}]);
case 40:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return function () {
return _ref3.apply(this, arguments);
};
}();
if (isGroupInput) {
// GROUP Validation support ['required', 'requiredAll'];
if (groupValidation && groupValidation.required === true) {
groupErrorLog = {
isError: inputFieldFilled <= 0,
type: inputFieldFilled <= 0 ? ['required'] : []
};
}
var validateAndSubmitForm =
/*#__PURE__*/
function () {
var _ref6 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee3(userInputs, formData, updateFormData, onSubmit, extraProps) {
var _ref7, updateFormDataArguments, isError;
if (groupValidation.requiredAll === true) {
groupErrorLog = {
isError: inputFieldFilled === userInputs.length,
type: inputFieldFilled !== userInputs.length ? ['requiredAll'] : []
};
}
}
return _regenerator["default"].wrap(function (_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return prepareArguments(userInputs, formData, [[], [], [], []], {
extraProps: extraProps
});
return [updateFormDataArguments, anyError, {
groupErrorLog: groupErrorLog
}];
};
case 2:
_ref7 = _context3.sent;
updateFormDataArguments = _ref7[0];
isError = false;
var validateAndSubmitForm = function (userInputs, formData, updateFormData, onSubmit, extraProps) {
var _prepareArguments2 = prepareArguments(userInputs, formData, [[], [], [], []], {
extraProps: extraProps
}),
updateFormDataArguments = _prepareArguments2[0];
if ((0, _typeof2["default"])(updateFormDataArguments[2]) === 'object' && Array.isArray(updateFormDataArguments[2])) {
updateFormDataArguments[2].forEach(function (x) {
if (x === true) isError = true;
});
}
var isError = false;
updateFormData.apply(void 0, updateFormDataArguments.concat([function (updatedFormData) {
if (typeof onSubmit === 'function') {
onSubmit(isError, (0, _NbFormState.getKeyValue)(updatedFormData), updatedFormData);
}
}]));
if ((0, _typeof2["default"])(updateFormDataArguments[2]) === 'object' && Array.isArray(updateFormDataArguments[2])) {
updateFormDataArguments[2].forEach(function (x) {
if (x === true) isError = true;
});
}
case 7:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
updateFormData.apply(void 0, updateFormDataArguments.concat([function (updatedFormData) {
if (typeof onSubmit === 'function') {
onSubmit(isError, (0, _NbFormState.getKeyValue)(updatedFormData), updatedFormData);
}
}]));
};
return function () {
return _ref6.apply(this, arguments);
};
}();
exports.validateAndSubmitForm = validateAndSubmitForm;

@@ -10,4 +10,8 @@ "use strict";

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _lodash = _interopRequireDefault(require("lodash.get"));

@@ -17,4 +21,3 @@

var _NbFormUtil = require("./NbFormUtil");
/* eslint-disable no-await-in-loop */
function validateEmail(email) {

@@ -34,314 +37,432 @@ // eslint-disable-next-line

var checkValidation = function (_ref, value, validationRule, data) {
var type = _ref.type,
id = _ref.id,
_ref$subType = _ref.subType,
inputType = _ref$subType === void 0 ? '' : _ref$subType;
var checkValidation =
/*#__PURE__*/
function () {
var _ref2 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(_ref, value, validationRule, data) {
var type, id, _ref$subType, inputType, isError, error, formData, extraProps, _validationRule, minlength, required, min, max, _validationRule$dataT, dataType, validateValue, customValidation, result, customError, _result$, customType, res, _res, _customError, _customType, isLengthError, processValue, inValidInput, _isLengthError, _isLengthError2;
if (validationRule === void 0) {
validationRule = {};
}
return _regenerator["default"].wrap(function (_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
type = _ref.type, id = _ref.id, _ref$subType = _ref.subType, inputType = _ref$subType === void 0 ? '' : _ref$subType;
var isError = false;
var error = [];
var formData = (0, _lodash["default"])(data, 'formData') || {};
var extraProps = (0, _lodash["default"])(data, 'extraProps') || {};
if (validationRule === void 0) {
validationRule = {};
}
if (validationRule) {
var _validationRule = validationRule,
minlength = _validationRule.minlength,
required = _validationRule.required,
min = _validationRule.min,
max = _validationRule.max,
_validationRule$dataT = _validationRule.dataType,
dataType = _validationRule$dataT === void 0 ? '' : _validationRule$dataT,
validateValue = _validationRule.value,
customValidation = _validationRule.customValidation;
isError = false;
error = [];
formData = (0, _lodash["default"])(data, 'formData') || {};
extraProps = (0, _lodash["default"])(data, 'extraProps') || {};
if (typeof customValidation === 'function') {
var customFormData = {};
Object.keys(customFormData).forEach(function (key) {
customFormData[key] = (0, _NbFormUtil.reshapeObject)(formData[key], {
value: true,
isError: true
});
});
var result = customValidation(value, customFormData, extraProps);
if (!validationRule) {
_context.next = 37;
break;
}
if (typeof result === 'boolean' && result) {
isError = result;
error.push('default');
} else if ((0, _typeof2["default"])(result) === 'object' && Array.isArray(result)) {
var customError = result[0],
_result$ = result[1],
customType = _result$ === void 0 ? 'default' : _result$;
_validationRule = validationRule, minlength = _validationRule.minlength, required = _validationRule.required, min = _validationRule.min, max = _validationRule.max, _validationRule$dataT = _validationRule.dataType, dataType = _validationRule$dataT === void 0 ? '' : _validationRule$dataT, validateValue = _validationRule.value, customValidation = _validationRule.customValidation;
if (customError) {
isError = customError;
error.push(customType);
}
} else if ((0, _typeof2["default"])(result) === 'object' && typeof result.isError === 'boolean') {
var _customError = result.isError,
_customType = result.type;
if (!(typeof customValidation === 'function')) {
_context.next = 30;
break;
}
if (_customError) {
isError = _customError;
error.push(_customType);
}
} else {
console.warn('Skipping NbForm-CustomValidation Invalid Return Data check Docs.');
}
}
result = customValidation(value, (0, _NbFormState.getKeyValue)(formData), extraProps);
if (typeof validateValue !== 'undefined' && validateValue !== value) {
isError = true;
error.push('value');
}
if (!(typeof result === 'boolean' && result)) {
_context.next = 15;
break;
}
if (value === undefined || value === null || typeof value === 'string' && value.length === 0) {
if (required) {
isError = true;
}
isError = result;
error.push('default');
_context.next = 30;
break;
error.push('required');
}
case 15:
if (!((0, _typeof2["default"])(result) === 'object' && Array.isArray(result))) {
_context.next = 20;
break;
}
if (minlength !== undefined) {
var isLengthError = value.toString().trim().length < minlength;
customError = result[0], _result$ = result[1], customType = _result$ === void 0 ? 'default' : _result$;
if (isLengthError) {
isError = true;
error.push('minlength');
}
}
if (customError) {
isError = customError;
error.push(customType);
}
var processValue = value;
_context.next = 30;
break;
if (type === 'location-autocomplete' && required) {
if (!value.selectedAddress) {
isError = true;
}
}
case 20:
if (!(result !== null && (0, _typeof2["default"])(result) === 'object')) {
_context.next = 29;
break;
}
if (type === 'input' && (inputType === 'email' || dataType === 'email')) {
if (!validateEmail(value)) {
isError = true;
error.push('type', 'dataType');
}
} // only for number or data type int/float for now
res = result;
if (!(typeof result.then === 'function')) {
_context.next = 26;
break;
}
if (type === 'input' && inputType === 'number' || ['int', 'float'].indexOf(dataType) !== -1) {
var inValidInput = false; // check valid number input
// eslint-disable-next-line
_context.next = 25;
return result;
if (isNaN(parseFloat(value))) {
isError = true;
error.push('type', 'dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
case 25:
res = _context.sent;
case 26:
if (typeof res.isError === 'boolean') {
_res = res, _customError = _res.isError, _customType = _res.type;
if (!inValidInput && dataType === 'int' && parseInt(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (_customError) {
isError = _customError;
error.push(_customType);
}
}
_context.next = 30;
break;
if (!inValidInput && dataType === 'float' && parseFloat(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // if input is valid further checks
case 29:
console.warn('Skipping NbForm-CustomValidation Invalid Return Data check Docs.');
case 30:
if (typeof validateValue !== 'undefined' && validateValue !== value) {
isError = true;
error.push('value');
}
if (!inValidInput) {
// remove zero and characters from inputs
if (!dataType || dataType === 'float') processValue = parseFloat(value);else processValue = parseInt(value); // min length check for process value
if (value === undefined || value === null || typeof value === 'string' && value.length === 0) {
if (required) {
isError = true;
}
if (minlength !== undefined) {
var _isLengthError = processValue.toString().length < minlength;
error.push('required');
}
if (_isLengthError) {
isError = true;
error.push('minlength');
}
}
if (minlength !== undefined) {
isLengthError = value.toString().trim().length < minlength;
if (type === 'tel' && (0, _lodash["default"])(formData, [id + "_dialCode", 'value']) === '91') {
// force minlength = 10
var _isLengthError2 = processValue.toString().length < 10;
if (isLengthError) {
isError = true;
error.push('minlength');
}
}
if (_isLengthError2) {
isError = true;
error.push('minlength');
}
} // minimum value check
// eslint-disable-next-line
processValue = value;
if (type === 'location-autocomplete' && required) {
if (!value.selectedAddress) {
isError = true;
}
}
if (!isNaN(min)) {
if (value < min) {
isError = true;
error.push('min');
}
} // maximum value check
// eslint-disable-next-line
if (type === 'input' && (inputType === 'email' || dataType === 'email')) {
if (!validateEmail(value)) {
isError = true;
error.push('type', 'dataType');
}
} // only for number or data type int/float for now
if (!isNaN(max)) {
if (value > max) {
isError = true;
error.push('max');
}
if (type === 'input' && inputType === 'number' || ['int', 'float'].indexOf(dataType) !== -1) {
inValidInput = false; // check valid number input
// eslint-disable-next-line
if (isNaN(parseFloat(value))) {
isError = true;
error.push('type', 'dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (!inValidInput && dataType === 'int' && parseInt(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (!inValidInput && dataType === 'float' && parseFloat(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // if input is valid further checks
if (!inValidInput) {
// remove zero and characters from inputs
if (!dataType || dataType === 'float') processValue = parseFloat(value);else processValue = parseInt(value); // min length check for process value
if (minlength !== undefined) {
_isLengthError = processValue.toString().length < minlength;
if (_isLengthError) {
isError = true;
error.push('minlength');
}
}
if (type === 'tel' && (0, _lodash["default"])(formData, [id + "_dialCode", 'value']) === '91') {
// force minlength = 10
_isLengthError2 = processValue.toString().length < 10;
if (_isLengthError2) {
isError = true;
error.push('minlength');
}
} // minimum value check
// eslint-disable-next-line
if (!isNaN(min)) {
if (value < min) {
isError = true;
error.push('min');
}
} // maximum value check
// eslint-disable-next-line
if (!isNaN(max)) {
if (value > max) {
isError = true;
error.push('max');
}
}
}
}
case 37:
return _context.abrupt("return", {
error: error,
status: isError
});
case 38:
case "end":
return _context.stop();
}
}
}
}
}, _callee);
}));
return {
error: error,
status: isError
return function () {
return _ref2.apply(this, arguments);
};
}; // Check Each Input Validation & Prepare updateFormData object
}(); // Check Each Input Validation & Prepare updateFormData object
var prepareArguments = function (userInputs, formData, currentFormArguments, otherOptions) {
if (currentFormArguments === void 0) {
currentFormArguments = [[], [], [], []];
}
var prepareArguments =
/*#__PURE__*/
function () {
var _ref3 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2(userInputs, formData, currentFormArguments, otherOptions) {
var updateFormDataArguments, anyError, _otherOptions, _otherOptions$isGroup, isGroupInput, _otherOptions$groupVa, groupValidation, _otherOptions$extraPr, extraProps, inputFieldFilled, index, userInput, _userInput$id, id, validation, _userInput$errorMsg, errorMsg, type, groupId, gErrorLog, _ref4, value, _ref5, isError, errorType, eType, groupErrorLog;
if (otherOptions === void 0) {
otherOptions = {};
}
return _regenerator["default"].wrap(function (_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (currentFormArguments === void 0) {
currentFormArguments = [[], [], [], []];
}
var updateFormDataArguments = [].concat(currentFormArguments);
var anyError = false;
var _otherOptions = otherOptions,
_otherOptions$isGroup = _otherOptions.isGroupInput,
isGroupInput = _otherOptions$isGroup === void 0 ? false : _otherOptions$isGroup,
_otherOptions$groupVa = _otherOptions.groupValidation,
groupValidation = _otherOptions$groupVa === void 0 ? {} : _otherOptions$groupVa,
_otherOptions$extraPr = _otherOptions.extraProps,
extraProps = _otherOptions$extraPr === void 0 ? {} : _otherOptions$extraPr;
var inputFieldFilled = 0;
userInputs.forEach(function (userInput, index) {
var _userInput$id = userInput.id,
id = _userInput$id === void 0 ? '' : _userInput$id,
validation = userInput.validation,
_userInput$errorMsg = userInput.errorMsg,
errorMsg = _userInput$errorMsg === void 0 ? {} : _userInput$errorMsg,
type = userInput.type;
if (otherOptions === void 0) {
otherOptions = {};
}
if (type === 'inputGroup') {
if ((0, _typeof2["default"])(userInput.input) === 'object' && Array.isArray(userInput.input)) {
// let groupError = false;
var gErrorLog = {};
updateFormDataArguments = [].concat(currentFormArguments);
anyError = false;
_otherOptions = otherOptions, _otherOptions$isGroup = _otherOptions.isGroupInput, isGroupInput = _otherOptions$isGroup === void 0 ? false : _otherOptions$isGroup, _otherOptions$groupVa = _otherOptions.groupValidation, groupValidation = _otherOptions$groupVa === void 0 ? {} : _otherOptions$groupVa, _otherOptions$extraPr = _otherOptions.extraProps, extraProps = _otherOptions$extraPr === void 0 ? {} : _otherOptions$extraPr;
inputFieldFilled = 0;
index = 0;
var _prepareArguments = prepareArguments(userInput.input, formData, updateFormDataArguments, {
isGroupInput: true,
groupValidation: validation,
extraProps: extraProps
});
case 7:
if (!(index < userInputs.length)) {
_context2.next = 37;
break;
}
updateFormDataArguments = _prepareArguments[0];
anyError = _prepareArguments[1];
gErrorLog = _prepareArguments[2].groupErrorLog;
userInput = userInputs[index];
_userInput$id = userInput.id, id = _userInput$id === void 0 ? '' : _userInput$id, validation = userInput.validation, _userInput$errorMsg = userInput.errorMsg, errorMsg = _userInput$errorMsg === void 0 ? {} : _userInput$errorMsg, type = userInput.type;
if (gErrorLog && gErrorLog.type.indexOf('required') === -1) {
inputFieldFilled += 1;
}
if (!(type === 'inputGroup')) {
_context2.next = 23;
break;
}
if (gErrorLog.isError) {
updateFormDataArguments[0].push(id || "group-" + index);
updateFormDataArguments[1].push('');
updateFormDataArguments[2].push(gErrorLog.isError);
updateFormDataArguments[3].push(gErrorLog.isError ? errorMsg[(0, _lodash["default"])(gErrorLog, 'type.0')] || errorMsg["default"] : '');
}
}
groupId = id || "group-" + index;
return;
}
if (!((0, _typeof2["default"])(userInput.input) === 'object' && Array.isArray(userInput.input))) {
_context2.next = 22;
break;
}
var value = (0, _lodash["default"])(formData, [id, 'value']) || '';
// let groupError = false;
gErrorLog = {};
_context2.next = 16;
return prepareArguments(userInput.input, formData, updateFormDataArguments, {
isGroupInput: true,
groupValidation: validation,
extraProps: extraProps
});
var _checkValidation = checkValidation(userInput, value, validation, {
formData: formData,
extraProps: extraProps
}),
isError = _checkValidation.status,
errorType = _checkValidation.error;
case 16:
_ref4 = _context2.sent;
updateFormDataArguments = _ref4[0];
anyError = _ref4[1];
gErrorLog = _ref4[2].groupErrorLog;
if (isError === true) {
anyError = true;
}
if (gErrorLog && gErrorLog.type.indexOf('required') === -1) {
inputFieldFilled += 1;
}
var eType = errorType || [];
if (gErrorLog.isError) {
updateFormDataArguments[0].push(groupId);
updateFormDataArguments[1].push('');
updateFormDataArguments[2].push(gErrorLog.isError);
updateFormDataArguments[3].push(gErrorLog.isError ? errorMsg[(0, _lodash["default"])(gErrorLog, 'type.0')] || errorMsg["default"] : '');
}
if (errorType.indexOf('required') === -1) {
inputFieldFilled += 1;
}
case 22:
return _context2.abrupt("return");
if (Array.isArray(errorType) && errorType.length > 0) {
eType = errorType[0];
}
case 23:
value = (0, _lodash["default"])(formData, [id, 'value']) || '';
_context2.next = 26;
return checkValidation(userInput, value, validation, {
formData: formData,
extraProps: extraProps
});
if (isError) {
updateFormDataArguments[0].push(id);
updateFormDataArguments[1].push(value);
updateFormDataArguments[2].push(isError);
updateFormDataArguments[3].push(isError ? errorMsg[eType] || errorMsg["default"] : '');
}
});
var groupErrorLog = {
isError: false,
type: []
case 26:
_ref5 = _context2.sent;
isError = _ref5.status;
errorType = _ref5.error;
if (isError === true) {
anyError = true;
}
eType = errorType || [];
if (errorType.indexOf('required') === -1) {
inputFieldFilled += 1;
}
if (Array.isArray(errorType) && errorType.length > 0) {
eType = errorType[0];
}
if (isError) {
updateFormDataArguments[0].push(id);
updateFormDataArguments[1].push(value);
updateFormDataArguments[2].push(isError);
updateFormDataArguments[3].push(isError ? errorMsg[eType] || errorMsg["default"] : '');
}
case 34:
index++;
_context2.next = 7;
break;
case 37:
groupErrorLog = {
isError: false,
type: []
};
if (isGroupInput) {
// GROUP Validation support ['required', 'requiredAll'];
if (groupValidation && groupValidation.required === true) {
groupErrorLog = {
isError: inputFieldFilled <= 0,
type: inputFieldFilled <= 0 ? ['required'] : []
};
}
if (groupValidation.requiredAll === true) {
groupErrorLog = {
isError: inputFieldFilled === userInputs.length,
type: inputFieldFilled !== userInputs.length ? ['requiredAll'] : []
};
}
} // eslint-disable-next-line consistent-return
return _context2.abrupt("return", [updateFormDataArguments, anyError, {
groupErrorLog: groupErrorLog
}]);
case 40:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return function () {
return _ref3.apply(this, arguments);
};
}();
if (isGroupInput) {
// GROUP Validation support ['required', 'requiredAll'];
if (groupValidation && groupValidation.required === true) {
groupErrorLog = {
isError: inputFieldFilled <= 0,
type: inputFieldFilled <= 0 ? ['required'] : []
};
}
var validateAndSubmitForm =
/*#__PURE__*/
function () {
var _ref6 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee3(userInputs, formData, updateFormData, onSubmit, extraProps) {
var _ref7, updateFormDataArguments, isError;
if (groupValidation.requiredAll === true) {
groupErrorLog = {
isError: inputFieldFilled === userInputs.length,
type: inputFieldFilled !== userInputs.length ? ['requiredAll'] : []
};
}
}
return _regenerator["default"].wrap(function (_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return prepareArguments(userInputs, formData, [[], [], [], []], {
extraProps: extraProps
});
return [updateFormDataArguments, anyError, {
groupErrorLog: groupErrorLog
}];
};
case 2:
_ref7 = _context3.sent;
updateFormDataArguments = _ref7[0];
isError = false;
var validateAndSubmitForm = function (userInputs, formData, updateFormData, onSubmit, extraProps) {
var _prepareArguments2 = prepareArguments(userInputs, formData, [[], [], [], []], {
extraProps: extraProps
}),
updateFormDataArguments = _prepareArguments2[0];
if ((0, _typeof2["default"])(updateFormDataArguments[2]) === 'object' && Array.isArray(updateFormDataArguments[2])) {
updateFormDataArguments[2].forEach(function (x) {
if (x === true) isError = true;
});
}
var isError = false;
updateFormData.apply(void 0, updateFormDataArguments.concat([function (updatedFormData) {
if (typeof onSubmit === 'function') {
onSubmit(isError, (0, _NbFormState.getKeyValue)(updatedFormData), updatedFormData);
}
}]));
if ((0, _typeof2["default"])(updateFormDataArguments[2]) === 'object' && Array.isArray(updateFormDataArguments[2])) {
updateFormDataArguments[2].forEach(function (x) {
if (x === true) isError = true;
});
}
case 7:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
updateFormData.apply(void 0, updateFormDataArguments.concat([function (updatedFormData) {
if (typeof onSubmit === 'function') {
onSubmit(isError, (0, _NbFormState.getKeyValue)(updatedFormData), updatedFormData);
}
}]));
};
return function () {
return _ref6.apply(this, arguments);
};
}();
exports.validateAndSubmitForm = validateAndSubmitForm;

@@ -12,2 +12,4 @@ "use strict";

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

@@ -17,2 +19,4 @@

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _lodash = _interopRequireDefault(require("lodash.get"));

@@ -22,4 +26,3 @@

var _NbFormUtil = require("./NbFormUtil");
/* eslint-disable no-await-in-loop */
function validateEmail(email) {

@@ -39,311 +42,488 @@ // eslint-disable-next-line

var checkValidation = function (_ref, value) {
var type = _ref.type,
id = _ref.id,
_ref$subType = _ref.subType,
inputType = _ref$subType === void 0 ? '' : _ref$subType;
var validationRule = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var data = arguments.length > 3 ? arguments[3] : undefined;
var isError = false;
var error = [];
var formData = (0, _lodash["default"])(data, 'formData') || {};
var extraProps = (0, _lodash["default"])(data, 'extraProps') || {};
var checkValidation =
/*#__PURE__*/
function () {
var _ref2 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(_ref, value) {
var type,
id,
_ref$subType,
inputType,
validationRule,
data,
isError,
error,
formData,
extraProps,
minlength,
required,
min,
max,
_validationRule$dataT,
dataType,
validateValue,
customValidation,
result,
_result,
customError,
_result$,
customType,
res,
_res,
_customError,
_customType,
isLengthError,
processValue,
inValidInput,
_isLengthError,
_isLengthError2,
_args = arguments;
if (validationRule) {
var minlength = validationRule.minlength,
required = validationRule.required,
min = validationRule.min,
max = validationRule.max,
_validationRule$dataT = validationRule.dataType,
dataType = _validationRule$dataT === void 0 ? '' : _validationRule$dataT,
validateValue = validationRule.value,
customValidation = validationRule.customValidation;
return _regenerator["default"].wrap(function (_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
type = _ref.type, id = _ref.id, _ref$subType = _ref.subType, inputType = _ref$subType === void 0 ? '' : _ref$subType;
validationRule = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
data = _args.length > 3 ? _args[3] : undefined;
isError = false;
error = [];
formData = (0, _lodash["default"])(data, 'formData') || {};
extraProps = (0, _lodash["default"])(data, 'extraProps') || {};
if (typeof customValidation === 'function') {
var customFormData = {};
Object.keys(customFormData).forEach(function (key) {
customFormData[key] = (0, _NbFormUtil.reshapeObject)(formData[key], {
value: true,
isError: true
});
});
var result = customValidation(value, customFormData, extraProps);
if (!validationRule) {
_context.next = 38;
break;
}
if (typeof result === 'boolean' && result) {
isError = result;
error.push('default');
} else if ((0, _typeof2["default"])(result) === 'object' && Array.isArray(result)) {
var _result = (0, _slicedToArray2["default"])(result, 2),
customError = _result[0],
_result$ = _result[1],
customType = _result$ === void 0 ? 'default' : _result$;
minlength = validationRule.minlength, required = validationRule.required, min = validationRule.min, max = validationRule.max, _validationRule$dataT = validationRule.dataType, dataType = _validationRule$dataT === void 0 ? '' : _validationRule$dataT, validateValue = validationRule.value, customValidation = validationRule.customValidation;
if (customError) {
isError = customError;
error.push(customType);
}
} else if ((0, _typeof2["default"])(result) === 'object' && typeof result.isError === 'boolean') {
var _customError = result.isError,
_customType = result.type;
if (!(typeof customValidation === 'function')) {
_context.next = 31;
break;
}
if (_customError) {
isError = _customError;
error.push(_customType);
}
} else {
console.warn('Skipping NbForm-CustomValidation Invalid Return Data check Docs.');
}
}
result = customValidation(value, (0, _NbFormState.getKeyValue)(formData), extraProps);
if (typeof validateValue !== 'undefined' && validateValue !== value) {
isError = true;
error.push('value');
}
if (!(typeof result === 'boolean' && result)) {
_context.next = 16;
break;
}
if (value === undefined || value === null || typeof value === 'string' && value.length === 0) {
if (required) {
isError = true;
}
isError = result;
error.push('default');
_context.next = 31;
break;
error.push('required');
}
case 16:
if (!((0, _typeof2["default"])(result) === 'object' && Array.isArray(result))) {
_context.next = 21;
break;
}
if (minlength !== undefined) {
var isLengthError = value.toString().trim().length < minlength;
_result = (0, _slicedToArray2["default"])(result, 2), customError = _result[0], _result$ = _result[1], customType = _result$ === void 0 ? 'default' : _result$;
if (isLengthError) {
isError = true;
error.push('minlength');
}
}
if (customError) {
isError = customError;
error.push(customType);
}
var processValue = value;
_context.next = 31;
break;
if (type === 'location-autocomplete' && required) {
if (!value.selectedAddress) {
isError = true;
}
}
case 21:
if (!(result !== null && (0, _typeof2["default"])(result) === 'object')) {
_context.next = 30;
break;
}
if (type === 'input' && (inputType === 'email' || dataType === 'email')) {
if (!validateEmail(value)) {
isError = true;
error.push('type', 'dataType');
}
} // only for number or data type int/float for now
res = result;
if (!(typeof result.then === 'function')) {
_context.next = 27;
break;
}
if (type === 'input' && inputType === 'number' || ['int', 'float'].indexOf(dataType) !== -1) {
var inValidInput = false; // check valid number input
// eslint-disable-next-line
_context.next = 26;
return result;
if (isNaN(parseFloat(value))) {
isError = true;
error.push('type', 'dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
case 26:
res = _context.sent;
case 27:
if (typeof res.isError === 'boolean') {
_res = res, _customError = _res.isError, _customType = _res.type;
if (!inValidInput && dataType === 'int' && parseInt(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (_customError) {
isError = _customError;
error.push(_customType);
}
}
_context.next = 31;
break;
if (!inValidInput && dataType === 'float' && parseFloat(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // if input is valid further checks
case 30:
console.warn('Skipping NbForm-CustomValidation Invalid Return Data check Docs.');
case 31:
if (typeof validateValue !== 'undefined' && validateValue !== value) {
isError = true;
error.push('value');
}
if (!inValidInput) {
// remove zero and characters from inputs
if (!dataType || dataType === 'float') processValue = parseFloat(value);else processValue = parseInt(value); // min length check for process value
if (value === undefined || value === null || typeof value === 'string' && value.length === 0) {
if (required) {
isError = true;
}
if (minlength !== undefined) {
var _isLengthError = processValue.toString().length < minlength;
error.push('required');
}
if (_isLengthError) {
isError = true;
error.push('minlength');
}
}
if (minlength !== undefined) {
isLengthError = value.toString().trim().length < minlength;
if (type === 'tel' && (0, _lodash["default"])(formData, ["".concat(id, "_dialCode"), 'value']) === '91') {
// force minlength = 10
var _isLengthError2 = processValue.toString().length < 10;
if (isLengthError) {
isError = true;
error.push('minlength');
}
}
if (_isLengthError2) {
isError = true;
error.push('minlength');
}
} // minimum value check
// eslint-disable-next-line
processValue = value;
if (type === 'location-autocomplete' && required) {
if (!value.selectedAddress) {
isError = true;
}
}
if (!isNaN(min)) {
if (value < min) {
isError = true;
error.push('min');
}
} // maximum value check
// eslint-disable-next-line
if (type === 'input' && (inputType === 'email' || dataType === 'email')) {
if (!validateEmail(value)) {
isError = true;
error.push('type', 'dataType');
}
} // only for number or data type int/float for now
if (!isNaN(max)) {
if (value > max) {
isError = true;
error.push('max');
}
if (type === 'input' && inputType === 'number' || ['int', 'float'].indexOf(dataType) !== -1) {
inValidInput = false; // check valid number input
// eslint-disable-next-line
if (isNaN(parseFloat(value))) {
isError = true;
error.push('type', 'dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (!inValidInput && dataType === 'int' && parseInt(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // check exact datatype if required
// eslint-disable-next-line
if (!inValidInput && dataType === 'float' && parseFloat(value) != value) {
isError = true;
error.push('dataType');
inValidInput = true;
} // if input is valid further checks
if (!inValidInput) {
// remove zero and characters from inputs
if (!dataType || dataType === 'float') processValue = parseFloat(value);else processValue = parseInt(value); // min length check for process value
if (minlength !== undefined) {
_isLengthError = processValue.toString().length < minlength;
if (_isLengthError) {
isError = true;
error.push('minlength');
}
}
if (type === 'tel' && (0, _lodash["default"])(formData, ["".concat(id, "_dialCode"), 'value']) === '91') {
// force minlength = 10
_isLengthError2 = processValue.toString().length < 10;
if (_isLengthError2) {
isError = true;
error.push('minlength');
}
} // minimum value check
// eslint-disable-next-line
if (!isNaN(min)) {
if (value < min) {
isError = true;
error.push('min');
}
} // maximum value check
// eslint-disable-next-line
if (!isNaN(max)) {
if (value > max) {
isError = true;
error.push('max');
}
}
}
}
case 38:
return _context.abrupt("return", {
error: error,
status: isError
});
case 39:
case "end":
return _context.stop();
}
}
}
}
}, _callee);
}));
return {
error: error,
status: isError
return function () {
return _ref2.apply(this, arguments);
};
}; // Check Each Input Validation & Prepare updateFormData object
}(); // Check Each Input Validation & Prepare updateFormData object
var prepareArguments = function (userInputs, formData) {
var currentFormArguments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [[], [], [], []];
var otherOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var updateFormDataArguments = (0, _toConsumableArray2["default"])(currentFormArguments);
var anyError = false;
var _otherOptions$isGroup = otherOptions.isGroupInput,
isGroupInput = _otherOptions$isGroup === void 0 ? false : _otherOptions$isGroup,
_otherOptions$groupVa = otherOptions.groupValidation,
groupValidation = _otherOptions$groupVa === void 0 ? {} : _otherOptions$groupVa,
_otherOptions$extraPr = otherOptions.extraProps,
extraProps = _otherOptions$extraPr === void 0 ? {} : _otherOptions$extraPr;
var inputFieldFilled = 0;
userInputs.forEach(function (userInput, index) {
var _userInput$id = userInput.id,
id = _userInput$id === void 0 ? '' : _userInput$id,
validation = userInput.validation,
_userInput$errorMsg = userInput.errorMsg,
errorMsg = _userInput$errorMsg === void 0 ? {} : _userInput$errorMsg,
type = userInput.type;
var prepareArguments =
/*#__PURE__*/
function () {
var _ref3 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2(userInputs, formData) {
var currentFormArguments,
otherOptions,
updateFormDataArguments,
anyError,
_otherOptions$isGroup,
isGroupInput,
_otherOptions$groupVa,
groupValidation,
_otherOptions$extraPr,
extraProps,
inputFieldFilled,
index,
userInput,
_userInput$id,
id,
validation,
_userInput$errorMsg,
errorMsg,
type,
groupId,
gErrorLog,
_ref4,
_ref5,
value,
_ref6,
isError,
errorType,
eType,
_errorType,
groupErrorLog,
_args2 = arguments;
if (type === 'inputGroup') {
var groupId = id || "group-".concat(index);
return _regenerator["default"].wrap(function (_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
currentFormArguments = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : [[], [], [], []];
otherOptions = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {};
updateFormDataArguments = (0, _toConsumableArray2["default"])(currentFormArguments);
anyError = false;
_otherOptions$isGroup = otherOptions.isGroupInput, isGroupInput = _otherOptions$isGroup === void 0 ? false : _otherOptions$isGroup, _otherOptions$groupVa = otherOptions.groupValidation, groupValidation = _otherOptions$groupVa === void 0 ? {} : _otherOptions$groupVa, _otherOptions$extraPr = otherOptions.extraProps, extraProps = _otherOptions$extraPr === void 0 ? {} : _otherOptions$extraPr;
inputFieldFilled = 0;
index = 0;
if ((0, _typeof2["default"])(userInput.input) === 'object' && Array.isArray(userInput.input)) {
// let groupError = false;
var gErrorLog = {};
case 7:
if (!(index < userInputs.length)) {
_context2.next = 38;
break;
}
var _prepareArguments = prepareArguments(userInput.input, formData, updateFormDataArguments, {
isGroupInput: true,
groupValidation: validation,
extraProps: extraProps
});
userInput = userInputs[index];
_userInput$id = userInput.id, id = _userInput$id === void 0 ? '' : _userInput$id, validation = userInput.validation, _userInput$errorMsg = userInput.errorMsg, errorMsg = _userInput$errorMsg === void 0 ? {} : _userInput$errorMsg, type = userInput.type;
var _prepareArguments2 = (0, _slicedToArray2["default"])(_prepareArguments, 3);
if (!(type === 'inputGroup')) {
_context2.next = 24;
break;
}
updateFormDataArguments = _prepareArguments2[0];
anyError = _prepareArguments2[1];
gErrorLog = _prepareArguments2[2].groupErrorLog;
groupId = id || "group-".concat(index);
if (gErrorLog && gErrorLog.type.indexOf('required') === -1) {
inputFieldFilled += 1;
}
if (!((0, _typeof2["default"])(userInput.input) === 'object' && Array.isArray(userInput.input))) {
_context2.next = 23;
break;
}
if (gErrorLog.isError) {
updateFormDataArguments[0].push(groupId);
updateFormDataArguments[1].push('');
updateFormDataArguments[2].push(gErrorLog.isError);
updateFormDataArguments[3].push(gErrorLog.isError ? errorMsg[(0, _lodash["default"])(gErrorLog, 'type.0')] || errorMsg["default"] : '');
}
}
// let groupError = false;
gErrorLog = {};
_context2.next = 16;
return prepareArguments(userInput.input, formData, updateFormDataArguments, {
isGroupInput: true,
groupValidation: validation,
extraProps: extraProps
});
return;
}
case 16:
_ref4 = _context2.sent;
_ref5 = (0, _slicedToArray2["default"])(_ref4, 3);
updateFormDataArguments = _ref5[0];
anyError = _ref5[1];
gErrorLog = _ref5[2].groupErrorLog;
var value = (0, _lodash["default"])(formData, [id, 'value']) || '';
if (gErrorLog && gErrorLog.type.indexOf('required') === -1) {
inputFieldFilled += 1;
}
var _checkValidation = checkValidation(userInput, value, validation, {
formData: formData,
extraProps: extraProps
}),
isError = _checkValidation.status,
errorType = _checkValidation.error;
if (gErrorLog.isError) {
updateFormDataArguments[0].push(groupId);
updateFormDataArguments[1].push('');
updateFormDataArguments[2].push(gErrorLog.isError);
updateFormDataArguments[3].push(gErrorLog.isError ? errorMsg[(0, _lodash["default"])(gErrorLog, 'type.0')] || errorMsg["default"] : '');
}
if (isError === true) {
anyError = true;
}
case 23:
return _context2.abrupt("return");
var eType = errorType || [];
case 24:
value = (0, _lodash["default"])(formData, [id, 'value']) || '';
_context2.next = 27;
return checkValidation(userInput, value, validation, {
formData: formData,
extraProps: extraProps
});
if (errorType.indexOf('required') === -1) {
inputFieldFilled += 1;
}
case 27:
_ref6 = _context2.sent;
isError = _ref6.status;
errorType = _ref6.error;
if (Array.isArray(errorType) && errorType.length > 0) {
var _errorType = (0, _slicedToArray2["default"])(errorType, 1);
if (isError === true) {
anyError = true;
}
eType = _errorType[0];
}
eType = errorType || [];
if (isError) {
updateFormDataArguments[0].push(id);
updateFormDataArguments[1].push(value);
updateFormDataArguments[2].push(isError);
updateFormDataArguments[3].push(isError ? errorMsg[eType] || errorMsg["default"] : '');
}
});
var groupErrorLog = {
isError: false,
type: []
if (errorType.indexOf('required') === -1) {
inputFieldFilled += 1;
}
if (Array.isArray(errorType) && errorType.length > 0) {
_errorType = (0, _slicedToArray2["default"])(errorType, 1);
eType = _errorType[0];
}
if (isError) {
updateFormDataArguments[0].push(id);
updateFormDataArguments[1].push(value);
updateFormDataArguments[2].push(isError);
updateFormDataArguments[3].push(isError ? errorMsg[eType] || errorMsg["default"] : '');
}
case 35:
index++;
_context2.next = 7;
break;
case 38:
groupErrorLog = {
isError: false,
type: []
};
if (isGroupInput) {
// GROUP Validation support ['required', 'requiredAll'];
if (groupValidation && groupValidation.required === true) {
groupErrorLog = {
isError: inputFieldFilled <= 0,
type: inputFieldFilled <= 0 ? ['required'] : []
};
}
if (groupValidation.requiredAll === true) {
groupErrorLog = {
isError: inputFieldFilled === userInputs.length,
type: inputFieldFilled !== userInputs.length ? ['requiredAll'] : []
};
}
} // eslint-disable-next-line consistent-return
return _context2.abrupt("return", [updateFormDataArguments, anyError, {
groupErrorLog: groupErrorLog
}]);
case 41:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return function () {
return _ref3.apply(this, arguments);
};
}();
if (isGroupInput) {
// GROUP Validation support ['required', 'requiredAll'];
if (groupValidation && groupValidation.required === true) {
groupErrorLog = {
isError: inputFieldFilled <= 0,
type: inputFieldFilled <= 0 ? ['required'] : []
};
}
var validateAndSubmitForm =
/*#__PURE__*/
function () {
var _ref7 = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee3(userInputs, formData, updateFormData, onSubmit, extraProps) {
var _ref8, _ref9, updateFormDataArguments, isError;
if (groupValidation.requiredAll === true) {
groupErrorLog = {
isError: inputFieldFilled === userInputs.length,
type: inputFieldFilled !== userInputs.length ? ['requiredAll'] : []
};
}
}
return _regenerator["default"].wrap(function (_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return prepareArguments(userInputs, formData, [[], [], [], []], {
extraProps: extraProps
});
return [updateFormDataArguments, anyError, {
groupErrorLog: groupErrorLog
}];
};
case 2:
_ref8 = _context3.sent;
_ref9 = (0, _slicedToArray2["default"])(_ref8, 1);
updateFormDataArguments = _ref9[0];
isError = false;
var validateAndSubmitForm = function (userInputs, formData, updateFormData, onSubmit, extraProps) {
var _prepareArguments3 = prepareArguments(userInputs, formData, [[], [], [], []], {
extraProps: extraProps
}),
_prepareArguments4 = (0, _slicedToArray2["default"])(_prepareArguments3, 1),
updateFormDataArguments = _prepareArguments4[0];
if ((0, _typeof2["default"])(updateFormDataArguments[2]) === 'object' && Array.isArray(updateFormDataArguments[2])) {
updateFormDataArguments[2].forEach(function (x) {
if (x === true) isError = true;
});
}
var isError = false;
updateFormData.apply(void 0, (0, _toConsumableArray2["default"])(updateFormDataArguments).concat([function (updatedFormData) {
if (typeof onSubmit === 'function') {
onSubmit(isError, (0, _NbFormState.getKeyValue)(updatedFormData), updatedFormData);
}
}]));
if ((0, _typeof2["default"])(updateFormDataArguments[2]) === 'object' && Array.isArray(updateFormDataArguments[2])) {
updateFormDataArguments[2].forEach(function (x) {
if (x === true) isError = true;
});
}
case 8:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
updateFormData.apply(void 0, (0, _toConsumableArray2["default"])(updateFormDataArguments).concat([function (updatedFormData) {
if (typeof onSubmit === 'function') {
onSubmit(isError, (0, _NbFormState.getKeyValue)(updatedFormData), updatedFormData);
}
}]));
};
return function () {
return _ref7.apply(this, arguments);
};
}();
exports.validateAndSubmitForm = validateAndSubmitForm;

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-rater"),require("react-bootstrap"),require("react-intl-tel-input"),require("react-select"),require("react-autocomplete-places")):"function"==typeof define&&define.amd?define(["react","react-rater","react-bootstrap","react-intl-tel-input","react-select","react-autocomplete-places"],t):(e=e||self)["@wadehrarshpreet/nbform"]=t(e.React,e["React-rater"],e["React-bootstrap"],e["React-intl-tel-input"],e["React-select"],e["React-autocomplete-places"])}(this,(function(e,t,r,n,o,a){"use strict";var i="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n,o=o&&o.hasOwnProperty("default")?o.default:o;var l="default"in a?a.default:a,s=function(e,t,r,n,o,a,i,l){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,o,a,i,l],c=0;(s=new Error(t.replace(/%s/g,(function(){return u[c++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}},u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(e,t){return e(t={exports:{}},t.exports),t.exports}var p=c((function(e){function t(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=t=function(e){return typeof e}:e.exports=t=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(r)}e.exports=t})),f=c((function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},t.apply(this,arguments)}e.exports=t})),d="Expected a function",h="__lodash_hash_undefined__",v=1/0,y="[object Function]",m="[object GeneratorFunction]",g="[object Symbol]",b=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,_=/^\./,C=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,x=/\\(\\)?/g,w=/^\[object .+?Constructor\]$/,S="object"==typeof u&&u&&u.Object===Object&&u,N="object"==typeof self&&self&&self.Object===Object&&self,I=S||N||Function("return this")();var P,j=Array.prototype,O=Function.prototype,k=Object.prototype,F=I["__core-js_shared__"],A=(P=/[^.]+$/.exec(F&&F.keys&&F.keys.IE_PROTO||""))?"Symbol(src)_1."+P:"",L=O.toString,T=k.hasOwnProperty,B=k.toString,R=RegExp("^"+L.call(T).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),z=I.Symbol,M=j.splice,G=J(I,"Map"),$=J(Object,"create"),D=z?z.prototype:void 0,V=D?D.toString:void 0;function q(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function W(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function K(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function H(e,t){for(var r,n,o=e.length;o--;)if((r=e[o][0])===(n=t)||r!=r&&n!=n)return o;return-1}function Y(e,t){for(var r,n=0,o=(t=function(e,t){if(te(e))return!1;var r=typeof e;if("number"==r||"symbol"==r||"boolean"==r||null==e||ne(e))return!0;return E.test(e)||!b.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:te(r=t)?r:Q(r)).length;null!=e&&n<o;)e=e[X(t[n++])];return n&&n==o?e:void 0}function U(e){return!(!re(e)||(t=e,A&&A in t))&&(function(e){var t=re(e)?B.call(e):"";return t==y||t==m}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?R:w).test(function(e){if(null!=e){try{return L.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}function Z(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function J(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return U(r)?r:void 0}q.prototype.clear=function(){this.__data__=$?$(null):{}},q.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},q.prototype.get=function(e){var t=this.__data__;if($){var r=t[e];return r===h?void 0:r}return T.call(t,e)?t[e]:void 0},q.prototype.has=function(e){var t=this.__data__;return $?void 0!==t[e]:T.call(t,e)},q.prototype.set=function(e,t){return this.__data__[e]=$&&void 0===t?h:t,this},W.prototype.clear=function(){this.__data__=[]},W.prototype.delete=function(e){var t=this.__data__,r=H(t,e);return!(r<0)&&(r==t.length-1?t.pop():M.call(t,r,1),!0)},W.prototype.get=function(e){var t=this.__data__,r=H(t,e);return r<0?void 0:t[r][1]},W.prototype.has=function(e){return H(this.__data__,e)>-1},W.prototype.set=function(e,t){var r=this.__data__,n=H(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},K.prototype.clear=function(){this.__data__={hash:new q,map:new(G||W),string:new q}},K.prototype.delete=function(e){return Z(this,e).delete(e)},K.prototype.get=function(e){return Z(this,e).get(e)},K.prototype.has=function(e){return Z(this,e).has(e)},K.prototype.set=function(e,t){return Z(this,e).set(e,t),this};var Q=ee((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ne(e))return V?V.call(e):"";var t=e+"";return"0"==t&&1/e==-v?"-0":t}(t);var r=[];return _.test(e)&&r.push(""),e.replace(C,(function(e,t,n,o){r.push(n?o.replace(x,"$1"):t||e)})),r}));function X(e){if("string"==typeof e||ne(e))return e;var t=e+"";return"0"==t&&1/e==-v?"-0":t}function ee(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(d);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=e.apply(this,n);return r.cache=a.set(o,i),i};return r.cache=new(ee.Cache||K),r}ee.Cache=K;var te=Array.isArray;function re(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ne(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&B.call(e)==g}var oe=function(e,t,r){var n=null==e?void 0:Y(e,t);return void 0===n?r:n},ae=function(e){return i.createElement(t,e)},ie=function(e){switch(e){case"place":case"places":return"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z";case"times":case"close":return"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";default:return null}},le=function(e){var t=e.color,r=e.height,n=e.width,o=e.type,a=void 0!==r?r:24,l=void 0!==n?n:24;return i.createElement("svg",f({style:{width:l+"px",height:a+"px"},viewBox:"0 0 "+a+" "+l},e),i.createElement("path",{fill:t||"#000000",d:ie(o)}))};var se=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t},ue=function(e){function t(){return e.apply(this,arguments)||this}se(t,e);var n=t.prototype;return n.getButtonClassName=function(){var e="nb-toggle-button";return this.props.size&&("lg"===this.props.size?e+=" btn-lg":"sm"===this.props.size?e+=" btn-sm":"xs"===this.props.size&&(e+=" btn-xs")),e.trim()},n.render=function(){var e=this,t=this.props,n=t.hasError,o=t.errorMsg,a=t.type,l=t.defaultValue,s=t.toggleButtonData,u=t.errorStyle,c=t.errorClass,p=void 0===c?"":c,f=t.onChange,d=t.className,h=t.containerClass,v=t.name;return i.createElement("div",{className:"nb-toggle-button-container "+(n?"has-error":"")+" "+h},i.createElement(r.ToggleButtonGroup,{type:a,value:l,onChange:f,name:v,className:d},void 0!==s&&s.length>0&&s.map((function(t,n){return i.createElement(r.ToggleButton,{id:t.value,className:e.getButtonClassName(),value:t.value,name:t.name,key:n},t.label)}))),n?i.createElement("div",{className:"nbform-err-msg "+p,style:u},o):null)},t}(e.PureComponent);ue.defaultProps={className:"",type:"radio",toggleButtonData:"",defaultValue:null,onChange:function(){},size:null};var ce=function(e){function t(t){var r=e.call(this,t)||this;return r.state={},r}return se(t,e),t.prototype.render=function(){var e=this.props,t=e.errorMsg,r=e.children,n=e.hasError,o=e.className,a=e.errorClass,l=e.wrap,s=e.containerClass,u=void 0===s?"":s,c=e.id,p=void 0===c?"":c,f=e.errorStyle;return i.createElement("div",{className:"nb_inpgrp "+u,id:p},i.createElement("div",{className:"nb__inpgrp_elements "+o,style:{flexWrap:l?"wrap":"nowrap"}},r),n?i.createElement("div",{className:"nbform-err-msg "+a,style:f},t):null)},t}(e.PureComponent);ce.defaultProps={children:null,errorMsg:"",className:"",wrap:!1};var pe=function(e){function t(t){var r=e.call(this,t)||this;return r.state={},r}return se(t,e),t.prototype.render=function(){var e,t=this.props,r=t.onChange,n=t.checked,o=t.label,a=t.errorStyle,l=t.errorClass,s=t.size,u=t.containerClass,c=void 0===u?"":u,p=t.className,f=void 0===p?"":p,d=t.textClass,h=void 0===d?"":d,v=t.id,y=t.hasError,m=t.errorMsg,g=t.labelPosition,b=void 0===g?"right":g;return i.createElement(i.Fragment,null,i.createElement("label",{className:"nb-switch "+c+" "+f,id:v},i.createElement("input",{className:"nb-switch-checkbox",type:"checkbox",onChange:r,checked:n}),i.createElement("div",{className:s?"nb-switch-toggle "+s:"nb-switch-toggle"}),o?i.createElement("span",{style:(e={cssFloat:b},e["margin-"+("left"===b?"right":"left")]="5px",e),className:"nb-switch-label "+h+" "+(y?"error-msg":"")},o):null),y?i.createElement("div",{className:"nbform-err-msg "+l,style:a},m):null)},t}(i.PureComponent);pe.defaultProps={onChange:function(){},isChecked:null,label:null};var fe=function(e){function t(t){var r=e.call(this,t)||this;return r.clearInput=function(){r.props.onChange({target:{value:""}}),r.inputEl.focus()},r.state={},r.inputEl=i.createRef(),r}se(t,e);var n=t.prototype;return n.swicthInputEl=function(e){var t=this,n=e.props;switch(n.type){case"text":case"email":case"tel":case"number":case"password":return i.createElement(r.FormControl,{style:n.inputStyle,type:n.type,value:n.value,className:"form-control "+n.inputClass,placeholder:n.placeholder,onChange:n.onChange,onBlur:n.onBlur,maxLength:n.maxLength,min:n.min,disabled:n.disabled,autoFocus:n.autoFocus,name:n.name,inputRef:function(e){t.inputEl=e,n.getRef&&"function"==typeof n.getRef&&n.getRef(e)},onKeyPress:function(e){n.onKeyPress?n.onKeyPress(e):"Enter"===e.key&&t.inputEl.blur()},onFocus:function(e){n.onFocus&&n.onFocus(e);try{var r=window.innerWidth<768;setTimeout((function(){if(r){var e=t.inputEl.getBoundingClientRect(),n=document.documentElement,o=document.documentElement.scrollTop;o||(o=window.scrollY,n=window),o+=e.top-10-60,n.scrollTo(0,o)}}),500)}catch(e){}},autoComplete:n.autoCompleteType||"off"});case"textarea":return i.createElement(r.FormControl,{inputRef:function(e){t.inputEl=e,n.getRef&&"function"==typeof n.getRef&&n.getRef(e)},className:"form-control "+n.inputClass,componentClass:n.type,value:n.value,placeholder:n.placeholder,onBlur:n.onBlur,onChange:n.onChange,name:n.name,maxLength:n.maxLength,disabled:n.disabled,rows:n.rows,autoComplete:n.autoCompleteType||"off",onFocus:function(e){n.onFocus&&n.onFocus(e);try{var r=window.innerWidth<768;setTimeout((function(){if(r){var e=t.inputEl.getBoundingClientRect(),n=document.documentElement,o=document.documentElement.scrollTop;o||(o=window.scrollY,n=window),o+=e.top-10-60,n.scrollTo(0,o)}}),500)}catch(e){}}});default:return""}},n.getWrapperClassName=function(){var e="form-group",t=this.props,r=t.containerClass,n=t.label,o=t.rightText,a=t.leftText,i=t.rightIcon,l=t.rightImage,s=t.autoClear,u=t.leftIcon,c=t.leftImage;return(u||c)&&(e+=" left-icon-form-group"),(i||l||s)&&(e+=" right-icon-form-group"),a&&(e+=" left-text-form-group"),o&&(e+=" right-text-form-group"),n||(e+=" no-label"),r?(r+" "+e).trim():e.trim()},n.render=function(){var e=this.props,t=e.errorMsg,n=e.hasError,o=e.leftIcon,a=e.leftImage,l=e.rightImage,s=e.autoClear,u=e.value,c=e.rightIcon,p=e.leftText,f=e.rightText,d=e.label,h=e.validationState,v=e.id,y=e.errorClass,m=e.errorStyle,g=e.size,b=e.required;return i.createElement(r.FormGroup,{controlId:v,bsSize:g,className:this.getWrapperClassName(),validationState:h},d?i.createElement(r.ControlLabel,null,d,b?i.createElement("sup",null,"*"):""):null,o?i.createElement("span",{className:"left-input-icon"},o):a?i.createElement("img",{alt:"left-input-img",className:"left-input-image",src:a}):p?i.createElement("span",{className:"left-input-text"},p):null,s||c?i.createElement("span",{className:"right-input-icon"},s?u?i.createElement(le,{type:"close",onClick:this.clearInput,className:"input-clear"}):null:c):l?i.createElement("img",{alt:"right-input-img",className:"right-input-image",src:c}):f?i.createElement("span",{className:"right-input-text"},f):null,this.swicthInputEl(this),n?i.createElement("div",{className:"nbform-err-msg "+y,style:m},t):null)},t}(e.PureComponent);fe.defaultProps={type:"text",placeholder:"",errorMsg:"",hasError:!1,leftIcon:null,rightIcon:null,leftText:null,rightText:null,value:"",label:"",disabled:!1,ref:"",validationState:null,id:"",size:"",autoComplete:"off",containerClass:"",inputClass:"",rows:2,onChange:function(){},onBlur:function(){},onFocus:function(){},autoClear:!1,required:!1,autoFocus:!1,name:""};var de=function(e){function t(t){var r=e.call(this,t)||this;return r.state={},r}return se(t,e),t.prototype.render=function(){var e=this.props,t=e.containerClass,r=void 0===t?"":t,o=e.inputClass,a=void 0===o?"":o,l=e.onSelectFlag,s=e.onPhoneNumberChange,u=e.defaultCountry,c=e.errorStyle,p=e.errorClass,d=e.value,h=e.placeholder,v=e.errorMsg,y=e.hasError,m=e.maxLength,g=e.size,b=e.disabled,E=e.id,_=e.telInputProps;return i.createElement("div",{className:"intl-custom "+r},i.createElement(n,{css:["intl-tel-input","form-control "+("lg"===g?"input-lg":"")+" "+(y?"has-error":""),a],separateDialCode:!0,defaultCountry:u||"in",preferredCountries:["in","us","gb"],fieldId:E,telInputProps:f({type:"number",maxLength:m},_),autoComplete:"tel",onSelectFlag:l,onPhoneNumberChange:s,value:d,placeholder:h,disabled:b}),y?i.createElement("div",{className:"nbform-err-msg "+p,style:c},v):null)},t}(e.PureComponent);de.defaultProps={separateDialCode:!0,defaultCountry:"in",telInputProps:{},placeholder:"Enter Mobile Number",size:""};var he=function(e){function t(){return e.apply(this,arguments)||this}return se(t,e),t.prototype.render=function(){var e=this.props,t=e.errorMsg,n=e.className,o=e.hasError,a=e.textClass,l=void 0===a?"":a,s=e.validationState,u=e.id,c=e.readOnly,p=e.disabled,f=e.text,d=void 0===f?"":f,h=e.errorStyle,v=e.errorClass,y=e.onChange,m=e.value,g=e.checked,b=e.inline,E=e.containerClass,_=void 0===E?"":E;return i.createElement(r.Checkbox,{id:u,inline:b,value:m,checked:g,disabled:p,readOnly:c,validationState:s,onChange:y,className:"nb-checkbox "+n+" "+_+" "+(o?"error":"")},i.createElement("span",{className:l,dangerouslySetInnerHTML:{__html:d}}),o?i.createElement("div",{className:"nbform-err-msg "+v,style:h},t):null)},t}(e.PureComponent);he.defaultProps={inline:!1,checked:!1,readOnly:!1,hasError:!1,disabled:!1,errorMsg:"",onChange:function(){},validationState:null,id:"",value:null,containerClass:"",className:""};var ve=Array.isArray,ye="object"==typeof u&&u&&u.Object===Object&&u,me="object"==typeof self&&self&&self.Object===Object&&self,ge=ye||me||Function("return this")(),be=ge.Symbol,Ee=Object.prototype,_e=Ee.hasOwnProperty,Ce=Ee.toString,xe=be?be.toStringTag:void 0;var we=function(e){var t=_e.call(e,xe),r=e[xe];try{e[xe]=void 0;var n=!0}catch(e){}var o=Ce.call(e);return n&&(t?e[xe]=r:delete e[xe]),o},Se=Object.prototype.toString;var Ne=function(e){return Se.call(e)},Ie="[object Null]",Pe="[object Undefined]",je=be?be.toStringTag:void 0;var Oe=function(e){return null==e?void 0===e?Pe:Ie:je&&je in Object(e)?we(e):Ne(e)};var ke=function(e){return null!=e&&"object"==typeof e},Fe="[object Symbol]";var Ae=function(e){return"symbol"==typeof e||ke(e)&&Oe(e)==Fe},Le=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Te=/^\w*$/;var Be=function(e,t){if(ve(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!Ae(e))||(Te.test(e)||!Le.test(e)||null!=t&&e in Object(t))};var Re=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},ze="[object AsyncFunction]",Me="[object Function]",Ge="[object GeneratorFunction]",$e="[object Proxy]";var De=function(e){if(!Re(e))return!1;var t=Oe(e);return t==Me||t==Ge||t==ze||t==$e},Ve=ge["__core-js_shared__"],qe=function(){var e=/[^.]+$/.exec(Ve&&Ve.keys&&Ve.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var We=function(e){return!!qe&&qe in e},Ke=Function.prototype.toString;var He=function(e){if(null!=e){try{return Ke.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Ye=/^\[object .+?Constructor\]$/,Ue=Function.prototype,Ze=Object.prototype,Je=Ue.toString,Qe=Ze.hasOwnProperty,Xe=RegExp("^"+Je.call(Qe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var et=function(e){return!(!Re(e)||We(e))&&(De(e)?Xe:Ye).test(He(e))};var tt=function(e,t){return null==e?void 0:e[t]};var rt=function(e,t){var r=tt(e,t);return et(r)?r:void 0},nt=rt(Object,"create");var ot=function(){this.__data__=nt?nt(null):{},this.size=0};var at=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},it="__lodash_hash_undefined__",lt=Object.prototype.hasOwnProperty;var st=function(e){var t=this.__data__;if(nt){var r=t[e];return r===it?void 0:r}return lt.call(t,e)?t[e]:void 0},ut=Object.prototype.hasOwnProperty;var ct=function(e){var t=this.__data__;return nt?void 0!==t[e]:ut.call(t,e)},pt="__lodash_hash_undefined__";var ft=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nt&&void 0===t?pt:t,this};function dt(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}dt.prototype.clear=ot,dt.prototype.delete=at,dt.prototype.get=st,dt.prototype.has=ct,dt.prototype.set=ft;var ht=dt;var vt=function(){this.__data__=[],this.size=0};var yt=function(e,t){return e===t||e!=e&&t!=t};var mt=function(e,t){for(var r=e.length;r--;)if(yt(e[r][0],t))return r;return-1},gt=Array.prototype.splice;var bt=function(e){var t=this.__data__,r=mt(t,e);return!(r<0)&&(r==t.length-1?t.pop():gt.call(t,r,1),--this.size,!0)};var Et=function(e){var t=this.__data__,r=mt(t,e);return r<0?void 0:t[r][1]};var _t=function(e){return mt(this.__data__,e)>-1};var Ct=function(e,t){var r=this.__data__,n=mt(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function xt(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}xt.prototype.clear=vt,xt.prototype.delete=bt,xt.prototype.get=Et,xt.prototype.has=_t,xt.prototype.set=Ct;var wt=xt,St=rt(ge,"Map");var Nt=function(){this.size=0,this.__data__={hash:new ht,map:new(St||wt),string:new ht}};var It=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Pt=function(e,t){var r=e.__data__;return It(t)?r["string"==typeof t?"string":"hash"]:r.map};var jt=function(e){var t=Pt(this,e).delete(e);return this.size-=t?1:0,t};var Ot=function(e){return Pt(this,e).get(e)};var kt=function(e){return Pt(this,e).has(e)};var Ft=function(e,t){var r=Pt(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function At(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}At.prototype.clear=Nt,At.prototype.delete=jt,At.prototype.get=Ot,At.prototype.has=kt,At.prototype.set=Ft;var Lt=At,Tt="Expected a function";function Bt(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(Tt);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=e.apply(this,n);return r.cache=a.set(o,i)||a,i};return r.cache=new(Bt.Cache||Lt),r}Bt.Cache=Lt;var Rt=Bt,zt=500;var Mt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gt=/\\(\\)?/g,$t=function(e){var t=Rt(e,(function(e){return r.size===zt&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Mt,(function(e,r,n,o){t.push(n?o.replace(Gt,"$1"):r||e)})),t}));var Dt=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o},Vt=1/0,qt=be?be.prototype:void 0,Wt=qt?qt.toString:void 0;var Kt=function e(t){if("string"==typeof t)return t;if(ve(t))return Dt(t,e)+"";if(Ae(t))return Wt?Wt.call(t):"";var r=t+"";return"0"==r&&1/t==-Vt?"-0":r};var Ht=function(e){return null==e?"":Kt(e)};var Yt=function(e,t){return ve(e)?e:Be(e,t)?[e]:$t(Ht(e))},Ut=1/0;var Zt=function(e){if("string"==typeof e||Ae(e))return e;var t=e+"";return"0"==t&&1/e==-Ut?"-0":t};var Jt=function(e,t){for(var r=0,n=(t=Yt(t,e)).length;null!=e&&r<n;)e=e[Zt(t[r++])];return r&&r==n?e:void 0};var Qt=function(e,t,r){var n=null==e?void 0:Jt(e,t);return void 0===n?r:n},Xt={control:function(e){return f({},e,{boxShadow:"none"})}},er=function(e){function t(t){var r=e.call(this,t)||this;return r.state={loaded:!1},r}se(t,e);var n=t.prototype;return n.componentDidMount=function(){this.setState({loaded:!0})},n.getWrapperClassName=function(){var e=this.props,t=e.size,r=e.containerClass,n="nb-select";return"lg"===t&&(n+=" nb-select__lg"),"sm"===t&&(n+=" nb-select__sm"),"xs"===t&&(n+=" nb-select__xs"),r?(r+" "+n).trim():n.trim()},n.render=function(){var e=this.props,t=e.errorMsg,n=e.hasError,a=e.onChange,l=e.size,s=e.label,u=e.validationState,c=e.errorStyle,p=e.errorClass,f=e.id,d=e.options,h=e.selectedValue,v=e.isSearchableboolean,y=e.validationId,m=e.containerId,g=this.state.loaded,b=Qt(h,"value");return i.createElement(r.FormGroup,{controlId:y,className:this.getWrapperClassName(),validationState:u},s?i.createElement(r.ControlLabel,null,s):null,g?i.createElement(o,{onChange:a,id:m||f,options:d,blurInputOnSelect:!0,className:"nb-select-container",classNamePrefix:"nb-select",isFocused:!0,styles:Xt,placeholder:this.props.placeholder,isSearchable:v,isDisabled:this.props.disabled,value:h}):b&&i.createElement("div",{className:"nb-select-loader "+(l||"")},i.createElement("span",{className:"nb-select-loader__value"},b&&b.toLowerCase?b.toLowerCase():"")),n?i.createElement("div",{className:"nbform-err-msg "+p,style:c},t):null)},t}(e.PureComponent);er.defaultProps={placeholder:"Select ...",errorMsg:"",hasError:!1,label:"",disabled:!1,validationState:null,id:"",size:void 0,containerClass:"",isSearchableboolean:!1,selectedValue:null,onChange:function(){}};var tr=function(e){function t(){return e.apply(this,arguments)||this}return se(t,e),t.prototype.render=function(){var e=this.props,t=e.id,n=e.readOnly,o=e.disabled,a=e.text,l=e.onChange,s=e.value,u=e.checked,c=e.name,p=e.inline,f=e.hasError,d=e.containerClass;return i.createElement(r.Radio,{id:t,inline:p,value:s,name:c,defaultChecked:u,disabled:o,readOnly:n,validationState:!p&&f?"error":null,onChange:l,className:"nb-radio "+d},a)},t}(e.PureComponent);function rr(e,t){if(void 0===t&&(t=!1),!e)return"0";if(t)return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");var r=!1;"-"===(e=e.toString()).charAt(0)&&(e=e.substr(1),r=!0);var n="";e.indexOf(".")>0&&(n=e.substring(e.indexOf("."),e.length));var o=(e=(e=Math.round(e)).toString()).substring(e.length-3),a=e.substring(0,e.length-3);""!==a&&(o=","+o);var i=a.replace(/\B(?=(\d{2})+(?!\d))/g,",")+o+n;return r?"-"+i:""+i}tr.defaultProps={checked:!1,readOnly:!1,disabled:!1,inline:!1,onChange:function(){},validationState:null,id:"",name:"",value:null,containerClass:""};var nr=function(e){return Boolean("object"===p(e)&&null!==e)};var or=function(e){function t(t){var r=e.call(this,t)||this;r.handleChange=function(e){r.setState({address:e},(function(){r.props.onSelect(r.state.address)})),r.props.onInputChange&&r.props.onInputChange(e)},r.handleSelect=function(e,t){try{r.inputRef.blur()}catch(e){console.log("unable to remove focus",e)}a.geocodeByPlaceId(t,"/api/v1/localities/place_detail/"+t+"/_search").then((function(t){r.setState({placeObj:t[0]},(function(){null!=r.props.currentBound?!function(e,t){void 0===t&&(t={});var r=t;return!(null==r||void 0===r.geometry||null===r.geometry||!e.contains(r.geometry.location))}(r.props.currentBound,t[0])?(r.setState({address:""}),r.props.showAlertMsg(!0,"Please select another locality in "+r.props.city.toLowerCase())):(r.setState({address:e}),a.getLatLng(t[0]).then((function(n){r.props.showAlertMsg(!1,""),r.props.onSelect(t,n,e)}))):(r.setState({address:e}),a.getLatLng(t[0]).then((function(n){r.props.onSelect(t,n,e)})))}))})).catch((function(e){return console.error("Error",e)}))},r.componentDidMount=function(){r.setState({address:r.props.prfillValue?r.props.prfillValue:""})},r.getClassName=function(){var e="",t=r.props,n=t.size,o=t.className,a=void 0===o?"":o,i=t.containerClass;return n&&(e+="nb-google-autocomplete-"+n)," "+a+" "+e+" "+(void 0===i?"":i)},r.render=function(){var e=r.props,t=e.city,n=e.page,o=e.debounce,a=r.state,s=a.address,u=a.top,c="/api/v1/localities/autocomplete/_search?hint="+s+"&city="+t.toLowerCase()+"&page="+n;return i.createElement(l,{value:r.state.address,onChange:r.handleChange,onSelect:r.handleSelect,onBlur:r.handleBlur,debounce:o,city:t,getSuggestionUrl:c,page:n,searchOptions:r.props.searchOptions,shouldFetchSuggestions:r.state.address.length>1},(function(e){var t=e.getInputProps,n=e.suggestions,o=e.getSuggestionItemProps,a=u,l=n.length,s=40*l+20;if(l&&r.inputRef&&r.inputRef.getBoundingClientRect&&"object"===("undefined"==typeof window?"undefined":p(window))){var c=r.inputRef.getBoundingClientRect().top;window.innerHeight-c-50<s&&(a=-1*s)}var d=[].concat(n).reverse();return i.createElement("div",{className:"nb-google-autocomplete"+r.getClassName()},i.createElement(fe,f({},t(f({},r.props,{getRef:function(e){r.inputRef=e}})),{getRef:function(e){r.inputRef=e}})),n.length>0&&i.createElement("div",{className:"autocomplete-dropdown-container",style:{top:a+"px"}},(a<0?d:n).map((function(e,t){return i.createElement("div",f({key:e.id||t},o(e,{className:"suggestion-item"})),i.createElement("span",null,i.createElement(le,{type:"place",className:"place-icon"})," ",e.description))}))))}))};var n=t.size,o=75;return"md"!==n&&n||(o=65),"sm"===n&&(o=55),t.label||(o-=25),r.state={address:"",placeObj:[],top:o},r.inputRef=i.createRef(),r}return se(t,e),t.prototype.UNSAFE__componentWillReceiveProps=function(e){""!==this.state.address&&e.clearAutocompleteValue&&this.setState({address:""})},t}(e.Component);or.defaultProps={size:void 0,id:"",containerClass:"",hasError:!1,leftIcon:null,rightIcon:null,leftText:null,rightText:null,label:"",disabled:!1,searchOptions:null,currentBound:null,page:"default",city:"",debounce:500,rightImage:null,leftImage:null,autoClear:!1};var ar=function(e,t,r){void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r=!1),s("object"===p(e),"INIT_STATE must be object");var n=Object.keys(e),o={},a={};return r&&(a.parent=r),t.forEach((function(t,r){var i=t.id,l=t.type,s=t.defaultDialCode,u=void 0===s?"91":s,c=t.defaultCountry,p=void 0===c?"in":c,d="";if(-1!==n.indexOf(i)&&(d=e[i]),"tel"===l)o[i]=f({value:d},a),o[i+"_dialCode"]=f({value:u},a),o[i+"_iso2"]=f({value:p},a);else{if("inputGroup"===l)return void(o=f({},o,{},ar(e,t.input,i||"group-"+r)));o[i]=f({value:d},a)}Object.keys(t).forEach((function(e){var r=t[e];if("string"==typeof r&&r.match(/^\$(.*)\$$/)&&r.match(/^\$(.*)\$$/).length>1){var n,l=r.match(/^\$(.*)\$$/)[1];o[i]||(o[i]=f({value:""},a)),o[l]||(o[l]=f({value:""},a)),o[l]._dependencies||(o[l]._dependencies={}),o[l]._dependencies[i]||(o[l]._dependencies[i]=[]),o[i].dependency=((n={})[e]=o[l].value||"",n),o[l]._dependencies[i].push(e)}}))})),o},ir=function(e){s("object"===p(e),"Invalid Data: make sure pass valid formData generated by NbForm");var t=Object.keys(e),r={};return t.forEach((function(t){s(Object.prototype.hasOwnProperty.call(e[t],"value"),"Invalid Data: make sure pass valid formData generated by NbForm"),r[t]=e[t].value||null})),r},lr={display:"flex",justifyContent:"flex-start"},sr=function(e){var t=e.inputId,r=e.idPrefix,n=e.userInput;try{var o=document.getElementById(t+"-container");if(n.nextFocusId)document.getElementById((r?r+"-":"")+n.nextFocusId+"-nbInput").focus();else if(o.nextElementSibling&&o.nextElementSibling.id){var a=o.nextElementSibling.id;if(a.match(new RegExp(r+"-(.*)-nbInput-container"))){var i=a.replace("-container","");document.getElementById(i).focus()}}}catch(e){}},ur=function(e,t){var r=t.inputId,n=t.userInput;if("Enter"===e.key)try{var o=document.getElementById(r);""!==o.value&&(o.blur(),sr(t))}catch(e){console.log("seems not found")}n.onKeyPress&&"function"==typeof n.onKeyPress&&n.onKeyPress(e)};function cr(e,t,r,n){void 0===n&&(n={});var o=n,a=o.idPrefix,l=o.customLabel,u=o.formData,c=o.nbGAEventCategory,d=o.nbGaEvent,h=o.index,v=o.customProps,y=o.extraProps,m=o.defaultStyle,g=void 0===m?{}:m,b=e.id,E=e.uiLabel,_=e.size,C=void 0===_?"":_,x=e.labelClass,w=e.inlineLabel,S=void 0!==w&&w,N=e.autoCompleteType,I=e.style,P=void 0===I?{}:I,j=e.errorClassName,O=void 0===j?"":j,k=t.value,F=t.isError,A=void 0!==F&&F,L=t.errorMsg,T=void 0===L?oe(e.errorMsg,"default"):L,B=t.dependency,R=void 0===B?{}:B,z=k||"",M=[],G=(a?a+"-":"")+b+"-nbInput",$=function(e,t,r){void 0===e&&(e={}),void 0===t&&(t={});var n=r.isError,o=void 0!==n&&n,a={},i={};return nr(e.label)&&(i=e.label),nr(e.error)&&(a=e.error),nr(t.label)&&(i=t.label),nr(t.error)&&(a=t.error),o&&nr(e.onError)&&(nr(e.onError.label)&&(i=e.onError.label),nr(e.onError.error)&&(a=e.onError.error)),o&&nr(t.onError)&&(nr(t.onError.label)&&(i=t.onError.label),nr(t.onError.error)&&(a=t.onError.error)),{labelStyle:i,errorStyle:a}}(g,P,{isError:A}),D=$.errorStyle,V=$.labelStyle;(E||l)&&M.push(i.createElement("label",{key:b+"InputLabel",htmlFor:G,className:x,style:f({marginRight:"5px",lineHeight:"25px",fontWeight:"600"},V)},l||E));var q=!1;if("undefined"!=typeof window&&window.isHybridView&&(q=!0),"function"==typeof e.customDisabled&&(e.disabled=Boolean(e.customDisabled(z,ir(u),y))),"function"==typeof e.customVisible&&!1===Boolean(e.customVisible(ir(u)),y))return null;if("function"==typeof e.customOptions){var W=e.customOptions(ir(u));"object"===p(W)&&Array.isArray(W)&&(e.options=W)}if("customInput"===e.type&&"function"==typeof e.render&&M.push(i.createElement(i.Fragment,null,i.createElement("div",{id:G},e.render(z,(function(e){r(b,e)}))),A&&i.createElement("div",{className:"nbform-err-msg "+O,style:D},T))),"inputGroup"===e.type&&M.push(i.createElement(ce,f({},e,v,R,{hasError:A,errorStyle:D,errorClass:O,errorMsg:T,id:G,key:b+"Input"}),(e.input||[]).map((function(e,t){"inputGroup"===e.type&&!e.id&&(e.id="sub-group-"+t);var n=e.id;return s(Boolean(n),"Invalid input id for data at input group "+h+" at sub index "+t),cr(e,u[n]||"",r,{idPrefix:n,formData:u,nbGaEvent:d,groupInputIndex:t})})))),"switch"===e.type&&M.push(i.createElement(pe,f({},v,R,{key:b+"Input",id:G,errorStyle:D,errorClass:O,checked:Boolean(z),label:e.text,labelPosition:e.textPosition||"right",className:e.containerClass||e.className,textClass:e.textClass||"",hasError:A,errorMsg:T,onChange:function(e){var t=!0===oe(e,"target.checked");r(b,t)}}))),"toggleButton"===e.type&&M.push(i.createElement(ue,f({id:G,key:b+"Input",size:C,hasError:A,errorStyle:D,errorClass:O,errorMsg:T,type:e.subType||"radio",onChange:function(t){e.options.forEach((function(e){e.value===t&&e.nbGAEvent&&"function"==typeof d&&d(c,e.nbGAEvent)})),r(b,t)},defaultValue:z,toggleButtonData:e.options,name:b+"ToggleButton"},v,R))),"input"===e.type){var K=e.subType;q&&-1!==["int","float"].indexOf(oe(e,"validation.dataType"))&&(K="number");var H="number"===K&&e.currencyFormatter;M.push(i.createElement(fe,f({key:b+"Input"},e,v,R,{size:C,label:"",value:H?rr(z,e.currencyFormatterInternational||!1):z,type:"number"===K?"text":K,hasError:A,errorStyle:D,errorClass:O,name:N||b,errorMsg:T,validationState:A?"error":null,id:G,onKeyPress:function(t){ur(t,{inputId:G,userInput:e,idPrefix:a})},onChange:function(e){var t=oe(e,"target.value");"number"===K&&void 0!==t&&(H&&(t=parseFloat(t.toString().replace(/,/g,""))),t&&"."===t[t.length-1]?t.match(/(\.)/g).length>1&&(t=t.toString().slice(0,t.length-1)):t=isNaN(parseFloat(t))?t.toString().slice(0,t.lenght-1):parseFloat(t)),r(b,t)}})))}return"select"===e.type&&M.push(i.createElement(er,f({key:b+"SelectInput"},e,v,R,{selectedValue:z,hasError:A,errorStyle:D,errorClass:O,validationState:A?"error":null,errorMsg:T,id:G,size:C,onChange:function(e){r(b,e)},isSearchableboolean:!!e.isSearchable&&oe(window,"innerWidth")>768}))),"tel"===e.type&&M.push(i.createElement("div",{key:b+"Input",className:"form-group"},i.createElement(de,f({},e,v,R,{errorStyle:D,errorClass:O,onSelectFlag:function(e,t){var n=t.dialCode,o=t.iso2;r([b+"_dialCode",b+"_iso2"],[n,o])},value:z,size:C,onPhoneNumberChange:function(e,t){r(b,t)},hasError:A,errorMsg:T,validationState:A?"error":null,id:G,telInputProps:{onKeyPress:function(t){ur(t,{inputId:G,userInput:e,idPrefix:a})}},defaultCountry:oe(u,[b+"_iso2","value"])||"in",maxLength:"91"===oe(u,[b+"_dialCode","value"])?10:15})))),"checkbox"===e.type&&M.push(i.createElement(he,f({key:b+"Input",id:G},v,R,e,{errorStyle:D,errorClass:O,value:Boolean(z),checked:Boolean(z),text:e.checkboxText,className:e.containerClass||e.className,textClass:e.textClass||"",hasError:A,errorMsg:T,onChange:function(e){var t=oe(e,"target.checked");r(b,t)}}))),"radio"===e.type&&e.options&&e.options.length>0&&M.push(i.createElement("div",{key:b+"Input",id:G,style:{marginBottom:"15px"}},e.options.map((function(t){var n=t.label,o=t.value;return i.createElement(tr,f({name:G,onChange:function(e){var t=e.target.value;r(b,t)}},v,R,{text:n,disabled:Boolean(e.disabled),value:o,hasError:A,key:G+"-"+t.value,id:G+"-"+t.value,inline:void 0===e.inline||e.inline}))})),A&&i.createElement("div",{className:"nbform-err-msg "+O,style:D},T))),"rating"===e.type&&M.push(i.createElement("div",{key:b+"Input",className:e.containerClass||""},i.createElement(ae,f({id:G},v,R,{className:"react-rater "+(e.className||""),total:e.max||5,rating:parseInt(z)||0,onRate:function(t){var n=t.rating;e.nbGAEvent&&d(c,e.nbGAEvent),r(b,n)}})),A&&i.createElement("div",{className:"nbform-err-msg "+O,style:D},T))),"location-autocomplete"===e.type&&M.push(i.createElement("div",{key:b+"Input",className:"form-group"},i.createElement(or,f({},e,v,R,{onSelect:function(t,n,o){"object"===p(t)&&Array.isArray(t)&&t.length>0?(r(b,{result:t,latLng:n,selectedAddress:o}),sr({inputId:G,idPrefix:a,userInput:e})):""===t&&r(b,{result:[],latLng:{},selectedAddress:""})},key:G+"Input",id:G,type:"text",hasError:A,errorMsg:T,validationState:A?"error":null,leftIcon:i.createElement(le,{type:"place"}),onKeyPress:function(t){ur(t,{inputId:G,userInput:e,idPrefix:a})}})))),0===M.length?(console.info("Invalid Input. NbForm-"+b),null):i.createElement("div",{key:G+"-container",className:e.wrapperClass||"",id:G+"-container",style:S?lr:{}},M)}var pr=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return(t=e.call.apply(e,[this].concat(o))||this).getButton=function(){var e=t.props,n=e.className,o=e.containerClass,a=e.btnStyle,l=e.size,s=e.disabled,u=e.type,c=e.block,p=e.text,f=e.onClick,d=e.children,h=e.id;return i.createElement(r.Button,{id:h,className:n+" "+o,onClick:f,bsStyle:a,bsSize:l,disabled:s,type:u,block:c},d||p||"")},t}return se(t,e),t.prototype.render=function(){var e=this.props.tooltip;return e?i.createElement(r.OverlayTrigger,{placement:"bottom",overlay:i.createElement(r.Tooltip,{id:"button-tooltip-"+(new Date).getTime()},e)},this.getButton()):this.getButton()},t}(e.PureComponent);pr.defaultProps={className:"",btnStyle:"default",size:"",disabled:!1,onClick:function(){},type:"button",block:!1,tooltip:!1,id:""};var fr=function(e,t,r,n){var o=e.type,a=e.id,i=e.subType,l=void 0===i?"":i;void 0===r&&(r={});var s=!1,u=[],c=oe(n,"formData")||{},f=oe(n,"extraProps")||{};if(r){var d=r,h=d.minlength,v=d.required,y=d.min,m=d.max,g=d.dataType,b=void 0===g?"":g,E=d.value,_=d.customValidation;if("function"==typeof _){var C={};Object.keys(C).forEach((function(e){C[e]=function(e,t){if(void 0===e&&(e={}),void 0===t&&(t={}),!nr(e)||!nr(t))return e;var r={};return Object.keys(t).forEach((function(n){t[n]&&(r[n]=e[n])})),r}(c[e],{value:!0,isError:!0})}));var x=_(t,C,f);if("boolean"==typeof x&&x)s=x,u.push("default");else if("object"===p(x)&&Array.isArray(x)){var w=x[0],S=x[1],N=void 0===S?"default":S;w&&(s=w,u.push(N))}else if("object"===p(x)&&"boolean"==typeof x.isError){var I=x.isError,P=x.type;I&&(s=I,u.push(P))}else console.warn("Skipping NbForm-CustomValidation Invalid Return Data check Docs.")}if(void 0!==E&&E!==t&&(s=!0,u.push("value")),(null==t||"string"==typeof t&&0===t.length)&&(v&&(s=!0),u.push("required")),void 0!==h)t.toString().trim().length<h&&(s=!0,u.push("minlength"));var j=t;if("location-autocomplete"===o&&v&&(t.selectedAddress||(s=!0)),"input"!==o||"email"!==l&&"email"!==b||/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t)||(s=!0,u.push("type","dataType")),"input"===o&&"number"===l||-1!==["int","float"].indexOf(b)){var O=!1;if(isNaN(parseFloat(t))&&(s=!0,u.push("type","dataType"),O=!0),O||"int"!==b||parseInt(t)==t||(s=!0,u.push("dataType"),O=!0),O||"float"!==b||parseFloat(t)==t||(s=!0,u.push("dataType"),O=!0),!O){if(j=b&&"float"!==b?parseInt(t):parseFloat(t),void 0!==h)j.toString().length<h&&(s=!0,u.push("minlength"));if("tel"===o&&"91"===oe(c,[a+"_dialCode","value"]))j.toString().length<10&&(s=!0,u.push("minlength"));isNaN(y)||t<y&&(s=!0,u.push("min")),isNaN(m)||t>m&&(s=!0,u.push("max"))}}}return{error:u,status:s}},dr=function(e,t,r,n){void 0===r&&(r=[[],[],[],[]]),void 0===n&&(n={});var o=[].concat(r),a=!1,i=n,l=i.isGroupInput,s=void 0!==l&&l,u=i.groupValidation,c=void 0===u?{}:u,f=i.extraProps,d=void 0===f?{}:f,h=0;e.forEach((function(e,r){var n=e.id,i=void 0===n?"":n,l=e.validation,s=e.errorMsg,u=void 0===s?{}:s;if("inputGroup"!==e.type){var c=oe(t,[i,"value"])||"",f=fr(e,c,l,{formData:t,extraProps:d}),v=f.status,y=f.error;!0===v&&(a=!0);var m=y||[];-1===y.indexOf("required")&&(h+=1),Array.isArray(y)&&y.length>0&&(m=y[0]),v&&(o[0].push(i),o[1].push(c),o[2].push(v),o[3].push(v?u[m]||u.default:""))}else if("object"===p(e.input)&&Array.isArray(e.input)){var g={},b=dr(e.input,t,o,{isGroupInput:!0,groupValidation:l,extraProps:d});o=b[0],a=b[1],(g=b[2].groupErrorLog)&&-1===g.type.indexOf("required")&&(h+=1),g.isError&&(o[0].push(i||"group-"+r),o[1].push(""),o[2].push(g.isError),o[3].push(g.isError?u[oe(g,"type.0")]||u.default:""))}}));var v={isError:!1,type:[]};return s&&(c&&!0===c.required&&(v={isError:h<=0,type:h<=0?["required"]:[]}),!0===c.requiredAll&&(v={isError:h===e.length,type:h!==e.length?["requiredAll"]:[]})),[o,a,{groupErrorLog:v}]},hr=c((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function s(e,t,r,n){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),i=new I(n||[]);return a._invoke=function(e,t,r){var n=c;return function(o,a){if(n===f)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw a;return j()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var l=w(i,r);if(l){if(l===h)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===c)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=f;var s=u(e,t,r);if("normal"===s.type){if(n=r.done?d:p,s.arg===h)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(e,r,i),a}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var c="suspendedStart",p="suspendedYield",f="executing",d="completed",h={};function v(){}function y(){}function m(){}var g={};g[a]=function(){return this};var b=Object.getPrototypeOf,E=b&&b(b(P([])));E&&E!==r&&n.call(E,a)&&(g=E);var _=m.prototype=v.prototype=Object.create(g);function C(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function x(e){var t;this._invoke=function(r,o){function a(){return new Promise((function(t,a){!function t(r,o,a,i){var l=u(e[r],e,o);if("throw"!==l.type){var s=l.arg,c=s.value;return c&&"object"==typeof c&&n.call(c,"__await")?Promise.resolve(c.__await).then((function(e){t("next",e,a,i)}),(function(e){t("throw",e,a,i)})):Promise.resolve(c).then((function(e){s.value=e,a(s)}),(function(e){return t("throw",e,a,i)}))}i(l.arg)}(r,o,t,a)}))}return t=t?t.then(a,a):a()}}function w(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,w(e,r),"throw"===r.method))return h;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var o=u(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,h;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,h):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function P(e){if(e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}return{next:j}}function j(){return{value:t,done:!0}}return y.prototype=_.constructor=m,m.constructor=y,m[l]=y.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l in e||(e[l]="GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},C(x.prototype),x.prototype[i]=function(){return this},e.AsyncIterator=x,e.async=function(t,r,n,o){var a=new x(s(t,r,n,o));return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},C(_),_[l]="Generator",_[a]=function(){return this},_.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=P,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return l.type="throw",l.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],l=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),N(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),h}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function vr(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){return void r(e)}l.done?t(s):Promise.resolve(s).then(n,o)}var yr=function(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){vr(a,n,o,i,l,"next",e)}function l(e){vr(a,n,o,i,l,"throw",e)}i(void 0)}))}},mr=function(e){var t={};return e.forEach((function(e){var r=e.id,n=e.customProps;"function"==typeof n&&(t[r]=n)})),t};return function(t){var r=t.id,n=t.data,o=t.ref,a=t.formClass,l=void 0===a?"":a,u=t.onSubmit,c=t.onChange,d=t.submitButtonText,h=void 0===d?"Submit":d,v=t.buttonClassName,y=void 0===v?"":v,m=t.defaultValue,g=void 0===m?{}:m,b=t.nbGaEvent,E=t.customFooter,_=t.getSubmitAction,C=t.style,x=void 0===C?{}:C,w=t.getResetFormAction,S=t.extraProps,N=void 0===S?{}:S;s(null!=r&&r.length>1,"Please Provide valid unique ID"),s(Array.isArray(n)&&n.length>0,"data should be array of object");var I=function(t,r,n){void 0===t&&(t={}),void 0===n&&(n=[]);var o=e.useState(ar(t,n)),a=o[0],i=o[1],l=e.useCallback((function(){i(ar(t,n))})),s=e.useCallback((function(e){try{if(Array.isArray(e)&&e.length>0)e=e[0];var t=document.getElementById(r+"-"+e+"-nbInput");t&&t.focus()}catch(e){}}),[r]),u=e.useCallback((function(e,t,r){var n=f({},e),o=n[t]._dependencies;"object"===p(o)&&Object.keys(o).length>0&&(Object.keys(o)||[]).forEach((function(e){Array.isArray(o[e])&&o[e].length>0&&o[e].forEach((function(t){var o;n[e]||(n[e]={value:""}),n[e].dependency||(n[e].dependency={}),n[e].dependency=f({},n[e].dependency,((o={})[t]=r,o))}))}));return n}),[]);return[a,e.useCallback((function(e,t,r,n,o){void 0===r&&(r=!1),void 0===n&&(n=""),i((function(a){var i=!1,l=f({},a),c=!1;if("function"==typeof r?o=r:c=r,Array.isArray(e)&&(i=!0),Array.isArray(e)){var p=!1;i&&e.length===t.length?e.forEach((function(r,o){l[r]||(l[r]={value:""}),void 0!==(l=u(l,r,t[o]))[r].parent&&void 0!==l[l[r].parent]&&(l[l[r].parent].isError=!1),l[r]=f({},l[r],{value:t[o],isError:!(!c||!c[o])&&c[o],errorMsg:c&&c[o]&&n&&n[o]?n[o]:""}),!p&&l[r].isError&&(s(e),p=!0)})):e.forEach((function(r,o){l[r]||(l[r]={value:""}),void 0!==(l=u(l,r,t))[r].parent&&void 0!==l[l[r].parent]&&(l[l[r].parent].isError=!1),l[r]=f({},l[r],{value:t,isError:c&&c[o]?c[o]:c,errorMsg:c&&c[o]&&n&&n[o]?n[o]:n}),l[r].isError&&s(e)}))}else l[e]||(l[e]={value:""}),void 0!==(l=u(l,e,t))[e].parent&&void 0!==l[l[e].parent]&&(l[l[e].parent].isError=!1),l[e]=f({},l[e],{value:t,isError:c,errorMsg:n}),c&&s(e);return o&&"function"==typeof o&&o(l),l}))}),[]),l]}(g,r,n),P=I[0],j=void 0===P?{}:P,O=I[1],k=I[2],F=function(e,t,r){var n=i.useState((function(){var t={};return e.forEach((function(e){var r=e.id;t[r]={}})),t})),o=n[0],a=n[1],l=i.useState(mr(e)),s=l[0],u=l[1],c=i.useCallback(function(){var e=yr(hr.mark((function e(t,r){var n;return hr.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("object"!==p(t)||null===t){e.next=12;break}if(n=t,"function"!=typeof t.then){e.next=6;break}return e.next=5,t;case 5:n=e.sent;case 6:if("object"===p(n)&&null!==n){e.next=9;break}return a((function(e){var t;return f({},e,((t={})[r]={},t))})),e.abrupt("return");case 9:a((function(e){var t;return f({},e,((t={})[r]=n,t))})),e.next=13;break;case 12:a((function(e){var t;return f({},e,((t={})[r]={},t))}));case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),[o]);return i.useEffect((function(){Object.keys(s).forEach((function(e){if(s[e]){var n=s[e];c(n(t[e].value,ir(t),r),e)}}))}),[t,r]),i.useEffect((function(){u(mr(e))}),[e]),o}(n,j,N),A=i.useRef(j);e.useEffect((function(){if("function"==typeof c){var e=function e(t,r){void 0===t&&(t={}),void 0===r&&(r={});var n={};return Object.keys(t).forEach((function(o){if(!Object.prototype.hasOwnProperty.call(r,o)||t[o]!==r[o]){if("object"===p(r[o])&&"null"!==r[o]&&Object.keys(r[o]).length>0){var a=e(t[o],r[o]),i=e(r[o],t[o]);if(0===Object.keys(a).length&&0===Object.keys(i).length)return}n[o]=t[o]}})),n}(j,A.current);c(ir(j),O,e),A.current=j}}),[j]);var L=i.useCallback((function(){!function(e,t,r,n,o){var a=dr(e,t,[[],[],[],[]],{extraProps:o})[0],i=!1;"object"===p(a[2])&&Array.isArray(a[2])&&a[2].forEach((function(e){!0===e&&(i=!0)})),r.apply(void 0,a.concat([function(e){"function"==typeof n&&n(i,ir(e),e)}]))}(n,j,O,u,N)}),[n,j,O,u,N]);return e.useEffect((function(){n.forEach((function(e){var t=e.type,r=e.id,n=e.dialCode,o=void 0===n?"91":n,a=e.iso2;"tel"===t&&O([r+"_dialCode",r+"_iso2"],[o,void 0===a?"in":a])})),"function"==typeof w&&w(k)}),[]),e.useEffect((function(){"function"==typeof _&&_(L)}),[L]),i.createElement("form",{id:r,className:"nbform-2ptp128 "+l,action:"#",method:"post",onSubmit:function(e){e.preventDefault(),e.stopPropagation(),L()},ref:function(e){"function"==typeof o&&o(e)},style:{textAlign:"left"}},n.map((function(e,t){"inputGroup"===e.type&&!e.id&&(e.id="group-"+t);var n=e.id;return s(Boolean(n),"Invalid input id for data input at index "+t),cr(e,j[n]||"",O,{idPrefix:r,formData:j,nbGaEvent:b,index:t,extraProps:N,defaultStyle:x,customProps:F[n]||{}})})),void 0!==E?E:i.createElement(pr,{btnStyle:"primary",type:"submit",className:"form-control "+y},h))}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("react-rater"),require("react-bootstrap"),require("react-intl-tel-input"),require("react-select"),require("react-autocomplete-places")):"function"==typeof define&&define.amd?define(["react","react-rater","react-bootstrap","react-intl-tel-input","react-select","react-autocomplete-places"],t):(e=e||self)["@wadehrarshpreet/nbform"]=t(e.React,e["React-rater"],e["React-bootstrap"],e["React-intl-tel-input"],e["React-select"],e["React-autocomplete-places"])}(this,(function(e,t,r,n,o,a){"use strict";var i="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n,o=o&&o.hasOwnProperty("default")?o.default:o;var l="default"in a?a.default:a,s=function(e,t,r,n,o,a,i,l){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,o,a,i,l],c=0;(s=new Error(t.replace(/%s/g,(function(){return u[c++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}},u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(e,t){return e(t={exports:{}},t.exports),t.exports}var p=c((function(e){function t(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=t=function(e){return typeof e}:e.exports=t=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(r)}e.exports=t})),f=c((function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},t.apply(this,arguments)}e.exports=t})),d="Expected a function",h="__lodash_hash_undefined__",v=1/0,y="[object Function]",m="[object GeneratorFunction]",g="[object Symbol]",b=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,_=/^\./,x=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,C=/\\(\\)?/g,w=/^\[object .+?Constructor\]$/,S="object"==typeof u&&u&&u.Object===Object&&u,N="object"==typeof self&&self&&self.Object===Object&&self,k=S||N||Function("return this")();var I,P=Array.prototype,j=Function.prototype,O=Object.prototype,F=k["__core-js_shared__"],A=(I=/[^.]+$/.exec(F&&F.keys&&F.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",L=j.toString,T=O.hasOwnProperty,B=O.toString,R=RegExp("^"+L.call(T).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),z=k.Symbol,M=P.splice,G=J(k,"Map"),$=J(Object,"create"),D=z?z.prototype:void 0,V=D?D.toString:void 0;function q(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function W(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function K(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function H(e,t){for(var r,n,o=e.length;o--;)if((r=e[o][0])===(n=t)||r!=r&&n!=n)return o;return-1}function Y(e,t){for(var r,n=0,o=(t=function(e,t){if(te(e))return!1;var r=typeof e;if("number"==r||"symbol"==r||"boolean"==r||null==e||ne(e))return!0;return E.test(e)||!b.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:te(r=t)?r:Q(r)).length;null!=e&&n<o;)e=e[X(t[n++])];return n&&n==o?e:void 0}function U(e){return!(!re(e)||(t=e,A&&A in t))&&(function(e){var t=re(e)?B.call(e):"";return t==y||t==m}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?R:w).test(function(e){if(null!=e){try{return L.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t}function Z(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function J(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return U(r)?r:void 0}q.prototype.clear=function(){this.__data__=$?$(null):{}},q.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},q.prototype.get=function(e){var t=this.__data__;if($){var r=t[e];return r===h?void 0:r}return T.call(t,e)?t[e]:void 0},q.prototype.has=function(e){var t=this.__data__;return $?void 0!==t[e]:T.call(t,e)},q.prototype.set=function(e,t){return this.__data__[e]=$&&void 0===t?h:t,this},W.prototype.clear=function(){this.__data__=[]},W.prototype.delete=function(e){var t=this.__data__,r=H(t,e);return!(r<0)&&(r==t.length-1?t.pop():M.call(t,r,1),!0)},W.prototype.get=function(e){var t=this.__data__,r=H(t,e);return r<0?void 0:t[r][1]},W.prototype.has=function(e){return H(this.__data__,e)>-1},W.prototype.set=function(e,t){var r=this.__data__,n=H(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},K.prototype.clear=function(){this.__data__={hash:new q,map:new(G||W),string:new q}},K.prototype.delete=function(e){return Z(this,e).delete(e)},K.prototype.get=function(e){return Z(this,e).get(e)},K.prototype.has=function(e){return Z(this,e).has(e)},K.prototype.set=function(e,t){return Z(this,e).set(e,t),this};var Q=ee((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(ne(e))return V?V.call(e):"";var t=e+"";return"0"==t&&1/e==-v?"-0":t}(t);var r=[];return _.test(e)&&r.push(""),e.replace(x,(function(e,t,n,o){r.push(n?o.replace(C,"$1"):t||e)})),r}));function X(e){if("string"==typeof e||ne(e))return e;var t=e+"";return"0"==t&&1/e==-v?"-0":t}function ee(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(d);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=e.apply(this,n);return r.cache=a.set(o,i),i};return r.cache=new(ee.Cache||K),r}ee.Cache=K;var te=Array.isArray;function re(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ne(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&B.call(e)==g}var oe=function(e,t,r){var n=null==e?void 0:Y(e,t);return void 0===n?r:n},ae=function(e){return i.createElement(t,e)},ie=function(e){switch(e){case"place":case"places":return"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z";case"times":case"close":return"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";default:return null}},le=function(e){var t=e.color,r=e.height,n=e.width,o=e.type,a=void 0!==r?r:24,l=void 0!==n?n:24;return i.createElement("svg",f({style:{width:l+"px",height:a+"px"},viewBox:"0 0 "+a+" "+l},e),i.createElement("path",{fill:t||"#000000",d:ie(o)}))};var se=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t},ue=function(e){function t(){return e.apply(this,arguments)||this}se(t,e);var n=t.prototype;return n.getButtonClassName=function(){var e="nb-toggle-button";return this.props.size&&("lg"===this.props.size?e+=" btn-lg":"sm"===this.props.size?e+=" btn-sm":"xs"===this.props.size&&(e+=" btn-xs")),e.trim()},n.render=function(){var e=this,t=this.props,n=t.hasError,o=t.errorMsg,a=t.type,l=t.defaultValue,s=t.toggleButtonData,u=t.errorStyle,c=t.errorClass,p=void 0===c?"":c,f=t.onChange,d=t.className,h=t.containerClass,v=t.name;return i.createElement("div",{className:"nb-toggle-button-container "+(n?"has-error":"")+" "+h},i.createElement(r.ToggleButtonGroup,{type:a,value:l,onChange:f,name:v,className:d},void 0!==s&&s.length>0&&s.map((function(t,n){return i.createElement(r.ToggleButton,{id:t.value,className:e.getButtonClassName(),value:t.value,name:t.name,key:n},t.label)}))),n?i.createElement("div",{className:"nbform-err-msg "+p,style:u},o):null)},t}(e.PureComponent);ue.defaultProps={className:"",type:"radio",toggleButtonData:"",defaultValue:null,onChange:function(){},size:null};var ce=function(e){function t(t){var r=e.call(this,t)||this;return r.state={},r}return se(t,e),t.prototype.render=function(){var e=this.props,t=e.errorMsg,r=e.children,n=e.hasError,o=e.className,a=e.errorClass,l=e.wrap,s=e.containerClass,u=void 0===s?"":s,c=e.id,p=void 0===c?"":c,f=e.errorStyle;return i.createElement("div",{className:"nb_inpgrp "+u,id:p},i.createElement("div",{className:"nb__inpgrp_elements "+o,style:{flexWrap:l?"wrap":"nowrap"}},r),n?i.createElement("div",{className:"nbform-err-msg "+a,style:f},t):null)},t}(e.PureComponent);ce.defaultProps={children:null,errorMsg:"",className:"",wrap:!1};var pe=function(e){function t(t){var r=e.call(this,t)||this;return r.state={},r}return se(t,e),t.prototype.render=function(){var e,t=this.props,r=t.onChange,n=t.checked,o=t.label,a=t.errorStyle,l=t.errorClass,s=t.size,u=t.containerClass,c=void 0===u?"":u,p=t.className,f=void 0===p?"":p,d=t.textClass,h=void 0===d?"":d,v=t.id,y=t.hasError,m=t.errorMsg,g=t.labelPosition,b=void 0===g?"right":g;return i.createElement(i.Fragment,null,i.createElement("label",{className:"nb-switch "+c+" "+f,id:v},i.createElement("input",{className:"nb-switch-checkbox",type:"checkbox",onChange:r,checked:n}),i.createElement("div",{className:s?"nb-switch-toggle "+s:"nb-switch-toggle"}),o?i.createElement("span",{style:(e={cssFloat:b},e["margin-"+("left"===b?"right":"left")]="5px",e),className:"nb-switch-label "+h+" "+(y?"error-msg":"")},o):null),y?i.createElement("div",{className:"nbform-err-msg "+l,style:a},m):null)},t}(i.PureComponent);pe.defaultProps={onChange:function(){},isChecked:null,label:null};var fe=function(e){function t(t){var r=e.call(this,t)||this;return r.clearInput=function(){r.props.onChange({target:{value:""}}),r.inputEl.focus()},r.state={},r.inputEl=i.createRef(),r}se(t,e);var n=t.prototype;return n.swicthInputEl=function(e){var t=this,n=e.props;switch(n.type){case"text":case"email":case"tel":case"number":case"password":return i.createElement(r.FormControl,{style:n.inputStyle,type:n.type,value:n.value,className:"form-control "+n.inputClass,placeholder:n.placeholder,onChange:n.onChange,onBlur:n.onBlur,maxLength:n.maxLength,min:n.min,disabled:n.disabled,autoFocus:n.autoFocus,name:n.name,inputRef:function(e){t.inputEl=e,n.getRef&&"function"==typeof n.getRef&&n.getRef(e)},onKeyPress:function(e){n.onKeyPress?n.onKeyPress(e):"Enter"===e.key&&t.inputEl.blur()},onFocus:function(e){n.onFocus&&n.onFocus(e);try{var r=window.innerWidth<768;setTimeout((function(){if(r){var e=t.inputEl.getBoundingClientRect(),n=document.documentElement,o=document.documentElement.scrollTop;o||(o=window.scrollY,n=window),o+=e.top-10-60,n.scrollTo(0,o)}}),500)}catch(e){}},autoComplete:n.autoCompleteType||"off"});case"textarea":return i.createElement(r.FormControl,{inputRef:function(e){t.inputEl=e,n.getRef&&"function"==typeof n.getRef&&n.getRef(e)},className:"form-control "+n.inputClass,componentClass:n.type,value:n.value,placeholder:n.placeholder,onBlur:n.onBlur,onChange:n.onChange,name:n.name,maxLength:n.maxLength,disabled:n.disabled,rows:n.rows,autoComplete:n.autoCompleteType||"off",onFocus:function(e){n.onFocus&&n.onFocus(e);try{var r=window.innerWidth<768;setTimeout((function(){if(r){var e=t.inputEl.getBoundingClientRect(),n=document.documentElement,o=document.documentElement.scrollTop;o||(o=window.scrollY,n=window),o+=e.top-10-60,n.scrollTo(0,o)}}),500)}catch(e){}}});default:return""}},n.getWrapperClassName=function(){var e="form-group",t=this.props,r=t.containerClass,n=t.label,o=t.rightText,a=t.leftText,i=t.rightIcon,l=t.rightImage,s=t.autoClear,u=t.leftIcon,c=t.leftImage;return(u||c)&&(e+=" left-icon-form-group"),(i||l||s)&&(e+=" right-icon-form-group"),a&&(e+=" left-text-form-group"),o&&(e+=" right-text-form-group"),n||(e+=" no-label"),r?(r+" "+e).trim():e.trim()},n.render=function(){var e=this.props,t=e.errorMsg,n=e.hasError,o=e.leftIcon,a=e.leftImage,l=e.rightImage,s=e.autoClear,u=e.value,c=e.rightIcon,p=e.leftText,f=e.rightText,d=e.label,h=e.validationState,v=e.id,y=e.errorClass,m=e.errorStyle,g=e.size,b=e.required;return i.createElement(r.FormGroup,{controlId:v,bsSize:g,className:this.getWrapperClassName(),validationState:h},d?i.createElement(r.ControlLabel,null,d,b?i.createElement("sup",null,"*"):""):null,o?i.createElement("span",{className:"left-input-icon"},o):a?i.createElement("img",{alt:"left-input-img",className:"left-input-image",src:a}):p?i.createElement("span",{className:"left-input-text"},p):null,s||c?i.createElement("span",{className:"right-input-icon"},s?u?i.createElement(le,{type:"close",onClick:this.clearInput,className:"input-clear"}):null:c):l?i.createElement("img",{alt:"right-input-img",className:"right-input-image",src:c}):f?i.createElement("span",{className:"right-input-text"},f):null,this.swicthInputEl(this),n?i.createElement("div",{className:"nbform-err-msg "+y,style:m},t):null)},t}(e.PureComponent);fe.defaultProps={type:"text",placeholder:"",errorMsg:"",hasError:!1,leftIcon:null,rightIcon:null,leftText:null,rightText:null,value:"",label:"",disabled:!1,ref:"",validationState:null,id:"",size:"",autoComplete:"off",containerClass:"",inputClass:"",rows:2,onChange:function(){},onBlur:function(){},onFocus:function(){},autoClear:!1,required:!1,autoFocus:!1,name:""};var de=function(e){function t(t){var r=e.call(this,t)||this;return r.state={},r}return se(t,e),t.prototype.render=function(){var e=this.props,t=e.containerClass,r=void 0===t?"":t,o=e.inputClass,a=void 0===o?"":o,l=e.onSelectFlag,s=e.onPhoneNumberChange,u=e.defaultCountry,c=e.errorStyle,p=e.errorClass,d=e.value,h=e.placeholder,v=e.errorMsg,y=e.hasError,m=e.maxLength,g=e.size,b=e.disabled,E=e.id,_=e.telInputProps;return i.createElement("div",{className:"intl-custom "+r},i.createElement(n,{css:["intl-tel-input","form-control "+("lg"===g?"input-lg":"")+" "+(y?"has-error":""),a],separateDialCode:!0,defaultCountry:u||"in",preferredCountries:["in","us","gb"],fieldId:E,telInputProps:f({type:"number",maxLength:m},_),autoComplete:"tel",onSelectFlag:l,onPhoneNumberChange:s,value:d,placeholder:h,disabled:b}),y?i.createElement("div",{className:"nbform-err-msg "+p,style:c},v):null)},t}(e.PureComponent);de.defaultProps={separateDialCode:!0,defaultCountry:"in",telInputProps:{},placeholder:"Enter Mobile Number",size:""};var he=function(e){function t(){return e.apply(this,arguments)||this}return se(t,e),t.prototype.render=function(){var e=this.props,t=e.errorMsg,n=e.className,o=e.hasError,a=e.textClass,l=void 0===a?"":a,s=e.validationState,u=e.id,c=e.readOnly,p=e.disabled,f=e.text,d=void 0===f?"":f,h=e.errorStyle,v=e.errorClass,y=e.onChange,m=e.value,g=e.checked,b=e.inline,E=e.containerClass,_=void 0===E?"":E;return i.createElement(r.Checkbox,{id:u,inline:b,value:m,checked:g,disabled:p,readOnly:c,validationState:s,onChange:y,className:"nb-checkbox "+n+" "+_+" "+(o?"error":"")},i.createElement("span",{className:l,dangerouslySetInnerHTML:{__html:d}}),o?i.createElement("div",{className:"nbform-err-msg "+v,style:h},t):null)},t}(e.PureComponent);he.defaultProps={inline:!1,checked:!1,readOnly:!1,hasError:!1,disabled:!1,errorMsg:"",onChange:function(){},validationState:null,id:"",value:null,containerClass:"",className:""};var ve=Array.isArray,ye="object"==typeof u&&u&&u.Object===Object&&u,me="object"==typeof self&&self&&self.Object===Object&&self,ge=ye||me||Function("return this")(),be=ge.Symbol,Ee=Object.prototype,_e=Ee.hasOwnProperty,xe=Ee.toString,Ce=be?be.toStringTag:void 0;var we=function(e){var t=_e.call(e,Ce),r=e[Ce];try{e[Ce]=void 0;var n=!0}catch(e){}var o=xe.call(e);return n&&(t?e[Ce]=r:delete e[Ce]),o},Se=Object.prototype.toString;var Ne=function(e){return Se.call(e)},ke="[object Null]",Ie="[object Undefined]",Pe=be?be.toStringTag:void 0;var je=function(e){return null==e?void 0===e?Ie:ke:Pe&&Pe in Object(e)?we(e):Ne(e)};var Oe=function(e){return null!=e&&"object"==typeof e},Fe="[object Symbol]";var Ae=function(e){return"symbol"==typeof e||Oe(e)&&je(e)==Fe},Le=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Te=/^\w*$/;var Be=function(e,t){if(ve(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!Ae(e))||(Te.test(e)||!Le.test(e)||null!=t&&e in Object(t))};var Re=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},ze="[object AsyncFunction]",Me="[object Function]",Ge="[object GeneratorFunction]",$e="[object Proxy]";var De=function(e){if(!Re(e))return!1;var t=je(e);return t==Me||t==Ge||t==ze||t==$e},Ve=ge["__core-js_shared__"],qe=function(){var e=/[^.]+$/.exec(Ve&&Ve.keys&&Ve.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var We=function(e){return!!qe&&qe in e},Ke=Function.prototype.toString;var He=function(e){if(null!=e){try{return Ke.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Ye=/^\[object .+?Constructor\]$/,Ue=Function.prototype,Ze=Object.prototype,Je=Ue.toString,Qe=Ze.hasOwnProperty,Xe=RegExp("^"+Je.call(Qe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var et=function(e){return!(!Re(e)||We(e))&&(De(e)?Xe:Ye).test(He(e))};var tt=function(e,t){return null==e?void 0:e[t]};var rt=function(e,t){var r=tt(e,t);return et(r)?r:void 0},nt=rt(Object,"create");var ot=function(){this.__data__=nt?nt(null):{},this.size=0};var at=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},it="__lodash_hash_undefined__",lt=Object.prototype.hasOwnProperty;var st=function(e){var t=this.__data__;if(nt){var r=t[e];return r===it?void 0:r}return lt.call(t,e)?t[e]:void 0},ut=Object.prototype.hasOwnProperty;var ct=function(e){var t=this.__data__;return nt?void 0!==t[e]:ut.call(t,e)},pt="__lodash_hash_undefined__";var ft=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nt&&void 0===t?pt:t,this};function dt(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}dt.prototype.clear=ot,dt.prototype.delete=at,dt.prototype.get=st,dt.prototype.has=ct,dt.prototype.set=ft;var ht=dt;var vt=function(){this.__data__=[],this.size=0};var yt=function(e,t){return e===t||e!=e&&t!=t};var mt=function(e,t){for(var r=e.length;r--;)if(yt(e[r][0],t))return r;return-1},gt=Array.prototype.splice;var bt=function(e){var t=this.__data__,r=mt(t,e);return!(r<0)&&(r==t.length-1?t.pop():gt.call(t,r,1),--this.size,!0)};var Et=function(e){var t=this.__data__,r=mt(t,e);return r<0?void 0:t[r][1]};var _t=function(e){return mt(this.__data__,e)>-1};var xt=function(e,t){var r=this.__data__,n=mt(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function Ct(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ct.prototype.clear=vt,Ct.prototype.delete=bt,Ct.prototype.get=Et,Ct.prototype.has=_t,Ct.prototype.set=xt;var wt=Ct,St=rt(ge,"Map");var Nt=function(){this.size=0,this.__data__={hash:new ht,map:new(St||wt),string:new ht}};var kt=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var It=function(e,t){var r=e.__data__;return kt(t)?r["string"==typeof t?"string":"hash"]:r.map};var Pt=function(e){var t=It(this,e).delete(e);return this.size-=t?1:0,t};var jt=function(e){return It(this,e).get(e)};var Ot=function(e){return It(this,e).has(e)};var Ft=function(e,t){var r=It(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function At(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}At.prototype.clear=Nt,At.prototype.delete=Pt,At.prototype.get=jt,At.prototype.has=Ot,At.prototype.set=Ft;var Lt=At,Tt="Expected a function";function Bt(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(Tt);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=e.apply(this,n);return r.cache=a.set(o,i)||a,i};return r.cache=new(Bt.Cache||Lt),r}Bt.Cache=Lt;var Rt=Bt,zt=500;var Mt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gt=/\\(\\)?/g,$t=function(e){var t=Rt(e,(function(e){return r.size===zt&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Mt,(function(e,r,n,o){t.push(n?o.replace(Gt,"$1"):r||e)})),t}));var Dt=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o},Vt=1/0,qt=be?be.prototype:void 0,Wt=qt?qt.toString:void 0;var Kt=function e(t){if("string"==typeof t)return t;if(ve(t))return Dt(t,e)+"";if(Ae(t))return Wt?Wt.call(t):"";var r=t+"";return"0"==r&&1/t==-Vt?"-0":r};var Ht=function(e){return null==e?"":Kt(e)};var Yt=function(e,t){return ve(e)?e:Be(e,t)?[e]:$t(Ht(e))},Ut=1/0;var Zt=function(e){if("string"==typeof e||Ae(e))return e;var t=e+"";return"0"==t&&1/e==-Ut?"-0":t};var Jt=function(e,t){for(var r=0,n=(t=Yt(t,e)).length;null!=e&&r<n;)e=e[Zt(t[r++])];return r&&r==n?e:void 0};var Qt=function(e,t,r){var n=null==e?void 0:Jt(e,t);return void 0===n?r:n},Xt={control:function(e){return f({},e,{boxShadow:"none"})}},er=function(e){function t(t){var r=e.call(this,t)||this;return r.state={loaded:!1},r}se(t,e);var n=t.prototype;return n.componentDidMount=function(){this.setState({loaded:!0})},n.getWrapperClassName=function(){var e=this.props,t=e.size,r=e.containerClass,n="nb-select";return"lg"===t&&(n+=" nb-select__lg"),"sm"===t&&(n+=" nb-select__sm"),"xs"===t&&(n+=" nb-select__xs"),r?(r+" "+n).trim():n.trim()},n.render=function(){var e=this.props,t=e.errorMsg,n=e.hasError,a=e.onChange,l=e.size,s=e.label,u=e.validationState,c=e.errorStyle,p=e.errorClass,f=e.id,d=e.options,h=e.selectedValue,v=e.isSearchableboolean,y=e.validationId,m=e.containerId,g=this.state.loaded,b=Qt(h,"value");return i.createElement(r.FormGroup,{controlId:y,className:this.getWrapperClassName(),validationState:u},s?i.createElement(r.ControlLabel,null,s):null,g?i.createElement(o,{onChange:a,id:m||f,options:d,blurInputOnSelect:!0,className:"nb-select-container",classNamePrefix:"nb-select",isFocused:!0,styles:Xt,placeholder:this.props.placeholder,isSearchable:v,isDisabled:this.props.disabled,value:h}):b&&i.createElement("div",{className:"nb-select-loader "+(l||"")},i.createElement("span",{className:"nb-select-loader__value"},b&&b.toLowerCase?b.toLowerCase():"")),n?i.createElement("div",{className:"nbform-err-msg "+p,style:c},t):null)},t}(e.PureComponent);er.defaultProps={placeholder:"Select ...",errorMsg:"",hasError:!1,label:"",disabled:!1,validationState:null,id:"",size:void 0,containerClass:"",isSearchableboolean:!1,selectedValue:null,onChange:function(){}};var tr=function(e){function t(){return e.apply(this,arguments)||this}return se(t,e),t.prototype.render=function(){var e=this.props,t=e.id,n=e.readOnly,o=e.disabled,a=e.text,l=e.onChange,s=e.value,u=e.checked,c=e.name,p=e.inline,f=e.hasError,d=e.containerClass;return i.createElement(r.Radio,{id:t,inline:p,value:s,name:c,defaultChecked:u,disabled:o,readOnly:n,validationState:!p&&f?"error":null,onChange:l,className:"nb-radio "+d},a)},t}(e.PureComponent);function rr(e,t){if(void 0===t&&(t=!1),!e)return"0";if(t)return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");var r=!1;"-"===(e=e.toString()).charAt(0)&&(e=e.substr(1),r=!0);var n="";e.indexOf(".")>0&&(n=e.substring(e.indexOf("."),e.length));var o=(e=(e=Math.round(e)).toString()).substring(e.length-3),a=e.substring(0,e.length-3);""!==a&&(o=","+o);var i=a.replace(/\B(?=(\d{2})+(?!\d))/g,",")+o+n;return r?"-"+i:""+i}tr.defaultProps={checked:!1,readOnly:!1,disabled:!1,inline:!1,onChange:function(){},validationState:null,id:"",name:"",value:null,containerClass:""};var nr=function(e){return Boolean("object"===p(e)&&null!==e)};var or=function(e){function t(t){var r=e.call(this,t)||this;r.handleChange=function(e){r.setState({address:e},(function(){r.props.onSelect(r.state.address)})),r.props.onInputChange&&r.props.onInputChange(e)},r.handleSelect=function(e,t){try{r.inputRef.blur()}catch(e){console.log("unable to remove focus",e)}a.geocodeByPlaceId(t,"/api/v1/localities/place_detail/"+t+"/_search").then((function(t){r.setState({placeObj:t[0]},(function(){null!=r.props.currentBound?!function(e,t){void 0===t&&(t={});var r=t;return!(null==r||void 0===r.geometry||null===r.geometry||!e.contains(r.geometry.location))}(r.props.currentBound,t[0])?(r.setState({address:""}),r.props.showAlertMsg(!0,"Please select another locality in "+r.props.city.toLowerCase())):(r.setState({address:e}),a.getLatLng(t[0]).then((function(n){r.props.showAlertMsg(!1,""),r.props.onSelect(t,n,e)}))):(r.setState({address:e}),a.getLatLng(t[0]).then((function(n){r.props.onSelect(t,n,e)})))}))})).catch((function(e){return console.error("Error",e)}))},r.componentDidMount=function(){r.setState({address:r.props.prfillValue?r.props.prfillValue:""})},r.getClassName=function(){var e="",t=r.props,n=t.size,o=t.className,a=void 0===o?"":o,i=t.containerClass;return n&&(e+="nb-google-autocomplete-"+n)," "+a+" "+e+" "+(void 0===i?"":i)},r.render=function(){var e=r.props,t=e.city,n=e.page,o=e.debounce,a=r.state,s=a.address,u=a.top,c="/api/v1/localities/autocomplete/_search?hint="+s+"&city="+t.toLowerCase()+"&page="+n;return i.createElement(l,{value:r.state.address,onChange:r.handleChange,onSelect:r.handleSelect,onBlur:r.handleBlur,debounce:o,city:t,getSuggestionUrl:c,page:n,searchOptions:r.props.searchOptions,shouldFetchSuggestions:r.state.address.length>1},(function(e){var t=e.getInputProps,n=e.suggestions,o=e.getSuggestionItemProps,a=u,l=n.length,s=40*l+20;if(l&&r.inputRef&&r.inputRef.getBoundingClientRect&&"object"===("undefined"==typeof window?"undefined":p(window))){var c=r.inputRef.getBoundingClientRect().top;window.innerHeight-c-50<s&&(a=-1*s)}var d=[].concat(n).reverse();return i.createElement("div",{className:"nb-google-autocomplete"+r.getClassName()},i.createElement(fe,f({},t(f({},r.props,{getRef:function(e){r.inputRef=e}})),{getRef:function(e){r.inputRef=e}})),n.length>0&&i.createElement("div",{className:"autocomplete-dropdown-container",style:{top:a+"px"}},(a<0?d:n).map((function(e,t){return i.createElement("div",f({key:e.id||t},o(e,{className:"suggestion-item"})),i.createElement("span",null,i.createElement(le,{type:"place",className:"place-icon"})," ",e.description))}))))}))};var n=t.size,o=75;return"md"!==n&&n||(o=65),"sm"===n&&(o=55),t.label||(o-=25),r.state={address:"",placeObj:[],top:o},r.inputRef=i.createRef(),r}return se(t,e),t.prototype.UNSAFE__componentWillReceiveProps=function(e){""!==this.state.address&&e.clearAutocompleteValue&&this.setState({address:""})},t}(e.Component);or.defaultProps={size:void 0,id:"",containerClass:"",hasError:!1,leftIcon:null,rightIcon:null,leftText:null,rightText:null,label:"",disabled:!1,searchOptions:null,currentBound:null,page:"default",city:"",debounce:500,rightImage:null,leftImage:null,autoClear:!1};var ar=function(e,t,r){void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r=!1),s("object"===p(e),"INIT_STATE must be object");var n=Object.keys(e),o={},a={};return r&&(a.parent=r),t.forEach((function(t,r){var i=t.id,l=t.type,s=t.defaultDialCode,u=void 0===s?"91":s,c=t.defaultCountry,p=void 0===c?"in":c,d="";if(-1!==n.indexOf(i)&&(d=e[i]),"tel"===l)o[i]=f({value:d},a),o[i+"_dialCode"]=f({value:u},a),o[i+"_iso2"]=f({value:p},a);else{if("inputGroup"===l)return void(o=f({},o,{},ar(e,t.input,i||"group-"+r)));o[i]=f({value:d},a)}Object.keys(t).forEach((function(e){var r=t[e];if("string"==typeof r&&r.match(/^\$(.*)\$$/)&&r.match(/^\$(.*)\$$/).length>1){var n,l=r.match(/^\$(.*)\$$/)[1];o[i]||(o[i]=f({value:""},a)),o[l]||(o[l]=f({value:""},a)),o[l]._dependencies||(o[l]._dependencies={}),o[l]._dependencies[i]||(o[l]._dependencies[i]=[]),o[i].dependency=((n={})[e]=o[l].value||"",n),o[l]._dependencies[i].push(e)}}))})),o},ir=function(e){s("object"===p(e),"Invalid Data: make sure pass valid formData generated by NbForm");var t=Object.keys(e),r={};return t.forEach((function(t){s(Object.prototype.hasOwnProperty.call(e[t],"value"),"Invalid Data: make sure pass valid formData generated by NbForm"),r[t]=e[t].value||null})),r},lr={display:"flex",justifyContent:"flex-start"},sr=function(e){var t=e.inputId,r=e.idPrefix,n=e.userInput;try{var o=document.getElementById(t+"-container");if(n.nextFocusId)document.getElementById((r?r+"-":"")+n.nextFocusId+"-nbInput").focus();else if(o.nextElementSibling&&o.nextElementSibling.id){var a=o.nextElementSibling.id;if(a.match(new RegExp(r+"-(.*)-nbInput-container"))){var i=a.replace("-container","");document.getElementById(i).focus()}}}catch(e){}},ur=function(e,t){var r=t.inputId,n=t.userInput;if("Enter"===e.key)try{var o=document.getElementById(r);""!==o.value&&(o.blur(),sr(t))}catch(e){console.log("seems not found")}n.onKeyPress&&"function"==typeof n.onKeyPress&&n.onKeyPress(e)};function cr(e,t,r,n){void 0===n&&(n={});var o=n,a=o.idPrefix,l=o.customLabel,u=o.formData,c=o.nbGAEventCategory,d=o.nbGaEvent,h=o.index,v=o.customProps,y=o.extraProps,m=o.defaultStyle,g=void 0===m?{}:m,b=e.id,E=e.uiLabel,_=e.size,x=void 0===_?"":_,C=e.labelClass,w=e.inlineLabel,S=void 0!==w&&w,N=e.autoCompleteType,k=e.style,I=void 0===k?{}:k,P=e.errorClassName,j=void 0===P?"":P,O=t.value,F=t.isError,A=void 0!==F&&F,L=t.errorMsg,T=void 0===L?oe(e.errorMsg,"default"):L,B=t.dependency,R=void 0===B?{}:B,z=O||"",M=[],G=(a?a+"-":"")+b+"-nbInput",$=function(e,t,r){void 0===e&&(e={}),void 0===t&&(t={});var n=r.isError,o=void 0!==n&&n,a={},i={};return nr(e.label)&&(i=e.label),nr(e.error)&&(a=e.error),nr(t.label)&&(i=t.label),nr(t.error)&&(a=t.error),o&&nr(e.onError)&&(nr(e.onError.label)&&(i=e.onError.label),nr(e.onError.error)&&(a=e.onError.error)),o&&nr(t.onError)&&(nr(t.onError.label)&&(i=t.onError.label),nr(t.onError.error)&&(a=t.onError.error)),{labelStyle:i,errorStyle:a}}(g,I,{isError:A}),D=$.errorStyle,V=$.labelStyle;(E||l)&&M.push(i.createElement("label",{key:b+"InputLabel",htmlFor:G,className:C,style:f({marginRight:"5px",lineHeight:"25px",fontWeight:"600"},V)},l||E));var q=!1;if("undefined"!=typeof window&&window.isHybridView&&(q=!0),"function"==typeof e.customDisabled&&(e.disabled=Boolean(e.customDisabled(z,ir(u),y))),"function"==typeof e.customVisible&&!1===Boolean(e.customVisible(ir(u)),y))return null;if("function"==typeof e.customOptions){var W=e.customOptions(ir(u));"object"===p(W)&&Array.isArray(W)&&(e.options=W)}if("customInput"===e.type&&"function"==typeof e.render&&M.push(i.createElement(i.Fragment,null,i.createElement("div",{id:G},e.render(z,(function(e){r(b,e)}))),A&&i.createElement("div",{className:"nbform-err-msg "+j,style:D},T))),"inputGroup"===e.type&&M.push(i.createElement(ce,f({},e,v,R,{hasError:A,errorStyle:D,errorClass:j,errorMsg:T,id:G,key:b+"Input"}),(e.input||[]).map((function(e,t){"inputGroup"===e.type&&!e.id&&(e.id="sub-group-"+t);var n=e.id;return s(Boolean(n),"Invalid input id for data at input group "+h+" at sub index "+t),cr(e,u[n]||"",r,{idPrefix:n,formData:u,nbGaEvent:d,groupInputIndex:t})})))),"switch"===e.type&&M.push(i.createElement(pe,f({},v,R,{key:b+"Input",id:G,errorStyle:D,errorClass:j,checked:Boolean(z),label:e.text,labelPosition:e.textPosition||"right",className:e.containerClass||e.className,textClass:e.textClass||"",hasError:A,errorMsg:T,onChange:function(e){var t=!0===oe(e,"target.checked");r(b,t)}}))),"toggleButton"===e.type&&M.push(i.createElement(ue,f({id:G,key:b+"Input",size:x,hasError:A,errorStyle:D,errorClass:j,errorMsg:T,type:e.subType||"radio",onChange:function(t){e.options.forEach((function(e){e.value===t&&e.nbGAEvent&&"function"==typeof d&&d(c,e.nbGAEvent)})),r(b,t)},defaultValue:z,toggleButtonData:e.options,name:b+"ToggleButton"},v,R))),"input"===e.type){var K=e.subType;q&&-1!==["int","float"].indexOf(oe(e,"validation.dataType"))&&(K="number");var H="number"===K&&e.currencyFormatter;M.push(i.createElement(fe,f({key:b+"Input"},e,v,R,{size:x,label:"",value:H?rr(z,e.currencyFormatterInternational||!1):z,type:"number"===K?"text":K,hasError:A,errorStyle:D,errorClass:j,name:N||b,errorMsg:T,validationState:A?"error":null,id:G,onKeyPress:function(t){ur(t,{inputId:G,userInput:e,idPrefix:a})},onChange:function(e){var t=oe(e,"target.value");"number"===K&&void 0!==t&&(H&&(t=parseFloat(t.toString().replace(/,/g,""))),t&&"."===t[t.length-1]?t.match(/(\.)/g).length>1&&(t=t.toString().slice(0,t.length-1)):t=isNaN(parseFloat(t))?t.toString().slice(0,t.lenght-1):parseFloat(t)),r(b,t)}})))}return"select"===e.type&&M.push(i.createElement(er,f({key:b+"SelectInput"},e,v,R,{selectedValue:z,hasError:A,errorStyle:D,errorClass:j,validationState:A?"error":null,errorMsg:T,id:G,size:x,onChange:function(e){r(b,e)},isSearchableboolean:!!e.isSearchable&&oe(window,"innerWidth")>768}))),"tel"===e.type&&M.push(i.createElement("div",{key:b+"Input",className:"form-group"},i.createElement(de,f({},e,v,R,{errorStyle:D,errorClass:j,onSelectFlag:function(e,t){var n=t.dialCode,o=t.iso2;r([b+"_dialCode",b+"_iso2"],[n,o])},value:z,size:x,onPhoneNumberChange:function(e,t){r(b,t)},hasError:A,errorMsg:T,validationState:A?"error":null,id:G,telInputProps:{onKeyPress:function(t){ur(t,{inputId:G,userInput:e,idPrefix:a})}},defaultCountry:oe(u,[b+"_iso2","value"])||"in",maxLength:"91"===oe(u,[b+"_dialCode","value"])?10:15})))),"checkbox"===e.type&&M.push(i.createElement(he,f({key:b+"Input",id:G},v,R,e,{errorStyle:D,errorClass:j,value:Boolean(z),checked:Boolean(z),text:e.checkboxText,className:e.containerClass||e.className,textClass:e.textClass||"",hasError:A,errorMsg:T,onChange:function(e){var t=oe(e,"target.checked");r(b,t)}}))),"radio"===e.type&&e.options&&e.options.length>0&&M.push(i.createElement("div",{key:b+"Input",id:G,style:{marginBottom:"15px"}},e.options.map((function(t){var n=t.label,o=t.value;return i.createElement(tr,f({name:G,onChange:function(e){var t=e.target.value;r(b,t)}},v,R,{text:n,disabled:Boolean(e.disabled),value:o,hasError:A,key:G+"-"+t.value,id:G+"-"+t.value,inline:void 0===e.inline||e.inline}))})),A&&i.createElement("div",{className:"nbform-err-msg "+j,style:D},T))),"rating"===e.type&&M.push(i.createElement("div",{key:b+"Input",className:e.containerClass||""},i.createElement(ae,f({id:G},v,R,{className:"react-rater "+(e.className||""),total:e.max||5,rating:parseInt(z)||0,onRate:function(t){var n=t.rating;e.nbGAEvent&&d(c,e.nbGAEvent),r(b,n)}})),A&&i.createElement("div",{className:"nbform-err-msg "+j,style:D},T))),"location-autocomplete"===e.type&&M.push(i.createElement("div",{key:b+"Input",className:"form-group"},i.createElement(or,f({},e,v,R,{onSelect:function(t,n,o){"object"===p(t)&&Array.isArray(t)&&t.length>0?(r(b,{result:t,latLng:n,selectedAddress:o}),sr({inputId:G,idPrefix:a,userInput:e})):""===t&&r(b,{result:[],latLng:{},selectedAddress:""})},key:G+"Input",id:G,type:"text",hasError:A,errorMsg:T,validationState:A?"error":null,leftIcon:i.createElement(le,{type:"place"}),onKeyPress:function(t){ur(t,{inputId:G,userInput:e,idPrefix:a})}})))),0===M.length?(console.info("Invalid Input. NbForm-"+b),null):i.createElement("div",{key:G+"-container",className:e.wrapperClass||"",id:G+"-container",style:S?lr:{}},M)}var pr=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return(t=e.call.apply(e,[this].concat(o))||this).getButton=function(){var e=t.props,n=e.className,o=e.containerClass,a=e.btnStyle,l=e.size,s=e.disabled,u=e.type,c=e.block,p=e.text,f=e.onClick,d=e.children,h=e.id;return i.createElement(r.Button,{id:h,className:n+" "+o,onClick:f,bsStyle:a,bsSize:l,disabled:s,type:u,block:c},d||p||"")},t}return se(t,e),t.prototype.render=function(){var e=this.props.tooltip;return e?i.createElement(r.OverlayTrigger,{placement:"bottom",overlay:i.createElement(r.Tooltip,{id:"button-tooltip-"+(new Date).getTime()},e)},this.getButton()):this.getButton()},t}(e.PureComponent);pr.defaultProps={className:"",btnStyle:"default",size:"",disabled:!1,onClick:function(){},type:"button",block:!1,tooltip:!1,id:""};var fr=c((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function s(e,t,r,n){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),i=new k(n||[]);return a._invoke=function(e,t,r){var n=c;return function(o,a){if(n===f)throw new Error("Generator is already running");if(n===d){if("throw"===o)throw a;return P()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var l=w(i,r);if(l){if(l===h)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===c)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=f;var s=u(e,t,r);if("normal"===s.type){if(n=r.done?d:p,s.arg===h)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(e,r,i),a}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var c="suspendedStart",p="suspendedYield",f="executing",d="completed",h={};function v(){}function y(){}function m(){}var g={};g[a]=function(){return this};var b=Object.getPrototypeOf,E=b&&b(b(I([])));E&&E!==r&&n.call(E,a)&&(g=E);var _=m.prototype=v.prototype=Object.create(g);function x(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function C(e){var t;this._invoke=function(r,o){function a(){return new Promise((function(t,a){!function t(r,o,a,i){var l=u(e[r],e,o);if("throw"!==l.type){var s=l.arg,c=s.value;return c&&"object"==typeof c&&n.call(c,"__await")?Promise.resolve(c.__await).then((function(e){t("next",e,a,i)}),(function(e){t("throw",e,a,i)})):Promise.resolve(c).then((function(e){s.value=e,a(s)}),(function(e){return t("throw",e,a,i)}))}i(l.arg)}(r,o,t,a)}))}return t=t?t.then(a,a):a()}}function w(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,w(e,r),"throw"===r.method))return h;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var o=u(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,h;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,h):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}return{next:P}}function P(){return{value:t,done:!0}}return y.prototype=_.constructor=m,m.constructor=y,m[l]=y.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l in e||(e[l]="GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},x(C.prototype),C.prototype[i]=function(){return this},e.AsyncIterator=C,e.async=function(t,r,n,o){var a=new C(s(t,r,n,o));return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},x(_),_[l]="Generator",_[a]=function(){return this},_.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=I,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return l.type="throw",l.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],l=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),N(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),h}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function dr(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){return void r(e)}l.done?t(s):Promise.resolve(s).then(n,o)}var hr=function(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){dr(a,n,o,i,l,"next",e)}function l(e){dr(a,n,o,i,l,"throw",e)}i(void 0)}))}};var vr=function(){var e=hr(fr.mark((function e(t,r,n,o){var a,i,l,s,u,c,f,d,h,v,y,m,g,b,E,_,x,C,w,S,N,k,I,P,j,O,F;return fr.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=t.type,i=t.id,l=t.subType,s=void 0===l?"":l,void 0===n&&(n={}),u=!1,c=[],f=oe(o,"formData")||{},d=oe(o,"extraProps")||{},!n){e.next=37;break}if(v=(h=n).minlength,y=h.required,m=h.min,g=h.max,b=h.dataType,E=void 0===b?"":b,_=h.value,"function"!=typeof(x=h.customValidation)){e.next=30;break}if("boolean"!=typeof(C=x(r,ir(f),d))||!C){e.next=15;break}u=C,c.push("default"),e.next=30;break;case 15:if("object"!==p(C)||!Array.isArray(C)){e.next=20;break}w=C[0],S=C[1],N=void 0===S?"default":S,w&&(u=w,c.push(N)),e.next=30;break;case 20:if(null===C||"object"!==p(C)){e.next=29;break}if(k=C,"function"!=typeof C.then){e.next=26;break}return e.next=25,C;case 25:k=e.sent;case 26:"boolean"==typeof k.isError&&(P=(I=k).isError,j=I.type,P&&(u=P,c.push(j))),e.next=30;break;case 29:console.warn("Skipping NbForm-CustomValidation Invalid Return Data check Docs.");case 30:void 0!==_&&_!==r&&(u=!0,c.push("value")),(null==r||"string"==typeof r&&0===r.length)&&(y&&(u=!0),c.push("required")),void 0!==v&&r.toString().trim().length<v&&(u=!0,c.push("minlength")),O=r,"location-autocomplete"===a&&y&&(r.selectedAddress||(u=!0)),"input"!==a||"email"!==s&&"email"!==E||/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(r)||(u=!0,c.push("type","dataType")),("input"===a&&"number"===s||-1!==["int","float"].indexOf(E))&&(F=!1,isNaN(parseFloat(r))&&(u=!0,c.push("type","dataType"),F=!0),F||"int"!==E||parseInt(r)==r||(u=!0,c.push("dataType"),F=!0),F||"float"!==E||parseFloat(r)==r||(u=!0,c.push("dataType"),F=!0),F||(O=E&&"float"!==E?parseInt(r):parseFloat(r),void 0!==v&&O.toString().length<v&&(u=!0,c.push("minlength")),"tel"===a&&"91"===oe(f,[i+"_dialCode","value"])&&O.toString().length<10&&(u=!0,c.push("minlength")),isNaN(m)||r<m&&(u=!0,c.push("min")),isNaN(g)||r>g&&(u=!0,c.push("max"))));case 37:return e.abrupt("return",{error:c,status:u});case 38:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),yr=function(){var e=hr(fr.mark((function e(t,r,n,o){var a,i,l,s,u,c,f,d,h,v,y,m,g,b,E,_,x,C,w,S,N,k,I,P,j,O;return fr.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:void 0===n&&(n=[[],[],[],[]]),void 0===o&&(o={}),a=[].concat(n),i=!1,s=(l=o).isGroupInput,u=void 0!==s&&s,c=l.groupValidation,f=void 0===c?{}:c,d=l.extraProps,h=void 0===d?{}:d,v=0,y=0;case 7:if(!(y<t.length)){e.next=37;break}if(m=t[y],g=m.id,b=void 0===g?"":g,E=m.validation,_=m.errorMsg,x=void 0===_?{}:_,"inputGroup"!==m.type){e.next=23;break}if(C=b||"group-"+y,"object"!==p(m.input)||!Array.isArray(m.input)){e.next=22;break}return w={},e.next=16,yr(m.input,r,a,{isGroupInput:!0,groupValidation:E,extraProps:h});case 16:S=e.sent,a=S[0],i=S[1],(w=S[2].groupErrorLog)&&-1===w.type.indexOf("required")&&(v+=1),w.isError&&(a[0].push(C),a[1].push(""),a[2].push(w.isError),a[3].push(w.isError?x[oe(w,"type.0")]||x.default:""));case 22:return e.abrupt("return");case 23:return N=oe(r,[b,"value"])||"",e.next=26,vr(m,N,E,{formData:r,extraProps:h});case 26:k=e.sent,I=k.status,P=k.error,!0===I&&(i=!0),j=P||[],-1===P.indexOf("required")&&(v+=1),Array.isArray(P)&&P.length>0&&(j=P[0]),I&&(a[0].push(b),a[1].push(N),a[2].push(I),a[3].push(I?x[j]||x.default:""));case 34:y++,e.next=7;break;case 37:return O={isError:!1,type:[]},u&&(f&&!0===f.required&&(O={isError:v<=0,type:v<=0?["required"]:[]}),!0===f.requiredAll&&(O={isError:v===t.length,type:v!==t.length?["requiredAll"]:[]})),e.abrupt("return",[a,i,{groupErrorLog:O}]);case 40:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),mr=function(){var e=hr(fr.mark((function e(t,r,n,o,a){var i,l,s;return fr.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,yr(t,r,[[],[],[],[]],{extraProps:a});case 2:i=e.sent,l=i[0],s=!1,"object"===p(l[2])&&Array.isArray(l[2])&&l[2].forEach((function(e){!0===e&&(s=!0)})),n.apply(void 0,l.concat([function(e){"function"==typeof o&&o(s,ir(e),e)}]));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),gr=function(e){var t={};return e.forEach((function(e){var r=e.id,n=e.customProps;"function"==typeof n&&(t[r]=n)})),t};return function(t){var r=t.id,n=t.data,o=t.ref,a=t.formClass,l=void 0===a?"":a,u=t.onSubmit,c=t.onChange,d=t.submitButtonText,h=void 0===d?"Submit":d,v=t.buttonClassName,y=void 0===v?"":v,m=t.defaultValue,g=void 0===m?{}:m,b=t.nbGaEvent,E=t.customFooter,_=t.getSubmitAction,x=t.style,C=void 0===x?{}:x,w=t.getResetFormAction,S=t.extraProps,N=void 0===S?{}:S;s(null!=r&&r.length>1,"Please Provide valid unique ID"),s(Array.isArray(n)&&n.length>0,"data should be array of object");var k=function(t,r,n){void 0===t&&(t={}),void 0===n&&(n=[]);var o=e.useState(ar(t,n)),a=o[0],i=o[1],l=e.useCallback((function(){i(ar(t,n))})),s=e.useCallback((function(e){try{if(Array.isArray(e)&&e.length>0)e=e[0];var t=document.getElementById(r+"-"+e+"-nbInput");t&&t.focus()}catch(e){}}),[r]),u=e.useCallback((function(e,t,r){var n=f({},e),o=n[t]._dependencies;"object"===p(o)&&Object.keys(o).length>0&&(Object.keys(o)||[]).forEach((function(e){Array.isArray(o[e])&&o[e].length>0&&o[e].forEach((function(t){var o;n[e]||(n[e]={value:""}),n[e].dependency||(n[e].dependency={}),n[e].dependency=f({},n[e].dependency,((o={})[t]=r,o))}))}));return n}),[]);return[a,e.useCallback((function(e,t,r,n,o){void 0===r&&(r=!1),void 0===n&&(n=""),i((function(a){var i=!1,l=f({},a),c=!1;if("function"==typeof r?o=r:c=r,Array.isArray(e)&&(i=!0),Array.isArray(e)){var p=!1;i&&e.length===t.length?e.forEach((function(r,o){l[r]||(l[r]={value:""}),void 0!==(l=u(l,r,t[o]))[r].parent&&void 0!==l[l[r].parent]&&(l[l[r].parent].isError=!1),l[r]=f({},l[r],{value:t[o],isError:!(!c||!c[o])&&c[o],errorMsg:c&&c[o]&&n&&n[o]?n[o]:""}),!p&&l[r].isError&&(s(e),p=!0)})):e.forEach((function(r,o){l[r]||(l[r]={value:""}),void 0!==(l=u(l,r,t))[r].parent&&void 0!==l[l[r].parent]&&(l[l[r].parent].isError=!1),l[r]=f({},l[r],{value:t,isError:c&&c[o]?c[o]:c,errorMsg:c&&c[o]&&n&&n[o]?n[o]:n}),l[r].isError&&s(e)}))}else l[e]||(l[e]={value:""}),void 0!==(l=u(l,e,t))[e].parent&&void 0!==l[l[e].parent]&&(l[l[e].parent].isError=!1),l[e]=f({},l[e],{value:t,isError:c,errorMsg:n}),c&&s(e);return o&&"function"==typeof o&&o(l),l}))}),[]),l]}(g,r,n),I=k[0],P=void 0===I?{}:I,j=k[1],O=k[2],F=function(e,t,r){var n=i.useState((function(){var t={};return e.forEach((function(e){var r=e.id;t[r]={}})),t})),o=n[0],a=n[1],l=i.useState(gr(e)),s=l[0],u=l[1],c=i.useCallback(function(){var e=hr(fr.mark((function e(t,r){var n;return fr.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("object"!==p(t)||null===t){e.next=12;break}if(n=t,"function"!=typeof t.then){e.next=6;break}return e.next=5,t;case 5:n=e.sent;case 6:if("object"===p(n)&&null!==n){e.next=9;break}return a((function(e){var t;return f({},e,((t={})[r]={},t))})),e.abrupt("return");case 9:a((function(e){var t;return f({},e,((t={})[r]=n,t))})),e.next=13;break;case 12:a((function(e){var t;return f({},e,((t={})[r]={},t))}));case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),[o]);return i.useEffect((function(){Object.keys(s).forEach((function(e){if(s[e]){var n=s[e];c(n(t[e].value,ir(t),r),e)}}))}),[t,r]),i.useEffect((function(){u(gr(e))}),[e]),o}(n,P,N),A=i.useRef(P);e.useEffect((function(){if("function"==typeof c){var e=function e(t,r){void 0===t&&(t={}),void 0===r&&(r={});var n={};return Object.keys(t).forEach((function(o){if(!Object.prototype.hasOwnProperty.call(r,o)||t[o]!==r[o]){if("object"===p(r[o])&&"null"!==r[o]&&Object.keys(r[o]).length>0){var a=e(t[o],r[o]),i=e(r[o],t[o]);if(0===Object.keys(a).length&&0===Object.keys(i).length)return}n[o]=t[o]}})),n}(P,A.current);c(ir(P),j,e),A.current=P}}),[P]);var L=i.useCallback((function(){mr(n,P,j,u,N)}),[n,P,j,u,N]);return e.useEffect((function(){n.forEach((function(e){var t=e.type,r=e.id,n=e.dialCode,o=void 0===n?"91":n,a=e.iso2;"tel"===t&&j([r+"_dialCode",r+"_iso2"],[o,void 0===a?"in":a])})),"function"==typeof w&&w(O)}),[]),e.useEffect((function(){"function"==typeof _&&_(L)}),[L]),i.createElement("form",{id:r,className:"nbform-2ptp128 "+l,action:"#",method:"post",onSubmit:function(e){e.preventDefault(),e.stopPropagation(),L()},ref:function(e){"function"==typeof o&&o(e)},style:{textAlign:"left"}},n.map((function(e,t){"inputGroup"===e.type&&!e.id&&(e.id="group-"+t);var n=e.id;return s(Boolean(n),"Invalid input id for data input at index "+t),cr(e,P[n]||"",j,{idPrefix:r,formData:P,nbGaEvent:b,index:t,extraProps:N,defaultStyle:C,customProps:F[n]||{}})})),void 0!==E?E:i.createElement(pr,{btnStyle:"primary",type:"submit",className:"form-control "+y},h))}}));
//# sourceMappingURL=nbform.umd.min.js.map
{
"name": "@wadehrarshpreet/nbform",
"homepage": "http://wadehrarshpreet.github.io/nbform",
"version": "0.0.1-alpha.9",
"version": "0.0.1-alpha.10",
"description": "React Form Generator Library",

@@ -6,0 +6,0 @@ "repository": {

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc