@bigbinary/neeto-form-frontend 3.14.8 → 4.0.0-beta

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 (48) hide show
  1. package/README.md +5 -3
  2. package/dist/BuildForm.js +27 -17
  3. package/dist/BuildForm.js.map +1 -1
  4. package/dist/ExternalForm.js +5 -5
  5. package/dist/ExternalForm.js.map +1 -1
  6. package/dist/Submission.js +2 -2
  7. package/dist/Submission.js.map +1 -1
  8. package/dist/UrlBuilder.js +4 -4
  9. package/dist/{buildForm-CXy5L1RP.js → buildForm-BwhLCvEE.js} +2 -2
  10. package/dist/{buildForm-CXy5L1RP.js.map → buildForm-BwhLCvEE.js.map} +1 -1
  11. package/dist/{buildForm-DNCW7prR.js → buildForm-CsVQHcC7.js} +2 -2
  12. package/dist/{buildForm-DNCW7prR.js.map → buildForm-CsVQHcC7.js.map} +1 -1
  13. package/dist/cjs/BuildForm.js +27 -17
  14. package/dist/cjs/BuildForm.js.map +1 -1
  15. package/dist/cjs/ExternalForm.js +5 -5
  16. package/dist/cjs/ExternalForm.js.map +1 -1
  17. package/dist/cjs/Submission.js +2 -2
  18. package/dist/cjs/Submission.js.map +1 -1
  19. package/dist/cjs/UrlBuilder.js +4 -4
  20. package/dist/cjs/hooks.js +4 -4
  21. package/dist/cjs/index.js +6 -6
  22. package/dist/{constants-b1EQ6-AS.js → constants-51SEJjzI.js} +2 -2
  23. package/dist/constants-51SEJjzI.js.map +1 -0
  24. package/dist/{constants-BVZZfXua.js → constants-C9wKMfgo.js} +2 -2
  25. package/dist/constants-C9wKMfgo.js.map +1 -0
  26. package/dist/{constants-CrLEqZUc.js → constants-Dmtgr5z3.js} +3 -3
  27. package/dist/{constants-CrLEqZUc.js.map → constants-Dmtgr5z3.js.map} +1 -1
  28. package/dist/{constants-CuzR2B5C.js → constants-gYwz1n9Z.js} +3 -3
  29. package/dist/{constants-CuzR2B5C.js.map → constants-gYwz1n9Z.js.map} +1 -1
  30. package/dist/hooks.js +4 -4
  31. package/dist/{index-BARvqe7c.js → index-D4URTv1p.js} +2 -2
  32. package/dist/{index-BARvqe7c.js.map → index-D4URTv1p.js.map} +1 -1
  33. package/dist/{index-BkNaYmLc.js → index-DnHrq-hl.js} +2 -2
  34. package/dist/{index-BkNaYmLc.js.map → index-DnHrq-hl.js.map} +1 -1
  35. package/dist/index.js +6 -6
  36. package/dist/main.css +1 -1
  37. package/dist/main.css.map +1 -1
  38. package/dist/{useFormSubmission-CYqHLtkA.js → useFormSubmission-BGNEnxvm.js} +2 -2
  39. package/dist/{useFormSubmission-CYqHLtkA.js.map → useFormSubmission-BGNEnxvm.js.map} +1 -1
  40. package/dist/{useFormSubmission-DMoyM44A.js → useFormSubmission-BUPnuOSG.js} +2 -2
  41. package/dist/{useFormSubmission-DMoyM44A.js.map → useFormSubmission-BUPnuOSG.js.map} +1 -1
  42. package/dist/{utils-3vf7iBuC.js → utils-Bhu45zuy.js} +4 -4
  43. package/dist/{utils-3vf7iBuC.js.map → utils-Bhu45zuy.js.map} +1 -1
  44. package/dist/{utils-E-UQc-9z.js → utils-DsI2Nrwl.js} +4 -4
  45. package/dist/{utils-E-UQc-9z.js.map → utils-DsI2Nrwl.js.map} +1 -1
  46. package/package.json +17 -15
  47. package/dist/constants-BVZZfXua.js.map +0 -1
  48. package/dist/constants-b1EQ6-AS.js.map +0 -1
package/README.md CHANGED
@@ -56,13 +56,15 @@ model. It also stores submissions.
56
56
  bundle exec rails db:migrate
57
57
  ```
58
58
 
59
- 5. Add this line to your application's `config/routes.rb` file (replace `at` to
60
- your desired route):
59
+ 5. Add this line to your application's `config/routes.rb` file.
61
60
 
62
61
  ```ruby
