@bigbinary/neeto-form-frontend 4.4.34 → 4.4.35

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/.ready CHANGED
@@ -1 +1 @@
1
- Built at 2026-07-20T16:34:28.469Z
1
+ Built at 2026-07-21T08:17:59.013Z
@@ -368,13 +368,17 @@ var Card = function Card(_ref) {
368
368
  "data-testid": "edit-question",
369
369
  key: "edit",
370
370
  label: t("neetoForm.common.edit"),
371
- onClick: onEdit
371
+ onClick: function onClick() {
372
+ return onEdit(question);
373
+ }
372
374
  }, {
373
375
  "data-testid": "clone-question",
374
376
  key: "clone",
375
377
  label: t("neetoForm.common.clone"),
376
378
  isVisible: !isSingular && yup.isFunction(onClone),
377
- onClick: onClone
379
+ onClick: function onClick() {
380
+ return onClone(question);
381
+ }
378
382
  }].concat(_toConsumableArray(extraMenuItems), [{
379
383
  "data-testid": "delete-question",
380
384
  key: "delete",
@@ -1131,6 +1135,7 @@ var Form$1 = function Form(_ref) {
1131
1135
  isSmsUpdatesEnabledByDefault = advancedFeatures.smsUpdatesEnabledByDefault;
1132
1136
  var kind = values.kind;
1133
1137
  var questionKinds = isEdit ? allQuestionKinds : availableQuestionKinds;
1138
+ var kindOptions = buildKindOptions(questionKinds);
1134
1139
  var questionKindUniquenessPattern = ramda.mergeLeft(isEdit && kindUniqueOn ? kindUniqueOn(values) : {}, {
1135
1140
  type: kind
1136
1141
  });
@@ -1160,16 +1165,22 @@ var Form$1 = function Form(_ref) {
1160
1165
  var isBasicSettingsVisible = !isRequired && (!isImmutable || shouldShowHideSwitch);
1161
1166
  var shouldShowRequiredSwitch = isBasicSettingsVisible && !isImmutable && !ramda.includes(kind, [constants.QUESTION_TYPES.PARAGRAPH, constants.QUESTION_TYPES.ADDRESS, constants.QUESTION_TYPES.SPOT]);
1162
1167
  var isSettingsBlockVisible = kind !== constants.QUESTION_TYPES.SPOT && (isBasicSettingsVisible || canMarkResponsesAsReadOnly || isTextarea || shouldShowSendSmsUpdatesSwitch);
1163
- var handleKindChange = function handleKindChange(option) {
1164
- var data = buildQuestionData(option);
1168
+ var handleKindChange = function handleKindChange(value) {
1169
+ var data = buildQuestionData(value);
1165
1170
  updateFormState(data);
1166
1171
  };
1167
- var buildQuestionData = function buildQuestionData(option) {
1168
- if (ramda.isNil(option)) {
1172
+
1173
+ // atoms Select reports the option's value, not the option object, and
1174
+ // clears to "" rather than null.
1175
+ var buildQuestionData = function buildQuestionData(value) {
1176
+ var _findBy;
1177
+ if (neetoCist.isNotPresent(value)) {
1169
1178
  return INITIAL_VALUES;
1170
1179
  }
1171
- var label = option.label,
1172
- value = option.value;
1180
+ var _ref3 = (_findBy = neetoCist.findBy({
1181
+ value: value
1182
+ }, kindOptions)) !== null && _findBy !== void 0 ? _findBy : {},
1183
+ label = _ref3.label;
1173
1184
  var kind = extractKindFromOption(value);
1174
1185
  var questionKind = getQuestionKind(availableQuestionKinds, {
1175
1186
  type: kind,
@@ -1206,19 +1217,17 @@ var Form$1 = function Form(_ref) {
1206
1217
  return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Sheet.Body, {
1207
1218
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1208
1219
  className: "w-full space-y-4",
1209
- children: [/*#__PURE__*/jsxRuntime.jsx(formik$1.Select, {
1220
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Select, {
1210
1221
  isClearable: true,
1211
1222
  isSearchable: true,
1212
- defaultValue: buildDefaultValueForKind(questionKind),
1213
- filterOption: filterKindOption,
1214
- innerRef: initialFocusRef,
1215
- isDisabled: isEdit,
1216
- name: "kind",
1217
- options: buildKindOptions(questionKinds),
1218
- formatOptionLabel: function formatOptionLabel(option, _ref3) {
1219
- var context = _ref3.context;
1220
- return context === "menu" ? /*#__PURE__*/jsxRuntime.jsx(KindOption, _objectSpread$d({}, option)) : option.label;
1223
+ formatOptionLabel: function formatOptionLabel(option) {
1224
+ return /*#__PURE__*/jsxRuntime.jsx(KindOption, _objectSpread$d({}, option));
1221
1225
  },
1226
+ formatTriggerLabel: ramda.prop("label"),
1227
+ isDisabled: isEdit,
1228
+ options: kindOptions,
1229
+ ref: initialFocusRef,
1230
+ value: buildDefaultValueForKind(questionKind),
1222
1231
  label: t("neetoForm.questions.common.questionFields.field.questionType"),
1223
1232
  onChange: handleKindChange
1224
1233
  }), yup.isRichTextQuestion(kind) ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -1498,6 +1507,9 @@ var Edit = function Edit(_ref) {
1498
1507
  })
1499
1508
  }), /*#__PURE__*/jsxRuntime.jsx(formik$1.Form, {
1500
1509
  formikProps: {
1510
+ // Sheet keeps children mounted, so this renders once before a
1511
+ // question is selected; without this those empty values stick.
1512
+ enableReinitialize: true,
1501
1513
  initialValues: _objectSpread$b(_objectSpread$b({}, question), {}, {
1502
1514
  isMinWordsEnabled: neetoCist.isPresent(question.minWords)
1503
1515
  }),
@@ -2748,20 +2760,11 @@ var buildKindOptions = function buildKindOptions(kinds) {
2748
2760
  };
2749
2761
  });
2750
2762
  };
2751
- var filterKindOption = function filterKindOption(option, rawInput) {
2752
- var _option$data$searchTe, _option$data;
2753
- var query = rawInput === null || rawInput === void 0 ? void 0 : rawInput.trim().toLowerCase();
2754
- if (!query) return true;
2755
- var searchTerms = (_option$data$searchTe = (_option$data = option.data) === null || _option$data === void 0 ? void 0 : _option$data.searchTerms) !== null && _option$data$searchTe !== void 0 ? _option$data$searchTe : [];
2756
- return searchTerms.some(function (term) {
2757
- return term.includes(query);
2758
- });
2759
- };
2760
2763
  var extractKindFromOption = ramda.pipe(ramda.split("-"), ramda.last);
2764
+
2765
+ // atoms Select takes a scalar value, not a `{ value }` object.
2761
2766
  var buildDefaultValueForKind = function buildDefaultValueForKind(questionKind) {
2762
- return neetoCist.isPresent(questionKind) ? {
2763
- value: transformValueForOption(questionKind)
2764
- } : undefined;
2767
+ return neetoCist.isPresent(questionKind) ? transformValueForOption(questionKind) : undefined;
2765
2768
  };
2766
2769
  var hideSwitchLabelProps = function hideSwitchLabelProps(helpUrl) {
2767
2770
  return helpUrl ? {
@@ -3004,17 +3007,21 @@ var Form = function Form(_ref) {
3004
3007
  setSelectedAction(yup.QUESTION_ACTIONS.ADD);
3005
3008
  setIsManageQuestionPaneOpen(true);
3006
3009
  };
3007
- var handleEdit = function handleEdit() {
3010
+
3011
+ // The dropdown menu portals out of the card, so its clicks never reach the
3012
+ // card's onClick — actions take the question rather than the selected one.
3013
+ var handleEdit = function handleEdit(question) {
3014
+ setSelectedQuestion(question);
3008
3015
  setSelectedAction(yup.QUESTION_ACTIONS.EDIT);
3009
3016
  setIsManageQuestionPaneOpen(true);
3010
3017
  };
3011
- var handleClone = function handleClone() {
3018
+ var handleClone = function handleClone(question) {
3012
3019
  var values = duplicateFieldData({
3013
- item: selectedQuestion,
3020
+ item: question,
3014
3021
  questionKinds: availableQuestionKinds,
3015
3022
  questions: questions
3016
3023
  });
3017
- var displayOrder = selectedQuestion.displayOrder + 1;
3024
+ var displayOrder = question.displayOrder + 1;
3018
3025
  var attributes = ramda.mergeLeft({
3019
3026
  displayOrder: displayOrder
3020
3027
  }, values);