optimized-react-component-library-xyz123 2.13.1 → 2.14.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.
package/dist/index.mjs CHANGED
@@ -24,6 +24,22 @@ var ValidationMessage = ({
24
24
  };
25
25
  var ValidationMessage_default = ValidationMessage;
26
26
 
27
+ // src/helpers/setPreviewAnswerLabel/setPreviewAnswerLabel.ts
28
+ var setPreviewAnswerLabel = (question, activatedLanguage) => {
29
+ var _a;
30
+ if ((question == null ? void 0 : question.answer) && question.answer.length > 0) {
31
+ const language = question.languageSupport.find((lang) => lang.language === activatedLanguage);
32
+ if (language && setPreviewAnswerLabel.length > 0) {
33
+ const answerOption = language.options.find(
34
+ (option) => option.value === question.answer
35
+ );
36
+ return (_a = answerOption.label) != null ? _a : "";
37
+ }
38
+ }
39
+ return "";
40
+ };
41
+ var setPreviewAnswerLabel_default = setPreviewAnswerLabel;
42
+
27
43
  // src/components/input-components/RadioMultipleStandard/RadioMultipleStandard.tsx
28
44
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
29
45
  var InputRadio = ({
@@ -87,9 +103,10 @@ var RadioMultipleStandard_default = InputRadio;
87
103
  var PreviewRadio = ({ question, activatedLanguage }) => {
88
104
  var _a, _b;
89
105
  const previewId = `preview-${question.id}`;
106
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
90
107
  return /* @__PURE__ */ jsxs2(Fragment, { children: [
91
108
  /* @__PURE__ */ jsx2("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
92
- ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ jsx2("dd", { className: "pts-radioMultiple-preview pts-root-answer", id: `answer-${previewId}`, children: question.answer }) : /* @__PURE__ */ jsx2(
109
+ ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ jsx2("dd", { className: "pts-radioMultiple-preview pts-root-answer", id: `answer-${previewId}`, children: questionAnswer.length > 0 ? questionAnswer : question.answer }) : /* @__PURE__ */ jsx2(
93
110
  "dd",
94
111
  {
95
112
  className: "pts-radioMultiple-preview pts-root-answer no-answer-preview-page",
@@ -2185,13 +2202,14 @@ var RadioWithInfo = ({
2185
2202
  ]
2186
2203
  }
2187
2204
  ) }),
2188
- showPreview && /* @__PURE__ */ jsx21(PreviewRadio2, { question })
2205
+ showPreview && /* @__PURE__ */ jsx21(PreviewRadio2, { question, activatedLanguage })
2189
2206
  ] });
2190
2207
  };
2191
2208
  var RadioMultipleWithInfoStandard_default = RadioWithInfo;
2192
- var PreviewRadio2 = ({ question }) => {
2209
+ var PreviewRadio2 = ({ question, activatedLanguage }) => {
2193
2210
  var _a, _b;
2194
2211
  const previewId = `preview-${question.id}`;
2212
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
2195
2213
  return /* @__PURE__ */ jsxs17(Fragment14, { children: [
2196
2214
  /* @__PURE__ */ jsx21("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
2197
2215
  ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ jsx21(
@@ -2199,7 +2217,7 @@ var PreviewRadio2 = ({ question }) => {
2199
2217
  {
2200
2218
  className: "pts-radioMultipleWithInfo2-preview pts-root-answer",
2201
2219
  id: `answer-${previewId}`,
2202
- children: question.answer
2220
+ children: questionAnswer.length > 0 ? questionAnswer : question.answer
2203
2221
  }
2204
2222
  ) : /* @__PURE__ */ jsx21(
2205
2223
  "dd",
@@ -2338,16 +2356,17 @@ var CustomDropdownStandard = ({
2338
2356
  ),
2339
2357
  hasOptionInfoText && /* @__PURE__ */ jsx23(OptionTextBody_default, { ...optionTextProps })
2340
2358
  ] }),
2341
- showPreview && /* @__PURE__ */ jsx23(PreviewDropdown, { question })
2359
+ showPreview && /* @__PURE__ */ jsx23(PreviewDropdown, { question, activatedLanguage })
2342
2360
  ] });
2343
2361
  };
2344
2362
  var DropdownStandard_default = CustomDropdownStandard;
2345
- var PreviewDropdown = ({ question, activatedLanguage = "sv" }) => {
2363
+ var PreviewDropdown = ({ question, activatedLanguage }) => {
2346
2364
  var _a, _b;
2347
2365
  const previewId = `preview-${question.id}`;
2366
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
2348
2367
  return /* @__PURE__ */ jsxs19(Fragment16, { children: [
2349
2368
  /* @__PURE__ */ jsx23("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
2350
- ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ jsx23("dd", { className: "pts-dropdown-preview pts-root-answer", id: `answer-${previewId}`, children: question.answer }) : /* @__PURE__ */ jsx23(
2369
+ ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ jsx23("dd", { className: "pts-dropdown-preview pts-root-answer", id: `answer-${previewId}`, children: questionAnswer.length > 0 ? questionAnswer : question.answer }) : /* @__PURE__ */ jsx23(
2351
2370
  "dd",
2352
2371
  {
2353
2372
  className: "pts-dropdown-preview pts-root-answer no-answer-preview-page",
@@ -3106,7 +3125,8 @@ var QuestionRenderer = ({
3106
3125
  {
3107
3126
  question,
3108
3127
  handleQuestionInputChange,
3109
- showPreview
3128
+ showPreview,
3129
+ activatedLanguage
3110
3130
  }
3111
3131
  ),
3112
3132
  question.questionType === "RadioWithInfo" && /* @__PURE__ */ jsx24(
@@ -3114,7 +3134,8 @@ var QuestionRenderer = ({
3114
3134
  {
3115
3135
  question,
3116
3136
  handleQuestionInputChange,
3117
- showPreview
3137
+ showPreview,
3138
+ activatedLanguage
3118
3139
  }
3119
3140
  ),
3120
3141
  question.questionType === "TextField" && /* @__PURE__ */ jsx24(
@@ -3168,7 +3189,8 @@ var QuestionRenderer = ({
3168
3189
  {
3169
3190
  question,
3170
3191
  handleQuestionInputChange,
3171
- showPreview
3192
+ showPreview,
3193
+ activatedLanguage
3172
3194
  }
3173
3195
  ),
3174
3196
  question.questionType === "InfoOnly" && /* @__PURE__ */ jsx24(