@bigbinary/neeto-form-frontend 4.4.39 → 4.4.40

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.
@@ -1,12 +1,12 @@
1
1
  import { Alert, Dialog, Typography, Tooltip, DropdownMenu, Button, Empty, Switch as Switch$1, Sheet, Select, Accordion, Label, Badge, Checkbox, Slider, Spinner } from '@bigbinary/neeto-atoms';
2
2
  import { useQueryClient } from '@tanstack/react-query';
3
3
  import classnames from 'classnames';
4
- import { isPresent, truncate, findBy, isNotPresent, slugify, existsBy, findById, findIndexById, hyphenate, noop, nullSafe, modifyBy, removeBy } from '@bigbinary/neeto-cist';
4
+ import { isPresent, truncate, findBy, slugify, existsBy, isNotPresent, findById, findIndexById, hyphenate, noop, nullSafe, modifyBy, removeBy } from '@bigbinary/neeto-cist';
5
5
  import { equals, path, when, assoc, includes, isEmpty, reject, keys, pick, omit, evolve, map, mergeLeft, prop, pipe, filter, isNotNil, values, uniq, join, pathSatisfies, assocPath, dissoc, isNil, append, pluck, test, paths, difference, startsWith, split, last, either, F, T } from 'ramda';
6
6
  import { j as useDeleteQuestion, b as useForm, k as useCreateQuestion, l as useUpdateQuestion, m as useReorderQuestions, Q as QUERY_KEYS } from './useFormApi-B5a0zkAT.js';
7
- import { o as QUESTION_ACTIONS, q as INDEPENDENT_LABELS_MAP, r as buildDisplayLabel, s as isElementOverflowing, c as isFunction, t as SELECTABLE_KINDS, u as isAutoGeneratedQuestion, g as fieldWithFallback, v as isRichTextQuestion, w as SPOT_QUESTION_FIELD_CODE, x as isNameQuestion, N as NON_BASIC_LATIN_CHARACTERS_REGEX, y as RESERVED_FIELD_CODES, z as renameKey, j as LABEL_FIELDS, B as isDefaultLanguage, F as buildAddQuestionButtonProps, G as validateEditorContent, H as FIELD_CODES_REJECT_CHARS_REGEX, M as MIN_WORDS_SWITCH_LABEL_PROPS, J as MIN_WORDS, K as isImmutableField, a as QUESTIONS_WITHOUT_FIELD_CODE, O as NON_HIDEABLE_FIELDS, T as NON_READ_ONLY_FIELDS, U as OPINION_LABEL_MAX_LENGTH, V as RICH_TEXT_QUESTIONS, h as ADDRESS_FIELD_WIDTHS, A as ADDRESS_FIELD_TYPES, W as generateDefaultOptions, X as MINIMUM_ADDRESS_FIELDS, Z as getDeletedRecords, _ as randomId, $ as getActiveRecords, a0 as FILE_TYPES_MAP, a1 as FILE_GROUPS, a2 as OPINION_SCALE_MIN_VALUE_OPTIONS, a3 as OPINION_SCALE_MAX_VALUE_OPTIONS, D as DEFAULT_CHOICE_QUESTION_ATTRIBUTES, a4 as MINIMUM_OPTIONS, a5 as IMAGE_HEIGHT_SLIDER_DEFAULTS, a6 as RATING_OPTIONS, a7 as STAR_RATING_MIN_VALUE_OPTIONS, a8 as STAR_RATING_MAX_VALUE_OPTIONS, a9 as STAR_RATING_ICONS_MAP, aa as YES_NO_ICONS_MAP, ab as buildDisabledAddButtonHelpPopoverProps, ac as buildReorderPayload, ad as QUESTIONS_INITIAL_VALUE, ae as isMandatoryField, af as QUESTION_KINDS, Q as QUESTION_KIND, ag as getActiveQuestionKindDetails, ah as DEFAULT_AVAILABLE_LANGUAGES, ai as DEFAULT_ADVANCED_FEATURES } from './yup-Cf-x7SqN.js';
7
+ import { o as QUESTION_ACTIONS, q as INDEPENDENT_LABELS_MAP, r as buildDisplayLabel, c as isFunction, s as SELECTABLE_KINDS, t as isAutoGeneratedQuestion, g as fieldWithFallback, u as isRichTextQuestion, v as SPOT_QUESTION_FIELD_CODE, w as isNameQuestion, N as NON_BASIC_LATIN_CHARACTERS_REGEX, x as RESERVED_FIELD_CODES, y as renameKey, j as LABEL_FIELDS, z as isDefaultLanguage, B as buildAddQuestionButtonProps, F as validateEditorContent, G as FIELD_CODES_REJECT_CHARS_REGEX, M as MIN_WORDS_SWITCH_LABEL_PROPS, H as MIN_WORDS, J as isImmutableField, a as QUESTIONS_WITHOUT_FIELD_CODE, K as NON_HIDEABLE_FIELDS, O as NON_READ_ONLY_FIELDS, T as OPINION_LABEL_MAX_LENGTH, U as RICH_TEXT_QUESTIONS, h as ADDRESS_FIELD_WIDTHS, A as ADDRESS_FIELD_TYPES, V as generateDefaultOptions, W as MINIMUM_ADDRESS_FIELDS, X as getDeletedRecords, Z as randomId, _ as getActiveRecords, $ as FILE_TYPES_MAP, a0 as FILE_GROUPS, a1 as OPINION_SCALE_MIN_VALUE_OPTIONS, a2 as OPINION_SCALE_MAX_VALUE_OPTIONS, D as DEFAULT_CHOICE_QUESTION_ATTRIBUTES, a3 as MINIMUM_OPTIONS, a4 as IMAGE_HEIGHT_SLIDER_DEFAULTS, a5 as RATING_OPTIONS, a6 as STAR_RATING_MIN_VALUE_OPTIONS, a7 as STAR_RATING_MAX_VALUE_OPTIONS, a8 as STAR_RATING_ICONS_MAP, a9 as YES_NO_ICONS_MAP, aa as buildDisabledAddButtonHelpPopoverProps, ab as buildReorderPayload, ac as QUESTIONS_INITIAL_VALUE, ad as isMandatoryField, ae as QUESTION_KINDS, Q as QUESTION_KIND, af as getActiveQuestionKindDetails, ag as DEFAULT_AVAILABLE_LANGUAGES, ah as DEFAULT_ADVANCED_FEATURES } from './yup-DItlKUzb.js';
8
8
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
9
- import { useState, useRef, useEffect, createElement } from 'react';
9
+ import { createElement, useRef, useEffect, useState } 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/v2/react-utils';
12
12
  import { showThumbsUpToastr, withEventTargetValue, hyphenize } from '@bigbinary/neeto-commons-frontend/v2/utils';
