optimized-react-component-library-xyz123 0.26.7 → 0.27.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.mjs CHANGED
@@ -3,7 +3,8 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  var InputRadio = ({
4
4
  question,
5
5
  handleQuestionInputChange,
6
- showPreview = false
6
+ showPreview = false,
7
+ activatedLanguage = "sv"
7
8
  }) => {
8
9
  var _a;
9
10
  const questionId = `question-${question.id}`;
@@ -49,11 +50,11 @@ var InputRadio = ({
49
50
  ]
50
51
  }
51
52
  ) }),
52
- showPreview && /* @__PURE__ */ jsx(PreviewRadio, { question })
53
+ showPreview && /* @__PURE__ */ jsx(PreviewRadio, { question, activatedLanguage })
53
54
  ] });
54
55
  };
55
56
  var RadioMultipleStandard_default = InputRadio;
56
- var PreviewRadio = ({ question }) => {
57
+ var PreviewRadio = ({ question, activatedLanguage }) => {
57
58
  var _a, _b;
58
59
  const previewId = `preview-${question.id}`;
59
60
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -63,7 +64,7 @@ var PreviewRadio = ({ question }) => {
63
64
  {
64
65
  className: "pts-radioMultiple-preview pts-root-answer no-answer-preview-page",
65
66
  id: `answer-${previewId}`,
66
- children: "Inget svar"
67
+ children: activatedLanguage === "en" ? "No answer" : "Inget svar"
67
68
  }
68
69
  )
69
70
  ] });
@@ -85,17 +86,17 @@ var MultipleCheckboxes = ({
85
86
  var _a2;
86
87
  const initialValues = ((_a2 = question.options) == null ? void 0 : _a2.filter((option) => {
87
88
  var _a3;
88
- return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.label);
89
- }).map((option) => option.label)) || [];
89
+ return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.id);
90
+ }).map((option) => option.id)) || [];
90
91
  console.log("Initial values:", initialValues);
91
92
  setCheckedValues(initialValues);
92
93
  }, [question.answer, question.options]);
93
- const handleInputChange = (event, optionValue) => {
94
+ const handleInputChange = (event, optionId) => {
94
95
  let updatedValues = [...checkedValues];
95
- if (updatedValues.includes(optionValue)) {
96
- updatedValues = updatedValues.filter((val) => val !== optionValue);
96
+ if (updatedValues.includes(optionId)) {
97
+ updatedValues = updatedValues.filter((val) => val !== optionId);
97
98
  } else {
98
- updatedValues.push(optionValue);
99
+ updatedValues.push(optionId);
99
100
  }
100
101
  setCheckedValues(updatedValues);
101
102
  const e = { target: { value: updatedValues.toString() } };
@@ -117,9 +118,9 @@ var MultipleCheckboxes = ({
117
118
  type: "checkbox",
118
119
  name: `${question.id}-option`,
119
120
  id: `${question.id}-option-${index}`,
120
- value: option.label,
121
- checked: checkedValues.includes(option.label),
122
- onChange: (e) => handleInputChange(e, option.label),
121
+ value: option.id,
122
+ checked: checkedValues.includes(option.id),
123
+ onChange: (e) => handleInputChange(e, option.id),
123
124
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0
124
125
  }
125
126
  ),
@@ -141,7 +142,7 @@ var PrevieMultipleCheckboxes = ({
141
142
  /* @__PURE__ */ jsx2("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
142
143
  question.answer ? question.options && question.options.length === 1 ? /* @__PURE__ */ jsx2("dd", { children: question.options[0].label }) : /* @__PURE__ */ jsx2("dd", { children: /* @__PURE__ */ jsx2("ul", { className: "pts-preview-answer-list", children: (_b = question.options) == null ? void 0 : _b.filter((option) => {
143
144
  var _a2;
144
- return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.label);
145
+ return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.id);
145
146
  }).map((option, index) => /* @__PURE__ */ jsx2("li", { children: option.label }, index)) }) }) : /* @__PURE__ */ jsx2("dd", { className: "no-answer-preview-page", children: activatedLanguage === "en" ? "No Answer" : "Inget svar" }),
146
147
  " "
147
148
  ] });
@@ -165,8 +166,8 @@ var CheckboxGroup = ({
165
166
  var _a2;
166
167
  const initialValues = ((_a2 = question.options) == null ? void 0 : _a2.filter((option) => {
167
168
  var _a3;
168
- return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.label);
169
- }).map((option) => option.label)) || [];
169
+ return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.id);
170
+ }).map((option) => option.id)) || [];
170
171
  setCheckedValues(initialValues);
