optimized-react-component-library-xyz123 0.27.4 → 0.27.5

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>;
@@ -727,6 +728,7 @@ interface CookieBannerProps {
727
728
  onClose?: () => void;
728
729
  acceptCookies: () => void;
729
730
  rejectCookies: () => void;
731
+ activatedLanguage?: string;
730
732
  }
731
733
 
732
734
  declare const CookieBanner: React$1.FC<CookieBannerProps>;
@@ -752,7 +754,10 @@ interface ModalProps {
752
754
 
753
755
  declare const Modal: FC<ModalProps>;
754
756
 
755
- declare const SkipLink: FC;
757
+ type SkipLinkProps = {
758
+ activatedLanguage?: string;
759
+ };
760
+ declare const SkipLink: FC<SkipLinkProps>;
756
761
 
757
762
  interface PrincipleOfPublicityProps {
758
763
  activatedLanguage?: string;
@@ -778,6 +783,7 @@ interface StartApplicationButtonProps {
778
783
  onClick: (event: React$1.MouseEvent<HTMLButtonElement>) => void;
779
784
  label?: string;
780
785
  className?: string;
786
+ activatedLanguage?: string;
781
787
  }
782
788
  /**
783
789
  * En standardiserad knapp för att starta e-tjänsten.
@@ -785,6 +791,7 @@ interface StartApplicationButtonProps {
785
791
  * @param {Function} onClick - Funktion som körs när användaren klickar på knappen.
786
792
  * @param {string} label - Text som visas på knappen.
787
793
  * @param {string} className - Extra CSS-klasser för knappen.
794
+ * @param {string} activatedLanguage - Aktiverat språk.
788
795
  */
789
796
  declare const StartApplicationButton: React$1.FC<StartApplicationButtonProps>;
790
797
 
@@ -845,12 +852,14 @@ declare const ValidationErrorSummaryList: React$1.FC<ValidationErrorSummaryListP
845
852
 
846
853
  interface FormStatusMessagesProps {
847
854
  formStatus: string;
855
+ activatedLanguage?: string;
848
856
  }
849
857
  /**
850
858
  * Visar ett error-meddelande om formuläret misslyckas att skicka in, dvs. status är
851
859
  * failed. Läser upp att formuläret laddas för skärmläsare när status är loading.
852
860
  *
853
861
  * @param {string} formStatus Nuvarande status för formuläret.
862
+ * @param {string} [activatedLanguage='sv'] Den aktiverade språkkoden (default är svenska).
854
863
  *
855
864
  */
856
865
  declare const FormStatusMessagesScreenReader: React$1.FC<FormStatusMessagesProps>;
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>;
@@ -727,6 +728,7 @@ interface CookieBannerProps {
727
728
  onClose?: () => void;
728
729
  acceptCookies: () => void;
729
730
  rejectCookies: () => void;
731
+ activatedLanguage?: string;
730
732
  }
731
733
 
732
734
  declare const CookieBanner: React$1.FC<CookieBannerProps>;
@@ -752,7 +754,10 @@ interface ModalProps {
752
754
 
753
755
  declare const Modal: FC<ModalProps>;
754
756
 
755
- declare const SkipLink: FC;
757
+ type SkipLinkProps = {
758
+ activatedLanguage?: string;
759
+ };
760
+ declare const SkipLink: FC<SkipLinkProps>;
756
761
 
757
762
  interface PrincipleOfPublicityProps {
758
763
  activatedLanguage?: string;
@@ -778,6 +783,7 @@ interface StartApplicationButtonProps {
778
783
  onClick: (event: React$1.MouseEvent<HTMLButtonElement>) => void;
779
784
  label?: string;
780
785
  className?: string;
786
+ activatedLanguage?: string;
781
787
  }
782
788
  /**
783
789
  * En standardiserad knapp för att starta e-tjänsten.
@@ -785,6 +791,7 @@ interface StartApplicationButtonProps {
785
791
  * @param {Function} onClick - Funktion som körs när användaren klickar på knappen.
786
792
  * @param {string} label - Text som visas på knappen.
787
793
  * @param {string} className - Extra CSS-klasser för knappen.
794
+ * @param {string} activatedLanguage - Aktiverat språk.
788
795
  */
789
796
  declare const StartApplicationButton: React$1.FC<StartApplicationButtonProps>;
790
797
 
@@ -845,12 +852,14 @@ declare const ValidationErrorSummaryList: React$1.FC<ValidationErrorSummaryListP
845
852
 
846
853
  interface FormStatusMessagesProps {
847
854
  formStatus: string;
855
+ activatedLanguage?: string;
848
856
  }
849
857
  /**
850
858
  * Visar ett error-meddelande om formuläret misslyckas att skicka in, dvs. status är
851
859
  * failed. Läser upp att formuläret laddas för skärmläsare när status är loading.
852
860
  *
853
861
  * @param {string} formStatus Nuvarande status för formuläret.
862
+ * @param {string} [activatedLanguage='sv'] Den aktiverade språkkoden (default är svenska).
854
863
  *
855
864
  */
856
865
  declare const FormStatusMessagesScreenReader: React$1.FC<FormStatusMessagesProps>;
package/dist/index.js CHANGED
@@ -85,7 +85,8 @@ var import_jsx_runtime = require("react/jsx-runtime");
85
85
  var InputRadio = ({
86
86
  question,
87
87
  handleQuestionInputChange,
88
- showPreview = false
88
+ showPreview = false,
89
+ activatedLanguage = "sv"
89
90
  }) => {
90
91
  var _a;
91
92
  const questionId = `question-${question.id}`;
@@ -131,11 +132,11 @@ var InputRadio = ({
131
132
  ]
132
133
  }
133
134
  ) }),
134
- showPreview && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PreviewRadio, { question })
135
+ showPreview && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PreviewRadio, { question, activatedLanguage })
135
136
  ] });
