optimized-react-component-library-xyz123 0.19.18 → 0.19.20

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
@@ -327,15 +327,12 @@ var InputTextarea = ({
327
327
  showPreview = false,
328
328
  activatedLanguage
329
329
  }) => {
330
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
330
+ var _a, _b, _c, _d, _e;
331
331
  const questionId = `question-${question.id}`;
332
332
  const inputId = `textarea-${question.id}`;
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
336
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
340
337
  !showPreview && question.visible && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
341
338
  "div",
@@ -367,29 +364,25 @@ var InputTextarea = ({
367
364
  required: question.isQuestionMandatory,
368
365
  "aria-required": question.isQuestionMandatory,
369
366
  "aria-invalid": question.hasValidationError,
370
- maxLength: ((_e = question.questionExtraAttribute) == null ? void 0 : _e.answerMaxLength) || defaultMaxLength,
367
+ maxLength: ((_a = question.questionExtraAttribute) == null ? void 0 : _a.answerMaxLength) || defaultMaxLength,
371
368
  "aria-describedby": [question.aboutText ? aboutId : null, question.hasValidationError ? errorId : null].filter(Boolean).join(" ") || void 0,
372
369
  id: inputId
373
370
  }
374
371
  ),
375
372
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pts-textarea-counter-error-container", children: [
376
- !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: [
377
374
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-label": "Felmeddelande.", className: "errorDot", children: "!" }),
378
375
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "errorText", children: question.validationDefaultMessesege })
379
376
  ] }),
380
- isTooLong && question.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pts-root-error", id: errorId, children: [
381
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-label": "Felmeddelande.", className: "errorDot", children: "!" }),
382
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "errorText", children: "Texten f\xE5r max vara 1000 tecken" })
383
- ] }),
384
- !((_f = question.questionExtraAttribute) == null ? void 0 : _f.hideTextCounter) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
377
+ !((_b = question.questionExtraAttribute) == null ? void 0 : _b.hideTextCounter) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
385
378
  "div",
386
379
  {
387
- className: `pts-character-counter ${question.answer && (((_g = question.questionExtraAttribute) == null ? void 0 : _g.answerMaxLength) || defaultMaxLength) && question.answer.length > (((_h = question.questionExtraAttribute) == null ? void 0 : _h.answerMaxLength) || defaultMaxLength) ? "error" : ""}`,
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" : ""}`,
388
381
  children: [
389
382
  question.answer ? question.answer.length : 0,
390
383
  " av",
391
384
  " ",
392
- ((_i = question.questionExtraAttribute) == null ? void 0 : _i.answerMaxLength) || defaultMaxLength,
385
+ ((_e = question.questionExtraAttribute) == null ? void 0 : _e.answerMaxLength) || defaultMaxLength,
393
386
  " tecken"
394
387
  ]
395
388
  }
@@ -1197,7 +1190,7 @@ var PreviewSingleCheckbox = ({
1197
1190
  // src/helpers/hasQuestionValidationError/hasQuestionValidationError.tsx
1198
1191
  var import_date_fns = require("date-fns");
1199
1192
  var hasQuestionValidationError = (question, questions) => {
1200
- var _a, _b, _c, _d, _e, _f;
1193
+ var _a, _b, _c, _d, _e;
1201
1194
  let error = false;
1202
1195
  if (question.isQuestionMandatory) {
1203
1196
  if (question.isTouched === false) {
@@ -1210,29 +1203,19 @@ var hasQuestionValidationError = (question, questions) => {
1210
1203
  error = true;
1211
1204
  }
1212
1205
  }
1213
- if ((_b = question.validationType) == null ? void 0 : _b.find(
1214
- (e) => {
1215
- var _a2;
1216
- return e === "maxLength" && ((_a2 = question.questionExtraAttribute) == null ? void 0 : _a2.answerMaxLength);
1217
- }
1218
- )) {
1219
- if (question.answer.length > question.questionExtraAttribute.answerMaxLength) {
1220
- error = true;
1221
- }
1222
- }
1223
- 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 !== "")) {
1224
1207
  const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
1225
1208
  if (!emailRegex.test(question.answer)) {
1226
1209
  error = true;
1227
1210
  }
1228
1211
  }
1229
- 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 !== "")) {
1230
1213
  const fourNumbersRegex = /^\d{4}$/.test(question.answer);
1231
1214
  if (!fourNumbersRegex) {
1232
1215
  error = true;
1233
1216
  }
1234
1217
  }
1235
- 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 !== "") {
1236
1219
  const regex = /^\d{4}-\d{2}-\d{2}$/;
1237
1220
  if (!regex.test(question.answer)) {
1238
1221
  error = true;
@@ -1246,18 +1229,16 @@ var hasQuestionValidationError = (question, questions) => {
1246
1229
  error = true;
1247
1230
  }
1248
1231
  }
1249
- 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-"));
1250
1233
  if (groupCheckError) {
1251
1234
  const ids = groupCheckError.replace("groupCheck-", "").split("-");
1252
- const relatedAnswers = ids.map(
1253
- (id) => {
1254
- var _a2;
1255
- return (_a2 = questions.find((q) => {
1256
- var _a3;
1257
- return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
1258
- })) == null ? void 0 : _a2.answer;
1259
- }
1260
- );
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
+ });
1261
1242
  const currentAnswer = question.answer;
1262
1243
  const allAnswers = [...relatedAnswers, currentAnswer];
1263
1244
  if (allAnswers.every((ans) => ans === "")) {
@@ -2142,7 +2123,7 @@ var CookieBanner_default = CookieBanner;
2142
2123
 
2143
2124
  // src/components/layout/FooterStandard/FooterStandard.tsx
2144
2125
  var import_jsx_runtime16 = require("react/jsx-runtime");
2145
- var Footer = ({ activatedLanguage = "sv" }) => {
2126
+ var Footer = ({ activatedLanguage = "sv", appUsesCookies = false, openCookieBanner }) => {
2146
2127
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("footer", { className: "pts-footer-container", children: [
2147
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" }) }),
2148
2129
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "pts-footer-content", children: [
@@ -2211,7 +2192,19 @@ var Footer = ({ activatedLanguage = "sv" }) => {
2211
2192
  ]
2212
2193
  }
2213
2194
  ) }),
2214
- /* @__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": activatedLanguage === "en" ? "Kakbanner" : '"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)(
2215
2208
  "a",
2216
2209
  {
2217
2210
  href: activatedLanguage === "en" ? "https://pts.se/en/cookies-eservices" : "https://www.pts.se/kakor-etjanster",