optimized-react-component-library-xyz123 0.28.6 → 0.28.8

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
@@ -74,11 +74,11 @@ var InputRadio = ({
74
74
  ]
75
75
  }
76
76
  ) }),
77
- showPreview && /* @__PURE__ */ jsx2(PreviewRadio, { question })
77
+ showPreview && /* @__PURE__ */ jsx2(PreviewRadio, { question, activatedLanguage })
78
78
  ] });
79
79
  };
80
80
  var RadioMultipleStandard_default = InputRadio;
81
- var PreviewRadio = ({ question }) => {
81
+ var PreviewRadio = ({ question, activatedLanguage }) => {
82
82
  var _a, _b;
83
83
  const previewId = `preview-${question.id}`;
84
84
  return /* @__PURE__ */ jsxs2(Fragment, { children: [
@@ -88,7 +88,7 @@ var PreviewRadio = ({ question }) => {
88
88
  {
89
89
  className: "pts-radioMultiple-preview pts-root-answer no-answer-preview-page",
90
90
  id: `answer-${previewId}`,
91
- children: "Inget svar"
91
+ children: activatedLanguage === "en" ? "No answer" : "Inget svar"
92
92
  }
93
93
  )
94
94
  ] });
@@ -110,17 +110,17 @@ var MultipleCheckboxes = ({
110
110
  var _a2;
111
111
  const initialValues = ((_a2 = question.options) == null ? void 0 : _a2.filter((option) => {
112
112
  var _a3;
113
- return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.label);
114
- }).map((option) => option.label)) || [];
113
+ return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.id);
114
+ }).map((option) => option.id)) || [];
115
115
  console.log("Initial values:", initialValues);
116
116
  setCheckedValues(initialValues);
117
117
  }, [question.answer, question.options]);
118
- const handleInputChange = (event, optionValue) => {
118
+ const handleInputChange = (event, optionId) => {
119
119
  let updatedValues = [...checkedValues];
120
- if (updatedValues.includes(optionValue)) {
121
- updatedValues = updatedValues.filter((val) => val !== optionValue);
120
+ if (updatedValues.includes(optionId)) {
121
+ updatedValues = updatedValues.filter((val) => val !== optionId);
122
122
  } else {
123
- updatedValues.push(optionValue);
123
+ updatedValues.push(optionId);
124
124
  }
125
125
  setCheckedValues(updatedValues);
126
126
  const e = { target: { value: updatedValues.toString() } };
@@ -142,9 +142,9 @@ var MultipleCheckboxes = ({
142
142
  type: "checkbox",
143
143
  name: `${question.id}-option`,
144
144
  id: `${question.id}-option-${index}`,
145
- value: option.label,
146
- checked: checkedValues.includes(option.label),
147
- onChange: (e) => handleInputChange(e, option.label),
145
+ value: option.id,
146
+ checked: checkedValues.includes(option.id),
147
+ onChange: (e) => handleInputChange(e, option.id),
148
148
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0
149
149
  }
150
150
  ),
@@ -166,7 +166,7 @@ var PrevieMultipleCheckboxes = ({
166
166
  /* @__PURE__ */ jsx3("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
167
167
  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) => {
168
168
  var _a2;
169
- return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.label);
169
+ return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.id);
170
170
  }).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" }),
171
171
  " "
172
172
  ] });
@@ -190,8 +190,8 @@ var CheckboxGroup = ({
190
190
  var _a2;
191
191
  const initialValues = ((_a2 = question.options) == null ? void 0 : _a2.filter((option) => {
192
192
  var _a3;
193
- return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.label);
194
- }).map((option) => option.label)) || [];
193
+ return (_a3 = question.answer) == null ? void 0 : _a3.includes(option.id);
194
+ }).map((option) => option.id)) || [];
195
195
  setCheckedValues(initialValues);
196
196
  }, [question.answer, question.options]);
