@bigbinary/neeto-form-frontend 4.2.11 → 4.4.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/en.json +50 -3
- package/dist/BuildForm.js +548 -87
- package/dist/BuildForm.js.map +1 -1
- package/dist/ExternalForm.js +7 -7
- package/dist/Submission.js +32 -1
- package/dist/Submission.js.map +1 -1
- package/dist/UrlBuilder.js +9 -8
- package/dist/UrlBuilder.js.map +1 -1
- package/dist/{buildForm-CooylMLL.js → buildForm-Bdc3ubm4.js} +2 -2
- package/dist/{buildForm-CooylMLL.js.map → buildForm-Bdc3ubm4.js.map} +1 -1
- package/dist/{buildForm-DcE5kFvR.js → buildForm-CkVmGF-A.js} +2 -2
- package/dist/{buildForm-DcE5kFvR.js.map → buildForm-CkVmGF-A.js.map} +1 -1
- package/dist/cjs/BuildForm.js +614 -153
- package/dist/cjs/BuildForm.js.map +1 -1
- package/dist/cjs/ExternalForm.js +21 -21
- package/dist/cjs/ExternalForm.js.map +1 -1
- package/dist/cjs/Submission.js +32 -1
- package/dist/cjs/Submission.js.map +1 -1
- package/dist/cjs/UrlBuilder.js +19 -18
- package/dist/cjs/UrlBuilder.js.map +1 -1
- package/dist/cjs/hooks.js +4 -4
- package/dist/cjs/index.js +11 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/{constants-51SEJjzI.js → constants-30230o5k.js} +4 -2
- package/dist/constants-30230o5k.js.map +1 -0
- package/dist/{constants-C9wKMfgo.js → constants-DNNZYQ9X.js} +4 -2
- package/dist/constants-DNNZYQ9X.js.map +1 -0
- package/dist/hooks.js +4 -4
- package/dist/{index-DnHrq-hl.js → index-BfavwyMH.js} +2 -2
- package/dist/{index-DnHrq-hl.js.map → index-BfavwyMH.js.map} +1 -1
- package/dist/{index-D4URTv1p.js → index-Dz5Yvk3n.js} +2 -2
- package/dist/{index-D4URTv1p.js.map → index-Dz5Yvk3n.js.map} +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/{useFormSubmission-BGNEnxvm.js → useFormSubmission-CdKlP6De.js} +2 -2
- package/dist/{useFormSubmission-BGNEnxvm.js.map → useFormSubmission-CdKlP6De.js.map} +1 -1
- package/dist/{useFormSubmission-BUPnuOSG.js → useFormSubmission-zyh3tA0H.js} +2 -2
- package/dist/{useFormSubmission-BUPnuOSG.js.map → useFormSubmission-zyh3tA0H.js.map} +1 -1
- package/dist/{utils-Dn-q4QBc.js → utils-CDyve_0y.js} +274 -73
- package/dist/utils-CDyve_0y.js.map +1 -0
- package/dist/{utils-Ch7Ggngj.js → utils-DfujkkDT.js} +323 -122
- package/dist/utils-DfujkkDT.js.map +1 -0
- package/dist/{constants-BjWWA3Oq.js → yup-DcJey7xZ.js} +149 -26
- package/dist/yup-DcJey7xZ.js.map +1 -0
- package/dist/{constants-QPLZ_r-D.js → yup-SHH_PrTm.js} +139 -28
- package/dist/yup-SHH_PrTm.js.map +1 -0
- package/package.json +20 -19
- package/types.d.ts +3 -0
- package/dist/constants-51SEJjzI.js.map +0 -1
- package/dist/constants-BjWWA3Oq.js.map +0 -1
- package/dist/constants-C9wKMfgo.js.map +0 -1
- package/dist/constants-QPLZ_r-D.js.map +0 -1
- package/dist/utils-Ch7Ggngj.js.map +0 -1
- package/dist/utils-Dn-q4QBc.js.map +0 -1
package/dist/BuildForm.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import { isPresent, truncate, findBy, isNotPresent, slugify, existsBy, hyphenate, noop, nullSafe, removeBy } from '@bigbinary/neeto-cist';
|
|
3
|
+
import { isPresent, truncate, findBy, isNotPresent, slugify, existsBy, findById, findIndexById, hyphenate, noop, nullSafe, modifyBy, removeBy } from '@bigbinary/neeto-cist';
|
|
4
4
|
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
5
|
-
import { equals, path,
|
|
6
|
-
import { k as useDeleteQuestion, Q as QUESTION_TYPES, a as useForm, l as useCreateQuestion, m as useUpdateQuestion, C as CAPTCHA_TYPES, n as useReorderQuestions, i as QUERY_KEYS } from './constants-
|
|
7
|
-
import {
|
|
5
|
+
import { equals, path, when, assoc, includes, isEmpty, reject, keys, pick, omit, evolve, map, mergeLeft, isNil, pipe, filter, isNotNil, values, uniq, join, pathSatisfies, assocPath, dissoc, append, pluck, test, paths, difference, prop, startsWith, split, last, either, T, F } from 'ramda';
|
|
6
|
+
import { k as useDeleteQuestion, Q as QUESTION_TYPES, a as useForm, l as useCreateQuestion, m as useUpdateQuestion, C as CAPTCHA_TYPES, n as useReorderQuestions, i as QUERY_KEYS } from './constants-30230o5k.js';
|
|
7
|
+
import { h as buildDisplayLabel, i as INDEPENDENT_LABELS_MAP, j as QUESTION_ACTIONS, k as isElementOverflowing, l as Drag, m as SELECTABLE_KINDS, n as isAutoGeneratedQuestion, o as isRichTextQuestion, N as NON_BASIC_LATIN_CHARACTERS_REGEX, p as RESERVED_FIELD_CODES, r as renameKey, e as LABEL_FIELDS, q as isDefaultLanguage, s as buildAddQuestionButtonProps, v as validateEditorContent, F as FIELD_CODES_REJECT_CHARS_REGEX, t as isImmutableField, Q as QUESTIONS_WITHOUT_FIELD_CODE, u as NON_HIDEABLE_FIELDS, w as NON_READ_ONLY_FIELDS, x as RICH_TEXT_QUESTIONS, O as OPINION_LABEL_MAX_LENGTH, A as ADDRESS_FIELD_WIDTHS, d as ADDRESS_FIELD_TYPES, y as generateDefaultOptions, M as MINIMUM_ADDRESS_FIELDS, z as getDeletedRecords, B as randomId, G as getActiveRecords, H as FILE_TYPES_MAP, J as FILE_GROUPS, K as OPINION_SCALE_MIN_VALUE_OPTIONS, T as OPINION_SCALE_MAX_VALUE_OPTIONS, D as DEFAULT_CHOICE_QUESTION_ATTRIBUTES, U as MINIMUM_OPTIONS, V as IMAGE_HEIGHT_SLIDER_DEFAULTS, W as RATING_OPTIONS, X as STAR_RATING_MIN_VALUE_OPTIONS, Y as STAR_RATING_MAX_VALUE_OPTIONS, Z as STAR_RATING_ICONS_MAP, _ as buildDisabledAddButtonHelpPopoverProps, $ as buildReorderPayload, a0 as isMandatoryField, a1 as QUESTION_KINDS, a as QUESTION_KIND, a2 as getActiveQuestionKindDetails, a3 as DEFAULT_AVAILABLE_LANGUAGES, a4 as DEFAULT_ADVANCED_FEATURES, a5 as QUESTIONS_INITIAL_VALUE } from './yup-SHH_PrTm.js';
|
|
8
8
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
9
9
|
import { useState, useRef, useEffect, createElement } from 'react';
|
|
10
10
|
import { Droppable, Draggable, DragDropContext } from '@hello-pangea/dnd';
|
|
11
11
|
import { withT, isMetaKeyPressed, useStateWithDependency, useFuncDebounce, useOnClickOutside } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
12
12
|
import { showThumbsUpToastr, withEventTargetValue, hyphenize } from '@bigbinary/neeto-commons-frontend/utils';
|
|
13
|
-
import { a as useBuildFormStore } from './buildForm-
|
|
13
|
+
import { a as useBuildFormStore } from './buildForm-CkVmGF-A.js';
|
|
14
14
|
import { shallow } from 'zustand/shallow';
|
|
15
15
|
import Alert from '@bigbinary/neetoui/Alert';
|
|
16
16
|
import { useTranslation, Trans } from 'react-i18next';
|
|
@@ -21,13 +21,13 @@ import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
|
21
21
|
import Dropdown from '@bigbinary/neetoui/Dropdown';
|
|
22
22
|
import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
23
23
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
24
|
-
import { i as isFunction, f as fieldWithFallback, c as isNameQuestion } from './index-
|
|
24
|
+
import { i as isFunction, f as fieldWithFallback, c as isNameQuestion } from './index-BfavwyMH.js';
|
|
25
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
25
26
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
26
27
|
import { t } from 'i18next';
|
|
27
28
|
import { v4 } from 'uuid';
|
|
28
29
|
import NoData from '@bigbinary/neetoui/NoData';
|
|
29
30
|
import Button from '@bigbinary/neetoui/Button';
|
|
30
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
31
31
|
import Pane from '@bigbinary/neetoui/Pane';
|
|
32
32
|
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
33
33
|
import Form$2 from '@bigbinary/neetoui/formik/Form';
|
|
@@ -40,6 +40,8 @@ import NeetoEditor from '@bigbinary/neeto-editor/Editor';
|
|
|
40
40
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
41
41
|
import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
|
|
42
42
|
import * as yup from 'yup';
|
|
43
|
+
import OptionFields from '@bigbinary/neeto-molecules/OptionFields';
|
|
44
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
43
45
|
import Radio from '@bigbinary/neetoui/formik/Radio';
|
|
44
46
|
import Label from '@bigbinary/neetoui/Label';
|
|
45
47
|
import CreatableSelect from 'react-select/creatable';
|
|
@@ -51,7 +53,6 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
|
51
53
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
52
54
|
import Checkbox$1 from '@bigbinary/neetoui/formik/Checkbox';
|
|
53
55
|
import Checkbox from '@bigbinary/neetoui/Checkbox';
|
|
54
|
-
import OptionFields from '@bigbinary/neeto-molecules/OptionFields';
|
|
55
56
|
import Slider from '@bigbinary/neetoui/Slider';
|
|
56
57
|
import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
|
|
57
58
|
import '@bigbinary/neeto-commons-frontend/constants';
|
|
@@ -325,8 +326,8 @@ var Card = function Card(_ref) {
|
|
|
325
326
|
});
|
|
326
327
|
};
|
|
327
328
|
|
|
328
|
-
function ownKeys$
|
|
329
|
-
function _objectSpread$
|
|
329
|
+
function ownKeys$i(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; }
|
|
330
|
+
function _objectSpread$i(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$i(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$i(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
330
331
|
var Questions = function Questions(_ref) {
|
|
331
332
|
var questions = _ref.questions,
|
|
332
333
|
isDeletable = _ref.isDeletable,
|
|
@@ -345,7 +346,7 @@ var Questions = function Questions(_ref) {
|
|
|
345
346
|
var droppableProps = _ref2.droppableProps,
|
|
346
347
|
placeholder = _ref2.placeholder,
|
|
347
348
|
innerRef = _ref2.innerRef;
|
|
348
|
-
return /*#__PURE__*/jsxs("div", _objectSpread$
|
|
349
|
+
return /*#__PURE__*/jsxs("div", _objectSpread$i(_objectSpread$i({}, droppableProps), {}, {
|
|
349
350
|
className: "space-y-2",
|
|
350
351
|
ref: innerRef,
|
|
351
352
|
children: [questions.map(function (question, index) {
|
|
@@ -359,7 +360,7 @@ var Questions = function Questions(_ref) {
|
|
|
359
360
|
var draggableProps = _ref3.draggableProps,
|
|
360
361
|
dragHandleProps = _ref3.dragHandleProps,
|
|
361
362
|
innerRef = _ref3.innerRef;
|
|
362
|
-
return /*#__PURE__*/jsx("div", _objectSpread$
|
|
363
|
+
return /*#__PURE__*/jsx("div", _objectSpread$i(_objectSpread$i(_objectSpread$i({}, draggableProps), dragHandleProps), {}, {
|
|
363
364
|
ref: innerRef,
|
|
364
365
|
children: /*#__PURE__*/jsx(Card, {
|
|
365
366
|
allQuestionKinds: allQuestionKinds,
|
|
@@ -392,11 +393,15 @@ var arrayHelpers = {
|
|
|
392
393
|
moveItem: moveItem
|
|
393
394
|
};
|
|
394
395
|
|
|
395
|
-
|
|
396
|
-
function
|
|
396
|
+
var _excluded$b = ["fields"];
|
|
397
|
+
function ownKeys$h(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; }
|
|
398
|
+
function _objectSpread$h(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$h(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$h(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
397
399
|
var isChoiceQuestion = function isChoiceQuestion(question) {
|
|
398
400
|
return includes(question === null || question === void 0 ? void 0 : question.kind, SELECTABLE_KINDS);
|
|
399
401
|
};
|
|
402
|
+
var isAddressQuestion = function isAddressQuestion(question) {
|
|
403
|
+
return (question === null || question === void 0 ? void 0 : question.kind) === QUESTION_TYPES.ADDRESS;
|
|
404
|
+
};
|
|
400
405
|
var underscoredWithoutSpecialCharacters = function underscoredWithoutSpecialCharacters(string) {
|
|
401
406
|
return string.toLowerCase().replace(/[\s-]/g, "_").replace(/[\W]/gi, "").replace(/_+/g, "_").replace(/^_+|_+$/, "");
|
|
402
407
|
};
|
|
@@ -420,9 +425,6 @@ var generateFieldCodePrefix = function generateFieldCodePrefix(label, kind) {
|
|
|
420
425
|
}
|
|
421
426
|
return addSuffixForReservedFieldCode(prefix) || "";
|
|
422
427
|
};
|
|
423
|
-
var renameKey = curry(function (oldKey, newKey, obj) {
|
|
424
|
-
return assoc(newKey, prop(oldKey, obj), dissoc(oldKey, obj));
|
|
425
|
-
});
|
|
426
428
|
var modifyDefaultValues = function modifyDefaultValues(_ref) {
|
|
427
429
|
var values = _ref.values,
|
|
428
430
|
kind = _ref.kind,
|
|
@@ -475,7 +477,7 @@ var handleFieldDragEnd = function handleFieldDragEnd(_ref4) {
|
|
|
475
477
|
var nextItems = _toConsumableArray(items);
|
|
476
478
|
arrayHelpers.moveItem(nextItems, source.index, destination.index);
|
|
477
479
|
var orderedItems = nextItems.map(function (item, index) {
|
|
478
|
-
return _objectSpread$
|
|
480
|
+
return _objectSpread$h(_objectSpread$h({}, item), {}, {
|
|
479
481
|
displayOrder: index
|
|
480
482
|
});
|
|
481
483
|
});
|
|
@@ -497,7 +499,7 @@ var createFieldData = function createFieldData(_ref5) {
|
|
|
497
499
|
selectedLanguage: selectedLanguage,
|
|
498
500
|
isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds
|
|
499
501
|
});
|
|
500
|
-
return _objectSpread$
|
|
502
|
+
return _objectSpread$h(_objectSpread$h({}, modifiedDefaultValues), {}, {
|
|
501
503
|
metadata: metadata,
|
|
502
504
|
isRequired: isRequired,
|
|
503
505
|
kind: type,
|
|
@@ -521,15 +523,18 @@ var duplicateFieldData = function duplicateFieldData(_ref6) {
|
|
|
521
523
|
}, questionKinds);
|
|
522
524
|
var label = fieldWithFallback(item, "label");
|
|
523
525
|
var defaultAttributeNames = keys(questionKind.defaults || {});
|
|
524
|
-
var
|
|
526
|
+
var _pick = pick(defaultAttributeNames, item),
|
|
527
|
+
fields = _pick.fields,
|
|
528
|
+
defaultAttributes = _objectWithoutProperties(_pick, _excluded$b);
|
|
525
529
|
var newQuestionLabel = isRichTextQuestion(kind) ? label : t("neetoForm.common.clonedElementLabel", {
|
|
526
530
|
label: label
|
|
527
531
|
});
|
|
528
|
-
return _objectSpread$
|
|
532
|
+
return _objectSpread$h(_objectSpread$h({}, defaultAttributes), {}, {
|
|
529
533
|
isRequired: isRequired,
|
|
530
534
|
kind: kind,
|
|
531
535
|
label: newQuestionLabel,
|
|
532
536
|
optionsAttributes: optionsAttributes && optionsAttributes.map(omit(["id"])),
|
|
537
|
+
fieldsAttributes: fields && fields.map(omit(["id"])),
|
|
533
538
|
nodeId: v4(),
|
|
534
539
|
fieldCode: generateUniqueFieldCode({
|
|
535
540
|
questions: questions,
|
|
@@ -553,7 +558,9 @@ var getAvailableQuestionKinds = function getAvailableQuestionKinds(_ref7) {
|
|
|
553
558
|
});
|
|
554
559
|
}, allQuestionKinds);
|
|
555
560
|
};
|
|
556
|
-
var formatQuestionAttributesForClone = when(
|
|
561
|
+
var formatQuestionAttributesForClone = when(function (question) {
|
|
562
|
+
return isChoiceQuestion(question) || isAddressQuestion(question);
|
|
563
|
+
}, assoc("isCloning", true));
|
|
557
564
|
|
|
558
565
|
var HelpText = withT(function (_ref) {
|
|
559
566
|
var t = _ref.t,
|
|
@@ -600,12 +607,14 @@ var NAME = QUESTION_TYPES.NAME,
|
|
|
600
607
|
INTEGER = QUESTION_TYPES.INTEGER,
|
|
601
608
|
DECIMAL = QUESTION_TYPES.DECIMAL,
|
|
602
609
|
STAR_RATING$1 = QUESTION_TYPES.STAR_RATING,
|
|
610
|
+
OPINION_SCALE$1 = QUESTION_TYPES.OPINION_SCALE,
|
|
603
611
|
RATING$1 = QUESTION_TYPES.RATING,
|
|
604
612
|
DATE = QUESTION_TYPES.DATE,
|
|
605
613
|
FILE_UPLOAD$1 = QUESTION_TYPES.FILE_UPLOAD,
|
|
606
614
|
CAPTCHA$1 = QUESTION_TYPES.CAPTCHA,
|
|
607
|
-
SMS_REMINDER = QUESTION_TYPES.SMS_REMINDER
|
|
608
|
-
|
|
615
|
+
SMS_REMINDER = QUESTION_TYPES.SMS_REMINDER,
|
|
616
|
+
ADDRESS$1 = QUESTION_TYPES.ADDRESS;
|
|
617
|
+
var QUESTIONS_WITH_ADDITIONAL_DATA = [].concat(_toConsumableArray(SELECTABLE_KINDS), [STAR_RATING$1, OPINION_SCALE$1, RATING$1, FILE_UPLOAD$1, CAPTCHA$1, EMAIL$1, ADDRESS$1]);
|
|
609
618
|
var QUESTIONS_WITH_PLACEHOLDERS = [NAME, PHONE, EMAIL$1, ADDITIONAL_GUESTS, TEXT, TEXTAREA, RICH_TEXT, INTEGER, DECIMAL, DATE, SMS_REMINDER];
|
|
610
619
|
var DEFAULT_PLACEHOLDERS = {
|
|
611
620
|
CHECKBOX: t("neetoForm.questions.common.questionFields.field.labelExample", {
|
|
@@ -625,18 +634,19 @@ var INITIAL_VALUES = {
|
|
|
625
634
|
isSplitMode: false
|
|
626
635
|
};
|
|
627
636
|
var VALID_FIELD_CODE_REGEX = /^[a-z0-9]+(_[a-z0-9]+)*$/;
|
|
637
|
+
var DRAFT_ID_PREFIX = "draft-";
|
|
628
638
|
|
|
629
639
|
var useHelpDoc = function useHelpDoc(key) {
|
|
630
640
|
return useBuildFormStore(path(["formState", "helpDocUrls", key]));
|
|
631
641
|
};
|
|
632
642
|
|
|
633
|
-
var _excluded$
|
|
634
|
-
function ownKeys$
|
|
635
|
-
function _objectSpread$
|
|
643
|
+
var _excluded$a = ["label", "name"];
|
|
644
|
+
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; }
|
|
645
|
+
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; }
|
|
636
646
|
var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
637
647
|
var label = _ref.label,
|
|
638
648
|
name = _ref.name,
|
|
639
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
649
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$a);
|
|
640
650
|
var _useFormikContext = useFormikContext(),
|
|
641
651
|
dirty = _useFormikContext.dirty,
|
|
642
652
|
isValid = _useFormikContext.isValid,
|
|
@@ -651,7 +661,7 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
|
651
661
|
var end = element.value.length;
|
|
652
662
|
element.setSelectionRange(end, end);
|
|
653
663
|
};
|
|
654
|
-
return /*#__PURE__*/jsx(Textarea, _objectSpread$
|
|
664
|
+
return /*#__PURE__*/jsx(Textarea, _objectSpread$g({
|
|
655
665
|
label: label,
|
|
656
666
|
name: name,
|
|
657
667
|
className: "neeto-form-nano-adaptive-input",
|
|
@@ -665,8 +675,8 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
|
665
675
|
}, otherProps));
|
|
666
676
|
};
|
|
667
677
|
|
|
668
|
-
function ownKeys$
|
|
669
|
-
function _objectSpread$
|
|
678
|
+
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; }
|
|
679
|
+
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; }
|
|
670
680
|
var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
671
681
|
var kind = _ref.kind,
|
|
672
682
|
isLabelDisabled = _ref.isLabelDisabled,
|
|
@@ -680,14 +690,14 @@ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
|
680
690
|
var shouldShowPlaceholder = includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
|
|
681
691
|
return /*#__PURE__*/jsxs("div", {
|
|
682
692
|
className: "space-y-4",
|
|
683
|
-
children: [/*#__PURE__*/jsx(FormikAdaptiveInput, _objectSpread$
|
|
693
|
+
children: [/*#__PURE__*/jsx(FormikAdaptiveInput, _objectSpread$f({
|
|
684
694
|
required: true,
|
|
685
695
|
disabled: isLabelDisabled,
|
|
686
696
|
label: t("neetoForm.questions.common.questionFields.field.question"),
|
|
687
697
|
name: "label",
|
|
688
698
|
placeholder: DEFAULT_PLACEHOLDERS[kind],
|
|
689
699
|
onChange: withEventTargetValue(handleLabelChange)
|
|
690
|
-
}, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsx(FormikAdaptiveInput, _objectSpread$
|
|
700
|
+
}, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsx(FormikAdaptiveInput, _objectSpread$f({
|
|
691
701
|
className: "neeto-form-nano-placeholder-input neeto-form-nano-placeholder-input-".concat(kind),
|
|
692
702
|
name: "placeholder",
|
|
693
703
|
label: t("neetoForm.questions.common.questionFields.field.placeholder")
|
|
@@ -695,8 +705,8 @@ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
|
|
|
695
705
|
});
|
|
696
706
|
};
|
|
697
707
|
|
|
698
|
-
function ownKeys$
|
|
699
|
-
function _objectSpread$
|
|
708
|
+
function ownKeys$e(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; }
|
|
709
|
+
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
700
710
|
var Name = function Name(_ref) {
|
|
701
711
|
var isLabelDisabled = _ref.isLabelDisabled,
|
|
702
712
|
_handleLabelChange = _ref.handleLabelChange;
|
|
@@ -716,7 +726,7 @@ var Name = function Name(_ref) {
|
|
|
716
726
|
label: t("neetoForm.common.splitAsFirstAndLastNames"),
|
|
717
727
|
name: "isSplitMode"
|
|
718
728
|
}), isSplitMode && !usesCustomSubmissionComponent ? /*#__PURE__*/jsxs(Fragment, {
|
|
719
|
-
children: [/*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$
|
|
729
|
+
children: [/*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
720
730
|
handleLabelChange: function handleLabelChange(value) {
|
|
721
731
|
return _handleLabelChange(value, LABEL_FIELDS.FIRST_NAME);
|
|
722
732
|
},
|
|
@@ -728,7 +738,7 @@ var Name = function Name(_ref) {
|
|
|
728
738
|
label: t("neetoForm.questions.common.questionFields.field.firstNamePlaceholder"),
|
|
729
739
|
name: "firstNamePlaceholder"
|
|
730
740
|
}
|
|
731
|
-
})), /*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$
|
|
741
|
+
})), /*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
732
742
|
handleLabelChange: function handleLabelChange(value) {
|
|
733
743
|
return _handleLabelChange(value, LABEL_FIELDS.LAST_NAME);
|
|
734
744
|
},
|
|
@@ -741,7 +751,7 @@ var Name = function Name(_ref) {
|
|
|
741
751
|
name: "lastNamePlaceholder"
|
|
742
752
|
}
|
|
743
753
|
}))]
|
|
744
|
-
}) : /*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$
|
|
754
|
+
}) : /*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$e(_objectSpread$e({}, commonProps), {}, {
|
|
745
755
|
labelProps: {
|
|
746
756
|
name: LABEL_FIELDS.FULL_NAME
|
|
747
757
|
},
|
|
@@ -908,12 +918,12 @@ var RequiredSwitch = withT(function (_ref) {
|
|
|
908
918
|
});
|
|
909
919
|
});
|
|
910
920
|
|
|
911
|
-
var _excluded$
|
|
912
|
-
function ownKeys$
|
|
913
|
-
function _objectSpread$
|
|
921
|
+
var _excluded$9 = ["maxLength"];
|
|
922
|
+
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; }
|
|
923
|
+
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; }
|
|
914
924
|
var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
915
925
|
var maxLength = _ref.maxLength,
|
|
916
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
926
|
+
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
917
927
|
var _useField = useField(props),
|
|
918
928
|
_useField2 = _slicedToArray(_useField, 3),
|
|
919
929
|
value = _useField2[0].value,
|
|
@@ -924,7 +934,7 @@ var InputWithMaxLength = function InputWithMaxLength(_ref) {
|
|
|
924
934
|
}
|
|
925
935
|
}, [value, maxLength, setValue]);
|
|
926
936
|
var shouldShowMaxLength = value && value.length > maxLength - 10;
|
|
927
|
-
return /*#__PURE__*/jsx(Input, _objectSpread$
|
|
937
|
+
return /*#__PURE__*/jsx(Input, _objectSpread$d(_objectSpread$d({}, props), shouldShowMaxLength && {
|
|
928
938
|
maxLength: maxLength
|
|
929
939
|
}));
|
|
930
940
|
};
|
|
@@ -1089,7 +1099,7 @@ var Form$1 = function Form(_ref) {
|
|
|
1089
1099
|
dataTestid: "settings-card",
|
|
1090
1100
|
title: t("neetoForm.common.settings"),
|
|
1091
1101
|
children: [isBasicSettingsVisible && /*#__PURE__*/jsxs(Fragment, {
|
|
1092
|
-
children: [!isImmutable && /*#__PURE__*/jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsx(Switch, {
|
|
1102
|
+
children: [!isImmutable && kind !== QUESTION_TYPES.ADDRESS && /*#__PURE__*/jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsx(Switch, {
|
|
1093
1103
|
label: t("neetoForm.common.hideQuestion"),
|
|
1094
1104
|
name: "isHidden",
|
|
1095
1105
|
labelProps: hideSwitchLabelProps(hideQuestionHelpDocUrl)
|
|
@@ -1153,6 +1163,15 @@ var buildNameLabelValidationSchema = function buildNameLabelValidationSchema(que
|
|
|
1153
1163
|
var isRequired = isFullName ? !question.isSplitMode : question.isSplitMode;
|
|
1154
1164
|
return isNameQuestion(question.kind) && isRequired ? requiredLabelValidation(schema, t("neetoForm.questions.common.questionFields.field.question")) : schema.notRequired();
|
|
1155
1165
|
};
|
|
1166
|
+
var buildOpinionScaleLabelValidationSchema = function buildOpinionScaleLabelValidationSchema(label) {
|
|
1167
|
+
return stringSchema.when("hasOpinionLabels", {
|
|
1168
|
+
is: true,
|
|
1169
|
+
then: requiredLabelValidation(stringSchema, label).max(OPINION_LABEL_MAX_LENGTH, t("neetoForm.error.mustBeOrLessThanOrEqualTo", {
|
|
1170
|
+
value: OPINION_LABEL_MAX_LENGTH
|
|
1171
|
+
})),
|
|
1172
|
+
otherwise: stringSchema.notRequired()
|
|
1173
|
+
});
|
|
1174
|
+
};
|
|
1156
1175
|
var stringSchema = yup.string();
|
|
1157
1176
|
var formValidationSchema = function formValidationSchema(question) {
|
|
1158
1177
|
var isFieldCodeEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -1175,22 +1194,32 @@ var formValidationSchema = function formValidationSchema(question) {
|
|
|
1175
1194
|
})
|
|
1176
1195
|
})) : schema.notRequired();
|
|
1177
1196
|
}),
|
|
1197
|
+
fields: yup.array().when("kind", function (kind, schema) {
|
|
1198
|
+
return kind === QUESTION_TYPES.ADDRESS ? schema.of(yup.object().shape({
|
|
1199
|
+
label: yup.string().when("_destroy", {
|
|
1200
|
+
is: true,
|
|
1201
|
+
otherwise: yup.string().trim().required(t("neetoForm.error.allFieldsRequired"))
|
|
1202
|
+
})
|
|
1203
|
+
})) : schema.notRequired();
|
|
1204
|
+
}),
|
|
1178
1205
|
highestRatingLabel: yup.string().nullable(),
|
|
1179
1206
|
averageRatingLabel: yup.string().nullable(),
|
|
1180
|
-
lowestRatingLabel: yup.string().nullable()
|
|
1207
|
+
lowestRatingLabel: yup.string().nullable(),
|
|
1208
|
+
leftOpinionLabel: buildOpinionScaleLabelValidationSchema(t("neetoForm.questions.opinionScale.leftLabel")),
|
|
1209
|
+
rightOpinionLabel: buildOpinionScaleLabelValidationSchema(t("neetoForm.questions.opinionScale.rightLabel"))
|
|
1181
1210
|
});
|
|
1182
1211
|
};
|
|
1183
1212
|
|
|
1184
|
-
var _excluded$
|
|
1185
|
-
function ownKeys$
|
|
1186
|
-
function _objectSpread$
|
|
1213
|
+
var _excluded$8 = ["question", "onClose", "questions", "handleSelect", "isOpen"];
|
|
1214
|
+
function ownKeys$c(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; }
|
|
1215
|
+
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1187
1216
|
var Add = function Add(_ref) {
|
|
1188
1217
|
var question = _ref.question,
|
|
1189
1218
|
onClose = _ref.onClose,
|
|
1190
1219
|
questions = _ref.questions,
|
|
1191
1220
|
handleSelect = _ref.handleSelect,
|
|
1192
1221
|
isOpen = _ref.isOpen,
|
|
1193
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1222
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
1194
1223
|
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
1195
1224
|
var _store$formState, _store$formState2, _store$formState3;
|
|
1196
1225
|
return {
|
|
@@ -1224,7 +1253,7 @@ var Add = function Add(_ref) {
|
|
|
1224
1253
|
language: language,
|
|
1225
1254
|
neetoFormQuestion: mergeLeft({
|
|
1226
1255
|
displayOrder: displayOrder
|
|
1227
|
-
}, values)
|
|
1256
|
+
}, transformValues(values))
|
|
1228
1257
|
}, {
|
|
1229
1258
|
onSuccess: function onSuccess(_ref2) {
|
|
1230
1259
|
var questions = _ref2.questions;
|
|
@@ -1249,7 +1278,7 @@ var Add = function Add(_ref) {
|
|
|
1249
1278
|
onSubmit: handleSubmit
|
|
1250
1279
|
},
|
|
1251
1280
|
children: /*#__PURE__*/jsxs(Fragment, {
|
|
1252
|
-
children: [/*#__PURE__*/jsx(Form$1, _objectSpread$
|
|
1281
|
+
children: [/*#__PURE__*/jsx(Form$1, _objectSpread$c({}, _objectSpread$c(_objectSpread$c({}, props), {}, {
|
|
1253
1282
|
question: question,
|
|
1254
1283
|
questions: questions
|
|
1255
1284
|
}))), /*#__PURE__*/jsx(Pane.Footer, {
|
|
@@ -1265,14 +1294,14 @@ var Add = function Add(_ref) {
|
|
|
1265
1294
|
});
|
|
1266
1295
|
};
|
|
1267
1296
|
|
|
1268
|
-
var _excluded$
|
|
1269
|
-
function ownKeys$
|
|
1270
|
-
function _objectSpread$
|
|
1297
|
+
var _excluded$7 = ["question", "isOpen", "onClose"];
|
|
1298
|
+
function ownKeys$b(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; }
|
|
1299
|
+
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1271
1300
|
var Edit = function Edit(_ref) {
|
|
1272
1301
|
var question = _ref.question,
|
|
1273
1302
|
isOpen = _ref.isOpen,
|
|
1274
1303
|
onClose = _ref.onClose,
|
|
1275
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1304
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
1276
1305
|
var _useTranslation = useTranslation(),
|
|
1277
1306
|
t = _useTranslation.t;
|
|
1278
1307
|
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
@@ -1293,7 +1322,7 @@ var Edit = function Edit(_ref) {
|
|
|
1293
1322
|
if (isUpdating || !isOpen) return;
|
|
1294
1323
|
var payload = {
|
|
1295
1324
|
language: language,
|
|
1296
|
-
neetoFormQuestion: values
|
|
1325
|
+
neetoFormQuestion: transformValues(values)
|
|
1297
1326
|
};
|
|
1298
1327
|
updateQuestion({
|
|
1299
1328
|
questionId: question.id,
|
|
@@ -1326,7 +1355,7 @@ var Edit = function Edit(_ref) {
|
|
|
1326
1355
|
onSubmit: handleSubmit
|
|
1327
1356
|
},
|
|
1328
1357
|
children: /*#__PURE__*/jsxs(Fragment, {
|
|
1329
|
-
children: [/*#__PURE__*/jsx(Form$1, _objectSpread$
|
|
1358
|
+
children: [/*#__PURE__*/jsx(Form$1, _objectSpread$b(_objectSpread$b({}, _objectSpread$b({
|
|
1330
1359
|
question: question
|
|
1331
1360
|
}, props)), {}, {
|
|
1332
1361
|
isEdit: true
|
|
@@ -1343,6 +1372,359 @@ var Edit = function Edit(_ref) {
|
|
|
1343
1372
|
});
|
|
1344
1373
|
};
|
|
1345
1374
|
|
|
1375
|
+
var VARIANTS = {
|
|
1376
|
+
hidden: {
|
|
1377
|
+
opacity: 0,
|
|
1378
|
+
height: 0,
|
|
1379
|
+
overflow: "hidden"
|
|
1380
|
+
},
|
|
1381
|
+
visible: {
|
|
1382
|
+
opacity: 1,
|
|
1383
|
+
height: "auto"
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
|
|
1387
|
+
var _excluded$6 = ["open", "className", "children"];
|
|
1388
|
+
function ownKeys$a(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; }
|
|
1389
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1390
|
+
var Collapsible = function Collapsible(_ref) {
|
|
1391
|
+
var open = _ref.open,
|
|
1392
|
+
_ref$className = _ref.className,
|
|
1393
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1394
|
+
children = _ref.children,
|
|
1395
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
1396
|
+
return /*#__PURE__*/jsx(AnimatePresence, {
|
|
1397
|
+
children: open && /*#__PURE__*/jsx(motion.div, _objectSpread$a(_objectSpread$a({
|
|
1398
|
+
animate: "visible",
|
|
1399
|
+
exit: "hidden",
|
|
1400
|
+
initial: "hidden",
|
|
1401
|
+
transition: {
|
|
1402
|
+
duration: 0.3
|
|
1403
|
+
},
|
|
1404
|
+
variants: VARIANTS
|
|
1405
|
+
}, otherProps), {}, {
|
|
1406
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1407
|
+
className: className,
|
|
1408
|
+
children: children
|
|
1409
|
+
})
|
|
1410
|
+
}))
|
|
1411
|
+
});
|
|
1412
|
+
};
|
|
1413
|
+
|
|
1414
|
+
var ADDRESS_FIELD_WIDTH_OPTIONS = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ADDRESS_FIELD_WIDTHS.FULL, {
|
|
1415
|
+
label: t("neetoForm.questions.address.widths.full"),
|
|
1416
|
+
value: ADDRESS_FIELD_WIDTHS.FULL
|
|
1417
|
+
}), ADDRESS_FIELD_WIDTHS.HALF, {
|
|
1418
|
+
label: t("neetoForm.questions.address.widths.half"),
|
|
1419
|
+
value: ADDRESS_FIELD_WIDTHS.HALF
|
|
1420
|
+
}), ADDRESS_FIELD_WIDTHS.ONE_FOURTH, {
|
|
1421
|
+
label: t("neetoForm.questions.address.widths.oneFourth"),
|
|
1422
|
+
value: ADDRESS_FIELD_WIDTHS.ONE_FOURTH
|
|
1423
|
+
}), ADDRESS_FIELD_WIDTHS.THREE_FOURTH, {
|
|
1424
|
+
label: t("neetoForm.questions.address.widths.threeFourth"),
|
|
1425
|
+
value: ADDRESS_FIELD_WIDTHS.THREE_FOURTH
|
|
1426
|
+
});
|
|
1427
|
+
var ADDRESS_FIELD_TYPE_OPTIONS = _defineProperty(_defineProperty({}, ADDRESS_FIELD_TYPES.INPUT, {
|
|
1428
|
+
label: t("neetoForm.questions.address.types.textInput"),
|
|
1429
|
+
value: ADDRESS_FIELD_TYPES.INPUT
|
|
1430
|
+
}), ADDRESS_FIELD_TYPES.SELECT, {
|
|
1431
|
+
label: t("neetoForm.questions.address.types.dropdown"),
|
|
1432
|
+
value: ADDRESS_FIELD_TYPES.SELECT
|
|
1433
|
+
});
|
|
1434
|
+
var ADDRESS_FIELD_FORM_VALIDATION_SCHEMA = yup.object().shape({
|
|
1435
|
+
label: yup.string().trim().required(t("neetoForm.error.requiredField", {
|
|
1436
|
+
label: t("neetoForm.questions.common.questionFields.field.label")
|
|
1437
|
+
})),
|
|
1438
|
+
width: yup.object().nullable().required(t("neetoForm.error.requiredField", {
|
|
1439
|
+
label: t("neetoForm.questions.address.width")
|
|
1440
|
+
})),
|
|
1441
|
+
fieldType: yup.object().nullable().required(t("neetoForm.error.requiredField", {
|
|
1442
|
+
label: t("neetoForm.questions.address.type")
|
|
1443
|
+
})),
|
|
1444
|
+
properties: yup.object().shape({
|
|
1445
|
+
options: yup.array().of(yup.object().shape({
|
|
1446
|
+
label: yup.string().required(t("neetoForm.error.requiredField", {
|
|
1447
|
+
label: t("neetoForm.common.option")
|
|
1448
|
+
}))
|
|
1449
|
+
})).unique("label", t("neetoForm.error.removeDuplicates"))
|
|
1450
|
+
})
|
|
1451
|
+
});
|
|
1452
|
+
var ERROR_MESSAGE_DELIMITER$1 = ". ";
|
|
1453
|
+
|
|
1454
|
+
function ownKeys$9(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; }
|
|
1455
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1456
|
+
var removeDuplicateErrorMessages$1 = pipe(filter(isNotNil), map(values), uniq, join(ERROR_MESSAGE_DELIMITER$1));
|
|
1457
|
+
var getAddressModalInitialValues = function getAddressModalInitialValues(field) {
|
|
1458
|
+
return field ? _objectSpread$9(_objectSpread$9({}, field), {}, {
|
|
1459
|
+
width: ADDRESS_FIELD_WIDTH_OPTIONS[field.width],
|
|
1460
|
+
fieldType: ADDRESS_FIELD_TYPE_OPTIONS[field.fieldType]
|
|
1461
|
+
}) : {
|
|
1462
|
+
label: "",
|
|
1463
|
+
isRequired: false,
|
|
1464
|
+
width: ADDRESS_FIELD_WIDTH_OPTIONS[ADDRESS_FIELD_WIDTHS.FULL],
|
|
1465
|
+
fieldType: ADDRESS_FIELD_TYPE_OPTIONS[ADDRESS_FIELD_TYPES.INPUT]
|
|
1466
|
+
};
|
|
1467
|
+
};
|
|
1468
|
+
var sanitizeAddressField = function sanitizeAddressField(field, isSelectField, defaultOptions) {
|
|
1469
|
+
var hasOptions = pathSatisfies(isPresent, ["properties", "options"], field);
|
|
1470
|
+
if (isSelectField && !hasOptions) {
|
|
1471
|
+
return assocPath(["properties", "options"], defaultOptions, field);
|
|
1472
|
+
}
|
|
1473
|
+
if (!isSelectField && hasOptions) {
|
|
1474
|
+
return dissoc("properties", field);
|
|
1475
|
+
}
|
|
1476
|
+
return field;
|
|
1477
|
+
};
|
|
1478
|
+
var formatErrorMessage$1 = function formatErrorMessage(error) {
|
|
1479
|
+
if (typeof error === "string") return error;
|
|
1480
|
+
return removeDuplicateErrorMessages$1(error);
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
var _excluded$5 = ["width", "fieldType"];
|
|
1484
|
+
function ownKeys$8(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; }
|
|
1485
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1486
|
+
var ManagePane = function ManagePane(_ref) {
|
|
1487
|
+
var isOpen = _ref.isOpen,
|
|
1488
|
+
selectedFieldId = _ref.selectedFieldId,
|
|
1489
|
+
onClose = _ref.onClose,
|
|
1490
|
+
title = _ref.title,
|
|
1491
|
+
fields = _ref.fields,
|
|
1492
|
+
initialFocusRef = _ref.initialFocusRef;
|
|
1493
|
+
var _useField = useField("fields"),
|
|
1494
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
1495
|
+
allFields = _useField2[0].value,
|
|
1496
|
+
setValue = _useField2[2].setValue;
|
|
1497
|
+
var _useTranslation = useTranslation(),
|
|
1498
|
+
t = _useTranslation.t;
|
|
1499
|
+
var defaultOptions = generateDefaultOptions(MINIMUM_ADDRESS_FIELDS);
|
|
1500
|
+
var editingField = findById(selectedFieldId, fields);
|
|
1501
|
+
var initialValues = getAddressModalInitialValues(editingField);
|
|
1502
|
+
var handleSubmit = function handleSubmit(_ref2) {
|
|
1503
|
+
var width = _ref2.width,
|
|
1504
|
+
fieldType = _ref2.fieldType,
|
|
1505
|
+
field = _objectWithoutProperties(_ref2, _excluded$5);
|
|
1506
|
+
var deletedFields = getDeletedRecords(allFields);
|
|
1507
|
+
var isSelectField = fieldType.value === ADDRESS_FIELD_TYPES.SELECT;
|
|
1508
|
+
var sanitizedField = sanitizeAddressField(field, isSelectField, defaultOptions);
|
|
1509
|
+
if (isNil(selectedFieldId)) {
|
|
1510
|
+
var position = fields.length;
|
|
1511
|
+
var id = "draft-".concat(randomId());
|
|
1512
|
+
var newField = _objectSpread$8(_objectSpread$8({
|
|
1513
|
+
id: id
|
|
1514
|
+
}, sanitizedField), {}, {
|
|
1515
|
+
altId: "alt-".concat(randomId()),
|
|
1516
|
+
position: position,
|
|
1517
|
+
width: width.value,
|
|
1518
|
+
fieldType: fieldType.value
|
|
1519
|
+
});
|
|
1520
|
+
var nextFields = append(newField, fields);
|
|
1521
|
+
setValue([].concat(_toConsumableArray(nextFields), _toConsumableArray(deletedFields)));
|
|
1522
|
+
} else {
|
|
1523
|
+
var selectedFieldIndex = findIndexById(selectedFieldId, fields);
|
|
1524
|
+
setValue(assoc(selectedFieldIndex, _objectSpread$8(_objectSpread$8({}, sanitizedField), {}, {
|
|
1525
|
+
width: width.value,
|
|
1526
|
+
fieldType: fieldType.value
|
|
1527
|
+
}), [].concat(_toConsumableArray(fields), _toConsumableArray(deletedFields))));
|
|
1528
|
+
}
|
|
1529
|
+
onClose();
|
|
1530
|
+
};
|
|
1531
|
+
var handleFieldTypeChange = function handleFieldTypeChange(setFieldValue, values) {
|
|
1532
|
+
return function (fieldType) {
|
|
1533
|
+
var _values$properties;
|
|
1534
|
+
setFieldValue("fieldType", fieldType);
|
|
1535
|
+
if (fieldType.value === ADDRESS_FIELD_TYPES.SELECT && isNotPresent((_values$properties = values.properties) === null || _values$properties === void 0 ? void 0 : _values$properties.options)) {
|
|
1536
|
+
setFieldValue("properties.options", defaultOptions);
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
};
|
|
1540
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
1541
|
+
initialFocusRef: initialFocusRef,
|
|
1542
|
+
isOpen: isOpen,
|
|
1543
|
+
onClose: onClose,
|
|
1544
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
1545
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1546
|
+
"data-testid": "add-address-field-title",
|
|
1547
|
+
style: "h2",
|
|
1548
|
+
weight: "semibold",
|
|
1549
|
+
children: title
|
|
1550
|
+
})
|
|
1551
|
+
}), /*#__PURE__*/jsx(Form$2, {
|
|
1552
|
+
formikProps: {
|
|
1553
|
+
initialValues: initialValues,
|
|
1554
|
+
validationSchema: ADDRESS_FIELD_FORM_VALIDATION_SCHEMA,
|
|
1555
|
+
onSubmit: handleSubmit
|
|
1556
|
+
},
|
|
1557
|
+
children: function children(_ref3) {
|
|
1558
|
+
var _values$fieldType;
|
|
1559
|
+
var values = _ref3.values,
|
|
1560
|
+
setFieldValue = _ref3.setFieldValue;
|
|
1561
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1562
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
1563
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
1564
|
+
className: "w-full space-y-6",
|
|
1565
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
1566
|
+
name: "label",
|
|
1567
|
+
ref: initialFocusRef,
|
|
1568
|
+
label: t("neetoForm.questions.common.questionFields.field.label"),
|
|
1569
|
+
placeholder: t("neetoForm.questions.address.fieldLabelPlaceholder")
|
|
1570
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1571
|
+
className: "grid grid-cols-2 gap-6",
|
|
1572
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
1573
|
+
label: t("neetoForm.questions.address.width"),
|
|
1574
|
+
name: "width",
|
|
1575
|
+
options: Object.values(ADDRESS_FIELD_WIDTH_OPTIONS)
|
|
1576
|
+
}), /*#__PURE__*/jsx(Select, {
|
|
1577
|
+
label: t("neetoForm.questions.address.type"),
|
|
1578
|
+
name: "fieldType",
|
|
1579
|
+
options: Object.values(ADDRESS_FIELD_TYPE_OPTIONS),
|
|
1580
|
+
onChange: handleFieldTypeChange(setFieldValue, values)
|
|
1581
|
+
})]
|
|
1582
|
+
}), /*#__PURE__*/jsx(Collapsible, {
|
|
1583
|
+
open: (values === null || values === void 0 || (_values$fieldType = values.fieldType) === null || _values$fieldType === void 0 ? void 0 : _values$fieldType.value) === ADDRESS_FIELD_TYPES.SELECT,
|
|
1584
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1585
|
+
className: "flex flex-col",
|
|
1586
|
+
children: /*#__PURE__*/jsx(OptionFields, {
|
|
1587
|
+
draggable: true,
|
|
1588
|
+
minOptions: MINIMUM_ADDRESS_FIELDS,
|
|
1589
|
+
name: "properties.options"
|
|
1590
|
+
})
|
|
1591
|
+
})
|
|
1592
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1593
|
+
className: "flex items-center gap-4",
|
|
1594
|
+
children: /*#__PURE__*/jsx(Switch, {
|
|
1595
|
+
label: t("neetoForm.common.required"),
|
|
1596
|
+
name: "isRequired"
|
|
1597
|
+
})
|
|
1598
|
+
})]
|
|
1599
|
+
})
|
|
1600
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
1601
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1602
|
+
className: "flex items-center gap-2",
|
|
1603
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
1604
|
+
className: "flex gap-x-2",
|
|
1605
|
+
cancelButtonProps: {
|
|
1606
|
+
type: "reset",
|
|
1607
|
+
onClick: onClose,
|
|
1608
|
+
disabled: false
|
|
1609
|
+
},
|
|
1610
|
+
submitButtonProps: {
|
|
1611
|
+
label: t("neetoForm.common.saveChanges")
|
|
1612
|
+
}
|
|
1613
|
+
})
|
|
1614
|
+
})
|
|
1615
|
+
})]
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
})]
|
|
1619
|
+
});
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
var Address = function Address() {
|
|
1623
|
+
var _findById;
|
|
1624
|
+
var _useState = useState(false),
|
|
1625
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1626
|
+
isAddressFieldPaneOpen = _useState2[0],
|
|
1627
|
+
setIsAddressFieldPaneOpen = _useState2[1];
|
|
1628
|
+
var _useState3 = useState(false),
|
|
1629
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1630
|
+
isDeleteAddressFieldAlertOpen = _useState4[0],
|
|
1631
|
+
setIsDeleteAddressFieldAlertOpen = _useState4[1];
|
|
1632
|
+
var _useState5 = useState(null),
|
|
1633
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1634
|
+
selectedFieldId = _useState6[0],
|
|
1635
|
+
setSelectedFieldId = _useState6[1];
|
|
1636
|
+
var initialFocusRef = useRef(null);
|
|
1637
|
+
var _useTranslation = useTranslation(),
|
|
1638
|
+
t = _useTranslation.t;
|
|
1639
|
+
var _useBuildFormStore = useBuildFormStore(function (store) {
|
|
1640
|
+
var _store$formState;
|
|
1641
|
+
return {
|
|
1642
|
+
selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"]
|
|
1643
|
+
};
|
|
1644
|
+
}, shallow),
|
|
1645
|
+
selectedLanguage = _useBuildFormStore.selectedLanguage;
|
|
1646
|
+
var name = "fields";
|
|
1647
|
+
var _useField = useField(name),
|
|
1648
|
+
_useField2 = _slicedToArray(_useField, 3),
|
|
1649
|
+
fields = _useField2[0].value,
|
|
1650
|
+
_useField2$ = _useField2[1],
|
|
1651
|
+
error = _useField2$.error,
|
|
1652
|
+
touched = _useField2$.touched,
|
|
1653
|
+
setFields = _useField2[2].setValue;
|
|
1654
|
+
var handleDelete = function handleDelete() {
|
|
1655
|
+
var deletedFields = getDeletedRecords(fields);
|
|
1656
|
+
var nextFields = getActiveRecords(fields);
|
|
1657
|
+
var selectedFieldIndex = findIndexById(selectedFieldId, nextFields);
|
|
1658
|
+
nextFields = assocPath([selectedFieldIndex, "deleted"], true, nextFields);
|
|
1659
|
+
setFields([].concat(_toConsumableArray(nextFields), _toConsumableArray(deletedFields)));
|
|
1660
|
+
};
|
|
1661
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1662
|
+
children: [/*#__PURE__*/jsx(Block, {
|
|
1663
|
+
dataTestid: "address-fields-block",
|
|
1664
|
+
title: t("neetoForm.questions.address.fields"),
|
|
1665
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
1666
|
+
children: [/*#__PURE__*/jsx(OptionFields, {
|
|
1667
|
+
name: name,
|
|
1668
|
+
draggable: true,
|
|
1669
|
+
shouldDestroy: true,
|
|
1670
|
+
editable: false,
|
|
1671
|
+
isNewItemsPrefilled: isDefaultLanguage(selectedLanguage),
|
|
1672
|
+
itemLabel: t("neetoForm.common.field"),
|
|
1673
|
+
minOptions: MINIMUM_ADDRESS_FIELDS,
|
|
1674
|
+
shouldResetEmptyOptionOnBlur: false,
|
|
1675
|
+
buttonProps: {
|
|
1676
|
+
label: t("neetoForm.questions.address.addField"),
|
|
1677
|
+
onClick: function onClick() {
|
|
1678
|
+
return setIsAddressFieldPaneOpen(true);
|
|
1679
|
+
}
|
|
1680
|
+
},
|
|
1681
|
+
onDelete: function onDelete(id) {
|
|
1682
|
+
setSelectedFieldId(id);
|
|
1683
|
+
setIsDeleteAddressFieldAlertOpen(true);
|
|
1684
|
+
},
|
|
1685
|
+
onEdit: function onEdit(id) {
|
|
1686
|
+
setSelectedFieldId(id);
|
|
1687
|
+
setIsAddressFieldPaneOpen(true);
|
|
1688
|
+
}
|
|
1689
|
+
}), touched && error && /*#__PURE__*/jsx("p", {
|
|
1690
|
+
className: "neeto-form-engine-input__error",
|
|
1691
|
+
"data-testid": "neeto-form-engine-address-fields-error",
|
|
1692
|
+
children: formatErrorMessage$1(error)
|
|
1693
|
+
})]
|
|
1694
|
+
})
|
|
1695
|
+
}), /*#__PURE__*/jsx(ManagePane, {
|
|
1696
|
+
initialFocusRef: initialFocusRef,
|
|
1697
|
+
selectedFieldId: selectedFieldId,
|
|
1698
|
+
fields: getActiveRecords(fields),
|
|
1699
|
+
isOpen: isAddressFieldPaneOpen,
|
|
1700
|
+
title: isNotNil(selectedFieldId) ? t("neetoForm.questions.address.editField") : t("neetoForm.questions.address.addField"),
|
|
1701
|
+
onClose: function onClose() {
|
|
1702
|
+
setIsAddressFieldPaneOpen(false);
|
|
1703
|
+
setSelectedFieldId(null);
|
|
1704
|
+
}
|
|
1705
|
+
}), /*#__PURE__*/jsx(Alert, {
|
|
1706
|
+
isOpen: isDeleteAddressFieldAlertOpen,
|
|
1707
|
+
submitButtonLabel: t("neetoForm.common.delete"),
|
|
1708
|
+
title: t("neetoForm.questions.address.deleteAlert.title"),
|
|
1709
|
+
message: /*#__PURE__*/jsx(Trans, {
|
|
1710
|
+
i18nKey: "neetoForm.questions.address.deleteAlert.message",
|
|
1711
|
+
values: {
|
|
1712
|
+
label: (_findById = findById(selectedFieldId, fields)) === null || _findById === void 0 ? void 0 : _findById.label
|
|
1713
|
+
}
|
|
1714
|
+
}),
|
|
1715
|
+
onClose: function onClose() {
|
|
1716
|
+
setIsDeleteAddressFieldAlertOpen(false);
|
|
1717
|
+
setSelectedFieldId(null);
|
|
1718
|
+
},
|
|
1719
|
+
onSubmit: function onSubmit() {
|
|
1720
|
+
setIsDeleteAddressFieldAlertOpen(false);
|
|
1721
|
+
handleDelete();
|
|
1722
|
+
setSelectedFieldId(null);
|
|
1723
|
+
}
|
|
1724
|
+
})]
|
|
1725
|
+
});
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1346
1728
|
var Captcha = withT(function (_ref) {
|
|
1347
1729
|
var t = _ref.t;
|
|
1348
1730
|
return /*#__PURE__*/jsxs(Radio, {
|
|
@@ -1361,19 +1743,19 @@ var Captcha = withT(function (_ref) {
|
|
|
1361
1743
|
});
|
|
1362
1744
|
});
|
|
1363
1745
|
|
|
1364
|
-
var _excluded$
|
|
1365
|
-
function ownKeys$
|
|
1366
|
-
function _objectSpread$
|
|
1746
|
+
var _excluded$4 = ["name", "title", "className"];
|
|
1747
|
+
function ownKeys$7(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; }
|
|
1748
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1367
1749
|
var SwitchBlock = function SwitchBlock(_ref) {
|
|
1368
1750
|
var name = _ref.name,
|
|
1369
1751
|
title = _ref.title,
|
|
1370
1752
|
_ref$className = _ref.className,
|
|
1371
1753
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1372
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
1754
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$4);
|
|
1373
1755
|
return /*#__PURE__*/jsxs(Label, {
|
|
1374
1756
|
className: classnames("flex items-center justify-start gap-2 ", className),
|
|
1375
1757
|
"data-testid": "neeto-form-engine-".concat(hyphenate(title && name), "-toggle-label"),
|
|
1376
|
-
children: [/*#__PURE__*/jsx(Switch, _objectSpread$
|
|
1758
|
+
children: [/*#__PURE__*/jsx(Switch, _objectSpread$7(_objectSpread$7({}, _objectSpread$7(_objectSpread$7({}, otherProps), {}, {
|
|
1377
1759
|
name: name
|
|
1378
1760
|
})), {}, {
|
|
1379
1761
|
"data-testid": "neeto-form-engine-".concat(hyphenate(title && name), "-switch")
|
|
@@ -1402,9 +1784,9 @@ var EMAIL_VERIFICATION_TRANSLATIONS = {
|
|
|
1402
1784
|
popoverDescription: t("neetoForm.emailVerification.popoverDescription")
|
|
1403
1785
|
};
|
|
1404
1786
|
|
|
1405
|
-
var _excluded$
|
|
1406
|
-
function ownKeys$
|
|
1407
|
-
function _objectSpread$
|
|
1787
|
+
var _excluded$3 = ["children"];
|
|
1788
|
+
function ownKeys$6(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; }
|
|
1789
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1408
1790
|
var STYLES = {
|
|
1409
1791
|
border: {
|
|
1410
1792
|
"default": "1px solid rgb(var(--neeto-ui-gray-400))",
|
|
@@ -1416,8 +1798,8 @@ var STYLES = {
|
|
|
1416
1798
|
}
|
|
1417
1799
|
};
|
|
1418
1800
|
var MultiValueRemove = function MultiValueRemove(props) {
|
|
1419
|
-
return /*#__PURE__*/jsx(components.MultiValueRemove, _objectSpread$
|
|
1420
|
-
innerProps: _objectSpread$
|
|
1801
|
+
return /*#__PURE__*/jsx(components.MultiValueRemove, _objectSpread$6(_objectSpread$6({}, props), {}, {
|
|
1802
|
+
innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "".concat(hyphenize(props.data.label), "-remove-icon"))),
|
|
1421
1803
|
children: /*#__PURE__*/jsx(Close, {
|
|
1422
1804
|
size: 16
|
|
1423
1805
|
})
|
|
@@ -1425,7 +1807,7 @@ var MultiValueRemove = function MultiValueRemove(props) {
|
|
|
1425
1807
|
};
|
|
1426
1808
|
var ValueContainer = function ValueContainer(_ref) {
|
|
1427
1809
|
var children = _ref.children,
|
|
1428
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1810
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
1429
1811
|
var _useTranslation = useTranslation(),
|
|
1430
1812
|
t = _useTranslation.t;
|
|
1431
1813
|
var getValue = props.getValue,
|
|
@@ -1437,8 +1819,8 @@ var ValueContainer = function ValueContainer(_ref) {
|
|
|
1437
1819
|
firstChild = _children[0],
|
|
1438
1820
|
rest = _children.slice(1);
|
|
1439
1821
|
var shouldCollapse = !isFocused && value.length > visibleDomainsCount;
|
|
1440
|
-
return /*#__PURE__*/jsxs(components.ValueContainer, _objectSpread$
|
|
1441
|
-
innerProps: _objectSpread$
|
|
1822
|
+
return /*#__PURE__*/jsxs(components.ValueContainer, _objectSpread$6(_objectSpread$6({}, props), {}, {
|
|
1823
|
+
innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "multi-domain-input-container")),
|
|
1442
1824
|
children: [shouldCollapse ? firstChild.slice(0, visibleDomainsCount) : firstChild, shouldCollapse && /*#__PURE__*/jsx(Tag, {
|
|
1443
1825
|
style: "secondary",
|
|
1444
1826
|
label: t("neetoForm.common.remainingItemsCount", {
|
|
@@ -1448,8 +1830,8 @@ var ValueContainer = function ValueContainer(_ref) {
|
|
|
1448
1830
|
}));
|
|
1449
1831
|
};
|
|
1450
1832
|
var ClearIndicator = function ClearIndicator(props) {
|
|
1451
|
-
return /*#__PURE__*/jsx(components.ClearIndicator, _objectSpread$
|
|
1452
|
-
innerProps: _objectSpread$
|
|
1833
|
+
return /*#__PURE__*/jsx(components.ClearIndicator, _objectSpread$6(_objectSpread$6({}, props), {}, {
|
|
1834
|
+
innerProps: _objectSpread$6(_objectSpread$6({}, props.innerProps), {}, _defineProperty({}, "data-testid", "clear-all-button")),
|
|
1453
1835
|
children: /*#__PURE__*/jsx(Close, {
|
|
1454
1836
|
className: "cursor-pointer",
|
|
1455
1837
|
size: 16
|
|
@@ -1470,7 +1852,7 @@ var CUSTOM_STYLES = {
|
|
|
1470
1852
|
input: assoc("overflow", "hidden"),
|
|
1471
1853
|
multiValue: function multiValue(styles, _ref2) {
|
|
1472
1854
|
var valid = _ref2.data.valid;
|
|
1473
|
-
return _objectSpread$
|
|
1855
|
+
return _objectSpread$6(_objectSpread$6({}, styles), {}, {
|
|
1474
1856
|
border: valid ? STYLES.border["default"] : STYLES.border.error,
|
|
1475
1857
|
color: valid ? STYLES.color["default"] : STYLES.color.error
|
|
1476
1858
|
});
|
|
@@ -1512,9 +1894,9 @@ var formatErrorMessage = function formatErrorMessage(error) {
|
|
|
1512
1894
|
return removeDuplicateErrorMessages(error);
|
|
1513
1895
|
};
|
|
1514
1896
|
|
|
1515
|
-
var _excluded$
|
|
1516
|
-
function ownKeys$
|
|
1517
|
-
function _objectSpread$
|
|
1897
|
+
var _excluded$2 = ["label", "value", "onChange", "error", "onBlur"];
|
|
1898
|
+
function ownKeys$5(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; }
|
|
1899
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1518
1900
|
var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
1519
1901
|
var _ref$label = _ref.label,
|
|
1520
1902
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
@@ -1526,7 +1908,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1526
1908
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
1527
1909
|
_ref$onBlur = _ref.onBlur,
|
|
1528
1910
|
onBlur = _ref$onBlur === void 0 ? noop : _ref$onBlur,
|
|
1529
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
1911
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
1530
1912
|
var _useState = useState(""),
|
|
1531
1913
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1532
1914
|
inputValue = _useState2[0],
|
|
@@ -1573,7 +1955,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1573
1955
|
"data-testid": "".concat(hyphenize(label), "-input-label"),
|
|
1574
1956
|
children: label
|
|
1575
1957
|
})
|
|
1576
|
-
}), /*#__PURE__*/jsx(CreatableSelect, _objectSpread$
|
|
1958
|
+
}), /*#__PURE__*/jsx(CreatableSelect, _objectSpread$5({
|
|
1577
1959
|
isMulti: true,
|
|
1578
1960
|
required: true,
|
|
1579
1961
|
classNamePrefix: "neeto-ui-react-select",
|
|
@@ -1583,7 +1965,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1583
1965
|
className: classnames("neeto-ui-react-select__container neeto-ui-react-select__container--medium neeto-ui-email-input__select", {
|
|
1584
1966
|
"neeto-ui-react-select__container--error": !!error
|
|
1585
1967
|
}),
|
|
1586
|
-
styles: _objectSpread$
|
|
1968
|
+
styles: _objectSpread$5(_objectSpread$5({}, CUSTOM_STYLES), {}, {
|
|
1587
1969
|
control: mergeLeft({
|
|
1588
1970
|
maxHeight: "200px",
|
|
1589
1971
|
overflowY: "auto"
|
|
@@ -1595,7 +1977,7 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1595
1977
|
},
|
|
1596
1978
|
onInputChange: setInputValue,
|
|
1597
1979
|
onKeyDown: handleKeyDown
|
|
1598
|
-
}, _objectSpread$
|
|
1980
|
+
}, _objectSpread$5({
|
|
1599
1981
|
inputValue: inputValue,
|
|
1600
1982
|
isFocused: isFocused,
|
|
1601
1983
|
onChange: onChange,
|
|
@@ -1617,8 +1999,8 @@ var MultiDomainInput = function MultiDomainInput(_ref) {
|
|
|
1617
1999
|
});
|
|
1618
2000
|
};
|
|
1619
2001
|
|
|
1620
|
-
function ownKeys$
|
|
1621
|
-
function _objectSpread$
|
|
2002
|
+
function ownKeys$4(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; }
|
|
2003
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1622
2004
|
var validateDomains = function validateDomains(value) {
|
|
1623
2005
|
var schema = yup.array().of(yup.string().test("verify domains", t("neetoForm.error.invalidDomain"), function (domain) {
|
|
1624
2006
|
return VALID_DOMAIN_REGEX.test(domain);
|
|
@@ -1658,7 +2040,7 @@ var buildHelpPopoverLabelProps = function buildHelpPopoverLabelProps(popoverDesc
|
|
|
1658
2040
|
return {
|
|
1659
2041
|
helpIconProps: {
|
|
1660
2042
|
"data-testid": "help-popover-button",
|
|
1661
|
-
popoverProps: _objectSpread$
|
|
2043
|
+
popoverProps: _objectSpread$4({
|
|
1662
2044
|
description: popoverDescription
|
|
1663
2045
|
}, helpLink && {
|
|
1664
2046
|
helpLinkProps: {
|
|
@@ -1857,8 +2239,60 @@ var FileUpload = function FileUpload() {
|
|
|
1857
2239
|
});
|
|
1858
2240
|
};
|
|
1859
2241
|
|
|
1860
|
-
|
|
1861
|
-
|
|
2242
|
+
var OpinionScale = function OpinionScale() {
|
|
2243
|
+
var _useTranslation = useTranslation(),
|
|
2244
|
+
t = _useTranslation.t;
|
|
2245
|
+
var _useFormikContext = useFormikContext(),
|
|
2246
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
2247
|
+
_useFormikContext$val = _useFormikContext.values.hasOpinionLabels,
|
|
2248
|
+
hasOpinionLabels = _useFormikContext$val === void 0 ? false : _useFormikContext$val;
|
|
2249
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
2250
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
2251
|
+
className: "flex space-x-4",
|
|
2252
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
2253
|
+
className: "w-1/2",
|
|
2254
|
+
"data-testid": "neeto-form-engine-opinion-scale-min-value",
|
|
2255
|
+
label: t("neetoForm.common.start"),
|
|
2256
|
+
name: "minValue",
|
|
2257
|
+
options: OPINION_SCALE_MIN_VALUE_OPTIONS,
|
|
2258
|
+
onChange: function onChange(option) {
|
|
2259
|
+
return setFieldValue("minValue", option === null || option === void 0 ? void 0 : option.value);
|
|
2260
|
+
}
|
|
2261
|
+
}), /*#__PURE__*/jsx(Select, {
|
|
2262
|
+
className: "w-1/2",
|
|
2263
|
+
"data-testid": "neeto-form-engine-opinion-scale-max-value",
|
|
2264
|
+
label: t("neetoForm.common.end"),
|
|
2265
|
+
name: "maxValue",
|
|
2266
|
+
options: OPINION_SCALE_MAX_VALUE_OPTIONS,
|
|
2267
|
+
onChange: function onChange(option) {
|
|
2268
|
+
return setFieldValue("maxValue", option === null || option === void 0 ? void 0 : option.value);
|
|
2269
|
+
}
|
|
2270
|
+
})]
|
|
2271
|
+
}), /*#__PURE__*/jsx(Switch, {
|
|
2272
|
+
"data-testid": "neeto-form-engine-opinion-scale-show-labels-switch",
|
|
2273
|
+
label: t("neetoForm.questions.opinionScale.showLabels"),
|
|
2274
|
+
name: "hasOpinionLabels"
|
|
2275
|
+
}), hasOpinionLabels && /*#__PURE__*/jsxs("div", {
|
|
2276
|
+
className: "flex space-x-4",
|
|
2277
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
2278
|
+
className: "w-1/2",
|
|
2279
|
+
"data-testid": "neeto-form-engine-opinion-scale-left-label",
|
|
2280
|
+
label: t("neetoForm.questions.opinionScale.leftLabel"),
|
|
2281
|
+
maxLength: OPINION_LABEL_MAX_LENGTH,
|
|
2282
|
+
name: "leftOpinionLabel"
|
|
2283
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
2284
|
+
className: "w-1/2",
|
|
2285
|
+
"data-testid": "neeto-form-engine-opinion-scale-right-label",
|
|
2286
|
+
label: t("neetoForm.questions.opinionScale.rightLabel"),
|
|
2287
|
+
maxLength: OPINION_LABEL_MAX_LENGTH,
|
|
2288
|
+
name: "rightOpinionLabel"
|
|
2289
|
+
})]
|
|
2290
|
+
})]
|
|
2291
|
+
});
|
|
2292
|
+
};
|
|
2293
|
+
|
|
2294
|
+
function ownKeys$3(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; }
|
|
2295
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1862
2296
|
var Options = function Options(_ref) {
|
|
1863
2297
|
var questionProps = _ref.questionProps;
|
|
1864
2298
|
var _useTranslation = useTranslation(),
|
|
@@ -1903,7 +2337,7 @@ var Options = function Options(_ref) {
|
|
|
1903
2337
|
return /*#__PURE__*/jsxs("div", {
|
|
1904
2338
|
className: "w-full space-y-4",
|
|
1905
2339
|
children: [/*#__PURE__*/jsxs("div", {
|
|
1906
|
-
children: [/*#__PURE__*/jsx(Label, _objectSpread$
|
|
2340
|
+
children: [/*#__PURE__*/jsx(Label, _objectSpread$3(_objectSpread$3({
|
|
1907
2341
|
className: "mb-2 block"
|
|
1908
2342
|
}, optionLabelProps), {}, {
|
|
1909
2343
|
children: t("neetoForm.questions.common.questionFields.field.options")
|
|
@@ -2059,19 +2493,27 @@ var StarRating = function StarRating() {
|
|
|
2059
2493
|
});
|
|
2060
2494
|
};
|
|
2061
2495
|
|
|
2496
|
+
var _excluded$1 = ["fields"];
|
|
2497
|
+
function ownKeys$2(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; }
|
|
2498
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2062
2499
|
var CHECKBOX = QUESTION_TYPES.CHECKBOX,
|
|
2063
2500
|
RADIO = QUESTION_TYPES.RADIO,
|
|
2064
2501
|
DROPDOWN = QUESTION_TYPES.DROPDOWN,
|
|
2065
2502
|
STAR_RATING = QUESTION_TYPES.STAR_RATING,
|
|
2503
|
+
OPINION_SCALE = QUESTION_TYPES.OPINION_SCALE,
|
|
2066
2504
|
RATING = QUESTION_TYPES.RATING,
|
|
2067
2505
|
FILE_UPLOAD = QUESTION_TYPES.FILE_UPLOAD,
|
|
2068
2506
|
CAPTCHA = QUESTION_TYPES.CAPTCHA,
|
|
2069
|
-
EMAIL = QUESTION_TYPES.EMAIL
|
|
2507
|
+
EMAIL = QUESTION_TYPES.EMAIL,
|
|
2508
|
+
ADDRESS = QUESTION_TYPES.ADDRESS;
|
|
2070
2509
|
var transformValueForOption = function transformValueForOption(_ref) {
|
|
2071
2510
|
var label = _ref.label,
|
|
2072
2511
|
type = _ref.type;
|
|
2073
2512
|
return "".concat(slugify(label), "-").concat(type);
|
|
2074
2513
|
};
|
|
2514
|
+
var omitDraftId = modifyBy({
|
|
2515
|
+
id: startsWith(DRAFT_ID_PREFIX)
|
|
2516
|
+
}, omit(["id"]));
|
|
2075
2517
|
var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
2076
2518
|
var kind = _ref2.kind,
|
|
2077
2519
|
questionProps = _ref2.questionProps,
|
|
@@ -2087,10 +2529,14 @@ var renderAdditionalData = function renderAdditionalData(_ref2) {
|
|
|
2087
2529
|
return /*#__PURE__*/jsx(Rating, {});
|
|
2088
2530
|
case STAR_RATING:
|
|
2089
2531
|
return /*#__PURE__*/jsx(StarRating, {});
|
|
2532
|
+
case OPINION_SCALE:
|
|
2533
|
+
return /*#__PURE__*/jsx(OpinionScale, {});
|
|
2090
2534
|
case FILE_UPLOAD:
|
|
2091
2535
|
return /*#__PURE__*/jsx(FileUpload, {});
|
|
2092
2536
|
case CAPTCHA:
|
|
2093
2537
|
return /*#__PURE__*/jsx(Captcha, {});
|
|
2538
|
+
case ADDRESS:
|
|
2539
|
+
return /*#__PURE__*/jsx(Address, {});
|
|
2094
2540
|
case EMAIL:
|
|
2095
2541
|
return !usesCustomSubmissionComponent && /*#__PURE__*/jsx(Email, {
|
|
2096
2542
|
usesCustomSubmissionComponent: usesCustomSubmissionComponent
|
|
@@ -2167,6 +2613,21 @@ var readOnlySwitchLabelProps = function readOnlySwitchLabelProps(helpUrl) {
|
|
|
2167
2613
|
}
|
|
2168
2614
|
};
|
|
2169
2615
|
};
|
|
2616
|
+
var transformValues = function transformValues(values) {
|
|
2617
|
+
switch (values.kind) {
|
|
2618
|
+
case QUESTION_TYPES.ADDRESS:
|
|
2619
|
+
{
|
|
2620
|
+
var _values$fields = values.fields,
|
|
2621
|
+
fields = _values$fields === void 0 ? [] : _values$fields,
|
|
2622
|
+
rest = _objectWithoutProperties(values, _excluded$1);
|
|
2623
|
+
return _objectSpread$2(_objectSpread$2({}, rest), {}, {
|
|
2624
|
+
fieldsAttributes: map(renameKey("deleted", "_destroy"), omitDraftId(fields))
|
|
2625
|
+
});
|
|
2626
|
+
}
|
|
2627
|
+
default:
|
|
2628
|
+
return values;
|
|
2629
|
+
}
|
|
2630
|
+
};
|
|
2170
2631
|
|
|
2171
2632
|
var _excluded = ["isOpen", "onClose", "action", "question", "availableQuestionKinds"];
|
|
2172
2633
|
function ownKeys$1(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; }
|