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.d.mts CHANGED
@@ -733,6 +733,8 @@ declare const CookieBanner: React$1.FC<CookieBannerProps>;
733
733
 
734
734
  interface FooterProps {
735
735
  activatedLanguage?: string;
736
+ appUsesCookies?: boolean;
737
+ openCookieBanner?: () => void;
736
738
  }
737
739
 
738
740
  declare const Footer: FC<FooterProps>;
package/dist/index.d.ts CHANGED
@@ -733,6 +733,8 @@ declare const CookieBanner: React$1.FC<CookieBannerProps>;
733
733
 
734
734
  interface FooterProps {
735
735
  activatedLanguage?: string;
736
+ appUsesCookies?: boolean;
737
+ openCookieBanner?: () => void;
736
738
  }
737
739
 
738
740
  declare const Footer: FC<FooterProps>;
package/dist/index.js CHANGED
@@ -333,11 +333,6 @@ var InputTextarea = ({
333
333
  const aboutId = `about-${question.id}`;
334
334
  const errorId = `error-${question.id}`;
335
335
  const defaultMaxLength = 1e3;
336
- const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
337
- const maxLength = (_d = (_c = question.questionExtraAttribute) == null ? void 0 : _c.answerMaxLength) != null ? _d : defaultMaxLength;
338
- const isTooLong = answerLength > maxLength;
339
- const counterText = activatedLanguage === "en" ? `${answerLength} of ${maxLength} characters` : `${answerLength} av ${maxLength} tecken`;
340
- const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r max vara ${maxLength} tecken`;
341
336
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
342
337
  !showPreview && question.visible && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
343
338
  "div",
@@ -369,20 +364,29 @@ var InputTextarea = ({
369
364
  required: question.isQuestionMandatory,
370
365
  "aria-required": question.isQuestionMandatory,
371
366
  "aria-invalid": question.hasValidationError,
367
+ maxLength: ((_a = question.questionExtraAttribute) == null ? void 0 : _a.answerMaxLength) || defaultMaxLength,
372
368
  "aria-describedby": [question.aboutText ? aboutId : null, question.hasValidationError ? errorId : null].filter(Boolean).join(" ") || void 0,
373
369
  id: inputId
374
370
  }
375
371
  ),
376
372
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pts-textarea-counter-error-container", children: [
377
- !isTooLong && question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
373
+ question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
378
374
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-label": "Felmeddelande.", className: "errorDot", children: "!" }),
379
375
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "errorText", children: question.validationDefaultMessesege })
380
376
  ] }),
381
- isTooLong && question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
382
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-label": "Felmeddelande.", className: "errorDot", children: "!" }),
383
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "errorText", children: maxLengthErrorText })
384
- ] }),
385
- !((_e = question.questionExtraAttribute) == null ? void 0 : _e.hideTextCounter) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "aria-live": "polite", className: `pts-character-counter`, children: counterText })
377
+ !((_b = question.questionExtraAttribute) == null ? void 0 : _b.hideTextCounter) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
378
+ "div",
379
+ {
380
+ 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" : ""}`,
381
+ children: [
382
+ question.answer ? question.answer.length : 0,
383
+ " av",
384
+ " ",
385
+ ((_e = question.questionExtraAttribute) == null ? void 0 : _e.answerMaxLength) || defaultMaxLength,
386
+ " tecken"
387
+ ]
388
+ }
389
+ )
386
390
  ] })
387
391
  ]
388
392
  }
