optimized-react-component-library-xyz123 0.23.4 → 0.23.6

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.d.mts CHANGED
@@ -118,6 +118,7 @@ interface RadioProps {
118
118
  question: IQuestion;
119
119
  handleQuestionInputChange: any;
120
120
  showPreview?: boolean;
121
+ activatedLanguage?: string;
121
122
  }
122
123
 
123
124
  declare const InputRadio: FC<RadioProps>;
package/dist/index.d.ts CHANGED
@@ -118,6 +118,7 @@ interface RadioProps {
118
118
  question: IQuestion;
119
119
  handleQuestionInputChange: any;
120
120
  showPreview?: boolean;
121
+ activatedLanguage?: string;
121
122
  }
122
123
 
123
124
  declare const InputRadio: FC<RadioProps>;
package/dist/index.js CHANGED
@@ -83,26 +83,27 @@ module.exports = __toCommonJS(index_exports);
83
83
  // src/components/input-components/InfoTextStandard/InfoTextStandard.tsx
84
84
  var import_dompurify = __toESM(require("dompurify"));
85
85
  var import_jsx_runtime = require("react/jsx-runtime");
86
- var InfoTextStandard = ({ text, value, questionId, activatedLanguage, showPreview, showText }) => {
87
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
88
- !showPreview && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
89
- "div",
90
- {
91
- id: questionId,
92
- className: "pts-root-question pts-infoTextdStandard-container",
93
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
+ var InfoTextStandard = ({ infoText, selectedValue, questionId, activatedLanguage }) => {
87
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
+ "div",
89
+ {
90
+ id: `textinfo-${questionId}-${selectedValue}`,
91
+ "aria-live": "polite",
92
+ "aria-atomic": "true",
93
+ children: infoText.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { id: questionId, className: "pts-root-question pts-infoTextdStandard-container", children: [
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "sr-only", children: activatedLanguage === "en" ? `Information about selected alternative - ${selectedValue}` : `Information om valt alternativ - ${selectedValue}` }),
95
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
96
  "div",
95
97
  {
96
98
  id: questionId,
97
99
  dangerouslySetInnerHTML: {
98
- __html: import_dompurify.default.sanitize(text != null ? text : "")
100
+ __html: import_dompurify.default.sanitize(infoText != null ? infoText : "")
99
101
  }
100
102
  }
101
103
  )
102
- }
103
- ),
104
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {})
105
- ] });
104
+ ] })
105
+ }
106
+ );
106
107
  };
107
108
  var InfoTextStandard_default = InfoTextStandard;
108
109
 
@@ -111,25 +112,22 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
111
112
  var InputRadio = ({
112
113
  question,
113
114
  handleQuestionInputChange,
114
- showPreview = false
115
+ showPreview = false,
116
+ activatedLanguage = "sv"
115
117
  }) => {
116
118
  var _a, _b, _c, _d;
117
119
  const questionId = `question-${question.id}`;
118
120
  const groupId = `radio-group-${question.id}`;
119
121
  const errorId = `error-${question.id}`;
122
+ const handleInputChange = (event) => {
123
+ const e = { target: { value: event.target.value } };
124
+ handleQuestionInputChange(e, question);
125
+ };
120
126
  const languageObj = question.languageSupport[0];
121
127
  var optionsInfoText = [];
122
128
  if ("optionsInfoText" in languageObj) {
123
129
  optionsInfoText = languageObj.optionsInfoText;
124
- console.log(languageObj.optionsInfoText, "q", optionsInfoText, question);
125
130
  }
126
- console.log((_a = optionsInfoText.find(
127
- (op) => op.value === question.answer
128
- )) == null ? void 0 : _a.text, question.answer);
129
- const handleInputChange = (event) => {
130
- const e = { target: { value: event.target.value } };
131
- handleQuestionInputChange(e, question);
132
- };
133
131
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
134
132
  !showPreview && question.visible && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "pts-root-question pts-radioMultiple-container", id: questionId, children: [
135
133
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -144,7 +142,7 @@ var InputRadio = ({
144
142
  " ",
145
143
  question.isQuestionMandatory && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-hidden": true, className: "pts-root-mandatoryAsterisk", children: "*" })
146
144
  ] }),
147
- (_b = question.options) == null ? void 0 : _b.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "pts-radio-option", children: [
145
+ (_a = question.options) == null ? void 0 : _a.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "pts-radio-option", children: [
148
146
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
149
147
  "input",
150
148
  {
@@ -153,8 +151,7 @@ var InputRadio = ({
153
151
  id: `${groupId}-option-${index}`,
154
152
  value: option.value,
155
153
  checked: question.answer === option.value,
156
- onChange: handleInputChange,
157
- "aria-describedby": "about_" + option.value
154
+ onChange: handleInputChange
158
155
  }
159
156
  ),
160
157
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: `${groupId}-option-${index}`, children: option.label }),
@@ -169,23 +166,12 @@ var InputRadio = ({
169
166
  }
170
167
  ),
171
168
  optionsInfoText.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
172
- "div",
169
+ InfoTextStandard_default,
173
170
  {
174
- id: "textinfo-option3",
175
- "aria-live": "polite",
176
- "aria-atomic": "true",
177
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
178
- InfoTextStandard_default,
179
- {
180
- text: (_d = (_c = optionsInfoText.find(
181
- (op) => op.value === question.answer
182
- )) == null ? void 0 : _c.text) != null ? _d : "",
183
- value: "",
184
- showPreview: false,
185
- questionId,
186
- showText: true
187
- }
188
- )
171
+ infoText: (_c = (_b = optionsInfoText.find((op) => op.selectedValue === question.answer)) == null ? void 0 : _b.infoText) != null ? _c : "",
172
+ selectedValue: (_d = question.answer) != null ? _d : "",
173
+ questionId,
174
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
189
175
  }
190
176
  )
191
177
  ] }),