136
137
  };
137
138
  var RadioMultipleStandard_default = InputRadio;
138
- var PreviewRadio = ({ question }) => {
139
+ var PreviewRadio = ({ question, activatedLanguage }) => {
139
140
  var _a, _b;
140
141
  const previewId = `preview-${question.id}`;
141
142
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
@@ -145,7 +146,7 @@ var PreviewRadio = ({ question }) => {
145
146
  {
146
147
  className: "pts-radioMultiple-preview pts-root-answer no-answer-preview-page",
147
148
  id: `answer-${previewId}`,
148
- children: "Inget svar"
149
+ children: activatedLanguage === "en" ? "No answer" : "Inget svar"
149
150
  }
150
151
  )
151
152
  ] });
@@ -167,17 +168,17 @@ var MultipleCheckboxes = ({
167
168
  var _a2;
168
169
  const initialValues = ((_a2 = question.options) == null ? void 0 : _a2.filter((option) => {
169
170
  var _a3;
170
- return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.label);
171
- }).map((option) => option.label)) || [];
171
+ return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.id);
172
+ }).map((option) => option.id)) || [];
172
173
  console.log("Initial values:", initialValues);
173
174
  setCheckedValues(initialValues);
174
175
  }, [question.answer, question.options]);
175
- const handleInputChange = (event, optionValue) => {
176
+ const handleInputChange = (event, optionId) => {
176
177
  let updatedValues = [...checkedValues];
177
- if (updatedValues.includes(optionValue)) {
178
- updatedValues = updatedValues.filter((val) => val !== optionValue);
178
+ if (updatedValues.includes(optionId)) {
179
+ updatedValues = updatedValues.filter((val) => val !== optionId);
179
180
  } else {
180
- updatedValues.push(optionValue);
181
+ updatedValues.push(optionId);
181
182
  }
182
183
  setCheckedValues(updatedValues);
183
184
  const e = { target: { value: updatedValues.toString() } };
@@ -199,9 +200,9 @@ var MultipleCheckboxes = ({
199
200
  type: "checkbox",
200
201
  name: `${question.id}-option`,
201
202
  id: `${question.id}-option-${index}`,
202
- value: option.label,
203
- checked: checkedValues.includes(option.label),
204
- onChange: (e) => handleInputChange(e, option.label),
203
+ value: option.id,
204
+ checked: checkedValues.includes(option.id),
205
+ onChange: (e) => handleInputChange(e, option.id),
205
206
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0
206
207
  }
207
208
  ),
@@ -223,7 +224,7 @@ var PrevieMultipleCheckboxes = ({
223
224
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
224
225
  question.answer ? question.options && question.options.length === 1 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { children: question.options[0].label }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "pts-preview-answer-list", children: (_b = question.options) == null ? void 0 : _b.filter((option) => {
225
226
  var _a2;
226
- return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.label);
227
+ return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.id);
227
228
  }).map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { children: option.label }, index)) }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { className: "no-answer-preview-page", children: activatedLanguage === "en" ? "No Answer" : "Inget svar" }),
228
229
  " "
229
230
  ] });
@@ -247,8 +248,8 @@ var CheckboxGroup = ({
247
248
  var _a2;
248
249
  const initialValues = ((_a2 = question.options) == null ? void 0 : _a2.filter((option) => {
249
250
  var _a3;
250
- return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.label);
251
- }).map((option) => option.label)) || [];
251
+ return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.id);
252
+ }).map((option) => option.id)) || [];
252
253
  setCheckedValues(initialValues);
