optimized-react-component-library-xyz123 0.19.15 → 0.19.16

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
@@ -4,9 +4,10 @@ var ValidationSummary = ({
4
4
  validationMessesege,
5
5
  validationId,
6
6
  activatedLanguage = "sv",
7
- showValidationSummary = false
7
+ showValidationSummary = false,
8
+ extraCssClass = ""
8
9
  }) => {
9
- return showValidationSummary && /* @__PURE__ */ jsxs("div", { className: "pts-root-error", id: validationId, children: [
10
+ return showValidationSummary && /* @__PURE__ */ jsxs("div", { className: `pts-root-error ${extraCssClass}`, id: validationId, children: [
10
11
  /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
11
12
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: activatedLanguage === "sv" ? "Valideringsfel" : "Validation error" }),
12
13
  /* @__PURE__ */ jsx("span", { className: "errorText", children: validationMessesege })
@@ -19,7 +20,8 @@ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
19
20
  var InputRadio = ({
20
21
  question,
21
22
  handleQuestionInputChange,
22
- showPreview = false
23
+ showPreview = false,
24
+ activatedLanguage = "sv"
23
25
  }) => {
24
26
  var _a, _b, _c;
25
27
  const questionId = `question-${question.id}`;
@@ -64,7 +66,7 @@ var InputRadio = ({
64
66
  showValidationSummary: (_b = question.hasValidationError) != null ? _b : false,
65
67
  validationId: errorId,
66
68
  validationMessesege: (_c = question.validationDefaultMessesege) != null ? _c : "",
67
- activatedLanguage: "sv"
69
+ activatedLanguage
68
70
  }
69
71
  )
70
72
  ]
@@ -177,7 +179,7 @@ var CheckboxGroup = ({
177
179
  showPreview = false,
178
180
  activatedLanguage = "sv"
179
181
  }) => {
180
- var _a;
182
+ var _a, _b, _c;
181
183
  const questionId = `question-${question.id}`;
182
184
  const errorId = `error-${question.id}`;
183
185
  const groupId = `checkbox-group-${question.id}`;
@@ -229,11 +231,15 @@ var CheckboxGroup = ({
229
231
  ),
230
232
  /* @__PURE__ */ jsx4("label", { htmlFor: `${groupId}-option-${index}`, children: option.label })
231
233
  ] }, index)),
232
- question.hasValidationError && /* @__PURE__ */ jsxs4("div", { className: "pts-root-error", id: errorId, children: [
233
- /* @__PURE__ */ jsx4("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
234
- /* @__PURE__ */ jsx4("span", { className: "sr-only", children: "Valideringsfel" }),
235
- /* @__PURE__ */ jsx4("span", { className: "errorText", children: question.validationDefaultMessesege })
236
- ] })
234
+ /* @__PURE__ */ jsx4(
235
+ ValidationMessage_default,
236
+ {
237
+ showValidationSummary: (_b = question.hasValidationError) != null ? _b : false,
238
+ validationId: errorId,
239
+ validationMessesege: (_c = question.validationDefaultMessesege) != null ? _c : "",
240
+ activatedLanguage
241
+ }
242
+ )
237
243
  ]
238
244
  }
239
245
  ) }),