@@ -1186,7 +1190,7 @@ var PreviewSingleCheckbox = ({
1186
1190
  // src/helpers/hasQuestionValidationError/hasQuestionValidationError.tsx
1187
1191
  var import_date_fns = require("date-fns");
1188
1192
  var hasQuestionValidationError = (question, questions) => {
1189
- var _a, _b, _c, _d, _e, _f;
1193
+ var _a, _b, _c, _d, _e;
1190
1194
  let error = false;
1191
1195
  if (question.isQuestionMandatory) {
1192
1196
  if (question.isTouched === false) {
@@ -1199,29 +1203,19 @@ var hasQuestionValidationError = (question, questions) => {
1199
1203
  error = true;
1200
1204
  }
1201
1205
  }
1202
- if ((_b = question.validationType) == null ? void 0 : _b.find(
1203
- (e) => {
1204
- var _a2;
1205
- return e === "maxLength" && ((_a2 = question.questionExtraAttribute) == null ? void 0 : _a2.answerMaxLength);
1206
- }
1207
- )) {
1208
- if (question.answer.length > question.questionExtraAttribute.answerMaxLength) {
1209
- error = true;
1210
- }
1211
- }
1212
- if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1206
+ if (((_b = question.validationType) == null ? void 0 : _b.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
1213
1207
  const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
1214
1208
  if (!emailRegex.test(question.answer)) {
1215
1209
  error = true;
1216
1210
  }
1217
1211
  }
1218
- if (((_d = question.validationType) == null ? void 0 : _d.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
1212
+ if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
1219
1213
  const fourNumbersRegex = /^\d{4}$/.test(question.answer);
1220
1214
  if (!fourNumbersRegex) {
1221
1215
  error = true;
1222
1216
  }
1223
1217
  }
1224
- if (((_e = question.validationType) == null ? void 0 : _e.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
1218
+ if (((_d = question.validationType) == null ? void 0 : _d.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
1225
1219
  const regex = /^\d{4}-\d{2}-\d{2}$/;
1226
1220
  if (!regex.test(question.answer)) {
1227
1221
  error = true;
@@ -1235,18 +1229,16 @@ var hasQuestionValidationError = (question, questions) => {
1235
1229
  error = true;
1236
1230
  }
1237
1231
  }
1238
- const groupCheckError = (_f = question.validationType) == null ? void 0 : _f.find((e) => e.startsWith("groupCheck-"));
1232
+ const groupCheckError = (_e = question.validationType) == null ? void 0 : _e.find((e) => e.startsWith("groupCheck-"));
1239
1233
  if (groupCheckError) {
1240
1234
  const ids = groupCheckError.replace("groupCheck-", "").split("-");
1241
- const relatedAnswers = ids.map(
1242
- (id) => {
1243
- var _a2;
1244
- return (_a2 = questions.find((q) => {
1245
- var _a3;
1246
- return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
1247
- })) == null ? void 0 : _a2.answer;
1248
- }
1249
- );
1235
+ const relatedAnswers = ids.map((id) => {
1236
+ var _a2;
1237
+ return (_a2 = questions.find((q) => {
1238
+ var _a3;
1239
+ return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
1240
+ })) == null ? void 0 : _a2.answer;
1241
+ });
1250
1242
  const currentAnswer = question.answer;
1251
1243
  const allAnswers = [...relatedAnswers, currentAnswer];
1252
1244
  if (allAnswers.every((ans) => ans === "")) {
@@ -2131,7 +2123,7 @@ var CookieBanner_default = CookieBanner;
2131
2123
 
2132
2124
  // src/components/layout/FooterStandard/FooterStandard.tsx
2133
2125
  var import_jsx_runtime16 = require("react/jsx-runtime");
2134
- var Footer = ({ activatedLanguage = "sv" }) => {
2126
+ var Footer = ({ activatedLanguage = "sv", appUsesCookies = false, openCookieBanner }) => {
2135
2127
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("footer", { className: "pts-footer-container", children: [
2136
2128
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "pts-footer-slogan-text-container", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "pts-footer-slogan-text", children: activatedLanguage === "sv" ? "S\xE4ker och tillg\xE4nglig kommunikation f\xF6r Sverige" : "Secure and accessible communication for Sweden" }) }),
2137
2129
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "pts-footer-content", children: [
@@ -2200,7 +2192,19 @@ var Footer = ({ activatedLanguage = "sv" }) => {
2200
2192
  ]
2201
2193
  }
2202
2194
  ) }),
2203
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2195
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { children: appUsesCookies ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2196
+ "button",
2197
+ {
2198
+ type: "button",
2199
+ "aria-controls": "cookie-banner",
2200
+ onClick: openCookieBanner,
2201
+ className: "pts-footer-button",
2202
+ children: [
2203
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "sr-only", children: activatedLanguage === "en" ? "PTS Cookies (opens cookie banner)" : "PTS Kakor (\xF6ppnar kakbanner)" }),
2204
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { "aria-hidden": "true", children: activatedLanguage === "en" ? "Cookies" : "Kakor" })
2205
+ ]
2206
+ }
2207
+ ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2204
2208
  "a",
2205
2209
  {
2206
2210
  href: activatedLanguage === "en" ? "https://pts.se/en/cookies-eservices" : "https://www.pts.se/kakor-etjanster",