optimized-react-component-library-xyz123 0.19.21 → 0.19.23
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 +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +59 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/css/mobileView.css +1 -2
- package/src/css/styles.css +3 -30
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
|
-
|
|
296
|
-
"
|
|
297
|
-
{
|
|
298
|
-
|
|
299
|
-
|
|
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,21 @@ 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;
|
|
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
|
|
345
|
+
const answerLength = (_b = (_a = question.answer) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
346
|
+
const maxLength = 100;
|
|
347
|
+
const isTooLong = answerLength > maxLength;
|
|
348
|
+
const maxLengthErrorText = activatedLanguage === "en" ? `The text must be ${maxLength} characters or less` : `Texten f\xE5r max vara ${maxLength} tecken`;
|
|
350
349
|
return /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
351
350
|
!showPreview && question.visible && /* @__PURE__ */ jsxs5(
|
|
352
351
|
"div",
|
|
353
352
|
{
|
|
354
353
|
id: questionId,
|
|
355
|
-
className: `pts-root-question pts-textField-container${((
|
|
354
|
+
className: `pts-root-question pts-textField-container${((_c = question.questionExtraAttribute) == null ? void 0 : _c.disabled) ? " pts-textField-disabled" : ""}${question.aboutText ? " pts-question-hasAbout" : ""}`.trim(),
|
|
356
355
|
children: [
|
|
357
356
|
/* @__PURE__ */ jsxs5("label", { htmlFor: inputId, children: [
|
|
358
357
|
question.questionLabel,
|
|
@@ -372,29 +371,33 @@ var TextFieldStandard = ({
|
|
|
372
371
|
/* @__PURE__ */ jsx5(
|
|
373
372
|
"input",
|
|
374
373
|
{
|
|
375
|
-
type: (
|
|
376
|
-
autoComplete: (
|
|
377
|
-
inputMode: (
|
|
374
|
+
type: (_e = (_d = question.questionExtraAttribute) == null ? void 0 : _d.inputType) != null ? _e : "text",
|
|
375
|
+
autoComplete: (_g = (_f = question.questionExtraAttribute) == null ? void 0 : _f.autoComplete) != null ? _g : void 0,
|
|
376
|
+
inputMode: (_i = (_h = question.questionExtraAttribute) == null ? void 0 : _h.inputMode) != null ? _i : void 0,
|
|
378
377
|
name: `question-name-${question.id}`,
|
|
379
378
|
className: question.hasValidationError ? "pts-root-question-input-error-border" : void 0,
|
|
380
379
|
onChange: (e) => handleQuestionInputChange(e, question),
|
|
381
380
|
value: question.answer,
|
|
382
|
-
maxLength: ((_h = question.questionExtraAttribute) == null ? void 0 : _h.answerMaxLength) || defaultMaxLength,
|
|
383
381
|
id: inputId,
|
|
384
|
-
disabled: (
|
|
382
|
+
disabled: (_j = question.questionExtraAttribute) == null ? void 0 : _j.disabled,
|
|
385
383
|
required: question.isQuestionMandatory,
|
|
386
384
|
"aria-required": question.isQuestionMandatory,
|
|
387
385
|
"aria-describedby": [question.aboutText ? aboutId : null].filter(Boolean).join(" ") || void 0,
|
|
388
386
|
"aria-invalid": question.hasValidationError,
|
|
389
387
|
"aria-errormessage": question.hasValidationError ? errorId : void 0,
|
|
390
|
-
spellCheck: (
|
|
391
|
-
autoCapitalize: (
|
|
388
|
+
spellCheck: (_l = (_k = question.questionExtraAttribute) == null ? void 0 : _k.spellCheck) != null ? _l : void 0,
|
|
389
|
+
autoCapitalize: (_n = (_m = question.questionExtraAttribute) == null ? void 0 : _m.autoCapitalize) != null ? _n : void 0
|
|
392
390
|
}
|
|
393
391
|
),
|
|
394
392
|
question.hasValidationError && /* @__PURE__ */ jsxs5("div", { className: "pts-root-error", id: errorId, children: [
|
|
395
393
|
/* @__PURE__ */ jsx5("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
|
|
396
394
|
/* @__PURE__ */ jsx5("span", { className: "sr-only", children: "Valideringsfel" }),
|
|
397
395
|
/* @__PURE__ */ jsx5("span", { className: "errorText", children: question.validationDefaultMessesege })
|
|
396
|
+
] }),
|
|
397
|
+
isTooLong && question.hasValidationError && /* @__PURE__ */ jsxs5("div", { className: "pts-root-error", id: errorId, children: [
|
|
398
|
+
/* @__PURE__ */ jsx5("span", { "aria-hidden": true, className: "errorDot", children: "!" }),
|
|
399
|
+
/* @__PURE__ */ jsx5("span", { className: "sr-only", children: "Valideringsfel" }),
|
|
400
|
+
/* @__PURE__ */ jsx5("span", { className: "errorText", children: maxLengthErrorText })
|
|
398
401
|
] })
|
|
399
402
|
]
|
|
400
403
|
}
|
|
@@ -1108,7 +1111,7 @@ var PreviewSingleCheckbox = ({
|
|
|
1108
1111
|
// src/helpers/hasQuestionValidationError/hasQuestionValidationError.tsx
|
|
1109
1112
|
import { isValid, parseISO } from "date-fns";
|
|
1110
1113
|
var hasQuestionValidationError = (question, questions) => {
|
|
1111
|
-
var _a, _b, _c, _d, _e;
|
|
1114
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1112
1115
|
let error = false;
|
|
1113
1116
|
if (question.isQuestionMandatory) {
|
|
1114
1117
|
if (question.isTouched === false) {
|
|
@@ -1121,19 +1124,34 @@ var hasQuestionValidationError = (question, questions) => {
|
|
|
1121
1124
|
error = true;
|
|
1122
1125
|
}
|
|
1123
1126
|
}
|
|
1124
|
-
if ((
|
|
1127
|
+
if ((_b = question.validationType) == null ? void 0 : _b.find(
|
|
1128
|
+
(e) => {
|
|
1129
|
+
var _a2;
|
|
1130
|
+
return e === "maxLength" && ((_a2 = question.questionExtraAttribute) == null ? void 0 : _a2.answerMaxLength);
|
|
1131
|
+
}
|
|
1132
|
+
)) {
|
|
1133
|
+
if (question.answer.length > question.questionExtraAttribute.answerMaxLength) {
|
|
1134
|
+
error = true;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
if (question.questionType === "TextField") {
|
|
1138
|
+
if (question.answer.length > 100) {
|
|
1139
|
+
error = true;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
if (((_c = question.validationType) == null ? void 0 : _c.find((e) => e === "email")) && (question.isQuestionMandatory || question.answer !== "")) {
|
|
1125
1143
|
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
1126
1144
|
if (!emailRegex.test(question.answer)) {
|
|
1127
1145
|
error = true;
|
|
1128
1146
|
}
|
|
1129
1147
|
}
|
|
1130
|
-
if (((
|
|
1148
|
+
if (((_d = question.validationType) == null ? void 0 : _d.find((e) => e === "fourNumbers")) && (question.isQuestionMandatory || question.answer !== "")) {
|
|
1131
1149
|
const fourNumbersRegex = /^\d{4}$/.test(question.answer);
|
|
1132
1150
|
if (!fourNumbersRegex) {
|
|
1133
1151
|
error = true;
|
|
1134
1152
|
}
|
|
1135
1153
|
}
|
|
1136
|
-
if (((
|
|
1154
|
+
if (((_e = question.validationType) == null ? void 0 : _e.find((e) => e === "isDateFormatValid")) && question.answer !== "") {
|
|
1137
1155
|
const regex = /^\d{4}-\d{2}-\d{2}$/;
|
|
1138
1156
|
if (!regex.test(question.answer)) {
|
|
1139
1157
|
error = true;
|
|
@@ -1147,16 +1165,18 @@ var hasQuestionValidationError = (question, questions) => {
|
|
|
1147
1165
|
error = true;
|
|
1148
1166
|
}
|
|
1149
1167
|
}
|
|
1150
|
-
const groupCheckError = (
|
|
1168
|
+
const groupCheckError = (_f = question.validationType) == null ? void 0 : _f.find((e) => e.startsWith("groupCheck-"));
|
|
1151
1169
|
if (groupCheckError) {
|
|
1152
1170
|
const ids = groupCheckError.replace("groupCheck-", "").split("-");
|
|
1153
|
-
const relatedAnswers = ids.map(
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1171
|
+
const relatedAnswers = ids.map(
|
|
1172
|
+
(id) => {
|
|
1173
|
+
var _a2;
|
|
1174
|
+
return (_a2 = questions.find((q) => {
|
|
1175
|
+
var _a3;
|
|
1176
|
+
return ((_a3 = q.id) == null ? void 0 : _a3.toString()) === id;
|
|
1177
|
+
})) == null ? void 0 : _a2.answer;
|
|
1178
|
+
}
|
|
1179
|
+
);
|
|
1160
1180
|
const currentAnswer = question.answer;
|
|
1161
1181
|
const allAnswers = [...relatedAnswers, currentAnswer];
|
|
1162
1182
|
if (allAnswers.every((ans) => ans === "")) {
|
|
@@ -2044,7 +2064,7 @@ var CookieBanner_default = CookieBanner;
|
|
|
2044
2064
|
|
|
2045
2065
|
// src/components/layout/FooterStandard/FooterStandard.tsx
|
|
2046
2066
|
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2047
|
-
var Footer = ({ activatedLanguage = "sv"
|
|
2067
|
+
var Footer = ({ activatedLanguage = "sv" }) => {
|
|
2048
2068
|
return /* @__PURE__ */ jsxs14("footer", { className: "pts-footer-container", children: [
|
|
2049
2069
|
/* @__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
2070
|
/* @__PURE__ */ jsxs14("div", { className: "pts-footer-content", children: [
|
|
@@ -2113,19 +2133,7 @@ var Footer = ({ activatedLanguage = "sv", appUsesCookies = false, openCookieBann
|
|
|
2113
2133
|
]
|
|
2114
2134
|
}
|
|
2115
2135
|
) }),
|
|
2116
|
-
/* @__PURE__ */ jsx16("li", { children:
|
|
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(
|
|
2136
|
+
/* @__PURE__ */ jsx16("li", { children: /* @__PURE__ */ jsxs14(
|
|
2129
2137
|
"a",
|
|
2130
2138
|
{
|
|
2131
2139
|
href: activatedLanguage === "en" ? "https://pts.se/en/cookies-eservices" : "https://www.pts.se/kakor-etjanster",
|