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.js CHANGED
@@ -112,6 +112,22 @@ var ValidationMessage = ({
112
112
  };
113
113
  var ValidationMessage_default = ValidationMessage;
114
114
 
115
+ // src/helpers/setPreviewAnswerLabel/setPreviewAnswerLabel.ts
116
+ var setPreviewAnswerLabel = (question, activatedLanguage) => {
117
+ var _a;
118
+ if ((question == null ? void 0 : question.answer) && question.answer.length > 0) {
119
+ const language = question.languageSupport.find((lang) => lang.language === activatedLanguage);
120
+ if (language && setPreviewAnswerLabel.length > 0) {
121
+ const answerOption = language.options.find(
122
+ (option) => option.value === question.answer
123
+ );
124
+ return (_a = answerOption.label) != null ? _a : "";
125
+ }
126
+ }
127
+ return "";
128
+ };
129
+ var setPreviewAnswerLabel_default = setPreviewAnswerLabel;
130
+
115
131
  // src/components/input-components/RadioMultipleStandard/RadioMultipleStandard.tsx
116
132
  var import_jsx_runtime2 = require("react/jsx-runtime");
117
133
  var InputRadio = ({
@@ -175,9 +191,10 @@ var RadioMultipleStandard_default = InputRadio;
175
191
  var PreviewRadio = ({ question, activatedLanguage }) => {
176
192
  var _a, _b;
177
193
  const previewId = `preview-${question.id}`;
194
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
178
195
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
179
196
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
180
- ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { className: "pts-radioMultiple-preview pts-root-answer", id: `answer-${previewId}`, children: question.answer }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
197
+ ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { className: "pts-radioMultiple-preview pts-root-answer", id: `answer-${previewId}`, children: questionAnswer.length > 0 ? questionAnswer : question.answer }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
181
198
  "dd",
182
199
  {
183
200
  className: "pts-radioMultiple-preview pts-root-answer no-answer-preview-page",
@@ -2273,13 +2290,14 @@ var RadioWithInfo = ({
2273
2290
  ]
2274
2291
  }
2275
2292
  ) }),
2276
- showPreview && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PreviewRadio2, { question })
2293
+ showPreview && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PreviewRadio2, { question, activatedLanguage })
2277
2294
  ] });
2278
2295
  };
2279
2296
  var RadioMultipleWithInfoStandard_default = RadioWithInfo;
2280
- var PreviewRadio2 = ({ question }) => {
2297
+ var PreviewRadio2 = ({ question, activatedLanguage }) => {
2281
2298
  var _a, _b;
2282
2299
  const previewId = `preview-${question.id}`;
2300
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
2283
2301
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
2284
2302
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
2285
2303
  ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -2287,7 +2305,7 @@ var PreviewRadio2 = ({ question }) => {
2287
2305
  {
2288
2306
  className: "pts-radioMultipleWithInfo2-preview pts-root-answer",
2289
2307
  id: `answer-${previewId}`,
2290
- children: question.answer
2308
+ children: questionAnswer.length > 0 ? questionAnswer : question.answer
2291
2309
  }
2292
2310
  ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2293
2311
  "dd",
@@ -2426,16 +2444,17 @@ var CustomDropdownStandard = ({
2426
2444
  ),
2427
2445
  hasOptionInfoText && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(OptionTextBody_default, { ...optionTextProps })
2428
2446
  ] }),
2429
- showPreview && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PreviewDropdown, { question })
2447
+ showPreview && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PreviewDropdown, { question, activatedLanguage })
2430
2448
  ] });
2431
2449
  };
2432
2450
  var DropdownStandard_default = CustomDropdownStandard;
2433
- var PreviewDropdown = ({ question, activatedLanguage = "sv" }) => {
2451
+ var PreviewDropdown = ({ question, activatedLanguage }) => {
2434
2452
  var _a, _b;
2435
2453
  const previewId = `preview-${question.id}`;
2454
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
2436
2455
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
2437
2456
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
2438
- ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("dd", { className: "pts-dropdown-preview pts-root-answer", id: `answer-${previewId}`, children: question.answer }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2457
+ ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("dd", { className: "pts-dropdown-preview pts-root-answer", id: `answer-${previewId}`, children: questionAnswer.length > 0 ? questionAnswer : question.answer }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2439
2458
  "dd",
2440
2459
  {
2441
2460
  className: "pts-dropdown-preview pts-root-answer no-answer-preview-page",
@@ -3191,7 +3210,8 @@ var QuestionRenderer = ({
3191
3210
  {
3192
3211
  question,
3193
3212
  handleQuestionInputChange,
3194
- showPreview
3213
+ showPreview,
3214
+ activatedLanguage
3195
3215
  }
3196
3216
  ),
3197
3217
  question.questionType === "RadioWithInfo" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
@@ -3199,7 +3219,8 @@ var QuestionRenderer = ({
3199
3219
  {
3200
3220
  question,
3201
3221
  handleQuestionInputChange,
3202
- showPreview
3222
+ showPreview,
3223
+ activatedLanguage
3203
3224
  }
3204
3225
  ),
3205
3226
  question.questionType === "TextField" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
@@ -3253,7 +3274,8 @@ var QuestionRenderer = ({
3253
3274
  {
3254
3275
  question,
3255
3276
  handleQuestionInputChange,
3256
- showPreview
3277
+ showPreview,
3278
+ activatedLanguage
3257
3279
  }
3258
3280
  ),
3259
3281
  question.questionType === "InfoOnly" && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(