@bigbinary/neeto-form-frontend 4.1.10 → 4.2.1

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.
Files changed (74) hide show
  1. package/app/javascript/src/translations/ar.json +5 -1
  2. package/app/javascript/src/translations/bg.json +5 -1
  3. package/app/javascript/src/translations/ca.json +5 -1
  4. package/app/javascript/src/translations/cs.json +5 -1
  5. package/app/javascript/src/translations/da.json +5 -1
  6. package/app/javascript/src/translations/de.json +5 -1
  7. package/app/javascript/src/translations/en.json +5 -1
  8. package/app/javascript/src/translations/es-MX.json +5 -1
  9. package/app/javascript/src/translations/es.json +5 -1
  10. package/app/javascript/src/translations/et.json +5 -1
  11. package/app/javascript/src/translations/fi.json +5 -1
  12. package/app/javascript/src/translations/fil.json +5 -1
  13. package/app/javascript/src/translations/fr.json +5 -1
  14. package/app/javascript/src/translations/he.json +5 -1
  15. package/app/javascript/src/translations/hi.json +5 -1
  16. package/app/javascript/src/translations/hr.json +5 -1
  17. package/app/javascript/src/translations/id.json +5 -1
  18. package/app/javascript/src/translations/it.json +5 -1
  19. package/app/javascript/src/translations/ja.json +5 -1
  20. package/app/javascript/src/translations/ko.json +5 -1
  21. package/app/javascript/src/translations/nl.json +5 -1
  22. package/app/javascript/src/translations/pl.json +5 -1
  23. package/app/javascript/src/translations/pt-BR.json +5 -1
  24. package/app/javascript/src/translations/pt.json +5 -1
  25. package/app/javascript/src/translations/ro.json +5 -1
  26. package/app/javascript/src/translations/ru.json +5 -1
  27. package/app/javascript/src/translations/sk.json +5 -1
  28. package/app/javascript/src/translations/sl.json +5 -1
  29. package/app/javascript/src/translations/sv.json +5 -1
  30. package/app/javascript/src/translations/th.json +5 -1
  31. package/app/javascript/src/translations/tr.json +5 -1
  32. package/app/javascript/src/translations/uk.json +5 -1
  33. package/app/javascript/src/translations/vi.json +5 -1
  34. package/app/javascript/src/translations/zh-CN.json +5 -1
  35. package/app/javascript/src/translations/zh-TW.json +5 -1
  36. package/dist/BuildForm.js +69 -26
  37. package/dist/BuildForm.js.map +1 -1
  38. package/dist/ExternalForm.js +3 -2
  39. package/dist/ExternalForm.js.map +1 -1
  40. package/dist/UrlBuilder.js +3 -2
  41. package/dist/UrlBuilder.js.map +1 -1
  42. package/dist/{buildForm-BwhLCvEE.js → buildForm-CooylMLL.js} +3 -2
  43. package/dist/buildForm-CooylMLL.js.map +1 -0
  44. package/dist/{buildForm-CsVQHcC7.js → buildForm-DcE5kFvR.js} +3 -2
  45. package/dist/buildForm-DcE5kFvR.js.map +1 -0
  46. package/dist/cjs/BuildForm.js +69 -26
  47. package/dist/cjs/BuildForm.js.map +1 -1
  48. package/dist/cjs/ExternalForm.js +3 -2
  49. package/dist/cjs/ExternalForm.js.map +1 -1
  50. package/dist/cjs/UrlBuilder.js +3 -2
  51. package/dist/cjs/UrlBuilder.js.map +1 -1
  52. package/dist/cjs/hooks.js +1 -1
  53. package/dist/cjs/index.js +5 -3
  54. package/dist/cjs/index.js.map +1 -1
  55. package/dist/{constants-BSbkmQ4t.js → constants-BjWWA3Oq.js} +10 -1
  56. package/dist/constants-BjWWA3Oq.js.map +1 -0
  57. package/dist/{constants-Da_Y-J4N.js → constants-QPLZ_r-D.js} +9 -2
  58. package/dist/constants-QPLZ_r-D.js.map +1 -0
  59. package/dist/hooks.js +1 -1
  60. package/dist/index.js +5 -3
  61. package/dist/index.js.map +1 -1
  62. package/dist/main.css +1 -1
  63. package/dist/main.css.map +1 -1
  64. package/dist/{utils-BdTASoGp.js → utils-BwFLBXs2.js} +88 -13
  65. package/dist/utils-BwFLBXs2.js.map +1 -0
  66. package/dist/{utils-BUXD94aD.js → utils-GRfGBny0.js} +88 -13
  67. package/dist/utils-GRfGBny0.js.map +1 -0
  68. package/package.json +17 -17
  69. package/dist/buildForm-BwhLCvEE.js.map +0 -1
  70. package/dist/buildForm-CsVQHcC7.js.map +0 -1
  71. package/dist/constants-BSbkmQ4t.js.map +0 -1
  72. package/dist/constants-Da_Y-J4N.js.map +0 -1
  73. package/dist/utils-BUXD94aD.js.map +0 -1
  74. package/dist/utils-BdTASoGp.js.map +0 -1