171
172
  }, [question.answer, question.options]);
172
173
  const handleInputChange = (event, optionValue) => {
@@ -200,9 +201,9 @@ var CheckboxGroup = ({
200
201
  type: "checkbox",
201
202
  name: `name-${question.id}`,
202
203
  id: `${groupId}-option-${index}`,
203
- value: option.label,
204
- checked: checkedValues.includes(option.label),
205
- onChange: (e) => handleInputChange(e, option.label),
204
+ value: option.id,
205
+ checked: checkedValues.includes(option.id),
206
+ onChange: (e) => handleInputChange(e, option.id),
206
207
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0
207
208
  }
208
209
  ),
@@ -230,7 +231,7 @@ var PreviewCheckboxGroup = ({
230
231
  /* @__PURE__ */ jsx3("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
231
232
  question.answer ? question.options && question.options.length === 1 ? /* @__PURE__ */ jsx3("dd", { children: question.options[0].label }) : /* @__PURE__ */ jsx3("dd", { children: /* @__PURE__ */ jsx3("ul", { className: "pts-preview-answer-list", children: (_b = question.options) == null ? void 0 : _b.filter((option) => {
232
233
  var _a2;
233
- return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.label);
234
+ return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.id);
234
235
  }).map((option, index) => /* @__PURE__ */ jsx3("li", { children: option.label }, index)) }) }) : /* @__PURE__ */ jsx3("dd", { className: "no-answer-preview-page", children: activatedLanguage === "en" ? "No Answer" : "Inget svar" }),
235
236
  " "
236
237
  ] });
@@ -701,7 +702,7 @@ var SelectedFiles = ({
701
702
  }
702
703
  ) })
703
704
  ] }) }),