197
197
  const handleInputChange = (event, optionValue) => {
@@ -225,9 +225,9 @@ var CheckboxGroup = ({
225
225
  type: "checkbox",
226
226
  name: `name-${question.id}`,
227
227
  id: `${groupId}-option-${index}`,
228
- value: option.label,
229
- checked: checkedValues.includes(option.label),
230
- onChange: (e) => handleInputChange(e, option.label),
228
+ value: option.id,
229
+ checked: checkedValues.includes(option.id),
230
+ onChange: (e) => handleInputChange(e, option.id),
231
231
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0
232
232
  }
233
233
  ),
@@ -259,7 +259,7 @@ var PreviewCheckboxGroup = ({
259
259
  /* @__PURE__ */ jsx4("dt", { id: `question-${previewId}`, children: (_a = question.previewLabel) != null ? _a : question.questionLabel }),
260
260
  question.answer ? question.options && question.options.length === 1 ? /* @__PURE__ */ jsx4("dd", { children: question.options[0].label }) : /* @__PURE__ */ jsx4("dd", { children: /* @__PURE__ */ jsx4("ul", { className: "pts-preview-answer-list", children: (_b = question.options) == null ? void 0 : _b.filter((option) => {
261
261
  var _a2;
262
- return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.label);
262
+ return (_a2 = question.answer) == null ? void 0 : _a2.includes(option.id);
263
263
  }).map((option, index) => /* @__PURE__ */ jsx4("li", { children: option.label }, index)) }) }) : /* @__PURE__ */ jsx4("dd", { className: "no-answer-preview-page", children: activatedLanguage === "en" ? "No Answer" : "Inget svar" }),
264
264
  " "
265
265
  ] });
