@bigbinary/neeto-form-frontend 1.2.17 → 1.2.19
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/dist/index.cjs.js +66 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +66 -30
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -12,13 +12,14 @@ import axios from 'axios';
|
|
|
12
12
|
import ReactDOM, { unstable_batchedUpdates, flushSync as flushSync$1 } from 'react-dom';
|
|
13
13
|
import { Input as Input$1, Textarea, Checkbox, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
14
14
|
import { useTranslation, Trans } from 'react-i18next';
|
|
15
|
-
import { withImmutableActions, withT, useDebounce
|
|
15
|
+
import { withImmutableActions, withT, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
16
16
|
import { create as create$1 } from 'zustand';
|
|
17
17
|
import classnames from 'classnames';
|
|
18
18
|
import * as yup from 'yup';
|
|
19
19
|
import { object, array, string } from 'yup';
|
|
20
20
|
import { Editor as Editor$1, isEditorEmpty, EditorContent } from '@bigbinary/neeto-editor';
|
|
21
21
|
import { withEventTargetValue, getQueryParams, dateFormat } from '@bigbinary/neeto-commons-frontend/utils';
|
|
22
|
+
import useHotkeys from '@bigbinary/neeto-hotkeys';
|
|
22
23
|
import dayjs from 'dayjs';
|
|
23
24
|
import { validation, PhoneNumberInput, PhoneNumber as PhoneNumber$1 } from '@bigbinary/neeto-molecules/PhoneNumber';
|
|
24
25
|
import path$1 from 'path';
|
|
@@ -11340,18 +11341,6 @@ var Question = function Question(_ref) {
|
|
|
11340
11341
|
});
|
|
11341
11342
|
};
|
|
11342
11343
|
|
|
11343
|
-
var moveItem = function moveItem(arr, sourceIndex, destinationIndex) {
|
|
11344
|
-
if (sourceIndex === destinationIndex) return arr;
|
|
11345
|
-
if (arr instanceof Array && arr[sourceIndex] !== undefined) {
|
|
11346
|
-
var removedItem = arr.splice(sourceIndex, 1)[0];
|
|
11347
|
-
arr.splice(destinationIndex, 0, removedItem);
|
|
11348
|
-
}
|
|
11349
|
-
return arr;
|
|
11350
|
-
};
|
|
11351
|
-
var arrayHelpers = {
|
|
11352
|
-
moveItem: moveItem
|
|
11353
|
-
};
|
|
11354
|
-
|
|
11355
11344
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
11356
11345
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
11357
11346
|
// generators (like Math.random()).
|
|
@@ -11417,6 +11406,18 @@ function v4(options, buf, offset) {
|
|
|
11417
11406
|
return unsafeStringify(rnds);
|
|
11418
11407
|
}
|
|
11419
11408
|
|
|
11409
|
+
var moveItem = function moveItem(arr, sourceIndex, destinationIndex) {
|
|
11410
|
+
if (sourceIndex === destinationIndex) return arr;
|
|
11411
|
+
if (arr instanceof Array && arr[sourceIndex] !== undefined) {
|
|
11412
|
+
var removedItem = arr.splice(sourceIndex, 1)[0];
|
|
11413
|
+
arr.splice(destinationIndex, 0, removedItem);
|
|
11414
|
+
}
|
|
11415
|
+
return arr;
|
|
11416
|
+
};
|
|
11417
|
+
var arrayHelpers = {
|
|
11418
|
+
moveItem: moveItem
|
|
11419
|
+
};
|
|
11420
|
+
|
|
11420
11421
|
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; }
|
|
11421
11422
|
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$6(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; }
|
|
11422
11423
|
var generateUniqueFieldCode = function generateUniqueFieldCode(type, questions) {
|
|
@@ -15875,7 +15876,7 @@ var getMultipleOptionsFromURL = function getMultipleOptionsFromURL(_ref2) {
|
|
|
15875
15876
|
fieldCodes = _ref2.fieldCodes,
|
|
15876
15877
|
fieldCode = _ref2.fieldCode;
|
|
15877
15878
|
var fieldCodeValue = fieldCodes[fieldCode];
|
|
15878
|
-
if (!fieldCodeValue) return
|
|
15879
|
+
if (!fieldCodeValue) return new Array(optionsAttributes.length).fill(false);
|
|
15879
15880
|
var allOptions = fieldCodeValue.split(",");
|
|
15880
15881
|
return optionsAttributes.map(function (option) {
|
|
15881
15882
|
return allOptions.includes(option.label);
|
|
@@ -15904,16 +15905,31 @@ var getAdditionalGuestsFromUrl = function getAdditionalGuestsFromUrl(_ref4) {
|
|
|
15904
15905
|
};
|
|
15905
15906
|
});
|
|
15906
15907
|
};
|
|
15908
|
+
var getRatingFromUrl = function getRatingFromUrl(_ref5) {
|
|
15909
|
+
var fieldCodes = _ref5.fieldCodes,
|
|
15910
|
+
fieldCode = _ref5.fieldCode;
|
|
15911
|
+
var fieldCodeValue = fieldCodes[fieldCode];
|
|
15912
|
+
var allowedValues = Object.values(RATING_VALUES).map(prop("value"));
|
|
15913
|
+
return allowedValues.includes(fieldCodeValue) ? fieldCodeValue : "";
|
|
15914
|
+
};
|
|
15915
|
+
var getNumberFromUrl = function getNumberFromUrl(_ref6) {
|
|
15916
|
+
var fieldCodes = _ref6.fieldCodes,
|
|
15917
|
+
fieldCode = _ref6.fieldCode,
|
|
15918
|
+
kind = _ref6.kind;
|
|
15919
|
+
var fieldCodeValue = fieldCodes[fieldCode];
|
|
15920
|
+
var parsedValue = kind === QUESTION_KIND.INTEGER.value ? parseInt(fieldCodeValue) : parseFloat(fieldCodeValue);
|
|
15921
|
+
return parsedValue || "";
|
|
15922
|
+
};
|
|
15907
15923
|
var getLabel$1 = function getLabel(label, isRequired) {
|
|
15908
15924
|
return isRequired ? "".concat(label, "*") : label;
|
|
15909
15925
|
};
|
|
15910
|
-
var generateInitValues = function generateInitValues(
|
|
15911
|
-
var questions =
|
|
15912
|
-
|
|
15913
|
-
initialValues =
|
|
15914
|
-
|
|
15915
|
-
localValues =
|
|
15916
|
-
fieldCodes =
|
|
15926
|
+
var generateInitValues = function generateInitValues(_ref7) {
|
|
15927
|
+
var questions = _ref7.questions,
|
|
15928
|
+
_ref7$initialValues = _ref7.initialValues,
|
|
15929
|
+
initialValues = _ref7$initialValues === void 0 ? [] : _ref7$initialValues,
|
|
15930
|
+
_ref7$localValues = _ref7.localValues,
|
|
15931
|
+
localValues = _ref7$localValues === void 0 ? {} : _ref7$localValues,
|
|
15932
|
+
fieldCodes = _ref7.fieldCodes;
|
|
15917
15933
|
var initValues = {};
|
|
15918
15934
|
var valuesMap = {};
|
|
15919
15935
|
if (initialValues) {
|
|
@@ -15974,6 +15990,26 @@ var generateInitValues = function generateInitValues(_ref5) {
|
|
|
15974
15990
|
});
|
|
15975
15991
|
return;
|
|
15976
15992
|
}
|
|
15993
|
+
case QUESTION_KIND.INTEGER.value:
|
|
15994
|
+
case QUESTION_KIND.DECIMAL.value:
|
|
15995
|
+
{
|
|
15996
|
+
var _valuesMap3;
|
|
15997
|
+
initValues[id] = ((_valuesMap3 = valuesMap) === null || _valuesMap3 === void 0 || (_valuesMap3 = _valuesMap3[id]) === null || _valuesMap3 === void 0 ? void 0 : _valuesMap3.value) || getNumberFromUrl({
|
|
15998
|
+
fieldCodes: fieldCodes,
|
|
15999
|
+
fieldCode: fieldCode,
|
|
16000
|
+
kind: kind
|
|
16001
|
+
});
|
|
16002
|
+
return;
|
|
16003
|
+
}
|
|
16004
|
+
case QUESTION_KIND.RATING.value:
|
|
16005
|
+
{
|
|
16006
|
+
var _valuesMap4;
|
|
16007
|
+
initValues[id] = ((_valuesMap4 = valuesMap) === null || _valuesMap4 === void 0 || (_valuesMap4 = _valuesMap4[id]) === null || _valuesMap4 === void 0 ? void 0 : _valuesMap4.value) || getRatingFromUrl({
|
|
16008
|
+
fieldCodes: fieldCodes,
|
|
16009
|
+
fieldCode: fieldCode
|
|
16010
|
+
});
|
|
16011
|
+
return;
|
|
16012
|
+
}
|
|
15977
16013
|
case QUESTION_KIND.TERMS.value:
|
|
15978
16014
|
{
|
|
15979
16015
|
initValues[id] = false;
|
|
@@ -15981,22 +16017,22 @@ var generateInitValues = function generateInitValues(_ref5) {
|
|
|
15981
16017
|
}
|
|
15982
16018
|
case QUESTION_KIND.FILE_UPLOAD.value:
|
|
15983
16019
|
{
|
|
15984
|
-
var _valuesMap$id$value2,
|
|
16020
|
+
var _valuesMap$id$value2, _valuesMap5;
|
|
15985
16021
|
initValues[id] = {
|
|
15986
|
-
files: (_valuesMap$id$value2 = (
|
|
16022
|
+
files: (_valuesMap$id$value2 = (_valuesMap5 = valuesMap) === null || _valuesMap5 === void 0 || (_valuesMap5 = _valuesMap5[id]) === null || _valuesMap5 === void 0 ? void 0 : _valuesMap5.value) !== null && _valuesMap$id$value2 !== void 0 ? _valuesMap$id$value2 : []
|
|
15987
16023
|
};
|
|
15988
16024
|
return;
|
|
15989
16025
|
}
|
|
15990
16026
|
case QUESTION_KIND.PHONE.value:
|
|
15991
16027
|
{
|
|
15992
|
-
var _valuesMap$id$value3,
|
|
15993
|
-
initValues[id] = (_valuesMap$id$value3 = (
|
|
16028
|
+
var _valuesMap$id$value3, _valuesMap6;
|
|
16029
|
+
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);
|
|
15994
16030
|
return;
|
|
15995
16031
|
}
|
|
15996
16032
|
case QUESTION_KIND.STAR_RATING.value:
|
|
15997
16033
|
{
|
|
15998
|
-
var _valuesMap$id$value4,
|
|
15999
|
-
initValues[id] = (_valuesMap$id$value4 = (
|
|
16034
|
+
var _valuesMap$id$value4, _valuesMap7;
|
|
16035
|
+
initValues[id] = (_valuesMap$id$value4 = (_valuesMap7 = valuesMap) === null || _valuesMap7 === void 0 || (_valuesMap7 = _valuesMap7[id]) === null || _valuesMap7 === void 0 ? void 0 : _valuesMap7.value) !== null && _valuesMap$id$value4 !== void 0 ? _valuesMap$id$value4 : getStarRatingFromUrl({
|
|
16000
16036
|
starCount: count,
|
|
16001
16037
|
fieldCodes: fieldCodes,
|
|
16002
16038
|
fieldCode: fieldCode
|
|
@@ -16005,8 +16041,8 @@ var generateInitValues = function generateInitValues(_ref5) {
|
|
|
16005
16041
|
}
|
|
16006
16042
|
default:
|
|
16007
16043
|
{
|
|
16008
|
-
var _valuesMap$id$value5,
|
|
16009
|
-
initValues[id] = (_valuesMap$id$value5 = (
|
|
16044
|
+
var _valuesMap$id$value5, _valuesMap8;
|
|
16045
|
+
initValues[id] = (_valuesMap$id$value5 = (_valuesMap8 = valuesMap) === null || _valuesMap8 === void 0 || (_valuesMap8 = _valuesMap8[id]) === null || _valuesMap8 === void 0 ? void 0 : _valuesMap8.value) !== null && _valuesMap$id$value5 !== void 0 ? _valuesMap$id$value5 : fieldCodes[fieldCode];
|
|
16010
16046
|
return;
|
|
16011
16047
|
}
|
|
16012
16048
|
}
|
|
@@ -27079,7 +27115,7 @@ var ExternalForm = function ExternalForm(_ref) {
|
|
|
27079
27115
|
questions: []
|
|
27080
27116
|
} : _useForm$data,
|
|
27081
27117
|
isLoading = _useForm.isLoading;
|
|
27082
|
-
var keyPressRef =
|
|
27118
|
+
var keyPressRef = useHotkeys("command+enter", ((_formikInnerRef$curre = formikInnerRef.current) === null || _formikInnerRef$curre === void 0 ? void 0 : _formikInnerRef$curre.handleSubmit) || noop$4, {
|
|
27083
27119
|
mode: "scoped"
|
|
27084
27120
|
});
|
|
27085
27121
|
if (isLoading || form.isQuestionsLoading || !!submissionId && submission !== null && submission !== void 0 && submission.isLoading) {
|