253
254
  }, [question.answer, question.options]);
254
255
  const handleInputChange = (event, optionValue) => {
@@ -282,9 +283,9 @@ var CheckboxGroup = ({
282
283
  type: "checkbox",
283
284
  name: `name-${question.id}`,
284
285
  id: `${groupId}-option-${index}`,
285
- value: option.label,
286
- checked: checkedValues.includes(option.label),
287
- onChange: (e) => handleInputChange(e, option.label),
286
+ value: option.id,
287
+ checked: checkedValues.includes(option.id),
288
+ onChange: (e) => handleInputChange(e, option.id),
288
289
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0
289
290
  }
290
291
  ),
@@ -312,7 +313,7 @@ var PreviewCheckboxGroup = ({
312
313
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
313
314
  question.answer ? question.options && question.options.length === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { children: question.options[0].label }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { className: "pts-preview-answer-list", children: (_b = question.options) == null ? void 0 : _b.filter((option) => {
314
315
  var _a2;
315
- return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.label);
316
+ return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.id);
316
317
  }).map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("li", { children: option.label }, index)) }) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { className: "no-answer-preview-page", children: activatedLanguage === "en" ? "No Answer" : "Inget svar" }),
317
318
  " "
318
319
  ] });
@@ -783,7 +784,7 @@ var SelectedFiles = ({
783
784
  }
784
785
  ) })
785
786
  ] }) }),
