optimized-react-component-library-xyz123 0.19.21 → 0.19.22

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
@@ -251,6 +251,11 @@ var InputTextarea = ({
251
251
  const aboutId = `about-${question.id}`;
252
252
  const errorId = `error-${question.id}`;
253
253
  const defaultMaxLength = 1e3;
254
+ const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
255
+ const maxLength = (_d = (_c = question.questionExtraAttribute) == null ? void 0 : _c.answerMaxLength) != null ? _d : defaultMaxLength;
256
+ const isTooLong = answerLength > maxLength;
257
+ const counterText = activatedLanguage === "en" ? `${answerLength} of ${maxLength} characters` : `${answerLength} av ${maxLength} tecken`;
258
+ const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r max vara ${maxLength} tecken`;
254
259
  return /* @__PURE__ */ jsxs4(Fragment4, { children: [
255
260
  !showPreview && question.visible && /* @__PURE__ */ jsxs4(
256
261
  "div",
@@ -282,29 +287,20 @@ var InputTextarea = ({
282
287
  required: question.isQuestionMandatory,
283
288
  "aria-required": question.isQuestionMandatory,
284
289
  "aria-invalid": question.hasValidationError,
285
- maxLength: ((_a = question.questionExtraAttribute) == null ? void 0 : _a.answerMaxLength) || defaultMaxLength,
286
290
  "aria-describedby": [question.aboutText ? aboutId : null, question.hasValidationError ? errorId : null].filter(Boolean).join(" ") || void 0,
287
291
  id: inputId
288
292
  }
289
293
  ),
290
294
  /* @__PURE__ */ jsxs4("div", { className: "pts-textarea-counter-error-container", children: [
291
- question.hasValidationError && /* @__PURE__ */ jsxs4("div", { className: "pts-root-error", id: errorId, children: [
295
+ !isTooLong && question.hasValidationError && /* @__PURE__ */ jsxs4("div", { className: "pts-root-error", id: errorId, children: [
292
296
  /* @__PURE__ */ jsx4("span", { "aria-label": "Felmeddelande.", className: "errorDot", children: "!" }),
293
297
  /* @__PURE__ */ jsx4("span", { className: "errorText", children: question.validationDefaultMessesege })
294
298
  ] }),
295
- !((_b = question.questionExtraAttribute) == null ? void 0 : _b.hideTextCounter) && /* @__PURE__ */ jsxs4(
296
- "div",
297
- {
298
- 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" : ""}`,
299
- children: [
300
- question.answer ? question.answer.length : 0,
301
- " av",
302
- " ",
303
- ((_e = question.questionExtraAttribute) == null ? void 0 : _e.answerMaxLength) || defaultMaxLength,
304
- " tecken"
305
- ]
306
- }
307
- )
299
+ isTooLong && question.hasValidationError && /* @__PURE__ */ jsxs4("div", { className: "pts-root-error", id: errorId, children: [
300
+ /* @__PURE__ */ jsx4("span", { "aria-label": "Felmeddelande.", className: "errorDot", children: "!" }),
301
+ /* @__PURE__ */ jsx4("span", { className: "errorText", children: maxLengthErrorText })
302
+ ] }),
303
+ !((_e = question.questionExtraAttribute) == null ? void 0 : _e.hideTextCounter) && /* @__PURE__ */ jsx4("div", { "aria-live": "polite", className: `pts-character-counter`, children: counterText })
308
304
  ] })
309
305
  ]
310
306
  }
