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

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,11 +251,6 @@ 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`;
259
254
  return /* @__PURE__ */ jsxs4(Fragment4, { children: [
260
255
  !showPreview && question.visible && /* @__PURE__ */ jsxs4(
261
256
  "div",
@@ -287,20 +282,29 @@ var InputTextarea = ({
287
282
  required: question.isQuestionMandatory,
288
283
  "aria-required": question.isQuestionMandatory,
289
284
  "aria-invalid": question.hasValidationError,
285
+ maxLength: ((_a = question.questionExtraAttribute) == null ? void 0 : _a.answerMaxLength) || defaultMaxLength,
290
286
  "aria-describedby": [question.aboutText ? aboutId : null, question.hasValidationError ? errorId : null].filter(Boolean).join(" ") || void 0,
291
287
  id: inputId
292
288
  }
293
289
  ),
294
290
  /* @__PURE__ */ jsxs4("div", { className: "pts-textarea-counter-error-container", children: [
295
- !isTooLong && question.hasValidationError && /* @__PURE__ */ jsxs4("div", { className: "pts-root-error", id: errorId, children: [
291
+ question.hasValidationError && /* @__PURE__ */ jsxs4("div", { className: "pts-root-error", id: errorId, children: [
296
292
  /* @__PURE__ */ jsx4("span", { "aria-label": "Felmeddelande.", className: "errorDot", children: "!" }),
297
293
  /* @__PURE__ */ jsx4("span", { className: "errorText", children: question.validationDefaultMessesege })
298
294
  ] }),
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 })
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
+ )
304
308
  ] })
305
309
  ]
306
310
  }
@@ -1104,7 +1108,7 @@ var PreviewSingleCheckbox = ({
1104
1108
  // src/helpers/hasQuestionValidationError/hasQuestionValidationError.tsx
1105
1109
  import { isValid, parseISO } from "date-fns";
1106
1110
  var hasQuestionValidationError = (question, questions) => {
1107
- var _a, _b, _c, _d, _e, _f;
1111
+ var _a, _b, _c, _d, _e;
1108
1112
  let error = false;
1109
1113
  if (question.isQuestionMandatory) {
1110
1114
  if (question.isTouched === false) {
@@ -1117,29 +1121,19 @@ var hasQuestionValidationError = (question, questions) => {
1117
1121
  error = true;
1118
1122
  }
1119
1123
  }
1120
- if ((_b = question.validationType) == null ? void 0 : _b.find(
1121
- (e) => {
1122
- var _a2;
1123
- return e === "maxLength" && ((_a2 = question.questionExtraAttribute) == null ? void 0 : _a2.answerMaxLength);
1124
- }
1125
- )) {
1126
- if (question.answer.length > question.questionExtraAttribute.answerMaxLength) {
1127
- error = true;
1128
- }
1129
- }
1130
- if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1124
+ if (((_b = question.validationType) == null ? void 0 : _b.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1131
1125
  const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
1132
1126
  if (!emailRegex.test(question.answer)) {
1133
1127
  error = true;
1134
1128
  }
1135
1129
  }
1136
- if (((_d = question.validationType) == null ? void 0 : _d.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
1130
+ if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
1137
1131
  const fourNumbersRegex = /^\d{4}$/.test(question.answer);
1138
1132
  if (!fourNumbersRegex) {
1139
1133
  error = true;
1140
1134
  }
1141
1135
  }
1142
- if (((_e = question.validationType) == null ? void 0 : _e.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
1136
+ if (((_d = question.validationType) == null ? void 0 : _d.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
1143
1137
  const regex = /^\d{4}-\d{2}-\d{2}$/;
1144
1138
  if (!regex.test(question.answer)) {
1145
1139
  error = true;
@@ -1153,18 +1147,16 @@ var hasQuestionValidationError = (question, questions) => {
1153
1147
  error = true;
1154
1148
  }
1155
1149
  }
1156
- const groupCheckError = (_f = question.validationType) == null ? void 0 : _f.find((e) => e.startsWith("groupCheck-"));
1150
+ const groupCheckError = (_e = question.validationType) == null ? void 0 : _e.find((e) => e.startsWith("groupCheck-"));
1157
1151
  if (groupCheckError) {
1158
1152
  const ids = groupCheckError.replace("groupCheck-", "").split("-");
1159
- const relatedAnswers = ids.map(
1160
- (id) => {
1161
- var _a2;
1162
- return (_a2 = questions.find((q) => {
1163
- var _a3;
1164
- return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
1165
- })) == null ? void 0 : _a2.answer;
1166
- }
1167
- );
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
+ });
1168
1160
  const currentAnswer = question.answer;
1169
1161
  const allAnswers = [...relatedAnswers, currentAnswer];
1170
1162
  if (allAnswers.every((ans) => ans === "")) {
@@ -2052,7 +2044,7 @@ var CookieBanner_default = CookieBanner;
2052
2044
 
2053
2045
  // src/components/layout/FooterStandard/FooterStandard.tsx
2054
2046
  import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
2055
- var Footer = ({ activatedLanguage = "sv" }) => {
2047
+ var Footer = ({ activatedLanguage = "sv", appUsesCookies = false, openCookieBanner }) => {
2056
2048
  return /* @__PURE__ */ jsxs14("footer", { className: "pts-footer-container", children: [
2057
2049
  /* @__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" }) }),
2058
2050
  /* @__PURE__ */ jsxs14("div", { className: "pts-footer-content", children: [
@@ -2121,7 +2113,19 @@ var Footer = ({ activatedLanguage = "sv" }) => {
2121
2113
  ]
2122
2114
  }
2123
2115
  ) }),
2124
- /* @__PURE__ */ jsx16("li", { children: /* @__PURE__ */ jsxs14(
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(
2125
2129
  "a",
2126
2130
  {
2127
2131
  href: activatedLanguage === "en" ? "https://pts.se/en/cookies-eservices" : "https://www.pts.se/kakor-etjanster",