704
- questionObject.files.length > 0 && /* @__PURE__ */ jsx10("ul", { className: "fileListUnorderedList", "aria-label": "Uppladdade filer", children: questionObject.files.map((file, index) => {
705
+ questionObject.files.length > 0 && /* @__PURE__ */ jsx10("ul", { className: "fileListUnorderedList", "aria-label": activatedLanguage === "en" ? "Uploaded files" : "Uppladdade filer", children: questionObject.files.map((file, index) => {
705
706
  const indicatorfileName = file.FileName;
706
707
  let mobileFirstFileName = file.FileName.split(".").shift();
707
708
  mobileFirstFileName = mobileFirstFileName.length > 8 ? mobileFirstFileName.substring(0, 8) + ".." : mobileFirstFileName;
@@ -1196,7 +1197,7 @@ function createApiDataObject(data, specialMappedQuestions, translatedAnswers) {
1196
1197
  let translatedAnswer = question.answer;
1197
1198
  if (question.answer && typeof question.answer === "string" && Array.isArray(question.options) && question.mappingId && specialMappedQuestions.has(question.mappingId)) {
1198
1199
  const answerNormalized = normalize(question.answer);
1199
- const matchingIds = question.options.filter((option) => answerNormalized.includes(normalize(option.label))).map((option) => `^${option.id}^`);
1200
+ const matchingIds = question.options.filter((option) => answerNormalized.includes(normalize(option.id))).map((option) => `^${option.id}^`);
1200
1201
  if (matchingIds.length > 0) {
1201
1202
  translatedAnswer = matchingIds.join(",");
1202
1203
  }
@@ -1990,7 +1991,8 @@ var CookieBanner = ({
1990
1991
  onCookieStateChange,
1991
1992
  onClose,
1992
1993
  acceptCookies,
1993
- rejectCookies
1994
+ rejectCookies,
1995
+ activatedLanguage = "sv"
1994
1996
  }) => {
1995
1997
  if (!visible) return null;
1996
1998
  const handleCookieChoice = (accepted) => {
@@ -2017,8 +2019,13 @@ var CookieBanner = ({
2017
2019
  id: "cookie-banner",
2018
2020
  tabIndex: -1,
2019
2021
  children: /* @__PURE__ */ jsxs13("div", { className: "content", children: [
2020
- /* @__PURE__ */ jsx15("h3", { id: "cookie-banner-title", children: "Kakor (cookies)" }),
2021
- /* @__PURE__ */ jsx15("p", { id: "cookie-banner-description", children: "PTS skulle vilja anv\xE4nda en statistikkaka i syfte att l\xF6pande f\xF6rb\xE4ttra webbplatsen. Samtycker du till det? Du kan n\xE4r som helst \xE4ndra ditt val. F\xF6r att \xE5terkalla ditt samtycke klickar du p\xE5 \u201DKakor\u201D i avsnittet l\xE4ngst ned p\xE5 webbplatsen." }),
2022
+ /* @__PURE__ */ jsxs13("h3", { id: "cookie-banner-title", children: [
2023
+ " ",
2024
+ activatedLanguage === "en" ? "Cookies" : "Kakor (cookies)"
2025
+ ] }),
2026
+ /* @__PURE__ */ jsx15("p", { id: "cookie-banner-description", children: activatedLanguage === "en" ? `PTS would like to use a web analytics cookie in order to continuously improve pts.se. Do you consent? You can change your choice at any time. To withdraw your consent, click on \u201CCookies\u201D at the bottom of the website.` : `PTS skulle vilja anv\xE4nda en statistikkaka i syfte att l\xF6pande f\xF6rb\xE4ttra webbplatsen.
2027
+ Samtycker du till det? Du kan n\xE4r som helst \xE4ndra ditt val. F\xF6r att \xE5terkalla ditt
2028
+ samtycke klickar du p\xE5 \u201DKakor\u201D i avsnittet l\xE4ngst ned p\xE5 webbplatsen.` }),
2022
2029
  /* @__PURE__ */ jsxs13("div", { className: "pts-cookieBanner-Links", children: [
2023
2030
  /* @__PURE__ */ jsxs13(
2024
2031
  "svg",
@@ -2047,13 +2054,13 @@ var CookieBanner = ({
2047
2054
  href: "https://pts.se/om-oss/om-pts.se/kakor-pa-webbplatsen/kakor-pa-pts-e-tjanster/",
2048
2055
  target: "_blank",
2049
2056
  rel: "noopener noreferrer",
2050
- children: "Kakor (cookies) p\xE5 pts.se (\xF6ppnas i ny flik)"
2057
+ children: activatedLanguage === "en" ? "Cookies on pts.se (opens in new tab)" : "Kakor (cookies) p\xE5 pts.se (\xF6ppnas i ny flik)"
2051
2058
  }
2052
2059
  )
2053
2060
  ] }),
2054
2061
  /* @__PURE__ */ jsxs13("div", { className: "pts-cookieBanner-Buttons", children: [
2055
- /* @__PURE__ */ jsx15("button", { onClick: () => handleCookieChoice(true), children: "Ja, jag samtycker" }),
2056
- /* @__PURE__ */ jsx15("button", { onClick: () => handleCookieChoice(false), children: "Nej, jag samtycker inte" })
2062
+ /* @__PURE__ */ jsx15("button", { onClick: () => handleCookieChoice(true), children: activatedLanguage === "en" ? "Yes, I consent" : "Ja, jag samtycker" }),
2063
+ /* @__PURE__ */ jsx15("button", { onClick: () => handleCookieChoice(false), children: activatedLanguage === "en" ? "No, I do not consent" : "Nej, jag samtycker inte" })
2057
2064
  ] })
2058
2065
  ] })
2059
2066
  }
@@ -2601,9 +2608,9 @@ var ModalStandard_default = Modal;
2601
2608
 
2602
2609
  // src/components/layout/SkipLinkStandard/SkipLinkStandard.tsx
2603
2610
  import { jsx as jsx20 } from "react/jsx-runtime";
2604
- var SkipLink = () => {
2611
+ var SkipLink = ({ activatedLanguage = "sv" }) => {
2605
2612
  function scrollToMainContent() {
2606
- const container = document.getElementById(`main-content`);
2613
+ const container = document.getElementById(`pts-main-service-headline`);
2607
2614
  if (container) {
2608
2615
  container.scrollIntoView({ behavior: "smooth", block: "center" });
2609
2616
  container.focus();
@@ -2617,7 +2624,7 @@ var SkipLink = () => {
2617
2624
  e.preventDefault();
2618
2625
  scrollToMainContent();
2619
2626
  },
2620
- children: "Till huvudinneh\xE5ll"
2627
+ children: activatedLanguage === "en" ? "Skip to main content" : "Till huvudinneh\xE5ll"
2621
2628
  }
2622
2629
  ) });
2623
2630
  };
@@ -2849,16 +2856,18 @@ var EditPreviewLinkStandard_default = EditPreviewLink;
2849
2856
  import { jsx as jsx25 } from "react/jsx-runtime";
2850
2857
  var StartApplicationButton = ({
2851
2858
  onClick,
2852
- label = "Starta e-tj\xE4nsten",
2853
- className = ""
2859
+ label,
2860
+ className = "",
2861
+ activatedLanguage = "sv"
2854
2862
  }) => {
2863
+ const defaultLabel = activatedLanguage === "en" ? "Start e-service" : "Starta e-tj\xE4nsten";
2855
2864
  return /* @__PURE__ */ jsx25(
2856
2865
  "button",
2857
2866
  {
2858
2867
  type: "button",
2859
2868
  className: `pts-forwardButton pts-start-applicationButton ${className}`,
2860
2869
  onClick,
2861
- children: label
2870
+ children: label || defaultLabel
2862
2871
  }
2863
2872
  );
2864
2873
  };
@@ -3017,10 +3026,10 @@ var ValidationErrorSummaryList_default = ValidationErrorSummaryList;
3017
3026
 
3018
3027
  // src/components/validation-and-status/FormStatusMessagesScreenReader/FormStatusMessagesScreenReader.tsx
3019
3028
  import { Fragment as Fragment17, jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
3020
- var FormStatusMessagesScreenReader = ({ formStatus }) => {
3029
+ var FormStatusMessagesScreenReader = ({ formStatus, activatedLanguage = "sv" }) => {
3021
3030
  return /* @__PURE__ */ jsxs23(Fragment17, { children: [
3022
- /* @__PURE__ */ jsx29("p", { "aria-live": "assertive", children: formStatus === "failed" && /* @__PURE__ */ jsx29("span", { className: "pts-root-mandatoryAsterisk", children: "N\xE5got gick fel, f\xF6rs\xF6k igen senare eller kontakta oss!" }) }),
3023
- /* @__PURE__ */ jsx29("div", { "aria-live": "polite", className: "visually-hidden", children: formStatus === "loading" ? "Ditt \xE4rende registreras. Uppdatera eller st\xE4ng inte sidan." : "" })
3031
+ /* @__PURE__ */ jsx29("p", { "aria-live": "assertive", children: formStatus === "failed" && /* @__PURE__ */ jsx29("span", { className: "pts-root-mandatoryAsterisk", children: activatedLanguage === "en" ? "Something went wrong, please try again later or contact us!" : "N\xE5got gick fel, f\xF6rs\xF6k igen senare eller kontakta oss!" }) }),
3032
+ /* @__PURE__ */ jsx29("div", { "aria-live": "polite", className: "visually-hidden", children: formStatus === "loading" ? activatedLanguage === "en" ? "Your case is being registered. Please do not refresh or close the page." : "Ditt \xE4rende registreras. Uppdatera eller st\xE4ng inte sidan." : "" })
3024
3033
  ] });
3025
3034
  };
3026
3035
  var FormStatusMessagesScreenReader_default = FormStatusMessagesScreenReader;