@@ -266,7 +272,7 @@ var InputTextarea = ({
266
272
  showPreview = false,
267
273
  activatedLanguage
268
274
  }) => {
269
- var _a, _b, _c, _d, _e;
275
+ var _a, _b, _c, _d, _e, _f, _g;
270
276
  const questionId = `question-${question.id}`;
271
277
  const inputId = `textarea-${question.id}`;
272
278
  const aboutId = `about-${question.id}`;
@@ -309,19 +315,24 @@ var InputTextarea = ({
309
315
  }
310
316
  ),
311
317
  /* @__PURE__ */ jsxs5("div", { className: "pts-textarea-counter-error-container", children: [
312
- question.hasValidationError && /* @__PURE__ */ jsxs5("div", { className: "pts-root-error", id: errorId, children: [
313
- /* @__PURE__ */ jsx5("span", { "aria-label": "Felmeddelande.", className: "errorDot", children: "!" }),
314
- /* @__PURE__ */ jsx5("span", { className: "errorText", children: question.validationDefaultMessesege })
315
- ] }),
316
- !((_b = question.questionExtraAttribute) == null ? void 0 : _b.hideTextCounter) && /* @__PURE__ */ jsxs5(
318
+ /* @__PURE__ */ jsx5(
319
+ ValidationMessage_default,
320
+ {
321
+ showValidationSummary: (_b = question.hasValidationError) != null ? _b : false,
322
+ validationId: errorId,
323
+ validationMessesege: (_c = question.validationDefaultMessesege) != null ? _c : "",
324
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
325
+ }
326
+ ),
327
+ !((_d = question.questionExtraAttribute) == null ? void 0 : _d.hideTextCounter) && /* @__PURE__ */ jsxs5(
317
328
  "div",
318
329
  {
319
- className: `pts-character-counter ${question.answer && (((_c = question.questionExtraAttribute) == null ? void 0 : _c.answerMaxLength) || defaultMaxLength) && question.answer.length > (((_d = question.questionExtraAttribute) == null ? void 0 : _d.answerMaxLength) || defaultMaxLength) ? "error" : ""}`,
330
+ 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" : ""}`,
320
331
  children: [
321
332
  question.answer ? question.answer.length : 0,
322
333
  " av",
323
334
  " ",
324
- ((_e = question.questionExtraAttribute) == null ? void 0 : _e.answerMaxLength) || defaultMaxLength,
335
+ ((_g = question.questionExtraAttribute) == null ? void 0 : _g.answerMaxLength) || defaultMaxLength,
325
336
  " tecken"
326
337
  ]
327
338
  }
@@ -362,7 +373,7 @@ var TextFieldStandard = ({
362
373
  showPreview = false,
363
374
  activatedLanguage
364
375
  }) => {
365
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
376
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
366
377
  const questionId = `question-${question.id}`;
367
378
  const inputId = `textField-${question.id}`;
368
379
  const aboutId = `about-${question.id}`;
@@ -412,6 +423,15 @@ var TextFieldStandard = ({
412
423
  autoCapitalize: (_m = (_l = question.questionExtraAttribute) == null ? void 0 : _l.autoCapitalize) != null ? _m : void 0
413
424
  }
414
425
  ),
426
+ /* @__PURE__ */ jsx6(
427
+ ValidationMessage_default,
428
+ {
429
+ showValidationSummary: (_n = question.hasValidationError) != null ? _n : false,
430
+ validationId: errorId,
431
+ validationMessesege: (_o = question.validationDefaultMessesege) != null ? _o : "",
432
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
433
+ }
434
+ ),
415
435
  question.hasValidationError && /* @__PURE__ */ jsxs6("div", { className: "pts-root-error", id: errorId, children: [
416
436
  /* @__PURE__ */ jsx6("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
417
437
  /* @__PURE__ */ jsx6("span", { className: "sr-only", children: "Valideringsfel" }),
@@ -795,6 +815,7 @@ var AddFiles = ({
795
815
  allowedTotalFileSize = 20971520
796
816
  // 20MB = (1024 * 1024) * 20
797
817
  }) => {
818
+ var _a, _b;
798
819
  if (allowedFileTypes.length < 1) {
799
820
  allowedFileTypes = [
800
821
  "pdf",
@@ -838,7 +859,7 @@ var AddFiles = ({
838
859
  }, []);
839
860
  const onDrop = useCallback(
840
861
  (acceptedFiles) => {
841
- var _a, _b, _c;
862
+ var _a2, _b2, _c;
842
863
  const validationErrors = [];
843
864
  const validFiles = [];
844
865
  const currentTotalFileSize = (questionObject.files || []).reduce(
@@ -846,7 +867,7 @@ var AddFiles = ({
846
867
  0
847
868
  );
848
869
  setTotalFileSize(currentTotalFileSize);
849
- if ((((_a = questionObject.files) == null ? void 0 : _a.length) || 0) >= allowedNumberOfFiles) {
870
+ if ((((_a2 = questionObject.files) == null ? void 0 : _a2.length) || 0) >= allowedNumberOfFiles) {
850
871
  acceptedFiles.forEach((file) => {
851
872
  validationErrors.push({
852
873
  FileName: file.name,
@@ -859,7 +880,7 @@ var AddFiles = ({
859
880
  }
860
881
  let accumulatedNewSize = 0;
861
882
  for (const file of acceptedFiles) {
862
- const fileExtension = ((_b = file.name.split(".").pop()) == null ? void 0 : _b.toLowerCase()) || "";
883
+ const fileExtension = ((_b2 = file.name.split(".").pop()) == null ? void 0 : _b2.toLowerCase()) || "";
863
884
  if (!allowedFileTypes.includes(fileExtension)) {
864
885
  validationErrors.push({
865
886
  FileName: file.name,
@@ -972,6 +993,16 @@ var AddFiles = ({
972
993
  ]
973
994
  }
974
995
  ),
996
+ /* @__PURE__ */ jsx12(
997
+ ValidationMessage_default,
998
+ {
999
+ showValidationSummary: (_a = questionObject.hasValidationError) != null ? _a : false,
1000
+ validationId: errorId,
1001
+ validationMessesege: (_b = questionObject.validationDefaultMessesege) != null ? _b : "",
1002
+ activatedLanguage,
1003
+ extraCssClass: "error addfileserror"
1004
+ }
1005
+ ),
975
1006
  questionObject.hasValidationError && /* @__PURE__ */ jsxs10("div", { className: "pts-root-error error addfileserror", id: errorId, children: [
976
1007
  /* @__PURE__ */ jsx12("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
977
1008
  /* @__PURE__ */ jsx12("span", { className: "sr-only", children: "Valideringsfel" }),
@@ -1042,7 +1073,7 @@ var SingleCheckbox = ({
1042
1073
  showPreview = false,
1043
1074
  activatedLanguage = "sv"
1044
1075
  }) => {
1045
- var _a, _b;
1076
+ var _a, _b, _c, _d;
1046
1077
  const questionId = `question-${question.id}`;
1047
1078
  const inputId = `checkbox-${question.id}`;
1048
1079
  const aboutId = `about-${question.id}`;
@@ -1095,12 +1126,15 @@ var SingleCheckbox = ({
1095
1126
  }
1096
1127
  ),
1097
1128
  " ",
1098
- question.hasValidationError && /* @__PURE__ */ jsxs11("div", { className: "pts-root-error", id: errorId, children: [
1099
- /* @__PURE__ */ jsx13("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
1100
- /* @__PURE__ */ jsx13("span", { className: "sr-only", children: "Valideringsfel" }),
1101
- /* @__PURE__ */ jsx13("span", { className: "errorText", children: question.validationDefaultMessesege })
1102
- ] }),
1103
- " "
1129
+ /* @__PURE__ */ jsx13(
1130
+ ValidationMessage_default,
1131
+ {
1132
+ showValidationSummary: (_c = question.hasValidationError) != null ? _c : false,
1133
+ validationId: errorId,
1134
+ validationMessesege: (_d = question.validationDefaultMessesege) != null ? _d : "",
1135
+ activatedLanguage
1136
+ }
1137
+ )
1104
1138
  ] }),
1105
1139
  " ",
1106
1140
  showPreview && /* @__PURE__ */ jsx13(PreviewSingleCheckbox, { activatedLanguage, question })
@@ -1921,11 +1955,12 @@ var QuestionGroup = ({
1921
1955
  showPreview = false,
1922
1956
  markQuestionAsDisplayed
1923
1957
  }) => {
1924
- var _a;
1958
+ var _a, _b, _c;
1925
1959
  if (!questions || questions.length === 0) {
1926
1960
  return null;
1927
1961
  }
1928
1962
  const firstQuestion = questions[0];
1963
+ const errorId = firstQuestion.id + "-error";
1929
1964
  const groupMandatory = (_a = firstQuestion.validationType) == null ? void 0 : _a.find((e) => e.startsWith("groupCheck-"));
1930
1965
  useEffect11(() => {
1931
1966
  questions.forEach((question) => {
@@ -1966,10 +2001,15 @@ var QuestionGroup = ({
1966
2001
  firstQuestion.validationDefaultMessesege
1967
2002
  ] })
1968
2003
  ] }),
1969
- firstQuestion.hasValidationError && /* @__PURE__ */ jsxs13("div", { className: "pts-root-error", id: firstQuestion.id + "-error", children: [
1970
- /* @__PURE__ */ jsx15("span", { "aria-label": "Valideringsfel", className: "errorDot", children: "!" }),
1971
- /* @__PURE__ */ jsx15("span", { className: "errorText", children: firstQuestion.validationDefaultMessesege })
1972
- ] }),
2004
+ /* @__PURE__ */ jsx15(
2005
+ ValidationMessage_default,
2006
+ {
2007
+ showValidationSummary: (_b = firstQuestion.hasValidationError) != null ? _b : false,
2008
+ validationId: errorId,
2009
+ validationMessesege: (_c = firstQuestion.validationDefaultMessesege) != null ? _c : "",
2010
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv"
2011
+ }
2012
+ ),
1973
2013
  groupQuestions
1974
2014
  ]
1975
2015
  }