@bigbinary/neeto-form-frontend 3.5.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/javascript/src/translations/ar.json +1 -0
- package/app/javascript/src/translations/de.json +1 -0
- package/app/javascript/src/translations/en.json +6 -2
- package/app/javascript/src/translations/es.json +1 -0
- package/app/javascript/src/translations/fr.json +1 -0
- package/app/javascript/src/translations/nl.json +1 -0
- package/app/javascript/src/translations/pl.json +1 -0
- package/app/javascript/src/translations/pt.json +1 -0
- package/dist/BuildForm.js +113 -97
- package/dist/BuildForm.js.map +1 -1
- package/dist/ExternalForm.js +3 -3
- package/dist/Submission.js +2 -1
- package/dist/Submission.js.map +1 -1
- package/dist/UrlBuilder.js +4 -3
- package/dist/UrlBuilder.js.map +1 -1
- package/dist/{buildForm-4a5a5251.js → buildForm-042737cb.js} +3 -2
- package/dist/buildForm-042737cb.js.map +1 -0
- package/dist/{buildForm-77b32f08.js → buildForm-354c6d6d.js} +3 -2
- package/dist/buildForm-354c6d6d.js.map +1 -0
- package/dist/cjs/BuildForm.js +111 -95
- package/dist/cjs/BuildForm.js.map +1 -1
- package/dist/cjs/ExternalForm.js +3 -3
- package/dist/cjs/Submission.js +2 -1
- package/dist/cjs/Submission.js.map +1 -1
- package/dist/cjs/UrlBuilder.js +4 -3
- package/dist/cjs/UrlBuilder.js.map +1 -1
- package/dist/cjs/hooks.js +1 -1
- package/dist/cjs/index.js +5 -5
- package/dist/{constants-9310a7c2.js → constants-3d8a5374.js} +4 -2
- package/dist/constants-3d8a5374.js.map +1 -0
- package/dist/{constants-f0f38e6f.js → constants-43eac775.js} +4 -2
- package/dist/constants-43eac775.js.map +1 -0
- package/dist/{constants-8afd221a.js → constants-669f203a.js} +26 -6
- package/dist/constants-669f203a.js.map +1 -0
- package/dist/{constants-25c02c05.js → constants-ca5ca2b1.js} +29 -5
- package/dist/constants-ca5ca2b1.js.map +1 -0
- package/dist/hooks.js +1 -1
- package/dist/index.js +5 -5
- package/dist/{utils-a2abd77b.js → utils-0eabfa9b.js} +280 -278
- package/dist/utils-0eabfa9b.js.map +1 -0
- package/dist/{utils-3fcf4c2b.js → utils-b26ce7e8.js} +279 -277
- package/dist/utils-b26ce7e8.js.map +1 -0
- package/package.json +14 -14
- package/types.d.ts +1 -2
- package/dist/buildForm-4a5a5251.js.map +0 -1
- package/dist/buildForm-77b32f08.js.map +0 -1
- package/dist/constants-25c02c05.js.map +0 -1
- package/dist/constants-8afd221a.js.map +0 -1
- package/dist/constants-9310a7c2.js.map +0 -1
- package/dist/constants-f0f38e6f.js.map +0 -1
- package/dist/utils-3fcf4c2b.js.map +0 -1
- package/dist/utils-a2abd77b.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useEffect, useState, useImperativeHandle, useRef, useCallback, createElement, memo, Fragment } from 'react';
|
|
3
3
|
import { useFormikContext, useField, Field, FastField } from 'formik';
|
|
4
|
-
import { isPresent,
|
|
4
|
+
import { isPresent, isNotEmpty, findBy, findById, isNotPresent, getRandomInt, randomPick, noop, hyphenate, slugify, notEqualsDeep } from '@bigbinary/neeto-cist';
|
|
5
5
|
import { i as isFunction, b as isEmptyValues, f as fieldWithFallback } from './index-2664c3e7.js';
|
|
6
6
|
import { dayjs, withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils';
|
|
7
7
|
import { parsePhoneNumber } from 'libphonenumber-js';
|
|
8
|
-
import {
|
|
8
|
+
import { includes, __, isNil, clamp, prop, map, identity, pluck, pipe, toLower, reject, values, assoc, isEmpty, isNotNil, equals, pick } from 'ramda';
|
|
9
9
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
10
10
|
import EditorContent from '@bigbinary/neeto-editor/EditorContent';
|
|
11
|
-
import { C as CAPTCHA_TYPES,
|
|
11
|
+
import { C as CAPTCHA_TYPES, q as generateArray } from './constants-669f203a.js';
|
|
12
12
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
13
13
|
import Button from '@bigbinary/neetoui/Button';
|
|
14
14
|
import NeetoUIMultiEmailInput from '@bigbinary/neetoui/MultiEmailInput';
|
|
@@ -21,9 +21,9 @@ import { validation, PhoneNumberInput } from '@bigbinary/neeto-molecules/PhoneNu
|
|
|
21
21
|
import * as yup from 'yup';
|
|
22
22
|
import i18next from 'i18next';
|
|
23
23
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
24
|
-
import { Q as QUESTION_KIND, E as ERROR_CODES, e as EMAIL_REGEX, R as RATING_VALUES, S as SCHEMA_LESS_QUESTION_KINDS, f as RATING_OPTIONS, I as ICONS_MAP } from './constants-9310a7c2.js';
|
|
25
|
-
import classnames from 'classnames';
|
|
26
24
|
import path from 'path';
|
|
25
|
+
import { Q as QUESTION_KIND, E as ERROR_CODES, e as EMAIL_REGEX, R as RATING_VALUES, S as SCHEMA_LESS_QUESTION_KINDS, f as RATING_OPTIONS, I as ICONS_MAP } from './constants-3d8a5374.js';
|
|
26
|
+
import classnames from 'classnames';
|
|
27
27
|
import { useUpdateEffect, withT, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
28
28
|
import Refresh from '@bigbinary/neeto-icons/Refresh';
|
|
29
29
|
import Input from '@bigbinary/neetoui/Input';
|
|
@@ -157,274 +157,9 @@ var getInvalidTypeError = function getInvalidTypeError(label, type) {
|
|
|
157
157
|
});
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
-
var _excluded$4 = ["kind", "customValidator"];
|
|
161
|
-
var _fieldKindValidatorMa;
|
|
162
160
|
function ownKeys$g(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
163
161
|
function _objectSpread$g(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$g(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$g(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
164
162
|
var t$1 = clientI18nInstance.t;
|
|
165
|
-
yup.addMethod(yup.array, "unique", function () {
|
|
166
|
-
var field, message;
|
|
167
|
-
if (arguments.length > 1) {
|
|
168
|
-
field = arguments[0];
|
|
169
|
-
message = arguments[1];
|
|
170
|
-
} else {
|
|
171
|
-
message = arguments[0];
|
|
172
|
-
}
|
|
173
|
-
var getValue = function getValue(item) {
|
|
174
|
-
return field ? item[field] : item;
|
|
175
|
-
};
|
|
176
|
-
var valueInLowerCase = pipe(getValue, toLower);
|
|
177
|
-
return this.test("unique", message, function () {
|
|
178
|
-
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
179
|
-
// ignore destroyed items in the array
|
|
180
|
-
var validItems = reject(prop("_destroy"), array);
|
|
181
|
-
var uniqueItems = new Set(map(valueInLowerCase, validItems));
|
|
182
|
-
|
|
183
|
-
// all items are unique
|
|
184
|
-
if (validItems.length === uniqueItems.size) return true;
|
|
185
|
-
return this.createError({
|
|
186
|
-
path: this.path,
|
|
187
|
-
message: message
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
var isValidDate = function isValidDate(date) {
|
|
192
|
-
return date && dayjs(date).isValid();
|
|
193
|
-
};
|
|
194
|
-
var extractEmailDomain = function extractEmailDomain(email) {
|
|
195
|
-
return email === null || email === void 0 ? void 0 : email.split("@")[1];
|
|
196
|
-
};
|
|
197
|
-
var isEmailFromRestrictedDomain = function isEmailFromRestrictedDomain(email, restrictedDomains) {
|
|
198
|
-
var domain = extractEmailDomain(email);
|
|
199
|
-
return includes(domain, restrictedDomains);
|
|
200
|
-
};
|
|
201
|
-
var validateTextField = function validateTextField(_ref) {
|
|
202
|
-
var kind = _ref.kind,
|
|
203
|
-
label = _ref.label,
|
|
204
|
-
isRequired = _ref.isRequired;
|
|
205
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
206
|
-
if (kind === QUESTION_KIND.PHONE.value) {
|
|
207
|
-
schema = validation(getInvalidFieldError(t$1("neetoForm.common.phoneNumberValidation")));
|
|
208
|
-
}
|
|
209
|
-
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
210
|
-
return schema.trim();
|
|
211
|
-
};
|
|
212
|
-
var validateEmailField = function validateEmailField(_ref2) {
|
|
213
|
-
var label = _ref2.label,
|
|
214
|
-
isRequired = _ref2.isRequired,
|
|
215
|
-
restrictedDomains = _ref2.restrictedDomains;
|
|
216
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string")).email(getInvalidFieldError("Email")).test("verify domain", function (_ref3) {
|
|
217
|
-
var value = _ref3.value;
|
|
218
|
-
return t$1("neetoForm.error.emailFromRestrictedDomain", {
|
|
219
|
-
domain: extractEmailDomain(value)
|
|
220
|
-
});
|
|
221
|
-
}, function (value) {
|
|
222
|
-
return isNotPresent(value) || !isEmailFromRestrictedDomain(value, restrictedDomains);
|
|
223
|
-
});
|
|
224
|
-
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
225
|
-
return schema.trim();
|
|
226
|
-
};
|
|
227
|
-
var validateNameField = function validateNameField(_ref4) {
|
|
228
|
-
var label = _ref4.label,
|
|
229
|
-
isRequired = _ref4.isRequired;
|
|
230
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
231
|
-
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
232
|
-
return schema.trim();
|
|
233
|
-
};
|
|
234
|
-
var validateSingleChoiceField = function validateSingleChoiceField(_ref5) {
|
|
235
|
-
var label = _ref5.label,
|
|
236
|
-
isRequired = _ref5.isRequired;
|
|
237
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
238
|
-
if (isRequired) schema = schema.required(getSelectMinError("an"));
|
|
239
|
-
return schema.trim();
|
|
240
|
-
};
|
|
241
|
-
var validateMultiChoiceField = function validateMultiChoiceField(_ref6) {
|
|
242
|
-
var isRequired = _ref6.isRequired;
|
|
243
|
-
var schema = yup.array().of(yup["boolean"]());
|
|
244
|
-
if (isRequired) schema = schema.compact().min(1, getSelectMinError("an"));
|
|
245
|
-
return schema;
|
|
246
|
-
};
|
|
247
|
-
var validateRatingField = function validateRatingField(_ref7) {
|
|
248
|
-
var label = _ref7.label,
|
|
249
|
-
isRequired = _ref7.isRequired;
|
|
250
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
251
|
-
if (isRequired) schema = schema.required(getSelectMinError("an"));
|
|
252
|
-
return schema.trim();
|
|
253
|
-
};
|
|
254
|
-
var validateStarRatingField = function validateStarRatingField(_ref8) {
|
|
255
|
-
var label = _ref8.label,
|
|
256
|
-
isRequired = _ref8.isRequired;
|
|
257
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
258
|
-
if (isRequired) {
|
|
259
|
-
schema = schema.required(getSelectMinError("a", t$1("neetoForm.common.rating")));
|
|
260
|
-
}
|
|
261
|
-
return schema.trim();
|
|
262
|
-
};
|
|
263
|
-
var validateTermsField = function validateTermsField(_ref9) {
|
|
264
|
-
var _ref9$isRequired = _ref9.isRequired,
|
|
265
|
-
isRequired = _ref9$isRequired === void 0 ? true : _ref9$isRequired;
|
|
266
|
-
return isRequired ? yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptTermsAndConditions")) : yup["boolean"]().notRequired();
|
|
267
|
-
};
|
|
268
|
-
var validateConditionField = function validateConditionField(_ref10) {
|
|
269
|
-
var _ref10$isRequired = _ref10.isRequired,
|
|
270
|
-
isRequired = _ref10$isRequired === void 0 ? true : _ref10$isRequired;
|
|
271
|
-
return isRequired ? yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptCondition")) : yup["boolean"]().notRequired();
|
|
272
|
-
};
|
|
273
|
-
var validateDateField = function validateDateField(_ref11) {
|
|
274
|
-
var label = _ref11.label,
|
|
275
|
-
isRequired = _ref11.isRequired;
|
|
276
|
-
var schema = yup.string().test("is valid date", getInvalidTypeError(label, "date"), function (value) {
|
|
277
|
-
return isNotPresent(value) || isValidDate(value);
|
|
278
|
-
});
|
|
279
|
-
if (isRequired) {
|
|
280
|
-
schema = schema.required(getRequiredFieldError(label));
|
|
281
|
-
}
|
|
282
|
-
return schema;
|
|
283
|
-
};
|
|
284
|
-
var validateMultiEmailField = function validateMultiEmailField(_ref12) {
|
|
285
|
-
var isRequired = _ref12.isRequired;
|
|
286
|
-
var schema = yup.array().of(yup.object().shape({
|
|
287
|
-
value: yup.string().email(getInvalidFieldError("Email")).trim()
|
|
288
|
-
})).nullable();
|
|
289
|
-
if (isRequired) {
|
|
290
|
-
schema = schema.compact().min(1, getSelectMinError("an", t$1("neetoForm.common.email")));
|
|
291
|
-
}
|
|
292
|
-
return schema;
|
|
293
|
-
};
|
|
294
|
-
var editorHasValue = function editorHasValue(content) {
|
|
295
|
-
return !isEditorEmpty(content);
|
|
296
|
-
};
|
|
297
|
-
var validateRichTextField = function validateRichTextField(_ref13) {
|
|
298
|
-
var isRequired = _ref13.isRequired;
|
|
299
|
-
var schema = yup.string();
|
|
300
|
-
if (isRequired) {
|
|
301
|
-
schema = schema.test("required", getRequiredFieldError("content"), editorHasValue);
|
|
302
|
-
}
|
|
303
|
-
return schema.trim();
|
|
304
|
-
};
|
|
305
|
-
var validateFileUploadField = function validateFileUploadField(_ref14) {
|
|
306
|
-
var isRequired = _ref14.isRequired,
|
|
307
|
-
multipleFilesAllowed = _ref14.multipleFilesAllowed;
|
|
308
|
-
var files_schema = yup.array();
|
|
309
|
-
if (isRequired) {
|
|
310
|
-
files_schema = files_schema.of(yup.object().shape({
|
|
311
|
-
name: yup.string(),
|
|
312
|
-
signedId: yup.string().required(t$1("neetoForm.fileUpload.validations.waitForUpload")),
|
|
313
|
-
url: yup.string().required(t$1("neetoForm.fileUpload.validations.waitForUpload"))
|
|
314
|
-
})).unique("name", t$1("neetoForm.fileUpload.validations.removeDuplicates")).min(1, multipleFilesAllowed ? t$1("neetoForm.fileUpload.validations.atLeastOneFileRequired") : t$1("neetoForm.fileUpload.validations.fileIsRequired"));
|
|
315
|
-
}
|
|
316
|
-
return yup.object().shape({
|
|
317
|
-
files: files_schema
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
var validateCaptchaField = function validateCaptchaField(_ref15) {
|
|
321
|
-
var variant = _ref15.variant;
|
|
322
|
-
return variant === CAPTCHA_TYPES.MATH_CAPTCHA ? yup.mixed().test("verification failed", t$1("neetoForm.error.captchaVerificationFailed"), function (value) {
|
|
323
|
-
return isNotPresent(value) || value;
|
|
324
|
-
}).transform(function (value) {
|
|
325
|
-
return value === "" ? null : value;
|
|
326
|
-
}).required(t$1("neetoForm.error.incompleteCaptcha")) : yup.string().trim().required(t$1("neetoForm.error.incompleteCaptcha"));
|
|
327
|
-
};
|
|
328
|
-
var fieldKindValidatorMap = (_fieldKindValidatorMa = {}, _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.EMAIL.value, validateEmailField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.NAME.value, validateNameField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.PHONE.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TEXT.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.QUESTION.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TEXTAREA.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DECIMAL.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.INTEGER.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DROPDOWN.value, validateSingleChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RADIO.value, validateSingleChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CHECKBOX.value, validateMultiChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RATING.value, validateRatingField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TERMS.value, validateTermsField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DATE.value, validateDateField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.STAR_RATING.value, validateStarRatingField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.ADDITIONAL_GUESTS.value, validateMultiEmailField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RICH_TEXT.value, validateRichTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CONDITION.value, validateConditionField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.FILE_UPLOAD.value, validateFileUploadField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CAPTCHA.value, validateCaptchaField), _fieldKindValidatorMa);
|
|
329
|
-
var validateFieldValue = function validateFieldValue(_ref16) {
|
|
330
|
-
var kind = _ref16.kind,
|
|
331
|
-
customValidator = _ref16.customValidator,
|
|
332
|
-
otherProps = _objectWithoutProperties(_ref16, _excluded$4);
|
|
333
|
-
return function (value) {
|
|
334
|
-
if (!(kind in fieldKindValidatorMap)) return;
|
|
335
|
-
var validator = fieldKindValidatorMap[kind];
|
|
336
|
-
var schema = customValidator || validator(_objectSpread$g({
|
|
337
|
-
kind: kind
|
|
338
|
-
}, otherProps));
|
|
339
|
-
|
|
340
|
-
// eslint-disable-next-line consistent-return, no-async-promise-executor
|
|
341
|
-
return new Promise( /*#__PURE__*/function () {
|
|
342
|
-
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
|
|
343
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
344
|
-
while (1) switch (_context.prev = _context.next) {
|
|
345
|
-
case 0:
|
|
346
|
-
_context.prev = 0;
|
|
347
|
-
_context.next = 3;
|
|
348
|
-
return schema.validate(value);
|
|
349
|
-
case 3:
|
|
350
|
-
resolve(undefined);
|
|
351
|
-
_context.next = 9;
|
|
352
|
-
break;
|
|
353
|
-
case 6:
|
|
354
|
-
_context.prev = 6;
|
|
355
|
-
_context.t0 = _context["catch"](0);
|
|
356
|
-
resolve(_context.t0.message);
|
|
357
|
-
case 9:
|
|
358
|
-
case "end":
|
|
359
|
-
return _context.stop();
|
|
360
|
-
}
|
|
361
|
-
}, _callee, null, [[0, 6]]);
|
|
362
|
-
}));
|
|
363
|
-
return function (_x) {
|
|
364
|
-
return _ref17.apply(this, arguments);
|
|
365
|
-
};
|
|
366
|
-
}());
|
|
367
|
-
};
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
var MultipleEmailInput = function MultipleEmailInput(_ref) {
|
|
371
|
-
var _jsx2;
|
|
372
|
-
var question = _ref.question,
|
|
373
|
-
customValidator = _ref.customValidator;
|
|
374
|
-
var name = question.id,
|
|
375
|
-
kind = question.kind,
|
|
376
|
-
isRequired = question.isRequired,
|
|
377
|
-
nodeId = question.nodeId;
|
|
378
|
-
var label = fieldWithFallback(question, "label");
|
|
379
|
-
var _useTranslation = useTranslation(),
|
|
380
|
-
t = _useTranslation.t;
|
|
381
|
-
var _useField = useField({
|
|
382
|
-
name: name || nodeId,
|
|
383
|
-
validate: validateFieldValue({
|
|
384
|
-
kind: kind,
|
|
385
|
-
label: label,
|
|
386
|
-
isRequired: isRequired,
|
|
387
|
-
customValidator: customValidator
|
|
388
|
-
})
|
|
389
|
-
}),
|
|
390
|
-
_useField2 = _slicedToArray(_useField, 3),
|
|
391
|
-
field = _useField2[0],
|
|
392
|
-
meta = _useField2[1],
|
|
393
|
-
_useField2$ = _useField2[2],
|
|
394
|
-
setValue = _useField2$.setValue,
|
|
395
|
-
setTouched = _useField2$.setTouched;
|
|
396
|
-
var _useState = useState(isPresent(field.value)),
|
|
397
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
398
|
-
isInputVisible = _useState2[0],
|
|
399
|
-
setIsInputVisible = _useState2[1];
|
|
400
|
-
return /*#__PURE__*/jsx("div", {
|
|
401
|
-
className: "neeto-form-engine-input__wrapper",
|
|
402
|
-
children: /*#__PURE__*/jsx("div", {
|
|
403
|
-
className: "neeto-ui-w-full",
|
|
404
|
-
children: isInputVisible ? /*#__PURE__*/jsx(NeetoUIMultiEmailInput, {
|
|
405
|
-
isRequired: isRequired,
|
|
406
|
-
label: label,
|
|
407
|
-
error: meta.touched ? meta.error : "",
|
|
408
|
-
helpText: t("neetoForm.common.addGuestsHelper"),
|
|
409
|
-
name: field.name,
|
|
410
|
-
placeholder: fieldWithFallback(question, "placeholder"),
|
|
411
|
-
value: field.value,
|
|
412
|
-
onBlur: function onBlur() {
|
|
413
|
-
return setTouched(true);
|
|
414
|
-
},
|
|
415
|
-
onChange: setValue
|
|
416
|
-
}) : /*#__PURE__*/jsx(Button, (_jsx2 = {
|
|
417
|
-
label: label
|
|
418
|
-
}, _defineProperty(_jsx2, "label", t("neetoForm.common.addGuests")), _defineProperty(_jsx2, "style", "secondary"), _defineProperty(_jsx2, "onClick", function onClick() {
|
|
419
|
-
return setIsInputVisible(true);
|
|
420
|
-
}), _jsx2))
|
|
421
|
-
})
|
|
422
|
-
});
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
function ownKeys$f(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
426
|
-
function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
427
|
-
var t = clientI18nInstance.t;
|
|
428
163
|
var toEmailValues = function toEmailValues() {
|
|
429
164
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
430
165
|
return values.map(function (value) {
|
|
@@ -517,7 +252,7 @@ var generateInitValues = function generateInitValues(_ref7) {
|
|
|
517
252
|
var valuesMap = {};
|
|
518
253
|
if (initialValues) {
|
|
519
254
|
valuesMap = initialValues.reduce(function (acc, answer) {
|
|
520
|
-
return _objectSpread$
|
|
255
|
+
return _objectSpread$g(_objectSpread$g({}, acc), {}, _defineProperty({}, answer.questionId, {
|
|
521
256
|
value: answer.value,
|
|
522
257
|
optionIds: answer.optionIds
|
|
523
258
|
}));
|
|
@@ -608,6 +343,7 @@ var generateInitValues = function generateInitValues(_ref7) {
|
|
|
608
343
|
return;
|
|
609
344
|
}
|
|
610
345
|
case QUESTION_KIND.PHONE.value:
|
|
346
|
+
case QUESTION_KIND.SMS_REMINDER.value:
|
|
611
347
|
{
|
|
612
348
|
var _valuesMap$id$value3, _valuesMap6;
|
|
613
349
|
initValues[id] = (_valuesMap$id$value3 = (_valuesMap6 = valuesMap) === null || _valuesMap6 === void 0 || (_valuesMap6 = _valuesMap6[id]) === null || _valuesMap6 === void 0 ? void 0 : _valuesMap6.value) !== null && _valuesMap$id$value3 !== void 0 ? _valuesMap$id$value3 : getPhoneNumberFromUrl(fieldCodes, fieldCode);
|
|
@@ -663,7 +399,7 @@ var generateFormResponse = function generateFormResponse(response, questions) {
|
|
|
663
399
|
kind: kind
|
|
664
400
|
});
|
|
665
401
|
});
|
|
666
|
-
} else if (kind
|
|
402
|
+
} else if (isPhoneNumberField(kind)) {
|
|
667
403
|
formResponse.push({
|
|
668
404
|
questionId: id,
|
|
669
405
|
value: responseValue ? parsePhoneNumber(responseValue).formatInternational() : "",
|
|
@@ -719,21 +455,21 @@ var renderErrorMessage = function renderErrorMessage(errorObject, maxFileSize, i
|
|
|
719
455
|
var code = error.code;
|
|
720
456
|
switch (code) {
|
|
721
457
|
case ERROR_CODES.FILE_TOO_LARGE:
|
|
722
|
-
return t("neetoForm.fileUpload.dropzone.errors.fileTooLarge", {
|
|
458
|
+
return t$1("neetoForm.fileUpload.dropzone.errors.fileTooLarge", {
|
|
723
459
|
fileName: file.name,
|
|
724
460
|
maxSize: Math.round(maxFileSize / 1048576)
|
|
725
461
|
});
|
|
726
462
|
case ERROR_CODES.FILE_INVALID_TYPE:
|
|
727
|
-
return t("neetoForm.fileUpload.dropzone.errors.fileInvalidType", {
|
|
463
|
+
return t$1("neetoForm.fileUpload.dropzone.errors.fileInvalidType", {
|
|
728
464
|
fileType: path.extname(file.name)
|
|
729
465
|
});
|
|
730
466
|
case ERROR_CODES.TOO_MANY_FILES:
|
|
731
467
|
if (!isMultiple) {
|
|
732
|
-
return t("neetoForm.fileUpload.dropzone.errors.tooManyFiles");
|
|
468
|
+
return t$1("neetoForm.fileUpload.dropzone.errors.tooManyFiles");
|
|
733
469
|
}
|
|
734
470
|
}
|
|
735
471
|
}
|
|
736
|
-
return t("neetoForm.fileUpload.dropzone.errors.defaultError", {
|
|
472
|
+
return t$1("neetoForm.fileUpload.dropzone.errors.defaultError", {
|
|
737
473
|
fileName: file.name
|
|
738
474
|
});
|
|
739
475
|
};
|
|
@@ -745,6 +481,272 @@ var getSelectedRating = function getSelectedRating(value) {
|
|
|
745
481
|
var parsedValue = parseInt(value);
|
|
746
482
|
return isNaN(parsedValue) ? -1 : parsedValue;
|
|
747
483
|
};
|
|
484
|
+
var isPhoneNumberField = includes(__, [QUESTION_KIND.PHONE.value, QUESTION_KIND.SMS_REMINDER.value]);
|
|
485
|
+
|
|
486
|
+
var _excluded$4 = ["kind", "customValidator"];
|
|
487
|
+
var _fieldKindValidatorMa;
|
|
488
|
+
function ownKeys$f(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
489
|
+
function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
490
|
+
var t = clientI18nInstance.t;
|
|
491
|
+
yup.addMethod(yup.array, "unique", function () {
|
|
492
|
+
var field, message;
|
|
493
|
+
if (arguments.length > 1) {
|
|
494
|
+
field = arguments[0];
|
|
495
|
+
message = arguments[1];
|
|
496
|
+
} else {
|
|
497
|
+
message = arguments[0];
|
|
498
|
+
}
|
|
499
|
+
var getValue = function getValue(item) {
|
|
500
|
+
return field ? item[field] : item;
|
|
501
|
+
};
|
|
502
|
+
var valueInLowerCase = pipe(getValue, toLower);
|
|
503
|
+
return this.test("unique", message, function () {
|
|
504
|
+
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
505
|
+
// ignore destroyed items in the array
|
|
506
|
+
var validItems = reject(prop("_destroy"), array);
|
|
507
|
+
var uniqueItems = new Set(map(valueInLowerCase, validItems));
|
|
508
|
+
|
|
509
|
+
// all items are unique
|
|
510
|
+
if (validItems.length === uniqueItems.size) return true;
|
|
511
|
+
return this.createError({
|
|
512
|
+
path: this.path,
|
|
513
|
+
message: message
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
var isValidDate = function isValidDate(date) {
|
|
518
|
+
return date && dayjs(date).isValid();
|
|
519
|
+
};
|
|
520
|
+
var extractEmailDomain = function extractEmailDomain(email) {
|
|
521
|
+
return email === null || email === void 0 ? void 0 : email.split("@")[1];
|
|
522
|
+
};
|
|
523
|
+
var isEmailFromRestrictedDomain = function isEmailFromRestrictedDomain(email, restrictedDomains) {
|
|
524
|
+
var domain = extractEmailDomain(email);
|
|
525
|
+
return includes(domain, restrictedDomains);
|
|
526
|
+
};
|
|
527
|
+
var validateTextField = function validateTextField(_ref) {
|
|
528
|
+
var kind = _ref.kind,
|
|
529
|
+
label = _ref.label,
|
|
530
|
+
isRequired = _ref.isRequired;
|
|
531
|
+
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
532
|
+
if (isPhoneNumberField(kind)) {
|
|
533
|
+
schema = validation(getInvalidFieldError(t("neetoForm.common.phoneNumberValidation")));
|
|
534
|
+
}
|
|
535
|
+
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
536
|
+
return schema.trim();
|
|
537
|
+
};
|
|
538
|
+
var validateEmailField = function validateEmailField(_ref2) {
|
|
539
|
+
var label = _ref2.label,
|
|
540
|
+
isRequired = _ref2.isRequired,
|
|
541
|
+
restrictedDomains = _ref2.restrictedDomains;
|
|
542
|
+
var schema = yup.string().typeError(getInvalidTypeError(label, "string")).email(getInvalidFieldError("Email")).test("verify domain", function (_ref3) {
|
|
543
|
+
var value = _ref3.value;
|
|
544
|
+
return t("neetoForm.error.emailFromRestrictedDomain", {
|
|
545
|
+
domain: extractEmailDomain(value)
|
|
546
|
+
});
|
|
547
|
+
}, function (value) {
|
|
548
|
+
return isNotPresent(value) || !isEmailFromRestrictedDomain(value, restrictedDomains);
|
|
549
|
+
});
|
|
550
|
+
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
551
|
+
return schema.trim();
|
|
552
|
+
};
|
|
553
|
+
var validateNameField = function validateNameField(_ref4) {
|
|
554
|
+
var label = _ref4.label,
|
|
555
|
+
isRequired = _ref4.isRequired;
|
|
556
|
+
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
557
|
+
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
558
|
+
return schema.trim();
|
|
559
|
+
};
|
|
560
|
+
var validateSingleChoiceField = function validateSingleChoiceField(_ref5) {
|
|
561
|
+
var label = _ref5.label,
|
|
562
|
+
isRequired = _ref5.isRequired;
|
|
563
|
+
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
564
|
+
if (isRequired) schema = schema.required(getSelectMinError("an"));
|
|
565
|
+
return schema.trim();
|
|
566
|
+
};
|
|
567
|
+
var validateMultiChoiceField = function validateMultiChoiceField(_ref6) {
|
|
568
|
+
var isRequired = _ref6.isRequired;
|
|
569
|
+
var schema = yup.array().of(yup["boolean"]());
|
|
570
|
+
if (isRequired) schema = schema.compact().min(1, getSelectMinError("an"));
|
|
571
|
+
return schema;
|
|
572
|
+
};
|
|
573
|
+
var validateRatingField = function validateRatingField(_ref7) {
|
|
574
|
+
var label = _ref7.label,
|
|
575
|
+
isRequired = _ref7.isRequired;
|
|
576
|
+
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
577
|
+
if (isRequired) schema = schema.required(getSelectMinError("an"));
|
|
578
|
+
return schema.trim();
|
|
579
|
+
};
|
|
580
|
+
var validateStarRatingField = function validateStarRatingField(_ref8) {
|
|
581
|
+
var label = _ref8.label,
|
|
582
|
+
isRequired = _ref8.isRequired;
|
|
583
|
+
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
584
|
+
if (isRequired) {
|
|
585
|
+
schema = schema.required(getSelectMinError("a", t("neetoForm.common.rating")));
|
|
586
|
+
}
|
|
587
|
+
return schema.trim();
|
|
588
|
+
};
|
|
589
|
+
var validateTermsField = function validateTermsField(_ref9) {
|
|
590
|
+
var _ref9$isRequired = _ref9.isRequired,
|
|
591
|
+
isRequired = _ref9$isRequired === void 0 ? true : _ref9$isRequired;
|
|
592
|
+
return isRequired ? yup["boolean"]().oneOf([true], t("neetoForm.common.mustAcceptTermsAndConditions")) : yup["boolean"]().notRequired();
|
|
593
|
+
};
|
|
594
|
+
var validateConditionField = function validateConditionField(_ref10) {
|
|
595
|
+
var _ref10$isRequired = _ref10.isRequired,
|
|
596
|
+
isRequired = _ref10$isRequired === void 0 ? true : _ref10$isRequired;
|
|
597
|
+
return isRequired ? yup["boolean"]().oneOf([true], t("neetoForm.common.mustAcceptCondition")) : yup["boolean"]().notRequired();
|
|
598
|
+
};
|
|
599
|
+
var validateDateField = function validateDateField(_ref11) {
|
|
600
|
+
var label = _ref11.label,
|
|
601
|
+
isRequired = _ref11.isRequired;
|
|
602
|
+
var schema = yup.string().test("is valid date", getInvalidTypeError(label, "date"), function (value) {
|
|
603
|
+
return isNotPresent(value) || isValidDate(value);
|
|
604
|
+
});
|
|
605
|
+
if (isRequired) {
|
|
606
|
+
schema = schema.required(getRequiredFieldError(label));
|
|
607
|
+
}
|
|
608
|
+
return schema;
|
|
609
|
+
};
|
|
610
|
+
var validateMultiEmailField = function validateMultiEmailField(_ref12) {
|
|
611
|
+
var isRequired = _ref12.isRequired;
|
|
612
|
+
var schema = yup.array().of(yup.object().shape({
|
|
613
|
+
value: yup.string().email(getInvalidFieldError("Email")).trim()
|
|
614
|
+
})).nullable();
|
|
615
|
+
if (isRequired) {
|
|
616
|
+
schema = schema.compact().min(1, getSelectMinError("an", t("neetoForm.common.email")));
|
|
617
|
+
}
|
|
618
|
+
return schema;
|
|
619
|
+
};
|
|
620
|
+
var editorHasValue = function editorHasValue(content) {
|
|
621
|
+
return !isEditorEmpty(content);
|
|
622
|
+
};
|
|
623
|
+
var validateRichTextField = function validateRichTextField(_ref13) {
|
|
624
|
+
var isRequired = _ref13.isRequired;
|
|
625
|
+
var schema = yup.string();
|
|
626
|
+
if (isRequired) {
|
|
627
|
+
schema = schema.test("required", getRequiredFieldError("content"), editorHasValue);
|
|
628
|
+
}
|
|
629
|
+
return schema.trim();
|
|
630
|
+
};
|
|
631
|
+
var validateFileUploadField = function validateFileUploadField(_ref14) {
|
|
632
|
+
var isRequired = _ref14.isRequired,
|
|
633
|
+
multipleFilesAllowed = _ref14.multipleFilesAllowed;
|
|
634
|
+
var files_schema = yup.array();
|
|
635
|
+
if (isRequired) {
|
|
636
|
+
files_schema = files_schema.of(yup.object().shape({
|
|
637
|
+
name: yup.string(),
|
|
638
|
+
signedId: yup.string().required(t("neetoForm.fileUpload.validations.waitForUpload")),
|
|
639
|
+
url: yup.string().required(t("neetoForm.fileUpload.validations.waitForUpload"))
|
|
640
|
+
})).unique("name", t("neetoForm.fileUpload.validations.removeDuplicates")).min(1, multipleFilesAllowed ? t("neetoForm.fileUpload.validations.atLeastOneFileRequired") : t("neetoForm.fileUpload.validations.fileIsRequired"));
|
|
641
|
+
}
|
|
642
|
+
return yup.object().shape({
|
|
643
|
+
files: files_schema
|
|
644
|
+
});
|
|
645
|
+
};
|
|
646
|
+
var validateCaptchaField = function validateCaptchaField(_ref15) {
|
|
647
|
+
var variant = _ref15.variant;
|
|
648
|
+
return variant === CAPTCHA_TYPES.MATH_CAPTCHA ? yup.mixed().test("verification failed", t("neetoForm.error.captchaVerificationFailed"), function (value) {
|
|
649
|
+
return isNotPresent(value) || value;
|
|
650
|
+
}).transform(function (value) {
|
|
651
|
+
return value === "" ? null : value;
|
|
652
|
+
}).required(t("neetoForm.error.incompleteCaptcha")) : yup.string().trim().required(t("neetoForm.error.incompleteCaptcha"));
|
|
653
|
+
};
|
|
654
|
+
var fieldKindValidatorMap = (_fieldKindValidatorMa = {}, _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.EMAIL.value, validateEmailField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.NAME.value, validateNameField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.PHONE.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TEXT.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.QUESTION.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TEXTAREA.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DECIMAL.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.INTEGER.value, validateTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DROPDOWN.value, validateSingleChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RADIO.value, validateSingleChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CHECKBOX.value, validateMultiChoiceField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RATING.value, validateRatingField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.TERMS.value, validateTermsField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.DATE.value, validateDateField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.STAR_RATING.value, validateStarRatingField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.ADDITIONAL_GUESTS.value, validateMultiEmailField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.RICH_TEXT.value, validateRichTextField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CONDITION.value, validateConditionField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.FILE_UPLOAD.value, validateFileUploadField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.CAPTCHA.value, validateCaptchaField), _defineProperty(_fieldKindValidatorMa, QUESTION_KIND.SMS_REMINDER.value, validateTextField), _fieldKindValidatorMa);
|
|
655
|
+
var validateFieldValue = function validateFieldValue(_ref16) {
|
|
656
|
+
var kind = _ref16.kind,
|
|
657
|
+
customValidator = _ref16.customValidator,
|
|
658
|
+
otherProps = _objectWithoutProperties(_ref16, _excluded$4);
|
|
659
|
+
return function (value) {
|
|
660
|
+
if (!(kind in fieldKindValidatorMap)) return;
|
|
661
|
+
var validator = fieldKindValidatorMap[kind];
|
|
662
|
+
var schema = customValidator || validator(_objectSpread$f({
|
|
663
|
+
kind: kind
|
|
664
|
+
}, otherProps));
|
|
665
|
+
|
|
666
|
+
// eslint-disable-next-line consistent-return, no-async-promise-executor
|
|
667
|
+
return new Promise( /*#__PURE__*/function () {
|
|
668
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
|
|
669
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
670
|
+
while (1) switch (_context.prev = _context.next) {
|
|
671
|
+
case 0:
|
|
672
|
+
_context.prev = 0;
|
|
673
|
+
_context.next = 3;
|
|
674
|
+
return schema.validate(value);
|
|
675
|
+
case 3:
|
|
676
|
+
resolve(undefined);
|
|
677
|
+
_context.next = 9;
|
|
678
|
+
break;
|
|
679
|
+
case 6:
|
|
680
|
+
_context.prev = 6;
|
|
681
|
+
_context.t0 = _context["catch"](0);
|
|
682
|
+
resolve(_context.t0.message);
|
|
683
|
+
case 9:
|
|
684
|
+
case "end":
|
|
685
|
+
return _context.stop();
|
|
686
|
+
}
|
|
687
|
+
}, _callee, null, [[0, 6]]);
|
|
688
|
+
}));
|
|
689
|
+
return function (_x) {
|
|
690
|
+
return _ref17.apply(this, arguments);
|
|
691
|
+
};
|
|
692
|
+
}());
|
|
693
|
+
};
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
var MultipleEmailInput = function MultipleEmailInput(_ref) {
|
|
697
|
+
var _jsx2;
|
|
698
|
+
var question = _ref.question,
|
|
699
|
+
customValidator = _ref.customValidator;
|
|
700
|
+
var name = question.id,
|
|
701
|
+
kind = question.kind,
|
|
702
|
+
isRequired = question.isRequired,
|
|
703
|
+
nodeId = question.nodeId;
|
|
704
|
+
var label = fieldWithFallback(question, "label");
|
|
705
|
+
var _useTranslation = useTranslation(),
|
|
706
|
+
t = _useTranslation.t;
|
|
707
|
+
var _useField = useField({
|
|
708
|
+
name: name || nodeId,
|
|
709
|
+
validate: validateFieldValue({
|
|
710
|
+
kind: kind,
|
|
711
|
+
label: label,
|
|
712
|
+
isRequired: isRequired,
|
|
713
|
+
customValidator: customValidator
|
|
714
|
+
})
|
|
715
|
+
}),
|
|
716
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
717
|
+
field = _useField2[0],
|
|
718
|
+
meta = _useField2[1],
|
|
719
|
+
_useField2$ = _useField2[2],
|
|
720
|
+
setValue = _useField2$.setValue,
|
|
721
|
+
setTouched = _useField2$.setTouched;
|
|
722
|
+
var _useState = useState(isPresent(field.value)),
|
|
723
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
724
|
+
isInputVisible = _useState2[0],
|
|
725
|
+
setIsInputVisible = _useState2[1];
|
|
726
|
+
return /*#__PURE__*/jsx("div", {
|
|
727
|
+
className: "neeto-form-engine-input__wrapper",
|
|
728
|
+
children: /*#__PURE__*/jsx("div", {
|
|
729
|
+
className: "neeto-ui-w-full",
|
|
730
|
+
children: isInputVisible ? /*#__PURE__*/jsx(NeetoUIMultiEmailInput, {
|
|
731
|
+
isRequired: isRequired,
|
|
732
|
+
label: label,
|
|
733
|
+
error: meta.touched ? meta.error : "",
|
|
734
|
+
helpText: t("neetoForm.common.addGuestsHelper"),
|
|
735
|
+
name: field.name,
|
|
736
|
+
placeholder: fieldWithFallback(question, "placeholder"),
|
|
737
|
+
value: field.value,
|
|
738
|
+
onBlur: function onBlur() {
|
|
739
|
+
return setTouched(true);
|
|
740
|
+
},
|
|
741
|
+
onChange: setValue
|
|
742
|
+
}) : /*#__PURE__*/jsx(Button, (_jsx2 = {
|
|
743
|
+
label: label
|
|
744
|
+
}, _defineProperty(_jsx2, "label", t("neetoForm.common.addGuests")), _defineProperty(_jsx2, "style", "secondary"), _defineProperty(_jsx2, "onClick", function onClick() {
|
|
745
|
+
return setIsInputVisible(true);
|
|
746
|
+
}), _jsx2))
|
|
747
|
+
})
|
|
748
|
+
});
|
|
749
|
+
};
|
|
748
750
|
|
|
749
751
|
var CaptchaField = function CaptchaField(_ref) {
|
|
750
752
|
var question = _ref.question,
|
|
@@ -2118,7 +2120,7 @@ var QUESTION_TO_COMPONENT_MAP = (_QUESTION_TO_COMPONEN = {}, _defineProperty(_QU
|
|
|
2118
2120
|
return /*#__PURE__*/jsx(EditorContent, {
|
|
2119
2121
|
content: fieldWithFallback(question, "label", true)
|
|
2120
2122
|
});
|
|
2121
|
-
}), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.TERMS.value, TermsField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.DATE.value, DateField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.STAR_RATING.value, StarRatingField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.ADDITIONAL_GUESTS.value, MultipleEmailInput), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.RICH_TEXT.value, RichTextEditor), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.CONDITION.value, ConditionField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.FILE_UPLOAD.value, FileUploadField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.CAPTCHA.value, CaptchaField), _QUESTION_TO_COMPONEN);
|
|
2123
|
+
}), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.TERMS.value, TermsField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.DATE.value, DateField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.STAR_RATING.value, StarRatingField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.ADDITIONAL_GUESTS.value, MultipleEmailInput), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.RICH_TEXT.value, RichTextEditor), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.CONDITION.value, ConditionField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.FILE_UPLOAD.value, FileUploadField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.CAPTCHA.value, CaptchaField), _defineProperty(_QUESTION_TO_COMPONEN, QUESTION_KIND.SMS_REMINDER.value, PhoneNumberField), _QUESTION_TO_COMPONEN);
|
|
2122
2124
|
var CAPTCHA_COMPONENT_MAP = (_CAPTCHA_COMPONENT_MA = {}, _defineProperty(_CAPTCHA_COMPONENT_MA, CAPTCHA_TYPES.RECAPTCHA_V2, Recaptcha), _defineProperty(_CAPTCHA_COMPONENT_MA, CAPTCHA_TYPES.MATH_CAPTCHA, MathCaptcha), _CAPTCHA_COMPONENT_MA);
|
|
2123
2125
|
|
|
2124
2126
|
var getFieldComponent = function getFieldComponent(_ref) {
|
|
@@ -2146,4 +2148,4 @@ var getPhoneData = function getPhoneData(value, countryCode) {
|
|
|
2146
2148
|
};
|
|
2147
2149
|
|
|
2148
2150
|
export { FormikWrap as F, generateInitValues as a, getFieldComponent as b, clientI18nInstance as c, buildAutoCompleteAttribute as d, generateFormResponse as e, clearLocalStorageValues as f, getWithExpiry as g, mergeRefs as m, renderButtonsInOrder as r };
|
|
2149
|
-
//# sourceMappingURL=utils-
|
|
2151
|
+
//# sourceMappingURL=utils-0eabfa9b.js.map
|