optimized-react-component-library-xyz123 2.8.20 → 2.8.22

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
@@ -1897,9 +1897,12 @@ import { jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
1897
1897
  var AlertInTextStandard = ({ content = "" }) => {
1898
1898
  return /* @__PURE__ */ jsxs14("div", { className: "pts-alertInText-container", children: [
1899
1899
  /* @__PURE__ */ jsx17("div", { className: "pts-alertInText-left", children: /* @__PURE__ */ jsx17(AlertInTextIcon, {}) }),
1900
- /* @__PURE__ */ jsx17("div", { className: "pts-alertInText-right", role: "note", children: /* @__PURE__ */ jsx17("div", { dangerouslySetInnerHTML: {
1901
- __html: DOMPurify5.sanitize(content, { ALLOWED_ATTR: ["style", "target", "href"] })
1902
- } }) })
1900
+ /* @__PURE__ */ jsx17("div", { className: "pts-alertInText-right", role: "note", children: /<\/?[a-z][\s\S]*>/i.test(content) ? /* @__PURE__ */ jsx17(
1901
+ "div",
1902
+ {
1903
+ dangerouslySetInnerHTML: { __html: DOMPurify5.sanitize(content) }
1904
+ }
1905
+ ) : /* @__PURE__ */ jsx17("p", { children: content }) })
1903
1906
  ] });
1904
1907
  };
1905
1908
  var AlertInTextStandard_default = AlertInTextStandard;
@@ -2208,28 +2211,60 @@ var getInfoTextConnectionList = (questionLanguageSupport, language) => {
2208
2211
  var _a, _b;
2209
2212
  return (_b = (_a = questionLanguageSupport.find((item) => (item == null ? void 0 : item.language) === language)) == null ? void 0 : _a.optionsInfoText) != null ? _b : [];
2210
2213
  };
2214
+ var setOptionTextBodyProps = (question, activatedLanguage, questionId, errorId) => {
2215
+ var _a, _b, _c, _d;
2216
+ const infoTextId = `infotext-${questionId}`;
2217
+ const optionsInfoText = getInfoTextConnectionList(
2218
+ question.languageSupport,
2219
+ activatedLanguage
2220
+ );
2221
+ const selectedInfo = optionsInfoText.find(
2222
+ (option) => option.selectedValue === question.answer
2223
+ );
2224
+ const selectedLabel = (_c = (_b = (_a = question.options) == null ? void 0 : _a.find(
2225
+ (option) => option.value === question.answer
2226
+ )) == null ? void 0 : _b.label) != null ? _c : "";
2227
+ const hasOptionInfoText = !!(selectedInfo == null ? void 0 : selectedInfo.infoText);
2228
+ const describedBy = [
2229
+ question.hasValidationError ? errorId : null,
2230
+ hasOptionInfoText ? infoTextId : null
2231
+ ].filter(Boolean).join(" ");
2232
+ return {
2233
+ describedBy,
2234
+ hasOptionInfoText,
2235
+ props: {
2236
+ optionInfoText: (_d = selectedInfo == null ? void 0 : selectedInfo.infoText) != null ? _d : "",
2237
+ selectedLabel,
2238
+ questionOptionTextId: infoTextId,
2239
+ activatedLanguage,
2240
+ hasOptionInfoText: true
2241
+ }
2242
+ };
2243
+ };
2211
2244
  var OptionTextBody = ({
2212
- infoText,
2245
+ optionInfoText,
2213
2246
  selectedLabel,
2214
- TextQuestionId,
2247
+ questionOptionTextId,
2215
2248
  activatedLanguage,
2216
- connectedToSelect = false
2249
+ hasOptionInfoText = false
2217
2250
  // hideStepperButtons = false
2218
2251
  }) => {
2219
2252
  return /* @__PURE__ */ jsx22(Fragment15, { children: /* @__PURE__ */ jsx22(
2220
2253
  "div",
2221
2254
  {
2222
- ...connectedToSelect && {
2223
- id: `${TextQuestionId}`,
2224
- //"aria-live": {liveMode},
2255
+ ...hasOptionInfoText && {
2256
+ id: `${questionOptionTextId}`,
2225
2257
  "aria-atomic": "true"
2226
2258
  },
2227
- children: infoText.length > 0 && /* @__PURE__ */ jsxs18("div", { id: TextQuestionId + "-placeholder", className: "pts-root-question pts-optionTextBody-container", children: [
2228
- /* @__PURE__ */ jsx22("span", { className: "sr-only", children: `${activatedLanguage === "en" ? `More information about this option` : `Mer information om detta val`}.` }),
2259
+ children: optionInfoText.length > 0 && /* @__PURE__ */ jsxs18("div", { id: questionOptionTextId + "-placeholder", className: "pts-optionTextBody-container", children: [
2260
+ /* @__PURE__ */ jsxs18("span", { className: "sr-only", children: [
2261
+ selectedLabel,
2262
+ `${activatedLanguage === "en" ? `More information about this option` : `Mer information om detta val`}.`
2263
+ ] }),
2229
2264
  /* @__PURE__ */ jsx22(
2230
2265
  TextBody_default,
2231
2266
  {
2232
- data: { alertInText: infoText }
2267
+ data: { alertInText: optionInfoText }
2233
2268
  }
2234
2269
  )
2235
2270
  ] })
@@ -2246,19 +2281,15 @@ var CustomDropdownStandard = ({
2246
2281
  showPreview = false,
2247
2282
  activatedLanguage = "sv"
2248
2283
  }) => {
2249
- var _a, _b, _c, _d, _e, _f, _g, _h;
2284
+ var _a, _b, _c;
2250
2285
  const questionId = `question-${question.id}`;
2251
2286
  const selectId = `select-${question.id}`;
2252
2287
  const errorId = `error-${question.id}`;
2253
- const infoTextId = `infotext-${questionId}`;
2254
- const optionsInfoText = getInfoTextConnectionList(question.languageSupport, activatedLanguage);
2255
- const hasInfoText = optionsInfoText.some(
2256
- (option) => option.selectedValue === question.answer
2257
- );
2258
- const describedBy = [
2259
- question.hasValidationError ? errorId : null,
2260
- hasInfoText ? infoTextId : null
2261
- ].filter(Boolean).join(" ");
2288
+ const {
2289
+ describedBy,
2290
+ hasOptionInfoText,
2291
+ props: optionTextProps
2292
+ } = setOptionTextBodyProps(question, activatedLanguage, questionId, errorId);
2262
2293
  const handleInputChange = (event) => {
2263
2294
  const e = { target: { value: event.target.value } };
2264
2295
  handleQuestionInputChange(e, question);
@@ -2280,6 +2311,7 @@ var CustomDropdownStandard = ({
2280
2311
  "aria-required": question.isQuestionMandatory,
2281
2312
  "aria-invalid": question.hasValidationError ? question.hasValidationError : void 0,
2282
2313
  "aria-describedby": describedBy || void 0,
2314
+ className: describedBy === errorId ? "pts-root-question-input-error-border" : "",
2283
2315
  children: [
2284
2316
  /* @__PURE__ */ jsx23("option", { value: "", children: activatedLanguage === "en" ? "Select an option" : "V\xE4lj alternativ" }),
2285
2317
  (_a = question.options) == null ? void 0 : _a.map((option, index) => {
@@ -2297,16 +2329,7 @@ var CustomDropdownStandard = ({
2297
2329
  activatedLanguage
2298
2330
  }
2299
2331
  ),
2300
- optionsInfoText.length > 0 && /* @__PURE__ */ jsx23(
2301
- OptionTextBody_default,
2302
- {
2303
- infoText: (_e = (_d = optionsInfoText.find((optionI) => optionI.selectedValue === question.answer)) == null ? void 0 : _d.infoText) != null ? _e : "",
2304
- selectedLabel: (_h = (_g = (_f = question.options) == null ? void 0 : _f.find((option) => option.value === question.answer)) == null ? void 0 : _g.label) != null ? _h : "",
2305
- TextQuestionId: infoTextId,
2306
- activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv",
2307
- connectedToSelect: true
2308
- }
2309
- )
2332
+ hasOptionInfoText && /* @__PURE__ */ jsx23(OptionTextBody_default, { ...optionTextProps })
2310
2333
  ] }),
2311
2334
  showPreview && /* @__PURE__ */ jsx23(PreviewDropdown, { question })
2312
2335
  ] });
@@ -3155,7 +3178,8 @@ var QuestionRenderer = ({
3155
3178
  {
3156
3179
  question,
3157
3180
  handleQuestionInputChange,
3158
- showPreview
3181
+ showPreview,
3182
+ activatedLanguage
3159
3183
  }
3160
3184
  )
3161
3185
  ] });