optimized-react-component-library-xyz123 2.13.1 → 2.14.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.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",
@@ -1305,6 +1322,7 @@ __export(icons_exports, {
1305
1322
  ChevronRightIcon: () => ChevronRightIcon,
1306
1323
  CloseIcon: () => CloseIcon,
1307
1324
  CollapseIcon: () => CollapseIcon,
1325
+ Cookie_icon: () => Cookie_icon,
1308
1326
  ExpandIcon: () => ExpandIcon,
1309
1327
  FileIcon: () => FileIcon,
1310
1328
  LanguageIcon: () => LanguageIcon,
@@ -1890,6 +1908,13 @@ var Logo_en = () => /* @__PURE__ */ jsxs13(
1890
1908
  ]
1891
1909
  }
1892
1910
  );
1911
+ var Cookie_icon = () => /* @__PURE__ */ jsx16("svg", { xmlns: "http://www.w3.org/2000/svg", width: "13", height: "16", viewBox: "0 0 13 16", fill: "none", children: /* @__PURE__ */ jsx16(
1912
+ "path",
1913
+ {
1914
+ d: "M4.67907 11.2981H8.32186C8.53419 11.2981 8.71217 11.228 8.85579 11.0878C8.9994 10.9476 9.07121 10.7736 9.07121 10.5658V7.91662C9.07121 7.70938 8.9994 7.53567 8.85579 7.39549C8.71217 7.25532 8.53388 7.18523 8.32093 7.18523H8.16029V6.27892C8.16029 5.82637 8.00243 5.44572 7.68671 5.13697C7.371 4.82882 6.98131 4.67475 6.51764 4.67475C6.05398 4.67475 5.66429 4.82882 5.34857 5.13697C5.03286 5.44511 4.875 5.82576 4.875 6.27892V7.18523H4.67814C4.46581 7.18523 4.28783 7.25532 4.14421 7.39549C4.0006 7.53567 3.92879 7.70938 3.92879 7.91662V10.5658C3.92879 10.7736 4.0006 10.9476 4.14421 11.0878C4.28783 11.228 4.46612 11.2981 4.67907 11.2981ZM5.58907 7.18523V6.27892C5.58907 6.02213 5.67821 5.80673 5.8565 5.63272C6.03479 5.45871 6.25517 5.3717 6.51764 5.3717C6.78012 5.3717 7.00081 5.45871 7.17971 5.63272C7.35862 5.80673 7.44745 6.02213 7.44621 6.27892V7.18523H5.58907ZM6.2335 15.9773C6.14064 15.9622 6.05398 15.9396 5.9735 15.9094C4.14607 15.2296 2.69379 14.0768 1.61664 12.4509C0.5395 10.825 0.000619048 9.06491 0 7.17073V3.289C0 2.97844 0.0906907 2.69869 0.272072 2.44976C0.452834 2.20082 0.687143 2.02047 0.975 1.90869L5.97536 0.0960688C6.15612 0.0320229 6.331 0 6.5 0C6.669 0 6.84419 0.0320229 7.02557 0.0960688L12.025 1.90869C12.3122 2.02107 12.5465 2.20143 12.7279 2.44976C12.9093 2.69869 13 2.97844 13 3.289V7.17073C13 9.06491 12.4614 10.825 11.3843 12.4509C10.3071 14.0768 8.85486 15.2296 7.02743 15.9094C6.94633 15.9396 6.85936 15.9622 6.7665 15.9773C6.67364 15.9924 6.58481 16 6.5 16C6.41519 16 6.32636 15.9924 6.2335 15.9773ZM6.5 15.1463C8.10952 14.6478 9.44048 13.6508 10.4929 12.1554C11.5452 10.66 12.0714 8.99845 12.0714 7.17073V3.27178C12.0714 3.15577 12.0386 3.05124 11.973 2.9582C11.908 2.86515 11.8158 2.79567 11.6963 2.74975L6.69686 0.937125C6.63743 0.912957 6.57181 0.900873 6.5 0.900873C6.42819 0.900873 6.36257 0.912957 6.30314 0.937125L1.30371 2.74975C1.18424 2.79567 1.092 2.86515 1.027 2.9582C0.961381 3.05124 0.928571 3.15577 0.928571 3.27178V7.17073C0.928571 8.99845 1.45476 10.66 2.50714 12.1554C3.55952 13.6508 4.89048 14.6478 6.5 15.1463Z",
1915
+ fill: "white"
1916
+ }
1917
+ ) });
1893
1918
 
