optimized-react-component-library-xyz123 2.11.1 → 2.12.2

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 = "sv") => {
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",
@@ -2270,9 +2287,10 @@ var RadioWithInfo = ({
2270
2287
  ] });
2271
2288
  };
2272
2289
  var RadioMultipleWithInfo2Standard_default = RadioWithInfo;
2273
- var PreviewRadio2 = ({ question }) => {
2290
+ var PreviewRadio2 = ({ question, activatedLanguage = "sv" }) => {
2274
2291
  var _a, _b;
2275
2292
  const previewId = `preview-${question.id}`;
2293
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
2276
2294
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
2277
2295
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
2278
2296
  ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -2280,7 +2298,7 @@ var PreviewRadio2 = ({ question }) => {
2280
2298
  {
2281
2299
  className: "pts-radioMultipleWithInfo2-preview pts-root-answer",
2282
2300
  id: `answer-${previewId}`,
2283
- children: question.answer
2301
+ children: questionAnswer.length > 0 ? questionAnswer : question.answer
2284
2302
  }
2285
2303
  ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2286
2304
  "dd",
@@ -2426,9 +2444,10 @@ var DropdownStandard_default = CustomDropdownStandard;
2426
2444
  var PreviewDropdown = ({ question, activatedLanguage = "sv" }) => {
2427
2445
  var _a, _b;
2428
2446
  const previewId = `preview-${question.id}`;
2447
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
2429
2448
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
2430
2449
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
2431
- ((_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)(
2450
+ ((_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)(
2432
2451
  "dd",
2433
2452
  {
2434
2453
  className: "pts-dropdown-preview pts-root-answer no-answer-preview-page",