@@ -274,12 +274,17 @@ var InputTextarea = ({
274
274
  showPreview = false,
275
275
  activatedLanguage
276
276
  }) => {
277
- var _a, _b, _c, _d, _e, _f, _g;
277
+ var _a, _b, _c, _d, _e, _f;
278
278
  const questionId = `question-${question.id}`;
279
279
  const inputId = `textarea-${question.id}`;
280
280
  const aboutId = `about-${question.id}`;
281
281
  const errorId = `error-${question.id}`;
282
282
  const defaultMaxLength = 1e3;
283
+ const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
284
+ const maxLength = (_d = (_c = question.questionExtraAttribute) == null ? void 0 : _c.answerMaxLength) != null ? _d : defaultMaxLength;
285
+ const isTooLong = answerLength > maxLength;
286
+ const counterText = activatedLanguage === "en" ? `${answerLength} of ${maxLength} characters` : `${answerLength} av ${maxLength} tecken`;
287
+ const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r max vara ${maxLength} tecken`;
283
288
  return /* @__PURE__ */ jsxs5(Fragment4, { children: [
284
289
  !showPreview && question.visible && /* @__PURE__ */ jsxs5(
285
290
  "div",
@@ -311,34 +316,30 @@ var InputTextarea = ({
311
316
  required: question.isQuestionMandatory,
312
317
  "aria-required": question.isQuestionMandatory,
313
318
  "aria-invalid": question.hasValidationError,
314
- maxLength: ((_a = question.questionExtraAttribute) == null ? void 0 : _a.answerMaxLength) || defaultMaxLength,
315
319
  "aria-describedby": [question.aboutText ? aboutId : null, question.hasValidationError ? errorId : null].filter(Boolean).join(" ") || void 0,
316
320
  id: inputId
317
321
  }
318
322
  ),
319
323
  /* @__PURE__ */ jsxs5("div", { className: "pts-textarea-counter-error-container", children: [
320
- /* @__PURE__ */ jsx5(
324
+ !isTooLong && question.hasValidationError && /* @__PURE__ */ jsx5(
321
325
  ValidationMessage_default,
322
326
  {
323
- showValidationMessage: (_b = question.hasValidationError) != null ? _b : false,
327
+ showValidationMessage: true,
324
328
  validationId: errorId,
325
- validationMessesege: (_c = question.validationDefaultMessesege) != null ? _c : "",
329
+ validationMessesege: (_e = question.validationDefaultMessesege) != null ? _e : "",
326
330
  activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
327
331
  }
328
332
  ),
329
- !((_d = question.questionExtraAttribute) == null ? void 0 : _d.hideTextCounter) && /* @__PURE__ */ jsxs5(
330
- "div",
333
+ isTooLong && question.hasValidationError && /* @__PURE__ */ jsx5(
334
+ ValidationMessage_default,
331
335
  {
332
- className: `pts-character-counter ${question.answer && (((_e = question.questionExtraAttribute) == null ? void 0 : _e.answerMaxLength) || defaultMaxLength) && question.answer.length > (((_f = question.questionExtraAttribute) == null ? void 0 : _f.answerMaxLength) || defaultMaxLength) ? "error" : ""}`,
333
- children: [
334
- question.answer ? question.answer.length : 0,
335
- " av",
336
- " ",
337
- ((_g = question.questionExtraAttribute) == null ? void 0 : _g.answerMaxLength) || defaultMaxLength,
338
- " tecken"
339
- ]
336
+ showValidationMessage: true,
337
+ validationId: errorId,
338
+ validationMessesege: maxLengthErrorText,
339
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
340
340
  }
341
- )
341
+ ),
342
+ !((_f = question.questionExtraAttribute) == null ? void 0 : _f.hideTextCounter) && /* @__PURE__ */ jsx5("div", { "aria-live": "polite", className: `pts-character-counter`, children: counterText })
342
343
  ] })
343
344
  ]
344
345
  }
@@ -380,13 +381,16 @@ var TextFieldStandard = ({
380
381
  const inputId = `textField-${question.id}`;
381
382
  const aboutId = `about-${question.id}`;
382
383
  const errorId = `error-${question.id}`;
383
- const defaultMaxLength = 1e3;
384
+ const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
385
+ const maxLength = 100;
386
+ const isTooLong = answerLength > maxLength;
387
+ const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r max vara ${maxLength} tecken`;
384
388
  return /* @__PURE__ */ jsxs6(Fragment5, { children: [
385
389
  !showPreview && question.visible && /* @__PURE__ */ jsxs6(
386
390
  "div",
387
391
  {
388
392
  id: questionId,
389
- className: `pts-root-question pts-textField-container${((_a = question.questionExtraAttribute) == null ? void 0 : _a.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
393
+ className: `pts-root-question pts-textField-container${((_c = question.questionExtraAttribute) == null ? void 0 : _c.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
390
394
  children: [
391
395
  /* @__PURE__ */ jsxs6("label", { htmlFor: inputId, children: [
392
396
  question.questionLabel,
@@ -406,33 +410,41 @@ var TextFieldStandard = ({
406
410
  /* @__PURE__ */ jsx6(
407
411
  "input",
408
412
  {
409
- type: (_c = (_b = question.questionExtraAttribute) == null ? void 0 : _b.inputType) != null ? _c : "text",
410
- autoComplete: (_e = (_d = question.questionExtraAttribute) == null ? void 0 : _d.autoComplete) != null ? _e : void 0,
411
- inputMode: (_g = (_f = question.questionExtraAttribute) == null ? void 0 : _f.inputMode) != null ? _g : void 0,
413
+ type: (_e = (_d = question.questionExtraAttribute) == null ? void 0 : _d.inputType) != null ? _e : "text",
414
+ autoComplete: (_g = (_f = question.questionExtraAttribute) == null ? void 0 : _f.autoComplete) != null ? _g : void 0,
415
+ inputMode: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.inputMode) != null ? _i : void 0,
412
416
  name: `question-name-${question.id}`,
413
417
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
414
418
  onChange: (e) => handleQuestionInputChange(e, question),
415
419
  value: question.answer,
416
- maxLength: ((_h = question.questionExtraAttribute) == null ? void 0 : _h.answerMaxLength) || defaultMaxLength,
417
420
  id: inputId,
418
- disabled: (_i = question.questionExtraAttribute) == null ? void 0 : _i.disabled,
421
+ disabled: (_j = question.questionExtraAttribute) == null ? void 0 : _j.disabled,
419
422
  required: question.isQuestionMandatory,
420
423
  "aria-required": question.isQuestionMandatory,
421
424
  "aria-describedby": [question.aboutText ? aboutId : null].filter(Boolean).join(" ") || void 0,
422
425
  "aria-invalid": question.hasValidationError,
423
426
  "aria-errormessage": question.hasValidationError ? errorId : void 0,
424
- spellCheck: (_k = (_j = question.questionExtraAttribute) == null ? void 0 : _j.spellCheck) != null ? _k : void 0,
425
- autoCapitalize: (_m = (_l = question.questionExtraAttribute) == null ? void 0 : _l.autoCapitalize) != null ? _m : void 0
427
+ spellCheck: (_l = (_k = question.questionExtraAttribute) == null ? void 0 : _k.spellCheck) != null ? _l : void 0,
428
+ autoCapitalize: (_n = (_m = question.questionExtraAttribute) == null ? void 0 : _m.autoCapitalize) != null ? _n : void 0
426
429
  }
427
430
  ),
428
- /* @__PURE__ */ jsx6(
431
+ !isTooLong && question.hasValidationError && /* @__PURE__ */ jsx6(
429
432
  ValidationMessage_default,
430
433
  {
431
- showValidationMessage: (_n = question.hasValidationError) != null ? _n : false,
434
+ showValidationMessage: true,
432
435
  validationId: errorId,
433
436
  validationMessesege: (_o = question.validationDefaultMessesege) != null ? _o : "",
434
437
  activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
435
438
  }
439
+ ),
440
+ isTooLong && question.hasValidationError && /* @__PURE__ */ jsx6(
441
+ ValidationMessage_default,
442
+ {
443
+ showValidationMessage: true,
444
+ validationId: errorId,
445
+ validationMessesege: maxLengthErrorText,
446
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
447
+ }
436
448
  )
437
449
  ]
438
450
  }
@@ -658,14 +670,12 @@ var SelectedFiles = ({
658
670
  let newFiles = questionObject.files.filter((f) => f !== file);
659
671
  const newCountOfFiles = newFiles.length;
660
672
  setNumberOfFiles(newCountOfFiles);
661
- const e = { target: { value: `${newCountOfFiles} files`, files: newFiles } };
673
+ let e = { target: { value: `${newCountOfFiles} files`, files: newFiles } };
674
+ const targetValue = e.target.value === "0 files" ? "" : e.target.value;
675
+ e = { ...e, target: { ...e.target, value: targetValue } };
662
676
  isTouched(e, questionObject);
663
677
  removeFile(newCountOfFiles);
664
678
  };
665
- useEffect4(() => {
666
- var _a;
667
- numberOfFiles > 0 && ((_a = theDiv.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" }));
668
- }, [numberOfFiles]);
669
679
  const useWindowWidth = () => {
670
680
  const [windowWidth2, setWindowWidth] = useState4(window.innerWidth);
671
681
  useEffect4(() => {
@@ -738,7 +748,7 @@ var SelectedFiles = ({
738
748
  }
739
749
  ) })
740
750
  ] }) }),
741
- questionObject.files.length > 0 && /* @__PURE__ */ jsx11("ul", { className: "fileListUnorderedList", "aria-label": "Uppladdade filer", children: questionObject.files.map((file, index) => {
751
+ questionObject.files.length > 0 && /* @__PURE__ */ jsx11("ul", { className: "fileListUnorderedList", "aria-label": activatedLanguage === "en" ? "Uploaded files" : "Uppladdade filer", children: questionObject.files.map((file, index) => {
742
752
  const indicatorfileName = file.FileName;
743
753
  let mobileFirstFileName = file.FileName.split(".").shift();
744
754
  mobileFirstFileName = mobileFirstFileName.length > 8 ? mobileFirstFileName.substring(0, 8) + ".." : mobileFirstFileName;
@@ -949,7 +959,7 @@ var AddFiles = ({
949
959
  const currentFiles = questionObject.files ? questionObject.files : [];
950
960
  const e = {
951
961
  target: {
952
- value: `${currentFiles.length + newFiles.length} files`,
962
+ value: currentFiles.length + newFiles.length > 0 ? `${currentFiles.length + newFiles.length} files` : "",
953
963
  files: [...currentFiles, ...newFiles]
954
964
  }
955
965
  };
@@ -972,73 +982,80 @@ var AddFiles = ({
972
982
  setErrorMessageAddingFile([]);
973
983
  };
974
984
  return /* @__PURE__ */ jsxs10(Fragment11, { children: [
975
- !showPreview && visible && /* @__PURE__ */ jsx12("div", { className: "root-question addFile-question-container", id: `question-${questionObject.id}`, children: /* @__PURE__ */ jsxs10("div", { role: "group", children: [
976
- questionObject.aboutText && /* @__PURE__ */ jsxs10(
977
- "p",
978
- {
979
- id: aboutId,
980
- className: clsx3(
981
- "addFilesMandatory",
982
- questionObject.hasValidationError ? " error" : ""
985
+ !showPreview && visible && /* @__PURE__ */ jsx12(
986
+ "div",
987
+ {
988
+ className: "root-question addFile-question-container",
989
+ id: `question-${questionObject.id}`,
990
+ children: /* @__PURE__ */ jsxs10("div", { role: "group", children: [
991
+ questionObject.aboutText && /* @__PURE__ */ jsxs10(
992
+ "p",
993
+ {
994
+ id: aboutId,
995
+ className: clsx3(
996
+ "addFilesMandatory",
997
+ questionObject.hasValidationError ? " error" : ""
998
+ ),
999
+ children: [
1000
+ questionObject.aboutText,
1001
+ questionObject.isQuestionMandatory && /* @__PURE__ */ jsxs10("span", { className: "pts-root-mandatoryAsterisk", "aria-label": "Obligatorisk fr\xE5ga", children: [
1002
+ " ",
1003
+ "*"
1004
+ ] })
1005
+ ]
1006
+ }
983
1007
  ),
984
- children: [
985
- questionObject.aboutText,
986
- questionObject.isQuestionMandatory && /* @__PURE__ */ jsxs10("span", { className: "pts-root-mandatoryAsterisk", "aria-label": "Obligatorisk fr\xE5ga", children: [
987
- " ",
988
- "*"
989
- ] })
990
- ]
991
- }
992
- ),
993
- /* @__PURE__ */ jsx12(
994
- ValidationMessage_default,
995
- {
996
- showValidationMessage: (_a = questionObject.hasValidationError) != null ? _a : false,
997
- validationId: errorId,
998
- validationMessesege: (_b = questionObject.validationDefaultMessesege) != null ? _b : "",
999
- activatedLanguage,
1000
- extraCssClass: "error addfileserror"
1001
- }
1002
- ),
1003
- /* @__PURE__ */ jsx12(
1004
- ExploreFilesStandard_default,
1005
- {
1006
- FilesSelected: onDrop,
1007
- numberOfFiles,
1008
- allowedNumberOfFiles,
1009
- activatedLanguage,
1010
- inputId,
1011
- labelId,
1012
- aboutId,
1013
- errorId,
1014
- questionObject,
1015
- errorMessageAddingFile,
1016
- removeUploadErrors: handleRemoveErrors
1017
- }
1018
- ),
1019
- /* @__PURE__ */ jsx12(
1020
- DropFilesStandard_default,
1021
- {
1022
- FilesSelected: onDrop,
1023
- DropFilesText: dropFilesText,
1024
- language: activatedLanguage
1025
- }
1026
- ),
1027
- /* @__PURE__ */ jsx12(
1028
- SelectedFilesStandard_default,
1029
- {
1030
- questionObject,
1031
- isTouched: handleQuestionInputChange,
1032
- removeFile: removeFileFromNumberOfFiles,
1033
- removeError,
1034
- errorMessageAddingFile,
1035
- activatedLanguage,
1036
- numberOfFiles,
1037
- setNumberOfFiles,
1038
- removeUploadErrors: handleRemoveErrors
1039
- }
1040
- )
1041
- ] }) }),
1008
+ /* @__PURE__ */ jsx12(
1009
+ ValidationMessage_default,
1010
+ {
1011
+ showValidationMessage: (_a = questionObject.hasValidationError) != null ? _a : false,
1012
+ validationId: errorId,
1013
+ validationMessesege: (_b = questionObject.validationDefaultMessesege) != null ? _b : "",
1014
+ activatedLanguage,
1015
+ extraCssClass: "error addfileserror"
1016
+ }
1017
+ ),
1018
+ /* @__PURE__ */ jsx12(
1019
+ ExploreFilesStandard_default,
1020
+ {
1021
+ FilesSelected: onDrop,
1022
+ numberOfFiles,
1023
+ allowedNumberOfFiles,
1024
+ activatedLanguage,
1025
+ inputId,
1026
+ labelId,
1027
+ aboutId,
1028
+ errorId,
1029
+ questionObject,
1030
+ errorMessageAddingFile,
1031
+ removeUploadErrors: handleRemoveErrors
1032
+ }
1033
+ ),
1034
+ /* @__PURE__ */ jsx12(
1035
+ DropFilesStandard_default,
1036
+ {
1037
+ FilesSelected: onDrop,
1038
+ DropFilesText: dropFilesText,
1039
+ language: activatedLanguage
1040
+ }
1041
+ ),
1042
+ /* @__PURE__ */ jsx12(
1043
+ SelectedFilesStandard_default,
1044
+ {
1045
+ questionObject,
1046
+ isTouched: handleQuestionInputChange,
1047
+ removeFile: removeFileFromNumberOfFiles,
1048
+ removeError,
1049
+ errorMessageAddingFile,
1050
+ activatedLanguage,
1051
+ numberOfFiles,
1052
+ setNumberOfFiles,
1053
+ removeUploadErrors: handleRemoveErrors
1054
+ }
1055
+ )
1056
+ ] })
1057
+ }
1058
+ ),
1042
1059
  showPreview && /* @__PURE__ */ jsx12(PreviewAddFiles, { activatedLanguage, questionObject })
1043
1060
  ] });
1044
1061
  };
@@ -1155,7 +1172,7 @@ var PreviewSingleCheckbox = ({
1155
1172
  // src/helpers/hasQuestionValidationError/hasQuestionValidationError.tsx
1156
1173
  import { isValid, parseISO } from "date-fns";
1157
1174
  var hasQuestionValidationError = (question, questions) => {
1158
- var _a, _b, _c, _d, _e;
1175
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1159
1176
  let error = false;
1160
1177
  if (question.isQuestionMandatory) {
1161
1178
  if (question.isTouched === false) {
@@ -1168,19 +1185,28 @@ var hasQuestionValidationError = (question, questions) => {
1168
1185
  error = true;
1169
1186
  }
1170
1187
  }
1171
- if (((_b = question.validationType) == null ? void 0 : _b.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1188
+ const maxLength = (_c = (_b = question.questionExtraAttribute) == null ? void 0 : _b.answerMaxLength) != null ? _c : 1e3;
1189
+ if (((_d = question.validationType) == null ? void 0 : _d.includes("maxLength")) && question.answer.length > maxLength) {
1190
+ error = true;
1191
+ }
1192
+ if (question.questionType === "TextField") {
1193
+ if (question.answer.length > 100) {
1194
+ error = true;
1195
+ }
1196
+ }
1197
+ if (((_e = question.validationType) == null ? void 0 : _e.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1172
1198
  const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
1173
1199
  if (!emailRegex.test(question.answer)) {
1174
1200
  error = true;
1175
1201
  }
1176
1202
  }
1177
- if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
1203
+ if (((_f = question.validationType) == null ? void 0 : _f.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
1178
1204
  const fourNumbersRegex = /^\d{4}$/.test(question.answer);
1179
1205
  if (!fourNumbersRegex) {
1180
1206
  error = true;
1181
1207
  }
1182
1208
  }
1183
- if (((_d = question.validationType) == null ? void 0 : _d.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
1209
+ if (((_g = question.validationType) == null ? void 0 : _g.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
1184
1210
  const regex = /^\d{4}-\d{2}-\d{2}$/;
1185
1211
  if (!regex.test(question.answer)) {
1186
1212
  error = true;
@@ -1194,16 +1220,18 @@ var hasQuestionValidationError = (question, questions) => {
1194
1220
  error = true;
1195
1221
  }
1196
1222
  }
1197
- const groupCheckError = (_e = question.validationType) == null ? void 0 : _e.find((e) => e.startsWith("groupCheck-"));
1223
+ const groupCheckError = (_h = question.validationType) == null ? void 0 : _h.find((e) => e.startsWith("groupCheck-"));
1198
1224
  if (groupCheckError) {
1199
1225
  const ids = groupCheckError.replace("groupCheck-", "").split("-");
1200
- const relatedAnswers = ids.map((id) => {
1201
- var _a2;
1202
- return (_a2 = questions.find((q) => {
1203
- var _a3;
1204
- return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
1205
- })) == null ? void 0 : _a2.answer;
1206
- });
1226
+ const relatedAnswers = ids.map(
1227
+ (id) => {
1228
+ var _a2;
1229
+ return (_a2 = questions.find((q) => {
1230
+ var _a3;
1231
+ return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
1232
+ })) == null ? void 0 : _a2.answer;
1233
+ }
1234
+ );
1207
1235
  const currentAnswer = question.answer;
1208
1236
  const allAnswers = [...relatedAnswers, currentAnswer];
1209
1237
  if (allAnswers.every((ans) => ans === "")) {
@@ -1224,7 +1252,7 @@ function createApiDataObject(data, specialMappedQuestions, translatedAnswers) {
1224
1252
  let translatedAnswer = question.answer;
1225
1253
  if (question.answer && typeof question.answer === "string" && Array.isArray(question.options) && question.mappingId && specialMappedQuestions.has(question.mappingId)) {
1226
1254
  const answerNormalized = normalize(question.answer);
1227
- const matchingIds = question.options.filter((option) => answerNormalized.includes(normalize(option.label))).map((option) => `^${option.id}^`);
1255
+ const matchingIds = question.options.filter((option) => answerNormalized.includes(normalize(option.id))).map((option) => `^${option.id}^`);
1228
1256
  if (matchingIds.length > 0) {
1229
1257
  translatedAnswer = matchingIds.join(",");
1230
1258
  }
@@ -2024,7 +2052,8 @@ var CookieBanner = ({
2024
2052
  onCookieStateChange,
2025
2053
  onClose,
2026
2054
  acceptCookies,
2027
- rejectCookies
2055
+ rejectCookies,
2056
+ activatedLanguage = "sv"
2028
2057
  }) => {
2029
2058
  if (!visible) return null;
2030
2059
  const handleCookieChoice = (accepted) => {
@@ -2051,8 +2080,13 @@ var CookieBanner = ({
2051
2080
  id: "cookie-banner",
2052
2081
  tabIndex: -1,
2053
2082
  children: /* @__PURE__ */ jsxs14("div", { className: "content", children: [
2054
- /* @__PURE__ */ jsx16("h3", { id: "cookie-banner-title", children: "Kakor (cookies)" }),
2055
- /* @__PURE__ */ jsx16("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." }),
2083
+ /* @__PURE__ */ jsxs14("h3", { id: "cookie-banner-title", children: [
2084
+ " ",
2085
+ activatedLanguage === "en" ? "Cookies" : "Kakor (cookies)"
2086
+ ] }),
2087
+ /* @__PURE__ */ jsx16("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.
2088
+ Samtycker du till det? Du kan n\xE4r som helst \xE4ndra ditt val. F\xF6r att \xE5terkalla ditt
2089
+ samtycke klickar du p\xE5 \u201DKakor\u201D i avsnittet l\xE4ngst ned p\xE5 webbplatsen.` }),
2056
2090
  /* @__PURE__ */ jsxs14("div", { className: "pts-cookieBanner-Links", children: [
2057
2091
  /* @__PURE__ */ jsxs14(
2058
2092
  "svg",
@@ -2081,13 +2115,13 @@ var CookieBanner = ({
2081
2115
  href: "https://pts.se/om-oss/om-pts.se/kakor-pa-webbplatsen/kakor-pa-pts-e-tjanster/",
2082
2116
  target: "_blank",
2083
2117
  rel: "noopener noreferrer",
2084
- children: "Kakor (cookies) p\xE5 pts.se (\xF6ppnas i nytt f\xF6nster)"
2118
+ children: activatedLanguage === "en" ? "Cookies on pts.se (opens in new tab)" : "Kakor (cookies) p\xE5 pts.se (\xF6ppnas i ny flik)"
2085
2119
  }
2086
2120
  )
2087
2121
  ] }),
2088
2122
  /* @__PURE__ */ jsxs14("div", { className: "pts-cookieBanner-Buttons", children: [
2089
- /* @__PURE__ */ jsx16("button", { onClick: () => handleCookieChoice(true), children: "Ja, jag samtycker" }),
2090
- /* @__PURE__ */ jsx16("button", { onClick: () => handleCookieChoice(false), children: "Nej, jag samtycker inte" })
2123
+ /* @__PURE__ */ jsx16("button", { onClick: () => handleCookieChoice(true), children: activatedLanguage === "en" ? "Yes, I consent" : "Ja, jag samtycker" }),
2124
+ /* @__PURE__ */ jsx16("button", { onClick: () => handleCookieChoice(false), children: activatedLanguage === "en" ? "No, I do not consent" : "Nej, jag samtycker inte" })
2091
2125
  ] })
2092
2126
  ] })
2093
2127
  }
@@ -2193,7 +2227,7 @@ var LanguageIcon = () => /* @__PURE__ */ jsx18("svg", { width: "15", height: "15
2193
2227
  fill: "#6E3282"
2194
2228
  }
2195
2229
  ) });
2196
- var Logo_sv = () => /* @__PURE__ */ jsxs16("svg", { width: "168.8", height: "46.67", viewBox: "0 0 168.8 46.67", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
2230
+ var Logo_sv = () => /* @__PURE__ */ jsxs16("svg", { width: "168.8", height: "40", viewBox: "0 0 168.8 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
2197
2231
  /* @__PURE__ */ jsx18(
2198
2232
  "path",
2199
2233
  {
@@ -2339,7 +2373,7 @@ var Logo_sv = () => /* @__PURE__ */ jsxs16("svg", { width: "168.8", height: "46.
2339
2373
  ),
2340
2374
  /* @__PURE__ */ jsx18("path", { d: "M82.2223 18.3335V37.2224", stroke: "currentColor", strokeWidth: "0.8", strokeMiterlimit: "10" })
2341
2375
  ] });
2342
- var Logo_en = () => /* @__PURE__ */ jsxs16("svg", { width: "189.0", height: "46.67", viewBox: "0 0 189 46.67", fill: "none", xmlns: "http://www.w3.org/2000/svg", role: "img", children: [
2376
+ var Logo_en = () => /* @__PURE__ */ jsxs16("svg", { width: "189.0", height: "40", viewBox: "0 0 189 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", role: "img", children: [
2343
2377
  /* @__PURE__ */ jsx18(
2344
2378
  "path",
2345
2379
  {
@@ -2635,9 +2669,9 @@ var ModalStandard_default = Modal;
2635
2669
 
2636
2670
  // src/components/layout/SkipLinkStandard/SkipLinkStandard.tsx
2637
2671
  import { jsx as jsx21 } from "react/jsx-runtime";
2638
- var SkipLink = () => {
2672
+ var SkipLink = ({ activatedLanguage = "sv" }) => {
2639
2673
  function scrollToMainContent() {
2640
- const container = document.getElementById(`main-content`);
2674
+ const container = document.getElementById(`pts-main-service-headline`);
2641
2675
  if (container) {
2642
2676
  container.scrollIntoView({ behavior: "smooth", block: "center" });
2643
2677
  container.focus();
@@ -2651,7 +2685,7 @@ var SkipLink = () => {
2651
2685
  e.preventDefault();
2652
2686
  scrollToMainContent();
2653
2687
  },
2654
- children: "Till huvudinneh\xE5ll"
2688
+ children: activatedLanguage === "en" ? "Skip to main content" : "Till huvudinneh\xE5ll"
2655
2689
  }
2656
2690
  ) });
2657
2691
  };
@@ -2883,16 +2917,18 @@ var EditPreviewLinkStandard_default = EditPreviewLink;
2883
2917
  import { jsx as jsx26 } from "react/jsx-runtime";
2884
2918
  var StartApplicationButton = ({
2885
2919
  onClick,
2886
- label = "Starta e-tj\xE4nsten",
2887
- className = ""
2920
+ label,
2921
+ className = "",
2922
+ activatedLanguage = "sv"
2888
2923
  }) => {
2924
+ const defaultLabel = activatedLanguage === "en" ? "Start e-service" : "Starta e-tj\xE4nsten";
2889
2925
  return /* @__PURE__ */ jsx26(
2890
2926
  "button",
2891
2927
  {
2892
2928
  type: "button",
2893
2929
  className: `pts-forwardButton pts-start-applicationButton ${className}`,
2894
2930
  onClick,
2895
- children: label
2931
+ children: label || defaultLabel
2896
2932
  }
2897
2933
  );
2898
2934
  };
@@ -3051,10 +3087,10 @@ var ValidationErrorSummaryList_default = ValidationErrorSummaryList;
3051
3087
 
3052
3088
  // src/components/validation-and-status/FormStatusMessagesScreenReader/FormStatusMessagesScreenReader.tsx
3053
3089
  import { Fragment as Fragment17, jsx as jsx30, jsxs as jsxs24 } from "react/jsx-runtime";
3054
- var FormStatusMessagesScreenReader = ({ formStatus }) => {
3090
+ var FormStatusMessagesScreenReader = ({ formStatus, activatedLanguage = "sv" }) => {
3055
3091
  return /* @__PURE__ */ jsxs24(Fragment17, { children: [
3056
- /* @__PURE__ */ jsx30("p", { "aria-live": "assertive", children: formStatus === "failed" && /* @__PURE__ */ jsx30("span", { className: "pts-root-mandatoryAsterisk", children: "N\xE5got gick fel, f\xF6rs\xF6k igen senare eller kontakta oss!" }) }),
3057
- /* @__PURE__ */ jsx30("div", { "aria-live": "polite", className: "visually-hidden", children: formStatus === "loading" ? "Ditt \xE4rende registreras. Uppdatera eller st\xE4ng inte sidan." : "" })
3092
+ /* @__PURE__ */ jsx30("p", { "aria-live": "assertive", children: formStatus === "failed" && /* @__PURE__ */ jsx30("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!" }) }),
3093
+ /* @__PURE__ */ jsx30("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." : "" })
3058
3094
  ] });
3059
3095
  };
3060
3096
  var FormStatusMessagesScreenReader_default = FormStatusMessagesScreenReader;