package/dist/BuildForm.js CHANGED
@@ -4,13 +4,13 @@ import { isPresent, truncate, findBy, isNotPresent, slugify, existsBy, hyphenate
4
4
  import Spinner from '@bigbinary/neetoui/Spinner';
5
5
  import { equals, path, curry, assoc, prop, dissoc, when, includes, isEmpty, reject, keys, pick, omit, evolve, map, mergeLeft, isNil, pipe, filter, isNotNil, uniq, join, pluck, test, paths, difference, split, last, either, T, F } from 'ramda';
6
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-51SEJjzI.js';
7
- import { f as buildDisplayLabel, h as INDEPENDENT_LABELS_MAP, i as QUESTION_ACTIONS, j as isElementOverflowing, D as Drag, k as SELECTABLE_KINDS, l as isAutoGeneratedQuestion, m as isRichTextQuestion, N as NON_BASIC_LATIN_CHARACTERS_REGEX, n as RESERVED_FIELD_CODES, d as LABEL_FIELDS, o as isDefaultLanguage, p as buildAddQuestionButtonProps, v as validateEditorContent, F as FIELD_CODES_REJECT_CHARS_REGEX, q as isImmutableField, Q as QUESTIONS_WITHOUT_FIELD_CODE, r as NON_HIDEABLE_FIELDS, s as NON_READ_ONLY_FIELDS, t as RICH_TEXT_QUESTIONS, u as FILE_TYPES_MAP, w as FILE_GROUPS, M as MINIMUM_OPTIONS, x as RATING_OPTIONS, y as STAR_RATING_MIN_VALUE_OPTIONS, z as STAR_RATING_MAX_VALUE_OPTIONS, A as STAR_RATING_ICONS_MAP, B as buildDisabledAddButtonHelpPopoverProps, G as buildReorderPayload, H as isMandatoryField, J as QUESTION_KINDS, a as QUESTION_KIND, K as getActiveQuestionKindDetails, O as DEFAULT_AVAILABLE_LANGUAGES, T as DEFAULT_ADVANCED_FEATURES, U as QUESTIONS_INITIAL_VALUE } from './constants-Da_Y-J4N.js';
7
+ import { f as buildDisplayLabel, h as INDEPENDENT_LABELS_MAP, i as QUESTION_ACTIONS, j as isElementOverflowing, k as Drag, l as SELECTABLE_KINDS, m as isAutoGeneratedQuestion, n as isRichTextQuestion, N as NON_BASIC_LATIN_CHARACTERS_REGEX, o as RESERVED_FIELD_CODES, d as LABEL_FIELDS, p as isDefaultLanguage, q as buildAddQuestionButtonProps, v as validateEditorContent, F as FIELD_CODES_REJECT_CHARS_REGEX, r as isImmutableField, Q as QUESTIONS_WITHOUT_FIELD_CODE, s as NON_HIDEABLE_FIELDS, t as NON_READ_ONLY_FIELDS, u as RICH_TEXT_QUESTIONS, w as FILE_TYPES_MAP, x as FILE_GROUPS, D as DEFAULT_CHOICE_QUESTION_ATTRIBUTES, M as MINIMUM_OPTIONS, y as IMAGE_HEIGHT_SLIDER_DEFAULTS, z as RATING_OPTIONS, A as STAR_RATING_MIN_VALUE_OPTIONS, B as STAR_RATING_MAX_VALUE_OPTIONS, G as STAR_RATING_ICONS_MAP, H as buildDisabledAddButtonHelpPopoverProps, J as buildReorderPayload, K as isMandatoryField, O as QUESTION_KINDS, a as QUESTION_KIND, T as getActiveQuestionKindDetails, U as DEFAULT_AVAILABLE_LANGUAGES, V as DEFAULT_ADVANCED_FEATURES, W as QUESTIONS_INITIAL_VALUE } from './constants-QPLZ_r-D.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-CsVQHcC7.js';
13
+ import { a as useBuildFormStore } from './buildForm-DcE5kFvR.js';
14
14
  import { shallow } from 'zustand/shallow';
15
15
  import Alert from '@bigbinary/neetoui/Alert';
16
16
  import { useTranslation, Trans } from 'react-i18next';
@@ -53,6 +53,7 @@ import _regeneratorRuntime from '@babel/runtime/regenerator';
53
53
  import Checkbox$1 from '@bigbinary/neetoui/formik/Checkbox';
54
54
  import Checkbox from '@bigbinary/neetoui/Checkbox';
55
55
  import OptionFields from '@bigbinary/neeto-molecules/OptionFields';
56
+ import Slider from '@bigbinary/neetoui/Slider';
56
57
  import '@bigbinary/neeto-commons-frontend/constants';
57
58
  import 'axios';
58
59
  import 'dompurify';
@@ -1874,12 +1875,17 @@ var Options = function Options(_ref) {
1874
1875
  var _useTranslation = useTranslation(),
1875
1876
  t = _useTranslation.t;
1876
1877
  var _useBuildFormStore = useBuildFormStore(function (store) {
1877
- var _store$formState;
1878
+ var _store$formState, _store$formState2;
1878
1879
  return {
1879
- selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"]
1880
+ selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"],
1881
+ isPictureChoiceEnabled: (_store$formState2 = store["formState"]) === null || _store$formState2 === void 0 ? void 0 : _store$formState2["isPictureChoiceEnabled"]
1880
1882
  };
1881
1883
  }, shallow),
1882
- selectedLanguage = _useBuildFormStore.selectedLanguage;
1884
+ selectedLanguage = _useBuildFormStore.selectedLanguage,
1885
+ isPictureChoiceEnabled = _useBuildFormStore.isPictureChoiceEnabled;
1886
+ var _useFormikContext = useFormikContext(),
1887
+ values = _useFormikContext.values,
1888
+ setFieldValue = _useFormikContext.setFieldValue;
1883
1889
  var name = "optionsAttributes";
1884
1890
  var _useField = useField(name),
1885
1891
  _useField2 = _slicedToArray(_useField, 3);
@@ -1898,24 +1904,56 @@ var Options = function Options(_ref) {
1898
1904
  var isManageOptionDisabled = isFunction(freezeOptions) ? freezeOptions(selectedLanguage) : freezeOptions;
1899
1905
  var isAddOptionDisabled = disableAddOption || isManageOptionDisabled;
1900
1906
  var isRemoveOptionDisabled = disableRemoveOption || isManageOptionDisabled;
1907
+ var isDropdown = values.kind === QUESTION_TYPES.DROPDOWN;
1908
+ var isPictureChoice = isPictureChoiceEnabled && !isDropdown && (values.isPictureChoice || DEFAULT_CHOICE_QUESTION_ATTRIBUTES.isPictureChoice);
1909
+ var imageHeight = values.imageHeight || DEFAULT_CHOICE_QUESTION_ATTRIBUTES.imageHeight;
1910
+ var handleImageHeightChange = function handleImageHeightChange(value) {
1911
+ setFieldValue("imageHeight", value);
1912
+ };
1901
1913
  return /*#__PURE__*/jsxs("div", {
1902
- className: "w-full",
1903
- children: [/*#__PURE__*/jsx(Label, _objectSpread$2(_objectSpread$2({
1904
- className: "mb-2 block"
1905
- }, optionLabelProps), {}, {
1906
- children: t("neetoForm.questions.common.questionFields.field.options")
1907
- })), /*#__PURE__*/jsx(OptionFields, {
1908
- name: name,
1909
- shouldDestroy: true,
1910
- destroyFlagName: "_destroy",
1911
- disabled: isManageOptionDisabled,
1912
- draggable: !isManageOptionDisabled,
1913
- isAddOptionEnabled: !isAddOptionDisabled,
1914
- isDeleteOptionEnabled: !isRemoveOptionDisabled,
1915
- isNewItemsPrefilled: isDefaultLanguage(selectedLanguage),
1916
- minOptions: MINIMUM_OPTIONS,
1917
- shouldResetEmptyOptionOnBlur: false,
1918
- onChange: setOptionsAttributes
1914
+ className: "w-full space-y-4",
1915
+ children: [/*#__PURE__*/jsxs("div", {
1916
+ children: [/*#__PURE__*/jsx(Label, _objectSpread$2(_objectSpread$2({
1917
+ className: "mb-2 block"
1918
+ }, optionLabelProps), {}, {
1919
+ children: t("neetoForm.questions.common.questionFields.field.options")
1920
+ })), /*#__PURE__*/jsx(OptionFields, {
1921
+ isPictureChoice: isPictureChoice,
1922
+ name: name,
1923
+ shouldDestroy: true,
1924
+ destroyFlagName: "_destroy",
1925
+ disabled: isManageOptionDisabled,
1926
+ draggable: !isManageOptionDisabled,
1927
+ isAddOptionEnabled: !isAddOptionDisabled,
1928
+ isDeleteOptionEnabled: !isRemoveOptionDisabled,
1929
+ isNewItemsPrefilled: isDefaultLanguage(selectedLanguage),
1930
+ minOptions: MINIMUM_OPTIONS,
1931
+ shouldResetEmptyOptionOnBlur: false,
1932
+ onChange: setOptionsAttributes
1933
+ })]
1934
+ }), !isDropdown && isPictureChoiceEnabled && /*#__PURE__*/jsxs(Block, {
1935
+ title: t("neetoForm.questions.common.questionFields.field.pictureChoiceSettings"),
1936
+ children: [/*#__PURE__*/jsx(Switch, {
1937
+ name: "isPictureChoice",
1938
+ label: t("neetoForm.questions.common.questionFields.field.addPicturesToOptions")
1939
+ }), isPictureChoice && /*#__PURE__*/jsxs(Fragment, {
1940
+ children: [/*#__PURE__*/jsx(Switch, {
1941
+ name: "shouldFitImages",
1942
+ label: t("neetoForm.questions.common.questionFields.field.fitImages")
1943
+ }), /*#__PURE__*/jsxs("div", {
1944
+ className: "mt-4",
1945
+ children: [/*#__PURE__*/jsx(Typography, {
1946
+ style: "body2",
1947
+ weight: "medium",
1948
+ children: t("neetoForm.questions.common.questionFields.field.imageHeight")
1949
+ }), /*#__PURE__*/jsx(Slider, {
1950
+ max: IMAGE_HEIGHT_SLIDER_DEFAULTS.max,
1951
+ min: IMAGE_HEIGHT_SLIDER_DEFAULTS.min,
1952
+ value: imageHeight,
1953
+ onChange: handleImageHeightChange
1954
+ })]
1955
+ })]
1956
+ })]
1919
1957
  })]
1920
1958
  });
1921
1959
  };
@@ -2188,7 +2226,8 @@ var Form = function Form(_ref) {
2188
2226
  usesCustomSubmissionComponent = _ref.usesCustomSubmissionComponent,
2189
2227
  questionsFromCache = _ref.questionsFromCache,
2190
2228
  onMutateSuccess = _ref.onMutateSuccess,
2191
- advancedFeatures = _ref.advancedFeatures;
2229
+ advancedFeatures = _ref.advancedFeatures,
2230
+ isPictureChoiceEnabled = _ref.isPictureChoiceEnabled;
2192
2231
  var containerRef = useRef();
2193
2232
  var _useStateWithDependen = useStateWithDependency(questionsFromCache),
2194
2233
  _useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
@@ -2262,9 +2301,10 @@ var Form = function Form(_ref) {
2262
2301
  hostSpecificData: hostSpecificData,
2263
2302
  onMutateSuccess: onMutateSuccess,
2264
2303
  advancedFeatures: advancedFeatures,
2265
- onLanguageChange: onLanguageChange
2304
+ onLanguageChange: onLanguageChange,
2305
+ isPictureChoiceEnabled: isPictureChoiceEnabled
2266
2306
  });
2267
- }, [formId, isFormEnabled, savedTitle, setFormData, selectedLanguage, helpDocUrls, isUsingDefaultQuestionKinds, usesCustomSubmissionComponent, hostSpecificData, onMutateSuccess, advancedFeatures, onLanguageChange]);
2307
+ }, [formId, isFormEnabled, savedTitle, setFormData, selectedLanguage, helpDocUrls, isUsingDefaultQuestionKinds, usesCustomSubmissionComponent, hostSpecificData, onMutateSuccess, advancedFeatures, onLanguageChange, isPictureChoiceEnabled]);
2268
2308
  var handleSelect = function handleSelect(question) {
2269
2309
  setSelectedQuestion(question);
2270
2310
  };
@@ -2447,7 +2487,9 @@ var BuildForm = function BuildForm(_ref) {
2447
2487
  onMutateSuccess = _ref$onMutateSuccess === void 0 ? noop : _ref$onMutateSuccess,
2448
2488
  hostSpecificData = _ref.hostSpecificData,
2449
2489
  _ref$canManageQuestio = _ref.canManageQuestions,
2450
- canManageQuestions = _ref$canManageQuestio === void 0 ? false : _ref$canManageQuestio;
2490
+ canManageQuestions = _ref$canManageQuestio === void 0 ? false : _ref$canManageQuestio,
2491
+ _ref$isPictureChoiceE = _ref.isPictureChoiceEnabled,
2492
+ isPictureChoiceEnabled = _ref$isPictureChoiceE === void 0 ? false : _ref$isPictureChoiceE;
2451
2493
  var queryClient = useQueryClient();
2452
2494
  var _useForm = useForm({
2453
2495
  formId: id,
@@ -2499,6 +2541,7 @@ var BuildForm = function BuildForm(_ref) {
2499
2541
  isDisabledFieldLabel: isDisabledFieldLabel,
2500
2542
  isFormEnabled: isFormEnabled,
2501
2543
  isKindAlreadyActive: isKindAlreadyActive,
2544
+ isPictureChoiceEnabled: isPictureChoiceEnabled,
2502
2545
  isRequiredField: isRequiredField,
2503
2546
  isUsingDefaultQuestionKinds: isUsingDefaultQuestionKinds,
2504
2547
  kindUniqueOn: kindUniqueOn,