@@ -341,18 +337,22 @@ var TextFieldStandard = ({
341
337
  showPreview = false,
342
338
  activatedLanguage
343
339
  }) => {
344
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
340
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
345
341
  const questionId = `question-${question.id}`;
346
342
  const inputId = `textField-${question.id}`;
347
343
  const aboutId = `about-${question.id}`;
348
344
  const errorId = `error-${question.id}`;
349
- const defaultMaxLength = 1e3;
345
+ const defaultMaxLength = 100;
346
+ const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
347
+ const maxLength = (_d = (_c = question.questionExtraAttribute) == null ? void 0 : _c.answerMaxLength) != null ? _d : defaultMaxLength;
348
+ const isTooLong = answerLength > maxLength;
349
+ const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r max vara ${maxLength} tecken`;
350
350
  return /* @__PURE__ */ jsxs5(Fragment5, { children: [
351
351
  !showPreview && question.visible && /* @__PURE__ */ jsxs5(
352
352
  "div",
353
353
  {
354
354
  id: questionId,
355
- className: `pts-root-question pts-textField-container${((_a = question.questionExtraAttribute) == null ? void 0 : _a.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
355
+ className: `pts-root-question pts-textField-container${((_e = question.questionExtraAttribute) == null ? void 0 : _e.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
356
356
  children: [
357
357
  /* @__PURE__ */ jsxs5("label", { htmlFor: inputId, children: [
358
358
  question.questionLabel,
@@ -372,29 +372,33 @@ var TextFieldStandard = ({
372
372
  /* @__PURE__ */ jsx5(
373
373
  "input",
374
374
  {
375
- type: (_c = (_b = question.questionExtraAttribute) == null ? void 0 : _b.inputType) != null ? _c : "text",
376
- autoComplete: (_e = (_d = question.questionExtraAttribute) == null ? void 0 : _d.autoComplete) != null ? _e : void 0,
377
- inputMode: (_g = (_f = question.questionExtraAttribute) == null ? void 0 : _f.inputMode) != null ? _g : void 0,
375
+ type: (_g = (_f = question.questionExtraAttribute) == null ? void 0 : _f.inputType) != null ? _g : "text",
376
+ autoComplete: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.autoComplete) != null ? _i : void 0,
377
+ inputMode: (_k = (_j = question.questionExtraAttribute) == null ? void 0 : _j.inputMode) != null ? _k : void 0,
378
378
  name: `question-name-${question.id}`,
379
379
  className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
380
380
  onChange: (e) => handleQuestionInputChange(e, question),
381
381
  value: question.answer,
382
- maxLength: ((_h = question.questionExtraAttribute) == null ? void 0 : _h.answerMaxLength) || defaultMaxLength,
383
382
  id: inputId,
384
- disabled: (_i = question.questionExtraAttribute) == null ? void 0 : _i.disabled,
383
+ disabled: (_l = question.questionExtraAttribute) == null ? void 0 : _l.disabled,
385
384
  required: question.isQuestionMandatory,
386
385
  "aria-required": question.isQuestionMandatory,
387
386
  "aria-describedby": [question.aboutText ? aboutId : null].filter(Boolean).join(" ") || void 0,
388
387
  "aria-invalid": question.hasValidationError,
389
388
  "aria-errormessage": question.hasValidationError ? errorId : void 0,
390
- spellCheck: (_k = (_j = question.questionExtraAttribute) == null ? void 0 : _j.spellCheck) != null ? _k : void 0,
391
- autoCapitalize: (_m = (_l = question.questionExtraAttribute) == null ? void 0 : _l.autoCapitalize) != null ? _m : void 0
389
+ spellCheck: (_n = (_m = question.questionExtraAttribute) == null ? void 0 : _m.spellCheck) != null ? _n : void 0,
390
+ autoCapitalize: (_p = (_o = question.questionExtraAttribute) == null ? void 0 : _o.autoCapitalize) != null ? _p : void 0
392
391
  }
393
392
  ),
394
393
  question.hasValidationError && /* @__PURE__ */ jsxs5("div", { className: "pts-root-error", id: errorId, children: [
395
394
  /* @__PURE__ */ jsx5("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
396
395
  /* @__PURE__ */ jsx5("span", { className: "sr-only", children: "Valideringsfel" }),
397
396
  /* @__PURE__ */ jsx5("span", { className: "errorText", children: question.validationDefaultMessesege })
397
+ ] }),
398
+ isTooLong && question.hasValidationError && /* @__PURE__ */ jsxs5("div", { className: "pts-root-error", id: errorId, children: [
399
+ /* @__PURE__ */ jsx5("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
400
+ /* @__PURE__ */ jsx5("span", { className: "sr-only", children: "Valideringsfel" }),
401
+ /* @__PURE__ */ jsx5("span", { className: "errorText", children: maxLengthErrorText })
398
402
  ] })
399
403
  ]
400
404
  }
@@ -1108,7 +1112,7 @@ var PreviewSingleCheckbox = ({
1108
1112
  // src/helpers/hasQuestionValidationError/hasQuestionValidationError.tsx
1109
1113
  import { isValid, parseISO } from "date-fns";
1110
1114
  var hasQuestionValidationError = (question, questions) => {
1111
- var _a, _b, _c, _d, _e;
1115
+ var _a, _b, _c, _d, _e, _f;
1112
1116
  let error = false;
1113
1117
  if (question.isQuestionMandatory) {
1114
1118
  if (question.isTouched === false) {
@@ -1121,19 +1125,29 @@ var hasQuestionValidationError = (question, questions) => {
1121
1125
  error = true;
1122
1126
  }
1123
1127
  }
1124
- if (((_b = question.validationType) == null ? void 0 : _b.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1128
+ if ((_b = question.validationType) == null ? void 0 : _b.find(
1129
+ (e) => {
1130
+ var _a2;
1131
+ return e === "maxLength" && ((_a2 = question.questionExtraAttribute) == null ? void 0 : _a2.answerMaxLength);
1132
+ }
1133
+ )) {
1134
+ if (question.answer.length > question.questionExtraAttribute.answerMaxLength) {
1135
+ error = true;
1136
+ }
1137
+ }
1138
+ if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1125
1139
  const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
1126
1140
  if (!emailRegex.test(question.answer)) {
1127
1141
  error = true;
1128
1142
  }
1129
1143
  }
1130
- if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
1144
+ if (((_d = question.validationType) == null ? void 0 : _d.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
1131
1145
  const fourNumbersRegex = /^\d{4}$/.test(question.answer);
1132
1146
  if (!fourNumbersRegex) {
1133
1147
  error = true;
1134
1148
  }
1135
1149
  }
1136
- if (((_d = question.validationType) == null ? void 0 : _d.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
1150
+ if (((_e = question.validationType) == null ? void 0 : _e.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
1137
1151
  const regex = /^\d{4}-\d{2}-\d{2}$/;
1138
1152
  if (!regex.test(question.answer)) {
1139
1153
  error = true;
@@ -1147,16 +1161,18 @@ var hasQuestionValidationError = (question, questions) => {
1147
1161
  error = true;
1148
1162
  }
1149
1163
  }
1150
- const groupCheckError = (_e = question.validationType) == null ? void 0 : _e.find((e) => e.startsWith("groupCheck-"));
1164
+ const groupCheckError = (_f = question.validationType) == null ? void 0 : _f.find((e) => e.startsWith("groupCheck-"));
1151
1165
  if (groupCheckError) {
1152
1166
  const ids = groupCheckError.replace("groupCheck-", "").split("-");
1153
- const relatedAnswers = ids.map((id) => {
1154
- var _a2;
1155
- return (_a2 = questions.find((q) => {
1156
- var _a3;
1157
- return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
1158
- })) == null ? void 0 : _a2.answer;
1159
- });
1167
+ const relatedAnswers = ids.map(
1168
+ (id) => {
1169
+ var _a2;
1170
+ return (_a2 = questions.find((q) => {
1171
+ var _a3;
1172
+ return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
1173
+ })) == null ? void 0 : _a2.answer;
1174
+ }
1175
+ );
1160
1176
  const currentAnswer = question.answer;
1161
1177
  const allAnswers = [...relatedAnswers, currentAnswer];
1162
1178
  if (allAnswers.every((ans) => ans === "")) {
@@ -2044,7 +2060,7 @@ var CookieBanner_default = CookieBanner;
2044
2060
 
2045
2061
  // src/components/layout/FooterStandard/FooterStandard.tsx
2046
2062
  import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
2047
- var Footer = ({ activatedLanguage = "sv", appUsesCookies = false, openCookieBanner }) => {
2063
+ var Footer = ({ activatedLanguage = "sv" }) => {
2048
2064
  return /* @__PURE__ */ jsxs14("footer", { className: "pts-footer-container", children: [
2049
2065
  /* @__PURE__ */ jsx16("div", { className: "pts-footer-slogan-text-container", children: /* @__PURE__ */ jsx16("p", { className: "pts-footer-slogan-text", children: activatedLanguage === "sv" ? "S\xE4ker och tillg\xE4nglig kommunikation f\xF6r Sverige" : "Secure and accessible communication for Sweden" }) }),
2050
2066
  /* @__PURE__ */ jsxs14("div", { className: "pts-footer-content", children: [
@@ -2113,19 +2129,7 @@ var Footer = ({ activatedLanguage = "sv", appUsesCookies = false, openCookieBann
2113
2129
  ]
2114
2130
  }
2115
2131
  ) }),
2116
- /* @__PURE__ */ jsx16("li", { children: appUsesCookies ? /* @__PURE__ */ jsxs14(
2117
- "button",
2118
- {
2119
- type: "button",
2120
- "aria-controls": "cookie-banner",
2121
- onClick: openCookieBanner,
2122
- className: "pts-footer-button",
2123
- children: [
2124
- /* @__PURE__ */ jsx16("span", { className: "sr-only", children: activatedLanguage === "en" ? "PTS Cookies (opens cookie banner)" : "PTS Kakor (\xF6ppnar kakbanner)" }),
2125
- /* @__PURE__ */ jsx16("span", { "aria-hidden": "true", children: activatedLanguage === "en" ? "Cookies" : "Kakor" })
2126
- ]
2127
- }
2128
- ) : /* @__PURE__ */ jsxs14(
2132
+ /* @__PURE__ */ jsx16("li", { children: /* @__PURE__ */ jsxs14(
2129
2133
  "a",
2130
2134
  {
2131
2135
  href: activatedLanguage === "en" ? "https://pts.se/en/cookies-eservices" : "https://www.pts.se/kakor-etjanster",