786
- questionObject.files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "fileListUnorderedList", "aria-label": "Uppladdade filer", children: questionObject.files.map((file, index) => {
787
+ questionObject.files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "fileListUnorderedList", "aria-label": activatedLanguage === "en" ? "Uploaded files" : "Uppladdade filer", children: questionObject.files.map((file, index) => {
787
788
  const indicatorfileName = file.FileName;
788
789
  let mobileFirstFileName = file.FileName.split(".").shift();
789
790
  mobileFirstFileName = mobileFirstFileName.length > 8 ? mobileFirstFileName.substring(0, 8) + ".." : mobileFirstFileName;
@@ -1278,7 +1279,7 @@ function createApiDataObject(data, specialMappedQuestions, translatedAnswers) {
1278
1279
  let translatedAnswer = question.answer;
1279
1280
  if (question.answer && typeof question.answer === "string" && Array.isArray(question.options) && question.mappingId && specialMappedQuestions.has(question.mappingId)) {
1280
1281
  const answerNormalized = normalize(question.answer);
1281
- const matchingIds = question.options.filter((option) => answerNormalized.includes(normalize(option.label))).map((option) => `^${option.id}^`);
1282
+ const matchingIds = question.options.filter((option) => answerNormalized.includes(normalize(option.id))).map((option) => `^${option.id}^`);
1282
1283
  if (matchingIds.length > 0) {
1283
1284
  translatedAnswer = matchingIds.join(",");
1284
1285
  }
@@ -2069,7 +2070,8 @@ var CookieBanner = ({
2069
2070
  onCookieStateChange,
2070
2071
  onClose,
2071
2072
  acceptCookies,
2072
- rejectCookies
2073
+ rejectCookies,
2074
+ activatedLanguage = "sv"
2073
2075
  }) => {
2074
2076
  if (!visible) return null;
2075
2077
  const handleCookieChoice = (accepted) => {
@@ -2096,8 +2098,13 @@ var CookieBanner = ({
2096
2098
  id: "cookie-banner",
2097
2099
  tabIndex: -1,
2098
2100
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "content", children: [
2099
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h3", { id: "cookie-banner-title", children: "Kakor (cookies)" }),
2100
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("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." }),
2101
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("h3", { id: "cookie-banner-title", children: [
2102
+ " ",
2103
+ activatedLanguage === "en" ? "Cookies" : "Kakor (cookies)"
2104
+ ] }),
2105
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("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.
2106
+ Samtycker du till det? Du kan n\xE4r som helst \xE4ndra ditt val. F\xF6r att \xE5terkalla ditt
2107
+ samtycke klickar du p\xE5 \u201DKakor\u201D i avsnittet l\xE4ngst ned p\xE5 webbplatsen.` }),
2101
2108
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "pts-cookieBanner-Links", children: [
2102
2109
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2103
2110
  "svg",
@@ -2126,13 +2133,13 @@ var CookieBanner = ({
2126
2133
  href: "https://pts.se/om-oss/om-pts.se/kakor-pa-webbplatsen/kakor-pa-pts-e-tjanster/",
2127
2134
  target: "_blank",
2128
2135
  rel: "noopener noreferrer",
2129
- children: "Kakor (cookies) p\xE5 pts.se (\xF6ppnas i ny flik)"
2136
+ children: activatedLanguage === "en" ? "Cookies on pts.se (opens in new tab)" : "Kakor (cookies) p\xE5 pts.se (\xF6ppnas i ny flik)"
2130
2137
  }
2131
2138
  )
2132
2139
  ] }),
2133
2140
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "pts-cookieBanner-Buttons", children: [
2134
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { onClick: () => handleCookieChoice(true), children: "Ja, jag samtycker" }),
2135
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { onClick: () => handleCookieChoice(false), children: "Nej, jag samtycker inte" })
2141
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { onClick: () => handleCookieChoice(true), children: activatedLanguage === "en" ? "Yes, I consent" : "Ja, jag samtycker" }),
2142
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { onClick: () => handleCookieChoice(false), children: activatedLanguage === "en" ? "No, I do not consent" : "Nej, jag samtycker inte" })
2136
2143
  ] })
2137
2144
  ] })
2138
2145
  }
@@ -2680,9 +2687,9 @@ var ModalStandard_default = Modal;
2680
2687
 
2681
2688
  // src/components/layout/SkipLinkStandard/SkipLinkStandard.tsx
2682
2689
  var import_jsx_runtime20 = require("react/jsx-runtime");
2683
- var SkipLink = () => {
2690
+ var SkipLink = ({ activatedLanguage = "sv" }) => {
2684
2691
  function scrollToMainContent() {
2685
- const container = document.getElementById(`main-content`);
2692
+ const container = document.getElementById(`pts-main-service-headline`);
2686
2693
  if (container) {
2687
2694
  container.scrollIntoView({ behavior: "smooth", block: "center" });
2688
2695
  container.focus();
@@ -2696,7 +2703,7 @@ var SkipLink = () => {
2696
2703
  e.preventDefault();
2697
2704
  scrollToMainContent();
2698
2705
  },
2699
- children: "Till huvudinneh\xE5ll"
2706
+ children: activatedLanguage === "en" ? "Skip to main content" : "Till huvudinneh\xE5ll"
2700
2707
  }
2701
2708
  ) });
2702
2709
  };
@@ -2928,16 +2935,18 @@ var EditPreviewLinkStandard_default = EditPreviewLink;
2928
2935
  var import_jsx_runtime25 = require("react/jsx-runtime");
2929
2936
  var StartApplicationButton = ({
2930
2937
  onClick,
2931
- label = "Starta e-tj\xE4nsten",
2932
- className = ""
2938
+ label,
2939
+ className = "",
2940
+ activatedLanguage = "sv"
2933
2941
  }) => {
2942
+ const defaultLabel = activatedLanguage === "en" ? "Start e-service" : "Starta e-tj\xE4nsten";
2934
2943
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2935
2944
  "button",
2936
2945
  {
2937
2946
  type: "button",
2938
2947
  className: `pts-forwardButton pts-start-applicationButton ${className}`,
2939
2948
  onClick,
2940
- children: label
2949
+ children: label || defaultLabel
2941
2950
  }
2942
2951
  );
2943
2952
  };
@@ -3096,10 +3105,10 @@ var ValidationErrorSummaryList_default = ValidationErrorSummaryList;
3096
3105
 
3097
3106
  // src/components/validation-and-status/FormStatusMessagesScreenReader/FormStatusMessagesScreenReader.tsx
3098
3107
  var import_jsx_runtime29 = require("react/jsx-runtime");
3099
- var FormStatusMessagesScreenReader = ({ formStatus }) => {
3108
+ var FormStatusMessagesScreenReader = ({ formStatus, activatedLanguage = "sv" }) => {
3100
3109
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
3101
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { "aria-live": "assertive", children: formStatus === "failed" && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "pts-root-mandatoryAsterisk", children: "N\xE5got gick fel, f\xF6rs\xF6k igen senare eller kontakta oss!" }) }),
3102
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { "aria-live": "polite", className: "visually-hidden", children: formStatus === "loading" ? "Ditt \xE4rende registreras. Uppdatera eller st\xE4ng inte sidan." : "" })
3110
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { "aria-live": "assertive", children: formStatus === "failed" && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("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!" }) }),
3111
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("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." : "" })
3103
3112
  ] });
3104
3113
  };
3105
3114
  var FormStatusMessagesScreenReader_default = FormStatusMessagesScreenReader;