@@ -265,11 +265,6 @@ var Card = function Card(_ref) {
265
265
  canManageQuestions = _ref.canManageQuestions,
266
266
  _ref$extraMenuItems = _ref.extraMenuItems,
267
267
  extraMenuItems = _ref$extraMenuItems === void 0 ? [] : _ref$extraMenuItems;
268
- var _useState = useState(false),
269
- _useState2 = _slicedToArray(_useState, 2),
270
- isTooltipEnabled = _useState2[0],
271
- setIsTooltipEnabled = _useState2[1];
272
- var questionLabelRef = useRef(null);
273
268
  var _useTranslation = useTranslation(),
274
269
  t = _useTranslation.t;
275
270
  var _getActiveKindDetails = getActiveKindDetails({
@@ -279,11 +274,6 @@ var Card = function Card(_ref) {
279
274
  isSingular = _getActiveKindDetails.isSingular,
280
275
  KindIcon = _getActiveKindDetails.icon;
281
276
  var questionLabel = buildDisplayLabel(question);
282
- useEffect(function () {
283
- var element = questionLabelRef.current;
284
- if (isNotPresent(element)) return;
285
- setIsTooltipEnabled(isElementOverflowing(element));
286
- }, [questionLabel]);
287
277
  return /*#__PURE__*/jsxs("div", {
288
278
  "data-testid": "neeto-form-engine-".concat(slugify(questionLabel)),
289
279
  className: classnames("border-border bg-card neeto-form-nano-form__card flex h-10 w-full items-center justify-between gap-2 overflow-hidden rounded-md border p-2", {
@@ -297,19 +287,12 @@ var Card = function Card(_ref) {
297
287
  children: [KindIcon && /*#__PURE__*/jsx(KindIcon, {
298
288
  className: "text-muted-foreground shrink-0",
299
289
  "data-testid": "question-card-kind-icon",
300
- size: 16
301
- }), /*#__PURE__*/jsx(Tooltip, {
302
- content: questionLabel,
303
- disabled: !isTooltipEnabled,
304
- position: "top",
305
- children: /*#__PURE__*/jsx(Typography, {
306
- className: "min-w-0 grow truncate",
307
- "data-testid": "".concat(slugify(questionLabel), "-question-card-label"),
308
- ref: questionLabelRef,
309
- variant: "body2",
310
- weight: "medium",
311
- children: questionLabel
312
- })
290
+ size: 20
291
+ }), /*#__PURE__*/jsx(Typography, {
292
+ className: "min-w-0 grow truncate",
293
+ "data-testid": "".concat(slugify(questionLabel), "-question-card-label"),
294
+ variant: "body2",
295
+ children: questionLabel
313
296
  })]
314
297
  }), canManageQuestions && /*#__PURE__*/jsx(MoreDropdown, {
315
298
  dropdownButtonProps: {
@@ -382,16 +365,16 @@ var Questions = function Questions(_ref) {
382
365
  var draggableProps = _ref3.draggableProps,
383
366
  dragHandleProps = _ref3.dragHandleProps,
384
367
  innerRef = _ref3.innerRef;
385
- return /*#__PURE__*/jsxs("div", _objectSpread$j(_objectSpread$j({}, draggableProps), {}, {
368
+ return /*#__PURE__*/jsxs("div", _objectSpread$j(_objectSpread$j(_objectSpread$j({}, draggableProps), dragHandleProps), {}, {
386
369
  className: "flex items-center gap-1",
387
370
  ref: innerRef,
388
- children: [canManageQuestions && /*#__PURE__*/jsx("span", _objectSpread$j(_objectSpread$j({}, dragHandleProps), {}, {
371
+ "data-testid": canManageQuestions ? "question-card-drag-handle" : undefined,
372
+ children: [canManageQuestions && /*#__PURE__*/jsx("span", {
389
373
  className: "text-muted-foreground hover:text-foreground shrink-0 cursor-grab transition-all duration-300 ease-in-out",
390
- "data-testid": "question-card-drag-handle",
391
374
  children: /*#__PURE__*/jsx(GripVertical, {
392
375
  size: 16
393
376
  })
394
- })), /*#__PURE__*/jsx("div", {
377
+ }), /*#__PURE__*/jsx("div", {
395
378
  className: "min-w-0 grow",
396
379
  children: /*#__PURE__*/jsx(Card, {
397
380
  allQuestionKinds: allQuestionKinds,
@@ -757,7 +740,7 @@ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
757
740
  t = _useTranslation.t;
758
741
  var shouldShowPlaceholder = includes(kind, QUESTIONS_WITH_PLACEHOLDERS);
759
742
  return /*#__PURE__*/jsxs("div", {
760
- className: "space-y-4",
743
+ className: "space-y-6",
761
744
  children: [/*#__PURE__*/jsx(FormikAdaptiveInput, _objectSpread$g({
762
745
  required: true,
763
746
  disabled: isLabelDisabled,
@@ -766,7 +749,6 @@ var LabelWithPlaceholder = function LabelWithPlaceholder(_ref) {
766
749
  placeholder: DEFAULT_PLACEHOLDERS[kind],
767
750
  onChange: withEventTargetValue(handleLabelChange)
768
751
  }, labelProps)), shouldShowPlaceholder && /*#__PURE__*/jsx(FormikAdaptiveInput, _objectSpread$g({
769
- className: "neeto-form-nano-placeholder-input neeto-form-nano-placeholder-input-".concat(kind),
770
752
  name: "placeholder",
771
753
  label: t("neetoForm.questions.common.questionFields.field.placeholder")
772
754
  }, placeholderProps))]
@@ -793,7 +775,7 @@ var Name = function Name(_ref) {
793
775
  children: [!usesCustomSubmissionComponent && /*#__PURE__*/jsx(Switch, {
794
776
  label: t("neetoForm.common.splitAsFirstAndLastNames"),
795
777
  name: "isSplitMode",
796
- size: "lg"
778
+ size: "default"
797
779
  }), isSplitMode && !usesCustomSubmissionComponent ? /*#__PURE__*/jsxs(Fragment, {
798
780
  children: [/*#__PURE__*/jsx(LabelWithPlaceholder, _objectSpread$f(_objectSpread$f({}, commonProps), {}, {
799
781
  handleLabelChange: function handleLabelChange(value) {
@@ -854,7 +836,7 @@ var Properties = function Properties(_ref) {
854
836
  });
855
837
  }
856
838
  return /*#__PURE__*/jsxs("div", {
857
- className: "space-y-4",
839
+ className: "space-y-6",
858
840
  children: [/*#__PURE__*/jsx(LabelWithPlaceholder, {
859
841
  handleLabelChange: handleLabelChange,
860
842
  isLabelDisabled: isLabelDisabled,
@@ -960,7 +942,7 @@ var RequiredSwitch = withT(function (_ref) {
960
942
  children: /*#__PURE__*/jsx(Switch, {
961
943
  label: t("neetoForm.common.required"),
962
944
  name: "isRequired",
963
- size: "lg"
945
+ size: "default"
964
946
  })
965
947
  });
966
948
  });
@@ -1030,7 +1012,7 @@ var Textarea = function Textarea() {
1030
1012
  checked: isMinWordsEnabled,
1031
1013
  label: t("neetoForm.questions.textarea.minimumWords"),
1032
1014
  labelProps: MIN_WORDS_SWITCH_LABEL_PROPS,
1033
- size: "lg",
1015
+ size: "default",
1034
1016
  onCheckedChange: handleToggleChange
1035
1017
  }), isMinWordsEnabled && /*#__PURE__*/jsx(Input, {
1036
1018
  className: "w-42 ms-14",
@@ -1176,7 +1158,7 @@ var Form$1 = function Form(_ref) {
1176
1158
  };
1177
1159
  return /*#__PURE__*/jsx(Sheet.Body, {
1178
1160
  children: /*#__PURE__*/jsxs("div", {
1179
- className: "w-full space-y-4",
1161
+ className: "w-full space-y-6",
1180
1162
  children: [/*#__PURE__*/jsx(Select, {
1181
1163
  isClearable: true,
1182
1164
  isSearchable: true,
@@ -1187,6 +1169,7 @@ var Form$1 = function Form(_ref) {
1187
1169
  isDisabled: isEdit,
1188
1170
  options: kindOptions,
1189
1171
  ref: initialFocusRef,
1172
+ size: "large",
1190
1173
  value: buildDefaultValueForKind(questionKind),
1191
1174
  label: t("neetoForm.questions.common.questionFields.field.questionType"),
1192
1175
  onChange: handleKindChange
@@ -1195,37 +1178,37 @@ var Form$1 = function Form(_ref) {
1195
1178
  isLabelDisabled: isLabelDisabled
1196
1179
  }), shouldShowRequiredSwitch && /*#__PURE__*/jsx(RequiredSwitch, {})]
1197
1180
  }) : /*#__PURE__*/jsxs("div", {
1198
- className: "space-y-4",
1181
+ className: "space-y-6",
1199
1182
  children: [/*#__PURE__*/jsx(Properties, {
1200
1183
  handleLabelChange: handleLabelChange,
1201
1184
  isLabelDisabled: isLabelDisabled,
1202
1185
  kind: kind,
1203
1186
  questionProps: questionProps
1204
1187
  }), isSettingsBlockVisible && /*#__PURE__*/jsxs("div", {
1205
- className: "space-y-4",
1188
+ className: "space-y-6",
1206
1189
  "data-testid": "settings-card",
1207
1190
  children: [isBasicSettingsVisible && /*#__PURE__*/jsxs(Fragment, {
1208
1191
  children: [shouldShowRequiredSwitch && /*#__PURE__*/jsx(RequiredSwitch, {}), shouldShowHideSwitch && /*#__PURE__*/jsx(Switch, {
1209
1192
  label: t("neetoForm.common.hideQuestion"),
1210
1193
  name: "isHidden",
1211
- size: "lg",
1194
+ size: "default",
1212
1195
  labelProps: hideSwitchLabelProps(hideQuestionHelpDocUrl)
1213
1196
  }), canRestrictResponseVisibilityToHost && /*#__PURE__*/jsx(Switch, {
1214
1197
  label: t("neetoForm.common.responseVisibleOnlyToHost"),
1215
1198
  name: "isResponseVisibleOnlyToHost",
1216
- size: "lg",
1199
+ size: "default",
1217
1200
  labelProps: responseVisibleOnlyToHostSwitchLabelProps(responseVisibleOnlyToHostHelpDocUrl)
1218
1201
  })]
1219
1202
  }), canMarkResponsesAsReadOnly && /*#__PURE__*/jsx(Switch, {
1220
1203
  label: t("neetoForm.common.readOnly"),
1221
1204
  labelProps: readOnlySwitchLabelProps(readOnlyHelpDocUrl),
1222
1205
  name: "isReadOnly",
1223
- size: "lg"
1206
+ size: "default"
1224
1207
  }), shouldShowSendSmsUpdatesSwitch && /*#__PURE__*/jsx(Switch, {
1225
1208
  disabled: isSmsUpdatesDisabled,
1226
1209
  label: t("neetoForm.common.sendSmsUpdates"),
1227
1210
  name: "sendSmsUpdates",
1228
- size: "lg",
1211
+ size: "default",
1229
1212
  labelProps: sendSmsUpdatesSwitchLabelProps(sendSmsUpdatesHelpDocUrl)
1230
1213
  }), isTextarea && enforceMinWordsInMultiLineTexts && /*#__PURE__*/jsx(Textarea, {})]
1231
1214
  }), shouldShowFieldCode && /*#__PURE__*/jsx(Accordion, {
@@ -1236,7 +1219,7 @@ var Form$1 = function Form(_ref) {
1236
1219
  children: /*#__PURE__*/jsx(Accordion.Item, {
1237
1220
  title: t("neetoForm.common.advancedProperties"),
1238
1221
  children: /*#__PURE__*/jsx("div", {
1239
- className: "flex flex-col space-y-4",
1222
+ className: "flex flex-col space-y-6",
1240
1223
  children: shouldShowFieldCode && /*#__PURE__*/jsx(FieldCode, {})
1241
1224
  })
1242
1225
  })
@@ -1503,7 +1486,7 @@ var Block = function Block(_ref) {
1503
1486
  children: title
1504
1487
  })
1505
1488
  }), /*#__PURE__*/jsx("div", {
1506
- className: "space-y-4",
1489
+ className: "space-y-6",
1507
1490
  children: children
1508
1491
  })]
1509
1492
  });
@@ -1730,7 +1713,7 @@ var ManagePane = function ManagePane(_ref) {
1730
1713
  children: /*#__PURE__*/jsx(Switch, {
1731
1714
  label: t("neetoForm.common.required"),
1732
1715
  name: "isRequired",
1733
- size: "lg"
1716
+ size: "default"
1734
1717
  })
1735
1718
  })]
1736
1719
  })
@@ -1893,7 +1876,7 @@ var SwitchBlock = function SwitchBlock(_ref) {
1893
1876
  className: classnames("flex items-center justify-start gap-2 ", className),
1894
1877
  "data-testid": "neeto-form-engine-".concat(hyphenate(title && name), "-toggle-label"),
1895
1878
  children: [/*#__PURE__*/jsx(Switch, _objectSpread$7(_objectSpread$7({
1896
- size: "lg"
1879
+ size: "default"
1897
1880
  }, _objectSpread$7(_objectSpread$7({}, otherProps), {}, {
1898
1881
  name: name
1899
1882
  })), {}, {
@@ -2266,7 +2249,7 @@ var VerifyEmails = function VerifyEmails() {
2266
2249
  label: title,
2267
2250
  labelProps: buildHelpPopoverLabelProps(popoverDescription, helpLink),
2268
2251
  name: "isVerificationEnabled",
2269
- size: "lg"
2252
+ size: "default"
2270
2253
  })
2271
2254
  });
2272
2255
  };
@@ -2280,7 +2263,7 @@ var Email = function Email(_ref) {
2280
2263
  _useFormikContext$val3 = _useFormikContext$val.isDomainBlacklistingEnabled,
2281
2264
  isDomainBlacklistingEnabled = _useFormikContext$val3 === void 0 ? false : _useFormikContext$val3;
2282
2265
  return /*#__PURE__*/jsx("div", {
2283
- className: "flex flex-col space-y-4",
2266
+ className: "flex flex-col space-y-6",
2284
2267
  children: !usesCustomSubmissionComponent && /*#__PURE__*/jsxs(Fragment, {
2285
2268
  children: [/*#__PURE__*/jsx(RestrictDomainsBlock, {
2286
2269
  domainName: "whitelistedDomains",
@@ -2411,7 +2394,7 @@ var OpinionScale = function OpinionScale() {
2411
2394
  "data-testid": "neeto-form-engine-opinion-scale-show-labels-switch",
2412
2395
  label: t("neetoForm.questions.opinionScale.showLabels"),
2413
2396
  name: "hasOpinionLabels",
2414
- size: "lg"
2397
+ size: "default"
2415
2398
  }), hasOpinionLabels && /*#__PURE__*/jsxs("div", {
2416
2399
  className: "flex space-x-4",
2417
2400
  children: [/*#__PURE__*/jsx(Input, {
@@ -2511,12 +2494,12 @@ var Options = function Options(_ref) {
2511
2494
  className: "space-y-4",
2512
2495
  children: [/*#__PURE__*/jsx(Switch, {
2513
2496
  name: "isPictureChoice",
2514
- size: "lg",
2497
+ size: "default",
2515
2498
  label: t("neetoForm.questions.common.questionFields.field.addPicturesToOptions")
2516
2499
  }), isPictureChoice && /*#__PURE__*/jsxs(Fragment, {
2517
2500
  children: [/*#__PURE__*/jsx(Switch, {
2518
2501
  name: "shouldFitImages",
2519
- size: "lg",
2502
+ size: "default",
2520
2503
  label: t("neetoForm.questions.common.questionFields.field.fitImages"),
2521
2504
  labelProps: {
2522
2505
  helpIconProps: {
@@ -2865,6 +2848,7 @@ var ManageQuestionPane = function ManageQuestionPane(_ref) {
2865
2848
  initialFocusRef: initialFocusRef,
2866
2849
  isOpen: isOpen,
2867
2850
  onClose: onClose,
2851
+ size: "large",
2868
2852
  children: /*#__PURE__*/jsx(Component, _objectSpread$1({}, _objectSpread$1({
2869
2853
  availableQuestionKinds: availableQuestionKinds,
2870
2854
  initialFocusRef: initialFocusRef,
@@ -3017,6 +3001,15 @@ var Form = function Form(_ref) {
3017
3001
  setSelectedAction(QUESTION_ACTIONS.EDIT);
3018
3002
  setIsManageQuestionPaneOpen(true);
3019
3003
  };
3004
+
3005
+ // The embeddable builder has no inline properties panel, so a bare card click
3006
+ // would only highlight the question. Open the edit pane on click so the
3007
+ // interaction has a purpose (drag still reorders — @hello-pangea/dnd
3008
+ // separates click from drag). Falls back to select-only when questions are
3009
+ // not manageable, so read-only consumers are unaffected.
3010
+ var handleQuestionClick = function handleQuestionClick(question) {
3011
+ return canManageQuestions ? handleEdit(question) : handleSelect(question);
3012
+ };
3020
3013
  var handleClone = function handleClone(question) {
3021
3014
  var values = duplicateFieldData({
3022
3015
  item: question,
@@ -3121,7 +3114,7 @@ var Form = function Form(_ref) {
3121
3114
  onClone: handleClone,
3122
3115
  onDelete: handleDelete,
3123
3116
  onEdit: handleEdit,
3124
- onSelect: handleSelect
3117
+ onSelect: handleQuestionClick
3125
3118
  })
3126
3119
  }), canManageQuestions && /*#__PURE__*/jsx("div", {
3127
3120
  className: "mb-8 flex w-full items-center gap-x-1",