@bigbinary/neeto-form-frontend 3.4.2 → 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 -8
- package/dist/ExternalForm.js.map +1 -1
- package/dist/Submission.js +2 -1
- package/dist/Submission.js.map +1 -1
- package/dist/UrlBuilder.js +5 -9
- 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 -8
- package/dist/cjs/ExternalForm.js.map +1 -1
- package/dist/cjs/Submission.js +2 -1
- package/dist/cjs/Submission.js.map +1 -1
- package/dist/cjs/UrlBuilder.js +5 -9
- package/dist/cjs/UrlBuilder.js.map +1 -1
- package/dist/cjs/hooks.js +1 -1
- package/dist/cjs/index.js +5 -10
- package/dist/cjs/index.js.map +1 -1
- 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 -10
- package/dist/index.js.map +1 -1
- package/dist/{utils-1ab9e83f.js → utils-0eabfa9b.js} +281 -288
- package/dist/utils-0eabfa9b.js.map +1 -0
- package/dist/{utils-38cc949e.js → utils-b26ce7e8.js} +287 -299
- 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-1ab9e83f.js.map +0 -1
- package/dist/utils-38cc949e.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
|
-
import dayjs from '
|
|
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,21 +21,16 @@ 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
|
-
import { withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils';
|
|
29
28
|
import Refresh from '@bigbinary/neeto-icons/Refresh';
|
|
30
29
|
import Input from '@bigbinary/neetoui/Input';
|
|
31
30
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
32
31
|
import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
|
|
33
32
|
import ReCAPTCHA from 'react-google-recaptcha';
|
|
34
33
|
import Checkbox from '@bigbinary/neetoui/Checkbox';
|
|
35
|
-
import localeData from 'dayjs/plugin/localeData';
|
|
36
|
-
import utc from 'dayjs/plugin/utc';
|
|
37
|
-
import weekday from 'dayjs/plugin/weekday';
|
|
38
|
-
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
39
34
|
import DatePicker from '@bigbinary/neetoui/DatePicker';
|
|
40
35
|
import Label from '@bigbinary/neetoui/Label';
|
|
41
36
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
@@ -162,274 +157,9 @@ var getInvalidTypeError = function getInvalidTypeError(label, type) {
|
|
|
162
157
|
});
|
|
163
158
|
};
|
|
164
159
|
|
|
165
|
-
var _excluded$4 = ["kind", "customValidator"];
|
|
166
|
-
var _fieldKindValidatorMa;
|
|
167
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; }
|
|
168
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; }
|
|
169
162
|
var t$1 = clientI18nInstance.t;
|
|
170
|
-
yup.addMethod(yup.array, "unique", function () {
|
|
171
|
-
var field, message;
|
|
172
|
-
if (arguments.length > 1) {
|
|
173
|
-
field = arguments[0];
|
|
174
|
-
message = arguments[1];
|
|
175
|
-
} else {
|
|
176
|
-
message = arguments[0];
|
|
177
|
-
}
|
|
178
|
-
var getValue = function getValue(item) {
|
|
179
|
-
return field ? item[field] : item;
|
|
180
|
-
};
|
|
181
|
-
var valueInLowerCase = pipe(getValue, toLower);
|
|
182
|
-
return this.test("unique", message, function () {
|
|
183
|
-
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
184
|
-
// ignore destroyed items in the array
|
|
185
|
-
var validItems = reject(prop("_destroy"), array);
|
|
186
|
-
var uniqueItems = new Set(map(valueInLowerCase, validItems));
|
|
187
|
-
|
|
188
|
-
// all items are unique
|
|
189
|
-
if (validItems.length === uniqueItems.size) return true;
|
|
190
|
-
return this.createError({
|
|
191
|
-
path: this.path,
|
|
192
|
-
message: message
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
var isValidDate = function isValidDate(date) {
|
|
197
|
-
return date && dayjs(date).isValid();
|
|
198
|
-
};
|
|
199
|
-
var extractEmailDomain = function extractEmailDomain(email) {
|
|
200
|
-
return email === null || email === void 0 ? void 0 : email.split("@")[1];
|
|
201
|
-
};
|
|
202
|
-
var isEmailFromRestrictedDomain = function isEmailFromRestrictedDomain(email, restrictedDomains) {
|
|
203
|
-
var domain = extractEmailDomain(email);
|
|
204
|
-
return includes(domain, restrictedDomains);
|
|
205
|
-
};
|
|
206
|
-
var validateTextField = function validateTextField(_ref) {
|
|
207
|
-
var kind = _ref.kind,
|
|
208
|
-
label = _ref.label,
|
|
209
|
-
isRequired = _ref.isRequired;
|
|
210
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
211
|
-
if (kind === QUESTION_KIND.PHONE.value) {
|
|
212
|
-
schema = validation(getInvalidFieldError(t$1("neetoForm.common.phoneNumberValidation")));
|
|
213
|
-
}
|
|
214
|
-
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
215
|
-
return schema.trim();
|
|
216
|
-
};
|
|
217
|
-
var validateEmailField = function validateEmailField(_ref2) {
|
|
218
|
-
var label = _ref2.label,
|
|
219
|
-
isRequired = _ref2.isRequired,
|
|
220
|
-
restrictedDomains = _ref2.restrictedDomains;
|
|
221
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string")).email(getInvalidFieldError("Email")).test("verify domain", function (_ref3) {
|
|
222
|
-
var value = _ref3.value;
|
|
223
|
-
return t$1("neetoForm.error.emailFromRestrictedDomain", {
|
|
224
|
-
domain: extractEmailDomain(value)
|
|
225
|
-
});
|
|
226
|
-
}, function (value) {
|
|
227
|
-
return isNotPresent(value) || !isEmailFromRestrictedDomain(value, restrictedDomains);
|
|
228
|
-
});
|
|
229
|
-
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
230
|
-
return schema.trim();
|
|
231
|
-
};
|
|
232
|
-
var validateNameField = function validateNameField(_ref4) {
|
|
233
|
-
var label = _ref4.label,
|
|
234
|
-
isRequired = _ref4.isRequired;
|
|
235
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
236
|
-
if (isRequired) schema = schema.trim().required(getRequiredFieldError(label));
|
|
237
|
-
return schema.trim();
|
|
238
|
-
};
|
|
239
|
-
var validateSingleChoiceField = function validateSingleChoiceField(_ref5) {
|
|
240
|
-
var label = _ref5.label,
|
|
241
|
-
isRequired = _ref5.isRequired;
|
|
242
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
243
|
-
if (isRequired) schema = schema.required(getSelectMinError("an"));
|
|
244
|
-
return schema.trim();
|
|
245
|
-
};
|
|
246
|
-
var validateMultiChoiceField = function validateMultiChoiceField(_ref6) {
|
|
247
|
-
var isRequired = _ref6.isRequired;
|
|
248
|
-
var schema = yup.array().of(yup["boolean"]());
|
|
249
|
-
if (isRequired) schema = schema.compact().min(1, getSelectMinError("an"));
|
|
250
|
-
return schema;
|
|
251
|
-
};
|
|
252
|
-
var validateRatingField = function validateRatingField(_ref7) {
|
|
253
|
-
var label = _ref7.label,
|
|
254
|
-
isRequired = _ref7.isRequired;
|
|
255
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
256
|
-
if (isRequired) schema = schema.required(getSelectMinError("an"));
|
|
257
|
-
return schema.trim();
|
|
258
|
-
};
|
|
259
|
-
var validateStarRatingField = function validateStarRatingField(_ref8) {
|
|
260
|
-
var label = _ref8.label,
|
|
261
|
-
isRequired = _ref8.isRequired;
|
|
262
|
-
var schema = yup.string().typeError(getInvalidTypeError(label, "string"));
|
|
263
|
-
if (isRequired) {
|
|
264
|
-
schema = schema.required(getSelectMinError("a", t$1("neetoForm.common.rating")));
|
|
265
|
-
}
|
|
266
|
-
return schema.trim();
|
|
267
|
-
};
|
|
268
|
-
var validateTermsField = function validateTermsField(_ref9) {
|
|
269
|
-
var _ref9$isRequired = _ref9.isRequired,
|
|
270
|
-
isRequired = _ref9$isRequired === void 0 ? true : _ref9$isRequired;
|
|
271
|
-
return isRequired ? yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptTermsAndConditions")) : yup["boolean"]().notRequired();
|
|
272
|
-
};
|
|
273
|
-
var validateConditionField = function validateConditionField(_ref10) {
|
|
274
|
-
var _ref10$isRequired = _ref10.isRequired,
|
|
275
|
-
isRequired = _ref10$isRequired === void 0 ? true : _ref10$isRequired;
|
|
276
|
-
return isRequired ? yup["boolean"]().oneOf([true], t$1("neetoForm.common.mustAcceptCondition")) : yup["boolean"]().notRequired();
|
|
277
|
-
};
|
|
278
|
-
var validateDateField = function validateDateField(_ref11) {
|
|
279
|
-
var label = _ref11.label,
|
|
280
|
-
isRequired = _ref11.isRequired;
|
|
281
|
-
var schema = yup.string().test("is valid date", getInvalidTypeError(label, "date"), function (value) {
|
|
282
|
-
return isNotPresent(value) || isValidDate(value);
|
|
283
|
-
});
|
|
284
|
-
if (isRequired) {
|
|
285
|
-
schema = schema.required(getRequiredFieldError(label));
|
|
286
|
-
}
|
|
287
|
-
return schema;
|
|
288
|
-
};
|
|
289
|
-
var validateMultiEmailField = function validateMultiEmailField(_ref12) {
|
|
290
|
-
var isRequired = _ref12.isRequired;
|
|
291
|
-
var schema = yup.array().of(yup.object().shape({
|
|
292
|
-
value: yup.string().email(getInvalidFieldError("Email")).trim()
|
|
293
|
-
})).nullable();
|
|
294
|
-
if (isRequired) {
|
|
295
|
-
schema = schema.compact().min(1, getSelectMinError("an", t$1("neetoForm.common.email")));
|
|
296
|
-
}
|
|
297
|
-
return schema;
|
|
298
|
-
};
|
|
299
|
-
var editorHasValue = function editorHasValue(content) {
|
|
300
|
-
return !isEditorEmpty(content);
|
|
301
|
-
};
|
|
302
|
-
var validateRichTextField = function validateRichTextField(_ref13) {
|
|
303
|
-
var isRequired = _ref13.isRequired;
|
|
304
|
-
var schema = yup.string();
|
|
305
|
-
if (isRequired) {
|
|
306
|
-
schema = schema.test("required", getRequiredFieldError("content"), editorHasValue);
|
|
307
|
-
}
|
|
308
|
-
return schema.trim();
|
|
309
|
-
};
|
|
310
|
-
var validateFileUploadField = function validateFileUploadField(_ref14) {
|
|
311
|
-
var isRequired = _ref14.isRequired,
|
|
312
|
-
multipleFilesAllowed = _ref14.multipleFilesAllowed;
|
|
313
|
-
var files_schema = yup.array();
|
|
314
|
-
if (isRequired) {
|
|
315
|
-
files_schema = files_schema.of(yup.object().shape({
|
|
316
|
-
name: yup.string(),
|
|
317
|
-
signedId: yup.string().required(t$1("neetoForm.fileUpload.validations.waitForUpload")),
|
|
318
|
-
url: yup.string().required(t$1("neetoForm.fileUpload.validations.waitForUpload"))
|
|
319
|
-
})).unique("name", t$1("neetoForm.fileUpload.validations.removeDuplicates")).min(1, multipleFilesAllowed ? t$1("neetoForm.fileUpload.validations.atLeastOneFileRequired") : t$1("neetoForm.fileUpload.validations.fileIsRequired"));
|
|
320
|
-
}
|
|
321
|
-
return yup.object().shape({
|
|
322
|
-
files: files_schema
|
|
323
|
-
});
|
|
324
|
-
};
|
|
325
|
-
var validateCaptchaField = function validateCaptchaField(_ref15) {
|
|
326
|
-
var variant = _ref15.variant;
|
|
327
|
-
return variant === CAPTCHA_TYPES.MATH_CAPTCHA ? yup.mixed().test("verification failed", t$1("neetoForm.error.captchaVerificationFailed"), function (value) {
|
|
328
|
-
return isNotPresent(value) || value;
|
|
329
|
-
}).transform(function (value) {
|
|
330
|
-
return value === "" ? null : value;
|
|
331
|
-
}).required(t$1("neetoForm.error.incompleteCaptcha")) : yup.string().trim().required(t$1("neetoForm.error.incompleteCaptcha"));
|
|
332
|
-
};
|
|
333
|
-
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);
|
|
334
|
-
var validateFieldValue = function validateFieldValue(_ref16) {
|
|
335
|
-
var kind = _ref16.kind,
|
|
336
|
-
customValidator = _ref16.customValidator,
|
|
337
|
-
otherProps = _objectWithoutProperties(_ref16, _excluded$4);
|
|
338
|
-
return function (value) {
|
|
339
|
-
if (!(kind in fieldKindValidatorMap)) return;
|
|
340
|
-
var validator = fieldKindValidatorMap[kind];
|
|
341
|
-
var schema = customValidator || validator(_objectSpread$g({
|
|
342
|
-
kind: kind
|
|
343
|
-
}, otherProps));
|
|
344
|
-
|
|
345
|
-
// eslint-disable-next-line consistent-return, no-async-promise-executor
|
|
346
|
-
return new Promise( /*#__PURE__*/function () {
|
|
347
|
-
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
|
|
348
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
349
|
-
while (1) switch (_context.prev = _context.next) {
|
|
350
|
-
case 0:
|
|
351
|
-
_context.prev = 0;
|
|
352
|
-
_context.next = 3;
|
|
353
|
-
return schema.validate(value);
|
|
354
|
-
case 3:
|
|
355
|
-
resolve(undefined);
|
|
356
|
-
_context.next = 9;
|
|
357
|
-
break;
|
|
358
|
-
case 6:
|
|
359
|
-
_context.prev = 6;
|
|
360
|
-
_context.t0 = _context["catch"](0);
|
|
361
|
-
resolve(_context.t0.message);
|
|
362
|
-
case 9:
|
|
363
|
-
case "end":
|
|
364
|
-
return _context.stop();
|
|
365
|
-
}
|
|
366
|
-
}, _callee, null, [[0, 6]]);
|
|
367
|
-
}));
|
|
368
|
-
return function (_x) {
|
|
369
|
-
return _ref17.apply(this, arguments);
|
|
370
|
-
};
|
|
371
|
-
}());
|
|
372
|
-
};
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
var MultipleEmailInput = function MultipleEmailInput(_ref) {
|
|
376
|
-
var _jsx2;
|
|
377
|
-
var question = _ref.question,
|
|
378
|
-
customValidator = _ref.customValidator;
|
|
379
|
-
var name = question.id,
|
|
380
|
-
kind = question.kind,
|
|
381
|
-
isRequired = question.isRequired,
|
|
382
|
-
nodeId = question.nodeId;
|
|
383
|
-
var label = fieldWithFallback(question, "label");
|
|
384
|
-
var _useTranslation = useTranslation(),
|
|
385
|
-
t = _useTranslation.t;
|
|
386
|
-
var _useField = useField({
|
|
387
|
-
name: name || nodeId,
|
|
388
|
-
validate: validateFieldValue({
|
|
389
|
-
kind: kind,
|
|
390
|
-
label: label,
|
|
391
|
-
isRequired: isRequired,
|
|
392
|
-
customValidator: customValidator
|
|
393
|
-
})
|
|
394
|
-
}),
|
|
395
|
-
_useField2 = _slicedToArray(_useField, 3),
|
|
396
|
-
field = _useField2[0],
|
|
397
|
-
meta = _useField2[1],
|
|
398
|
-
_useField2$ = _useField2[2],
|
|
399
|
-
setValue = _useField2$.setValue,
|
|
400
|
-
setTouched = _useField2$.setTouched;
|
|
401
|
-
var _useState = useState(isPresent(field.value)),
|
|
402
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
403
|
-
isInputVisible = _useState2[0],
|
|
404
|
-
setIsInputVisible = _useState2[1];
|
|
405
|
-
return /*#__PURE__*/jsx("div", {
|
|
406
|
-
className: "neeto-form-engine-input__wrapper",
|
|
407
|
-
children: /*#__PURE__*/jsx("div", {
|
|
408
|
-
className: "neeto-ui-w-full",
|
|
409
|
-
children: isInputVisible ? /*#__PURE__*/jsx(NeetoUIMultiEmailInput, {
|
|
410
|
-
isRequired: isRequired,
|
|
411
|
-
label: label,
|
|
412
|
-
error: meta.touched ? meta.error : "",
|
|
413
|
-
helpText: t("neetoForm.common.addGuestsHelper"),
|
|
414
|
-
name: field.name,
|
|
415
|
-
placeholder: fieldWithFallback(question, "placeholder"),
|
|
416
|
-
value: field.value,
|
|
417
|
-
onBlur: function onBlur() {
|
|
418
|
-
return setTouched(true);
|
|
419
|
-
},
|
|
420
|
-
onChange: setValue
|
|
421
|
-
}) : /*#__PURE__*/jsx(Button, (_jsx2 = {
|
|
422
|
-
label: label
|
|
423
|
-
}, _defineProperty(_jsx2, "label", t("neetoForm.common.addGuests")), _defineProperty(_jsx2, "style", "secondary"), _defineProperty(_jsx2, "onClick", function onClick() {
|
|
424
|
-
return setIsInputVisible(true);
|
|
425
|
-
}), _jsx2))
|
|
426
|
-
})
|
|
427
|
-
});
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
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; }
|
|
431
|
-
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; }
|
|
432
|
-
var t = clientI18nInstance.t;
|
|
433
163
|
var toEmailValues = function toEmailValues() {
|
|
434
164
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
435
165
|
return values.map(function (value) {
|
|
@@ -522,7 +252,7 @@ var generateInitValues = function generateInitValues(_ref7) {
|
|
|
522
252
|
var valuesMap = {};
|
|
523
253
|
if (initialValues) {
|
|
524
254
|
valuesMap = initialValues.reduce(function (acc, answer) {
|
|
525
|
-
return _objectSpread$
|
|
255
|
+
return _objectSpread$g(_objectSpread$g({}, acc), {}, _defineProperty({}, answer.questionId, {
|
|
526
256
|
value: answer.value,
|
|
527
257
|
optionIds: answer.optionIds
|
|
528
258
|
}));
|
|
@@ -613,6 +343,7 @@ var generateInitValues = function generateInitValues(_ref7) {
|
|
|
613
343
|
return;
|
|
614
344
|
}
|
|
615
345
|
case QUESTION_KIND.PHONE.value:
|
|
346
|
+
case QUESTION_KIND.SMS_REMINDER.value:
|
|
616
347
|
{
|
|
617
348
|
var _valuesMap$id$value3, _valuesMap6;
|
|
618
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);
|
|
@@ -668,7 +399,7 @@ var generateFormResponse = function generateFormResponse(response, questions) {
|
|
|
668
399
|
kind: kind
|
|
669
400
|
});
|
|
670
401
|
});
|
|
671
|
-
} else if (kind
|
|
402
|
+
} else if (isPhoneNumberField(kind)) {
|
|
672
403
|
formResponse.push({
|
|
673
404
|
questionId: id,
|
|
674
405
|
value: responseValue ? parsePhoneNumber(responseValue).formatInternational() : "",
|
|
@@ -724,21 +455,21 @@ var renderErrorMessage = function renderErrorMessage(errorObject, maxFileSize, i
|
|
|
724
455
|
var code = error.code;
|
|
725
456
|
switch (code) {
|
|
726
457
|
case ERROR_CODES.FILE_TOO_LARGE:
|
|
727
|
-
return t("neetoForm.fileUpload.dropzone.errors.fileTooLarge", {
|
|
458
|
+
return t$1("neetoForm.fileUpload.dropzone.errors.fileTooLarge", {
|
|
728
459
|
fileName: file.name,
|
|
729
460
|
maxSize: Math.round(maxFileSize / 1048576)
|
|
730
461
|
});
|
|
731
462
|
case ERROR_CODES.FILE_INVALID_TYPE:
|
|
732
|
-
return t("neetoForm.fileUpload.dropzone.errors.fileInvalidType", {
|
|
463
|
+
return t$1("neetoForm.fileUpload.dropzone.errors.fileInvalidType", {
|
|
733
464
|
fileType: path.extname(file.name)
|
|
734
465
|
});
|
|
735
466
|
case ERROR_CODES.TOO_MANY_FILES:
|
|
736
467
|
if (!isMultiple) {
|
|
737
|
-
return t("neetoForm.fileUpload.dropzone.errors.tooManyFiles");
|
|
468
|
+
return t$1("neetoForm.fileUpload.dropzone.errors.tooManyFiles");
|
|
738
469
|
}
|
|
739
470
|
}
|
|
740
471
|
}
|
|
741
|
-
return t("neetoForm.fileUpload.dropzone.errors.defaultError", {
|
|
472
|
+
return t$1("neetoForm.fileUpload.dropzone.errors.defaultError", {
|
|
742
473
|
fileName: file.name
|
|
743
474
|
});
|
|
744
475
|
};
|
|
@@ -750,6 +481,272 @@ var getSelectedRating = function getSelectedRating(value) {
|
|
|
750
481
|
var parsedValue = parseInt(value);
|
|
751
482
|
return isNaN(parsedValue) ? -1 : parsedValue;
|
|
752
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
|
+
};
|
|
753
750
|
|
|
754
751
|
var CaptchaField = function CaptchaField(_ref) {
|
|
755
752
|
var question = _ref.question,
|
|
@@ -959,10 +956,6 @@ var ConditionField = function ConditionField(_ref) {
|
|
|
959
956
|
var _excluded$3 = ["value"];
|
|
960
957
|
function ownKeys$d(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; }
|
|
961
958
|
function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
962
|
-
dayjs.extend(weekOfYear);
|
|
963
|
-
dayjs.extend(weekday);
|
|
964
|
-
dayjs.extend(localeData);
|
|
965
|
-
dayjs.extend(utc);
|
|
966
959
|
var DateField = function DateField(_ref) {
|
|
967
960
|
var question = _ref.question,
|
|
968
961
|
customValidator = _ref.customValidator;
|
|
@@ -2127,7 +2120,7 @@ var QUESTION_TO_COMPONENT_MAP = (_QUESTION_TO_COMPONEN = {}, _defineProperty(_QU
|
|
|
2127
2120
|
return /*#__PURE__*/jsx(EditorContent, {
|
|
2128
2121
|
content: fieldWithFallback(question, "label", true)
|
|
2129
2122
|
});
|
|
2130
|
-
}), _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);
|
|
2131
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);
|
|
2132
2125
|
|
|
2133
2126
|
var getFieldComponent = function getFieldComponent(_ref) {
|
|
@@ -2155,4 +2148,4 @@ var getPhoneData = function getPhoneData(value, countryCode) {
|
|
|
2155
2148
|
};
|
|
2156
2149
|
|
|
2157
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 };
|
|
2158
|
-
//# sourceMappingURL=utils-
|
|
2151
|
+
//# sourceMappingURL=utils-0eabfa9b.js.map
|