63
- mount NeetoFormEngine::Engine, at: "/neeto_form_engine"
62
+ mount NeetoFormEngine::Engine, at: "/neeto_form"
64
63
  ```
65
64
 
65
+ **NOTE: The mount point must be `/neeto_form` and cannot be changed to any
66
+ other path.**
67
+
66
68
  6. Create file `neeto_form_engine.rb` under `config/initializers` to provide the
67
69
  `owner_class` information
68
70
 
package/dist/BuildForm.js CHANGED
@@ -3,14 +3,14 @@ import classnames from 'classnames';
3
3
  import { isPresent, truncate, findBy, isNotPresent, slugify, existsBy, hyphenate, noop, nullSafe, removeBy } from '@bigbinary/neeto-cist';
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
- 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-b1EQ6-AS.js';
7
- import { e as buildDisplayLabel, f as INDEPENDENT_LABELS_MAP, h as QUESTION_ACTIONS, i as isElementOverflowing, D as Drag, j as SELECTABLE_KINDS, k as isAutoGeneratedQuestion, l as isRichTextQuestion, N as NON_BASIC_LATIN_CHARACTERS_REGEX, m as RESERVED_FIELD_CODES, L as LABEL_FIELDS, n as isDefaultLanguage, o as buildAddQuestionButtonProps, v as validateEditorContent, F as FIELD_CODES_REJECT_CHARS_REGEX, p as isImmutableField, Q as QUESTIONS_WITHOUT_FIELD_CODE, q as NON_HIDEABLE_FIELDS, r as NON_READ_ONLY_FIELDS, s as RICH_TEXT_QUESTIONS, t as FILE_TYPES_MAP, u as FILE_GROUPS, M as MINIMUM_OPTIONS, w as RATING_OPTIONS, x as STAR_RATING_MIN_VALUE_OPTIONS, y as STAR_RATING_MAX_VALUE_OPTIONS, z as STAR_RATING_ICONS_MAP, A as buildDisabledAddButtonHelpPopoverProps, B as buildReorderPayload, G as isMandatoryField, H as QUESTION_KINDS, a as QUESTION_KIND, J as getActiveQuestionKindDetails, K as DEFAULT_AVAILABLE_LANGUAGES, O as DEFAULT_ADVANCED_FEATURES, P as QUESTIONS_INITIAL_VALUE } from './constants-CuzR2B5C.js';
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 { e as buildDisplayLabel, f as INDEPENDENT_LABELS_MAP, h as QUESTION_ACTIONS, i as isElementOverflowing, D as Drag, j as SELECTABLE_KINDS, k as isAutoGeneratedQuestion, l as isRichTextQuestion, N as NON_BASIC_LATIN_CHARACTERS_REGEX, m as RESERVED_FIELD_CODES, L as LABEL_FIELDS, n as isDefaultLanguage, o as buildAddQuestionButtonProps, v as validateEditorContent, F as FIELD_CODES_REJECT_CHARS_REGEX, p as isImmutableField, Q as QUESTIONS_WITHOUT_FIELD_CODE, q as NON_HIDEABLE_FIELDS, r as NON_READ_ONLY_FIELDS, s as RICH_TEXT_QUESTIONS, t as FILE_TYPES_MAP, u as FILE_GROUPS, M as MINIMUM_OPTIONS, w as RATING_OPTIONS, x as STAR_RATING_MIN_VALUE_OPTIONS, y as STAR_RATING_MAX_VALUE_OPTIONS, z as STAR_RATING_ICONS_MAP, A as buildDisabledAddButtonHelpPopoverProps, B as buildReorderPayload, G as isMandatoryField, H as QUESTION_KINDS, a as QUESTION_KIND, J as getActiveQuestionKindDetails, K as DEFAULT_AVAILABLE_LANGUAGES, O as DEFAULT_ADVANCED_FEATURES, P as QUESTIONS_INITIAL_VALUE } from './constants-gYwz1n9Z.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-DNCW7prR.js';
13
+ import { a as useBuildFormStore } from './buildForm-CsVQHcC7.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,7 +21,7 @@ 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-BkNaYmLc.js';
24
+ import { i as isFunction, f as fieldWithFallback, c as isNameQuestion } from './index-DnHrq-hl.js';
25
25
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
26
26
  import { t } from 'i18next';
27
27
  import { v4 } from 'uuid';
@@ -205,7 +205,7 @@ var Overview = function Overview(_ref) {
205
205
  availableLanguages = _ref.availableLanguages,
206
206
  additionalActionOptions = _ref.additionalActionOptions;
207
207
  return /*#__PURE__*/jsxs("div", {
208
- className: "neeto-form-nano-form-wrapper__overview mb-4 w-full flex-shrink-0 space-y-4 pt-6",
208
+ className: "neeto-form-nano-form-wrapper__overview mb-4 w-full shrink-0 space-y-4 pt-6",
209
209
  children: [/*#__PURE__*/jsxs("div", {
210
210
  className: "flex items-center justify-between",
211
211
  children: [/*#__PURE__*/jsx(Typography, {
@@ -215,7 +215,7 @@ var Overview = function Overview(_ref) {
215
215
  weight: "neeto-ui-font-semibold",
216
216
  children: title
217
217
  }), /*#__PURE__*/jsxs("div", {
218
- className: "flex flex-shrink-0 items-center justify-between space-x-1",
218
+ className: "flex shrink-0 items-center justify-between space-x-1",
219
219
  children: [availableLanguages.length > 1 && /*#__PURE__*/jsx(ChangeLanguageDropdown, {
220
220
  availableLanguages: availableLanguages
221
221
  }), isPresent(additionalActionOptions) && /*#__PURE__*/jsx(MoreDropdown, {
@@ -247,7 +247,8 @@ var Card = function Card(_ref) {
247
247
  onSelect = _ref.onSelect,
248
248
  onEdit = _ref.onEdit,
249
249
  onClone = _ref.onClone,
250
- onDelete = _ref.onDelete;
250
+ onDelete = _ref.onDelete,
251
+ canManageQuestions = _ref.canManageQuestions;
251
252
  var _useState = useState(false),
252
253
  _useState2 = _slicedToArray(_useState, 2),
253
254
  isTooltipEnabled = _useState2[0],
@@ -275,15 +276,15 @@ var Card = function Card(_ref) {
275
276
  return onSelect(question);
276
277
  },
277
278
  children: [/*#__PURE__*/jsxs("div", {
278
- className: "flex min-w-0 flex-grow items-center gap-1",
279
- children: [/*#__PURE__*/jsx(Drag, {
280
- className: "neeto-ui-text-gray-600 flex-shrink-0"
279
+ className: "flex min-w-0 grow items-center gap-1",
280
+ children: [canManageQuestions && /*#__PURE__*/jsx(Drag, {
281
+ className: "neeto-ui-text-gray-600 shrink-0"
281
282
  }), /*#__PURE__*/jsx(Tooltip, {
282
283
  content: questionLabel,
283
284
  disabled: !isTooltipEnabled,
284
285
  position: "top",
285
286
  children: /*#__PURE__*/jsx(Typography, {
286
- className: "line-clamp-2 min-w-0 flex-grow truncate break-words",
287
+ className: "line-clamp-2 min-w-0 grow truncate break-words",
287
288
  "data-cy": "".concat(slugify(questionLabel), "-question-card-label"),
288
289
  lineHeight: "snug",
289
290
  ref: questionLabelRef,
@@ -292,7 +293,7 @@ var Card = function Card(_ref) {
292
293
  children: questionLabel
293
294
  })
294
295
  })]
295
- }), /*#__PURE__*/jsx(MoreDropdown, {
296
+ }), canManageQuestions && /*#__PURE__*/jsx(MoreDropdown, {
296
297
  dropdownButtonProps: {
297
298
  className: "shrink-0"
298
299
  },
@@ -334,9 +335,11 @@ var Questions = function Questions(_ref) {
334
335
  onEdit = _ref.onEdit,
335
336
  onClone = _ref.onClone,
336
337
  onDelete = _ref.onDelete,
337
- onSelect = _ref.onSelect;
338
+ onSelect = _ref.onSelect,
339
+ canManageQuestions = _ref.canManageQuestions;
338
340
  return /*#__PURE__*/jsx(Droppable, {
339
341
  droppableId: "droppable",
342
+ isDropDisabled: !canManageQuestions,
340
343
  children: function children(_ref2) {
341
344
  var droppableProps = _ref2.droppableProps,
342
345
  placeholder = _ref2.placeholder,
@@ -349,6 +352,7 @@ var Questions = function Questions(_ref) {
349
352
  return /*#__PURE__*/createElement(Draggable, {
350
353
  index: index,
351
354
  draggableId: "question-".concat((_question$id = question.id) !== null && _question$id !== void 0 ? _question$id : question.nodeId),
355
+ isDragDisabled: !canManageQuestions,
352
356
  key: "question-".concat((_question$id2 = question.id) !== null && _question$id2 !== void 0 ? _question$id2 : question.nodeId)
353
357
  }, function (_ref3) {
354
358
  var draggableProps = _ref3.draggableProps,
@@ -358,6 +362,7 @@ var Questions = function Questions(_ref) {
358
362
  ref: innerRef,
359
363
  children: /*#__PURE__*/jsx(Card, {
360
364
  allQuestionKinds: allQuestionKinds,
365
+ canManageQuestions: canManageQuestions,
361
366
  getActiveKindDetails: getActiveKindDetails,
362
367
  onClone: onClone,
363
368
  onEdit: onEdit,
@@ -2164,6 +2169,7 @@ var Form = function Form(_ref) {
2164
2169
  isDisabledFieldLabel = _ref.isDisabledFieldLabel,
2165
2170
  disabledAddButtonHelpPopoverProps = _ref.disabledAddButtonHelpPopoverProps,
2166
2171
  isFormEnabled = _ref.isFormEnabled,
2172
+ canManageQuestions = _ref.canManageQuestions,
2167
2173
  savedTitle = _ref.savedTitle,
2168
2174
  formTitle = _ref.formTitle,
2169
2175
  formDescription = _ref.formDescription,
@@ -2334,7 +2340,7 @@ var Form = function Form(_ref) {
2334
2340
  description: formDescription,
2335
2341
  title: formTitle
2336
2342
  }), /*#__PURE__*/jsx("div", {
2337
- className: "neeto-form-nano-form-wrapper__body min-h-0 w-full flex-grow space-y-6 overflow-y-auto pb-6",
2343
+ className: "neeto-form-nano-form-wrapper__body min-h-0 w-full grow space-y-6 overflow-y-auto pb-6",
2338
2344
  children: isPresent(questions) ? /*#__PURE__*/jsxs("div", {
2339
2345
  className: "space-y-6",
2340
2346
  ref: containerRef,
@@ -2353,6 +2359,7 @@ var Form = function Form(_ref) {
2353
2359
  });
2354
2360
  },
2355
2361
  children: /*#__PURE__*/jsx(Questions, {
2362
+ canManageQuestions: canManageQuestions,
2356
2363
  getActiveKindDetails: getActiveKindDetails,
2357
2364
  isDeletable: isDeletable,
2358
2365
  questions: questions,
@@ -2363,7 +2370,7 @@ var Form = function Form(_ref) {
2363
2370
  onEdit: handleEdit,
2364
2371
  onSelect: handleSelect
2365
2372
  })
2366
- }), /*#__PURE__*/jsx("div", {
2373
+ }), canManageQuestions && /*#__PURE__*/jsx("div", {
2367
2374
  className: "mb-8 flex w-full items-center gap-x-1",
2368
2375
  children: /*#__PURE__*/jsx(AddQuestion, {
2369
2376
  addQuestionHelpProps: addQuestionHelpProps,
@@ -2374,7 +2381,7 @@ var Form = function Form(_ref) {
2374
2381
  })]
2375
2382
  }) : /*#__PURE__*/jsx(AddFirstQuestion, {
2376
2383
  disabledAddButtonHelpPopoverProps: disabledAddButtonHelpPopoverProps,
2377
- isDisabled: isEmpty(availableQuestionKinds),
2384
+ isDisabled: isEmpty(availableQuestionKinds) || !canManageQuestions,
2378
2385
  onAdd: handleAdd
2379
2386
  })
2380
2387
  }), /*#__PURE__*/jsx(ManageQuestionPane, {
@@ -2435,7 +2442,9 @@ var BuildForm = function BuildForm(_ref) {
2435
2442
  usesCustomSubmissionComponent = _ref$usesCustomSubmis === void 0 ? false : _ref$usesCustomSubmis,
2436
2443
  _ref$onMutateSuccess = _ref.onMutateSuccess,
2437
2444
  onMutateSuccess = _ref$onMutateSuccess === void 0 ? noop : _ref$onMutateSuccess,
2438
- hostSpecificData = _ref.hostSpecificData;
2445
+ hostSpecificData = _ref.hostSpecificData,
2446
+ _ref$canManageQuestio = _ref.canManageQuestions,
2447
+ canManageQuestions = _ref$canManageQuestio === void 0 ? false : _ref$canManageQuestio;
2439
2448
  var queryClient = useQueryClient();
2440
2449
  var _useForm = useForm({
2441
2450
  formId: id,
@@ -2477,6 +2486,7 @@ var BuildForm = function BuildForm(_ref) {
2477
2486
  additionalActionOptions: additionalActionOptions,
2478
2487
  advancedFeatures: advancedFeatures,
2479
2488
  availableLanguages: availableLanguages,
2489
+ canManageQuestions: canManageQuestions,
2480
2490
  disabledAddButtonHelpPopoverProps: disabledAddButtonHelpPopoverProps,
2481
2491
  formDescription: formDescription,
2482
2492
  formTitle: formTitle,