1894
1919
  // src/components/layout/AlertInTextStandard/AlertInTextStandard.tsx
1895
1920
  import DOMPurify5 from "dompurify";
@@ -2185,13 +2210,14 @@ var RadioWithInfo = ({
2185
2210
  ]
2186
2211
  }
2187
2212
  ) }),
2188
- showPreview && /* @__PURE__ */ jsx21(PreviewRadio2, { question })
2213
+ showPreview && /* @__PURE__ */ jsx21(PreviewRadio2, { question, activatedLanguage })
2189
2214
  ] });
2190
2215
  };
2191
2216
  var RadioMultipleWithInfoStandard_default = RadioWithInfo;
2192
- var PreviewRadio2 = ({ question }) => {
2217
+ var PreviewRadio2 = ({ question, activatedLanguage }) => {
2193
2218
  var _a, _b;
2194
2219
  const previewId = `preview-${question.id}`;
2220
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
2195
2221
  return /* @__PURE__ */ jsxs17(Fragment14, { children: [
2196
2222
  /* @__PURE__ */ jsx21("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
2197
2223
  ((_b = question.answer) == null ? void 0 : _b.trim()) ? /* @__PURE__ */ jsx21(
@@ -2199,7 +2225,7 @@ var PreviewRadio2 = ({ question }) => {
2199
2225
  {
2200
2226
  className: "pts-radioMultipleWithInfo2-preview pts-root-answer",
2201
2227
  id: `answer-${previewId}`,
2202
- children: question.answer
2228
+ children: questionAnswer.length > 0 ? questionAnswer : question.answer
2203
2229
  }
2204
2230
  ) : /* @__PURE__ */ jsx21(
2205
2231
  "dd",
@@ -2338,16 +2364,17 @@ var CustomDropdownStandard = ({
2338
2364
  ),
2339
2365
  hasOptionInfoText && /* @__PURE__ */ jsx23(OptionTextBody_default, { ...optionTextProps })
2340
2366
  ] }),
2341
- showPreview && /* @__PURE__ */ jsx23(PreviewDropdown, { question })
2367
+ showPreview && /* @__PURE__ */ jsx23(PreviewDropdown, { question, activatedLanguage })
2342
2368
  ] });
2343
2369
  };
2344
2370
  var DropdownStandard_default = CustomDropdownStandard;
2345
- var PreviewDropdown = ({ question, activatedLanguage = "sv" }) => {
2371
+ var PreviewDropdown = ({ question, activatedLanguage }) => {
2346
2372
  var _a, _b;
2347
2373
  const previewId = `preview-${question.id}`;
2374
+ const questionAnswer = setPreviewAnswerLabel_default(question, activatedLanguage);
2348
2375
  return /* @__PURE__ */ jsxs19(Fragment16, { children: [
2349
2376
  /* @__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(
2377
+ ((_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
2378
  "dd",
2352
2379
  {
2353
2380
  className: "pts-dropdown-preview pts-root-answer no-answer-preview-page",
@@ -3106,7 +3133,8 @@ var QuestionRenderer = ({
3106
3133
  {
3107
3134
  question,
3108
3135
  handleQuestionInputChange,
3109
- showPreview
3136
+ showPreview,
3137
+ activatedLanguage
3110
3138
  }
3111
3139
  ),
3112
3140
  question.questionType === "RadioWithInfo" && /* @__PURE__ */ jsx24(
@@ -3114,7 +3142,8 @@ var QuestionRenderer = ({
3114
3142
  {
3115
3143
  question,
3116
3144
  handleQuestionInputChange,
3117
- showPreview
3145
+ showPreview,
3146
+ activatedLanguage
3118
3147
  }
3119
3148
  ),
3120
3149
  question.questionType === "TextField" && /* @__PURE__ */ jsx24(
@@ -3168,7 +3197,8 @@ var QuestionRenderer = ({
3168
3197
  {
3169
3198
  question,
3170
3199
  handleQuestionInputChange,
3171
- showPreview
3200
+ showPreview,
3201
+ activatedLanguage
3172
3202
  }
3173
3203
  ),
3174
3204
  question.questionType === "InfoOnly" && /* @__PURE__ */ jsx24(
@@ -3362,7 +3392,11 @@ var CookieBanner_default = CookieBanner;
3362
3392
 
3363
3393
  // src/components/layout/FooterStandard/FooterStandard.tsx
3364
3394
  import { jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
3365
- var Footer = ({ activatedLanguage = "sv" }) => {
3395
+ var Footer = ({
3396
+ activatedLanguage = "sv",
3397
+ appUsesCookies = false,
3398
+ openCookieBanner
3399
+ }) => {
3366
3400
  return /* @__PURE__ */ jsxs23("footer", { className: "pts-footer-container", children: [
3367
3401
  /* @__PURE__ */ jsx27("div", { className: "pts-footer-slogan-text-container", children: /* @__PURE__ */ jsx27("p", { className: "pts-footer-slogan-text", children: activatedLanguage === "sv" ? "S\xE4ker och tillg\xE4nglig kommunikation f\xF6r Sverige" : "Secure and accessible communication for Sweden" }) }),
3368
3402
  /* @__PURE__ */ jsxs23("div", { className: "pts-footer-content", children: [
@@ -3431,7 +3465,20 @@ var Footer = ({ activatedLanguage = "sv" }) => {
3431
3465
  ]
3432
3466
  }
3433
3467
  ) }),
3434
- /* @__PURE__ */ jsx27("li", { children: /* @__PURE__ */ jsxs23(
3468
+ /* @__PURE__ */ jsx27("li", { children: appUsesCookies ? /* @__PURE__ */ jsxs23(
3469
+ "button",
3470
+ {
3471
+ type: "button",
3472
+ "aria-controls": "cookie-banner",
3473
+ onClick: openCookieBanner,
3474
+ className: "pts-footer-button pts-secondary-button",
3475
+ children: [
3476
+ /* @__PURE__ */ jsx27("span", { className: "sr-only", children: activatedLanguage === "en" ? "PTS Cookies (opens cookie banner)" : "PTS Kakor (\xF6ppnar kakbanner)" }),
3477
+ /* @__PURE__ */ jsx27("span", { "aria-hidden": "true", className: "secondary_icon", children: /* @__PURE__ */ jsx27(Cookie_icon, {}) }),
3478
+ /* @__PURE__ */ jsx27("span", { "aria-hidden": "true", children: activatedLanguage === "en" ? "Cookies" : "Kakor" })
3479
+ ]
3480
+ }
3481
+ ) : /* @__PURE__ */ jsxs23(
3435
3482
  "a",
3436
3483
  {
3437
3484
  href: activatedLanguage === "en" ? "https://pts.se/en/cookies-eservices" : "https://www.pts.se/kakor-etjanster",
@@ -3861,7 +3908,7 @@ var Header = ({
3861
3908
  "button",
3862
3909
  {
3863
3910
  lang: activatedLanguage === "en" ? "en" : "sv",
3864
- className: "pts-languageButton",
3911
+ className: "pts-languageButton pts-secondary-button",
3865
3912
  onClick: handleLanguageClick,
3866
3913
  children: [
3867
3914
  /* @__PURE__ */ jsx29("div", { className: "languageIcon", children: /* @__PURE__ */ jsx29("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx29(LanguageIcon2, {}) }) }),
@@ -3909,12 +3956,10 @@ var Navigation = ({
3909
3956
  setOpenSubMenu(null);
3910
3957
  return;
3911
3958
  }
3912
- const defaultOpenSubMenu = activePath == null ? null : (_b = (_a = menuLinks.find(
3913
- (link) => {
3914
- var _a2;
3915
- return (_a2 = link.children) == null ? void 0 : _a2.some((child) => child.href.includes(activePath));
3916
- }
3917
- )) == null ? void 0 : _a.label[activatedLanguage]) != null ? _b : null;
3959
+ const defaultOpenSubMenu = activePath == null ? null : (_b = (_a = menuLinks.find((link) => {
3960
+ var _a2;
3961
+ return (_a2 = link.children) == null ? void 0 : _a2.some((child) => child.href.includes(activePath));
3962
+ })) == null ? void 0 : _a.label[activatedLanguage]) != null ? _b : null;
3918
3963
  setOpenSubMenu(defaultOpenSubMenu);
3919
3964
  }, [isOpen, activePath, menuLinks, activatedLanguage]);
3920
3965
  useEffect13(() => {
@@ -3995,7 +4040,7 @@ var Navigation = ({
3995
4040
  /* @__PURE__ */ jsx30("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ jsxs26(
3996
4041
  "button",
3997
4042
  {
3998
- className: "pts-navigation-close-button",
4043
+ className: "pts-navigation-close-button pts-secondary-button",
3999
4044
  onClick: () => handleMenuClick("close"),
4000
4045
  type: "button",
4001
4046
  children: [
@@ -4011,14 +4056,7 @@ var Navigation = ({
4011
4056
  lang: activatedLanguage,
4012
4057
  children: [
4013
4058
  /* @__PURE__ */ jsx30("div", { children: /* @__PURE__ */ jsxs26("div", { className: "pts-navigation-button", children: [
4014
- /* @__PURE__ */ jsx30("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx30("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx30(
4015
- LinkComponent,
4016
- {
4017
- onClick: () => handleMenuClick("link"),
4018
- href,
4019
- children: label[activatedLanguage]
4020
- }
4021
- ) }),
4059
+ /* @__PURE__ */ jsx30("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx30("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx30(LinkComponent, { onClick: () => handleMenuClick("link"), href, children: label[activatedLanguage] }) }),
4022
4060
  children && /* @__PURE__ */ jsx30(
4023
4061
  "button",
4024
4062
  {
@@ -4041,14 +4079,15 @@ var Navigation = ({
4041
4079
  className: "pts-sub-navigation-container",
4042
4080
  id: "sub-menu-" + index,
4043
4081
  role: "region",
4044
- children: /* @__PURE__ */ jsx30("ul", { className: "pts-sub-navigation-list", lang: activatedLanguage, children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ jsx30("li", { className: "pts-sub-navigation-item", lang: activatedLanguage, children: /* @__PURE__ */ jsx30(
4045
- LinkComponent,
4082
+ children: /* @__PURE__ */ jsx30("ul", { className: "pts-sub-navigation-list", lang: activatedLanguage, children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ jsx30(
4083
+ "li",
4046
4084
  {
4047
- onClick: () => handleMenuClick("link"),
4048
- href: href2,
4049
- children: label2[activatedLanguage]
4050
- }
4051
- ) }, "nav-child-" + index2)) })
4085
+ className: "pts-sub-navigation-item",
4086
+ lang: activatedLanguage,
4087
+ children: /* @__PURE__ */ jsx30(LinkComponent, { onClick: () => handleMenuClick("link"), href: href2, children: label2[activatedLanguage] })
4088
+ },
4089
+ "nav-child-" + index2
4090
+ )) })
4052
4091
  }
4053
4092
  )
4054
4093
  ]
@@ -4115,7 +4154,7 @@ import { Fragment as Fragment21, jsx as jsx33, jsxs as jsxs29 } from "react/jsx-
4115
4154
  var NavigationHeader = ({
4116
4155
  headline = void 0,
4117
4156
  homelink = "",
4118
- //??
4157
+ //??
4119
4158
  activatedLanguage = "sv",
4120
4159
  useLanguage = false,
4121
4160
  useNavigationMenu = true,
@@ -4189,14 +4228,23 @@ var NavigationHeader = ({
4189
4228
  ) }),
4190
4229
  /* @__PURE__ */ jsx33("div", { className: `${hasHeadline ? "pts-navigation-header-headline-container" : ""}`, children: hasHeadline && /* @__PURE__ */ jsx33("div", { className: "pts-site-headline", children: headline }) }),
4191
4230
  /* @__PURE__ */ jsx33("div", { className: "pts-navigation-header-nav-container", children: (useLanguage || useNavigationMenu || useSearch) && /* @__PURE__ */ jsxs29(Fragment21, { children: [
4192
- useSearch && !isMenuOpen && /* @__PURE__ */ jsx33(Fragment21, { children: /* @__PURE__ */ jsxs29("button", { type: "button", onClick: handleSearchClick, children: [
4193
- /* @__PURE__ */ jsx33("span", { "aria-hidden": "true", className: "pts-navigation-header-icons", children: getSearchIcon() }),
4194
- /* @__PURE__ */ jsx33("span", { className: "pts-navigation-header-button-label", children: getSearchLabel() })
4195
- ] }) }),
4231
+ useSearch && !isMenuOpen && /* @__PURE__ */ jsx33(Fragment21, { children: /* @__PURE__ */ jsxs29(
4232
+ "button",
4233
+ {
4234
+ type: "button",
4235
+ className: "pts-secondary-button",
4236
+ onClick: handleSearchClick,
4237
+ children: [
4238
+ /* @__PURE__ */ jsx33("span", { "aria-hidden": "true", className: "pts-navigation-header-icons", children: getSearchIcon() }),
4239
+ /* @__PURE__ */ jsx33("span", { className: "pts-navigation-header-button-label", children: getSearchLabel() })
4240
+ ]
4241
+ }
4242
+ ) }),
4196
4243
  useLanguage && !isMenuOpen && /* @__PURE__ */ jsxs29(
4197
4244
  "button",
4198
4245
  {
4199
4246
  type: "button",
4247
+ className: "pts-secondary-button",
4200
4248
  lang: activatedLanguage === "en" ? "en" : "sv",
4201
4249
  onClick: handleLanguageClick,
4202
4250
  "aria-label": activatedLanguage === "sv" ? "Change language to English" : "\xC4ndra spr\xE5k till svenska",
@@ -4210,12 +4258,20 @@ var NavigationHeader = ({
4210
4258
  "button",
4211
4259
  {
4212
4260
  type: "button",
4261
+ className: "pts-secondary-button",
4213
4262
  onClick: handleMenuClick,
4214
4263
  "aria-expanded": isMenuOpen,
4215
4264
  "aria-controls": "main-navigation",
4216
4265
  ref: menuButtonFocusRef,
4217
4266
  children: [
4218
- /* @__PURE__ */ jsx33("span", { "aria-hidden": "true", className: isMenuOpen ? "pts-close-icon" : "pts-open-icon", children: getMenuIcon() }),
4267
+ /* @__PURE__ */ jsx33(
4268
+ "span",
4269
+ {
4270
+ "aria-hidden": "true",
4271
+ className: isMenuOpen ? "pts-close-icon" : "pts-open-icon",
4272
+ children: getMenuIcon()
4273
+ }
4274
+ ),
4219
4275
  /* @__PURE__ */ jsx33("span", { className: "pts-navigation-header-button-label", children: getMenuLabel() })
4220
4276
  ]
4221
4277
  }